[docs] Fix sphinx warnings (#2453)

* Add default auto doc options

* Ensure all references are unique

* Use anonymous links to avoid duplicate references

* Remove default options, fix wrong module name

* Don’t index repeated class

* Remove repeated classes included through automodule

* Fix warnings

* We don’t use our own static directory

* Correctly format XML in docs

* Fix indentation

* Fix overline

* Bring TOC to top

* Fix definition list

* Offset definition lists and examples

* Fix erroneous markup

* Fix markup

* Already included in automodule

* Fix args markup

* Correct markup for example

* Don’t reindex repeated module

* Correct XML code block markup

* Fix markup errors, change example to doctest

* Correct list markup

* Make ttx docstring both valid RST and valid help output

* Various other boring markup fixes

* Fix example indenting

* Make docstring valid RST and valid help output

* Mock import for reportlab

* It’s ok if manual links don’t appear in toctrees

* Oops typo, I guess doctests are useful
This commit is contained in:
Simon Cozens 2021-12-02 15:31:49 +00:00 committed by GitHub
parent 445108f735
commit 0f03e6529a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 905 additions and 729 deletions

View File

@ -11,43 +11,3 @@ This package also contains two modules for manipulating CFF format glyphs:
specializer specializer
width width
.. autoclass:: fontTools.cffLib.CFFFontSet
:inherited-members:
:members:
.. autoclass:: fontTools.cffLib.TopDict
:members:
.. autoclass:: fontTools.cffLib.CharStrings
:members:
.. autoclass:: fontTools.cffLib.Index
:members:
.. autoclass:: fontTools.cffLib.GlobalSubrsIndex
:members:
.. autoclass:: fontTools.cffLib.TopDictIndex
:members:
.. autoclass:: fontTools.cffLib.CFFWriter
:members:
.. autoclass:: fontTools.cffLib.IndexCompiler
:members:
.. autoclass:: fontTools.cffLib.TopDictIndexCompiler
:members:
.. autoclass:: fontTools.cffLib.FDArrayIndexCompiler
:members:
.. autoclass:: fontTools.cffLib.GlobalSubrsCompiler
:members:
.. autoclass:: fontTools.cffLib.SubrsCompiler
:members:
.. autoclass:: fontTools.cffLib.CharStringsCompiler
:members:

View File

@ -3,9 +3,3 @@ colorLib.builder: Build COLR/CPAL tables from scratch
##################################################### #####################################################
.. automodule:: fontTools.colorLib.builder .. automodule:: fontTools.colorLib.builder
:members: buildCPAL, buildCOLR, populateCOLRv0
.. autoclass:: fontTools.colorLib.builder.ColorPaletteType
:inherited-members:
:members:
:undoc-members:

View File

@ -32,7 +32,12 @@ needs_sphinx = "1.3"
# ones. # ones.
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.napoleon", "sphinx.ext.coverage", "sphinx.ext.autosectionlabel"] extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.napoleon", "sphinx.ext.coverage", "sphinx.ext.autosectionlabel"]
autodoc_mock_imports = ["gtk"] autodoc_mock_imports = ["gtk", "reportlab"]
autodoc_default_options = {
'members': True,
'inherited-members': True
}
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"] templates_path = ["_templates"]
@ -99,7 +104,7 @@ html_theme_options = {"display_version": False}
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"] # html_static_path = ["_static"]
html_favicon = "assets/img/favicon.ico" html_favicon = "assets/img/favicon.ico"

View File

@ -95,7 +95,7 @@ Class Methods
.. _source-descriptor-object:
SourceDescriptor object SourceDescriptor object
======================= =======================
@ -883,7 +883,7 @@ Attributes
is not important for compiling variable fonts. is not important for compiling variable fonts.
5.1.1 conditionset element 5.1.1 conditionset element
======================= ==========================
- Child element of ``rule`` - Child element of ``rule``
- Contains one or more ``condition`` elements. - Contains one or more ``condition`` elements.

View File

@ -1,3 +1,4 @@
:orphan:
.. _developerinfo: .. _developerinfo:
.. image:: ../../Icons/FontToolsIconGreenCircle.png .. image:: ../../Icons/FontToolsIconGreenCircle.png
:width: 200px :width: 200px

View File

@ -4,6 +4,3 @@ plistlib: Tools for handling .plist files
.. automodule:: fontTools.misc.plistlib .. automodule:: fontTools.misc.plistlib
:members: totree, fromtree, load, loads, dump, dumps :members: totree, fromtree, load, loads, dump, dumps
.. autoclass:: fontTools.misc.plistlib.Data
:members:

View File

@ -1,3 +1,5 @@
:orphan:
Optional Dependencies Optional Dependencies
===================== =====================

View File

