[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:
parent
445108f735
commit
0f03e6529a
@ -11,43 +11,3 @@ This package also contains two modules for manipulating CFF format glyphs:
|
||||
|
||||
specializer
|
||||
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:
|
||||
|
@ -3,9 +3,3 @@ colorLib.builder: Build COLR/CPAL tables from scratch
|
||||
#####################################################
|
||||
|
||||
.. automodule:: fontTools.colorLib.builder
|
||||
:members: buildCPAL, buildCOLR, populateCOLRv0
|
||||
|
||||
.. autoclass:: fontTools.colorLib.builder.ColorPaletteType
|
||||
:inherited-members:
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
@ -32,7 +32,12 @@ needs_sphinx = "1.3"
|
||||
# ones.
|
||||
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.
|
||||
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,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# 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"
|
||||
|
||||
|
@ -95,7 +95,7 @@ Class Methods
|
||||
|
||||
|
||||
|
||||
|
||||
.. _source-descriptor-object:
|
||||
|
||||
SourceDescriptor object
|
||||
=======================
|
||||
@ -883,7 +883,7 @@ Attributes
|
||||
is not important for compiling variable fonts.
|
||||
|
||||
5.1.1 conditionset element
|
||||
=======================
|
||||
==========================
|
||||
|
||||
- Child element of ``rule``
|
||||
- Contains one or more ``condition`` elements.
|
||||
|
@ -1,3 +1,4 @@
|
||||
:orphan:
|
||||
.. _developerinfo:
|
||||
.. image:: ../../Icons/FontToolsIconGreenCircle.png
|
||||
:width: 200px
|
||||
|
@ -4,6 +4,3 @@ plistlib: Tools for handling .plist files
|
||||
|
||||
.. automodule:: fontTools.misc.plistlib
|
||||
:members: totree, fromtree, load, loads, dump, dumps
|
||||
|
||||
.. autoclass:: fontTools.misc.plistlib.Data
|
||||
:members:
|
||||
|
@ -1,3 +1,5 @@
|
||||
:orphan:
|
||||
|
||||
Optional Dependencies
|
||||
=====================
|
||||
|
||||
|
@ -11,16 +11,31 @@ lookups, coverage tables and so on.
|
||||
High-level OpenType Layout Lookup Builders
|
||||
------------------------------------------
|
||||
|
||||
.. automodule:: fontTools.otlLib.builder
|
||||
:members: AlternateSubstBuilder, ChainContextPosBuilder, ChainContextSubstBuilder, LigatureSubstBuilder, MultipleSubstBuilder, CursivePosBuilder, MarkBasePosBuilder, MarkLigPosBuilder, MarkMarkPosBuilder, ReverseChainSingleSubstBuilder, SingleSubstBuilder, ClassPairPosSubtableBuilder, PairPosBuilder, SinglePosBuilder
|
||||
:member-order: bysource
|
||||
.. currentmodule:: fontTools.otlLib.builder
|
||||
|
||||
.. 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
|
||||
--------------------------------------
|
||||
|
||||
.. automodule:: fontTools.otlLib.builder
|
||||
:members: buildCoverage, buildLookup
|
||||
.. currentmodule:: fontTools.otlLib.builder
|
||||
|
||||
.. autofunction:: buildCoverage
|
||||
.. autofunction:: buildLookup
|
||||
|
||||
------------------------------------
|
||||
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
|
||||
help build more complex lookups (contextual and chaining lookups).
|
||||
|
||||
.. automodule:: fontTools.otlLib.builder
|
||||
:members: buildSingleSubstSubtable, buildMultipleSubstSubtable, buildAlternateSubstSubtable, buildLigatureSubstSubtable
|
||||
.. currentmodule:: fontTools.otlLib.builder
|
||||
|
||||
.. autofunction:: buildSingleSubstSubtable
|
||||
.. autofunction:: buildMultipleSubstSubtable
|
||||
.. autofunction:: buildAlternateSubstSubtable
|
||||
.. autofunction:: buildLigatureSubstSubtable
|
||||
|
||||
--------------------------
|
||||
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
|
||||
mark record tables.
|
||||
|
||||
.. automodule:: fontTools.otlLib.builder
|
||||
:members: buildValue, buildAnchor, buildMarkArray, buildDevice, buildBaseArray, buildComponentRecord, buildMarkArray, buildValue
|
||||
:member-order: bysource
|
||||
.. currentmodule:: fontTools.otlLib.builder
|
||||
.. autofunction:: buildValue
|
||||
.. autofunction:: buildAnchor
|
||||
.. autofunction:: buildMarkArray
|
||||
.. autofunction:: buildDevice
|
||||
.. autofunction:: buildBaseArray
|
||||
.. autofunction:: buildComponentRecord
|
||||
|
||||
------------------------------------
|
||||
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
|
||||
help build more complex lookups (contextual and chaining lookups).
|
||||
|
||||
.. automodule:: fontTools.otlLib.builder
|
||||
:members: buildCursivePosSubtable, buildLigatureArray, buildMarkBasePos, buildMarkBasePosSubtable, buildMarkLigPos, buildMarkLigPosSubtable, buildPairPosClassesSubtable, buildPairPosGlyphs, buildPairPosGlyphsSubtable, buildSinglePos, buildSinglePosSubtable
|
||||
:member-order: bysource
|
||||
.. currentmodule:: fontTools.otlLib.builder
|
||||
|
||||
.. 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
|
||||
@ -61,14 +94,16 @@ GDEF Table Subtable Builders
|
||||
|
||||
These functions build subtables for elements of the ``GDEF`` table.
|
||||
|
||||
.. automodule:: fontTools.otlLib.builder
|
||||
:members: buildAttachList, buildLigCaretList, buildMarkGlyphSetsDef
|
||||
:member-order: bysource
|
||||
.. currentmodule:: fontTools.otlLib.builder
|
||||
|
||||
.. autofunction:: buildAttachList
|
||||
.. autofunction:: buildLigCaretList
|
||||
.. autofunction:: buildMarkGlyphSetsDef
|
||||
|
||||
------------------
|
||||
STAT Table Builder
|
||||
------------------
|
||||
|
||||
.. automodule:: fontTools.otlLib.builder
|
||||
:members: buildStatTable
|
||||
:member-order: bysource
|
||||
.. currentmodule:: fontTools.otlLib.builder
|
||||
|
||||
.. autofunction:: buildStatTable
|
||||
|
@ -11,6 +11,7 @@ BitmapGlyphMetrics
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. automodule:: fontTools.ttLib.tables.BitmapGlyphMetrics
|
||||
:noindex:
|
||||
:inherited-members:
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
@ -11,6 +11,7 @@ BitmapGlyphMetrics
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. automodule:: fontTools.ttLib.tables.BitmapGlyphMetrics
|
||||
:noindex:
|
||||
:inherited-members:
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
@ -11,6 +11,7 @@ TupleVariation
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
.. automodule:: fontTools.ttLib.tables.TupleVariation
|
||||
:noindex:
|
||||
:inherited-members:
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
@ -2,6 +2,25 @@
|
||||
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
|
||||
for handling, building and interpolating variable font data. These routines
|
||||
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.
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
builder
|
||||
cff
|
||||
errors
|
||||
featureVars
|
||||
instancer
|
||||
interpolatable
|
||||
interpolate_layout
|
||||
iup
|
||||
merger
|
||||
models
|
||||
mutator
|
||||
mvar
|
||||
plot
|
||||
varStore
|
||||
|
||||
.. automodule:: fontTools.varLib
|
||||
:inherited-members:
|
||||
:members:
|
||||
|
@ -3,38 +3,27 @@ voltLib
|
||||
#######
|
||||
|
||||
.. automodule:: fontTools.voltLib
|
||||
:inherited-members:
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
ast
|
||||
---
|
||||
|
||||
.. automodule:: fontTools.voltLib.ast
|
||||
:inherited-members:
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
error
|
||||
-----
|
||||
|
||||
.. automodule:: fontTools.voltLib.parser
|
||||
:inherited-members:
|
||||
:members:
|
||||
.. automodule:: fontTools.voltLib.error
|
||||
:undoc-members:
|
||||
|
||||
lexer
|
||||
-----
|
||||
|
||||
.. automodule:: fontTools.voltLib.lexer
|
||||
:inherited-members:
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
parser
|
||||
------
|
||||
|
||||
.. automodule:: fontTools.voltLib.parser
|
||||
:inherited-members:
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
@ -145,11 +145,11 @@ def populateCOLRv0(
|
||||
"""Build v0 color layers and add to existing COLR table.
|
||||
|
||||
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,
|
||||
color palette index) tuples. Can be empty.
|
||||
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:
|
||||
colorGlyphItems = sorted(
|
||||
@ -192,10 +192,12 @@ def buildCOLR(
|
||||
clipBoxes: Optional[Dict[str, _ClipBoxInput]] = None,
|
||||
) -> C_O_L_R_.table_C_O_L_R_:
|
||||
"""Build COLR table from color layers mapping.
|
||||
|
||||
Args:
|
||||
|
||||
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
|
||||
list of Paint for COLRv1.
|
||||
color palette index) tuples for COLRv0; or a single ``Paint`` (dict) or
|
||||
list of ``Paint`` for COLRv1.
|
||||
version: the version of COLR table. If None, the version is determined
|
||||
by the presence of COLRv1 paints or variation data (varStore), which
|
||||
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.
|
||||
clipBoxes: Optional map of base glyph name to clip box 4- or 5-tuples:
|
||||
(xMin, yMin, xMax, yMax) or (xMin, yMin, xMax, yMax, varIndexBase).
|
||||
Return:
|
||||
|
||||
Returns:
|
||||
A new COLR table.
|
||||
"""
|
||||
self = C_O_L_R_.table_C_O_L_R_()
|
||||
|
@ -160,18 +160,22 @@ class SourceDescriptor(SimpleDescriptor):
|
||||
|
||||
|
||||
class RuleDescriptor(SimpleDescriptor):
|
||||
"""<!-- optional: list of substitution rules -->
|
||||
<rules>
|
||||
<rule name="vertical.bars">
|
||||
<conditionset>
|
||||
<condition minimum="250.000000" maximum="750.000000" name="weight"/>
|
||||
<condition minimum="100" name="width"/>
|
||||
<condition minimum="10" maximum="40" name="optical"/>
|
||||
</conditionset>
|
||||
<sub name="cent" with="cent.alt"/>
|
||||
<sub name="dollar" with="dollar.alt"/>
|
||||
</rule>
|
||||
</rules>
|
||||
"""Represents the rule descriptor element
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<!-- optional: list of substitution rules -->
|
||||
<rules>
|
||||
<rule name="vertical.bars">
|
||||
<conditionset>
|
||||
<condition minimum="250.000000" maximum="750.000000" name="weight"/>
|
||||
<condition minimum="100" name="width"/>
|
||||
<condition minimum="10" maximum="40" name="optical"/>
|
||||
</conditionset>
|
||||
<sub name="cent" with="cent.alt"/>
|
||||
<sub name="dollar" with="dollar.alt"/>
|
||||
</rule>
|
||||
</rules>
|
||||
"""
|
||||
_attrs = ['name', 'conditionSets', 'subs'] # what do we need here
|
||||
|
||||
@ -996,7 +1000,10 @@ class BaseDocReader(LogMixin):
|
||||
|
||||
def readGlyphElement(self, glyphElement, instanceObject):
|
||||
"""
|
||||
Read the glyph element.
|
||||
Read the glyph element:
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<glyph name="b" unicode="0x62"/>
|
||||
<glyph name="b"/>
|
||||
<glyph name="b">
|
||||
|
@ -150,9 +150,9 @@ def strToFixed(string, precisionBits):
|
||||
|
||||
Examples::
|
||||
|
||||
>>> ## to convert a float string to a 2.14 fixed-point number:
|
||||
>>> strToFixed('-0.61884', precisionBits=14)
|
||||
-10139
|
||||
>>> ## to convert a float string to a 2.14 fixed-point number:
|
||||
>>> strToFixed('-0.61884', precisionBits=14)
|
||||
-10139
|
||||
"""
|
||||
value = float(string)
|
||||
return otRound(value * (1 << precisionBits))
|
||||
|
@ -10,12 +10,16 @@ used as dictionary keys.
|
||||
|
||||
This module exports the following symbols:
|
||||
|
||||
Transform -- this is the main class
|
||||
Identity -- Transform instance set to the identity transformation
|
||||
Offset -- Convenience function that returns a translating transformation
|
||||
Scale -- Convenience function that returns a scaling transformation
|
||||
Transform
|
||||
this is the main class
|
||||
Identity
|
||||
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.transformPoint((100, 100))
|
||||
@ -72,7 +76,8 @@ class Transform(NamedTuple):
|
||||
Transform instances are immutable: all transforming methods, eg.
|
||||
rotate(), return a new Transform instance.
|
||||
|
||||
Examples:
|
||||
:Example:
|
||||
|
||||
>>> t = Transform()
|
||||
>>> t
|
||||
<Transform [1 0 0 1 0 0]>
|
||||
@ -85,7 +90,8 @@ class Transform(NamedTuple):
|
||||
(200, 300)
|
||||
|
||||
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 0 0 1 0 0]>
|
||||
>>> Transform(dx=12)
|
||||
@ -93,7 +99,8 @@ class Transform(NamedTuple):
|
||||
>>> Transform(yx=12)
|
||||
<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)
|
||||
6
|
||||
>>> list(Identity)
|
||||
@ -101,13 +108,15 @@ class Transform(NamedTuple):
|
||||
>>> tuple(Identity)
|
||||
(1, 0, 0, 1, 0, 0)
|
||||
|
||||
Transform instances are comparable:
|
||||
Transform instances are comparable::
|
||||
|
||||
>>> t1 = Identity.scale(2, 3).translate(4, 6)
|
||||
>>> t2 = Identity.translate(8, 18).scale(2, 3)
|
||||
>>> t1 == t2
|
||||
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)
|
||||
>>> t2 = Identity.translate(0.08, 0.18).scale(0.2, 0.3)
|
||||
>>> t1
|
||||
@ -118,12 +127,14 @@ class Transform(NamedTuple):
|
||||
0
|
||||
|
||||
Transform instances are hashable, meaning you can use them as
|
||||
keys in dictionaries:
|
||||
keys in dictionaries::
|
||||
|
||||
>>> d = {Scale(12, 13): None}
|
||||
>>> d
|
||||
{<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)
|
||||
>>> t2 = Identity.translate(0.08, 0.18).scale(0.2, 0.3)
|
||||
>>> t1
|
||||
@ -149,7 +160,8 @@ class Transform(NamedTuple):
|
||||
def transformPoint(self, p):
|
||||
"""Transform a point.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
|
||||
>>> t = Transform()
|
||||
>>> t = t.scale(2.5, 5.5)
|
||||
>>> t.transformPoint((100, 100))
|
||||
@ -162,7 +174,8 @@ class Transform(NamedTuple):
|
||||
def transformPoints(self, points):
|
||||
"""Transform a list of points.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
|
||||
>>> t = Scale(2, 3)
|
||||
>>> t.transformPoints([(0, 0), (0, 100), (100, 100), (100, 0)])
|
||||
[(0, 0), (0, 300), (200, 300), (200, 0)]
|
||||
@ -174,7 +187,8 @@ class Transform(NamedTuple):
|
||||
def transformVector(self, v):
|
||||
"""Transform an (dx, dy) vector, treating translation as zero.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
|
||||
>>> t = Transform(2, 0, 0, 2, 10, 20)
|
||||
>>> t.transformVector((3, -4))
|
||||
(6, -8)
|
||||
@ -187,7 +201,7 @@ class Transform(NamedTuple):
|
||||
def transformVectors(self, vectors):
|
||||
"""Transform a list of (dx, dy) vector, treating translation as zero.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> t = Transform(2, 0, 0, 2, 10, 20)
|
||||
>>> t.transformVectors([(3, -4), (5, -6)])
|
||||
[(6, -8), (10, -12)]
|
||||
@ -199,7 +213,7 @@ class Transform(NamedTuple):
|
||||
def translate(self, x=0, y=0):
|
||||
"""Return a new transformation, translated (offset) by x, y.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> t = Transform()
|
||||
>>> t.translate(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
|
||||
may be None, which implies to use the x value for y as well.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> t = Transform()
|
||||
>>> t.scale(5)
|
||||
<Transform [5 0 0 5 0 0]>
|
||||
@ -226,7 +240,7 @@ class Transform(NamedTuple):
|
||||
def rotate(self, angle):
|
||||
"""Return a new transformation, rotated by 'angle' (radians).
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> import math
|
||||
>>> t = Transform()
|
||||
>>> t.rotate(math.pi / 2)
|
||||
@ -241,7 +255,7 @@ class Transform(NamedTuple):
|
||||
def skew(self, x=0, y=0):
|
||||
"""Return a new transformation, skewed by x and y.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> import math
|
||||
>>> t = Transform()
|
||||
>>> t.skew(math.pi / 4)
|
||||
@ -255,7 +269,7 @@ class Transform(NamedTuple):
|
||||
"""Return a new transformation, transformed by another
|
||||
transformation.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> t = Transform(2, 0, 0, 3, 1, 6)
|
||||
>>> t.transform((4, 3, 2, 1, 5, 6))
|
||||
<Transform [8 9 4 3 11 24]>
|
||||
@ -276,7 +290,7 @@ class Transform(NamedTuple):
|
||||
transformed by self. self.reverseTransform(other) is equivalent to
|
||||
other.transform(self).
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> t = Transform(2, 0, 0, 3, 1, 6)
|
||||
>>> t.reverseTransform((4, 3, 2, 1, 5, 6))
|
||||
<Transform [8 6 6 3 21 15]>
|
||||
@ -297,7 +311,7 @@ class Transform(NamedTuple):
|
||||
def inverse(self):
|
||||
"""Return the inverse transformation.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> t = Identity.translate(2, 3).scale(4, 5)
|
||||
>>> t.transformPoint((10, 20))
|
||||
(42, 103)
|
||||
@ -315,7 +329,10 @@ class Transform(NamedTuple):
|
||||
return self.__class__(xx, xy, yx, yy, dx, dy)
|
||||
|
||||
def toPS(self):
|
||||
"""Return a PostScript representation:
|
||||
"""Return a PostScript representation
|
||||
|
||||
:Example:
|
||||
|
||||
>>> t = Identity.scale(2, 3).translate(4, 5)
|
||||
>>> t.toPS()
|
||||
'[2 0 0 3 8 15]'
|
||||
@ -325,6 +342,9 @@ class Transform(NamedTuple):
|
||||
|
||||
def __bool__(self):
|
||||
"""Returns True if transform is not identity, False otherwise.
|
||||
|
||||
:Example:
|
||||
|
||||
>>> bool(Identity)
|
||||
False
|
||||
>>> bool(Transform())
|
||||
@ -351,7 +371,7 @@ Identity = Transform()
|
||||
def Offset(x=0, y=0):
|
||||
"""Return the identity transformation offset by x, y.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> Offset(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
|
||||
may be None, which implies to use the x value for y as well.
|
||||
|
||||
Example:
|
||||
:Example:
|
||||
>>> Scale(2, 3)
|
||||
<Transform [2 0 0 3 0 0]>
|
||||
>>>
|
||||
|
@ -24,7 +24,7 @@ log = logging.getLogger(__name__)
|
||||
def buildCoverage(glyphs, glyphMap):
|
||||
"""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
|
||||
define the glyphs involved in a layout subtable. This allows shaping engines
|
||||
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):
|
||||
"""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
|
||||
positioning) in a data structure expressing their overall lookup type -
|
||||
for example, single substitution, mark-to-base attachment, and so on -
|
||||
|
@ -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
|
||||
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'
|
||||
|
||||
@ -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
|
||||
for documentation purposes. Subclassing it basically tells the reader:
|
||||
"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
|
||||
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
|
||||
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
|
||||
BasePen subclasses are fontTools.pens.boundsPen.BoundsPen and
|
||||
fontTools.pens.cocoaPen.CocoaPen.
|
||||
@ -151,7 +151,7 @@ class NullPen(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
|
||||
|
||||
|
@ -14,10 +14,11 @@ class ControlBoundsPen(BasePen):
|
||||
on their extremes.
|
||||
|
||||
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).
|
||||
|
||||
If 'ignoreSinglePoints' is True, single points are ignored.
|
||||
If ``ignoreSinglePoints`` is True, single points are ignored.
|
||||
"""
|
||||
|
||||
def __init__(self, glyphSet, ignoreSinglePoints=False):
|
||||
@ -73,7 +74,8 @@ class BoundsPen(ControlBoundsPen):
|
||||
than the "control bounds".
|
||||
|
||||
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)
|
||||
"""
|
||||
|
||||
|
@ -23,13 +23,15 @@ class Cu2QuPen(AbstractPen):
|
||||
""" A filter pen to convert cubic bezier curves to quadratic b-splines
|
||||
using the FontTools SegmentPen protocol.
|
||||
|
||||
other_pen: another SegmentPen used to draw the transformed outline.
|
||||
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
|
||||
value equal, or close to UPEM / 1000.
|
||||
reverse_direction: flip the contours' direction but keep starting point.
|
||||
stats: a dictionary counting the point numbers of quadratic segments.
|
||||
ignore_single_points: don't emit contours containing only a single point
|
||||
Args:
|
||||
|
||||
other_pen: another SegmentPen used to draw the transformed outline.
|
||||
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
|
||||
value equal, or close to UPEM / 1000.
|
||||
reverse_direction: flip the contours' direction but keep starting point.
|
||||
stats: a dictionary counting the point numbers of quadratic segments.
|
||||
ignore_single_points: don't emit contours containing only a single point
|
||||
|
||||
NOTE: The "ignore_single_points" argument is deprecated since v1.3.0,
|
||||
which dropped Robofab subpport. It's no longer needed to special-case
|
||||
@ -138,12 +140,13 @@ class Cu2QuPointPen(BasePointToSegmentPen):
|
||||
""" A filter pen to convert cubic bezier curves to quadratic b-splines
|
||||
using the RoboFab PointPen protocol.
|
||||
|
||||
other_point_pen: another PointPen used to draw the transformed outline.
|
||||
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
|
||||
value equal, or close to UPEM / 1000.
|
||||
reverse_direction: reverse the winding direction of all contours.
|
||||
stats: a dictionary counting the point numbers of quadratic segments.
|
||||
Args:
|
||||
other_point_pen: another PointPen used to draw the transformed outline.
|
||||
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
|
||||
value equal, or close to UPEM / 1000.
|
||||
reverse_direction: reverse the winding direction of all contours.
|
||||
stats: a dictionary counting the point numbers of quadratic segments.
|
||||
"""
|
||||
|
||||
def __init__(self, other_point_pen, max_err, reverse_direction=False,
|
||||
|
@ -29,21 +29,21 @@ class RecordingPen(AbstractPen):
|
||||
The recording can be accessed as pen.value; or replayed using
|
||||
pen.replay(otherPen).
|
||||
|
||||
Usage example:
|
||||
==============
|
||||
from fontTools.ttLib import TTFont
|
||||
from fontTools.pens.recordingPen import RecordingPen
|
||||
:Example:
|
||||
|
||||
glyph_name = 'dollar'
|
||||
font_path = 'MyFont.otf'
|
||||
from fontTools.ttLib import TTFont
|
||||
from fontTools.pens.recordingPen import RecordingPen
|
||||
|
||||
font = TTFont(font_path)
|
||||
glyphset = font.getGlyphSet()
|
||||
glyph = glyphset[glyph_name]
|
||||
glyph_name = 'dollar'
|
||||
font_path = 'MyFont.otf'
|
||||
|
||||
pen = RecordingPen()
|
||||
glyph.draw(pen)
|
||||
print(pen.value)
|
||||
font = TTFont(font_path)
|
||||
glyphset = font.getGlyphSet()
|
||||
glyph = glyphset[glyph_name]
|
||||
|
||||
pen = RecordingPen()
|
||||
glyph.draw(pen)
|
||||
print(pen.value)
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@ -72,23 +72,23 @@ class DecomposingRecordingPen(DecomposingPen, RecordingPen):
|
||||
|
||||
The constructor takes a single 'glyphSet' positional argument,
|
||||
a dictionary of glyph objects (i.e. with a 'draw' method) keyed
|
||||
by thir name.
|
||||
by thir name::
|
||||
|
||||
>>> class SimpleGlyph(object):
|
||||
... def draw(self, pen):
|
||||
... pen.moveTo((0, 0))
|
||||
... pen.curveTo((1, 1), (2, 2), (3, 3))
|
||||
... pen.closePath()
|
||||
>>> class CompositeGlyph(object):
|
||||
... def draw(self, pen):
|
||||
... pen.addComponent('a', (1, 0, 0, 1, -1, 1))
|
||||
>>> glyphSet = {'a': SimpleGlyph(), 'b': CompositeGlyph()}
|
||||
>>> for name, glyph in sorted(glyphSet.items()):
|
||||
... pen = DecomposingRecordingPen(glyphSet)
|
||||
... glyph.draw(pen)
|
||||
... print("{}: {}".format(name, pen.value))
|
||||
a: [('moveTo', ((0, 0),)), ('curveTo', ((1, 1), (2, 2), (3, 3))), ('closePath', ())]
|
||||
b: [('moveTo', ((-1, 1),)), ('curveTo', ((0, 2), (1, 3), (2, 4))), ('closePath', ())]
|
||||
>>> class SimpleGlyph(object):
|
||||
... def draw(self, pen):
|
||||
... pen.moveTo((0, 0))
|
||||
... pen.curveTo((1, 1), (2, 2), (3, 3))
|
||||
... pen.closePath()
|
||||
>>> class CompositeGlyph(object):
|
||||
... def draw(self, pen):
|
||||
... pen.addComponent('a', (1, 0, 0, 1, -1, 1))
|
||||
>>> glyphSet = {'a': SimpleGlyph(), 'b': CompositeGlyph()}
|
||||
>>> for name, glyph in sorted(glyphSet.items()):
|
||||
... pen = DecomposingRecordingPen(glyphSet)
|
||||
... glyph.draw(pen)
|
||||
... print("{}: {}".format(name, pen.value))
|
||||
a: [('moveTo', ((0, 0),)), ('curveTo', ((1, 1), (2, 2), (3, 3))), ('closePath', ())]
|
||||
b: [('moveTo', ((-1, 1),)), ('curveTo', ((0, 2), (1, 3), (2, 4))), ('closePath', ())]
|
||||
"""
|
||||
# raises KeyError if base glyph is not found in glyphSet
|
||||
skipMissingComponents = False
|
||||
@ -100,23 +100,23 @@ class RecordingPointPen(AbstractPointPen):
|
||||
The recording can be accessed as pen.value; or replayed using
|
||||
pointPen.replay(otherPointPen).
|
||||
|
||||
Usage example:
|
||||
==============
|
||||
from defcon import Font
|
||||
from fontTools.pens.recordingPen import RecordingPointPen
|
||||
:Example:
|
||||
|
||||
glyph_name = 'a'
|
||||
font_path = 'MyFont.ufo'
|
||||
from defcon import Font
|
||||
from fontTools.pens.recordingPen import RecordingPointPen
|
||||
|
||||
font = Font(font_path)
|
||||
glyph = font[glyph_name]
|
||||
glyph_name = 'a'
|
||||
font_path = 'MyFont.ufo'
|
||||
|
||||
pen = RecordingPointPen()
|
||||
glyph.drawPoints(pen)
|
||||
print(pen.value)
|
||||
font = Font(font_path)
|
||||
glyph = font[glyph_name]
|
||||
|
||||
new_glyph = font.newGlyph('b')
|
||||
pen.replay(new_glyph.getPointPen())
|
||||
pen = RecordingPointPen()
|
||||
glyph.drawPoints(pen)
|
||||
print(pen.value)
|
||||
|
||||
new_glyph = font.newGlyph('b')
|
||||
pen.replay(new_glyph.getPointPen())
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
@ -7,7 +7,7 @@ __all__ = ["ReportLabPen"]
|
||||
|
||||
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):
|
||||
BasePen.__init__(self, glyphSet)
|
||||
|
@ -24,82 +24,100 @@ __usage__ = "pyftsubset font-file [glyph...] [--option=value]..."
|
||||
__doc__="""\
|
||||
pyftsubset -- OpenType font subsetter and optimizer
|
||||
|
||||
pyftsubset is an OpenType font subsetter and optimizer, based on fontTools.
|
||||
It accepts any TT- or CFF-flavored OpenType (.otf or .ttf) or WOFF (.woff)
|
||||
font file. The subsetted glyph set is based on the specified glyphs
|
||||
or characters, and specified OpenType layout features.
|
||||
pyftsubset is an OpenType font subsetter and optimizer, based on fontTools.
|
||||
It accepts any TT- or CFF-flavored OpenType (.otf or .ttf) or WOFF (.woff)
|
||||
font file. The subsetted glyph set is based on the specified glyphs
|
||||
or characters, and specified OpenType layout features.
|
||||
|
||||
The tool also performs some size-reducing optimizations, aimed for using
|
||||
subset fonts as webfonts. Individual optimizations can be enabled or
|
||||
disabled, and are enabled by default when they are safe.
|
||||
The tool also performs some size-reducing optimizations, aimed for using
|
||||
subset fonts as webfonts. Individual optimizations can be enabled or
|
||||
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,
|
||||
--text, --text-file, --unicodes, or --unicodes-file, must be specified.
|
||||
At least one glyph or one of --gids, --gids-file, --glyphs, --glyphs-file,
|
||||
--text, --text-file, --unicodes, or --unicodes-file, must be specified.
|
||||
|
||||
Arguments:
|
||||
font-file
|
||||
The input font file.
|
||||
glyph
|
||||
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.
|
||||
Args:
|
||||
|
||||
Initial glyph set specification:
|
||||
These options populate the initial glyph set. Same option can appear
|
||||
multiple times, and the results are accummulated.
|
||||
--gids=<NNN>[,<NNN>...]
|
||||
Specify comma/whitespace-separated list of glyph IDs or ranges as
|
||||
decimal numbers. For example, --gids=10-12,14 adds glyphs with
|
||||
numbers 10, 11, 12, and 14.
|
||||
--gids-file=<path>
|
||||
Like --gids but reads from a file. Anything after a '#' on any line
|
||||
is ignored as comments.
|
||||
--glyphs=<glyphname>[,<glyphname>...]
|
||||
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
|
||||
that are accepted on the command line. The special string '*' will keep
|
||||
the entire glyph set.
|
||||
--glyphs-file=<path>
|
||||
Like --glyphs but reads from a file. Anything after a '#' on any line
|
||||
is ignored as comments.
|
||||
--text=<text>
|
||||
Specify characters to include in the subset, as UTF-8 string.
|
||||
--text-file=<path>
|
||||
Like --text but reads from a file. Newline character are not added to
|
||||
the subset.
|
||||
--unicodes=<XXXX>[,<XXXX>...]
|
||||
Specify comma/whitespace-separated list of Unicode codepoints or
|
||||
ranges as hex numbers, optionally prefixed with 'U+', 'u', etc.
|
||||
For example, --unicodes=41-5a,61-7a adds ASCII letters, so does
|
||||
the more verbose --unicodes=U+0041-005A,U+0061-007A.
|
||||
The special strings '*' will choose all Unicode characters mapped
|
||||
by the font.
|
||||
--unicodes-file=<path>
|
||||
Like --unicodes, but reads from a file. Anything after a '#' on any
|
||||
line in the file is ignored as comments.
|
||||
--ignore-missing-glyphs
|
||||
Do not fail if some requested glyphs or gids are not available in
|
||||
the font.
|
||||
--no-ignore-missing-glyphs
|
||||
Stop and fail if some requested glyphs or gids are not available
|
||||
in the font. [default]
|
||||
--ignore-missing-unicodes [default]
|
||||
Do not fail if some requested Unicode characters (including those
|
||||
indirectly specified using --text or --text-file) are not available
|
||||
in the font.
|
||||
--no-ignore-missing-unicodes
|
||||
Stop and fail if some requested Unicode characters are not available
|
||||
in the font.
|
||||
Note the default discrepancy between ignoring missing glyphs versus
|
||||
unicodes. This is for historical reasons and in the future
|
||||
--no-ignore-missing-unicodes might become default.
|
||||
font-file
|
||||
The input font file.
|
||||
glyph
|
||||
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.
|
||||
|
||||
Initial glyph set specification
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
These options populate the initial glyph set. Same option can appear
|
||||
multiple times, and the results are accummulated.
|
||||
|
||||
--gids=<NNN>[,<NNN>...]
|
||||
Specify comma/whitespace-separated list of glyph IDs or ranges as decimal
|
||||
numbers. For example, --gids=10-12,14 adds glyphs with numbers 10, 11,
|
||||
12, and 14.
|
||||
|
||||
--gids-file=<path>
|
||||
Like --gids but reads from a file. Anything after a '#' on any line is
|
||||
ignored as comments.
|
||||
|
||||
--glyphs=<glyphname>[,<glyphname>...]
|
||||
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
|
||||
that are accepted on the command line. The special string '*' will keep
|
||||
the entire glyph set.
|
||||
|
||||
--glyphs-file=<path>
|
||||
Like --glyphs but reads from a file. Anything after a '#' on any line
|
||||
is ignored as comments.
|
||||
|
||||
--text=<text>
|
||||
Specify characters to include in the subset, as UTF-8 string.
|
||||
|
||||
--text-file=<path>
|
||||
Like --text but reads from a file. Newline character are not added to
|
||||
the subset.
|
||||
|
||||
--unicodes=<XXXX>[,<XXXX>...]
|
||||
Specify comma/whitespace-separated list of Unicode codepoints or
|
||||
ranges as hex numbers, optionally prefixed with 'U+', 'u', etc.
|
||||
For example, --unicodes=41-5a,61-7a adds ASCII letters, so does
|
||||
the more verbose --unicodes=U+0041-005A,U+0061-007A.
|
||||
The special strings '*' will choose all Unicode characters mapped
|
||||
by the font.
|
||||
|
||||
--unicodes-file=<path>
|
||||
Like --unicodes, but reads from a file. Anything after a '#' on any
|
||||
line in the file is ignored as comments.
|
||||
|
||||
--ignore-missing-glyphs
|
||||
Do not fail if some requested glyphs or gids are not available in
|
||||
the font.
|
||||
|
||||
--no-ignore-missing-glyphs
|
||||
Stop and fail if some requested glyphs or gids are not available
|
||||
in the font. [default]
|
||||
|
||||
--ignore-missing-unicodes [default]
|
||||
Do not fail if some requested Unicode characters (including those
|
||||
indirectly specified using --text or --text-file) are not available
|
||||
in the font.
|
||||
|
||||
--no-ignore-missing-unicodes
|
||||
Stop and fail if some requested Unicode characters are not available
|
||||
in the font.
|
||||
Note the default discrepancy between ignoring missing glyphs versus
|
||||
unicodes. This is for historical reasons and in the future
|
||||
--no-ignore-missing-unicodes might become default.
|
||||
|
||||
Other options
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
For the other options listed below, to see the current value of the option,
|
||||
pass a value of '?' to it, with or without a '='.
|
||||
|
||||
Examples::
|
||||
|
||||
Other options:
|
||||
For the other options listed below, to see the current value of the option,
|
||||
pass a value of '?' to it, with or without a '='.
|
||||
Examples:
|
||||
$ pyftsubset --glyph-names?
|
||||
Current setting for 'glyph-names' is: False
|
||||
$ ./pyftsubset --name-IDs=?
|
||||
@ -108,242 +126,299 @@ Other options:
|
||||
Current setting for 'hinting' is: True
|
||||
Current setting for 'hinting' is: False
|
||||
|
||||
Output options:
|
||||
--output-file=<path>
|
||||
The output font file. If not specified, the subsetted font
|
||||
will be saved in as font-file.subset.
|
||||
--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
|
||||
--with-zopfli
|
||||
Use the Google Zopfli algorithm to compress WOFF. The output is 3-8 %
|
||||
smaller than pure zlib, but the compression speed is much slower.
|
||||
The Zopfli Python bindings are available at:
|
||||
https://pypi.python.org/pypi/zopfli
|
||||
Output options
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
Glyph set expansion:
|
||||
These options control how additional glyphs are added to the subset.
|
||||
--retain-gids
|
||||
Retain glyph indices; just empty glyphs not needed in-place.
|
||||
--notdef-glyph
|
||||
Add the '.notdef' glyph to the subset (ie, keep it). [default]
|
||||
--no-notdef-glyph
|
||||
Drop the '.notdef' glyph unless specified in the glyph set. This
|
||||
saves a few bytes, but is not possible for Postscript-flavored
|
||||
fonts, as those require '.notdef'. For TrueType-flavored fonts,
|
||||
this works fine as long as no unsupported glyphs are requested
|
||||
from the font.
|
||||
--notdef-outline
|
||||
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
|
||||
needed otherwise.
|
||||
--no-notdef-outline
|
||||
When including a '.notdef' glyph, remove its outline. This saves
|
||||
a few bytes. [default]
|
||||
--recommended-glyphs
|
||||
Add glyphs 0, 1, 2, and 3 to the subset, as recommended for
|
||||
TrueType-flavored fonts: '.notdef', 'NULL' or '.null', 'CR', 'space'.
|
||||
Some legacy software might require this, but no modern system does.
|
||||
--no-recommended-glyphs
|
||||
Do not add glyphs 0, 1, 2, and 3 to the subset, unless specified in
|
||||
glyph set. [default]
|
||||
--no-layout-closure
|
||||
Do not expand glyph set to add glyphs produced by OpenType layout
|
||||
features. Instead, OpenType layout features will be subset to only
|
||||
rules that are relevant to the otherwise-specified glyph set.
|
||||
--layout-features[+|-]=<feature>[,<feature>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the comma-separated
|
||||
set of OpenType layout feature tags that will be preserved.
|
||||
Glyph variants used by the preserved features are added to the
|
||||
specified subset glyph set. By default, 'calt', 'ccmp', 'clig', 'curs',
|
||||
'dnom', 'frac', 'kern', 'liga', 'locl', 'mark', 'mkmk', 'numr', 'rclt',
|
||||
'rlig', 'rvrn', and all features required for script shaping are
|
||||
preserved. To see the full list, try '--layout-features=?'.
|
||||
Use '*' to keep all features.
|
||||
Multiple --layout-features options can be provided if necessary.
|
||||
Examples:
|
||||
--layout-features+=onum,pnum,ss01
|
||||
* Keep the default set of features and 'onum', 'pnum', 'ss01'.
|
||||
--layout-features-='mark','mkmk'
|
||||
* Keep the default set of features but drop 'mark' and 'mkmk'.
|
||||
--layout-features='kern'
|
||||
* Only keep the 'kern' feature, drop all others.
|
||||
--layout-features=''
|
||||
* Drop all features.
|
||||
--layout-features='*'
|
||||
* Keep all features.
|
||||
--layout-features+=aalt --layout-features-=vrt2
|
||||
* Keep default set of features plus 'aalt', but drop 'vrt2'.
|
||||
--layout-scripts[+|-]=<script>[,<script>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the comma-separated
|
||||
set of OpenType layout script tags that will be preserved. LangSys tags
|
||||
can be appended to script tag, separated by '.', for example:
|
||||
'arab.dflt,arab.URD,latn.TRK'. By default all scripts are retained ('*').
|
||||
--output-file=<path>
|
||||
The output font file. If not specified, the subsetted font
|
||||
will be saved in as font-file.subset.
|
||||
|
||||
Hinting options:
|
||||
--hinting
|
||||
Keep hinting [default]
|
||||
--no-hinting
|
||||
Drop glyph-specific hinting and font-wide hinting tables, as well
|
||||
as remove hinting-related bits and pieces from other tables (eg. GPOS).
|
||||
See --hinting-tables for list of tables that are dropped by default.
|
||||
Instructions and hints are stripped from 'glyf' and 'CFF ' tables
|
||||
respectively. This produces (sometimes up to 30%) smaller fonts that
|
||||
are suitable for extremely high-resolution systems, like high-end
|
||||
mobile devices and retina displays.
|
||||
--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
|
||||
|
||||
Optimization options:
|
||||
--desubroutinize
|
||||
Remove CFF use of subroutinizes. Subroutinization is a way to make CFF
|
||||
fonts smaller. For small subsets however, desubroutinizing might make
|
||||
the font smaller. It has even been reported that desubroutinized CFF
|
||||
fonts compress better (produce smaller output) WOFF and WOFF2 fonts.
|
||||
Also see note under --no-hinting.
|
||||
--no-desubroutinize [default]
|
||||
Leave CFF subroutinizes as is, only throw away unused subroutinizes.
|
||||
--with-zopfli
|
||||
Use the Google Zopfli algorithm to compress WOFF. The output is 3-8 %
|
||||
smaller than pure zlib, but the compression speed is much slower.
|
||||
The Zopfli Python bindings are available at:
|
||||
https://pypi.python.org/pypi/zopfli
|
||||
|
||||
Font table options:
|
||||
--drop-tables[+|-]=<table>[,<table>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the comma-separated
|
||||
set of tables that will be be dropped.
|
||||
By default, the following tables are dropped:
|
||||
'BASE', 'JSTF', 'DSIG', 'EBDT', 'EBLC', 'EBSC', 'PCLT', 'LTSH'
|
||||
and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill'.
|
||||
The tool will attempt to subset the remaining tables.
|
||||
Examples:
|
||||
--drop-tables-='BASE'
|
||||
* Drop the default set of tables but keep 'BASE'.
|
||||
--drop-tables+=GSUB
|
||||
* Drop the default set of tables and 'GSUB'.
|
||||
--drop-tables=DSIG
|
||||
* Only drop the 'DSIG' table, keep all others.
|
||||
--drop-tables=
|
||||
* Keep all tables.
|
||||
--no-subset-tables+=<table>[,<table>...]
|
||||
Add to the set of tables that will not be subsetted.
|
||||
By default, the following tables are included in this list, as
|
||||
they do not need subsetting (ignore the fact that 'loca' is listed
|
||||
here): 'gasp', 'head', 'hhea', 'maxp', 'vhea', 'OS/2', 'loca', 'name',
|
||||
'cvt ', 'fpgm', 'prep', 'VMDX', 'DSIG', 'CPAL', 'MVAR', 'cvar', 'STAT'.
|
||||
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
|
||||
option is passed.
|
||||
Example:
|
||||
--no-subset-tables+=FFTM
|
||||
* Keep 'FFTM' table in the font by preventing subsetting.
|
||||
--passthrough-tables
|
||||
Do not drop tables that the tool does not know how to subset.
|
||||
--no-passthrough-tables
|
||||
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]
|
||||
--hinting-tables[-]=<table>[,<table>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the list of font-wide
|
||||
hinting tables that will be dropped if --no-hinting is specified,
|
||||
Examples:
|
||||
--hinting-tables-='VDMX'
|
||||
* Drop font-wide hinting tables except 'VDMX'.
|
||||
--hinting-tables=''
|
||||
* Keep all font-wide hinting tables (but strip hints from glyphs).
|
||||
--legacy-kern
|
||||
Keep TrueType 'kern' table even when OpenType 'GPOS' is available.
|
||||
--no-legacy-kern
|
||||
Drop TrueType 'kern' table if OpenType 'GPOS' is available. [default]
|
||||
Glyph set expansion
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Font naming options:
|
||||
These options control what is retained in the 'name' table. For numerical
|
||||
codes, see: http://www.microsoft.com/typography/otspec/name.htm
|
||||
--name-IDs[+|-]=<nameID>[,<nameID>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
|
||||
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.
|
||||
Examples:
|
||||
--name-IDs+=7,8,9
|
||||
* Also keep Trademark, Manufacturer and Designer name entries.
|
||||
--name-IDs=''
|
||||
* Drop all 'name' table entries.
|
||||
--name-IDs='*'
|
||||
* keep all 'name' table entries
|
||||
--name-legacy
|
||||
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
|
||||
entires for English. See: https://github.com/fonttools/fonttools/issues/146
|
||||
--no-name-legacy
|
||||
Drop legacy (non-Unicode) 'name' table entries [default]
|
||||
--name-languages[+|-]=<langID>[,<langID>]
|
||||
Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
|
||||
langIDs that will be preserved. By default only records with langID
|
||||
0x0409 (English) are preserved. Use '*' to keep all langIDs.
|
||||
--obfuscate-names
|
||||
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).
|
||||
These options control how additional glyphs are added to the subset.
|
||||
|
||||
Glyph naming and encoding options:
|
||||
--glyph-names
|
||||
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
|
||||
and PDF viewers might rely on glyph names to extract Unicode text
|
||||
from PDF documents.
|
||||
--no-glyph-names
|
||||
Drop PS glyph names in TT-flavored fonts, by using 'post' table
|
||||
version 3.0. [default]
|
||||
--legacy-cmap
|
||||
Keep the legacy 'cmap' subtables (0.x, 1.x, 4.x etc.).
|
||||
--no-legacy-cmap
|
||||
Drop the legacy 'cmap' subtables. [default]
|
||||
--symbol-cmap
|
||||
Keep the 3.0 symbol 'cmap'.
|
||||
--no-symbol-cmap
|
||||
Drop the 3.0 symbol 'cmap'. [default]
|
||||
--retain-gids
|
||||
Retain glyph indices; just empty glyphs not needed in-place.
|
||||
|
||||
Other font-specific options:
|
||||
--recalc-bounds
|
||||
Recalculate font bounding boxes.
|
||||
--no-recalc-bounds
|
||||
Keep original font bounding boxes. This is faster and still safe
|
||||
for all practical purposes. [default]
|
||||
--recalc-timestamp
|
||||
Set font 'modified' timestamp to current time.
|
||||
--no-recalc-timestamp
|
||||
Do not modify font 'modified' timestamp. [default]
|
||||
--canonical-order
|
||||
Order tables as recommended in the OpenType standard. This is not
|
||||
required by the standard, nor by any known implementation.
|
||||
--no-canonical-order
|
||||
Keep original order of font tables. This is faster. [default]
|
||||
--prune-unicode-ranges
|
||||
Update the 'OS/2 ulUnicodeRange*' bits after subsetting. The Unicode
|
||||
ranges defined in the OpenType specification v1.7 are intersected with
|
||||
the Unicode codepoints specified in the font's Unicode 'cmap' subtables:
|
||||
when no overlap is found, the bit will be switched off. However, it will
|
||||
*not* be switched on if an intersection is found. [default]
|
||||
--no-prune-unicode-ranges
|
||||
Don't change the 'OS/2 ulUnicodeRange*' bits.
|
||||
--recalc-average-width
|
||||
Update the 'OS/2 xAvgCharWidth' field after subsetting.
|
||||
--no-recalc-average-width
|
||||
Don't change the 'OS/2 xAvgCharWidth' field. [default]
|
||||
--recalc-max-context
|
||||
Update the 'OS/2 usMaxContext' field after subsetting.
|
||||
--no-recalc-max-context
|
||||
Don't change the 'OS/2 usMaxContext' field. [default]
|
||||
--font-number=<number>
|
||||
Select font number for TrueType Collection (.ttc/.otc), starting from 0.
|
||||
--pretty-svg
|
||||
When subsetting SVG table, use lxml pretty_print=True option to indent
|
||||
the XML output (only recommended for debugging purposes).
|
||||
--notdef-glyph
|
||||
Add the '.notdef' glyph to the subset (ie, keep it). [default]
|
||||
|
||||
Application options:
|
||||
--verbose
|
||||
Display verbose information of the subsetting process.
|
||||
--timing
|
||||
Display detailed timing information of the subsetting process.
|
||||
--xml
|
||||
Display the TTX XML representation of subsetted font.
|
||||
--no-notdef-glyph
|
||||
Drop the '.notdef' glyph unless specified in the glyph set. This
|
||||
saves a few bytes, but is not possible for Postscript-flavored
|
||||
fonts, as those require '.notdef'. For TrueType-flavored fonts,
|
||||
this works fine as long as no unsupported glyphs are requested
|
||||
from the font.
|
||||
|
||||
Example:
|
||||
Produce a subset containing the characters ' !"#$%' without performing
|
||||
size-reducing optimizations:
|
||||
--notdef-outline
|
||||
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
|
||||
needed otherwise.
|
||||
|
||||
--no-notdef-outline
|
||||
When including a '.notdef' glyph, remove its outline. This saves
|
||||
a few bytes. [default]
|
||||
|
||||
--recommended-glyphs
|
||||
Add glyphs 0, 1, 2, and 3 to the subset, as recommended for
|
||||
TrueType-flavored fonts: '.notdef', 'NULL' or '.null', 'CR', 'space'.
|
||||
Some legacy software might require this, but no modern system does.
|
||||
|
||||
--no-recommended-glyphs
|
||||
Do not add glyphs 0, 1, 2, and 3 to the subset, unless specified in
|
||||
glyph set. [default]
|
||||
|
||||
--no-layout-closure
|
||||
Do not expand glyph set to add glyphs produced by OpenType layout
|
||||
features. Instead, OpenType layout features will be subset to only
|
||||
rules that are relevant to the otherwise-specified glyph set.
|
||||
|
||||
--layout-features[+|-]=<feature>[,<feature>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the comma-separated
|
||||
set of OpenType layout feature tags that will be preserved.
|
||||
Glyph variants used by the preserved features are added to the
|
||||
specified subset glyph set. By default, 'calt', 'ccmp', 'clig', 'curs',
|
||||
'dnom', 'frac', 'kern', 'liga', 'locl', 'mark', 'mkmk', 'numr', 'rclt',
|
||||
'rlig', 'rvrn', and all features required for script shaping are
|
||||
preserved. To see the full list, try '--layout-features=?'.
|
||||
Use '*' to keep all features.
|
||||
Multiple --layout-features options can be provided if necessary.
|
||||
Examples:
|
||||
|
||||
--layout-features+=onum,pnum,ss01
|
||||
* Keep the default set of features and 'onum', 'pnum', 'ss01'.
|
||||
--layout-features-='mark','mkmk'
|
||||
* Keep the default set of features but drop 'mark' and 'mkmk'.
|
||||
--layout-features='kern'
|
||||
* Only keep the 'kern' feature, drop all others.
|
||||
--layout-features=''
|
||||
* Drop all features.
|
||||
--layout-features='*'
|
||||
* Keep all features.
|
||||
--layout-features+=aalt --layout-features-=vrt2
|
||||
* Keep default set of features plus 'aalt', but drop 'vrt2'.
|
||||
|
||||
--layout-scripts[+|-]=<script>[,<script>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the comma-separated
|
||||
set of OpenType layout script tags that will be preserved. LangSys tags
|
||||
can be appended to script tag, separated by '.', for example:
|
||||
'arab.dflt,arab.URD,latn.TRK'. By default all scripts are retained ('*').
|
||||
|
||||
Hinting options
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
--hinting
|
||||
Keep hinting [default]
|
||||
|
||||
--no-hinting
|
||||
Drop glyph-specific hinting and font-wide hinting tables, as well
|
||||
as remove hinting-related bits and pieces from other tables (eg. GPOS).
|
||||
See --hinting-tables for list of tables that are dropped by default.
|
||||
Instructions and hints are stripped from 'glyf' and 'CFF ' tables
|
||||
respectively. This produces (sometimes up to 30%) smaller fonts that
|
||||
are suitable for extremely high-resolution systems, like high-end
|
||||
mobile devices and retina displays.
|
||||
|
||||
Optimization options
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
--desubroutinize
|
||||
Remove CFF use of subroutinizes. Subroutinization is a way to make CFF
|
||||
fonts smaller. For small subsets however, desubroutinizing might make
|
||||
the font smaller. It has even been reported that desubroutinized CFF
|
||||
fonts compress better (produce smaller output) WOFF and WOFF2 fonts.
|
||||
Also see note under --no-hinting.
|
||||
|
||||
--no-desubroutinize [default]
|
||||
Leave CFF subroutinizes as is, only throw away unused subroutinizes.
|
||||
|
||||
Font table options
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
--drop-tables[+|-]=<table>[,<table>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the comma-separated
|
||||
set of tables that will be be dropped.
|
||||
By default, the following tables are dropped:
|
||||
'BASE', 'JSTF', 'DSIG', 'EBDT', 'EBLC', 'EBSC', 'PCLT', 'LTSH'
|
||||
and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill'.
|
||||
The tool will attempt to subset the remaining tables.
|
||||
|
||||
Examples:
|
||||
|
||||
--drop-tables-='BASE'
|
||||
* Drop the default set of tables but keep 'BASE'.
|
||||
|
||||
--drop-tables+=GSUB
|
||||
* Drop the default set of tables and 'GSUB'.
|
||||
|
||||
--drop-tables=DSIG
|
||||
* Only drop the 'DSIG' table, keep all others.
|
||||
|
||||
--drop-tables=
|
||||
* Keep all tables.
|
||||
|
||||
--no-subset-tables+=<table>[,<table>...]
|
||||
Add to the set of tables that will not be subsetted.
|
||||
By default, the following tables are included in this list, as
|
||||
they do not need subsetting (ignore the fact that 'loca' is listed
|
||||
here): 'gasp', 'head', 'hhea', 'maxp', 'vhea', 'OS/2', 'loca', 'name',
|
||||
'cvt ', 'fpgm', 'prep', 'VMDX', 'DSIG', 'CPAL', 'MVAR', 'cvar', 'STAT'.
|
||||
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
|
||||
option is passed.
|
||||
|
||||
Example:
|
||||
|
||||
--no-subset-tables+=FFTM
|
||||
* Keep 'FFTM' table in the font by preventing subsetting.
|
||||
|
||||
--passthrough-tables
|
||||
Do not drop tables that the tool does not know how to subset.
|
||||
|
||||
--no-passthrough-tables
|
||||
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]
|
||||
|
||||
--hinting-tables[-]=<table>[,<table>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the list of font-wide
|
||||
hinting tables that will be dropped if --no-hinting is specified.
|
||||
|
||||
Examples:
|
||||
|
||||
--hinting-tables-='VDMX'
|
||||
* Drop font-wide hinting tables except 'VDMX'.
|
||||
--hinting-tables=''
|
||||
* Keep all font-wide hinting tables (but strip hints from glyphs).
|
||||
|
||||
--legacy-kern
|
||||
Keep TrueType 'kern' table even when OpenType 'GPOS' is available.
|
||||
|
||||
--no-legacy-kern
|
||||
Drop TrueType 'kern' table if OpenType 'GPOS' is available. [default]
|
||||
|
||||
Font naming options
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
These options control what is retained in the 'name' table. For numerical
|
||||
codes, see: http://www.microsoft.com/typography/otspec/name.htm
|
||||
|
||||
--name-IDs[+|-]=<nameID>[,<nameID>...]
|
||||
Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
|
||||
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.
|
||||
|
||||
Examples:
|
||||
|
||||
--name-IDs+=7,8,9
|
||||
* Also keep Trademark, Manufacturer and Designer name entries.
|
||||
--name-IDs=''
|
||||
* Drop all 'name' table entries.
|
||||
--name-IDs='*'
|
||||
* keep all 'name' table entries
|
||||
|
||||
--name-legacy
|
||||
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
|
||||
entires for English. See: https://github.com/fonttools/fonttools/issues/146
|
||||
|
||||
--no-name-legacy
|
||||
Drop legacy (non-Unicode) 'name' table entries [default]
|
||||
|
||||
--name-languages[+|-]=<langID>[,<langID>]
|
||||
Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
|
||||
langIDs that will be preserved. By default only records with langID
|
||||
0x0409 (English) are preserved. Use '*' to keep all langIDs.
|
||||
|
||||
--obfuscate-names
|
||||
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).
|
||||
|
||||
Glyph naming and encoding options
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
--glyph-names
|
||||
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
|
||||
and PDF viewers might rely on glyph names to extract Unicode text
|
||||
from PDF documents.
|
||||
--no-glyph-names
|
||||
Drop PS glyph names in TT-flavored fonts, by using 'post' table
|
||||
version 3.0. [default]
|
||||
--legacy-cmap
|
||||
Keep the legacy 'cmap' subtables (0.x, 1.x, 4.x etc.).
|
||||
--no-legacy-cmap
|
||||
Drop the legacy 'cmap' subtables. [default]
|
||||
--symbol-cmap
|
||||
Keep the 3.0 symbol 'cmap'.
|
||||
--no-symbol-cmap
|
||||
Drop the 3.0 symbol 'cmap'. [default]
|
||||
|
||||
Other font-specific options
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
--recalc-bounds
|
||||
Recalculate font bounding boxes.
|
||||
--no-recalc-bounds
|
||||
Keep original font bounding boxes. This is faster and still safe
|
||||
for all practical purposes. [default]
|
||||
--recalc-timestamp
|
||||
Set font 'modified' timestamp to current time.
|
||||
--no-recalc-timestamp
|
||||
Do not modify font 'modified' timestamp. [default]
|
||||
--canonical-order
|
||||
Order tables as recommended in the OpenType standard. This is not
|
||||
required by the standard, nor by any known implementation.
|
||||
--no-canonical-order
|
||||
Keep original order of font tables. This is faster. [default]
|
||||
--prune-unicode-ranges
|
||||
Update the 'OS/2 ulUnicodeRange*' bits after subsetting. The Unicode
|
||||
ranges defined in the OpenType specification v1.7 are intersected with
|
||||
the Unicode codepoints specified in the font's Unicode 'cmap' subtables:
|
||||
when no overlap is found, the bit will be switched off. However, it will
|
||||
*not* be switched on if an intersection is found. [default]
|
||||
--no-prune-unicode-ranges
|
||||
Don't change the 'OS/2 ulUnicodeRange*' bits.
|
||||
--recalc-average-width
|
||||
Update the 'OS/2 xAvgCharWidth' field after subsetting.
|
||||
--no-recalc-average-width
|
||||
Don't change the 'OS/2 xAvgCharWidth' field. [default]
|
||||
--recalc-max-context
|
||||
Update the 'OS/2 usMaxContext' field after subsetting.
|
||||
--no-recalc-max-context
|
||||
Don't change the 'OS/2 usMaxContext' field. [default]
|
||||
--font-number=<number>
|
||||
Select font number for TrueType Collection (.ttc/.otc), starting from 0.
|
||||
--pretty-svg
|
||||
When subsetting SVG table, use lxml pretty_print=True option to indent
|
||||
the XML output (only recommended for debugging purposes).
|
||||
|
||||
Application options
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
--verbose
|
||||
Display verbose information of the subsetting process.
|
||||
--timing
|
||||
Display detailed timing information of the subsetting process.
|
||||
--xml
|
||||
Display the TTX XML representation of subsetted font.
|
||||
|
||||
Example
|
||||
^^^^^^^
|
||||
|
||||
Produce a subset containing the characters ' !"#$%' without performing
|
||||
size-reducing optimizations::
|
||||
|
||||
$ pyftsubset font.ttf --unicodes="U+0020-0025" \\
|
||||
--layout-features='*' --glyph-names --symbol-cmap --legacy-cmap \\
|
||||
|
@ -3,15 +3,18 @@
|
||||
https://docs.microsoft.com/en-us/typography/opentype/spec/svg
|
||||
|
||||
The XML format is:
|
||||
<SVG>
|
||||
<svgDoc endGlyphID="1" startGlyphID="1">
|
||||
<![CDATA[ <complete SVG doc> ]]
|
||||
</svgDoc>
|
||||
...
|
||||
<svgDoc endGlyphID="n" startGlyphID="m">
|
||||
<![CDATA[ <complete SVG doc> ]]
|
||||
</svgDoc>
|
||||
</SVG>
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<SVG>
|
||||
<svgDoc endGlyphID="1" startGlyphID="1">
|
||||
<![CDATA[ <complete SVG doc> ]]
|
||||
</svgDoc>
|
||||
...
|
||||
<svgDoc endGlyphID="n" startGlyphID="m">
|
||||
<![CDATA[ <complete SVG doc> ]]
|
||||
</svgDoc>
|
||||
</SVG>
|
||||
"""
|
||||
|
||||
from fontTools.misc.textTools import bytesjoin, strjoin, tobytes, tostr
|
||||
|
@ -867,12 +867,13 @@ _customTableRegistry = {}
|
||||
|
||||
def registerCustomTableClass(tag, moduleName, className=None):
|
||||
"""Register a custom packer/unpacker class for a table.
|
||||
|
||||
The 'moduleName' must be an importable module. If no 'className'
|
||||
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
|
||||
fontTools.ttLib.tables.DefaultTable.DefaultTable
|
||||
:py:class:`fontTools.ttLib.tables.DefaultTable.DefaultTable`
|
||||
"""
|
||||
if className is None:
|
||||
className = "table_" + tagToIdentifier(tag)
|
||||
@ -943,10 +944,14 @@ def tagToIdentifier(tag):
|
||||
letters get an underscore after the letter. Trailing spaces are
|
||||
trimmed. Illegal characters are escaped as two hex bytes. If the
|
||||
result starts with a number (as the result of a hex escape), an
|
||||
extra underscore is prepended. Examples:
|
||||
'glyf' -> '_g_l_y_f'
|
||||
'cvt ' -> '_c_v_t'
|
||||
'OS/2' -> 'O_S_2f_2'
|
||||
extra underscore is prepended. Examples::
|
||||
|
||||
>>> tagToIdentifier('glyf')
|
||||
'_g_l_y_f'
|
||||
>>> tagToIdentifier('cvt ')
|
||||
'_c_v_t'
|
||||
>>> tagToIdentifier('OS/2')
|
||||
'O_S_2f_2'
|
||||
"""
|
||||
import re
|
||||
tag = Tag(tag)
|
||||
|
@ -1,88 +1,105 @@
|
||||
"""\
|
||||
usage: ttx [options] inputfile1 [... inputfileN]
|
||||
|
||||
TTX -- From OpenType To XML And Back
|
||||
TTX -- From OpenType To XML And Back
|
||||
|
||||
If an input file is a TrueType or OpenType font file, it will be
|
||||
decompiled to a TTX file (an XML-based text format).
|
||||
If an input file is a TTX file, it will be compiled to whatever
|
||||
format the data is in, a TrueType or OpenType/CFF font file.
|
||||
If an input file is a TrueType or OpenType font file, it will be
|
||||
decompiled to a TTX file (an XML-based text format).
|
||||
If an input file is a TTX file, it will be compiled to whatever
|
||||
format the data is in, a TrueType or OpenType/CFF font file.
|
||||
|
||||
Output files are created so they are unique: an existing file is
|
||||
never overwritten.
|
||||
Output files are created so they are unique: an existing file is
|
||||
never overwritten.
|
||||
|
||||
General options:
|
||||
-h Help: print this message.
|
||||
--version: show version and exit.
|
||||
-d <outputfolder> Specify a directory where the output files are
|
||||
to be created.
|
||||
-o <outputfile> Specify a file to write the output to. A special
|
||||
value of - would use the standard output.
|
||||
-f Overwrite existing output file(s), ie. don't append numbers.
|
||||
-v Verbose: more messages will be written to stdout about what
|
||||
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.
|
||||
General options
|
||||
===============
|
||||
|
||||
Dump options:
|
||||
-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
|
||||
are allowed. When no -t option is specified, all tables
|
||||
will be dumped.
|
||||
-x <table> Specify a table to exclude from the dump. Multiple
|
||||
-x options are allowed. -t and -x are mutually exclusive.
|
||||
-s Split tables: save the TTX data into separate TTX files per
|
||||
table and write one small TTX file that contains references
|
||||
to the individual table dumps. This file can be used as
|
||||
input to ttx, as long as the table files are in the
|
||||
same directory.
|
||||
-g Split glyf table: Save the glyf data into separate TTX files
|
||||
per glyph and write a small TTX for the glyf table which
|
||||
contains references to the individual TTGlyph elements.
|
||||
NOTE: specifying -g implies -s (no need for -s together with -g)
|
||||
-i Do NOT disassemble TT instructions: when this option is given,
|
||||
all TrueType programs (glyph programs, the font program and the
|
||||
pre-program) will be written to the TTX 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:
|
||||
{'raw', 'row', 'bitwise', 'extfile'} or for the CBDT:
|
||||
{'raw', 'extfile'} Each option does one of the following:
|
||||
-z raw
|
||||
* export the bitmap data as a hex dump
|
||||
-z row
|
||||
* export each row as hex data
|
||||
-z bitwise
|
||||
* export each row as binary in an ASCII art style
|
||||
-z extfile
|
||||
* export the data as external files with XML references
|
||||
If no export format is specified 'raw' format is used.
|
||||
-e Don't ignore decompilation errors, but show a full traceback
|
||||
and abort.
|
||||
-y <number> Select font number for TrueType Collection (.ttc/.otc),
|
||||
starting from 0.
|
||||
--unicodedata <UnicodeData.txt> Use custom database file to write
|
||||
character names in the comments of the cmap TTX output.
|
||||
--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.
|
||||
-h Help print this message.
|
||||
--version show version and exit.
|
||||
-d <outputfolder> Specify a directory where the output files are
|
||||
to be created.
|
||||
-o <outputfile> Specify a file to write the output to. A special
|
||||
value of - would use the standard output.
|
||||
-f Overwrite existing output file(s), ie. don't append
|
||||
numbers.
|
||||
-v Verbose: more messages will be written to stdout
|
||||
about what 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.
|
||||
|
||||
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.
|
||||
-b Don't recalc glyph bounding boxes: use the values in the TTX
|
||||
file as-is.
|
||||
--recalc-timestamp Set font 'modified' timestamp to current time.
|
||||
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
|
||||
--with-zopfli Use Zopfli instead of Zlib to compress WOFF. The Python
|
||||
extension is available at https://pypi.python.org/pypi/zopfli
|
||||
Dump options
|
||||
============
|
||||
|
||||
-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
|
||||
are allowed. When no -t option is specified, all tables
|
||||
will be dumped.
|
||||
-x <table> Specify a table to exclude from the dump. Multiple
|
||||
-x options are allowed. -t and -x are mutually exclusive.
|
||||
-s Split tables: save the TTX data into separate TTX files per
|
||||
table and write one small TTX file that contains references
|
||||
to the individual table dumps. This file can be used as
|
||||
input to ttx, as long as the table files are in the
|
||||
same directory.
|
||||
-g Split glyf table: Save the glyf data into separate TTX files
|
||||
per glyph and write a small TTX for the glyf table which
|
||||
contains references to the individual TTGlyph elements.
|
||||
NOTE: specifying -g implies -s (no need for -s together
|
||||
with -g)
|
||||
-i Do NOT disassemble TT instructions: when this option is
|
||||
given, all TrueType programs (glyph programs, the font
|
||||
program and the pre-program) will be written to the TTX
|
||||
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:
|
||||
{'raw', 'row', 'bitwise', 'extfile'} or for the CBDT:
|
||||
{'raw', 'extfile'} Each option does one of the following:
|
||||
|
||||
-z raw
|
||||
export the bitmap data as a hex dump
|
||||
-z row
|
||||
export each row as hex data
|
||||
-z bitwise
|
||||
export each row as binary in an ASCII art style
|
||||
-z extfile
|
||||
export the data as external files with XML references
|
||||
|
||||
If no export format is specified 'raw' format is used.
|
||||
-e Don't ignore decompilation errors, but show a full traceback
|
||||
and abort.
|
||||
-y <number> Select font number for TrueType Collection (.ttc/.otc),
|
||||
starting from 0.
|
||||
--unicodedata <UnicodeData.txt>
|
||||
Use custom database file to write character names in the
|
||||
comments of the cmap TTX output.
|
||||
--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.
|
||||
|
||||
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.
|
||||
-b Don't recalc glyph bounding boxes: use the values in the
|
||||
TTX file as-is.
|
||||
--recalc-timestamp
|
||||
Set font 'modified' timestamp to current time.
|
||||
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
|
||||
--with-zopfli
|
||||
Use Zopfli instead of Zlib to compress WOFF. The Python
|
||||
extension is available at https://pypi.python.org/pypi/zopfli
|
||||
"""
|
||||
|
||||
|
||||
|
@ -491,7 +491,7 @@ class UFOReader(_UFOBaseIO):
|
||||
"""
|
||||
Get maps defining the renaming that was done during any
|
||||
needed kerning group conversion. This method returns a
|
||||
dictionary of this form:
|
||||
dictionary of this form::
|
||||
|
||||
{
|
||||
"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.
|
||||
This will effectively undo the conversion done when
|
||||
UFOReader reads this data. The dictionary should have
|
||||
this form:
|
||||
this form::
|
||||
|
||||
{
|
||||
"side1" : {"group name to use when writing" : "group name in data"},
|
||||
|
@ -360,23 +360,33 @@ class GlyphSet(_UFOBaseIO):
|
||||
'glyphObject' argument can be any kind of object (even None);
|
||||
the readGlyph() method will attempt to set the following
|
||||
attributes on it:
|
||||
"width" the advance width of the glyph
|
||||
"height" the advance height of the glyph
|
||||
"unicodes" a list of unicode values for this glyph
|
||||
"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
|
||||
|
||||
width
|
||||
the advance width of the glyph
|
||||
height
|
||||
the advance height of the glyph
|
||||
unicodes
|
||||
a list of unicode values for this glyph
|
||||
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:
|
||||
1) An attribute *won't* be set if the .glif file doesn't
|
||||
contain data for it. 'glyphObject' will have to deal
|
||||
with default values itself.
|
||||
2) If setting the attribute fails with an AttributeError
|
||||
(for example if the 'glyphObject' attribute is read-
|
||||
only), readGlyph() will not propagate that exception,
|
||||
but ignore that attribute.
|
||||
|
||||
1) An attribute *won't* be set if the .glif file doesn't
|
||||
contain data for it. 'glyphObject' will have to deal
|
||||
with default values itself.
|
||||
2) If setting the attribute fails with an AttributeError
|
||||
(for example if the 'glyphObject' attribute is read-
|
||||
only), readGlyph() will not propagate that exception,
|
||||
but ignore that attribute.
|
||||
|
||||
To retrieve outline information, you need to pass an object
|
||||
conforming to the PointPen protocol as the 'pointPen' argument.
|
||||
@ -401,14 +411,23 @@ class GlyphSet(_UFOBaseIO):
|
||||
'glyphObject' argument can be any kind of object (even None);
|
||||
the writeGlyph() method will attempt to get the following
|
||||
attributes from it:
|
||||
"width" the advance with of the glyph
|
||||
"height" the advance height of the glyph
|
||||
"unicodes" a list of unicode values for this glyph
|
||||
"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
|
||||
|
||||
width
|
||||
the advance width of the glyph
|
||||
height
|
||||
the advance height of the glyph
|
||||
unicodes
|
||||
a list of unicode values for this glyph
|
||||
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
|
||||
have the attribute, it will simply be skipped.
|
||||
@ -600,23 +619,33 @@ def readGlyphFromString(
|
||||
The 'glyphObject' argument can be any kind of object (even None);
|
||||
the readGlyphFromString() method will attempt to set the following
|
||||
attributes on it:
|
||||
"width" the advance with of the glyph
|
||||
"height" the advance height of the glyph
|
||||
"unicodes" a list of unicode values for this glyph
|
||||
"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
|
||||
|
||||
width
|
||||
the advance width of the glyph
|
||||
height
|
||||
the advance height of the glyph
|
||||
unicodes
|
||||
a list of unicode values for this glyph
|
||||
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:
|
||||
1) An attribute *won't* be set if the .glif file doesn't
|
||||
contain data for it. 'glyphObject' will have to deal
|
||||
with default values itself.
|
||||
2) If setting the attribute fails with an AttributeError
|
||||
(for example if the 'glyphObject' attribute is read-
|
||||
only), readGlyphFromString() will not propagate that
|
||||
exception, but ignore that attribute.
|
||||
|
||||
1) An attribute *won't* be set if the .glif file doesn't
|
||||
contain data for it. 'glyphObject' will have to deal
|
||||
with default values itself.
|
||||
2) If setting the attribute fails with an AttributeError
|
||||
(for example if the 'glyphObject' attribute is read-
|
||||
only), readGlyphFromString() will not propagate that
|
||||
exception, but ignore that attribute.
|
||||
|
||||
To retrieve outline information, you need to pass an object
|
||||
conforming to the PointPen protocol as the 'pointPen' argument.
|
||||
@ -733,14 +762,23 @@ def writeGlyphToString(
|
||||
The 'glyphObject' argument can be any kind of object (even None);
|
||||
the writeGlyphToString() method will attempt to get the following
|
||||
attributes from it:
|
||||
"width" the advance width of the glyph
|
||||
"height" the advance height of the glyph
|
||||
"unicodes" a list of unicode values for this glyph
|
||||
"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
|
||||
|
||||
width
|
||||
the advance width of the glyph
|
||||
height
|
||||
the advance height of the glyph
|
||||
unicodes
|
||||
a list of unicode values for this glyph
|
||||
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
|
||||
have the attribute, it will simply be skipped.
|
||||
|
@ -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.
|
||||
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.
|
||||
|
||||
The 'relevant' source fonts are selected by first getting the right
|
||||
submodel using vsindex_dict[vsindex]. The indices of the
|
||||
subModel.locations are mapped to source font list indices by
|
||||
submodel using ``vsindex_dict[vsindex]``. The indices of the
|
||||
``subModel.locations`` are mapped to source font list indices by
|
||||
assuming the latter order is the same as the order of the
|
||||
var_model.locations. I can then get the index of each subModel
|
||||
location in the list of var_model.locations.
|
||||
``var_model.locations``. I can then get the index of each subModel
|
||||
location in the list of ``var_model.locations``.
|
||||
"""
|
||||
|
||||
topDict = top_dicts[0]
|
||||
@ -591,19 +593,24 @@ class CFF2CharStringMergePen(T2CharStringPen):
|
||||
def reorder_blend_args(self, commands, get_delta_func):
|
||||
"""
|
||||
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] ]
|
||||
We re-arrange this to
|
||||
[ [master_0 x, master_1 x, master_2 x],
|
||||
[master_0 y, master_1 y, master_2 y]
|
||||
]
|
||||
|
||||
We re-arrange this to::
|
||||
|
||||
[ [master_0 x, master_1 x, master_2 x],
|
||||
[master_0 y, master_1 y, master_2 y]
|
||||
]
|
||||
|
||||
If the master values are all the same, we collapse the list to
|
||||
as single value instead of a list.
|
||||
|
||||
We then convert this to:
|
||||
[ [master_0 x] + [x delta tuple] + [numBlends=1]
|
||||
[master_0 y] + [y delta tuple] + [numBlends=1]
|
||||
]
|
||||
We then convert this to::
|
||||
|
||||
[ [master_0 x] + [x delta tuple] + [numBlends=1]
|
||||
[master_0 y] + [y delta tuple] + [numBlends=1]
|
||||
]
|
||||
"""
|
||||
for cmd in commands:
|
||||
# arg[i] is the set of arguments for this operator from master i.
|
||||
|
@ -94,20 +94,22 @@ def overlayFeatureVariations(conditionalSubstitutions):
|
||||
substitution dictionaries. These dictionaries are not merged to allow data
|
||||
sharing when they are converted into font tables.
|
||||
|
||||
Example:
|
||||
>>> condSubst = [
|
||||
... # A list of (Region, Substitution) tuples.
|
||||
... ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
|
||||
... ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
|
||||
... ([{"wdth": (0.5, 1.0)}], {"cent": "cent.rvrn"}),
|
||||
... ([{"wght": (0.5, 1.0), "wdth": (-1, 1.0)}], {"dollar": "dollar.rvrn"}),
|
||||
... ]
|
||||
>>> from pprint import pprint
|
||||
>>> pprint(overlayFeatureVariations(condSubst))
|
||||
[({'wdth': (0.5, 1.0), 'wght': (0.5, 1.0)},
|
||||
[{'dollar': 'dollar.rvrn'}, {'cent': 'cent.rvrn'}]),
|
||||
({'wdth': (0.5, 1.0)}, [{'cent': 'cent.rvrn'}]),
|
||||
({'wght': (0.5, 1.0)}, [{'dollar': 'dollar.rvrn'}])]
|
||||
Example::
|
||||
|
||||
>>> condSubst = [
|
||||
... # A list of (Region, Substitution) tuples.
|
||||
... ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
|
||||
... ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
|
||||
... ([{"wdth": (0.5, 1.0)}], {"cent": "cent.rvrn"}),
|
||||
... ([{"wght": (0.5, 1.0), "wdth": (-1, 1.0)}], {"dollar": "dollar.rvrn"}),
|
||||
... ]
|
||||
>>> from pprint import pprint
|
||||
>>> pprint(overlayFeatureVariations(condSubst))
|
||||
[({'wdth': (0.5, 1.0), 'wght': (0.5, 1.0)},
|
||||
[{'dollar': 'dollar.rvrn'}, {'cent': 'cent.rvrn'}]),
|
||||
({'wdth': (0.5, 1.0)}, [{'cent': 'cent.rvrn'}]),
|
||||
({'wght': (0.5, 1.0)}, [{'dollar': 'dollar.rvrn'}])]
|
||||
|
||||
"""
|
||||
|
||||
# Merge same-substitutions rules, as this creates fewer number oflookups.
|
||||
@ -184,11 +186,12 @@ def overlayFeatureVariations(conditionalSubstitutions):
|
||||
#
|
||||
|
||||
def overlayBox(top, bot):
|
||||
"""Overlays `top` box on top of `bot` box.
|
||||
"""Overlays ``top`` box on top of ``bot`` box.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
@ -5,9 +5,9 @@ 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.
|
||||
|
||||
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
|
||||
|
||||
See `fonttools varLib.instancer --help` for more info on the CLI options.
|
||||
|
||||
@ -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.
|
||||
|
||||
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.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,
|
||||
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;
|
||||
L3) restricting the range of variation of one or more axes, by setting either
|
||||
|
||||
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;
|
||||
L3
|
||||
restricting the range of variation of one or more axes, by setting either
|
||||
a new minimum or maximum, potentially -- though not necessarily -- dropping
|
||||
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)
|
||||
are supported, but support for CFF2 variable fonts will be added soon.
|
||||
|
@ -169,46 +169,47 @@ def supportScalar(location, support, ot=True):
|
||||
class VariationModel(object):
|
||||
|
||||
"""
|
||||
Locations must be in normalized space. Ie. base master
|
||||
is at origin (0).
|
||||
>>> from pprint import pprint
|
||||
>>> locations = [ \
|
||||
{'wght':100}, \
|
||||
{'wght':-100}, \
|
||||
{'wght':-180}, \
|
||||
{'wdth':+.3}, \
|
||||
{'wght':+120,'wdth':.3}, \
|
||||
{'wght':+120,'wdth':.2}, \
|
||||
{}, \
|
||||
{'wght':+180,'wdth':.3}, \
|
||||
{'wght':+180}, \
|
||||
]
|
||||
>>> model = VariationModel(locations, axisOrder=['wght'])
|
||||
>>> pprint(model.locations)
|
||||
[{},
|
||||
{'wght': -100},
|
||||
{'wght': -180},
|
||||
{'wght': 100},
|
||||
{'wght': 180},
|
||||
{'wdth': 0.3},
|
||||
{'wdth': 0.3, 'wght': 180},
|
||||
{'wdth': 0.3, 'wght': 120},
|
||||
{'wdth': 0.2, 'wght': 120}]
|
||||
>>> pprint(model.deltaWeights)
|
||||
[{},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0, 4: 1.0, 5: 1.0},
|
||||
{0: 1.0, 3: 0.75, 4: 0.25, 5: 1.0, 6: 0.6666666666666666},
|
||||
{0: 1.0,
|
||||
3: 0.75,
|
||||
4: 0.25,
|
||||
5: 0.6666666666666667,
|
||||
6: 0.4444444444444445,
|
||||
7: 0.6666666666666667}]
|
||||
Locations must be in normalized space. Ie. base master
|
||||
is at origin (0)::
|
||||
|
||||
>>> from pprint import pprint
|
||||
>>> locations = [ \
|
||||
{'wght':100}, \
|
||||
{'wght':-100}, \
|
||||
{'wght':-180}, \
|
||||
{'wdth':+.3}, \
|
||||
{'wght':+120,'wdth':.3}, \
|
||||
{'wght':+120,'wdth':.2}, \
|
||||
{}, \
|
||||
{'wght':+180,'wdth':.3}, \
|
||||
{'wght':+180}, \
|
||||
]
|
||||
>>> model = VariationModel(locations, axisOrder=['wght'])
|
||||
>>> pprint(model.locations)
|
||||
[{},
|
||||
{'wght': -100},
|
||||
{'wght': -180},
|
||||
{'wght': 100},
|
||||
{'wght': 180},
|
||||
{'wdth': 0.3},
|
||||
{'wdth': 0.3, 'wght': 180},
|
||||
{'wdth': 0.3, 'wght': 120},
|
||||
{'wdth': 0.2, 'wght': 120}]
|
||||
>>> pprint(model.deltaWeights)
|
||||
[{},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0, 4: 1.0, 5: 1.0},
|
||||
{0: 1.0, 3: 0.75, 4: 0.25, 5: 1.0, 6: 0.6666666666666666},
|
||||
{0: 1.0,
|
||||
3: 0.75,
|
||||
4: 0.25,
|
||||
5: 0.6666666666666667,
|
||||
6: 0.4444444444444445,
|
||||
7: 0.6666666666666667}]
|
||||
"""
|
||||
|
||||
def __init__(self, locations, axisOrder=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user