From 46dedc035154483ed2ad022a1e0ec1b50a89bebb Mon Sep 17 00:00:00 2001 From: benfry Date: Wed, 1 Jun 2005 18:03:24 +0000 Subject: [PATCH] tweaking some font stuff while working on frankenfont --- core/PApplet.java | 17 ++++++++--------- core/PFont.java | 13 ++++++++++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/core/PApplet.java b/core/PApplet.java index a7a06de1a..78bc56a02 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -2804,17 +2804,12 @@ public class PApplet extends Applet public PFont createFont(String name, float size) { - return createFont(name, size, PFont.DEFAULT_CHARSET, true); - } - - - public PFont createFont(String name, float size, char charset[]) { - return createFont(name, size, charset, true); + return createFont(name, size, true, PFont.DEFAULT_CHARSET); } public PFont createFont(String name, float size, boolean smooth) { - return createFont(name, size, PFont.DEFAULT_CHARSET, smooth); + return createFont(name, size, smooth, PFont.DEFAULT_CHARSET); } @@ -2824,9 +2819,13 @@ public class PApplet extends Applet * the data folder of this sketch. *

* Only works with Java 1.3 or later. + *

+ * Use 'null' for the charset if you want to use any of the 65,536 + * unicode characters that exist in the font. Note that this can + * produce an enormous file or may cause an OutOfMemoryError. */ public PFont createFont(String name, float size, - char charset[], boolean smooth) { + boolean smooth, char charset[]) { if (PApplet.javaVersion < 1.3f) { throw new RuntimeException("Can only create fonts with " + "Java 1.3 or higher"); @@ -2866,7 +2865,7 @@ public class PApplet extends Applet throw new RuntimeException("Problem using createFont() " + "with the file " + name); } - return new PFont(font, charset, smooth); + return new PFont(font, smooth, charset); } diff --git a/core/PFont.java b/core/PFont.java index 9cbfa5650..9373978d9 100644 --- a/core/PFont.java +++ b/core/PFont.java @@ -96,7 +96,7 @@ public class PFont implements PConstants { public int ascent; public int descent; - int ascii[]; // quick lookup for the ascii chars + protected int ascii[]; // quick lookup for the ascii chars // shared by the text() functions to avoid incessant allocation of memory protected char textBuffer[] = new char[8 * 1024]; @@ -674,7 +674,7 @@ public class PFont implements PConstants { * @param charset array of all unicode chars that should be included * @param smooth true to enable smoothing/anti-aliasing */ - public PFont(Font font, char charset[], boolean smooth) { + public PFont(Font font, boolean smooth, char charset[]) { if (PApplet.javaVersion < 1.3f) { throw new RuntimeException("Can only create fonts with " + "Java 1.3 or higher"); @@ -861,7 +861,8 @@ public class PFont implements PConstants { } if (!pixelFound) { - //System.out.println("no pixels found in char " + ((char)i)); + //System.out.println("no pixels found in unicode char " + c + + // "(" + PApplet.hex(c) + ")"); // this was dumb that it was set to 20 & 30, because for small // fonts, those guys don't exist minX = minY = 0; //20; @@ -869,6 +870,12 @@ public class PFont implements PConstants { // this will create a 1 pixel white (clear) character.. // maybe better to set one to -1 so nothing is added? + /* + } else { + System.out.println(PApplet.hex(c) + " has bounds " + + minX + ", " + minY + " to " + + maxX + ", " + maxY); + */ } value[index] = c;