MCPcopy Index your code
hub / github.com/processing/processing / getFont

Method getFont

app/src/processing/app/Preferences.java:350–400  ·  view source on GitHub ↗
(String attr)

Source from the content-addressed store, hash-verified

348
349 // Identical version found in Settings.java
350 static public Font getFont(String attr) {
351 try {
352 boolean replace = false;
353 String value = get(attr);
354 if (value == null) {
355 // use the default font instead
356 value = getDefault(attr);
357 replace = true;
358 }
359
360 String[] pieces = PApplet.split(value, ',');
361
362 if (pieces.length != 3) {
363 value = getDefault(attr);
364 pieces = PApplet.split(value, ',');
365 replace = true;
366 }
367
368 String name = pieces[0];
369 int style = Font.PLAIN; // equals zero
370 if (pieces[1].indexOf("bold") != -1) { //$NON-NLS-1$
371 style |= Font.BOLD;
372 }
373 if (pieces[1].indexOf("italic") != -1) { //$NON-NLS-1$
374 style |= Font.ITALIC;
375 }
376 int size = PApplet.parseInt(pieces[2], 12);
377
378 // replace bad font with the default from lib/preferences.txt
379 if (replace) {
380 set(attr, value);
381 }
382
383 if (!name.startsWith("processing.")) {
384 return new Font(name, style, size);
385
386 } else {
387 if (pieces[0].equals("processing.sans")) {
388 return Toolkit.getSansFont(size, style);
389 } else if (pieces[0].equals("processing.mono")) {
390 return Toolkit.getMonoFont(size, style);
391 }
392 }
393
394 } catch (Exception e) {
395 // Adding try/catch block because this may be where
396 // a lot of startup crashes are happening.
397 Messages.log("Error with font " + get(attr) + " for attribute " + attr);
398 }
399 return new Font("Dialog", Font.PLAIN, 12);
400 }
401
402
403 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Callers 2

PreferencesFrameMethod · 0.95
updateModeMethod · 0.95

Calls 10

getMethod · 0.95
getDefaultMethod · 0.95
splitMethod · 0.95
parseIntMethod · 0.95
setMethod · 0.95
getSansFontMethod · 0.95
getMonoFontMethod · 0.95
logMethod · 0.95
startsWithMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected