Returns a font with the given family name or, if not available, a similar font, e.g. Helvetica replaced by Arial
(String fontFamilyName, int style, float size)
| 10 | |
| 11 | /** Returns a font with the given family name or, if not available, a similar font, e.g. Helvetica replaced by Arial */ |
| 12 | public static Font getFont(String fontFamilyName, int style, float size) { |
| 13 | Font font = new Font(fontFamilyName, style, (int)size); |
| 14 | if (!font.getFamily().startsWith(fontFamilyName)) { |
| 15 | String[] similarFonts = getSimilarFontsList(fontFamilyName); |
| 16 | font = getFont(similarFonts, style, (int)size); |
| 17 | } |
| 18 | if (size != (int)size) |
| 19 | font = font.deriveFont(size); |
| 20 | return font; |
| 21 | } |
| 22 | |
| 23 | /** Returns the font for first element of the 'fontNames' array, where a Font Family Name starts with this name. |
| 24 | * E.g. if fontNames = {"Times New Roman", "Serif" and the system has no "Times New Roman", but finds "Serif", |
no test coverage detected