Skip to content

Commit 3ec2f28

Browse files
committed
wrapping up fixes for #197, #198
1 parent 1522aea commit 3ec2f28

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

core/src/processing/core/PFont.java

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,16 @@ public PFont(Font font, boolean smooth, char[] charset) {
267267

268268
if (charset == null) {
269269
lazy = true;
270-
// lazyFont = font;
271270

272271
} else {
273-
// charset needs to be sorted to make index lookup run more quickly
272+
// The charset needs to be sorted to make index lookup run quickly
274273
// http://dev.processing.org/bugs/show_bug.cgi?id=494
275-
276-
// make copy of charset for sorting to not effect original array
277-
// fix for bug: https://github.com/processing/processing4/issues/197
278-
char[] sortedCharset = Arrays.copyOf(charset, charset.length );
279-
274+
// First make copy of charset[] so the user's array is not modified
275+
// https://github.com/processing/processing4/issues/197
276+
char[] sortedCharset = Arrays.copyOf(charset, charset.length);
280277
Arrays.sort(sortedCharset);
281278

282279
glyphs = new Glyph[sortedCharset.length];
283-
284280
glyphCount = 0;
285281
for (char c : sortedCharset) {
286282
if (font.canDisplay(c)) {
@@ -297,28 +293,6 @@ public PFont(Font font, boolean smooth, char[] charset) {
297293
if (glyphCount != sortedCharset.length) {
298294
glyphs = (Glyph[]) PApplet.subset(glyphs, 0, glyphCount);
299295
}
300-
301-
// foreign font, so just make ascent the max topExtent
302-
// for > 1.0.9, not doing this anymore.
303-
// instead using getAscent() and getDescent() values for these cases.
304-
// if ((ascent == 0) && (descent == 0)) {
305-
// //for (int i = 0; i < charCount; i++) {
306-
// for (Glyph glyph : glyphs) {
307-
// char cc = (char) glyph.value;
308-
// //char cc = (char) glyphs[i].value;
309-
// if (Character.isWhitespace(cc) ||
310-
// (cc == '\u00A0') || (cc == '\u2007') || (cc == '\u202F')) {
311-
// continue;
312-
// }
313-
// if (glyph.topExtent > ascent) {
314-
// ascent = glyph.topExtent;
315-
// }
316-
// int d = -glyph.topExtent + glyph.height;
317-
// if (d > descent) {
318-
// descent = d;
319-
// }
320-
// }
321-
// }
322296
}
323297

324298
// If not already created, just create these two characters to calculate

todo.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ X increases export size, but impact is so worth it
1515
X Update JDK to 11.0.11+9
1616
X modernize the RegisteredMethods code to use collections classes w/ concurrency
1717
X https://github.com/processing/processing4/pull/199
18+
X don't sort user's charset array when calling createFont()
19+
X https://github.com/processing/processing4/issues/197
20+
X https://github.com/processing/processing4/pull/198
1821

1922

2023
earlier

0 commit comments

Comments
 (0)