Docs: add boilerplate docstrings to table converters. Mostly links to reference specs.

This commit is contained in:
Nathan Williis 2024-12-04 15:58:46 +00:00
parent 993b007fc1
commit e5eb053105
83 changed files with 632 additions and 20 deletions

View File

@ -2,4 +2,13 @@ from .otBase import BaseTTXConverter
class table_B_A_S_E_(BaseTTXConverter):
"""Baseline table
The ``BASE`` table contains information needed to align glyphs in
different scripts, from different fonts, or at different sizes
within the same line of text.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/base
"""
pass

View File

@ -21,6 +21,16 @@ import struct
class table_C_B_D_T_(E_B_D_T_.table_E_B_D_T_):
"""Color Bitmap Data table
The ``CBDT`` table contains color bitmap data for glyphs. It must
be used in concert with the ``CBLC`` table.
It is backwards-compatible with the monochrome/grayscale ``EBDT`` table.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/cbdt
"""
# Change the data locator table being referenced.
locatorName = "CBLC"

View File

@ -6,4 +6,14 @@ from . import E_B_L_C_
class table_C_B_L_C_(E_B_L_C_.table_E_B_L_C_):
"""Color Bitmap Location table
The ``CBLC`` table contains the locations of color bitmaps for glyphs. It must
be used in concert with the ``CBDT`` table.
It is backwards-compatible with the monochrome/grayscale ``EBLC`` table.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/cblc
"""
dependencies = ["CBDT"]

View File

@ -4,6 +4,21 @@ from . import DefaultTable
class table_C_F_F_(DefaultTable.DefaultTable):
"""Compact Font Format table (version 1)
The ``CFF`` table embeds a CFF-formatted font. The CFF font format
predates OpenType and could be used as a standalone font file, but the
``CFF`` table is also used to package CFF fonts into an OpenType
container.
.. note::
``CFF`` has been succeeded by ``CFF2``, which eliminates much of
the redundancy incurred by embedding CFF version 1 in an OpenType
font.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/cff
"""
def __init__(self, tag=None):
DefaultTable.DefaultTable.__init__(self, tag)
self.cff = cffLib.CFFFontSet()

View File

@ -3,6 +3,19 @@ from fontTools.ttLib.tables.C_F_F_ import table_C_F_F_
class table_C_F_F__2(table_C_F_F_):
"""Compact Font Format version 2 table
The ``CFF2`` table contains glyph data for a CFF2-flavored OpenType
font.
.. note::
``CFF2`` is the successor to ``CFF``, and eliminates much of
the redundancy incurred by embedding CFF version 1 in an OpenType
font.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/cff2
"""
def decompile(self, data, otFont):
self.cff.decompile(BytesIO(data), otFont, isCFF2=True)
assert len(self.cff) == 1, "can't deal with multi-font CFF tables."

View File

@ -7,11 +7,19 @@ from . import DefaultTable
class table_C_O_L_R_(DefaultTable.DefaultTable):
"""This table is structured so that you can treat it like a dictionary keyed by glyph name.
"""Color table
The ``COLR`` table defines color presentation of outline glyphs. It must
be used in concert with the ``CPAL`` table, which contains the color
descriptors used.
This table is structured so that you can treat it like a dictionary keyed by glyph name.
``ttFont['COLR'][<glyphName>]`` will return the color layers for any glyph.
``ttFont['COLR'][<glyphName>] = <value>`` will set the color layers for any glyph.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/colr
"""
@staticmethod

View File

@ -11,6 +11,15 @@ import sys
class table_C_P_A_L_(DefaultTable.DefaultTable):
"""Color Palette table
The ``CPAL`` table contains a set of one or more color palettes. The color
records in each palette can be referenced by the ``COLR`` table to specify
the colors used in a color glyph.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/cpal
"""
NO_NAME_ID = 0xFFFF
DEFAULT_PALETTE_TYPE = 0

View File

@ -39,6 +39,13 @@ DSIG_SignatureBlockFormat = """
class table_D_S_I_G_(DefaultTable.DefaultTable):
"""Digital Signature table
The ``DSIG`` table contains cryptographic signatures for the font.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/dsig
"""
def decompile(self, data, ttFont):
dummy, newData = sstruct.unpack2(DSIG_HeaderFormat, data, self)
assert self.ulVersion == 1, "DSIG ulVersion must be 1"

