fontParts.world

Note

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

fontParts.world.AllFonts(sortOptions=None)[source]

Get a list of all open fonts. Optionally, provide a value for sortOptions to sort the fonts. See world.FontList.sortBy for options.

from fontParts.world import *

fonts = AllFonts()
for font in fonts:
    # do something

fonts = AllFonts("magic")
for font in fonts:
    # do something

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

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)[source]

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.OpenFonts(directory=None, showInterface=True, fileExtensions=None)[source]

Open all fonts with the given fileExtensions located in directory. If directory is None, a dialog for selecting a directory will be opened. directory may also be a list of directories. If showInterface is False, the font should be opened without graphical interface. The default for showInterface is True.

The fonts are located within the directory using the glob <https://docs.python.org/library/glob.html>`_ module. The patterns are created with os.path.join(glob, "*" + fileExtension) for every file extension in fileExtensions. If fileExtensions if None the environment will use its default fileExtensions.

from fontParts.world import *

fonts = OpenFonts()
fonts = OpenFonts(showInterface=False)
fontParts.world.CurrentFont()[source]

Get the “current” font.

fontParts.world.CurrentLayer()[source]

Get the “current” layer from CurrentGlyph.

from fontParts.world import *

layer = CurrentLayer()
fontParts.world.CurrentGlyph()[source]

Get the “current” glyph from CurrentFont.

from fontParts.world import *

glyph = CurrentGlyph()
fontParts.world.CurrentContours()[source]

Get the “currently” selected contours from CurrentGlyph.

from fontParts.world import *

contours = CurrentContours()

This returns an immutable list, even when nothing is selected.

fontParts.world.CurrentSegments()[source]

Get the “currently” selected segments from CurrentContours.

from fontParts.world import *

segments = CurrentSegments()

This returns an immutable list, even when nothing is selected.

fontParts.world.CurrentPoints()[source]

Get the “currently” selected points from CurrentContours.

from fontParts.world import *

points = CurrentPoints()

This returns an immutable list, even when nothing is selected.

fontParts.world.CurrentComponents()[source]

Get the “currently” selected components from CurrentGlyph.

from fontParts.world import *

components = CurrentComponents()

This returns an immutable list, even when nothing is selected.

fontParts.world.CurrentAnchors()[source]

Get the “currently” selected anchors from CurrentGlyph.

from fontParts.world import *

anchors = CurrentAnchors()

This returns an immutable list, even when nothing is selected.

fontParts.world.CurrentGuidelines()[source]

Get the “currently” selected guidelines from CurrentGlyph. This will include both font level and glyph level guidelines.

from fontParts.world import *

guidelines = CurrentGuidelines()

This returns an immutable list, even when nothing is selected.

fontParts.world.FontList(fonts=None)[source]

Get a list with font specific methods.

from fontParts.world import *

fonts = FontList()

Refer to BaseFontList for full documentation.

class fontParts.world.BaseFontList[source]