Skip to content

Commit

Permalink
[otlLib] Document buildMathTable
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledhosny committed Feb 14, 2024
1 parent 0f953cc commit bb55793
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions Lib/fontTools/otlLib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2922,6 +2922,99 @@ def buildMathTable(
vertGlyphAssembly=None,
horizGlyphAssembly=None,
):
"""
Add a 'MATH' table to 'ttFont'.
'constants' is a dictionary of math constants. The keys are the constant
names from the MATH table specification (with capital first letter), and the
values are the constant values as numbers.
'italicsCorrections' is a dictionary of italic corrections. The keys are the
glyph names, and the values are the italic corrections as numbers.
'topAccentAttachments' is a dictionary of top accent attachments. The keys
are the glyph names, and the values are the top accent horizontal positions
as numbers.
'extendedShapes' is a set of extended shape glyphs.
'mathKerns' is a dictionary of math kerns. The keys are the glyph names, and
the values are dictionaries. The keys of these dictionaries are the side
names ('TopRight', 'TopLeft', 'BottomRight', 'BottomLeft'), and the values
are tuples of two lists. The first list contains the correction heights as
numbers, and the second list contains the kern values as numbers.
'minConnectorOverlap' is the minimum connector overlap as a number.
'vertGlyphVariants' is a dictionary of vertical glyph variants. The keys are
the glyph names, and the values are tuples of glyph name and full advance height.
'horizGlyphVariants' is a dictionary of horizontal glyph variants. The keys
are the glyph names, and the values are tuples of glyph name and full
advance width.
'vertGlyphAssembly' is a dictionary of vertical glyph assemblies. The keys
are the glyph names, and the values are tuples of assembly parts and italics
correction. The assembly parts are tuples of glyph name, flags, start
connector length, end connector length, and full advance height.
'horizGlyphAssembly' is a dictionary of horizontal glyph assemblies. The
keys are the glyph names, and the values are tuples tuples of assembly parts
and italics correction. The assembly parts are tuples of glyph name, flags,
start connector length, end connector length, and full advance width.
Where a number is expected, an integer or a float can be used. The floats
will be rounded.
Example::
constants = {
"ScriptPercentScaleDown": 70,
"ScriptScriptPercentScaleDown": 50,
"DelimitedSubFormulaMinHeight": 24,
"DisplayOperatorMinHeight": 60,
...
}
italicsCorrections = {
"fitalic-math": 100,
"fbolditalic-math": 120,
...
}
topAccentAttachments = {
"circumflexcomb": 500,
"acutecomb": 400,
"A": 300,
"B": 340,
...
}
extendedShapes = {"parenleft", "parenright", ...}
mathKerns = {
"A": {
"TopRight": ([-50, -100], [10, 20, 30]),
"TopLeft": ([50, 100], [10, 20, 30]),
...
},
...
}
vertGlyphVariants = {
"parenleft": [("parenleft", 700), ("parenleft.size1", 1000), ...],
"parenright": [("parenright", 700), ("parenright.size1", 1000), ...],
...
}
vertGlyphAssembly = {
"braceleft": [
(
("braceleft.bottom", 0, 0, 200, 500),
("braceleft.extender", 1, 200, 200, 200)),
("braceleft.middle", 0, 100, 100, 700),
("braceleft.extender", 1, 200, 200, 200),
("braceleft.top", 0, 200, 0, 500),
),
100,
],
...
}
"""
glyphMap = ttFont.getReverseGlyphMap()

ttFont["MATH"] = math = ttLib.newTable("MATH")
Expand Down

0 comments on commit bb55793

Please sign in to comment.