Replace fonts of unclear origin

The font being used in the ApiDemos is of unclear origin, replace
it with a font we created. Also cleanup the code around it

Test: manual
Bug: 37726227
Change-Id: I7e30c3afddc731473c9bbe5a767fa0e1144a20d6
This commit is contained in:
Clara Bayarri
2017-05-24 16:21:36 +01:00
parent 56d4fb84d6
commit a3516bc957
3 changed files with 200 additions and 9 deletions

View File

@@ -17,7 +17,10 @@
package com.example.android.apis.graphics;
import android.content.Context;
import android.graphics.*;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
@@ -30,25 +33,26 @@ public class Typefaces extends GraphicsActivity {
}
private static class SampleView extends View {
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Typeface mFace;
public SampleView(Context context) {
super(context);
mFace = Typeface.createFromAsset(getContext().getAssets(),
"fonts/samplefont.ttf");
mFace = Typeface.createFromAsset(getContext().getAssets(), "fonts/samplefont.ttf");
mPaint.setTextSize(64);
}
@Override protected void onDraw(Canvas canvas) {
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
mPaint.setTypeface(null);
canvas.drawText("Default", 10, 100, mPaint);
canvas.drawText("Draw with Default:", 10, 100, mPaint);
canvas.drawText(" SAMPLE TEXT", 10, 200, mPaint);
canvas.drawText("Draw with Custom Font", 10, 400, mPaint);
canvas.drawText("(Custom Font draws 'A' with solid triangle.)", 10, 500, mPaint);
mPaint.setTypeface(mFace);
canvas.drawText("Custom", 10, 200, mPaint);
canvas.drawText(" SAMPLE TEXT", 10, 600, mPaint);
}
}
}