Object Reference

FontParts scripts are built on with objects that represent fonts, glyphs, contours and so on. The objects are obtained through fontParts.world.

fontParts.world

Note

We still need to decide if we need a world module or if we should recommend namespace injection.

fontParts.world.AllFonts()

Get a list of all open fonts.

  • XXX should this include fonts with showInterface=False?
  • XXX define the special sorting methods that must be in the return object.
from fontParts.world import *

fonts = AllFonts()
for font in fonts:
    # do something
fontParts.world.NewFont(familyName=None, styleName=None, showInterface=True)

Create a new font. familyName will be assigned to font.info.familyName and styleName will be assigned to font.info.styleName. These are optional and default to None. If showInterface is False, the font should be created without graphical interface. The default for showInterface is True.

from fontParts.world import *

font = NewFont()
font = NewFont(familyName="My Family", styleName="My Style")
font = NewFont(showInterface=False)
fontParts.world.OpenFont(path, showInterface=True)

Open font located at path. If showInterface is False, the font should be opened without graphical interface. The default for showInterface is True.

from fontParts.world import *

font = OpenFont("/path/to/my/font.ufo")
font = OpenFont("/path/to/my/font.ufo", showInterface=False)
fontParts.world.CurrentFont()

Get the “current” font.

fontParts.world.CurrentLayer()

Get the “current” font’s “current” layer.

from fontParts.world import *

layer = CurrentLayer()
fontParts.world.CurrentGlyph()

Get the “current” font’s “current” layer’s “current” glyph.

from fontParts.world import *

glyph = CurrentGlyph()

Note

CurrentContour() CurrentSegment() CurrentPoint() CurrentAnchor() CurrentGuideline()