@ -11,16 +11,31 @@ lookups, coverage tables and so on.
High-level OpenType Layout Lookup Builders High-level OpenType Layout Lookup Builders
------------------------------------------ ------------------------------------------
.. automodule:: fontTools.otlLib.builder .. currentmodule:: fontTools.otlLib.builder
:members: AlternateSubstBuilder, ChainContextPosBuilder, ChainContextSubstBuilder, LigatureSubstBuilder, MultipleSubstBuilder, CursivePosBuilder, MarkBasePosBuilder, MarkLigPosBuilder, MarkMarkPosBuilder, ReverseChainSingleSubstBuilder, SingleSubstBuilder, ClassPairPosSubtableBuilder, PairPosBuilder, SinglePosBuilder
:member-order: bysource .. autoclass:: AlternateSubstBuilder
.. autoclass:: ChainContextPosBuilder
.. autoclass:: ChainContextSubstBuilder
.. autoclass:: LigatureSubstBuilder
.. autoclass:: MultipleSubstBuilder
.. autoclass:: CursivePosBuilder
.. autoclass:: MarkBasePosBuilder
.. autoclass:: MarkLigPosBuilder
.. autoclass:: MarkMarkPosBuilder
.. autoclass:: ReverseChainSingleSubstBuilder
.. autoclass:: SingleSubstBuilder
.. autoclass:: ClassPairPosSubtableBuilder
.. autoclass:: PairPosBuilder
.. autoclass:: SinglePosBuilder
-------------------------------------- --------------------------------------
Common OpenType Layout Data Structures Common OpenType Layout Data Structures
-------------------------------------- --------------------------------------
.. automodule:: fontTools.otlLib.builder .. currentmodule:: fontTools.otlLib.builder
:members: buildCoverage, buildLookup
.. autofunction:: buildCoverage
.. autofunction:: buildLookup
------------------------------------ ------------------------------------
Low-level GSUB Table Lookup Builders Low-level GSUB Table Lookup Builders
@ -29,8 +44,12 @@ Low-level GSUB Table Lookup Builders
These functions deal with the "simple" lookup types. See above for classes to These functions deal with the "simple" lookup types. See above for classes to
help build more complex lookups (contextual and chaining lookups). help build more complex lookups (contextual and chaining lookups).
.. automodule:: fontTools.otlLib.builder .. currentmodule:: fontTools.otlLib.builder
:members: buildSingleSubstSubtable, buildMultipleSubstSubtable, buildAlternateSubstSubtable, buildLigatureSubstSubtable
.. autofunction:: buildSingleSubstSubtable
.. autofunction:: buildMultipleSubstSubtable
.. autofunction:: buildAlternateSubstSubtable
.. autofunction:: buildLigatureSubstSubtable
-------------------------- --------------------------
GPOS Shared Table Builders GPOS Shared Table Builders
@ -40,9 +59,13 @@ The functions help build the `GPOS shared tables <https://docs.microsoft.com/en-
as defined in the OpenType spec: value records, anchors, mark arrays and as defined in the OpenType spec: value records, anchors, mark arrays and
mark record tables. mark record tables.
.. automodule:: fontTools.otlLib.builder .. currentmodule:: fontTools.otlLib.builder
:members: buildValue, buildAnchor, buildMarkArray, buildDevice, buildBaseArray, buildComponentRecord, buildMarkArray, buildValue .. autofunction:: buildValue
:member-order: bysource .. autofunction:: buildAnchor
.. autofunction:: buildMarkArray
.. autofunction:: buildDevice
.. autofunction:: buildBaseArray
.. autofunction:: buildComponentRecord
------------------------------------ ------------------------------------
Low-level GPOS Table Lookup Builders Low-level GPOS Table Lookup Builders
@ -51,9 +74,19 @@ Low-level GPOS Table Lookup Builders
These functions deal with the "simple" lookup types. See above for classes to These functions deal with the "simple" lookup types. See above for classes to
help build more complex lookups (contextual and chaining lookups). help build more complex lookups (contextual and chaining lookups).
.. automodule:: fontTools.otlLib.builder .. currentmodule:: fontTools.otlLib.builder
:members: buildCursivePosSubtable, buildLigatureArray, buildMarkBasePos, buildMarkBasePosSubtable, buildMarkLigPos, buildMarkLigPosSubtable, buildPairPosClassesSubtable, buildPairPosGlyphs, buildPairPosGlyphsSubtable, buildSinglePos, buildSinglePosSubtable
:member-order: bysource .. autofunction:: buildCursivePosSubtable
.. autofunction:: buildLigatureArray
.. autofunction:: buildMarkBasePos
.. autofunction:: buildMarkBasePosSubtable
.. autofunction:: buildMarkLigPos
.. autofunction:: buildMarkLigPosSubtable
.. autofunction:: buildPairPosClassesSubtable
.. autofunction:: buildPairPosGlyphs
.. autofunction:: buildPairPosGlyphsSubtable
.. autofunction:: buildSinglePos
.. autofunction:: buildSinglePosSubtable
---------------------------- ----------------------------
GDEF Table Subtable Builders GDEF Table Subtable Builders
@ -61,14 +94,16 @@ GDEF Table Subtable Builders
These functions build subtables for elements of the ``GDEF`` table. These functions build subtables for elements of the ``GDEF`` table.
.. automodule:: fontTools.otlLib.builder .. currentmodule:: fontTools.otlLib.builder
:members: buildAttachList, buildLigCaretList, buildMarkGlyphSetsDef
:member-order: bysource .. autofunction:: buildAttachList
.. autofunction:: buildLigCaretList
.. autofunction:: buildMarkGlyphSetsDef
------------------ ------------------
STAT Table Builder STAT Table Builder
------------------ ------------------
.. automodule:: fontTools.otlLib.builder .. currentmodule:: fontTools.otlLib.builder
:members: buildStatTable
:member-order: bysource .. autofunction:: buildStatTable

View File

@ -11,6 +11,7 @@ BitmapGlyphMetrics
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
.. automodule:: fontTools.ttLib.tables.BitmapGlyphMetrics .. automodule:: fontTools.ttLib.tables.BitmapGlyphMetrics
:noindex:
:inherited-members: :inherited-members:
:members: :members:
:undoc-members: :undoc-members:

View File

@ -11,6 +11,7 @@ BitmapGlyphMetrics
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
.. automodule:: fontTools.ttLib.tables.BitmapGlyphMetrics .. automodule:: fontTools.ttLib.tables.BitmapGlyphMetrics
:noindex:
:inherited-members: :inherited-members:
:members: :members:
:undoc-members: :undoc-members:

View File

@ -11,6 +11,7 @@ TupleVariation
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
.. automodule:: fontTools.ttLib.tables.TupleVariation .. automodule:: fontTools.ttLib.tables.TupleVariation
:noindex:
:inherited-members: :inherited-members:
:members: :members:
:undoc-members: :undoc-members:

View File

@ -2,6 +2,25 @@
varLib: OpenType Variation Support varLib: OpenType Variation Support
################################## ##################################
.. toctree::
:maxdepth: 2
builder
cff
errors
featureVars
instancer
interpolatable
interpolate_layout
iup
merger
models
mutator
mvar
plot
varStore
The ``fontTools.varLib`` package contains a number of classes and routines The ``fontTools.varLib`` package contains a number of classes and routines
for handling, building and interpolating variable font data. These routines for handling, building and interpolating variable font data. These routines
rely on a common set of concepts, many of which are equivalent to concepts rely on a common set of concepts, many of which are equivalent to concepts
@ -90,24 +109,6 @@ support scalar
0 below its minimum or above its maximum. 0 below its minimum or above its maximum.
.. toctree::
:maxdepth: 2
builder
cff
errors
featureVars
instancer
interpolatable
interpolate_layout
iup
merger
models
mutator
mvar
plot
varStore
.. automodule:: fontTools.varLib .. automodule:: fontTools.varLib
:inherited-members: :inherited-members:
:members: :members:

View File

@ -3,38 +3,27 @@ voltLib
####### #######
.. automodule:: fontTools.voltLib .. automodule:: fontTools.voltLib
:inherited-members:
:members:
:undoc-members:
ast ast
--- ---
.. automodule:: fontTools.voltLib.ast .. automodule:: fontTools.voltLib.ast
:inherited-members:
:members:
:undoc-members: :undoc-members:
error error
----- -----
.. automodule:: fontTools.voltLib.parser .. automodule:: fontTools.voltLib.error
:inherited-members:
:members:
:undoc-members: :undoc-members:
lexer lexer
----- -----
.. automodule:: fontTools.voltLib.lexer .. automodule:: fontTools.voltLib.lexer
:inherited-members:
:members:
:undoc-members: :undoc-members:
parser parser
------ ------
.. automodule:: fontTools.voltLib.parser .. automodule:: fontTools.voltLib.parser
:inherited-members:
:members:
:undoc-members: :undoc-members:

View File

@ -145,11 +145,11 @@ def populateCOLRv0(
"""Build v0 color layers and add to existing COLR table. """Build v0 color layers and add to existing COLR table.
Args: Args:
table: a raw otTables.COLR() object (not ttLib's table_C_O_L_R_). table: a raw ``otTables.COLR()`` object (not ttLib's ``table_C_O_L_R_``).
colorGlyphsV0: map of base glyph names to lists of (layer glyph names, colorGlyphsV0: map of base glyph names to lists of (layer glyph names,
color palette index) tuples. Can be empty. color palette index) tuples. Can be empty.
glyphMap: a map from glyph names to glyph indices, as returned from glyphMap: a map from glyph names to glyph indices, as returned from
TTFont.getReverseGlyphMap(), to optionally sort base records by GID. ``TTFont.getReverseGlyphMap()``, to optionally sort base records by GID.
""" """
if glyphMap is not None: if glyphMap is not None:
colorGlyphItems = sorted( colorGlyphItems = sorted(
@ -192,10 +192,12 @@ def buildCOLR(
clipBoxes: Optional[Dict[str, _ClipBoxInput]] = None, clipBoxes: Optional[Dict[str, _ClipBoxInput]] = None,
) -> C_O_L_R_.table_C_O_L_R_: ) -> C_O_L_R_.table_C_O_L_R_:
"""Build COLR table from color layers mapping. """Build COLR table from color layers mapping.
Args: Args:
colorGlyphs: map of base glyph name to, either list of (layer glyph name, colorGlyphs: map of base glyph name to, either list of (layer glyph name,
color palette index) tuples for COLRv0; or a single Paint (dict) or color palette index) tuples for COLRv0; or a single ``Paint`` (dict) or
list of Paint for COLRv1. list of ``Paint`` for COLRv1.
version: the version of COLR table. If None, the version is determined version: the version of COLR table. If None, the version is determined
by the presence of COLRv1 paints or variation data (varStore), which by the presence of COLRv1 paints or variation data (varStore), which
require version 1; otherwise, if all base glyphs use only simple color require version 1; otherwise, if all base glyphs use only simple color
@ -206,7 +208,8 @@ def buildCOLR(
varIndexMap: Optional DeltaSetIndexMap for deltas associated with v1 layer. varIndexMap: Optional DeltaSetIndexMap for deltas associated with v1 layer.
clipBoxes: Optional map of base glyph name to clip box 4- or 5-tuples: clipBoxes: Optional map of base glyph name to clip box 4- or 5-tuples:
(xMin, yMin, xMax, yMax) or (xMin, yMin, xMax, yMax, varIndexBase). (xMin, yMin, xMax, yMax) or (xMin, yMin, xMax, yMax, varIndexBase).
Return:
Returns:
A new COLR table. A new COLR table.
""" """
self = C_O_L_R_.table_C_O_L_R_() self = C_O_L_R_.table_C_O_L_R_()

View File

@ -160,7 +160,11 @@ class SourceDescriptor(SimpleDescriptor):
class RuleDescriptor(SimpleDescriptor): class RuleDescriptor(SimpleDescriptor):
"""<!-- optional: list of substitution rules --> """Represents the rule descriptor element
.. code-block:: xml
<!-- optional: list of substitution rules -->
<rules> <rules>
<rule name="vertical.bars"> <rule name="vertical.bars">
<conditionset> <conditionset>
@ -996,7 +1000,10 @@ class BaseDocReader(LogMixin):
def readGlyphElement(self, glyphElement, instanceObject): def readGlyphElement(self, glyphElement, instanceObject):
""" """
Read the glyph element. Read the glyph element:
.. code-block:: xml
<glyph name="b" unicode="0x62"/> <glyph name="b" unicode="0x62"/>
<glyph name="b"/> <glyph name="b"/>
<glyph name="b"> <glyph name="b">

View File

@ -10,12 +10,16 @@ used as dictionary keys.
This module exports the following symbols: This module exports the following symbols:
Transform -- this is the main class Transform
Identity -- Transform instance set to the identity transformation this is the main class
Offset -- Convenience function that returns a translating transformation Identity
Scale -- Convenience function that returns a scaling transformation Transform instance set to the identity transformation
Offset
Convenience function that returns a translating transformation
Scale
Convenience function that returns a scaling transformation
Examples: :Example:
>>> t = Transform(2, 0, 0, 3, 0, 0) >>> t = Transform(2, 0, 0, 3, 0, 0)
>>> t.transformPoint((100, 100)) >>> t.transformPoint((100, 100))
@ -72,7 +76,8 @@ class Transform(NamedTuple):
Transform instances are immutable: all transforming methods, eg. Transform instances are immutable: all transforming methods, eg.
rotate(), return a new Transform instance. rotate(), return a new Transform instance.
Examples: :Example:
>>> t = Transform() >>> t = Transform()
>>> t >>> t
<Transform [1 0 0 1 0 0]> <Transform [1 0 0 1 0 0]>
@ -85,7 +90,8 @@ class Transform(NamedTuple):
(200, 300) (200, 300)
Transform's constructor takes six arguments, all of which are Transform's constructor takes six arguments, all of which are
optional, and can be used as keyword arguments: optional, and can be used as keyword arguments::
>>> Transform(12) >>> Transform(12)
<Transform [12 0 0 1 0 0]> <Transform [12 0 0 1 0 0]>
>>> Transform(dx=12) >>> Transform(dx=12)
@ -93,7 +99,8 @@ class Transform(NamedTuple):
>>> Transform(yx=12) >>> Transform(yx=12)
<Transform [1 0 12 1 0 0]> <Transform [1 0 12 1 0 0]>
Transform instances also behave like sequences of length 6: Transform instances also behave like sequences of length 6::
>>> len(Identity) >>> len(Identity)
6 6
>>> list(Identity) >>> list(Identity)
@ -101,13 +108,15 @@ class Transform(NamedTuple):
>>> tuple(Identity) >>> tuple(Identity)
(1, 0, 0, 1, 0, 0) (1, 0, 0, 1, 0, 0)
Transform instances are comparable: Transform instances are comparable::
>>> t1 = Identity.scale(2, 3).translate(4, 6) >>> t1 = Identity.scale(2, 3).translate(4, 6)
>>> t2 = Identity.translate(8, 18).scale(2, 3) >>> t2 = Identity.translate(8, 18).scale(2, 3)
>>> t1 == t2 >>> t1 == t2
1 1
But beware of floating point rounding errors: But beware of floating point rounding errors::
>>> t1 = Identity.scale(0.2, 0.3).translate(0.4, 0.6) >>> t1 = Identity.scale(0.2, 0.3).translate(0.4, 0.6)
>>> t2 = Identity.translate(0.08, 0.18).scale(0.2, 0.3) >>> t2 = Identity.translate(0.08, 0.18).scale(0.2, 0.3)
>>> t1 >>> t1
@ -118,12 +127,14 @@ class Transform(NamedTuple):
0 0
Transform instances are hashable, meaning you can use them as Transform instances are hashable, meaning you can use them as
keys in dictionaries: keys in dictionaries::
>>> d = {Scale(12, 13): None} >>> d = {Scale(12, 13): None}
>>> d >>> d
{<Transform [12 0 0 13 0 0]>: None} {<Transform [12 0 0 13 0 0]>: None}
But again, beware of floating point rounding errors: But again, beware of floating point rounding errors::
>>> t1 = Identity.scale(0.2, 0.3).translate(0.4, 0.6) >>> t1 = Identity.scale(0.2, 0.3).translate(0.4, 0.6)
>>> t2 = Identity.translate(0.08, 0.18).scale(0.2, 0.3) >>> t2 = Identity.translate(0.08, 0.18).scale(0.2, 0.3)
>>> t1 >>> t1
@ -149,7 +160,8 @@ class Transform(NamedTuple):
def transformPoint(self, p): def transformPoint(self, p):
"""Transform a point. """Transform a point.
Example: :Example:
>>> t = Transform() >>> t = Transform()
>>> t = t.scale(2.5, 5.5) >>> t = t.scale(2.5, 5.5)
>>> t.transformPoint((100, 100)) >>> t.transformPoint((100, 100))
@ -162,7 +174,8 @@ class Transform(NamedTuple):
def transformPoints(self, points): def transformPoints(self, points):
"""Transform a list of points. """Transform a list of points.
Example: :Example:
>>> t = Scale(2, 3) >>> t = Scale(2, 3)
>>> t.transformPoints([(0, 0), (0, 100), (100, 100), (100, 0)]) >>> t.transformPoints([(0, 0), (0, 100), (100, 100), (100, 0)])
[(0, 0), (0, 300), (200, 300), (200, 0)] [(0, 0), (0, 300), (200, 300), (200, 0)]
@ -174,7 +187,8 @@ class Transform(NamedTuple):
def transformVector(self, v): def transformVector(self, v):
"""Transform an (dx, dy) vector, treating translation as zero. """Transform an (dx, dy) vector, treating translation as zero.
Example: :Example:
>>> t = Transform(2, 0, 0, 2, 10, 20) >>> t = Transform(2, 0, 0, 2, 10, 20)
>>> t.transformVector((3, -4)) >>> t.transformVector((3, -4))
(6, -8) (6, -8)
@ -187,7 +201,7 @@ class Transform(NamedTuple):
def transformVectors(self, vectors): def transformVectors(self, vectors):
"""Transform a list of (dx, dy) vector, treating translation as zero. """Transform a list of (dx, dy) vector, treating translation as zero.
Example: :Example:
>>> t = Transform(2, 0, 0, 2, 10, 20) >>> t = Transform(2, 0, 0, 2, 10, 20)
>>> t.transformVectors([(3, -4), (5, -6)]) >>> t.transformVectors([(3, -4), (5, -6)])
[(6, -8), (10, -12)] [(6, -8), (10, -12)]
@ -199,7 +213,7 @@ class Transform(NamedTuple):
def translate(self, x=0, y=0): def translate(self, x=0, y=0):
"""Return a new transformation, translated (offset) by x, y. """Return a new transformation, translated (offset) by x, y.
Example: :Example:
>>> t = Transform() >>> t = Transform()
>>> t.translate(20, 30) >>> t.translate(20, 30)
<Transform [1 0 0 1 20 30]> <Transform [1 0 0 1 20 30]>
@ -211,7 +225,7 @@ class Transform(NamedTuple):
"""Return a new transformation, scaled by x, y. The 'y' argument """Return a new transformation, scaled by x, y. The 'y' argument
may be None, which implies to use the x value for y as well. may be None, which implies to use the x value for y as well.
Example: :Example:
>>> t = Transform() >>> t = Transform()
>>> t.scale(5) >>> t.scale(5)
<Transform [5 0 0 5 0 0]> <Transform [5 0 0 5 0 0]>
@ -226,7 +240,7 @@ class Transform(NamedTuple):
def rotate(self, angle): def rotate(self, angle):
"""Return a new transformation, rotated by 'angle' (radians). """Return a new transformation, rotated by 'angle' (radians).
Example: :Example:
>>> import math >>> import math
>>> t = Transform() >>> t = Transform()
>>> t.rotate(math.pi / 2) >>> t.rotate(math.pi / 2)
@ -241,7 +255,7 @@ class Transform(NamedTuple):
def skew(self, x=0, y=0): def skew(self, x=0, y=0):
"""Return a new transformation, skewed by x and y. """Return a new transformation, skewed by x and y.
Example: :Example:
>>> import math >>> import math
>>> t = Transform() >>> t = Transform()
>>> t.skew(math.pi / 4) >>> t.skew(math.pi / 4)
@ -255,7 +269,7 @@ class Transform(NamedTuple):
"""Return a new transformation, transformed by another """Return a new transformation, transformed by another
transformation. transformation.
Example: :Example:
>>> t = Transform(2, 0, 0, 3, 1, 6) >>> t = Transform(2, 0, 0, 3, 1, 6)
>>> t.transform((4, 3, 2, 1, 5, 6)) >>> t.transform((4, 3, 2, 1, 5, 6))
<Transform [8 9 4 3 11 24]> <Transform [8 9 4 3 11 24]>
@ -276,7 +290,7 @@ class Transform(NamedTuple):
transformed by self. self.reverseTransform(other) is equivalent to transformed by self. self.reverseTransform(other) is equivalent to
other.transform(self). other.transform(self).
Example: :Example:
>>> t = Transform(2, 0, 0, 3, 1, 6) >>> t = Transform(2, 0, 0, 3, 1, 6)
>>> t.reverseTransform((4, 3, 2, 1, 5, 6)) >>> t.reverseTransform((4, 3, 2, 1, 5, 6))
<Transform [8 6 6 3 21 15]> <Transform [8 6 6 3 21 15]>
@ -297,7 +311,7 @@ class Transform(NamedTuple):
def inverse(self): def inverse(self):
"""Return the inverse transformation. """Return the inverse transformation.
Example: :Example:
>>> t = Identity.translate(2, 3).scale(4, 5) >>> t = Identity.translate(2, 3).scale(4, 5)
>>> t.transformPoint((10, 20)) >>> t.transformPoint((10, 20))
(42, 103) (42, 103)
@ -315,7 +329,10 @@ class Transform(NamedTuple):
return self.__class__(xx, xy, yx, yy, dx, dy) return self.__class__(xx, xy, yx, yy, dx, dy)
def toPS(self): def toPS(self):
"""Return a PostScript representation: """Return a PostScript representation
:Example:
>>> t = Identity.scale(2, 3).translate(4, 5) >>> t = Identity.scale(2, 3).translate(4, 5)
>>> t.toPS() >>> t.toPS()
'[2 0 0 3 8 15]' '[2 0 0 3 8 15]'
@ -325,6 +342,9 @@ class Transform(NamedTuple):
def __bool__(self): def __bool__(self):
"""Returns True if transform is not identity, False otherwise. """Returns True if transform is not identity, False otherwise.
:Example:
>>> bool(Identity) >>> bool(Identity)
False False
>>> bool(Transform()) >>> bool(Transform())
@ -351,7 +371,7 @@ Identity = Transform()
def Offset(x=0, y=0): def Offset(x=0, y=0):
"""Return the identity transformation offset by x, y. """Return the identity transformation offset by x, y.
Example: :Example:
>>> Offset(2, 3) >>> Offset(2, 3)
<Transform [1 0 0 1 2 3]> <Transform [1 0 0 1 2 3]>
>>> >>>
@ -362,7 +382,7 @@ def Scale(x, y=None):
"""Return the identity transformation scaled by x, y. The 'y' argument """Return the identity transformation scaled by x, y. The 'y' argument
may be None, which implies to use the x value for y as well. may be None, which implies to use the x value for y as well.
Example: :Example:
>>> Scale(2, 3) >>> Scale(2, 3)
<Transform [2 0 0 3 0 0]> <Transform [2 0 0 3 0 0]>
>>> >>>

View File

@ -24,7 +24,7 @@ log = logging.getLogger(__name__)
def buildCoverage(glyphs, glyphMap): def buildCoverage(glyphs, glyphMap):
"""Builds a coverage table. """Builds a coverage table.
Coverage tables (as defined in the `OpenType spec <https://docs.microsoft.com/en-gb/typography/opentype/spec/chapter2#coverage-table>`_) Coverage tables (as defined in the `OpenType spec <https://docs.microsoft.com/en-gb/typography/opentype/spec/chapter2#coverage-table>`__)
are used in all OpenType Layout lookups apart from the Extension type, and are used in all OpenType Layout lookups apart from the Extension type, and
define the glyphs involved in a layout subtable. This allows shaping engines define the glyphs involved in a layout subtable. This allows shaping engines
to compare the glyph stream with the coverage table and quickly determine to compare the glyph stream with the coverage table and quickly determine
@ -66,7 +66,7 @@ LOOKUP_FLAG_USE_MARK_FILTERING_SET = 0x0010
def buildLookup(subtables, flags=0, markFilterSet=None): def buildLookup(subtables, flags=0, markFilterSet=None):
"""Turns a collection of rules into a lookup. """Turns a collection of rules into a lookup.
A Lookup (as defined in the `OpenType Spec <https://docs.microsoft.com/en-gb/typography/opentype/spec/chapter2#lookupTbl>`_) A Lookup (as defined in the `OpenType Spec <https://docs.microsoft.com/en-gb/typography/opentype/spec/chapter2#lookupTbl>`__)
wraps the individual rules in a layout operation (substitution or wraps the individual rules in a layout operation (substitution or
positioning) in a data structure expressing their overall lookup type - positioning) in a data structure expressing their overall lookup type -
for example, single substitution, mark-to-base attachment, and so on - for example, single substitution, mark-to-base attachment, and so on -

