diff --git a/samples/ApiDemos/assets/fonts/samplefont.ttf b/samples/ApiDemos/assets/fonts/samplefont.ttf index 49f1c620b..e8fc3a997 100644 Binary files a/samples/ApiDemos/assets/fonts/samplefont.ttf and b/samples/ApiDemos/assets/fonts/samplefont.ttf differ diff --git a/samples/ApiDemos/assets/fonts/samplefont.ttx b/samples/ApiDemos/assets/fonts/samplefont.ttx new file mode 100644 index 000000000..9678a1b60 --- /dev/null +++ b/samples/ApiDemos/assets/fonts/samplefont.ttx @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright (C) 2017 The Android Open Source Project + + + Sample Font + + + Regular + + + Sample Font + + + SampleFont-Regular + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + http://www.apache.org/licenses/LICENSE-2.0 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Typefaces.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Typefaces.java index 08facaa41..dadc3015e 100644 --- a/samples/ApiDemos/src/com/example/android/apis/graphics/Typefaces.java +++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Typefaces.java @@ -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); } } }