% language=uk
\environment luatex-style
\environment luatex-logos
\startcomponent luatex-fontloader
\startchapter[reference=fontloader,title={The fontloader}]
The fontloader library is sort of independent of the rest in the sense that it
can load font into a \LUA\ table that then can be converted into a table suitable
for \TEX. The library is an adapted subset of \FONTFORGE\ and as such gives a
similar view on a font (which has advantages when you want to debug.)
\section{Getting quick information on a font}
When you want to locate font by name you need some basic information that is
hidden in the font files. For that reason we provide an efficient helper that
gets the basic information without loading all of the font. Normally this helper
is used to create a font (name) database.
\startfunctioncall
info =
fontloader.info( filename)
\stopfunctioncall
This function returns either \type {nil}, or a \type {table}, or an array of
small tables (in the case of a \TRUETYPE\ collection). The returned table(s) will
contain some fairly interesting information items from the font(s) defined by the
file:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{fontname} \NC string \NC the \POSTSCRIPT\ name of the font\NC \NR
\NC \type{fullname} \NC string \NC the formal name of the font\NC \NR
\NC \type{familyname} \NC string \NC the family name this font belongs to\NC \NR
\NC \type{weight} \NC string \NC a string indicating the color value of the font\NC \NR
\NC \type{version} \NC string \NC the internal font version\NC \NR
\NC \type{italicangle} \NC float \NC the slant angle\NC \NR
\NC \type{units_per_em} \NC number \NC 1000 for \POSTSCRIPT-based fonts, usually 2048 for \TRUETYPE\NC \NR
\NC \type{pfminfo} \NC table \NC (see \in{section}[fontloaderpfminfotable])\NC \NR
\stoptabulate
Getting information through this function is (sometimes much) more efficient than
loading the font properly, and is therefore handy when you want to create a
dictionary of available fonts based on a directory contents.
\section{Loading an \OPENTYPE\ or \TRUETYPE\ file}
If you want to use an \OPENTYPE\ font, you have to get the metric information
from somewhere. Using the \type {fontloader} library, the simplest way to get
that information is thus:
\starttyping
function load_font (filename)
local metrics = nil
local font = fontloader.open(filename)
if font then
metrics = fontloader.to_table(font)
fontloader.close(font)
end
return metrics
end
myfont = load_font('/opt/tex/texmf/fonts/data/arial.ttf')
\stoptyping
The main function call is
\startfunctioncall
f, w = fontloader.open( filename)
f, w = fontloader.open( filename, fontname)
\stopfunctioncall
The first return value is a userdata representation of the font. The second
return value is a table containing any warnings and errors reported by fontloader
while opening the font. In normal typesetting, you would probably ignore the
second argument, but it can be useful for debugging purposes.
For \TRUETYPE\ collections (when filename ends in 'ttc') and \DFONT\ collections,
you have to use a second string argument to specify which font you want from the
collection. Use the \type {fontname} strings that are returned by \type
{fontloader.info} for that.
To turn the font into a table, \type {fontloader.to_table} is used on the font
returned by \type {fontloader.open}.
\startfunctioncall
f = fontloader.to_table( font)
\stopfunctioncall
This table cannot be used directly by \LUATEX\ and should be turned into another
one as described in~\in {chapter} [fonts]. Do not forget to store the \type
{fontname} value in the \type {psname} field of the metrics table to be returned
to \LUATEX, otherwise the font inclusion backend will not be able to find the
correct font in the collection.
See \in {section} [fontloadertables] for details on the userdata object returned
by \type {fontloader.open()} and the layout of the \type {metrics} table returned
by \type {fontloader.to_table()}.
The font file is parsed and partially interpreted by the font loading routines
from \FONTFORGE. The file format can be \OPENTYPE, \TRUETYPE, \TRUETYPE\
Collection, \CFF, or \TYPEONE.
There are a few advantages to this approach compared to reading the actual font
file ourselves:
\startitemize
\startitem
The font is automatically re|-|encoded, so that the \type {metrics} table for
\TRUETYPE\ and \OPENTYPE\ fonts is using \UNICODE\ for the character indices.
\stopitem
\startitem
Many features are pre|-|processed into a format that is easier to handle than
just the bare tables would be.
\stopitem
\startitem
\POSTSCRIPT|-|based \OPENTYPE\ fonts do not store the character height and
depth in the font file, so the character boundingbox has to be calculated in
some way.
\stopitem
\startitem
In the future, it may be interesting to allow \LUA\ scripts access to
the font program itself, perhaps even creating or changing the font.
\stopitem
\stopitemize
A loaded font is discarded with:
\startfunctioncall
fontloader.close( font)
\stopfunctioncall
\section{Applying a \quote{feature file}}
You can apply a \quote{feature file} to a loaded font:
\startfunctioncall
errors = fontloader.apply_featurefile( font, filename)
\stopfunctioncall
A \quote {feature file} is a textual representation of the features in an
\OPENTYPE\ font. See
\starttyping
http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html
\stoptyping
and
\starttyping
http://fontforge.sourceforge.net/featurefile.html
\stoptyping
for a more detailed description of feature files.
If the function fails, the return value is a table containing any errors reported
by fontloader while applying the feature file. On success, \type {nil} is
returned.
\section{Applying an \quote{\AFM\ file}}
You can apply an \quote {\AFM\ file} to a loaded font:
\startfunctioncall
errors = fontloader.apply_afmfile( font, filename)
\stopfunctioncall
An \AFM\ file is a textual representation of (some of) the meta information
in a \TYPEONE\ font. See
\starttyping
ftp://ftp.math.utah.edu/u/ma/hohn/linux/postscript/5004.AFM_Spec.pdf
\stoptyping
for more information about \AFM\ files.
Note: If you \type {fontloader.open()} a \TYPEONE\ file named \type {font.pfb},
the library will automatically search for and apply \type {font.afm} if it exists
in the same directory as the file \type {font.pfb}. In that case, there is no
need for an explicit call to \type {apply_afmfile()}.
If the function fails, the return value is a table containing any errors reported
by fontloader while applying the AFM file. On success, \type {nil} is returned.
\section[fontloadertables]{Fontloader font tables}
As mentioned earlier, the return value of \type {fontloader.open()} is a userdata
object. One way to have access to the actual metrics is to call \type
{fontloader.to_table()} on this object, returning the table structure that is
explained in the following sections. In teh following sections we will not
explain each field in detail. Most fields are self descriptive and for the more
technical aspects you need to consult the relevant font references.
It turns out that the result from \type {fontloader.to_table()} sometimes needs
very large amounts of memory (depending on the font's complexity and size) so it
is possible to access the userdata object directly.
\startitemize
\startitem
All top|-|level keys that would be returned by \type {to_table()}
can also be accessed directly.
\stopitem
\startitem
The top|-|level key \quote {glyphs} returns a {\it virtual\/} array that
allows indices from \type {f.glyphmin} to (\type {f.glyphmax}).
\stopitem
\startitem
The items in that virtual array (the actual glyphs) are themselves also
userdata objects, and each has accessors for all of the keys explained in the
section \quote {Glyph items} below.
\stopitem
\startitem
The top|-|level key \quote {subfonts} returns an {\it actual} array of userdata
objects, one for each of the subfonts (or nil, if there are no subfonts).
\stopitem
\stopitemize
A short example may be helpful. This code generates a printout of all
the glyph names in the font \type {PunkNova.kern.otf}:
\starttyping
local f = fontloader.open('PunkNova.kern.otf')
print (f.fontname)
local i = 0
if f.glyphcnt > 0 then
for i=f.glyphmin,f.glyphmax do
local g = f.glyphs[i]
if g then
print(g.name)
end
i = i + 1
end
end
fontloader.close(f)
\stoptyping
In this case, the \LUATEX\ memory requirement stays below 100MB on the test
computer, while the internal structure generated by \type {to_table()} needs more
than 2GB of memory (the font itself is 6.9MB in disk size).
Only the top|-|level font, the subfont table entries, and the glyphs are virtual
objects, everything else still produces normal \LUA\ values and tables.
If you want to know the valid fields in a font or glyph structure, call the \type
{fields} function on an object of a particular type (either glyph or font):
\startfunctioncall
fields = fontloader.fields( font)
fields = fontloader.fields( font_glyph)
\stopfunctioncall
For instance:
\startfunctioncall
local fields = fontloader.fields(f)
local fields = fontloader.fields(f.glyphs[0])
\stopfunctioncall
\section{Table types}
\subsection{Top-level}
The top|-|level keys in the returned table are (the explanations in this part of
the documentation are not yet finished):
\starttabulate[|l|l|p|]
\BC key \BC type \NC explanation \NC \NR
\NC \type{table_version} \NC number \NC indicates the metrics version (currently~0.3)\NC \NR
\NC \type{fontname} \NC string \NC \POSTSCRIPT\ font name\NC \NR
\NC \type{fullname} \NC string \NC official (human-oriented) font name\NC \NR
\NC \type{familyname} \NC string \NC family name\NC \NR
\NC \type{weight} \NC string \NC weight indicator\NC \NR
\NC \type{copyright} \NC string \NC copyright information\NC \NR
\NC \type{filename} \NC string \NC the file name\NC \NR
\NC \type{version} \NC string \NC font version\NC \NR
\NC \type{italicangle} \NC float \NC slant angle\NC \NR
\NC \type{units_per_em} \NC number \NC 1000 for \POSTSCRIPT-based fonts, usually 2048 for \TRUETYPE\NC \NR
\NC \type{ascent} \NC number \NC height of ascender in \type {units_per_em}\NC \NR
\NC \type{descent} \NC number \NC depth of descender in \type {units_per_em}\NC \NR
\NC \type{upos} \NC float \NC \NC \NR
\NC \type{uwidth} \NC float \NC \NC \NR
\NC \type{uniqueid} \NC number \NC \NC \NR
\NC \type{glyphs} \NC array \NC \NC \NR
\NC \type{glyphcnt} \NC number \NC number of included glyphs\NC \NR
\NC \type{glyphmax} \NC number \NC maximum used index the glyphs array\NC \NR
\NC \type{glyphmin} \NC number \NC minimum used index the glyphs array\NC \NR
\NC \type{notdef_loc} \NC number \NC location of the \type {.notdef} glyph
or \type {-1} when not present \NC \NR
\NC \type{hasvmetrics} \NC number \NC \NC \NR
\NC \type{onlybitmaps} \NC number \NC \NC \NR
\NC \type{serifcheck} \NC number \NC \NC \NR
\NC \type{isserif} \NC number \NC \NC \NR
\NC \type{issans} \NC number \NC \NC \NR
\NC \type{encodingchanged} \NC number \NC \NC \NR
\NC \type{strokedfont} \NC number \NC \NC \NR
\NC \type{use_typo_metrics} \NC number \NC \NC \NR
\NC \type{weight_width_slope_only} \NC number \NC \NC \NR
\NC \type{head_optimized_for_cleartype} \NC number \NC \NC \NR
\NC \type{uni_interp} \NC enum \NC \type {unset}, \type {none}, \type {adobe},
\type {greek}, \type {japanese}, \type {trad_chinese},
\type {simp_chinese}, \type {korean}, \type {ams}\NC \NR
\NC \type{origname} \NC string \NC the file name, as supplied by the user\NC \NR
\NC \type{map} \NC table \NC \NC \NR
\NC \type{private} \NC table \NC \NC \NR
\NC \type{xuid} \NC string \NC \NC \NR
\NC \type{pfminfo} \NC table \NC \NC \NR
\NC \type{names} \NC table \NC \NC \NR
\NC \type{cidinfo} \NC table \NC \NC \NR
\NC \type{subfonts} \NC array \NC \NC \NR
\NC \type{commments} \NC string \NC \NC \NR
\NC \type{fontlog} \NC string \NC \NC \NR
\NC \type{cvt_names} \NC string \NC \NC \NR
\NC \type{anchor_classes} \NC table \NC \NC \NR
\NC \type{ttf_tables} \NC table \NC \NC \NR
\NC \type{ttf_tab_saved} \NC table \NC \NC \NR
\NC \type{kerns} \NC table \NC \NC \NR
\NC \type{vkerns} \NC table \NC \NC \NR
\NC \type{texdata} \NC table \NC \NC \NR
\NC \type{lookups} \NC table \NC \NC \NR
\NC \type{gpos} \NC table \NC \NC \NR
\NC \type{gsub} \NC table \NC \NC \NR
\NC \type{mm} \NC table \NC \NC \NR
\NC \type{chosenname} \NC string \NC \NC \NR
\NC \type{macstyle} \NC number \NC \NC \NR
\NC \type{fondname} \NC string \NC \NC \NR
%NC \type{design_size} \NC number \NC \NC \NR
\NC \type{fontstyle_id} \NC number \NC \NC \NR
\NC \type{fontstyle_name} \NC table \NC \NC \NR
%NC \type{design_range_bottom} \NC number \NC \NC \NR
%NC \type{design_range_top} \NC number \NC \NC \NR
\NC \type{strokewidth} \NC float \NC \NC \NR
\NC \type{mark_classes} \NC table \NC \NC \NR
\NC \type{creationtime} \NC number \NC \NC \NR
\NC \type{modificationtime} \NC number \NC \NC \NR
\NC \type{os2_version} \NC number \NC \NC \NR
\NC \type{sfd_version} \NC number \NC \NC \NR
\NC \type{math} \NC table \NC \NC \NR
\NC \type{validation_state} \NC table \NC \NC \NR
\NC \type{horiz_base} \NC table \NC \NC \NR
\NC \type{vert_base} \NC table \NC \NC \NR
\NC \type{extrema_bound} \NC number \NC \NC \NR
\NC \type{truetype} \NC boolean \NC signals a \TRUETYPE\ font \NC \NR
\stoptabulate
\subsection{Glyph items}
The \type {glyphs} is an array containing the per|-|character
information (quite a few of these are only present if nonzero).
\starttabulate[|l|l|p|]
\BC \type{key} \BC type \BC explanation \NC \NR
\NC \type{name} \NC string \NC the glyph name \NC \NR
\NC \type{unicode} \NC number \NC unicode code point, or -1 \NC \NR
\NC \type{boundingbox} \NC array \NC array of four numbers, see note below \NC \NR
\NC \type{width} \NC number \NC only for horizontal fonts \NC \NR
\NC \type{vwidth} \NC number \NC only for vertical fonts \NC \NR
\NC \type{tsidebearing} \NC number \NC only for vertical ttf/otf fonts, and only if nonzero \NC \NR
\NC \type{lsidebearing} \NC number \NC only if nonzero and not equal to boundingbox[1] \NC \NR
\NC \type{class} \NC string \NC one of "none", "base", "ligature", "mark", "component"
(if not present, the glyph class is \quote {automatic}) \NC \NR
\NC \type{kerns} \NC array \NC only for horizontal fonts, if set \NC \NR
\NC \type{vkerns} \NC array \NC only for vertical fonts, if set \NC \NR
\NC \type{dependents} \NC array \NC linear array of glyph name strings, only if nonempty\NC \NR
\NC \type{lookups} \NC table \NC only if nonempty \NC \NR
\NC \type{ligatures} \NC table \NC only if nonempty \NC \NR
\NC \type{anchors} \NC table \NC only if set \NC \NR
\NC \type{comment} \NC string \NC only if set \NC \NR
\NC \type{tex_height} \NC number \NC only if set \NC \NR
\NC \type{tex_depth} \NC number \NC only if set \NC \NR
\NC \type{italic_correction} \NC number \NC only if set \NC \NR
\NC \type{top_accent} \NC number \NC only if set \NC \NR
\NC \type{is_extended_shape} \NC number \NC only if this character is part of a math extension list \NC \NR
\NC \type{altuni} \NC table \NC alternate \UNICODE\ items \NC \NR
\NC \type{vert_variants} \NC table \NC \NC \NR
\NC \type{horiz_variants} \NC table \NC \NC \NR
\NC \type{mathkern} \NC table \NC \NC \NR
\stoptabulate
On \type {boundingbox}: The boundingbox information for \TRUETYPE\ fonts and
\TRUETYPE-based \OTF\ fonts is read directly from the font file.
\POSTSCRIPT-based fonts do not have this information, so the boundingbox of
traditional \POSTSCRIPT\ fonts is generated by interpreting the actual bezier
curves to find the exact boundingbox. This can be a slow process, so the
boundingboxes of \POSTSCRIPT-based \OTF\ fonts (and raw \CFF\ fonts) are
calculated using an approximation of the glyph shape based on the actual glyph
points only, instead of taking the whole curve into account. This means that
glyphs that have missing points at extrema will have a too|-|tight boundingbox,
but the processing is so much faster that in our opinion the tradeoff is worth
it.
The \type {kerns} and \type {vkerns} are linear arrays of small hashes:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{char} \NC string \NC \NC \NR
\NC \type{off} \NC number \NC \NC \NR
\NC \type{lookup} \NC string \NC \NC \NR
\stoptabulate
The \type {lookups} is a hash, based on lookup subtable names, with
the value of each key inside that a linear array of small hashes:
% TODO: fix this description
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{type} \NC enum \NC \type {position}, \type {pair}, \type
{substitution}, \type {alternate}, \type
{multiple}, \type {ligature}, \type {lcaret},
\type {kerning}, \type {vkerning}, \type
{anchors}, \type {contextpos}, \type
{contextsub}, \type {chainpos}, \type
{chainsub}, \type {reversesub}, \type {max},
\type {kernback}, \type {vkernback} \NC \NR
\NC \type{specification} \NC table \NC extra data \NC \NR
\stoptabulate
For the first seven values of \type {type}, there can be additional
sub|-|information, stored in the sub-table \type {specification}:
\starttabulate[|l|l|p|]
\BC value \BC type \BC explanation \NC \NR
\NC \type{position} \NC table \NC a table of the \type {offset_specs} type \NC \NR
\NC \type{pair} \NC table \NC one string: \type {paired}, and an array of one
or two \type {offset_specs} tables: \type
{offsets} \NC \NR
\NC \type{substitution} \NC table \NC one string: \type {variant} \NC \NR
\NC \type{alternate} \NC table \NC one string: \type {components} \NC \NR
\NC \type{multiple} \NC table \NC one string: \type {components} \NC \NR
\NC \type{ligature} \NC table \NC two strings: \type {components}, \type {char} \NC \NR
\NC \type{lcaret} \NC array \NC linear array of numbers \NC \NR
\stoptabulate
Tables for \type {offset_specs} contain up to four number|-|valued fields: \type
{x} (a horizontal offset), \type {y} (a vertical offset), \type {h} (an advance
width correction) and \type {v} (an advance height correction).
The \type {ligatures} is a linear array of small hashes:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{lig} \NC table \NC uses the same substructure as a single item in
the \type {lookups} table explained above \NC \NR
\NC \type{char} \NC string \NC \NC \NR
\NC \type{components} \NC array \NC linear array of named components \NC \NR
\NC \type{ccnt} \NC number \NC \NC \NR
\stoptabulate
The \type {anchor} table is indexed by a string signifying the anchor type, which
is one of
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{mark} \NC table \NC placement mark \NC \NR
\NC \type{basechar} \NC table \NC mark for attaching combining items to a base char \NC \NR
\NC \type{baselig} \NC table \NC mark for attaching combining items to a ligature \NC \NR
\NC \type{basemark} \NC table \NC generic mark for attaching combining items to connect to \NC \NR
\NC \type{centry} \NC table \NC cursive entry point \NC \NR
\NC \type{cexit} \NC table \NC cursive exit point \NC \NR
\stoptabulate
The content of these is a short array of defined anchors, with the
entry keys being the anchor names. For all except \type {baselig}, the
value is a single table with this definition:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{x} \NC number \NC x location \NC \NR
\NC \type{y} \NC number \NC y location \NC \NR
\NC \type{ttf_pt_index} \NC number \NC truetype point index, only if given \NC \NR
\stoptabulate
For \type {baselig}, the value is a small array of such anchor sets sets, one for
each constituent item of the ligature.
For clarification, an anchor table could for example look like this :
\starttyping
['anchor'] = {
['basemark'] = {
['Anchor-7'] = { ['x']=170, ['y']=1080 }
},
['mark'] ={
['Anchor-1'] = { ['x']=160, ['y']=810 },
['Anchor-4'] = { ['x']=160, ['y']=800 }
},
['baselig'] = {
[1] = { ['Anchor-2'] = { ['x']=160, ['y']=650 } },
[2] = { ['Anchor-2'] = { ['x']=460, ['y']=640 } }
}
}
\stoptyping
Note: The \type {baselig} table can be sparse!
\subsection{map table}
The top|-|level map is a list of encoding mappings. Each of those is a table
itself.
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{enccount} \NC number \NC \NC \NR
\NC \type{encmax} \NC number \NC \NC \NR
\NC \type{backmax} \NC number \NC \NC \NR
\NC \type{remap} \NC table \NC \NC \NR
\NC \type{map} \NC array \NC non|-|linear array of mappings\NC \NR
\NC \type{backmap} \NC array \NC non|-|linear array of backward mappings\NC \NR
\NC \type{enc} \NC table \NC \NC \NR
\stoptabulate
The \type {remap} table is very small:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{firstenc} \NC number \NC \NC \NR
\NC \type{lastenc} \NC number \NC \NC \NR
\NC \type{infont} \NC number \NC \NC \NR
\stoptabulate
The \type {enc} table is a bit more verbose:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{enc_name} \NC string \NC \NC \NR
\NC \type{char_cnt} \NC number \NC \NC \NR
\NC \type{char_max} \NC number \NC \NC \NR
\NC \type{unicode} \NC array \NC of \UNICODE\ position numbers\NC \NR
\NC \type{psnames} \NC array \NC of \POSTSCRIPT\ glyph names\NC \NR
\NC \type{builtin} \NC number \NC \NC \NR
\NC \type{hidden} \NC number \NC \NC \NR
\NC \type{only_1byte} \NC number \NC \NC \NR
\NC \type{has_1byte} \NC number \NC \NC \NR
\NC \type{has_2byte} \NC number \NC \NC \NR
\NC \type{is_unicodebmp} \NC number \NC only if nonzero\NC \NR
\NC \type{is_unicodefull} \NC number \NC only if nonzero\NC \NR
\NC \type{is_custom} \NC number \NC only if nonzero\NC \NR
\NC \type{is_original} \NC number \NC only if nonzero\NC \NR
\NC \type{is_compact} \NC number \NC only if nonzero\NC \NR
\NC \type{is_japanese} \NC number \NC only if nonzero\NC \NR
\NC \type{is_korean} \NC number \NC only if nonzero\NC \NR
\NC \type{is_tradchinese} \NC number \NC only if nonzero [name?]\NC \NR
\NC \type{is_simplechinese} \NC number \NC only if nonzero\NC \NR
\NC \type{low_page} \NC number \NC \NC \NR
\NC \type{high_page} \NC number \NC \NC \NR
\NC \type{iconv_name} \NC string \NC \NC \NR
\NC \type{iso_2022_escape} \NC string \NC \NC \NR
\stoptabulate
\subsection{private table}
This is the font's private \POSTSCRIPT\ dictionary, if any. Keys and values are
both strings.
\subsection{cidinfo table}
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{registry} \NC string \NC \NC \NR
\NC \type{ordering} \NC string \NC \NC \NR
\NC \type{supplement} \NC number \NC \NC \NR
\NC \type{version} \NC number \NC \NC \NR
\stoptabulate
\subsection[fontloaderpfminfotable]{pfminfo table}
The \type {pfminfo} table contains most of the OS/2 information:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{pfmset} \NC number \NC \NC \NR
\NC \type{winascent_add} \NC number \NC \NC \NR
\NC \type{windescent_add} \NC number \NC \NC \NR
\NC \type{hheadascent_add} \NC number \NC \NC \NR
\NC \type{hheaddescent_add} \NC number \NC \NC \NR
\NC \type{typoascent_add} \NC number \NC \NC \NR
\NC \type{typodescent_add} \NC number \NC \NC \NR
\NC \type{subsuper_set} \NC number \NC \NC \NR
\NC \type{panose_set} \NC number \NC \NC \NR
\NC \type{hheadset} \NC number \NC \NC \NR
\NC \type{vheadset} \NC number \NC \NC \NR
\NC \type{pfmfamily} \NC number \NC \NC \NR
\NC \type{weight} \NC number \NC \NC \NR
\NC \type{width} \NC number \NC \NC \NR
\NC \type{avgwidth} \NC number \NC \NC \NR
\NC \type{firstchar} \NC number \NC \NC \NR
\NC \type{lastchar} \NC number \NC \NC \NR
\NC \type{fstype} \NC number \NC \NC \NR
\NC \type{linegap} \NC number \NC \NC \NR
\NC \type{vlinegap} \NC number \NC \NC \NR
\NC \type{hhead_ascent} \NC number \NC \NC \NR
\NC \type{hhead_descent} \NC number \NC \NC \NR
\NC \type{os2_typoascent} \NC number \NC \NC \NR
\NC \type{os2_typodescent} \NC number \NC \NC \NR
\NC \type{os2_typolinegap} \NC number \NC \NC \NR
\NC \type{os2_winascent} \NC number \NC \NC \NR
\NC \type{os2_windescent} \NC number \NC \NC \NR
\NC \type{os2_subxsize} \NC number \NC \NC \NR
\NC \type{os2_subysize} \NC number \NC \NC \NR
\NC \type{os2_subxoff} \NC number \NC \NC \NR
\NC \type{os2_subyoff} \NC number \NC \NC \NR
\NC \type{os2_supxsize} \NC number \NC \NC \NR
\NC \type{os2_supysize} \NC number \NC \NC \NR
\NC \type{os2_supxoff} \NC number \NC \NC \NR
\NC \type{os2_supyoff} \NC number \NC \NC \NR
\NC \type{os2_strikeysize} \NC number \NC \NC \NR
\NC \type{os2_strikeypos} \NC number \NC \NC \NR
\NC \type{os2_family_class} \NC number \NC \NC \NR
\NC \type{os2_xheight} \NC number \NC \NC \NR
\NC \type{os2_capheight} \NC number \NC \NC \NR
\NC \type{os2_defaultchar} \NC number \NC \NC \NR
\NC \type{os2_breakchar} \NC number \NC \NC \NR
\NC \type{os2_vendor} \NC string \NC \NC \NR
\NC \type{codepages} \NC table \NC A two-number array of encoded code pages \NC \NR
\NC \type{unicoderages} \NC table \NC A four-number array of encoded unicode ranges \NC \NR
\NC \type{panose} \NC table \NC \NC \NR
\stoptabulate
The \type {panose} subtable has exactly 10 string keys:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{familytype} \NC string \NC Values as in the \OPENTYPE\ font
specification: \type {Any}, \type {No Fit},
\type {Text and Display}, \type {Script},
\type {Decorative}, \type {Pictorial} \NC
\NR
\NC \type{serifstyle} \NC string \NC See the \OPENTYPE\ font specification for
values \NC \NR
\NC \type{weight} \NC string \NC idem \NC \NR
\NC \type{proportion} \NC string \NC idem \NC \NR
\NC \type{contrast} \NC string \NC idem \NC \NR
\NC \type{strokevariation} \NC string \NC idem \NC \NR
\NC \type{armstyle} \NC string \NC idem \NC \NR
\NC \type{letterform} \NC string \NC idem \NC \NR
\NC \type{midline} \NC string \NC idem \NC \NR
\NC \type{xheight} \NC string \NC idem \NC \NR
\stoptabulate
\subsection[fontloadernamestable]{names table}
Each item has two top|-|level keys:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{lang} \NC string \NC language for this entry \NC \NR
\NC \type{names} \NC table \NC \NC \NR
\stoptabulate
The \type {names} keys are the actual \TRUETYPE\ name strings. The possible keys
are:
\starttabulate[|l|p|]
\BC key \BC explanation \NC \NR
\NC \type{copyright} \NC \NC \NR
\NC \type{family} \NC \NC \NR
\NC \type{subfamily} \NC \NC \NR
\NC \type{uniqueid} \NC \NC \NR
\NC \type{fullname} \NC \NC \NR
\NC \type{version} \NC \NC \NR
\NC \type{postscriptname} \NC \NC \NR
\NC \type{trademark} \NC \NC \NR
\NC \type{manufacturer} \NC \NC \NR
\NC \type{designer} \NC \NC \NR
\NC \type{descriptor} \NC \NC \NR
\NC \type{venderurl} \NC \NC \NR
\NC \type{designerurl} \NC \NC \NR
\NC \type{license} \NC \NC \NR
\NC \type{licenseurl} \NC \NC \NR
\NC \type{idontknow} \NC \NC \NR
\NC \type{preffamilyname} \NC \NC \NR
\NC \type{prefmodifiers} \NC \NC \NR
\NC \type{compatfull} \NC \NC \NR
\NC \type{sampletext} \NC \NC \NR
\NC \type{cidfindfontname} \NC \NC \NR
\NC \type{wwsfamily} \NC \NC \NR
\NC \type{wwssubfamily} \NC \NC \NR
\stoptabulate
\subsection{anchor_classes table}
The anchor_classes classes:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{name} \NC string \NC a descriptive id of this anchor class\NC \NR
\NC \type{lookup} \NC string \NC \NC \NR
\NC \type{type} \NC string \NC one of \type {mark}, \type {mkmk}, \type {curs}, \type {mklg} \NC \NR
\stoptabulate
% type is actually a lookup subtype, not a feature name. Officially, these
% strings should be gpos_mark2mark etc.
\subsection{gpos table}
The \type {gpos} table has one array entry for each lookup. (The \type {gpos_}
prefix is somewhat redundant.)
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{type} \NC string \NC one of \type {gpos_single}, \type {gpos_pair},
\type {gpos_cursive}, \type {gpos_mark2base},\crlf
\type {gpos_mark2ligature}, \type
{gpos_mark2mark}, \type {gpos_context},\crlf \type
{gpos_contextchain} \NC \NR
\NC \type{flags} \NC table \NC \NC \NR
\NC \type{name} \NC string \NC \NC \NR
\NC \type{features} \NC array \NC \NC \NR
\NC \type{subtables} \NC array \NC \NC \NR
\stoptabulate
The flags table has a true value for each of the lookup flags that is actually
set:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{r2l} \NC boolean \NC \NC \NR
\NC \type{ignorebaseglyphs} \NC boolean \NC \NC \NR
\NC \type{ignoreligatures} \NC boolean \NC \NC \NR
\NC \type{ignorecombiningmarks} \NC boolean \NC \NC \NR
\NC \type{mark_class} \NC string \NC \NC \NR
\stoptabulate
The features subtable items of gpos have:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{tag} \NC string \NC \NC \NR
\NC \type{scripts} \NC table \NC \NC \NR
\stoptabulate
The scripts table within features has:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{script} \NC string \NC \NC \NR
\NC \type{langs} \NC array of strings \NC \NC \NR
\stoptabulate
The subtables table has:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{name} \NC string \NC \NC \NR
\NC \type{suffix} \NC string \NC (only if used)\NC \NR % used by gpos_single to get a default
\NC \type{anchor_classes} \NC number \NC (only if used)\NC \NR
\NC \type{vertical_kerning} \NC number \NC (only if used)\NC \NR
\NC \type{kernclass} \NC table \NC (only if used)\NC \NR
\stoptabulate
The kernclass with subtables table has:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{firsts} \NC array of strings \NC \NC \NR
\NC \type{seconds} \NC array of strings \NC \NC \NR
\NC \type{lookup} \NC string or array \NC associated lookup(s) \NC \NR
\NC \type{offsets} \NC array of numbers \NC \NC \NR
\stoptabulate
Note: the kernclass (as far as we can see) always has one entry so it could be one level
deep instead. Also the seconds start at \type {[2]} which is close to the fontforge
internals so we keep that too.
\subsection{gsub table}
This has identical layout to the \type {gpos} table, except for the
type:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{type} \NC string \NC one of \type {gsub_single}, \type {gsub_multiple},
\type {gsub_alternate}, \type
{gsub_ligature},\crlf \type {gsub_context}, \type
{gsub_contextchain}, \type
{gsub_reversecontextchain} \NC \NR
\stoptabulate
\subsection{ttf_tables and ttf_tab_saved tables}
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{tag} \NC string \NC \NC \NR
\NC \type{len} \NC number \NC \NC \NR
\NC \type{maxlen} \NC number \NC \NC \NR
\NC \type{data} \NC number \NC \NC \NR
\stoptabulate
\subsection{mm table}
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{axes} \NC table \NC array of axis names \NC \NR
\NC \type{instance_count} \NC number \NC \NC \NR
\NC \type{positions} \NC table \NC array of instance positions
(\#axes * instances )\NC \NR
\NC \type{defweights} \NC table \NC array of default weights for instances \NC \NR
\NC \type{cdv} \NC string \NC \NC \NR
\NC \type{ndv} \NC string \NC \NC \NR
\NC \type{axismaps} \NC table \NC \NC \NR
\stoptabulate
The \type {axismaps}:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{blends} \NC table \NC an array of blend points \NC \NR
\NC \type{designs} \NC table \NC an array of design values \NC \NR
\NC \type{min} \NC number \NC \NC \NR
\NC \type{def} \NC number \NC \NC \NR
\NC \type{max} \NC number \NC \NC \NR
\stoptabulate
\subsection{mark_classes table}
The keys in this table are mark class names, and the values are a
space|-|separated string of glyph names in this class.
\subsection{math table}
\starttabulate[|l|p|]
\NC \type{ScriptPercentScaleDown} \NC \NC \NR
\NC \type{ScriptScriptPercentScaleDown} \NC \NC \NR
\NC \type{DelimitedSubFormulaMinHeight} \NC \NC \NR
\NC \type{DisplayOperatorMinHeight} \NC \NC \NR
\NC \type{MathLeading} \NC \NC \NR
\NC \type{AxisHeight} \NC \NC \NR
\NC \type{AccentBaseHeight} \NC \NC \NR
\NC \type{FlattenedAccentBaseHeight} \NC \NC \NR
\NC \type{SubscriptShiftDown} \NC \NC \NR
\NC \type{SubscriptTopMax} \NC \NC \NR
\NC \type{SubscriptBaselineDropMin} \NC \NC \NR
\NC \type{SuperscriptShiftUp} \NC \NC \NR
\NC \type{SuperscriptShiftUpCramped} \NC \NC \NR
\NC \type{SuperscriptBottomMin} \NC \NC \NR
\NC \type{SuperscriptBaselineDropMax} \NC \NC \NR
\NC \type{SubSuperscriptGapMin} \NC \NC \NR
\NC \type{SuperscriptBottomMaxWithSubscript} \NC \NC \NR
\NC \type{SpaceAfterScript} \NC \NC \NR
\NC \type{UpperLimitGapMin} \NC \NC \NR
\NC \type{UpperLimitBaselineRiseMin} \NC \NC \NR
\NC \type{LowerLimitGapMin} \NC \NC \NR
\NC \type{LowerLimitBaselineDropMin} \NC \NC \NR
\NC \type{StackTopShiftUp} \NC \NC \NR
\NC \type{StackTopDisplayStyleShiftUp} \NC \NC \NR
\NC \type{StackBottomShiftDown} \NC \NC \NR
\NC \type{StackBottomDisplayStyleShiftDown} \NC \NC \NR
\NC \type{StackGapMin} \NC \NC \NR
\NC \type{StackDisplayStyleGapMin} \NC \NC \NR
\NC \type{StretchStackTopShiftUp} \NC \NC \NR
\NC \type{StretchStackBottomShiftDown} \NC \NC \NR
\NC \type{StretchStackGapAboveMin} \NC \NC \NR
\NC \type{StretchStackGapBelowMin} \NC \NC \NR
\NC \type{FractionNumeratorShiftUp} \NC \NC \NR
\NC \type{FractionNumeratorDisplayStyleShiftUp} \NC \NC \NR
\NC \type{FractionDenominatorShiftDown} \NC \NC \NR
\NC \type{FractionDenominatorDisplayStyleShiftDown} \NC \NC \NR
\NC \type{FractionNumeratorGapMin} \NC \NC \NR
\NC \type{FractionNumeratorDisplayStyleGapMin} \NC \NC \NR
\NC \type{FractionRuleThickness} \NC \NC \NR
\NC \type{FractionDenominatorGapMin} \NC \NC \NR
\NC \type{FractionDenominatorDisplayStyleGapMin} \NC \NC \NR
\NC \type{SkewedFractionHorizontalGap} \NC \NC \NR
\NC \type{SkewedFractionVerticalGap} \NC \NC \NR
\NC \type{OverbarVerticalGap} \NC \NC \NR
\NC \type{OverbarRuleThickness} \NC \NC \NR
\NC \type{OverbarExtraAscender} \NC \NC \NR
\NC \type{UnderbarVerticalGap} \NC \NC \NR
\NC \type{UnderbarRuleThickness} \NC \NC \NR
\NC \type{UnderbarExtraDescender} \NC \NC \NR
\NC \type{RadicalVerticalGap} \NC \NC \NR
\NC \type{RadicalDisplayStyleVerticalGap} \NC \NC \NR
\NC \type{RadicalRuleThickness} \NC \NC \NR
\NC \type{RadicalExtraAscender} \NC \NC \NR
\NC \type{RadicalKernBeforeDegree} \NC \NC \NR
\NC \type{RadicalKernAfterDegree} \NC \NC \NR
\NC \type{RadicalDegreeBottomRaisePercent} \NC \NC \NR
\NC \type{MinConnectorOverlap} \NC \NC \NR
\NC \type{FractionDelimiterSize} \NC \NC \NR
\NC \type{FractionDelimiterDisplayStyleSize} \NC \NC \NR
\stoptabulate
\subsection{validation_state table}
\starttabulate[|l|p|]
\BC key \BC explanation \NC \NR
\NC \type{bad_ps_fontname} \NC \NC \NR
\NC \type{bad_glyph_table} \NC \NC \NR
\NC \type{bad_cff_table} \NC \NC \NR
\NC \type{bad_metrics_table} \NC \NC \NR
\NC \type{bad_cmap_table} \NC \NC \NR
\NC \type{bad_bitmaps_table} \NC \NC \NR
\NC \type{bad_gx_table} \NC \NC \NR
\NC \type{bad_ot_table} \NC \NC \NR
\NC \type{bad_os2_version} \NC \NC \NR
\NC \type{bad_sfnt_header} \NC \NC \NR
\stoptabulate
\subsection{horiz_base and vert_base table}
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{tags} \NC table \NC an array of script list tags\NC \NR
\NC \type{scripts} \NC table \NC \NC \NR
\stoptabulate
The \type {scripts} subtable:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{baseline} \NC table \NC \NC \NR
\NC \type{default_baseline} \NC number \NC \NC \NR
\NC \type{lang} \NC table \NC \NC \NR
\stoptabulate
The \type {lang} subtable:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{tag} \NC string \NC a script tag \NC \NR
\NC \type{ascent} \NC number \NC \NC \NR
\NC \type{descent} \NC number \NC \NC \NR
\NC \type{features} \NC table \NC \NC \NR
\stoptabulate
The \type {features} points to an array of tables with the same layout except
that in those nested tables, the tag represents a language.
\subsection{altuni table}
An array of alternate \UNICODE\ values. Inside that array are hashes with:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{unicode} \NC number \NC this glyph is also used for this unicode \NC \NR
\NC \type{variant} \NC number \NC the alternative is driven by this unicode selector \NC \NR
\stoptabulate
\subsection{vert_variants and horiz_variants table}
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{variants} \NC string \NC \NC \NR
\NC \type{italic_correction} \NC number \NC \NC \NR
\NC \type{parts} \NC table \NC \NC \NR
\stoptabulate
The \type {parts} table is an array of smaller tables:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{component} \NC string \NC \NC \NR
\NC \type{extender} \NC number \NC \NC \NR
\NC \type{start} \NC number \NC \NC \NR
\NC \type{end} \NC number \NC \NC \NR
\NC \type{advance} \NC number \NC \NC \NR
\stoptabulate
\subsection{mathkern table}
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{top_right} \NC table \NC \NC \NR
\NC \type{bottom_right} \NC table \NC \NC \NR
\NC \type{top_left} \NC table \NC \NC \NR
\NC \type{bottom_left} \NC table \NC \NC \NR
\stoptabulate
Each of the subtables is an array of small hashes with two keys:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{height} \NC number \NC \NC \NR
\NC \type{kern} \NC number \NC \NC \NR
\stoptabulate
\subsection{kerns table}
Substructure is identical to the per|-|glyph subtable.
\subsection{vkerns table}
Substructure is identical to the per|-|glyph subtable.
\subsection{texdata table}
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{type} \NC string \NC \type {unset}, \type {text}, \type {math}, \type {mathext} \NC \NR
\NC \type{params} \NC array \NC 22 font numeric parameters \NC \NR
\stoptabulate
\subsection{lookups table}
Top|-|level \type {lookups} is quite different from the ones at character level.
The keys in this hash are strings, the values the actual lookups, represented as
dictionary tables.
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{type} \NC string \NC \NC \NR
\NC \type{format} \NC enum \NC one of \type {glyphs}, \type {class}, \type {coverage}, \type {reversecoverage} \NC \NR
\NC \type{tag} \NC string \NC \NC \NR
\NC \type{current_class} \NC array \NC \NC \NR
\NC \type{before_class} \NC array \NC \NC \NR
\NC \type{after_class} \NC array \NC \NC \NR
\NC \type{rules} \NC array \NC an array of rule items\NC \NR
\stoptabulate
Rule items have one common item and one specialized item:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{lookups} \NC array \NC a linear array of lookup names\NC \NR
\NC \type{glyphs} \NC array \NC only if the parent's format is \type {glyphs}\NC \NR
\NC \type{class} \NC array \NC only if the parent's format is \type {class}\NC \NR
\NC \type{coverage} \NC array \NC only if the parent's format is \type {coverage}\NC \NR
\NC \type{reversecoverage} \NC array \NC only if the parent's format is \type {reversecoverage}\NC \NR
\stoptabulate
A glyph table is:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{names} \NC string \NC \NC \NR
\NC \type{back} \NC string \NC \NC \NR
\NC \type{fore} \NC string \NC \NC \NR
\stoptabulate
A class table is:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{current} \NC array \NC of numbers \NC \NR
\NC \type{before} \NC array \NC of numbers \NC \NR
\NC \type{after} \NC array \NC of numbers \NC \NR
\stoptabulate
coverage:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{current} \NC array \NC of strings \NC \NR
\NC \type{before} \NC array \NC of strings\NC \NR
\NC \type{after} \NC array \NC of strings \NC \NR
\stoptabulate
reversecoverage:
\starttabulate[|l|l|p|]
\BC key \BC type \BC explanation \NC \NR
\NC \type{current} \NC array \NC of strings \NC \NR
\NC \type{before} \NC array \NC of strings\NC \NR
\NC \type{after} \NC array \NC of strings \NC \NR
\NC \type{replacements} \NC string \NC \NC \NR
\stoptabulate
\stopchapter
\stopcomponent