View File

@ -8,7 +8,7 @@ it is an abstraction for drawing outlines, making sure that outline objects
don't need to know the details about how and where they're being drawn, and don't need to know the details about how and where they're being drawn, and
that drawings don't need to know the details of how outlines are stored. that drawings don't need to know the details of how outlines are stored.
The most basic pattern is this: The most basic pattern is this::
outline.draw(pen) # 'outline' draws itself onto 'pen' outline.draw(pen) # 'outline' draws itself onto 'pen'
@ -21,13 +21,13 @@ The AbstractPen class defines the Pen protocol. It implements almost
nothing (only no-op closePath() and endPath() methods), but is useful nothing (only no-op closePath() and endPath() methods), but is useful
for documentation purposes. Subclassing it basically tells the reader: for documentation purposes. Subclassing it basically tells the reader:
"this class implements the Pen protocol.". An examples of an AbstractPen "this class implements the Pen protocol.". An examples of an AbstractPen
subclass is fontTools.pens.transformPen.TransformPen. subclass is :py:class:`fontTools.pens.transformPen.TransformPen`.
The BasePen class is a base implementation useful for pens that actually The BasePen class is a base implementation useful for pens that actually
draw (for example a pen renders outlines using a native graphics engine). draw (for example a pen renders outlines using a native graphics engine).
BasePen contains a lot of base functionality, making it very easy to build BasePen contains a lot of base functionality, making it very easy to build
a pen that fully conforms to the pen protocol. Note that if you subclass a pen that fully conforms to the pen protocol. Note that if you subclass
BasePen, you _don't_ override moveTo(), lineTo(), etc., but _moveTo(), BasePen, you *don't* override moveTo(), lineTo(), etc., but _moveTo(),
_lineTo(), etc. See the BasePen doc string for details. Examples of _lineTo(), etc. See the BasePen doc string for details. Examples of
BasePen subclasses are fontTools.pens.boundsPen.BoundsPen and BasePen subclasses are fontTools.pens.boundsPen.BoundsPen and
fontTools.pens.cocoaPen.CocoaPen. fontTools.pens.cocoaPen.CocoaPen.
@ -151,7 +151,7 @@ class NullPen(AbstractPen):
class LoggingPen(LogMixin, AbstractPen): class LoggingPen(LogMixin, AbstractPen):
"""A pen with a `log` property (see fontTools.misc.loggingTools.LogMixin) """A pen with a ``log`` property (see fontTools.misc.loggingTools.LogMixin)
""" """
pass pass

