We are already shipping Roboto-Condensed.ttf, let's use it

This commit is contained in:
Henrik Rydgård 2017-06-06 15:45:43 +02:00
parent e4d2c95968
commit 751c61bd69
2 changed files with 14 additions and 0 deletions

View file

@ -406,6 +406,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextRenderer.init(this);
shuttingDown = false;
registerCallbacks();

View file

@ -1,17 +1,30 @@
package org.ppsspp.ppsspp;
import android.content.Context;
import android.graphics.*;
import android.util.Log;
import java.nio.ByteBuffer;
public class TextRenderer {
private static Paint p;
private static Paint bg;
private static Typeface robotoCondensed;
private static final String TAG = "TextRenderer";
static {
p = new Paint(Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
p.setColor(Color.WHITE);
bg = new Paint();
bg.setColor(Color.BLACK);
}
public static void init(Context ctx) {
robotoCondensed = Typeface.createFromAsset(ctx.getAssets(), "Roboto-Condensed.ttf");
if (robotoCondensed != null) {
Log.i(TAG, "Successfully loaded Roboto Condensed");
p.setTypeface(robotoCondensed);
} else {
Log.e(TAG, "Failed to load Roboto Condensed");
}
}
private static Point measure(String string, double textSize) {
Rect bound = new Rect();
p.setTextSize((float)textSize);