Computers & Writing Systems
You are here: Type Design > Resources
Table of Contents
FLGlyphBuilder is a Python script for building composite glyphs in FontLab. The composite glyphs can be built using attachment points and/or shifting of component glyphs. Using attachment points, composites are assembled by describing which attachment points should coincide, rather than having to give absolute locations in terms of shifting. Within FontLab, attachment points are created as anchors on specific glyphs. The constructed composites inherit attachment points from their components. FLGlyphBuilder is controlled by a composite definition file. This XML file contains the following key elements:
Composite Definition File
This describes a glyph and the attributes allow setting of the name and Unicode id for the glyph. The glyph element has children which describe what goes into the glyph.
The "overstrike" attribute controls whether an attachment to a base glyph can extend beyond the origin or the advance width of the base glyph. The default is set by the default_overstrike global variable (see below). Set to 1 to allow attached glyphs to extend to the left of origin or to the right of advance. Set to 0 to shift attached glyphs right and increase advance so overstriking of adjacent glyphs does not happen.
A base character is a reference to a glyph via Unicode id, postscript name, or glyph id which is used in building the composite glyph. If there is more than one base glyph in a composite glyph, then the base glyphs are concatenated in sequence according to their advance widths.
A base glyph may have attachments (eg diacritics), which may have their own attachments in their turn. The "attach" element has two attributes which name the attachment point on the base ("at") and the attachment point on the diacritic ("with") which are used for positioning so that the attachment points coincide. If these are missing, then the glyphs are aligned centrally in the x direction and with no adjustment vertically.
It is also possible to shift base and attach glyphs. Shifting occurs after attachment (for obvious reasons) if both are used together.
Here is a sample composite definition XML file:
<?xml version="1.0"?> <font> <glyph PSName="LtnSmA.Sup"> <base PSName="LtnSupSmA"/> </glyph> <glyph PSName="LtnSmAAcute" UID="00E1"> <base PSName="LtnSmA"> <attach PSName="CombAcute" with="_U" at="U"/> </base> </glyph> <glyph PSName="LtnSmACircumAcute" UID="1EA5"> <base PSName="LtnSmA"> <attach PSName="CombCircum" with="_U" at="U"> <attach PSName="CombAcute" with="_U" at="U"/> </attach> </base> </glyph> <glyph PSName="SmRomNumTwo" UID="2171"> <base PSName="LtnSmI"/> <base PSName="LtnSmI"/> </glyph> <glyph PSName="GrSubSmBeta" UID="1D66"> <base PSName="ModSmBeta"> <shift x="0" y="-1256"/> </base> </glyph> </font>
The DTD is below.
FLGlyphBuilder works with anchors in the FontLab glyphs. Thus a designer adds an attachment point to a glyph by adding an anchor into the glyph design in Fontlab.
FLGlyphBuilder has several global variables which should be set before it is ran within the FontLab macro window. Below is a description of these variables. See the script file for more details.
This may be set to the actual composite definition file to use, otherwise setting it to None will cause the composite definition file to be built from the font filename with the fileext.
The composite definition file name is assumed to be the same as the fontlab filename minus its .vfb extension and with this value appended.
Logging information is output to this file or the screen if set to None.
A file containing a list of glyphs in the ctlfile that should not be created by FLGlyphBuilder. Used to handle composite glyphs that need manual adjustment of compoment placement or inherited attachment points. Can be set to None so all glyphs in the ctlfile are built to create drafts, then set to a file name to prevent rebuilding so manual adjustments can be safely applied.
The stoplist contains a list of glyph names. Comments can be added if the beginning of a line is #. Blank lines are allowed. An example is below.
Another file containing a stop list used as above.
stoplist1 can be used for problem composites in all faces while stoplist2 can be used for problem composites in a particular face.
Controls whether overstrike guarding occurs by default or not. Sets the default value for the overstrike attribute on the glyph element (see above).
This variable controls what happens if a glyph is created that already exists in the font. The variable can take any of these values:
Controls various aspects of the behaviour of FLGlyphBuilder. This is a bit field with each bit position having a meaning.
This is a bitfield value that controls what information will be output during the process, primary for debugging purposes.
Control what information is output to the log
This is a hash of color values to use for different types of glyph. See FLGlyphBuilder.py for details.
Fontlab object that constitutes the source font. Defaults to the current font.
Fontlab object in which to create new glyphs. Defaults to the current font but may be another font, to create a new font or add glyphs to another font.
Here is a sample stop list:
# Ogonek moved to match curve of o LtnSmOOgonekMacron # U moved up LtnSmOOgonekMacron LtnSmAeMacron LtnCapADotAbvMacron
The DTD for the composite definition file is:
<!ELEMENT font (glyph)+> <!ELEMENT glyph (base)+> <!ATTLIST glyph PSName CDATA #IMPLIED UID CDATA #IMPLIED GID CDATA #IMPLIED overstrike (0 | false | 1 | true ) #IMPLIED> <!ELEMENT base (attach | shift)*> <!ATTLIST base PSName CDATA #IMPLIED UID CDATA #IMPLIED GID CDATA #IMPLIED> <!ELEMENT attach (shift)*> <!ATTLIST attach PSName CDATA #IMPLIED UID CDATA #IMPLIED GID CDATA #IMPLIED with CDATA #IMPLIED at CDATA #IMPLIED> <!ELEMENT shift EMPTY> <!ATTLIST shift x CDATA #IMPLIED y CDATA #IMPLIED>
The original FLGlyphBuilder was (and is) a Perl script which works directly on TrueType font (ttf) files. The script on this page is a rewrite for FontLab in Python. It supports only a subset of the features of the Perl version. The Perl ttfbuilder package is available on CPAN Perl TTFBuilder. Consult that script for the definitive format for the XML composite definition file. The name of the Perl script may be changed to GlyphBuilder in the future. Thanks to Martin Hosken for creating the intial version of FLGlyphBuilder.
Note: If you want to add a response to this article, you need to enable cookies in your browser, and then restart your browser.
Note: the opinions expressed in submitted contributions below do not necessarily reflect the opinions of our website.
© 2003-2023 SIL International, all rights reserved, unless otherwise noted elsewhere on this page.