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: list[str] | tuple[str, ...] | None = None) BaseFontList[source]¶
Get a list of all open fonts.
Optionally, provide a value for sortOptions to sort the fonts. See
BaseFontList.sortByfor options.- Parameters:
sortOptions – The optional
listortupleofstrsort options to apply to the list. Defaults toNone.- Returns:
A
BaseFontListinstance representing all open fonts.
Example:
from fontParts.world import AllFonts 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: str | None = None, styleName: str | None = None, showInterface: bool = True) BaseFont[source]¶
Create a new font.
- Parameters:
familyName – The optional
BaseInfo.familyNameto apply to the font as astr.styleName – The optional
BaseInfo.styleNameto apply to the font as astr.showInterface – A
boolindicating whether to show the graphical interface. IfFalse, the font should be opened without a graphical interface. Defaults toTrue.
- Returns:
The newly created
BaseFontinstance.
Example:
from fontParts.world import NewFont font = NewFont() font = NewFont(familyName="My Family", styleName="My Style") font = NewFont(showInterface=False)
- fontParts.world.OpenFont(path: str, showInterface: bool = True) BaseFont[source]¶
Open font located at the specified path.
- Parameters:
- Returns:
The newly opened
BaseFontinstance.
Example:
from fontParts.world import OpenFont font = OpenFont("/path/to/my/font.ufo") font = OpenFont("/path/to/my/font.ufo", showInterface=False)
- fontParts.world.OpenFonts(directory: str | CollectionType[str] | None = None, showInterface: bool = True, fileExtensions: CollectionType[str] | None = None) Generator[BaseFont][source]¶
Open all fonts located in the specified directories.
The fonts are located within the directory using the
globmodule. The patterns are created withos.path.join(directory, "*" + fileExtension)for every file extension in fileExtensions.- Parameters:
directory – The optional directory
stror thelistortupleof directories to search for fonts. IfNone(default), a dialog for selecting a directory will be opened.showInterface – A
boolindicating whether to show the graphical interface. IfFalse, the font should be opened without a graphical interface. Defaults toTrue.fileExtensions – The optional file extensions to search for as a
listortupleofstritems. IfNone(default), the default file extensions will be used.
- Returns:
A
generatoryielding the opened fonts.
Example:
from fontParts.world import OpenFonts fonts = OpenFonts() fonts = OpenFonts(showInterface=False)
- fontParts.world.CurrentFont() BaseFont[source]¶
Get the currently active font.
- Returns:
A
BaseFontsubclass instance representing the currently active font.
- fontParts.world.CurrentLayer() BaseLayer[source]¶
Get the currently active layer from
CurrentGlyph.- Returns:
A
BaseLayersubclass instance representing the currently active glyph layer.
Example:
from fontParts.world import CurrentLayer layer = CurrentLayer()
- fontParts.world.CurrentGlyph() BaseGlyph[source]¶
Get the currently active glyph from
CurrentFont.- Returns:
A
BaseGlyphsubclass instance representing the currently active glyph.
Example:
from fontParts.world import CurrentGlyph glyph = CurrentGlyph()
- fontParts.world.CurrentContours() tuple[BaseContour, ...][source]¶
Get the currently selected contours from
CurrentGlyph.- Returns:
A
tupleofBaseContoursubclass instances representing the currently selected glyph contours. If nothing is selected, thetuplewill be empty.
Example:
from fontParts.world import CurrentContours contours = CurrentContours()
- fontParts.world.CurrentSegments() tuple[BaseSegment, ...][source]¶
Get the currently selected segments from
CurrentContours.- Returns:
A
tupleofBaseSegmentssubclass instances representing the currently selected contour segments. If nothing is selected, thetuplewill be empty.
Example:
from fontParts.world import CurrentSegments segments = CurrentSegments()
- fontParts.world.CurrentPoints() tuple[BasePoint, ...][source]¶
Get the currently selected points from
CurrentContours.- Returns:
A
tupleofBasePointsubclass instances representing the currently selected contour points. If nothing is selected, thetuplewill be empty.
Example:
from fontParts.world import CurrentPoints points = CurrentPoints()
- fontParts.world.CurrentComponents() tuple[BaseComponent, ...][source]¶
Get the currently selected components from
CurrentGlyph.- Returns:
A
tupleofBaseComponentsubclass instances representing the currently selected glyph components. If nothing is selected, thetuplewill be empty.
Example:
from fontParts.world import CurrentComponents components = CurrentComponents()
- fontParts.world.CurrentAnchors() tuple[BaseAnchor, ...][source]¶
Get the currently selected anchors from
CurrentGlyph.- Returns:
A
tupleofBaseAnchorsubclass instances representing the currently selected glyph anchors. If nothing is selected, thetuplewill be empty.
Example:
from fontParts.world import CurrentAnchors anchors = CurrentAnchors()
- fontParts.world.CurrentGuidelines() tuple[BaseGuideline, ...][source]¶
Get the currently selected guidelines from
CurrentGlyph.This will include both font level and glyph level guidelines.
- Returns:
A
tupleofBaseGuidelinesubclass instances representing the currently selected guidelines. If nothing is selected, thetuplewill be empty.
Example:
from fontParts.world import CurrentGuidelines guidelines = CurrentGuidelines()
- fontParts.world.FontList(fonts: Iterable[T] | None = None)[source]¶
Get a list with font-specific methods.
- Returns:
A
BaseFontListinstance.
Example:
from fontParts.world import FontList fonts = FontList()
Refer to
BaseFontListfor full documentation.