robofab.ufoLib
index
/code/projects/robofab/Lib/robofab/ufoLib.py

"
A library for importing .ufo files and their descendants.
This library works with robofab objects. Using the magic of the
U.F.O., common attributes are exported to and read from .plist files.
 
It contains two very simple classes for reading and writing the
various components of the .ufo. Currently, the .ufo supports the
files detailed below. But, these files are not absolutely required.
If the a file is not included in the .ufo, it is implied that the data
of that file is empty.
 
FontName.ufo/
        metainfo.plist      # meta info about the .ufo bundle, most impartantly the
                            # format version number.
        glyphs/
                contents.plist  # a plist mapping all glyph names to file names
                a.glif          # a glif file
                ...etc...
        fontinfo.plist      # font names, versions, copyright, dimentions, etc.
        kerning.plist       # kerning
        lib.plist           # user definable data
        groups.plist        # glyph group definitions

 
Modules
       
os

 
Classes
       
__builtin__.object
UFOReader
UFOWriter

 
class UFOReader(__builtin__.object)
    read the various components of the .ufo
 
  Methods defined here:
__init__(self, path)
getCharacterMapping(self)
Return a dictionary that maps unicode values (ints) to
lists of glyph names.
getGlyphSet(self)
return the GlyphSet associated with the
glyphs directory in the .ufo
readGroups(self)
read groups.plist. returns a dict that should
be applied to a font.groups object.
readInfo(self, info)
read info.plist. it requires a font.info object
as an argument. this will write the attributes
defined in the file into the info object.
readKerning(self)
read kerning.plist. returns a dict that should
be applied to a font.kerning object.
readLib(self)
read lib.plist. returns a dict that should
be applied to a font.lib object.
readMetaInfo(self)
read metainfo.plist. mostly used
for internal operations

Data and other attributes defined here:
__dict__ = <dictproxy object at 0x1665bf0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'UFOReader' objects>
list of weak references to the object (if defined)

 
class UFOWriter(__builtin__.object)
    write the various components of the .ufo
 
  Methods defined here:
__init__(self, path)
getGlyphSet(self, glyphNameToFileNameFunc=None)
return the GlyphSet associated with the
glyphs directory in the .ufo
makeGlyphPath(self)
make the glyphs directory in the .ufo
returns the path of the directory created
writeGroups(self, groups)
write groups.plist. this method requires a
dict of glyph groups as an argument.
writeInfo(self, info)
write info.plist. this method requires a
font.info object. attributes will be taken from
the given object and written into the file
writeKerning(self, kerning)
write kerning.plist. this method requires a
dict of kerning pairs as an argument
writeLib(self, libDict)
write lib.plist. this method requires a
lib dict as an argument

Data and other attributes defined here:
__dict__ = <dictproxy object at 0x1669fb0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'UFOWriter' objects>
list of weak references to the object (if defined)
fileCreator = 'org.robofab.ufoLib'
formatVersion = 1

 
Functions
       
StringIO(...)
StringIO([s]) -- Return a StringIO-like stream for reading or writing
makeUFOPath(fontPath)
return a .ufo pathname based on a .vfb pathname
writePlistAtomically(obj, path)
Write a plist for 'obj' to 'path'. Do this sort of atomically,
making it harder to cause corrupt files, for example when writePlist
encounters an error halfway during write. Also: don't write out the
file if it would be identical to what's already there, meaning the
modification date won't get stomped when writing the same data.

 
Data
        FONTINFO_FILENAME = 'fontinfo.plist'
GLYPHS_DIRNAME = 'glyphs'
GROUPS_FILENAME = 'groups.plist'
KERNING_FILENAME = 'kerning.plist'
LIB_FILENAME = 'lib.plist'
METAINFO_FILENAME = 'metainfo.plist'
READ_MODE = 'r'
WRITE_MODE = 'w'
fontInfoAttrs = ['familyName', 'styleName', 'fullName', 'fontName', 'menuName', 'fontStyle', 'note', 'versionMajor', 'versionMinor', 'year', 'copyright', 'notice', 'trademark', 'license', 'licenseURL', 'createdBy', 'designer', 'designerURL', 'vendorURL', 'unitsPerEm', ...]