From c8c45392041f2ad9be8f7c552a8ee871b0ed0a06 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 12 Mar 2017 09:59:12 -0400 Subject: [PATCH] don't derive the font again if the size is unchanged (#4956) --- core/src/processing/awt/PGraphicsJava2D.java | 22 +++++++------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/core/src/processing/awt/PGraphicsJava2D.java b/core/src/processing/awt/PGraphicsJava2D.java index 325563526..44e123c1a 100644 --- a/core/src/processing/awt/PGraphicsJava2D.java +++ b/core/src/processing/awt/PGraphicsJava2D.java @@ -1908,14 +1908,9 @@ public class PGraphicsJava2D extends PGraphics { @Override protected void handleTextSize(float size) { // if a native version available, derive this font -// if (textFontNative != null) { -// textFontNative = textFontNative.deriveFont(size); -// g2.setFont(textFontNative); -// textFontNativeMetrics = g2.getFontMetrics(textFontNative); -// } Font font = (Font) textFont.getNative(); - //if (font != null && (textFont.isStream() || hints[ENABLE_NATIVE_FONTS])) { - if (font != null) { + // don't derive again if the font size has not changed + if (font != null && font.getSize2D() != size) { Map map = new HashMap(); map.put(TextAttribute.SIZE, size); @@ -1928,13 +1923,12 @@ public class PGraphicsJava2D extends PGraphics { textFont.setNative(font); fontObject = font; -// Font dfont = font.deriveFont(size); -//// Map attrs = dfont.getAttributes(); -//// for (TextAttribute ta : attrs.keySet()) { -//// System.out.println(ta + " -> " + attrs.get(ta)); -//// } -// g2.setFont(dfont); -// textFont.setNative(dfont); + /* + Map attrs = font.getAttributes(); + for (TextAttribute ta : attrs.keySet()) { + System.out.println(ta + " -> " + attrs.get(ta)); + } + */ } // take care of setting the textSize and textLeading vars