View File

@ -38,6 +38,14 @@ ebdtComponentFormat = """
class table_E_B_D_T_(DefaultTable.DefaultTable):
"""Embedded Bitmap Data table
The ``EBDT`` table contains monochrome or grayscale bitmap data for
glyphs. It must be used in concert with the ``EBLC`` table.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/ebdt
"""
# Keep a reference to the name of the data locator table.
locatorName = "EBLC"

View File

@ -66,6 +66,14 @@ codeOffsetPairSize = struct.calcsize(codeOffsetPairFormat)
class table_E_B_L_C_(DefaultTable.DefaultTable):
"""Embedded Bitmap Location table
The ``EBLC`` table contains the locations of monochrome or grayscale
bitmaps for glyphs. It must be used in concert with the ``EBDT`` table.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/eblc
"""
dependencies = ["EBDT"]
# This method can be overridden in subclasses to support new formats

View File

@ -13,6 +13,16 @@ FFTMFormat = """
class table_F_F_T_M_(DefaultTable.DefaultTable):
"""FontForge Time Stamp table
The ``FFTM`` table is used by the free-software font editor
FontForge to record timestamps for the creation and modification
of font source (.sfd) files and a timestamp for FontForge's
own source code.
See also https://fontforge.org/docs/techref/non-standard.html
"""
def decompile(self, data, ttFont):
dummy, rest = sstruct.unpack2(FFTMFormat, data, self)

View File

@ -12,12 +12,17 @@ Feat_hdr_format = """
class table_F__e_a_t(DefaultTable.DefaultTable):
"""The ``Feat`` table is used exclusively by the Graphite shaping engine
"""Feature table
The ``Feat`` table is used exclusively by the Graphite shaping engine
to store features and possible settings specified in GDL. Graphite features
determine what rules are applied to transform a glyph stream.
Not to be confused with ``feat``, or the OpenType Layout tables
``GSUB``/``GPOS``."""
``GSUB``/``GPOS``.
See also https://graphite.sil.org/graphite_techAbout#graphite-font-tables
"""
def __init__(self, tag=None):
DefaultTable.DefaultTable.__init__(self, tag)

View File

@ -2,4 +2,12 @@ from .otBase import BaseTTXConverter
class table_G_D_E_F_(BaseTTXConverter):
"""Glyph Definition table
The ``GDEF`` table stores various glyph properties that are used
by OpenType Layout.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/gdef
"""
pass

View File

@ -81,6 +81,13 @@ class GMAPRecord(object):
class table_G_M_A_P_(DefaultTable.DefaultTable):
"""Glyphlets GMAP table
The ``GMAP`` table is used by Adobe's SING Glyphlets.
See also https://web.archive.org/web/20080627183635/http://www.adobe.com/devnet/opentype/gdk/topic.html
"""
dependencies = []
def decompile(self, data, ttFont):

View File

@ -16,6 +16,13 @@ GPKGFormat = """
class table_G_P_K_G_(DefaultTable.DefaultTable):
"""Glyphlets GPKG table
The ``GPKG`` table is used by Adobe's SING Glyphlets.
See also https://web.archive.org/web/20080627183635/http://www.adobe.com/devnet/opentype/gdk/topic.html
"""
def decompile(self, data, ttFont):
dummy, newData = sstruct.unpack2(GPKGFormat, data, self)

View File

@ -2,4 +2,13 @@ from .otBase import BaseTTXConverter
class table_G_P_O_S_(BaseTTXConverter):
"""Glyph Positioning table
The ``GPOS`` table stores advanced glyph-positioning data
used in OpenType Layout features, such as mark attachment,
cursive attachment, kerning, and other position adjustments.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/gpos
"""
pass

View File

@ -2,4 +2,12 @@ from .otBase import BaseTTXConverter
class table_G_S_U_B_(BaseTTXConverter):
"""Glyph Substitution table
The ``GSUB`` table contains glyph-substitution rules used in
OpenType Layout.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/gsub
"""
pass

View File

