Changeset 10787 in josm for trunk/src/com/kitfox/svg/Text.java
- Timestamp:
- 2016-08-12T03:16:58+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/Text.java
r8084 r10787 37 37 38 38 import com.kitfox.svg.util.FontSystem; 39 import com.kitfox.svg.util.TextBuilder;40 39 import com.kitfox.svg.xml.StyleAttribute; 41 40 import java.awt.Graphics2D; 42 41 import java.awt.Shape; 43 import java.awt.font.FontRenderContext;44 42 import java.awt.geom.AffineTransform; 45 43 import java.awt.geom.GeneralPath; … … 51 49 import java.util.regex.Pattern; 52 50 53 //import org.apache.batik.ext.awt.geom.ExtendedGeneralPath;54 51 /** 55 52 * @author Mark McKay … … 265 262 protected void buildText() throws SVGException 266 263 { 267 268 264 //Get font 269 Font font = diagram.getUniverse().getFont(fontFamily); 265 String[] families = fontFamily.split(","); 266 Font font = null; 267 for (int i = 0; i < families.length; ++i) 268 { 269 font = diagram.getUniverse().getFont(fontFamily); 270 if (font != null) 271 { 272 break; 273 } 274 } 275 270 276 if (font == null) 271 277 { 272 // System.err.println("Could not load font");273 274 278 font = new FontSystem(fontFamily, fontStyle, fontWeight, (int)fontSize); 275 // java.awt.Font sysFont = new java.awt.Font(fontFamily, style | weight, (int)fontSize); 276 // buildSysFont(sysFont); 277 // return; 278 } 279 280 // font = new java.awt.Font(font.getFamily(), style | weight, font.getSize()); 281 282 // Area textArea = new Area(); 279 } 280 283 281 GeneralPath textPath = new GeneralPath(); 284 282 textShape = textPath; … … 286 284 float cursorX = x, cursorY = y; 287 285 288 FontFace fontFace = font.getFontFace();289 //int unitsPerEm = fontFace.getUnitsPerEm();290 int ascent = fontFace.getAscent();291 float fontScale = fontSize / (float) ascent;292 293 // AffineTransform oldXform = g.getTransform();294 // TextBuilder builder = new TextBuilder();295 //296 // for (Iterator it = content.iterator(); it.hasNext();)297 // {298 // Object obj = it.next();299 //300 // if (obj instanceof String)301 // {302 // String text = (String) obj;303 // if (text != null)304 // {305 // text = text.trim();306 // }307 //308 // for (int i = 0; i < text.length(); i++)309 // {310 // String unicode = text.substring(i, i + 1);311 // MissingGlyph glyph = font.getGlyph(unicode);312 //313 // builder.appendGlyph(glyph);314 // }315 // }316 // else if (obj instanceof Tspan)317 // {318 // Tspan tspan = (Tspan)obj;319 // tspan.buildGlyphs(builder);320 // }321 // }322 //323 // builder.formatGlyphs();324 325 326 327 328 329 330 331 332 286 AffineTransform xform = new AffineTransform(); 333 287 … … 344 298 } 345 299 346 strokeWidthScalar = 1f / fontScale;347 348 300 for (int i = 0; i < text.length(); i++) 349 301 { 350 302 xform.setToIdentity(); 351 303 xform.setToTranslation(cursorX, cursorY); 352 xform.scale(fontScale, fontScale);353 // g.transform(xform);354 304 355 305 String unicode = text.substring(i, i + 1); … … 362 312 textPath.append(path, false); 363 313 } 364 // else glyph.render(g); 365 366 cursorX += fontScale * glyph.getHorizAdvX(); 367 368 // g.setTransform(oldXform); 314 315 cursorX += glyph.getHorizAdvX(); 369 316 } 370 317
Note:
See TracChangeset
for help on using the changeset viewer.