View File

@ -14,10 +14,11 @@ class ControlBoundsPen(BasePen):
on their extremes. on their extremes.
When the shape has been drawn, the bounds are available as the When the shape has been drawn, the bounds are available as the
'bounds' attribute of the pen object. It's a 4-tuple: ``bounds`` attribute of the pen object. It's a 4-tuple::
(xMin, yMin, xMax, yMax). (xMin, yMin, xMax, yMax).
If 'ignoreSinglePoints' is True, single points are ignored. If ``ignoreSinglePoints`` is True, single points are ignored.
""" """
def __init__(self, glyphSet, ignoreSinglePoints=False): def __init__(self, glyphSet, ignoreSinglePoints=False):
@ -73,7 +74,8 @@ class BoundsPen(ControlBoundsPen):
than the "control bounds". than the "control bounds".
When the shape has been drawn, the bounds are available as the When the shape has been drawn, the bounds are available as the
'bounds' attribute of the pen object. It's a 4-tuple: ``bounds`` attribute of the pen object. It's a 4-tuple::
(xMin, yMin, xMax, yMax) (xMin, yMin, xMax, yMax)
""" """

View File

@ -23,6 +23,8 @@ class Cu2QuPen(AbstractPen):
""" A filter pen to convert cubic bezier curves to quadratic b-splines """ A filter pen to convert cubic bezier curves to quadratic b-splines
using the FontTools SegmentPen protocol. using the FontTools SegmentPen protocol.
Args:
other_pen: another SegmentPen used to draw the transformed outline. other_pen: another SegmentPen used to draw the transformed outline.
max_err: maximum approximation error in font units. For optimal results, max_err: maximum approximation error in font units. For optimal results,
if you know the UPEM of the font, we recommend setting this to a if you know the UPEM of the font, we recommend setting this to a
@ -138,6 +140,7 @@ class Cu2QuPointPen(BasePointToSegmentPen):
""" A filter pen to convert cubic bezier curves to quadratic b-splines """ A filter pen to convert cubic bezier curves to quadratic b-splines
using the RoboFab PointPen protocol. using the RoboFab PointPen protocol.
Args:
other_point_pen: another PointPen used to draw the transformed outline. other_point_pen: another PointPen used to draw the transformed outline.
max_err: maximum approximation error in font units. For optimal results, max_err: maximum approximation error in font units. For optimal results,
if you know the UPEM of the font, we recommend setting this to a if you know the UPEM of the font, we recommend setting this to a

View File

@ -29,8 +29,8 @@ class RecordingPen(AbstractPen):
The recording can be accessed as pen.value; or replayed using The recording can be accessed as pen.value; or replayed using
pen.replay(otherPen). pen.replay(otherPen).
Usage example: :Example:
==============
from fontTools.ttLib import TTFont from fontTools.ttLib import TTFont
from fontTools.pens.recordingPen import RecordingPen from fontTools.pens.recordingPen import RecordingPen
@ -72,7 +72,7 @@ class DecomposingRecordingPen(DecomposingPen, RecordingPen):
The constructor takes a single 'glyphSet' positional argument, The constructor takes a single 'glyphSet' positional argument,
a dictionary of glyph objects (i.e. with a 'draw' method) keyed a dictionary of glyph objects (i.e. with a 'draw' method) keyed
by thir name. by thir name::
>>> class SimpleGlyph(object): >>> class SimpleGlyph(object):
... def draw(self, pen): ... def draw(self, pen):
@ -100,8 +100,8 @@ class RecordingPointPen(AbstractPointPen):
The recording can be accessed as pen.value; or replayed using The recording can be accessed as pen.value; or replayed using
pointPen.replay(otherPointPen). pointPen.replay(otherPointPen).
Usage example: :Example:
==============
from defcon import Font from defcon import Font
from fontTools.pens.recordingPen import RecordingPointPen from fontTools.pens.recordingPen import RecordingPointPen

View File

@ -7,7 +7,7 @@ __all__ = ["ReportLabPen"]
class ReportLabPen(BasePen): class ReportLabPen(BasePen):
"""A pen for drawing onto a reportlab.graphics.shapes.Path object.""" """A pen for drawing onto a ``reportlab.graphics.shapes.Path`` object."""
def __init__(self, glyphSet, path=None): def __init__(self, glyphSet, path=None):
BasePen.__init__(self, glyphSet) BasePen.__init__(self, glyphSet)

View File

