Skip to content

Commit 550eaf4

Browse files
committed
sets the resized native font in PGraphicsOpenGL, fix processing#2109
1 parent 4f2bcfe commit 550eaf4

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

core/src/processing/opengl/PGL.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,11 @@ protected int getTextWidth(Object font, char buffer[], int start, int stop) {
19001900
}
19011901

19021902

1903+
protected Object getDerivedFont(Object font, float size) {
1904+
return null;
1905+
}
1906+
1907+
19031908
///////////////////////////////////////////////////////////
19041909

19051910
// Tessellator interface

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package processing.opengl;
2424

2525
import processing.core.*;
26+
2627
import java.net.URL;
2728
import java.nio.*;
2829
import java.util.*;
@@ -3281,6 +3282,18 @@ protected float textWidthImpl(char buffer[], int start, int stop) {
32813282
}
32823283

32833284

3285+
@Override
3286+
public void textSize(float size) {
3287+
if (textFont == null) defaultFontOrDeath("textSize", size);
3288+
Object font = textFont.getNative();
3289+
if (font != null) {
3290+
Object dfont = pgl.getDerivedFont(font, size);
3291+
textFont.setNative(dfont);
3292+
}
3293+
super.textSize(size);
3294+
}
3295+
3296+
32843297
/**
32853298
* Implementation of actual drawing for a line of text.
32863299
*/

core/src/processing/opengl/PJOGL.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,12 @@ protected int getTextWidth(Object font, char buffer[], int start, int stop) {
968968
}
969969

970970

971+
@Override
972+
protected Object getDerivedFont(Object font, float size) {
973+
return ((Font)font).deriveFont(size);
974+
}
975+
976+
971977
///////////////////////////////////////////////////////////
972978

973979
// Tessellator

java/libraries/lwjgl/src/processing/lwjgl/PLWJGL.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ protected int getTextWidth(Object font, char buffer[], int start, int stop) {
354354
FontMetrics metrics = pg.parent.getFontMetrics((Font)font);
355355
return metrics.charsWidth(buffer, start, length);
356356
}
357+
358+
359+
@Override
360+
protected Object getDerivedFont(Object font, float size) {
361+
return ((Font)font).deriveFont(size);
362+
}
357363

358364

359365
///////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)