From be73da84daeb549009bfbf6f5a3489f23b2a7009 Mon Sep 17 00:00:00 2001 From: benfry Date: Thu, 21 Aug 2008 23:37:13 +0000 Subject: [PATCH] removing font code to put it elsewhere --- candy/src/processing/candy/SVG.java | 211 ---------------------------- 1 file changed, 211 deletions(-) diff --git a/candy/src/processing/candy/SVG.java b/candy/src/processing/candy/SVG.java index 9e58cfad8..e8d449d3a 100755 --- a/candy/src/processing/candy/SVG.java +++ b/candy/src/processing/candy/SVG.java @@ -1665,215 +1665,4 @@ public class SVG { parent.endShape(closed ? PConstants.CLOSE : PConstants.OPEN); } } - - /* - public void draw() { - drawShape(); - } - - - public void draw(PApplet tp) { - PApplet p = parent; - parent = tp; - drawShape(); - parent = p; - } - - - public void draw(PGraphics parent) { - parent.beginShape(); - - parent.vertex(x[0], y[0]); - int i = 1; // moveto has the first point - while (i < count) { - switch (kind[i]) { - case MOVETO: - parent.breakShape(); - parent.vertex(x[i], y[i]); - i++; - break; - - case LINETO: - parent.vertex(x[i], y[i]); - i++; - break; - - case QCURVETO: // doubles the control point - parent.bezierVertex(x[i], y[i], x[i+1], y[i+1], x[i+1], y[i+1]); - i += 2; - break; - - case CURVETO: - parent.bezierVertex(x[i], y[i], x[i+1], y[i+1], x[i+2], y[i+2]); - i += 3; - break; - } - } - parent.endShape(closed ? PConstants.CLOSE : PConstants.OPEN); - } - */ - - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - - /* - // http://www.w3.org/TR/SVG11/fonts.html - public class Font extends BaseObject { -// String id; -// XMLElement element; - - public FontFace face; - - public HashMap namedGlyphs; - public HashMap unicodeGlyphs; - - public int glyphCount; - public FontGlyph[] glyphs; - public FontGlyph missingGlyph; - - - public Font(BaseObject parent, XMLElement properties) { - super(parent, properties); - - XMLElement[] elements = properties.getChildren(); - - namedGlyphs = new HashMap(); - unicodeGlyphs = new HashMap(); - glyphCount = 0; - glyphs = new FontGlyph[elements.length]; - - for (int i = 0; i < elements.length; i++) { - String name = elements[i].getName(); - XMLElement elem = elements[i]; - if (name.equals("glyph")) { - FontGlyph fg = new FontGlyph(this, elem); - if (fg.count != 0) { - if (fg.name != null) { - namedGlyphs.put(fg.name, fg); - } - if (fg.unicode != 0) { - unicodeGlyphs.put(new Character(fg.unicode), fg); - } - } - glyphs[glyphCount++] = fg; - - } else if (name.equals("missing-glyph")) { - missingGlyph = new FontGlyph(this, elem); - } else if (name.equals("font-face")) { - face = new FontFace(this, elem); - } else { - System.err.println("Ignoring " + name + " inside "); - } - } - } - - - protected void drawShape() { - // does nothing for fonts - } - - - public void drawString(String str, float x, float y, float size) { - // 1) scale by the 1.0/unitsPerEm - // 2) scale up by a font size - parent.pushMatrix(); - float s = size / (float) face.unitsPerEm; - //System.out.println("scale is " + s); - // swap y coord at the same time, since fonts have y=0 at baseline - parent.translate(x, y); - parent.scale(s, -s); - char[] c = str.toCharArray(); - for (int i = 0; i < c.length; i++) { - // call draw on each char (pulling it w/ the unicode table) - FontGlyph fg = (FontGlyph) unicodeGlyphs.get(new Character(c[i])); - if (fg != null) { - fg.draw(); - // add horizAdvX/unitsPerEm to the x coordinate along the way - parent.translate(fg.horizAdvX, 0); - } else { - System.err.println("'" + c[i] + "' not available."); - } - } - parent.popMatrix(); - } - - - public void drawChar(char c, float x, float y, float size) { - parent.pushMatrix(); - float s = size / (float) face.unitsPerEm; - parent.translate(x, y); - parent.scale(s, -s); - FontGlyph fg = (FontGlyph) unicodeGlyphs.get(new Character(c)); - if (fg != null) fg.draw(); - parent.popMatrix(); - } - } - - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - - public class FontFace extends BaseObject { - int horizOriginX; // dflt 0 - int horizOriginY; // dflt 0 - int horizAdvX; // no dflt? - int vertOriginX; // dflt horizAdvX/2 - int vertOriginY; // dflt ascent - int vertAdvY; // dflt 1em (unitsPerEm value) - - String fontFamily; - int fontWeight; // can also be normal or bold (also comma separated) - String fontStretch; - int unitsPerEm; // dflt 1000 - int[] panose1; // dflt "0 0 0 0 0 0 0 0 0 0" - int ascent; - int descent; - int[] bbox; // spec says comma separated, tho not w/ forge - int underlineThickness; - int underlinePosition; - //String unicodeRange; // gonna ignore for now - - - public FontFace(BaseObject parent, XMLElement properties) { - super(parent, properties); - - unitsPerEm = properties.getIntAttribute("units-per-em", 1000); - } - - - protected void drawShape() { - // nothing to draw in the font face attribute - } - } - - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - - public class FontGlyph extends Path { - String name; - //String unicode; - char unicode; //c; - int horizAdvX; - - public FontGlyph(BaseObject parent, XMLElement properties) { - super(parent, properties); - - name = properties.getStringAttribute("glyph-name"); - String u = properties.getStringAttribute("unicode"); - unicode = 0; - if (u != null) { - if (u.length() == 1) { - unicode = u.charAt(0); - //System.out.println("unicode for " + name + " is " + u); - } else { - System.err.println("unicode for " + name + - " is more than one char: " + u); - } - } - horizAdvX = properties.getIntAttribute("horiz-adv-x", 0); - } - } - */ }