@ -33,42 +33,51 @@ pyftsubset -- OpenType font subsetter and optimizer
subset fonts as webfonts. Individual optimizations can be enabled or subset fonts as webfonts. Individual optimizations can be enabled or
disabled, and are enabled by default when they are safe. disabled, and are enabled by default when they are safe.
Usage: Usage: """+__usage__+"""
"""+__usage__+"""
At least one glyph or one of --gids, --gids-file, --glyphs, --glyphs-file, At least one glyph or one of --gids, --gids-file, --glyphs, --glyphs-file,
--text, --text-file, --unicodes, or --unicodes-file, must be specified. --text, --text-file, --unicodes, or --unicodes-file, must be specified.
Arguments: Args:
font-file font-file
The input font file. The input font file.
glyph glyph
Specify one or more glyph identifiers to include in the subset. Must be Specify one or more glyph identifiers to include in the subset. Must be
PS glyph names, or the special string '*' to keep the entire glyph set. PS glyph names, or the special string '*' to keep the entire glyph set.
Initial glyph set specification: Initial glyph set specification
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
These options populate the initial glyph set. Same option can appear These options populate the initial glyph set. Same option can appear
multiple times, and the results are accummulated. multiple times, and the results are accummulated.
--gids=<NNN>[,<NNN>...] --gids=<NNN>[,<NNN>...]
Specify comma/whitespace-separated list of glyph IDs or ranges as Specify comma/whitespace-separated list of glyph IDs or ranges as decimal
decimal numbers. For example, --gids=10-12,14 adds glyphs with numbers. For example, --gids=10-12,14 adds glyphs with numbers 10, 11,
numbers 10, 11, 12, and 14. 12, and 14.
--gids-file=<path> --gids-file=<path>
Like --gids but reads from a file. Anything after a '#' on any line Like --gids but reads from a file. Anything after a '#' on any line is
is ignored as comments. ignored as comments.
--glyphs=<glyphname>[,<glyphname>...] --glyphs=<glyphname>[,<glyphname>...]
Specify comma/whitespace-separated PS glyph names to add to the subset. Specify comma/whitespace-separated PS glyph names to add to the subset.
Note that only PS glyph names are accepted, not gidNNN, U+XXXX, etc Note that only PS glyph names are accepted, not gidNNN, U+XXXX, etc
that are accepted on the command line. The special string '*' will keep that are accepted on the command line. The special string '*' will keep
the entire glyph set. the entire glyph set.
--glyphs-file=<path> --glyphs-file=<path>
Like --glyphs but reads from a file. Anything after a '#' on any line Like --glyphs but reads from a file. Anything after a '#' on any line
is ignored as comments. is ignored as comments.
--text=<text> --text=<text>
Specify characters to include in the subset, as UTF-8 string. Specify characters to include in the subset, as UTF-8 string.
--text-file=<path> --text-file=<path>
Like --text but reads from a file. Newline character are not added to Like --text but reads from a file. Newline character are not added to
the subset. the subset.
--unicodes=<XXXX>[,<XXXX>...] --unicodes=<XXXX>[,<XXXX>...]
Specify comma/whitespace-separated list of Unicode codepoints or Specify comma/whitespace-separated list of Unicode codepoints or
ranges as hex numbers, optionally prefixed with 'U+', 'u', etc. ranges as hex numbers, optionally prefixed with 'U+', 'u', etc.
@ -76,19 +85,24 @@ Initial glyph set specification:
the more verbose --unicodes=U+0041-005A,U+0061-007A. the more verbose --unicodes=U+0041-005A,U+0061-007A.
The special strings '*' will choose all Unicode characters mapped The special strings '*' will choose all Unicode characters mapped
by the font. by the font.
--unicodes-file=<path> --unicodes-file=<path>
Like --unicodes, but reads from a file. Anything after a '#' on any Like --unicodes, but reads from a file. Anything after a '#' on any
line in the file is ignored as comments. line in the file is ignored as comments.
--ignore-missing-glyphs --ignore-missing-glyphs
Do not fail if some requested glyphs or gids are not available in Do not fail if some requested glyphs or gids are not available in
the font. the font.
--no-ignore-missing-glyphs --no-ignore-missing-glyphs
Stop and fail if some requested glyphs or gids are not available Stop and fail if some requested glyphs or gids are not available
in the font. [default] in the font. [default]
--ignore-missing-unicodes [default] --ignore-missing-unicodes [default]
Do not fail if some requested Unicode characters (including those Do not fail if some requested Unicode characters (including those
indirectly specified using --text or --text-file) are not available indirectly specified using --text or --text-file) are not available
in the font. in the font.
--no-ignore-missing-unicodes --no-ignore-missing-unicodes
Stop and fail if some requested Unicode characters are not available Stop and fail if some requested Unicode characters are not available
in the font. in the font.
@ -96,10 +110,14 @@ Initial glyph set specification:
unicodes. This is for historical reasons and in the future unicodes. This is for historical reasons and in the future
--no-ignore-missing-unicodes might become default. --no-ignore-missing-unicodes might become default.
Other options: Other options
^^^^^^^^^^^^^
For the other options listed below, to see the current value of the option, For the other options listed below, to see the current value of the option,
pass a value of '?' to it, with or without a '='. pass a value of '?' to it, with or without a '='.
Examples:
Examples::
$ pyftsubset --glyph-names? $ pyftsubset --glyph-names?
Current setting for 'glyph-names' is: False Current setting for 'glyph-names' is: False
$ ./pyftsubset --name-IDs=? $ ./pyftsubset --name-IDs=?
@ -108,50 +126,65 @@ Other options:
Current setting for 'hinting' is: True Current setting for 'hinting' is: True
Current setting for 'hinting' is: False Current setting for 'hinting' is: False
Output options: Output options
^^^^^^^^^^^^^^
--output-file=<path> --output-file=<path>
The output font file. If not specified, the subsetted font The output font file. If not specified, the subsetted font
will be saved in as font-file.subset. will be saved in as font-file.subset.
--flavor=<type> --flavor=<type>
Specify flavor of output font file. May be 'woff' or 'woff2'. Specify flavor of output font file. May be 'woff' or 'woff2'.
Note that WOFF2 requires the Brotli Python extension, available Note that WOFF2 requires the Brotli Python extension, available
at https://github.com/google/brotli at https://github.com/google/brotli
--with-zopfli --with-zopfli
Use the Google Zopfli algorithm to compress WOFF. The output is 3-8 % Use the Google Zopfli algorithm to compress WOFF. The output is 3-8 %
smaller than pure zlib, but the compression speed is much slower. smaller than pure zlib, but the compression speed is much slower.
The Zopfli Python bindings are available at: The Zopfli Python bindings are available at:
https://pypi.python.org/pypi/zopfli https://pypi.python.org/pypi/zopfli
Glyph set expansion: Glyph set expansion
^^^^^^^^^^^^^^^^^^^
These options control how additional glyphs are added to the subset. These options control how additional glyphs are added to the subset.
--retain-gids --retain-gids
Retain glyph indices; just empty glyphs not needed in-place. Retain glyph indices; just empty glyphs not needed in-place.
--notdef-glyph --notdef-glyph
Add the '.notdef' glyph to the subset (ie, keep it). [default] Add the '.notdef' glyph to the subset (ie, keep it). [default]
--no-notdef-glyph --no-notdef-glyph
Drop the '.notdef' glyph unless specified in the glyph set. This Drop the '.notdef' glyph unless specified in the glyph set. This
saves a few bytes, but is not possible for Postscript-flavored saves a few bytes, but is not possible for Postscript-flavored
fonts, as those require '.notdef'. For TrueType-flavored fonts, fonts, as those require '.notdef'. For TrueType-flavored fonts,
this works fine as long as no unsupported glyphs are requested this works fine as long as no unsupported glyphs are requested
from the font. from the font.
--notdef-outline --notdef-outline
Keep the outline of '.notdef' glyph. The '.notdef' glyph outline is Keep the outline of '.notdef' glyph. The '.notdef' glyph outline is
used when glyphs not supported by the font are to be shown. It is not used when glyphs not supported by the font are to be shown. It is not
needed otherwise. needed otherwise.
--no-notdef-outline --no-notdef-outline
When including a '.notdef' glyph, remove its outline. This saves When including a '.notdef' glyph, remove its outline. This saves
a few bytes. [default] a few bytes. [default]
--recommended-glyphs --recommended-glyphs
Add glyphs 0, 1, 2, and 3 to the subset, as recommended for Add glyphs 0, 1, 2, and 3 to the subset, as recommended for
TrueType-flavored fonts: '.notdef', 'NULL' or '.null', 'CR', 'space'. TrueType-flavored fonts: '.notdef', 'NULL' or '.null', 'CR', 'space'.
Some legacy software might require this, but no modern system does. Some legacy software might require this, but no modern system does.
--no-recommended-glyphs --no-recommended-glyphs
Do not add glyphs 0, 1, 2, and 3 to the subset, unless specified in Do not add glyphs 0, 1, 2, and 3 to the subset, unless specified in
glyph set. [default] glyph set. [default]
--no-layout-closure --no-layout-closure
Do not expand glyph set to add glyphs produced by OpenType layout Do not expand glyph set to add glyphs produced by OpenType layout
features. Instead, OpenType layout features will be subset to only features. Instead, OpenType layout features will be subset to only
rules that are relevant to the otherwise-specified glyph set. rules that are relevant to the otherwise-specified glyph set.
--layout-features[+|-]=<feature>[,<feature>...] --layout-features[+|-]=<feature>[,<feature>...]
Specify (=), add to (+=) or exclude from (-=) the comma-separated Specify (=), add to (+=) or exclude from (-=) the comma-separated
set of OpenType layout feature tags that will be preserved. set of OpenType layout feature tags that will be preserved.
@ -163,6 +196,7 @@ Glyph set expansion:
Use '*' to keep all features. Use '*' to keep all features.
Multiple --layout-features options can be provided if necessary. Multiple --layout-features options can be provided if necessary.
Examples: Examples:
--layout-features+=onum,pnum,ss01 --layout-features+=onum,pnum,ss01
* Keep the default set of features and 'onum', 'pnum', 'ss01'. * Keep the default set of features and 'onum', 'pnum', 'ss01'.
--layout-features-='mark','mkmk' --layout-features-='mark','mkmk'
@ -175,15 +209,19 @@ Glyph set expansion:
* Keep all features. * Keep all features.
--layout-features+=aalt --layout-features-=vrt2 --layout-features+=aalt --layout-features-=vrt2
* Keep default set of features plus 'aalt', but drop 'vrt2'. * Keep default set of features plus 'aalt', but drop 'vrt2'.
--layout-scripts[+|-]=<script>[,<script>...] --layout-scripts[+|-]=<script>[,<script>...]
Specify (=), add to (+=) or exclude from (-=) the comma-separated Specify (=), add to (+=) or exclude from (-=) the comma-separated
set of OpenType layout script tags that will be preserved. LangSys tags set of OpenType layout script tags that will be preserved. LangSys tags
can be appended to script tag, separated by '.', for example: can be appended to script tag, separated by '.', for example:
'arab.dflt,arab.URD,latn.TRK'. By default all scripts are retained ('*'). 'arab.dflt,arab.URD,latn.TRK'. By default all scripts are retained ('*').
Hinting options: Hinting options
^^^^^^^^^^^^^^^
--hinting --hinting
Keep hinting [default] Keep hinting [default]
--no-hinting --no-hinting
Drop glyph-specific hinting and font-wide hinting tables, as well Drop glyph-specific hinting and font-wide hinting tables, as well
as remove hinting-related bits and pieces from other tables (eg. GPOS). as remove hinting-related bits and pieces from other tables (eg. GPOS).
@ -193,17 +231,22 @@ Hinting options:
are suitable for extremely high-resolution systems, like high-end are suitable for extremely high-resolution systems, like high-end
mobile devices and retina displays. mobile devices and retina displays.
Optimization options: Optimization options
^^^^^^^^^^^^^^^^^^^^
--desubroutinize --desubroutinize
Remove CFF use of subroutinizes. Subroutinization is a way to make CFF Remove CFF use of subroutinizes. Subroutinization is a way to make CFF
fonts smaller. For small subsets however, desubroutinizing might make fonts smaller. For small subsets however, desubroutinizing might make
the font smaller. It has even been reported that desubroutinized CFF the font smaller. It has even been reported that desubroutinized CFF
fonts compress better (produce smaller output) WOFF and WOFF2 fonts. fonts compress better (produce smaller output) WOFF and WOFF2 fonts.
Also see note under --no-hinting. Also see note under --no-hinting.
--no-desubroutinize [default] --no-desubroutinize [default]
Leave CFF subroutinizes as is, only throw away unused subroutinizes. Leave CFF subroutinizes as is, only throw away unused subroutinizes.
Font table options: Font table options
^^^^^^^^^^^^^^^^^^
--drop-tables[+|-]=<table>[,<table>...] --drop-tables[+|-]=<table>[,<table>...]
Specify (=), add to (+=) or exclude from (-=) the comma-separated Specify (=), add to (+=) or exclude from (-=) the comma-separated
set of tables that will be be dropped. set of tables that will be be dropped.
@ -211,15 +254,21 @@ Font table options:
'BASE', 'JSTF', 'DSIG', 'EBDT', 'EBLC', 'EBSC', 'PCLT', 'LTSH' 'BASE', 'JSTF', 'DSIG', 'EBDT', 'EBLC', 'EBSC', 'PCLT', 'LTSH'
and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill'. and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill'.
The tool will attempt to subset the remaining tables. The tool will attempt to subset the remaining tables.
Examples: Examples:
--drop-tables-='BASE' --drop-tables-='BASE'
* Drop the default set of tables but keep 'BASE'. * Drop the default set of tables but keep 'BASE'.
--drop-tables+=GSUB --drop-tables+=GSUB
* Drop the default set of tables and 'GSUB'. * Drop the default set of tables and 'GSUB'.
--drop-tables=DSIG --drop-tables=DSIG
* Only drop the 'DSIG' table, keep all others. * Only drop the 'DSIG' table, keep all others.
--drop-tables= --drop-tables=
* Keep all tables. * Keep all tables.
--no-subset-tables+=<table>[,<table>...] --no-subset-tables+=<table>[,<table>...]
Add to the set of tables that will not be subsetted. Add to the set of tables that will not be subsetted.
By default, the following tables are included in this list, as By default, the following tables are included in this list, as
@ -229,56 +278,76 @@ Font table options:
By default, tables that the tool does not know how to subset and are not By default, tables that the tool does not know how to subset and are not
specified here will be dropped from the font, unless --passthrough-tables specified here will be dropped from the font, unless --passthrough-tables
option is passed. option is passed.
Example: Example:
--no-subset-tables+=FFTM --no-subset-tables+=FFTM
* Keep 'FFTM' table in the font by preventing subsetting. * Keep 'FFTM' table in the font by preventing subsetting.
--passthrough-tables --passthrough-tables
Do not drop tables that the tool does not know how to subset. Do not drop tables that the tool does not know how to subset.
--no-passthrough-tables --no-passthrough-tables
Tables that the tool does not know how to subset and are not specified Tables that the tool does not know how to subset and are not specified
in --no-subset-tables will be dropped from the font. [default] in --no-subset-tables will be dropped from the font. [default]
--hinting-tables[-]=<table>[,<table>...] --hinting-tables[-]=<table>[,<table>...]
Specify (=), add to (+=) or exclude from (-=) the list of font-wide Specify (=), add to (+=) or exclude from (-=) the list of font-wide
hinting tables that will be dropped if --no-hinting is specified, hinting tables that will be dropped if --no-hinting is specified.
Examples: Examples:
--hinting-tables-='VDMX' --hinting-tables-='VDMX'
* Drop font-wide hinting tables except 'VDMX'. * Drop font-wide hinting tables except 'VDMX'.
--hinting-tables='' --hinting-tables=''
* Keep all font-wide hinting tables (but strip hints from glyphs). * Keep all font-wide hinting tables (but strip hints from glyphs).
--legacy-kern --legacy-kern
Keep TrueType 'kern' table even when OpenType 'GPOS' is available. Keep TrueType 'kern' table even when OpenType 'GPOS' is available.
--no-legacy-kern --no-legacy-kern
Drop TrueType 'kern' table if OpenType 'GPOS' is available. [default] Drop TrueType 'kern' table if OpenType 'GPOS' is available. [default]
Font naming options: Font naming options
^^^^^^^^^^^^^^^^^^^
These options control what is retained in the 'name' table. For numerical These options control what is retained in the 'name' table. For numerical
codes, see: http://www.microsoft.com/typography/otspec/name.htm codes, see: http://www.microsoft.com/typography/otspec/name.htm
--name-IDs[+|-]=<nameID>[,<nameID>...] --name-IDs[+|-]=<nameID>[,<nameID>...]
Specify (=), add to (+=) or exclude from (-=) the set of 'name' table Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
entry nameIDs that will be preserved. By default, only nameIDs between 0 entry nameIDs that will be preserved. By default, only nameIDs between 0
and 6 are preserved, the rest are dropped. Use '*' to keep all entries. and 6 are preserved, the rest are dropped. Use '*' to keep all entries.
Examples: Examples:
--name-IDs+=7,8,9 --name-IDs+=7,8,9
* Also keep Trademark, Manufacturer and Designer name entries. * Also keep Trademark, Manufacturer and Designer name entries.
--name-IDs='' --name-IDs=''
* Drop all 'name' table entries. * Drop all 'name' table entries.
--name-IDs='*' --name-IDs='*'
* keep all 'name' table entries * keep all 'name' table entries
--name-legacy --name-legacy
Keep legacy (non-Unicode) 'name' table entries (0.x, 1.x etc.). Keep legacy (non-Unicode) 'name' table entries (0.x, 1.x etc.).
XXX Note: This might be needed for some fonts that have no Unicode name XXX Note: This might be needed for some fonts that have no Unicode name
entires for English. See: https://github.com/fonttools/fonttools/issues/146 entires for English. See: https://github.com/fonttools/fonttools/issues/146
--no-name-legacy --no-name-legacy
Drop legacy (non-Unicode) 'name' table entries [default] Drop legacy (non-Unicode) 'name' table entries [default]
--name-languages[+|-]=<langID>[,<langID>] --name-languages[+|-]=<langID>[,<langID>]
Specify (=), add to (+=) or exclude from (-=) the set of 'name' table Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
langIDs that will be preserved. By default only records with langID langIDs that will be preserved. By default only records with langID
0x0409 (English) are preserved. Use '*' to keep all langIDs. 0x0409 (English) are preserved. Use '*' to keep all langIDs.
--obfuscate-names --obfuscate-names
Make the font unusable as a system font by replacing name IDs 1, 2, 3, 4, Make the font unusable as a system font by replacing name IDs 1, 2, 3, 4,
and 6 with dummy strings (it is still fully functional as webfont). and 6 with dummy strings (it is still fully functional as webfont).
Glyph naming and encoding options: Glyph naming and encoding options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--glyph-names --glyph-names
Keep PS glyph names in TT-flavored fonts. In general glyph names are Keep PS glyph names in TT-flavored fonts. In general glyph names are
not needed for correct use of the font. However, some PDF generators not needed for correct use of the font. However, some PDF generators
@ -296,7 +365,9 @@ Glyph naming and encoding options:
--no-symbol-cmap --no-symbol-cmap
Drop the 3.0 symbol 'cmap'. [default] Drop the 3.0 symbol 'cmap'. [default]
Other font-specific options: Other font-specific options
^^^^^^^^^^^^^^^^^^^^^^^^^^^
--recalc-bounds --recalc-bounds
Recalculate font bounding boxes. Recalculate font bounding boxes.
--no-recalc-bounds --no-recalc-bounds
@ -333,7 +404,9 @@ Other font-specific options:
When subsetting SVG table, use lxml pretty_print=True option to indent When subsetting SVG table, use lxml pretty_print=True option to indent
the XML output (only recommended for debugging purposes). the XML output (only recommended for debugging purposes).
Application options: Application options
^^^^^^^^^^^^^^^^^^^
--verbose --verbose
Display verbose information of the subsetting process. Display verbose information of the subsetting process.
--timing --timing
@ -341,9 +414,11 @@ Application options:
--xml --xml
Display the TTX XML representation of subsetted font. Display the TTX XML representation of subsetted font.
Example: Example
^^^^^^^
Produce a subset containing the characters ' !"#$%' without performing Produce a subset containing the characters ' !"#$%' without performing
size-reducing optimizations: size-reducing optimizations::
$ pyftsubset font.ttf --unicodes="U+0020-0025" \\ $ pyftsubset font.ttf --unicodes="U+0020-0025" \\
--layout-features='*' --glyph-names --symbol-cmap --legacy-cmap \\ --layout-features='*' --glyph-names --symbol-cmap --legacy-cmap \\

