1 4 5 9 10 package org.openlaszlo.media; 11 12 import org.apache.batik.svggen.font.table.GlyphDescription; 13 import org.apache.batik.svggen.font.table.GlyfDescript; 14 import org.apache.batik.svggen.font.Point; 15 16 import org.apache.log4j.*; 18 19 22 public class TTFGlyph { 23 24 private Point[] points; 25 26 30 public TTFGlyph(GlyphDescription gd) { 31 int endPtIndex = 0; 32 points = new Point[gd.getPointCount()]; 33 for (int i = 0; i < gd.getPointCount(); i++) { 34 boolean endPt = gd.getEndPtOfContours(endPtIndex) == i; 35 if (endPt) { 36 endPtIndex++; 37 } 38 points[i] = new Point( 39 gd.getXCoordinate(i), 40 gd.getYCoordinate(i), 41 (gd.getFlags(i) & GlyfDescript.onCurve) != 0, 42 endPt); 43 } 44 } 45 46 49 public Point getPoint(int i) { 50 return points[i]; 51 } 52 53 56 public int getNumPoints() { 57 return points.length; 58 } 59 60 64 public void dump(Logger logger) { 65 for (int i = 0; i < points.length; i++) { 66 logger.debug( "Point x " + points[i].x + 67 " y " + points[i].y + 68 " " + points[i].onCurve + 69 " " + points[i].endOfContour); 70 } 71 } 72 73 77 public void scale(double factor) { 78 for (int i = 0; i < points.length; i++) { 79 points[i].x *= factor; 80 points[i].y *= -factor; 81 } 82 } 83 } 84 | Popular Tags |