@ -62,8 +62,9 @@ class _Dict(dict):
class table_G__l_a_t(DefaultTable.DefaultTable):
"""
Support Graphite Glat tables
"""Graphite Glyph Attributes table
See also https://graphite.sil.org/graphite_techAbout#graphite-font-tables
"""
def __init__(self, tag=None):

View File

@ -15,8 +15,9 @@ Gloc_header = """
class table_G__l_o_c(DefaultTable.DefaultTable):
"""
Support Graphite Gloc tables
"""Graphite Index to Glyph Atttributes table
See also https://graphite.sil.org/graphite_techAbout#graphite-font-tables
"""
dependencies = ["Glat"]

View File

@ -2,4 +2,12 @@ from .otBase import BaseTTXConverter
class table_H_V_A_R_(BaseTTXConverter):
"""Horizontal Metrics Variations table
The ``HVAR`` table contains variations in horizontal glyph metrics
in variable fonts.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/hvar
"""
pass

View File

@ -2,4 +2,12 @@ from .otBase import BaseTTXConverter
class table_J_S_T_F_(BaseTTXConverter):
"""Justification table
The ``JSTF`` table contains glyph substitution and positioning
data used to perform text justification.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/jstf
"""
pass

View File

@ -9,6 +9,16 @@ import array
class table_L_T_S_H_(DefaultTable.DefaultTable):
"""Linear Threshold table
The ``LTSH`` table contains per-glyph settings indicating the ppem sizes
at which the advance width metric should be scaled linearly, despite the
effects of any TrueType instructions that might otherwise alter the
advance width.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/ltsh
"""
def decompile(self, data, ttFont):
version, numGlyphs = struct.unpack(">HH", data[:4])
data = data[4:]

View File

@ -2,4 +2,12 @@ from .otBase import BaseTTXConverter
class table_M_A_T_H_(BaseTTXConverter):
"""Mathematical Typesetting table
The ``MATH`` table contains a variety of information needed to
typeset glyphs in mathematical formulas and expressions.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/math
"""
pass

View File

@ -68,6 +68,13 @@ def getLabelString(labelID):
class table_M_E_T_A_(DefaultTable.DefaultTable):
"""Glyphlets META table
The ``META`` table is used by Adobe's SING Glyphlets.
See also https://web.archive.org/web/20080627183635/http://www.adobe.com/devnet/opentype/gdk/topic.html
"""
dependencies = []
def decompile(self, data, ttFont):

View File

@ -2,4 +2,12 @@ from .otBase import BaseTTXConverter
class table_M_V_A_R_(BaseTTXConverter):
"""Metrics Variations table
The ``MVAR`` table contains variation information for font-wide
metrics in a variable font.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/mvar
"""
pass

View File

@ -113,7 +113,14 @@ OS2_format_5_addition = bigendian + OS2_format_5_addition
class table_O_S_2f_2(DefaultTable.DefaultTable):
"""the OS/2 table"""
"""OS/2 and Windows Metrics table
The ``OS/2`` table contains a variety of font-wide metrics and
parameters that may be useful to an operating system or other
software for system-integration purposes.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/os2
"""
dependencies = ["head"]

View File

@ -20,6 +20,13 @@ SINGFormat = """
class table_S_I_N_G_(DefaultTable.DefaultTable):
"""Glyphlets SING table
The ``SING`` table is used by Adobe's SING Glyphlets.
See also https://web.archive.org/web/20080627183635/http://www.adobe.com/devnet/opentype/gdk/topic.html
"""
dependencies = []
def decompile(self, data, ttFont):

View File

@ -2,4 +2,14 @@ from .otBase import BaseTTXConverter
class table_S_T_A_T_(BaseTTXConverter):
"""Style Attributes table
The ``STAT`` table records stylistic or typeface-design attributes that
differentiate the individual fonts within a font family from one another.
Those attributes can be used to assist users when navigating the style
variations of a variable font or a family of static fonts.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/stat
"""
pass

View File

@ -51,6 +51,14 @@ doc_index_entry_format_0Size = sstruct.calcsize(doc_index_entry_format_0)
class table_S_V_G_(DefaultTable.DefaultTable):
"""Scalable Vector Graphics table
The ``SVG`` table contains representations for glyphs in the SVG
image format.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/stat
"""
def decompile(self, data, ttFont):
self.docList = []
# Version 0 is the standardized version of the table; and current.

View File

