Changeset 14331 in josm for trunk/src/com/kitfox/svg/util


Ignore:
Timestamp:
2018-10-14T17:02:51+02:00 (6 years ago)
Author:
Don-vip
Message:

see #14319, see #16838 - fix regressions introduced in svgSalamander 1.1.2

see https://github.com/blackears/svgSalamander/issues/29

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/kitfox/svg/util/FontSystem.java

    r14328 r14331  
    4848import java.util.HashMap;
    4949import java.util.HashSet;
     50import java.util.Locale;
    5051
    5152/**
     
    5859    FontMetrics fm;
    5960
    60     HashMap<String, Glyph> glyphCache = new HashMap<String, Glyph>();
     61    HashMap<String, Glyph> glyphCache = new HashMap<>();
    6162   
    62     static HashSet<String> sysFontNames = new HashSet<String>();
     63    static HashSet<String> sysFontNames = new HashSet<>();
    6364
    6465    public static boolean checkIfSystemFontExists(String fontName)
     
    6667        if (sysFontNames.isEmpty())
    6768        {
    68             for (String name: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames())
     69            for (String name: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(Locale.ENGLISH))
    6970            {
    7071                sysFontNames.add(name);
     
    8081        for (String fontName: families)
    8182        {
    82             if (checkIfSystemFontExists(fontName))
     83            String javaFontName = mapJavaFontName(fontName);
     84            if (checkIfSystemFontExists(javaFontName))
    8385            {
    84                 return new FontSystem(fontName, fontStyle, fontWeight, fontSize);
     86                return new FontSystem(javaFontName, fontStyle, fontWeight, fontSize);
    8587            }
    8688        }
    8789
    8890        return null;
     91    }
     92
     93    private static String mapJavaFontName(String fontName) {
     94        if ("serif".equals(fontName)) {
     95            return java.awt.Font.SERIF;
     96        } else if ("sans-serif".equals(fontName)) {
     97            return java.awt.Font.SANS_SERIF;
     98        } else if ("monospace".equals(fontName)) {
     99            return java.awt.Font.MONOSPACED;
     100        } else {
     101            return fontName;
     102        }
    89103    }
    90104
Note: See TracChangeset for help on using the changeset viewer.