robofab.pens.JSONPen
index
/code/projects/robofab/Lib/robofab/pens/JSONPen.py

Pen en wrapper for exporting glyphs to a description in JSON format.
The JSON structure is similar to the .GLIF format.
 
{
        "glyph":{
                "advance":{"width":268.0},
                "name":"period",
                "unicode":{"hex":"002E"},
                "source":"/Foundry/Critter UFO work/Source june 05_2/instances/NeueCritter_ExtraBlack.ufo/period",
                "outline":[
                        {"contour":[
                                {"point":{"x":249.9, "y":83.3, "type":"curve"}},
                                {"point":{"x":249.9, "y":151.8}},
                                {"point":{"x":200.1, "y":186.8}},
                                {"point":{"x":134.0, "y":186.8, "type":"curve"}},
                                {"point":{"x":65.3, "y":186.8}},
                                {"point":{"x":15.5, "y":148.2}},
                                {"point":{"x":15.5, "y":83.3, "type":"curve"}},
                                {"point":{"x":15.5, "y":12.5}},
                                {"point":{"x":65.3, "y":-15.0}},
                                {"point":{"x":134.0, "y":-15.0, "type":"curve"}},
                                {"point":{"x":200.1, "y":-15.0}},
                                {"point":{"x":249.9, "y":16.1}}
                        ]}
                ]
        }
}
 
 
More on JSON
http://en.wikipedia.org/wiki/JSON

 
Classes
       
robofab.pens.pointPen.AbstractPointPen
FabToJSONPen

 
class FabToJSONPen(robofab.pens.pointPen.AbstractPointPen)
    Pen object to write glyph outline data to a string in JSON format.
This is not a complete glyph description.
 
  Methods defined here:
__init__(self, glyphSet, indents=2)
addComponent(self, glyphName, transformation)
addPoint(self, pt, segmentType=None, smooth=False, name=None, **kwargs)
beginPath(self)
endPath(self)
getData(self)

 
Functions
       
exportGlyphToJSON(font, glyph, indent=1)
Return a string with a complete glyph description as JSON.