View File

@ -3,6 +3,9 @@
https://docs.microsoft.com/en-us/typography/opentype/spec/svg https://docs.microsoft.com/en-us/typography/opentype/spec/svg
The XML format is: The XML format is:
.. code-block:: xml
<SVG> <SVG>
<svgDoc endGlyphID="1" startGlyphID="1"> <svgDoc endGlyphID="1" startGlyphID="1">
<![CDATA[ <complete SVG doc> ]] <![CDATA[ <complete SVG doc> ]]

View File

@ -867,12 +867,13 @@ _customTableRegistry = {}
def registerCustomTableClass(tag, moduleName, className=None): def registerCustomTableClass(tag, moduleName, className=None):
"""Register a custom packer/unpacker class for a table. """Register a custom packer/unpacker class for a table.
The 'moduleName' must be an importable module. If no 'className' The 'moduleName' must be an importable module. If no 'className'
is given, it is derived from the tag, for example it will be is given, it is derived from the tag, for example it will be
table_C_U_S_T_ for a 'CUST' tag. ``table_C_U_S_T_`` for a 'CUST' tag.
The registered table class should be a subclass of The registered table class should be a subclass of
fontTools.ttLib.tables.DefaultTable.DefaultTable :py:class:`fontTools.ttLib.tables.DefaultTable.DefaultTable`
""" """
if className is None: if className is None:
className = "table_" + tagToIdentifier(tag) className = "table_" + tagToIdentifier(tag)
@ -943,10 +944,14 @@ def tagToIdentifier(tag):
letters get an underscore after the letter. Trailing spaces are letters get an underscore after the letter. Trailing spaces are
trimmed. Illegal characters are escaped as two hex bytes. If the trimmed. Illegal characters are escaped as two hex bytes. If the
result starts with a number (as the result of a hex escape), an result starts with a number (as the result of a hex escape), an
extra underscore is prepended. Examples: extra underscore is prepended. Examples::
'glyf' -> '_g_l_y_f'
'cvt ' -> '_c_v_t' >>> tagToIdentifier('glyf')
'OS/2' -> 'O_S_2f_2' '_g_l_y_f'
>>> tagToIdentifier('cvt ')
'_c_v_t'
>>> tagToIdentifier('OS/2')
'O_S_2f_2'
""" """
import re import re
tag = Tag(tag) tag = Tag(tag)

