Changeset 14331 in josm
- Timestamp:
- 2018-10-14T17:02:51+02:00 (6 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/Tspan.java
r14328 r14331 234 234 } 235 235 236 if (font == null) 237 { 238 font = FontSystem.createFont("Serif", fontStyle, fontWeight, fontStyle); 239 } 240 236 241 AffineTransform xform = new AffineTransform(); 237 242 -
trunk/src/com/kitfox/svg/util/FontSystem.java
r14328 r14331 48 48 import java.util.HashMap; 49 49 import java.util.HashSet; 50 import java.util.Locale; 50 51 51 52 /** … … 58 59 FontMetrics fm; 59 60 60 HashMap<String, Glyph> glyphCache = new HashMap< String, Glyph>();61 HashMap<String, Glyph> glyphCache = new HashMap<>(); 61 62 62 static HashSet<String> sysFontNames = new HashSet< String>();63 static HashSet<String> sysFontNames = new HashSet<>(); 63 64 64 65 public static boolean checkIfSystemFontExists(String fontName) … … 66 67 if (sysFontNames.isEmpty()) 67 68 { 68 for (String name: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames( ))69 for (String name: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(Locale.ENGLISH)) 69 70 { 70 71 sysFontNames.add(name); … … 80 81 for (String fontName: families) 81 82 { 82 if (checkIfSystemFontExists(fontName)) 83 String javaFontName = mapJavaFontName(fontName); 84 if (checkIfSystemFontExists(javaFontName)) 83 85 { 84 return new FontSystem( fontName, fontStyle, fontWeight, fontSize);86 return new FontSystem(javaFontName, fontStyle, fontWeight, fontSize); 85 87 } 86 88 } 87 89 88 90 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 } 89 103 } 90 104 -
trunk/src/com/kitfox/svg/xml/XMLParseUtil.java
r11525 r14331 56 56 static final Matcher fpMatch = Pattern.compile("([-+]?((\\d*\\.\\d+)|(\\d+))([eE][+-]?\\d+)?)(\\%|in|cm|mm|pt|pc|px|em|ex)?").matcher(""); 57 57 static final Matcher intMatch = Pattern.compile("[-+]?\\d+").matcher(""); 58 static final Matcher quoteMatch = Pattern.compile("^'|'$").matcher(""); 58 59 59 60 /** Creates a new instance of XMLParseUtil */ … … 320 321 321 322 String key = styles[i].substring(0, colon).trim(); 322 String value = styles[i].substring(colon + 1).trim();323 String value = quoteMatch.reset(styles[i].substring(colon + 1).trim()).replaceAll(""); 323 324 324 325 map.put(key, new StyleAttribute(key, value)); -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r14328 r14331 34 34 import java.util.Base64; 35 35 import java.util.Collection; 36 import java.util.EnumMap; 36 37 import java.util.HashMap; 37 38 import java.util.HashSet; … … 315 316 316 317 /** small cache of critical images used in many parts of the application */ 317 private static final Map<OsmPrimitiveType, ImageIcon> osmPrimitiveTypeCache = new HashMap<>();318 private static final Map<OsmPrimitiveType, ImageIcon> osmPrimitiveTypeCache = new EnumMap<>(OsmPrimitiveType.class); 318 319 319 320 /** larger cache of critical padded image icons used in many parts of the application */ … … 1634 1635 } 1635 1636 1636 if (realWidth == 0 || realHeight == 0) { 1637 int roundedWidth = Math.round(realWidth); 1638 int roundedHeight = Math.round(realHeight); 1639 if (roundedWidth <= 0 || roundedHeight <= 0) { 1640 Logging.error("createImageFromSvg: {0} {1} realWidth={2} realHeight={3}", 1641 svg.getXMLBase(), dim, Float.toString(realWidth), Float.toString(realHeight)); 1637 1642 return null; 1638 1643 } 1639 BufferedImage img = new BufferedImage( Math.round(realWidth), Math.round(realHeight), BufferedImage.TYPE_INT_ARGB);1644 BufferedImage img = new BufferedImage(roundedWidth, roundedHeight, BufferedImage.TYPE_INT_ARGB); 1640 1645 Graphics2D g = img.createGraphics(); 1641 1646 g.setClip(0, 0, img.getWidth(), img.getHeight());
Note:
See TracChangeset
for help on using the changeset viewer.