(String attr)
| 179 | |
| 180 | // identical version found in Preferences.java |
| 181 | public Font getFont(String attr) { |
| 182 | try { |
| 183 | boolean replace = false; |
| 184 | String value = get(attr); |
| 185 | if (value == null) { |
| 186 | // use the default font instead |
| 187 | value = getDefault(attr); |
| 188 | replace = true; |
| 189 | } |
| 190 | |
| 191 | String[] pieces = PApplet.split(value, ','); |
| 192 | |
| 193 | if (pieces.length != 3) { |
| 194 | value = getDefault(attr); |
| 195 | pieces = PApplet.split(value, ','); |
| 196 | replace = true; |
| 197 | } |
| 198 | |
| 199 | String name = pieces[0]; |
| 200 | int style = Font.PLAIN; // equals zero |
| 201 | if (pieces[1].indexOf("bold") != -1) { //$NON-NLS-1$ |
| 202 | style |= Font.BOLD; |
| 203 | } |
| 204 | if (pieces[1].indexOf("italic") != -1) { //$NON-NLS-1$ |
| 205 | style |= Font.ITALIC; |
| 206 | } |
| 207 | int size = PApplet.parseInt(pieces[2], 12); |
| 208 | size = Toolkit.zoom(size); |
| 209 | |
| 210 | // replace bad font with the default from lib/preferences.txt |
| 211 | if (replace) { |
| 212 | set(attr, value); |
| 213 | } |
| 214 | |
| 215 | if (!name.startsWith("processing.")) { |
| 216 | return new Font(name, style, size); |
| 217 | |
| 218 | } else { |
| 219 | if (pieces[0].equals("processing.sans")) { |
| 220 | return Toolkit.getSansFont(size, style); |
| 221 | } else if (pieces[0].equals("processing.mono")) { |
| 222 | return Toolkit.getMonoFont(size, style); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | } catch (Exception e) { |
| 227 | // Adding try/catch block because this may be where |
| 228 | // a lot of startup crashes are happening. |
| 229 | Messages.log("Error with font " + get(attr) + " for attribute " + attr); |
| 230 | } |
| 231 | return new Font("Dialog", Font.PLAIN, 12); |
| 232 | } |
| 233 | } |
nothing calls this directly
no test coverage detected