()
| 940 | |
| 941 | // Gets the plain (not bold, not italic) version of each |
| 942 | static private List<Font> getMonoFontList() { |
| 943 | GraphicsEnvironment ge = |
| 944 | GraphicsEnvironment.getLocalGraphicsEnvironment(); |
| 945 | Font[] fonts = ge.getAllFonts(); |
| 946 | List<Font> outgoing = new ArrayList<>(); |
| 947 | // Using AffineTransform.getScaleInstance(100, 100) doesn't change sizes |
| 948 | FontRenderContext frc = |
| 949 | new FontRenderContext(new AffineTransform(), |
| 950 | Preferences.getBoolean("editor.antialias"), |
| 951 | true); // use fractional metrics |
| 952 | for (Font font : fonts) { |
| 953 | if (font.getStyle() == Font.PLAIN && |
| 954 | font.canDisplay('i') && font.canDisplay('M') && |
| 955 | font.canDisplay(' ') && font.canDisplay('.')) { |
| 956 | |
| 957 | // The old method just returns 1 or 0, and using deriveFont(size) |
| 958 | // is overkill. It also causes deprecation warnings |
| 959 | // @SuppressWarnings("deprecation") |
| 960 | // FontMetrics fm = awtToolkit.getFontMetrics(font); |
| 961 | //FontMetrics fm = awtToolkit.getFontMetrics(font.deriveFont(24)); |
| 962 | // System.out.println(fm.charWidth('i') + " " + fm.charWidth('M')); |
| 963 | // if (fm.charWidth('i') == fm.charWidth('M') && |
| 964 | // fm.charWidth('M') == fm.charWidth(' ') && |
| 965 | // fm.charWidth(' ') == fm.charWidth('.')) { |
| 966 | double w = font.getStringBounds(" ", frc).getWidth(); |
| 967 | if (w == font.getStringBounds("i", frc).getWidth() && |
| 968 | w == font.getStringBounds("M", frc).getWidth() && |
| 969 | w == font.getStringBounds(".", frc).getWidth()) { |
| 970 | |
| 971 | // //PApplet.printArray(font.getAvailableAttributes()); |
| 972 | // Map<TextAttribute,?> attr = font.getAttributes(); |
| 973 | // System.out.println(font.getFamily() + " > " + font.getName()); |
| 974 | // System.out.println(font.getAttributes()); |
| 975 | // System.out.println(" " + attr.get(TextAttribute.WEIGHT)); |
| 976 | // System.out.println(" " + attr.get(TextAttribute.POSTURE)); |
| 977 | |
| 978 | outgoing.add(font); |
| 979 | // System.out.println(" good " + w); |
| 980 | } |
| 981 | } |
| 982 | } |
| 983 | return outgoing; |
| 984 | } |
| 985 | |
| 986 | |
| 987 | static public String[] getMonoFontFamilies() { |
no test coverage detected