View File

@ -11,23 +11,28 @@ usage: ttx [options] inputfile1 [... inputfileN]
Output files are created so they are unique: an existing file is Output files are created so they are unique: an existing file is
never overwritten. never overwritten.
General options: General options
-h Help: print this message. ===============
--version: show version and exit.
-h Help print this message.
--version show version and exit.
-d <outputfolder> Specify a directory where the output files are -d <outputfolder> Specify a directory where the output files are
to be created. to be created.
-o <outputfile> Specify a file to write the output to. A special -o <outputfile> Specify a file to write the output to. A special
value of - would use the standard output. value of - would use the standard output.
-f Overwrite existing output file(s), ie. don't append numbers. -f Overwrite existing output file(s), ie. don't append
-v Verbose: more messages will be written to stdout about what numbers.
is being done. -v Verbose: more messages will be written to stdout
-q Quiet: No messages will be written to stdout about what about what is being done.
is being done. -q Quiet: No messages will be written to stdout about
what is being done.
-a allow virtual glyphs ID's on compile or decompile. -a allow virtual glyphs ID's on compile or decompile.
Dump options: Dump options
-l List table info: instead of dumping to a TTX file, list some ============
minimal info about each table.
-l List table info: instead of dumping to a TTX file, list
some minimal info about each table.
-t <table> Specify a table to dump. Multiple -t options -t <table> Specify a table to dump. Multiple -t options
are allowed. When no -t option is specified, all tables are allowed. When no -t option is specified, all tables
will be dumped. will be dumped.
@ -41,47 +46,59 @@ usage: ttx [options] inputfile1 [... inputfileN]
-g Split glyf table: Save the glyf data into separate TTX files -g Split glyf table: Save the glyf data into separate TTX files
per glyph and write a small TTX for the glyf table which per glyph and write a small TTX for the glyf table which
contains references to the individual TTGlyph elements. contains references to the individual TTGlyph elements.
NOTE: specifying -g implies -s (no need for -s together with -g) NOTE: specifying -g implies -s (no need for -s together
-i Do NOT disassemble TT instructions: when this option is given, with -g)
all TrueType programs (glyph programs, the font program and the -i Do NOT disassemble TT instructions: when this option is
pre-program) will be written to the TTX file as hex data given, all TrueType programs (glyph programs, the font
instead of assembly. This saves some time and makes the TTX program and the pre-program) will be written to the TTX
file smaller. file as hex data instead of assembly. This saves some time
and makes the TTX file smaller.
-z <format> Specify a bitmap data export option for EBDT: -z <format> Specify a bitmap data export option for EBDT:
{'raw', 'row', 'bitwise', 'extfile'} or for the CBDT: {'raw', 'row', 'bitwise', 'extfile'} or for the CBDT:
{'raw', 'extfile'} Each option does one of the following: {'raw', 'extfile'} Each option does one of the following:
-z raw -z raw
* export the bitmap data as a hex dump export the bitmap data as a hex dump
-z row -z row
* export each row as hex data export each row as hex data
-z bitwise -z bitwise
* export each row as binary in an ASCII art style export each row as binary in an ASCII art style
-z extfile -z extfile
* export the data as external files with XML references export the data as external files with XML references
If no export format is specified 'raw' format is used. If no export format is specified 'raw' format is used.
-e Don't ignore decompilation errors, but show a full traceback -e Don't ignore decompilation errors, but show a full traceback
and abort. and abort.
-y <number> Select font number for TrueType Collection (.ttc/.otc), -y <number> Select font number for TrueType Collection (.ttc/.otc),
starting from 0. starting from 0.
--unicodedata <UnicodeData.txt> Use custom database file to write --unicodedata <UnicodeData.txt>
character names in the comments of the cmap TTX output. Use custom database file to write character names in the
--newline <value> Control how line endings are written in the XML comments of the cmap TTX output.
file. It can be 'LF', 'CR', or 'CRLF'. If not specified, the --newline <value>
Control how line endings are written in the XML file. It
can be 'LF', 'CR', or 'CRLF'. If not specified, the
default platform-specific line endings are used. default platform-specific line endings are used.
Compile options: Compile options
-m Merge with TrueType-input-file: specify a TrueType or OpenType ===============
font file to be merged with the TTX file. This option is only
valid when at most one TTX file is specified. -m Merge with TrueType-input-file: specify a TrueType or
-b Don't recalc glyph bounding boxes: use the values in the TTX OpenType font file to be merged with the TTX file. This
file as-is. option is only valid when at most one TTX file is specified.
--recalc-timestamp Set font 'modified' timestamp to current time. -b Don't recalc glyph bounding boxes: use the values in the
By default, the modification time of the TTX file will be used. TTX file as-is.
--no-recalc-timestamp Keep the original font 'modified' timestamp. --recalc-timestamp
--flavor <type> Specify flavor of output font file. May be 'woff' Set font 'modified' timestamp to current time.
or 'woff2'. Note that WOFF2 requires the Brotli Python extension, By default, the modification time of the TTX file will be
used.
--no-recalc-timestamp
Keep the original font 'modified' timestamp.
--flavor <type>
Specify flavor of output font file. May be 'woff' or 'woff2'.
Note that WOFF2 requires the Brotli Python extension,
available at https://github.com/google/brotli available at https://github.com/google/brotli
--with-zopfli Use Zopfli instead of Zlib to compress WOFF. The Python --with-zopfli
Use Zopfli instead of Zlib to compress WOFF. The Python
extension is available at https://pypi.python.org/pypi/zopfli extension is available at https://pypi.python.org/pypi/zopfli
""" """

View File