@ -343,7 +343,10 @@ class _Object:
class table_S__i_l_f(DefaultTable.DefaultTable):
"""Silf table support"""
"""Graphite Rules table
See also https://graphite.sil.org/graphite_techAbout#graphite-font-tables
"""
def __init__(self, tag=None):
DefaultTable.DefaultTable.__init__(self, tag)

View File

@ -12,6 +12,11 @@ Sill_hdr = """
class table_S__i_l_l(DefaultTable.DefaultTable):
"""Graphite Languages table
See also https://graphite.sil.org/graphite_techAbout#graphite-font-tables
"""
def __init__(self, tag=None):
DefaultTable.DefaultTable.__init__(self, tag)
self.langs = {}

View File

@ -1,3 +1,11 @@
""" TSI{B,C,D,J,P,S,V} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its table source data.
TSIB contains the source text for the ``BASE`` table.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from .T_S_I_V_ import table_T_S_I_V_

View File

@ -1,3 +1,12 @@
""" TSI{B,C,D,J,P,S,V} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its table source data.
TSIC contains the source text for the Variation CVT window and data for
the ``cvar`` table.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from .otBase import BaseTTXConverter

View File

@ -1,3 +1,11 @@
""" TSI{B,C,D,J,P,S,V} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its table source data.
TSID contains the source text for the ``GDEF`` table.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from .T_S_I_V_ import table_T_S_I_V_

View File

@ -1,3 +1,11 @@
""" TSI{B,C,D,J,P,S,V} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its table source data.
TSIJ contains the source text for the ``JSTF`` table.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from .T_S_I_V_ import table_T_S_I_V_

View File

@ -1,3 +1,11 @@
""" TSI{B,C,D,J,P,S,V} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its table source data.
TSIP contains the source text for the ``GPOS`` table.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from .T_S_I_V_ import table_T_S_I_V_

View File

@ -1,3 +1,11 @@
""" TSI{B,C,D,J,P,S,V} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its table source data.
TSIS contains the source text for the ``GSUB`` table.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from .T_S_I_V_ import table_T_S_I_V_

View File

@ -1,3 +1,9 @@
""" TSI{B,C,D,J,P,S,V} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its table source data.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from fontTools.misc.textTools import strjoin, tobytes, tostr
from . import asciiTable

View File

@ -4,6 +4,8 @@ tool to store its hinting source data.
TSI0 is the index table containing the lengths and offsets for the glyph
programs and 'extra' programs ('fpgm', 'prep', and 'cvt') that are contained
in the TSI1 table.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from . import DefaultTable

View File

@ -3,6 +3,8 @@ tool to store its hinting source data.
TSI1 contains the text of the glyph programs in the form of low-level assembly
code, as well as the 'extra' programs 'fpgm', 'ppgm' (i.e. 'prep'), and 'cvt'.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from . import DefaultTable

View File

@ -4,6 +4,8 @@ tool to store its hinting source data.
TSI2 is the index table containing the lengths and offsets for the glyph
programs that are contained in the TSI3 table. It uses the same format as
the TSI0 table.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from fontTools import ttLib

View File

@ -2,6 +2,8 @@
tool to store its hinting source data.
TSI3 contains the text of the glyph programs in the form of 'VTTTalk' code.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from fontTools import ttLib

View File

@ -2,6 +2,8 @@
tool to store its hinting source data.
TSI5 contains the VTT character groups.
See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
"""
from fontTools.misc.textTools import safeEval

View File

@ -2,4 +2,13 @@ from . import asciiTable
class table_T_T_F_A_(asciiTable.asciiTable):
"""ttfautohint parameters table
The ``TTFA`` table is used by the free-software `ttfautohint` program
to record the parameters that `ttfautohint` was called with when it
was used to auto-hint the font.
See also http://freetype.org/ttfautohint/doc/ttfautohint.html#miscellaneous-1
"""
pass

View File

@ -2,4 +2,11 @@ from .otBase import BaseTTXConverter
class table_V_A_R_C_(BaseTTXConverter):
"""Variable Components table
The ``VARC`` table contains variation information for composite glyphs.
See also https://github.com/harfbuzz/boring-expansion-spec/blob/main/VARC.md
"""
pass

View File

@ -37,6 +37,14 @@ VDMX_vTableFmt = """
class table_V_D_M_X_(DefaultTable.DefaultTable):
"""Vertical Device Metrics table
The ``VDMX`` table records changes to the vertical glyph minima
and maxima that result from Truetype instructions.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/vdmx
"""
def decompile(self, data, ttFont):
pos = 0 # track current position from to start of VDMX table
dummy, data = sstruct.unpack2(VDMX_HeaderFmt, data, self)

