(int size, int style)
| 1294 | |
| 1295 | |
| 1296 | static public Font getSansFont(int size, int style) { |
| 1297 | // Prior to 4.0 beta 9, we had a manual override for |
| 1298 | // individual languages to use SansSerif instead. |
| 1299 | // In beta 9, that was moved to the language translation file. |
| 1300 | // https://github.com/processing/processing/issues/2886 |
| 1301 | // https://github.com/processing/processing/issues/4944 |
| 1302 | String fontFamilySans = Language.text("font.family.sans"); |
| 1303 | |
| 1304 | if (sansFont == null || sansBoldFont == null) { |
| 1305 | try { |
| 1306 | if ("Processing Sans".equals(fontFamilySans)) { |
| 1307 | sansFont = initFont("ProcessingSans-Regular.ttf", size); |
| 1308 | sansBoldFont = initFont("ProcessingSans-Bold.ttf", size); |
| 1309 | } |
| 1310 | } catch (Exception e) { |
| 1311 | Messages.err("Could not load sans font", e); |
| 1312 | } |
| 1313 | } |
| 1314 | |
| 1315 | // If not using "Processing Sans" above, or an Exception was thrown |
| 1316 | if (sansFont == null || sansBoldFont == null) { |
| 1317 | sansFont = new Font(fontFamilySans, Font.PLAIN, size); |
| 1318 | sansBoldFont = new Font(fontFamilySans, Font.BOLD, size); |
| 1319 | } |
| 1320 | |
| 1321 | if (style == Font.BOLD) { |
| 1322 | if (size == sansBoldFont.getSize() || size == 0) { |
| 1323 | return sansBoldFont; |
| 1324 | } else { |
| 1325 | return sansBoldFont.deriveFont((float) size); |
| 1326 | } |
| 1327 | } else { |
| 1328 | if (size == sansFont.getSize() || size == 0) { |
| 1329 | return sansFont; |
| 1330 | } else { |
| 1331 | return sansFont.deriveFont((float) size); |
| 1332 | } |
| 1333 | } |
| 1334 | } |
| 1335 | |
| 1336 | |
| 1337 | /** |
no test coverage detected