mojo.roboFont

version

buildNumber

internalFontClasses

AllFonts(*deprecatedSortOptions, sortOptions=None, reverse=False)

Return a list of all open fonts.

Optional sorting options can be provided. see FontsList

CurrentFont()

Return the front most open font.

CurrentGlyph()

Return the front current glyph.

NewFont(familyName=None, styleName=None, showInterface=True, showUI=None)

Open a new font. Optional familyName and styleName can be provided. Use showInterface (bool) to indicate if the font should be opened in the UI.

OpenFont(pathOrObject=None, showInterface=True, showUI=None)

Open a font with a given path. If no path is given a get file dialog will pop up. Optionally showInterface can be toggle on/off.

OpenFonts(directory=None, showInterface=True, fileExtensions=None)

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)

OpenWindow(controller, *args, **kwargs)

Open window and control if that window is not openend twice.

Return True when the window is already opened. False if a new instance of the window is opened.

CreateCursor(pathOrImage, hotSpot=(4, 4))

Create a cursor from a path or an NSImage. Optional a hotSpot x, y tuple can be provided.

testRoboFontEnvironment(showInterface=False)

class FontsList()

A list object to sort fonts according to different options.

Inherits from subclass: fontParts.world.BaseFontList

append

clear

count

extend

index

insert

pop

remove

reverse

sort

getFontsByFamilyName(familyName)

Get a list of fonts that match familyName. This will return an instance of BaseFontList.

getFontsByFamilyNameStyleName(familyName, styleName)

Get a list of fonts that match familyName and styleName. This will return an instance of BaseFontList.

getFontsByFontInfoAttribute(*attributeValuePairs)

Get a list of fonts that match the (attribute, value) combinations in attributeValuePairs.

>>> subFonts = fonts.getFontsByFontInfoAttribute(("xHeight", 20))
>>> subFonts = fonts.getFontsByFontInfoAttribute(("xHeight", 20), ("descender", -150))

This will return an instance of BaseFontList.

getFontsByStyleName(styleName)

Get a list of fonts that match styleName. This will return an instance of BaseFontList.

sortBy(sortOptions, reverse=False)

Sort fonts with the ordering preferences defined by sortBy. sortBy must be one of the following:

  • sort description string
  • BaseInfo attribute name
  • sort value function
  • list/tuple containing sort description strings, BaseInfo attribute names and/or sort value functions
  • "magic"

Sort Description Strings

The sort description strings, and how they modify the sort, are:

   
“familyName” | F amily names by alphabetical order.
“styleName” | S tyle names by alphabetical order.
“isItalic” | I talics before romans.
“isRoman” | R omans before italics.
“widthValue” | W idth values by numerical order.
“weightValue” | W eight values by numerical order.
“monospace” | M onospaced before proportional.
“proportional” | P roportional before monospaced.
>>> fonts.sortBy(("familyName", "styleName"))

Font Info Attribute Names

Any BaseFont attribute name may be included as a sort option. For example, to sort by x-height value, you’d use the "xHeight" attribute name.

>>> fonts.sortBy("xHeight")

Sort Value Function

A sort value function must be a function that accepts one argument, font. This function must return a sortable value for the given font. For example:

def glyphCountSortValue(font):
    return len(font)

>>> fonts.sortBy(glyphCountSortValue)

A list of sort description strings and/or sort functions may also be provided. This should be in order of most to least important. For example, to sort by family name and then style name, do this:

“magic”

If “magic” is given for sortBy, the fonts will be sorted based on this sort description sequence:

  • "familyName"
  • "isProportional"
  • "widthValue"
  • "weightValue"
  • "styleName"
  • "isRoman"

    fonts.sortBy(“magic”)

Last edited on 18/03/2024