MCPcopy Index your code
hub / github.com/benfry/processing4 / getFont

Method getFont

app/src/processing/app/Settings.java:205–256  ·  view source on GitHub ↗
(String attr)

Source from the content-addressed store, hash-verified

203
204 // identical version found in Preferences.java
205 public Font getFont(String attr) {
206 try {
207 boolean replace = false;
208 String value = get(attr);
209 if (value == null) {
210 // use the default font instead
211 value = getDefault(attr);
212 replace = true;
213 }
214
215 String[] pieces = PApplet.split(value, ',');
216
217 if (pieces.length != 3) {
218 value = getDefault(attr);
219 pieces = PApplet.split(value, ',');
220 replace = true;
221 }
222
223 String name = pieces[0];
224 int style = Font.PLAIN; // equals zero
225 if (pieces[1].contains("bold")) { //$NON-NLS-1$
226 style |= Font.BOLD;
227 }
228 if (pieces[1].contains("italic")) { //$NON-NLS-1$
229 style |= Font.ITALIC;
230 }
231 int size = PApplet.parseInt(pieces[2], 12);
232 size = Toolkit.zoom(size);
233
234 // replace bad font with the default from lib/preferences.txt
235 if (replace) {
236 set(attr, value);
237 }
238
239 if (!name.startsWith("processing.")) {
240 return new Font(name, style, size);
241
242 } else {
243 if (pieces[0].equals("processing.sans")) {
244 return Toolkit.getSansFont(size, style);
245 } else if (pieces[0].equals("processing.mono")) {
246 return Toolkit.getMonoFont(size, style);
247 }
248 }
249
250 } catch (Exception e) {
251 // Adding try/catch block because this may be where
252 // a lot of startup crashes are happening.
253 Messages.log("Error with font " + get(attr) + " for attribute " + attr);
254 }
255 return new Font("Dialog", Font.PLAIN, 12);
256 }
257
258
259 public String remove(String key) {

Callers

nothing calls this directly

Calls 11

getMethod · 0.95
getDefaultMethod · 0.95
splitMethod · 0.95
parseIntMethod · 0.95
zoomMethod · 0.95
setMethod · 0.95
getSansFontMethod · 0.95
getMonoFontMethod · 0.95
logMethod · 0.95
containsMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected