()
| 1174 | |
| 1175 | // Gets the plain (not bold, not italic) version of each |
| 1176 | static private List<Font> getMonoFontList() { |
| 1177 | GraphicsEnvironment ge = |
| 1178 | GraphicsEnvironment.getLocalGraphicsEnvironment(); |
| 1179 | Font[] fonts = ge.getAllFonts(); |
| 1180 | List<Font> outgoing = new ArrayList<>(); |
| 1181 | // Using AffineTransform.getScaleInstance(100, 100) doesn't change sizes |
| 1182 | FontRenderContext frc = |
| 1183 | new FontRenderContext(new AffineTransform(), |
| 1184 | Preferences.getBoolean("editor.antialias"), |
| 1185 | true); // use fractional metrics |
| 1186 | for (Font font : fonts) { |
| 1187 | if (font.getStyle() == Font.PLAIN && |
| 1188 | font.canDisplay('i') && font.canDisplay('M') && |
| 1189 | font.canDisplay(' ') && font.canDisplay('.')) { |
| 1190 | |
| 1191 | // The old method just returns 1 or 0, and using deriveFont(size) |
| 1192 | // is overkill. It also causes deprecation warnings |
| 1193 | // @SuppressWarnings("deprecation") |
| 1194 | // FontMetrics fm = awtToolkit.getFontMetrics(font); |
| 1195 | //FontMetrics fm = awtToolkit.getFontMetrics(font.deriveFont(24)); |
| 1196 | // System.out.println(fm.charWidth('i') + " " + fm.charWidth('M')); |
| 1197 | // if (fm.charWidth('i') == fm.charWidth('M') && |
| 1198 | // fm.charWidth('M') == fm.charWidth(' ') && |
| 1199 | // fm.charWidth(' ') == fm.charWidth('.')) { |
| 1200 | double w = font.getStringBounds(" ", frc).getWidth(); |
| 1201 | if (w == font.getStringBounds("i", frc).getWidth() && |
| 1202 | w == font.getStringBounds("M", frc).getWidth() && |
| 1203 | w == font.getStringBounds(".", frc).getWidth()) { |
| 1204 | |
| 1205 | // //PApplet.printArray(font.getAvailableAttributes()); |
| 1206 | // Map<TextAttribute,?> attr = font.getAttributes(); |
| 1207 | // System.out.println(font.getFamily() + " > " + font.getName()); |
| 1208 | // System.out.println(font.getAttributes()); |
| 1209 | // System.out.println(" " + attr.get(TextAttribute.WEIGHT)); |
| 1210 | // System.out.println(" " + attr.get(TextAttribute.POSTURE)); |
| 1211 | |
| 1212 | outgoing.add(font); |
| 1213 | // System.out.println(" good " + w); |
| 1214 | } |
| 1215 | } |
| 1216 | } |
| 1217 | return outgoing; |
| 1218 | } |
| 1219 | |
| 1220 | |
| 1221 | static public String[] getMonoFontFamilies() { |
no test coverage detected