View File

@ -4,11 +4,18 @@ import struct
class table_V_O_R_G_(DefaultTable.DefaultTable):
"""This table is structured so that you can treat it like a dictionary keyed by glyph name.
"""Vertical Origin table
The ``VORG`` table contains the vertical origin of each glyph
in a `CFF` or `CFF2` font.
This table is structured so that you can treat it like a dictionary keyed by glyph name.
``ttFont['VORG'][<glyphName>]`` will return the vertical origin for any glyph.
``ttFont['VORG'][<glyphName>] = <value>`` will set the vertical origin for any glyph.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/vorg
"""
def decompile(self, data, ttFont):

View File

@ -2,4 +2,12 @@ from .otBase import BaseTTXConverter
class table_V_V_A_R_(BaseTTXConverter):
"""Vertical Metrics Variations table
The ``VVAR`` table contains variation data for per-glyph vertical metrics
in a variable font.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/vvar
"""
pass

View File

@ -2,11 +2,12 @@ from .otBase import BaseTTXConverter
class table__a_n_k_r(BaseTTXConverter):
"""
"""Anchor Point table
The anchor point table provides a way to define anchor points.
These are points within the coordinate space of a given glyph,
independent of the control points used to render the glyph.
Anchor points are used in conjunction with the 'kerx' table.
Anchor points are used in conjunction with the ``kerx`` table.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ankr.html
"""

View File

@ -22,7 +22,7 @@ from .otBase import BaseTTXConverter
class table__a_v_a_r(BaseTTXConverter):
"""Axis Variations Table
"""Axis Variations table
This class represents the ``avar`` table of a variable font. The object has one
substantive attribute, ``segments``, which maps axis tags to a segments dictionary::
@ -43,6 +43,8 @@ class table__a_v_a_r(BaseTTXConverter):
``avar`` segment mapping must contain the entries ``-1.0: -1.0, 0.0: 0.0, 1.0: 1.0``.
fontTools does not enforce this, so it is your responsibility to ensure that
mappings are valid.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/avar
"""
dependencies = ["fvar"]

View File

@ -3,4 +3,13 @@ from .otBase import BaseTTXConverter
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bsln.html
class table__b_s_l_n(BaseTTXConverter):
"""Baseline table
The AAT ``bsln`` table is similar in purpose to the OpenType ``BASE``
table; it stores per-script baselines to support automatic alignment
of lines of text.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bsln.html
"""
pass

View File

@ -3,7 +3,9 @@ from .otBase import BaseTTXConverter
class table__c_i_d_g(BaseTTXConverter):
"""The AAT ``cidg`` table has almost the same structure as ``gidc``,
"""CID to Glyph ID table
The AAT ``cidg`` table has almost the same structure as ``gidc``,
just mapping CIDs to GlyphIDs instead of the reverse direction.
It is useful for fonts that may be used by a PDF renderer in lieu of
@ -14,6 +16,9 @@ class table__c_i_d_g(BaseTTXConverter):
obsoleted by ``cidg``.
For example, the first font in ``/System/Library/Fonts/PingFang.ttc``
(which Apple ships pre-installed on MacOS 10.12.6) has a ``cidg`` table."""
(which Apple ships pre-installed on MacOS 10.12.6) has a ``cidg`` table.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6gcid.html
"""
pass

View File

@ -54,6 +54,8 @@ class table__c_m_a_p(DefaultTable.DefaultTable):
cmap = newTable("cmap")
cmap.tableVersion = 0
cmap.tables = [cmap4_0_3]
See also https://learn.microsoft.com/en-us/typography/opentype/spec/cmap
"""
def getcmap(self, platformID, platEncID):

View File

@ -24,6 +24,14 @@ CVAR_HEADER_SIZE = sstruct.calcsize(CVAR_HEADER_FORMAT)
class table__c_v_a_r(DefaultTable.DefaultTable):
"""Control Value Table (CVT) variations table
The ``cvar`` table contains variations for the values in a ``cvt``
table.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/cvar
"""
dependencies = ["cvt ", "fvar"]
def __init__(self, tag=None):

