Legend:
Library
Module
Module type
Parameter
Class
Class type
FontForge Font object. It generally contains a list of glyphs, an encoding to order those glyphs, a fontname, a list of GPOS/GSUB lookups and many other things. API: almost complete (all listed even the unimplemented ones) compared to the Python API.
FontForge module
type t
Abstract type for fonts
Python workarounds
val contains_glyphname : glyphname:string ->t-> bool
Equivalent to the Python expression: glyphname in font. Returns whether the font contains a glyph with the given name.
i.e. let feature = lookupFeature feature:"liga" scripts:[script]
Creates a new lookup with the given name, type and flags. It will tag it with any indicated features. The type of one of
gsub_single
gsub_multiple
gsub_alternate
gsub_ligature
gsub_context
gsub_contextchain
gsub_revesechain
morx_indic
morx_context
morx_insert
gpos_single
gpos_pair
gpos_cursive
gpos_mark2base
gpos_mark2ligature
gpos_mark2mark
gpos_context
gpos_contextchain
kern_statemachine
The flags argument is a tuple of strings. At most one of these strings may be the name of a mark class. The others are:
right_to_left
ignore_bases
ignore_ligatures
ignore_marks
A feature-script-lang tuple is a tuple with one entry for each feature (there may be no entries if there are no features). Each entry is itself a two element tuple, the first entry is a string containing a 4 letter feature tag, and the second entry is another tuple (potentially empty) with an entry for each script for which the feature is active. Each entry here is itself a two element tuple. The first element is a 4 letter script tag and the second is a tuple of languages. Each entry in the language tuple is a four letter language.
Example: (("liga",(("latn",("dflt")),)),) The optional final argument allows you to specify the ordering of the lookup. If not specified the lookup will be come the first lookup in its table.
Creates a new lookup with the given name, type and flags. It will tag it with any indicated features. The type of one of
gsub_single
gsub_multiple
gsub_alternate
gsub_ligature
gsub_context
gsub_contextchain
gsub_revesechain
morx_indic
morx_context
morx_insert
gpos_single
gpos_pair
gpos_cursive
gpos_mark2base
gpos_mark2ligature
gpos_mark2mark
gpos_context
gpos_contextchain
kern_statemachine
The flags argument is a tuple of strings. At most one of these strings may be the name of a mark class. The others are:
right_to_left
ignore_bases
ignore_ligatures
ignore_marks
A feature-script-lang tuple is a tuple with one entry for each feature (there may be no entries if there are no features). Each entry is itself a two element tuple, the first entry is a string containing a 4 letter feature tag, and the second entry is another tuple (potentially empty) with an entry for each script for which the feature is active. Each entry here is itself a two element tuple. The first element is a 4 letter script tag and the second is a tuple of languages. Each entry in the language tuple is a four letter language.
Example: (("liga",(("latn",("dflt")),)),) The optional final argument allows you to specify the ordering of the lookup. If not specified the lookup will be come the first lookup in its table.
Creates a new subtable within the specified lookup. The lookup name should be a string specifying an existing lookup. The subtable name should also be a string and should not match any currently existing subtable in the lookup. The optional final argument allows you to specify the ordering within the lookup. If not specified this subtable will be first in the lookup. If you want to create a subtable in a contextual lookup, then use addContextualSubtable below. If you want to create a kerning class subtable, then use addKerningClass above.
TODO
val addContextualSubtable: lookupname:string -> subtable:string -> subtabletype:string -> rule: ?? -> ?afterSubtable:string -> ?bclasses:string -> mclasses: string -> ?fclasses:string -> ?bclassnames:string -> ?mclassnames:string -> ?fclassnames:string -> t -> unit
Removes any existing AALT features (and any lookups solely controled by such features) and creates new ones containing all possible single and alternate substutions available for each glyph.
Removes any existing AALT features (and any lookups solely controled by such features) and creates new ones containing all possible single and alternate substutions available for each glyph.
Converts a normal font into a CID-keyed font with one subfont using the CMAP to determine the mapping.
Removes the current subfont from a cid-keyed font.
Frees memory for the current font. Warning: Any python pointers to it will become invalid.
TODO
compareFonts
val createChar : unicode:int ->?name:string ->t->Glyph.t
Create (and return) a character at the specified unicode codepoint in this font and optionally name it. If you wish to create an glyph with no unicode codepoint set the first argument to -1 and specify a name. If there is already a character there, return it (it will not be renamed).
Merge feature and lookup information from an adobe feature file, or metrics information from the (afm,tfm,etc) file into the current font.
Deprecated name for mergeFeature above
val mergeLookups : lookupname1:string ->lookupname2:string ->t-> unit
Deprecated name for mergeFeature above
The lookups must be of the same type. All subtables from lookupname2 will be moved to lookupname1, the features list of lookupname2 will be merged with that of lookupname1, and lookupname2 will be removed.
val mergeLookupSubtables : subtable1:string ->subtable2:string ->t-> unit
The lookups must be of the same type. All subtables from lookupname2 will be moved to lookupname1, the features list of lookupname2 will be merged with that of lookupname1, and lookupname2 will be removed.
The subtables must be in the same lookup. Not all lookup types allow their subtables to be merged (contextual subtables may not be merged, kerning classes may not be (kerning pairs may be)). Any information bound to subtable2 will be bound to subtable1 and subtable2 will be removed.
TODO
printSample
val randomText : script:string ->?lang:string ->t-> string
Returns a random text sample using the letter frequencies of the specified script (and optionally language). Both script and language should be expressed as strings containing OpenType Script and Language tags. "dflt" is a reasonable language tag. If the language is not specified, one will be chosen at random. If FontForge has no frequency information for the script/language specified it will use the letters in the script with equal frequencies.
Returns a random text sample using the letter frequencies of the specified script (and optionally language). Both script and language should be expressed as strings containing OpenType Script and Language tags. "dflt" is a reasonable language tag. If the language is not specified, one will be chosen at random. If FontForge has no frequency information for the script/language specified it will use the letters in the script with equal frequencies.
A tuple with an entry for each bitmap strike to be regenerated (rerasterized). Each strike is identified by pixelsize (if the strike is a grey scale font it will be indicated by (bitmap-depth<<16)|pixelsize.
val removeAnchorClass : anchorclass:string ->t-> unit
Removes the named AnchorClass (and all associated points) from the font.
Remove the subtable (and all data associated with it).
You may either pass in a FontForge glyph object (from this font) or identify a glyph in the font by unicode code point or name. In any case the glyph will be removed from the font. WARNING: This frees fontforge's storage to this glyph. If you have any python pointers (also FFglyph.t value) to that storage they will be looking at garbage. This does not go through the usual python reference mechanism.
val removeGlyph_from_unicode : unicode:int ->t-> unit
You may either pass in a FontForge glyph object (from this font) or identify a glyph in the font by unicode code point or name. In any case the glyph will be removed from the font. WARNING: This frees fontforge's storage to this glyph. If you have any python pointers (also FFglyph.t value) to that storage they will be looking at garbage. This does not go through the usual python reference mechanism.
Shortcut using removeGlyph.
val removeGlyph_from_glyphname : glyphname:string ->t-> unit
Shortcut using removeGlyph.
Shortcut using removeGlyph.
val removeGlyph_from_glyph : glyph:Glyph.t->t-> unit
Reloads the font from the disk. Caveat: if you have any pointers to glyphs which live in the font those pointers will no longer be valid, and using them will cause crashes. This is very un-python-like.
Reloads the font from the disk. Caveat: if you have any pointers to glyphs which live in the font those pointers will no longer be valid, and using them will cause crashes. This is very un-python-like.
Reloads the font from the backup file on the disk. Caveat: if you have any pointers to glyphs which live in the font those pointers will no longer be valid, and using them will cause crashes. This is very un-python-like.
Reloads the font from the backup file on the disk. Caveat: if you have any pointers to glyphs which live in the font those pointers will no longer be valid, and using them will cause crashes. This is very un-python-like.
Saves the font to an sfd file. See also generate()
Gets binary data from any saved table. FontForge will save 'fpgm', 'prep', 'cvt ' and 'maxp'. FontForge may also save tables which you explicitly request. Do not expect to get binary data for tables like 'GPOS' or 'glyf' which FontForge will generate when it creates a font... that information is not currently available. Returns a binary string.
Validates the font and returns a bit mask of all errors from all glyphs (as defined in the validation_state of a glyph -- except bit 0x1 is clear). If the font passed the validation then the return value will be 0 (not 0x1). Otherwise the return value will be the set of errors found. Note: The set of errors is slightly different for TrueType and PostScript output. The returned mask contains the list of potential errors. You must figure out which apply to you.
Normally each glyph will cache its validation_state and it will not be recalculated. If you pass a non-zero argument to the routine then it will force recalculation of each glyph -- this can be slow.s
Extrema should be marked by on-curve points. If a curve in any selected glyph lacks a point at a significant extremum this command will add one.
For all selected upper or lower case letters in the latin, greek and cyrillic scripts this will try to create a small caps version of that glyph in a new glyph slot. So if you select "A" (or "a") then a glyph "a.sc" will be created (if "a.sc" already exists, it will be reused, and its current contents cleared). The contents of "a.sc" will be based on the upper case variant of this glyph (and that variant must be present for the command to work). FontForge will also create two lookups (unless appropriate ones already exist) one, bound to the feature 'c2sc' will map upper case letters to small caps, the other, bound to feature 'smcp' will map lower case letters to small caps.
For all selected upper or lower case letters in the latin, greek and cyrillic scripts this will try to create a small caps version of that glyph in a new glyph slot. So if you select "A" (or "a") then a glyph "a.sc" will be created (if "a.sc" already exists, it will be reused, and its current contents cleared). The contents of "a.sc" will be based on the upper case variant of this glyph (and that variant must be present for the command to work). FontForge will also create two lookups (unless appropriate ones already exist) one, bound to the feature 'c2sc' will map upper case letters to small caps, the other, bound to feature 'smcp' will map lower case letters to small caps.
Generates PostScript hints for all selected glyphs.
Auto traces any background images in all selected glyphs.
If any of the selected characters is a composite character, then this command will clear it and insert references to its components (this command can create new glyphs).
If any of the selected characters is a composite character, then this command will clear it and insert references to its components (this command can create new glyphs).
Orders the contours in the selected glyphs by the x coordinate of their leftmost point. This can reduce the size of the charstring needed to describe the glyph(s).
Orders the contours in the selected glyphs by the x coordinate of their leftmost point. This can reduce the size of the charstring needed to describe the glyph(s).
Sets the start point of all the contours of the selected glyphs to be the leftmost point on the contour. If there are several points with that value then use the one which is closest to the baseline. This can reduce the size of the charstring needed to describe the glyph(s). By regularizing things it can also make more things available to be put in subroutines.
Sets the start point of all the contours of the selected glyphs to be the leftmost point on the contour. If there are several points with that value then use the one which is closest to the baseline. This can reduce the size of the charstring needed to describe the glyph(s). By regularizing things it can also make more things available to be put in subroutines.
Orients all contours so that external ones are clockwise and internal counter-clockwise in all selected glyphs.
Checks a font for glyphs with mixed contours and references (or references with transformation matrices which cannot be represented truetype (ie. scaling by 2 or more)). If a mixed case is discovered fontforge will take the contours out of the glyph, put them in a new glyph, and make a reference to the new glyph.
Checks a font for glyphs with mixed contours and references (or references with transformation matrices which cannot be represented truetype (ie. scaling by 2 or more)). If a mixed case is discovered fontforge will take the contours out of the glyph, put them in a new glyph, and make a reference to the new glyph.
Copies all selected glyphs into (fontforge's internal) clipboard. And then clears them.
Pastes the contents of (fontforge's internal) clipboard into the selected glyphs -- and retains what was there before.
Removes overlapping areas in all selected glyphs. See also intersect.
val replaceWithReference : ?fudge:float ->t-> unit
Removes overlapping areas in all selected glyphs. See also intersect.
Finds any glyph which contains an inline copy of one of the selected glyphs, and converts that copy into a reference to the appropriate glyph. Selection is changed to the set of glyphs which the command alters. If specified the fudge argument specifies the error allowed for coordinate differences.
Finds any glyph which contains an inline copy of one of the selected glyphs, and converts that copy into a reference to the appropriate glyph. Selection is changed to the set of glyphs which the command alters. If specified the fudge argument specifies the error allowed for coordinate differences.
Rounds the x and y coordinates of each point in all selected glyphs. If factor is specified then new-coord = round(factor*old-coord)/factor. See also cluster.
val nltransform : xexpr:string ->yexpr:string ->t-> unit
Transforms all selected glyphs by the matrix.
xexpr and yexpr are strings specifying non-linear transformations that will be applied to all points in the selected glyphs of the font (with xexpr being applied to x values, and yexpr to y values, of course). The syntax for the expressions is explained in the non-linear transform dialog.
xexpr and yexpr are strings specifying non-linear transformations that will be applied to all points in the selected glyphs of the font (with xexpr being applied to x values, and yexpr to y values, of course). The syntax for the expressions is explained in the non-linear transform dialog.
Unlinks all references in all selected glyphs and replaces them with splines.
Attributes
Submodules giving read and write access to FontForge contour attributes.