Skip to content

Commit 2e7a4c8

Browse files
committed
set size of fonts in Android2D, fixes #248
1 parent 959b7b2 commit 2e7a4c8

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

core/src/processing/a2d/PGraphicsAndroid2D.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,10 +1246,16 @@ public PShape loadShape(String filename) {
12461246
public void textFont(PFont which) {
12471247
super.textFont(which);
12481248
fillPaint.setTypeface((Typeface) which.getNative());
1249+
fillPaint.setTextSize(which.getDefaultSize());
12491250
}
12501251

12511252

1252-
//public void textFont(PFont which, float size)
1253+
@Override
1254+
public void textFont(PFont which, float size) {
1255+
super.textFont(which, size);
1256+
fillPaint.setTypeface((Typeface) which.getNative());
1257+
fillPaint.setTextSize(which.getDefaultSize());
1258+
}
12531259

12541260

12551261
//public void textLeading(float leading)
@@ -1281,14 +1287,7 @@ public void textSize(float size) {
12811287
fillPaint.setTextSize(size);
12821288
}
12831289

1284-
// take care of setting the textSize and textLeading vars
1285-
// this has to happen second, because it calls textAscent()
1286-
// (which requires the native font metrics to be set)
1287-
textSize = size;
1288-
// PApplet.println("P2D textSize textAscent -> " + textAscent());
1289-
// PApplet.println("P2D textSize textDescent -> " + textDescent());
1290-
textLeading = (textAscent() + textDescent()) * 1.275f;
1291-
// PApplet.println("P2D textSize textLeading = " + textLeading);
1290+
handleTextSize(size);
12921291
}
12931292

12941293

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3493,7 +3493,7 @@ protected void handleTextSize(float size) {
34933493
Object font = textFont.getNative();
34943494
if (font != null) {
34953495
Object dfont = pgl.getDerivedFont(font, size);
3496-
textFont.setNative(dfont);
3496+
if (dfont != null) textFont.setNative(dfont);
34973497
}
34983498
super.handleTextSize(size);
34993499
}

0 commit comments

Comments
 (0)