robofab.pens.svgPen (version 0.1)
index
/code/projects/robofab/Lib/robofab/pens/svgPen.py

 
Modules
       
os
re

 
Classes
       
fontTools.pens.basePen.BasePen(fontTools.pens.basePen.AbstractPen)
FabToSVGPen
Description
ExtractGlyphFromSVG
Line
SVGDocument
SVGPath

 
class Description
    Simple wrapper for SVG descriptions.
 
  Methods defined here:
__init__(self, text)
write(self)

 
class ExtractGlyphFromSVG
    Extract glyph data from a SVG file.
 
  Methods defined here:
__init__(self, path, glyph)
drawData(self)
getGlyph(self)
read(self, aFile)
readPath(self, data)
readSVGTree(self, tree)

 
class FabToSVGPen(fontTools.pens.basePen.BasePen)
    A pen to create and draw the glyph as a path object into a SVG document.
 
 
Method resolution order:
FabToSVGPen
fontTools.pens.basePen.BasePen
fontTools.pens.basePen.AbstractPen

Methods defined here:
__init__(self, glyphSet)
drawProportions(self)
Additional boundinbox, baseline, xheight as simple lines.
setName(self, name)
setParentPath(self, parentPath)
setUnicode(self, unicode)
setWidth(self, width)
write(self, filePath=None)
Finally, make an SVG document, add the path and save to file.

Methods inherited from fontTools.pens.basePen.BasePen:
addComponent(self, glyphName, transformation)
This default implementation simply transforms the points
of the base glyph and draws it onto self.
closePath(self)
curveTo(self, *points)
endPath(self)
lineTo(self, pt)
moveTo(self, pt)
qCurveTo(self, *points)

 
class Line
    <line x1="100" y1="300" x2="300" y2="100" stroke-width="5"  />
 
  Methods defined here:
__init__(self, (x1, y1), (x2, y2), strokeWidth=1, strokeColor=None)
write(self)

 
class SVGDocument
    Very basic container for SVG data.
 
  Methods defined here:
__init__(self, (width, height), units='pt')
add(self, item)
comment(self, text)
save(self, path=None)
scale(self, (sx, sy))
setStrokeColor(self, colorName)
translate(self, (dx, dy))

 
class SVGPath
    Path object for SVG vector paths.
 
  Methods defined here:
__init__(self, fillColor=None, strokeColor=None, strokeWidth=None)
closePath(self)
curveTo(self, (x1, y1, x2, y2, x3, y3))
lineTo(self, (x, y))
moveTo(self, (x, y))
qCurveTo(self, (x1, y1, x2, y2))
write(self)
        <path d="M200,300 L400,50 L600,300 
   L800,550 L1000,300"
fill="none" stroke="#888888" stroke-width="2" />

 
Functions
       
exportGlyphToSVG(glyph, glyphSet, dir)
Export a glyph to a properly named SVG file in the
specified directory.
importFontFromSVG(dir, font)
Import glyphs from all SVG files in dir.
importGlyphFromSVG(filePath)
Import a single glyph from the SVG file at filePath.
intfloat(x)
Return a value as a  nice looking stringified int if possible, return stringified float otherwise.
testExportImport(ufoPath, glyphName, dir)

 
Data
        __version__ = '0.1'
cmdSearch = <_sre.SRE_Pattern object at 0x1902000>
declaration = '<svg width="%s%s" height="%s%s" viewBox="0 0 %s ..."http://www.w3.org/2000/svg" version="1.1">\n '
fabEndTag = '#robofab_glyph_end'
fabNameTag = '#robofab_glyph_name:'
fabParentPathTag = '#robofab_glyph_parent:'
fabStartTag = '#robofab_glyph_start'
fabUnicodeTag = '#robofab_glyph_unicode:'
fabWidthTag = '#robofab_glyph_width:'
footer = '</svg>'
header = '<?xml version="1.0" standalone="no"?>\n<!DOCTYPE ...ttp://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'
pathSearch = <_sre.SRE_Pattern object at 0x1167e10>