View File

@ -5,6 +5,14 @@ import array
class table__c_v_t(DefaultTable.DefaultTable):
"""Control Value Table
The Control Value Table holds a list of values that can be referenced
by TrueType font instructions.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/cvt
"""
def decompile(self, data, ttFont):
values = array.array("h")
values.frombytes(data)

View File

@ -2,11 +2,14 @@ from .otBase import BaseTTXConverter
class table__f_e_a_t(BaseTTXConverter):
"""The feature name table is an AAT (Apple Advanced Typography) table for
"""Feature name table
The feature name table is an AAT (Apple Advanced Typography) table for
storing font features, settings, and their human-readable names. It should
not be confused with the ``Feat`` table or the OpenType Layout ``GSUB``/``GPOS``
tables. See `Feature Name Table <https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html>`_
in the TrueType Reference Manual for more information on the structure and
purpose of this table."""
tables.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html
"""
pass

View File

@ -3,6 +3,17 @@ from . import ttProgram
class table__f_p_g_m(DefaultTable.DefaultTable):
"""Font Program table
The ``fpgm`` table typically contains function defintions that are
used by font instructions. This Font Program is similar to the Control
Value Program that is stored in the ``prep`` table, but
the ``fpgm`` table is only executed one time, when the font is first
used.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/fpgm
"""
def decompile(self, data, ttFont):
program = ttProgram.Program()
program.fromBytecode(data)

View File

@ -43,6 +43,14 @@ FVAR_INSTANCE_FORMAT = """
class table__f_v_a_r(DefaultTable.DefaultTable):
"""FonT Variations table
The ``fvar`` table contains records of the variation axes and of the
named instances in a variable font.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6fvar.html
"""
dependencies = ["name"]
def __init__(self, tag=None):

View File

@ -10,6 +10,14 @@ GASP_GRIDFIT = 0x0001
class table__g_a_s_p(DefaultTable.DefaultTable):
"""Grid-fitting and Scan-conversion Procedure table
The ``gasp`` table defines the preferred rasterization settings for
the font when rendered on monochrome and greyscale output devices.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/gasp
"""
def decompile(self, data, ttFont):
self.version, numRanges = struct.unpack(">HH", data[:4])
assert 0 <= self.version <= 1, "unknown 'gasp' format: %s" % self.version

View File

@ -3,4 +3,11 @@ from .otBase import BaseTTXConverter
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6gcid.html
class table__g_c_i_d(BaseTTXConverter):
"""Glyph ID to CID table
The AAT ``gcid` table stores glyphID-to-CID mappings.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6gcid.html
"""
pass

View File

@ -54,7 +54,7 @@ SCALE_COMPONENT_OFFSET_DEFAULT = 0 # 0 == MS, 1 == Apple
class table__g_l_y_f(DefaultTable.DefaultTable):
"""Glyph Data Table
"""Glyph Data table
This class represents the `glyf <https://docs.microsoft.com/en-us/typography/opentype/spec/glyf>`_
table, which contains outlines for glyphs in TrueType format. In many cases,

View File

@ -41,6 +41,16 @@ GVAR_HEADER_SIZE = sstruct.calcsize(GVAR_HEADER_FORMAT)
class table__g_v_a_r(DefaultTable.DefaultTable):
"""Glyph Variations table
The ``gvar`` table provides the per-glyph variation data that
describe how glyph outlines in the ``glyf`` table change across
the variation space that is defined for the font in the ``fvar``
table.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/gvar
"""
dependencies = ["fvar", "glyf"]
def __init__(self, tag=None):

View File

@ -31,6 +31,14 @@ class _GlyphnamedList(Mapping):
class table__h_d_m_x(DefaultTable.DefaultTable):
"""Horizontal Device Metrics table
The ``hdmx`` table is an optional table that stores advance widths for
glyph outlines at specified pixel sizes.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/hdmx
"""
def decompile(self, data, ttFont):
numGlyphs = ttFont["maxp"].numGlyphs
glyphOrder = ttFont.getGlyphOrder()

View File

