MyAdapter(Context context, List<ContentItem> objects) { super(context, 0, objects); mTypeFaceLight = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); mTypeFaceRegular = Typeface.createFromAsset(context.getAssets(), "OpenSans-Regular.ttf"); }
public BarChartItem(ChartData<?> cd, Context c) { super(cd); mTf = Typeface.createFromAsset(c.getAssets(), "OpenSans-Regular.ttf"); }
public LineChartItem(ChartData<?> cd, Context c) { super(cd); mTf = Typeface.createFromAsset(c.getAssets(), "OpenSans-Regular.ttf"); }
@Override public Typeface getTypeface(Context context) { if (typeface == null) { try { typeface = Typeface.createFromAsset(context.getAssets(), "fonts/" + TTF_FILE); } catch (Exception e) { return null; } } return typeface; }
/** * Returns typeface from name. */ private static Typeface getTypeface(final Context context, final String name) { return Typeface.createFromAsset(context.getAssets(), name); } }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); tfRegular = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); tfLight = Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"); }
public PieChartItem(ChartData<?> cd, Context c) { super(cd); mTf = Typeface.createFromAsset(c.getAssets(), "OpenSans-Regular.ttf"); mCenterText = generateCenterText(); }
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Regular.ttf"); return super.onCreateView(inflater, container, savedInstanceState); }
public RadarMarkerView(Context context, int layoutResource) { super(context, layoutResource); tvContent = findViewById(R.id.tvContent); tvContent.setTypeface(Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf")); }
private Typeface getTypeFaceFromAsset(String fontPath) { if (fontPath != null) { return Typeface.createFromAsset( getContext().getAssets(), fontPath); } return null; }
private Typeface getFontFamily(String fontFamily) { Typeface defaultTypeface = fontFamilies.get(fontFamily); if (defaultTypeface != null) { return defaultTypeface; } Typeface typeface = null; if (delegate != null) { typeface = delegate.fetchFont(fontFamily); } if (delegate != null && typeface == null) { String path = delegate.getFontPath(fontFamily); if (path != null) { typeface = Typeface.createFromAsset(assetManager, path); } } if (typeface == null) { String path = "fonts/" + fontFamily + defaultFontFileExtension; typeface = Typeface.createFromAsset(assetManager, path); } fontFamilies.put(fontFamily, typeface); return typeface; }
@Override public void onClick(View view) { Toasty.Config.getInstance() .setToastTypeface(Typeface.createFromAsset(getAssets(), "PCap Terminal.otf")) .allowQueue(false) .apply(); Toasty.custom(MainActivity.this, R.string.custom_message, getResources().getDrawable(R.drawable.laptop512), Color.BLACK, Color.GREEN, Toasty.LENGTH_SHORT, true, true).show(); Toasty.Config.reset(); // Use this if you want to use the configuration above only once } });
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_line, container, false); chart = v.findViewById(R.id.lineChart1); chart.getDescription().setEnabled(false); chart.setDrawGridBackground(false); chart.setData(getComplexity()); chart.animateX(3000); Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); Legend l = chart.getLegend(); l.setTypeface(tf); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tf); chart.getAxisRight().setEnabled(false); XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(false); return v; } }
@Test public void createFromAsset_throwsExceptionWhenFontNotFound() throws Exception { try { Typeface.createFromAsset( ApplicationProvider.getApplicationContext().getAssets(), "nonexistent.ttf"); fail("Expected exception"); } catch (RuntimeException expected) { // Expected } } }
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_pie, container, false); chart = v.findViewById(R.id.pieChart1); chart.getDescription().setEnabled(false); Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); chart.setCenterTextTypeface(tf); chart.setCenterText(generateCenterText()); chart.setCenterTextSize(10f); chart.setCenterTextTypeface(tf); // radius of the center hole in percent of maximum radius chart.setHoleRadius(45f); chart.setTransparentCircleRadius(50f); Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(false); chart.setData(generatePieData()); return v; }
chart.animateX(3000); Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_bar, container, false); // create a new chart object chart = new BarChart(getActivity()); chart.getDescription().setEnabled(false); chart.setOnChartGestureListener(this); MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view); mv.setChartView(chart); // For bounds control chart.setMarker(mv); chart.setDrawGridBackground(false); chart.setDrawBarShadow(false); Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); chart.setData(generateBarData(1, 20000, 12)); Legend l = chart.getLegend(); l.setTypeface(tf); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) chart.getAxisRight().setEnabled(false); XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(false); // programmatically add the chart FrameLayout parent = v.findViewById(R.id.parentLayout); parent.addView(chart); return v; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_colored_lines); setTitle("LineChartActivityColored"); charts[0] = findViewById(R.id.chart1); charts[1] = findViewById(R.id.chart2); charts[2] = findViewById(R.id.chart3); charts[3] = findViewById(R.id.chart4); Typeface mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Bold.ttf"); for (int i = 0; i < charts.length; i++) { LineData data = getData(36, 100); data.setValueTypeface(mTf); // add some transparency to the color with "& 0x90FFFFFF" setupChart(charts[i], data, colors[i % colors.length]); } }
@Test public void createFromAsset_shouldCreateTypeface() { Typeface typeface = Typeface.createFromAsset( ApplicationProvider.getApplicationContext().getAssets(), "myFont.ttf"); assertThat(typeface.getStyle()).isEqualTo(Typeface.NORMAL); assertThat(shadowOf(typeface).getFontDescription().getFamilyName()).isEqualTo("myFont.ttf"); assertThat(shadowOf(typeface).getFontDescription().getStyle()).isEqualTo(Typeface.NORMAL); }
@Test @UiThreadTest public void setTitleTypeface_UpdatesTypeface() { BottomBarTab tab = bottomBar.getCurrentTab(); Typeface testTypeface = Typeface.createFromAsset( bottomBar.getContext().getAssets(), "fonts/GreatVibes-Regular.otf"); assertNotEquals(testTypeface, tab.getTitleTypeFace()); assertNotEquals(testTypeface, tab.getTitleView().getTypeface()); bottomBar.setTabTitleTypeface(testTypeface); assertEquals(testTypeface, tab.getTitleTypeFace()); assertEquals(testTypeface, tab.getTitleView().getTypeface()); }