From 93704cca0ace3bff31dea5d3841ba185ad89398a Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Tue, 28 Dec 2021 17:53:58 +0100 Subject: Reference the "special key font" in the Theme object Remove the last cast of the context. --- srcs/juloo.keyboard2/Theme.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'srcs/juloo.keyboard2/Theme.java') diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java index 60c9b88..af2f3d7 100644 --- a/srcs/juloo.keyboard2/Theme.java +++ b/srcs/juloo.keyboard2/Theme.java @@ -35,9 +35,9 @@ public class Theme keyDownBgPaint.setColor(res.getColor(R.color.key_down_bg)); _keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null); _keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null); - Typeface specialKeysFont = ((Keyboard2)context).getSpecialKeyFont(); - _specialKeyLabelPaint = initLabelPaint(Paint.Align.CENTER, specialKeysFont); - _specialKeySubLabelPaint = initLabelPaint(Paint.Align.LEFT, specialKeysFont); + Typeface specialKeyFont = getSpecialKeyFont(context); + _specialKeyLabelPaint = initLabelPaint(Paint.Align.CENTER, specialKeyFont); + _specialKeySubLabelPaint = initLabelPaint(Paint.Align.LEFT, specialKeyFont); } public Paint labelPaint(boolean special_font) @@ -61,4 +61,15 @@ public class Theme paint.setTypeface(font); return (paint); } + + private static Typeface _specialKeyFont = null; + + static public Typeface getSpecialKeyFont(Context context) + { + if (_specialKeyFont == null) + { + _specialKeyFont = Typeface.createFromAsset(context.getAssets(), "fonts/keys.ttf"); + } + return _specialKeyFont; + } } -- cgit v1.2.3