@ -37,6 +37,13 @@ headFormat = """
class table__h_e_a_d(DefaultTable.DefaultTable):
"""Font Header table
The ``head`` table contains a variety of font-wide information.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/head
"""
dependencies = ["maxp", "loca", "CFF ", "CFF2"]
def decompile(self, data, ttFont):

View File

@ -31,6 +31,18 @@ hheaFormat = """
class table__h_h_e_a(DefaultTable.DefaultTable):
"""Horizontal Header table
The ``hhea`` table contains information needed during horizontal
text layout.
.. note::
This converter class is kept in sync with the :class:`._v_h_e_a.table__v_h_e_a`
table constructor.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/hhea
"""
# Note: Keep in sync with table__v_h_e_a
dependencies = ["hmtx", "glyf", "CFF ", "CFF2"]

View File

@ -12,6 +12,15 @@ log = logging.getLogger(__name__)
class table__h_m_t_x(DefaultTable.DefaultTable):
"""Horizontal Metrics table
The ``hmtx`` table contains per-glyph metrics for the glyphs in a
``glyf``, ``CFF ``, or ``CFF2`` table, as needed for horizontal text
layout.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/hmtx
"""
headerTag = "hhea"
advanceName = "width"
sideBearingName = "lsb"

View File

@ -12,6 +12,17 @@ log = logging.getLogger(__name__)
class table__k_e_r_n(DefaultTable.DefaultTable):
"""Kerning table
The ``kern`` table contains values that contextually adjust the inter-glyph
spacing for the glyphs in a ``glyf`` table.
Note that similar contextual spacing adjustments can also be stored
in the "kern" feature of a ``GPOS`` table.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/kern
"""
def getkern(self, format):
for subtable in self.kernTables:
if subtable.format == format:

View File

@ -2,4 +2,12 @@ from .otBase import BaseTTXConverter
class table__l_c_a_r(BaseTTXConverter):
"""Ligature Caret table
The AAT ``lcar`` table stores division points within ligatures, which applications
can use to position carets properly between the logical parts of the ligature.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6lcar.html
"""
pass

View File

@ -8,6 +8,14 @@ log = logging.getLogger(__name__)
class table__l_o_c_a(DefaultTable.DefaultTable):
"""Index to Location table
The ``loca`` table stores the offsets in the ``glyf`` table that correspond
to the descriptions of each glyph. The glyphs are references by Glyph ID.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/loca
"""
dependencies = ["glyf"]
def decompile(self, data, ttFont):

View File

@ -6,6 +6,14 @@ import struct
class table__l_t_a_g(DefaultTable.DefaultTable):
"""Language Tag table
The AAT ``ltag`` table contains mappings between the numeric codes used
in the language field of the ``name`` table and IETF language tags.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ltag.html
"""
def __init__(self, tag=None):
DefaultTable.DefaultTable.__init__(self, tag)
self.version, self.flags = 1, 0

View File

@ -27,6 +27,14 @@ maxpFormat_1_0_add = """
class table__m_a_x_p(DefaultTable.DefaultTable):
"""Maximum Profile table
The ``maxp`` table contains the memory requirements for the data in
the font.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/maxp
"""
dependencies = ["glyf"]
def decompile(self, data, ttFont):

View File

@ -24,6 +24,14 @@ DATA_MAP_FORMAT = """
class table__m_e_t_a(DefaultTable.DefaultTable):
"""Metadata table
The ``meta`` table contains various metadata values for the font. Each
category of metadata in the table is identified by a four-character tag.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/meta
"""
def __init__(self, tag=None):
DefaultTable.DefaultTable.__init__(self, tag)
self.data = {}

View File

@ -3,4 +3,12 @@ from .otBase import BaseTTXConverter
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6mort.html
class table__m_o_r_t(BaseTTXConverter):
"""The AAT ``mort`` table contains glyph transformations used for script shaping and
for various other optional smart features.
Note: ``mort`` has been deprecated in favor of the newer ``morx`` table.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6mort.html
"""
pass

View File

@ -3,4 +3,13 @@ from .otBase import BaseTTXConverter
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html
class table__m_o_r_x(BaseTTXConverter):
"""The AAT ``morx`` table contains glyph transformations used for script shaping and
for various other optional smart features, akin to ``GSUB`` and ``GPOS`` features
in OpenType Layout.
Note: ``morx`` is a replacement for the now deprecated ``mort`` table.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html
"""
pass

