| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A basic OpenType GSUB and GPOS layout engine written in Python.
This document covers the basic usage of the compositor package. For more detailed information read the documentation strings in the source.
Some assumptions about the OpenType fonts being used are made by the package:
from compositor import Fontfont = Font(path)glyph = font["aGlyphName"]Returns the glyph object named aGlyphName. This will raise a KeyError if aGlyphName is not in the font.
isThere = "aGlyphName" in fontReturns a boolean representing if aGlyphName is in the font.
font.keys()A list of all glyph names in the font.
glyphRecords = font.process(aString)This is the most important method. It takes a string (Unicode or plain ASCII) and processes it with the features defined in the font's GSUB and GPOS tables. A list of GlyphRecord objects will be returned.
featureTags = font.getFeatureList()A list of all available features in GSUB and GPOS.
state = font.getFeatureState(featureTag)Get a boolean representing if a feature is on or not. This assumes that the feature state is consistent in both the GSUB and GPOS tables. A CompositorError will be raised if the feature is inconsistently applied. A CompositorError will be raised if featureTag is not defined in GSUB or GPOS.
font.setFeatureState(self, featureTag, state)Set the application state of a feature.
glyph.draw(pen)Draws the glyph with a FontTools pen.
The Compositor GSUB and GPOS tables adhere as closely as possible to the GSUB and GPOS specification. Every effort has been made to keep terminology consistent. All known deviations from the spec are documented. (The deviations are generally trivial. For example, most the of the subtables don't implement the Count attributes. This is done because the Python iterator provides a more convenient and faster way to deal with iteration than creating a range. Therefore, the Count objects are not needed.)
For performance reasons, when a new font is loaded, all of the GSUB and GPOS data is extracted from the font with fontTools. The data is placed into compositor objects. These objects are then used to process text. This initial loading can be relatively expensive, but the processing speed of the objects is worth the initial expense.
To install this package, type the following in the command line:
python setup.py install
| Back | FazBrowse Home | New Git URL |