1

我在 TextDrawer 类中试过这个,但它不起作用

  try {  titleTypeface = Typeface.createFromAsset(context.getAssets(), "Face Your Fears.ttf");

} catch (Exception e) {
// Pretend that never happened, and use the default font
Log.d(TAG, "TITLE FONT: ");
Log.d(TAG, "default font");
}
titlePaint.setTypeface(titleTypeface);
textPaint.setTypeface(titleTypeface);

有什么建议么 ?

4

1 回答 1

2

我的 TextDrawer 构造函数如下所示,对我有用

public TextDrawer(Resources resources, ShowcaseAreaCalculator calculator, Context context) {
    padding = resources.getDimension(R.dimen.text_padding);
    actionBarOffset = resources.getDimension(R.dimen.action_bar_offset);

    this.calculator = calculator;
    this.context = context;

    String fontPath = "fonts/SuperAwesomeFont.ttf";
    Typeface mTypeFace = Typeface.createFromAsset(context.getAssets(),fontPath);

    titlePaint = new TextPaint();
    titlePaint.setAntiAlias(true);
    titlePaint.setTypeface(mTypeFace);

    textPaint = new TextPaint();
    textPaint.setAntiAlias(true);
    textPaint.setTypeface(mTypeFace);
}
于 2015-02-02T15:38:36.750 回答