View File

@ -36,6 +36,16 @@ nameRecordSize = sstruct.calcsize(nameRecordFormat)
class table__n_a_m_e(DefaultTable.DefaultTable):
"""Naming table
The ``name`` table is used to store a variety of strings that can be
associated with user-facing font information. Records in the ``name``
table can be tagged with language tags to support multilingual naming
and can support platform-specific character-encoding variants.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/name
"""
dependencies = ["ltag"]
def decompile(self, data, ttFont):

View File

@ -3,4 +3,12 @@ from .otBase import BaseTTXConverter
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6opbd.html
class table__o_p_b_d(BaseTTXConverter):
"""Optical Bounds table
The AAT ``opbd`` table contains optical boundary points for glyphs, which
applications can use for the visual alignment of lines of text.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6opbd.html
"""
pass

View File

@ -27,6 +27,15 @@ postFormatSize = sstruct.calcsize(postFormat)
class table__p_o_s_t(DefaultTable.DefaultTable):
"""PostScript table
The ``post`` table contains information needed to use the font on
PostScript printers, including the PostScript names of glyphs and
data that was stored in the ``FontInfo`` dictionary for Type 1 fonts.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/post
"""
def decompile(self, data, ttFont):
sstruct.unpack(postFormat, data[:postFormatSize], self)
data = data[postFormatSize:]

View File

@ -4,4 +4,13 @@ superclass = ttLib.getTableClass("fpgm")
class table__p_r_e_p(superclass):
"""Control Value Program table
The ``prep`` table contains TrueType instructions that can makee font-wide
alterations to the Control Value Table. It may potentially be executed
before any glyph is processed.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/prep
"""
pass

View File

@ -3,4 +3,10 @@ from .otBase import BaseTTXConverter
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6prop.html
class table__p_r_o_p(BaseTTXConverter):
"""The AAT ``prop`` table can store a variety of per-glyph properties, such as
Unicode directionality or whether glyphs are non-spacing marks.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6prop.html
"""
pass

View File

@ -28,6 +28,16 @@ sbixStrikeOffsetFormatSize = sstruct.calcsize(sbixStrikeOffsetFormat)
class table__s_b_i_x(DefaultTable.DefaultTable):
"""Standard Bitmap Graphics table
The ``sbix`` table stores bitmap image data in standard graphics formats
like JPEG, PNG, or TIFF. The glyphs for which the ``sbix`` table provides
data are indexed by Glyph ID. For each such glyph, the ``sbix`` table can
hold different data for different sizes, called "strikes."
See also https://learn.microsoft.com/en-us/typography/opentype/spec/sbix
"""
def __init__(self, tag=None):
DefaultTable.DefaultTable.__init__(self, tag)
self.version = 1

View File

@ -58,6 +58,13 @@ PER_SIZE_VALUE_FORMAT_SIZE = struct.calcsize(PER_SIZE_VALUE_FORMAT)
class table__t_r_a_k(DefaultTable.DefaultTable):
"""The AAT ``trak`` table can store per-size adjustments to each glyph's
sidebearings to make when tracking is enabled, which applications can
use to provide more visually balanced line spacing.
See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6trak.html
"""
dependencies = ["name"]
def compile(self, ttFont):

View File

@ -31,6 +31,18 @@ vheaFormat = """
class table__v_h_e_a(DefaultTable.DefaultTable):
"""Vertical Header table
The ``vhea`` table contains information needed during vertical
text layout.
.. note::
This converter class is kept in sync with the :class:`._h_h_e_a.table__h_h_e_a`
table constructor.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/vhea
"""
# Note: Keep in sync with table__h_h_e_a
dependencies = ["vmtx", "glyf", "CFF ", "CFF2"]

View File

@ -4,6 +4,15 @@ superclass = ttLib.getTableClass("hmtx")
class table__v_m_t_x(superclass):
"""Vertical Metrics table
The ``vmtx`` table contains per-glyph metrics for the glyphs in a
``glyf``, ``CFF ``, or ``CFF2`` table, as needed for vertical text
layout.
See also https://learn.microsoft.com/en-us/typography/opentype/spec/vmtx
"""
headerTag = "vhea"
advanceName = "height"
sideBearingName = "tsb"