sets the resized native font in PGraphicsOpenGL, fix #2109

This commit is contained in:
codeanticode
2013-10-03 17:03:14 -04:00
parent 994be867e9
commit 312fb99508
4 changed files with 30 additions and 0 deletions
+5
View File
@@ -1900,6 +1900,11 @@ public abstract class PGL {
}
protected Object getDerivedFont(Object font, float size) {
return null;
}
///////////////////////////////////////////////////////////
// Tessellator interface
@@ -23,6 +23,7 @@
package processing.opengl;
import processing.core.*;
import java.net.URL;
import java.nio.*;
import java.util.*;
@@ -3281,6 +3282,18 @@ public class PGraphicsOpenGL extends PGraphics {
}
@Override
public void textSize(float size) {
if (textFont == null) defaultFontOrDeath("textSize", size);
Object font = textFont.getNative();
if (font != null) {
Object dfont = pgl.getDerivedFont(font, size);
textFont.setNative(dfont);
}
super.textSize(size);
}
/**
* Implementation of actual drawing for a line of text.
*/
+6
View File
@@ -968,6 +968,12 @@ public class PJOGL extends PGL {
}
@Override
protected Object getDerivedFont(Object font, float size) {
return ((Font)font).deriveFont(size);
}
///////////////////////////////////////////////////////////
// Tessellator
@@ -354,6 +354,12 @@ public class PLWJGL extends PGL {
FontMetrics metrics = pg.parent.getFontMetrics((Font)font);
return metrics.charsWidth(buffer, start, length);
}
@Override
protected Object getDerivedFont(Object font, float size) {
return ((Font)font).deriveFont(size);
}
///////////////////////////////////////////////////////////