@ -491,7 +491,7 @@ class UFOReader(_UFOBaseIO):
""" """
Get maps defining the renaming that was done during any Get maps defining the renaming that was done during any
needed kerning group conversion. This method returns a needed kerning group conversion. This method returns a
dictionary of this form: dictionary of this form::
{ {
"side1" : {"old group name" : "new group name"}, "side1" : {"old group name" : "new group name"},
@ -1173,7 +1173,7 @@ class UFOWriter(UFOReader):
when writing groups and kerning in UFO 1 and UFO 2. when writing groups and kerning in UFO 1 and UFO 2.
This will effectively undo the conversion done when This will effectively undo the conversion done when
UFOReader reads this data. The dictionary should have UFOReader reads this data. The dictionary should have
this form: this form::
{ {
"side1" : {"group name to use when writing" : "group name in data"}, "side1" : {"group name to use when writing" : "group name in data"},

View File

@ -360,16 +360,26 @@ class GlyphSet(_UFOBaseIO):
'glyphObject' argument can be any kind of object (even None); 'glyphObject' argument can be any kind of object (even None);
the readGlyph() method will attempt to set the following the readGlyph() method will attempt to set the following
attributes on it: attributes on it:
"width" the advance width of the glyph
"height" the advance height of the glyph width
"unicodes" a list of unicode values for this glyph the advance width of the glyph
"note" a string height
"lib" a dictionary containing custom data the advance height of the glyph
"image" a dictionary containing image data unicodes
"guidelines" a list of guideline data dictionaries a list of unicode values for this glyph
"anchors" a list of anchor data dictionaries note
a string
lib
a dictionary containing custom data
image
a dictionary containing image data
guidelines
a list of guideline data dictionaries
anchors
a list of anchor data dictionaries
All attributes are optional, in two ways: All attributes are optional, in two ways:
1) An attribute *won't* be set if the .glif file doesn't 1) An attribute *won't* be set if the .glif file doesn't
contain data for it. 'glyphObject' will have to deal contain data for it. 'glyphObject' will have to deal
with default values itself. with default values itself.
@ -401,14 +411,23 @@ class GlyphSet(_UFOBaseIO):
'glyphObject' argument can be any kind of object (even None); 'glyphObject' argument can be any kind of object (even None);
the writeGlyph() method will attempt to get the following the writeGlyph() method will attempt to get the following
attributes from it: attributes from it:
"width" the advance with of the glyph
"height" the advance height of the glyph width
"unicodes" a list of unicode values for this glyph the advance width of the glyph
"note" a string height
"lib" a dictionary containing custom data the advance height of the glyph
"image" a dictionary containing image data unicodes
"guidelines" a list of guideline data dictionaries a list of unicode values for this glyph
"anchors" a list of anchor data dictionaries note
a string
lib
a dictionary containing custom data
image
a dictionary containing image data
guidelines
a list of guideline data dictionaries
anchors
a list of anchor data dictionaries
All attributes are optional: if 'glyphObject' doesn't All attributes are optional: if 'glyphObject' doesn't
have the attribute, it will simply be skipped. have the attribute, it will simply be skipped.
@ -600,16 +619,26 @@ def readGlyphFromString(
The 'glyphObject' argument can be any kind of object (even None); The 'glyphObject' argument can be any kind of object (even None);
the readGlyphFromString() method will attempt to set the following the readGlyphFromString() method will attempt to set the following
attributes on it: attributes on it:
"width" the advance with of the glyph
"height" the advance height of the glyph width
"unicodes" a list of unicode values for this glyph the advance width of the glyph
"note" a string height
"lib" a dictionary containing custom data the advance height of the glyph
"image" a dictionary containing image data unicodes
"guidelines" a list of guideline data dictionaries a list of unicode values for this glyph
"anchors" a list of anchor data dictionaries note
a string
lib
a dictionary containing custom data
image
a dictionary containing image data
guidelines
a list of guideline data dictionaries
anchors
a list of anchor data dictionaries
All attributes are optional, in two ways: All attributes are optional, in two ways:
1) An attribute *won't* be set if the .glif file doesn't 1) An attribute *won't* be set if the .glif file doesn't
contain data for it. 'glyphObject' will have to deal contain data for it. 'glyphObject' will have to deal
with default values itself. with default values itself.
@ -733,14 +762,23 @@ def writeGlyphToString(
The 'glyphObject' argument can be any kind of object (even None); The 'glyphObject' argument can be any kind of object (even None);
the writeGlyphToString() method will attempt to get the following the writeGlyphToString() method will attempt to get the following
attributes from it: attributes from it:
"width" the advance width of the glyph
"height" the advance height of the glyph width
"unicodes" a list of unicode values for this glyph the advance width of the glyph
"note" a string height
"lib" a dictionary containing custom data the advance height of the glyph
"image" a dictionary containing image data unicodes
"guidelines" a list of guideline data dictionaries a list of unicode values for this glyph
"anchors" a list of anchor data dictionaries note
a string
lib
a dictionary containing custom data
image
a dictionary containing image data
guidelines
a list of guideline data dictionaries
anchors
a list of anchor data dictionaries
All attributes are optional: if 'glyphObject' doesn't All attributes are optional: if 'glyphObject' doesn't
have the attribute, it will simply be skipped. have the attribute, it will simply be skipped.

View File

@ -163,15 +163,17 @@ def merge_PrivateDicts(top_dicts, vsindex_dict, var_model, fd_map):
""" """
I step through the FontDicts in the FDArray of the varfont TopDict. I step through the FontDicts in the FDArray of the varfont TopDict.
For each varfont FontDict: For each varfont FontDict:
step through each key in FontDict.Private.
For each key, step through each relevant source font Private dict, and * step through each key in FontDict.Private.
* For each key, step through each relevant source font Private dict, and
build a list of values to blend. build a list of values to blend.
The 'relevant' source fonts are selected by first getting the right The 'relevant' source fonts are selected by first getting the right
submodel using vsindex_dict[vsindex]. The indices of the submodel using ``vsindex_dict[vsindex]``. The indices of the
subModel.locations are mapped to source font list indices by ``subModel.locations`` are mapped to source font list indices by
assuming the latter order is the same as the order of the assuming the latter order is the same as the order of the
var_model.locations. I can then get the index of each subModel ``var_model.locations``. I can then get the index of each subModel
location in the list of var_model.locations. location in the list of ``var_model.locations``.
""" """
topDict = top_dicts[0] topDict = top_dicts[0]
@ -591,16 +593,21 @@ class CFF2CharStringMergePen(T2CharStringPen):
def reorder_blend_args(self, commands, get_delta_func): def reorder_blend_args(self, commands, get_delta_func):
""" """
We first re-order the master coordinate values. We first re-order the master coordinate values.
For a moveto to lineto, the args are now arranged as: For a moveto to lineto, the args are now arranged as::
[ [master_0 x,y], [master_1 x,y], [master_2 x,y] ] [ [master_0 x,y], [master_1 x,y], [master_2 x,y] ]
We re-arrange this to
We re-arrange this to::
[ [master_0 x, master_1 x, master_2 x], [ [master_0 x, master_1 x, master_2 x],
[master_0 y, master_1 y, master_2 y] [master_0 y, master_1 y, master_2 y]
] ]
If the master values are all the same, we collapse the list to If the master values are all the same, we collapse the list to
as single value instead of a list. as single value instead of a list.
We then convert this to: We then convert this to::
[ [master_0 x] + [x delta tuple] + [numBlends=1] [ [master_0 x] + [x delta tuple] + [numBlends=1]
[master_0 y] + [y delta tuple] + [numBlends=1] [master_0 y] + [y delta tuple] + [numBlends=1]
] ]

View File

@ -94,7 +94,8 @@ def overlayFeatureVariations(conditionalSubstitutions):
substitution dictionaries. These dictionaries are not merged to allow data substitution dictionaries. These dictionaries are not merged to allow data
sharing when they are converted into font tables. sharing when they are converted into font tables.
Example: Example::
>>> condSubst = [ >>> condSubst = [
... # A list of (Region, Substitution) tuples. ... # A list of (Region, Substitution) tuples.
... ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}), ... ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
@ -108,6 +109,7 @@ def overlayFeatureVariations(conditionalSubstitutions):
[{'dollar': 'dollar.rvrn'}, {'cent': 'cent.rvrn'}]), [{'dollar': 'dollar.rvrn'}, {'cent': 'cent.rvrn'}]),
({'wdth': (0.5, 1.0)}, [{'cent': 'cent.rvrn'}]), ({'wdth': (0.5, 1.0)}, [{'cent': 'cent.rvrn'}]),
({'wght': (0.5, 1.0)}, [{'dollar': 'dollar.rvrn'}])] ({'wght': (0.5, 1.0)}, [{'dollar': 'dollar.rvrn'}])]
""" """
# Merge same-substitutions rules, as this creates fewer number oflookups. # Merge same-substitutions rules, as this creates fewer number oflookups.
@ -184,11 +186,12 @@ def overlayFeatureVariations(conditionalSubstitutions):
# #
def overlayBox(top, bot): def overlayBox(top, bot):
"""Overlays `top` box on top of `bot` box. """Overlays ``top`` box on top of ``bot`` box.
Returns two items: Returns two items:
- Box for intersection of `top` and `bot`, or None if they don't intersect.
- Box for remainder of `bot`. Remainder box might not be exact (since the * Box for intersection of ``top`` and ``bot``, or None if they don't intersect.
* Box for remainder of ``bot``. Remainder box might not be exact (since the
remainder might not be a simple box), but is inclusive of the exact remainder might not be a simple box), but is inclusive of the exact
remainder. remainder.
""" """

View File

@ -5,7 +5,7 @@ create full instances (i.e. static fonts) from variable fonts, as well as "parti
variable fonts that only contain a subset of the original variation space. variable fonts that only contain a subset of the original variation space.
For example, if you wish to pin the width axis to a given location while also For example, if you wish to pin the width axis to a given location while also
restricting the weight axis to 400..700 range, you can do: restricting the weight axis to 400..700 range, you can do::
$ fonttools varLib.instancer ./NotoSans-VF.ttf wdth=85 wght=400:700 $ fonttools varLib.instancer ./NotoSans-VF.ttf wdth=85 wght=400:700
@ -17,7 +17,7 @@ and returns a new TTFont representing either a partial VF, or full instance if a
the VF axes were given an explicit coordinate. the VF axes were given an explicit coordinate.
E.g. here's how to pin the wght axis at a given location in a wght+wdth variable E.g. here's how to pin the wght axis at a given location in a wght+wdth variable
font, keeping only the deltas associated with the wdth axis: font, keeping only the deltas associated with the wdth axis::
| >>> from fontTools import ttLib | >>> from fontTools import ttLib
| >>> from fontTools.varLib import instancer | >>> from fontTools.varLib import instancer
@ -53,12 +53,17 @@ whereas mutator implicitly drops the axis at its default coordinate.
The module currently supports only the first three "levels" of partial instancing, The module currently supports only the first three "levels" of partial instancing,
with the rest planned to be implemented in the future, namely: with the rest planned to be implemented in the future, namely:
L1) dropping one or more axes while leaving the default tables unmodified;
L2) dropping one or more axes while pinning them at non-default locations; L1
L3) restricting the range of variation of one or more axes, by setting either dropping one or more axes while leaving the default tables unmodified;
L2
dropping one or more axes while pinning them at non-default locations;
L3
restricting the range of variation of one or more axes, by setting either
a new minimum or maximum, potentially -- though not necessarily -- dropping a new minimum or maximum, potentially -- though not necessarily -- dropping
entire regions of variations that fall completely outside this new range. entire regions of variations that fall completely outside this new range.
L4) moving the default location of an axis. L4
moving the default location of an axis.
Currently only TrueType-flavored variable fonts (i.e. containing 'glyf' table) Currently only TrueType-flavored variable fonts (i.e. containing 'glyf' table)
are supported, but support for CFF2 variable fonts will be added soon. are supported, but support for CFF2 variable fonts will be added soon.

View File

@ -170,7 +170,8 @@ class VariationModel(object):
""" """
Locations must be in normalized space. Ie. base master Locations must be in normalized space. Ie. base master
is at origin (0). is at origin (0)::
>>> from pprint import pprint >>> from pprint import pprint
>>> locations = [ \ >>> locations = [ \
{'wght':100}, \ {'wght':100}, \