code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def transformVectors(self, vectors):
"""Transform a list of (dx, dy) vector, treating translation as zero.
:Example:
>>> t = Transform(2, 0, 0, 2, 10, 20)
>>> t.transformVectors([(3, -4), (5, -6)])
[(6, -8), (10, -12)]
>>>
"""
... | Transform a list of (dx, dy) vector, treating translation as zero.
:Example:
>>> t = Transform(2, 0, 0, 2, 10, 20)
>>> t.transformVectors([(3, -4), (5, -6)])
[(6, -8), (10, -12)]
>>>
| transformVectors | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def scale(self, x: float = 1, y: float | None = None):
"""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:
>>> t = Transform()
>>> t.scale(5)
<Transform [5 0 0 5 0... | 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:
>>> t = Transform()
>>> t.scale(5)
<Transform [5 0 0 5 0 0]>
>>> t.scale(5, 6)
<Transform ... | scale | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def rotate(self, angle: float):
"""Return a new transformation, rotated by 'angle' (radians).
:Example:
>>> import math
>>> t = Transform()
>>> t.rotate(math.pi / 2)
<Transform [0 1 -1 0 0 0]>
>>>
"""
c = _n... | Return a new transformation, rotated by 'angle' (radians).
:Example:
>>> import math
>>> t = Transform()
>>> t.rotate(math.pi / 2)
<Transform [0 1 -1 0 0 0]>
>>>
| rotate | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def transform(self, other):
"""Return a new transformation, transformed by another
transformation.
:Example:
>>> t = Transform(2, 0, 0, 3, 1, 6)
>>> t.transform((4, 3, 2, 1, 5, 6))
<Transform [8 9 4 3 11 24]>
>>>
"""
... | Return a new transformation, transformed by another
transformation.
:Example:
>>> t = Transform(2, 0, 0, 3, 1, 6)
>>> t.transform((4, 3, 2, 1, 5, 6))
<Transform [8 9 4 3 11 24]>
>>>
| transform | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def reverseTransform(self, other):
"""Return a new transformation, which is the other transformation
transformed by self. self.reverseTransform(other) is equivalent to
other.transform(self).
:Example:
>>> t = Transform(2, 0, 0, 3, 1, 6)
>>> t.reverseTrans... | Return a new transformation, which is the other transformation
transformed by self. self.reverseTransform(other) is equivalent to
other.transform(self).
:Example:
>>> t = Transform(2, 0, 0, 3, 1, 6)
>>> t.reverseTransform((4, 3, 2, 1, 5, 6))
<Tran... | reverseTransform | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def inverse(self):
"""Return the inverse transformation.
:Example:
>>> t = Identity.translate(2, 3).scale(4, 5)
>>> t.transformPoint((10, 20))
(42, 103)
>>> it = t.inverse()
>>> it.transformPoint((42, 103))
... | Return the inverse transformation.
:Example:
>>> t = Identity.translate(2, 3).scale(4, 5)
>>> t.transformPoint((10, 20))
(42, 103)
>>> it = t.inverse()
>>> it.transformPoint((42, 103))
(10.0, 20.0)
>... | inverse | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def Scale(x: float, y: float | None = None) -> Transform:
"""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:
>>> Scale(2, 3)
<Transform [2 0 0 3 0 0]>
>>>
"""
if y is 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:
>>> Scale(2, 3)
<Transform [2 0 0 3 0 0]>
>>>
| Scale | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def fromTransform(self, transform):
"""Return a DecomposedTransform() equivalent of this transformation.
The returned solution always has skewY = 0, and angle in the (-180, 180].
:Example:
>>> DecomposedTransform.fromTransform(Transform(3, 0, 0, 2, 0, 0))
Decompo... | Return a DecomposedTransform() equivalent of this transformation.
The returned solution always has skewY = 0, and angle in the (-180, 180].
:Example:
>>> DecomposedTransform.fromTransform(Transform(3, 0, 0, 2, 0, 0))
DecomposedTransform(translateX=0, translateY=0, rotati... | fromTransform | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def toTransform(self) -> Transform:
"""Return the Transform() equivalent of this transformation.
:Example:
>>> DecomposedTransform(scaleX=2, scaleY=2).toTransform()
<Transform [2 0 0 2 0 0]>
>>>
"""
t = Transform()
t = t.translate(... | Return the Transform() equivalent of this transformation.
:Example:
>>> DecomposedTransform(scaleX=2, scaleY=2).toTransform()
<Transform [2 0 0 2 0 0]>
>>>
| toTransform | python | fonttools/fonttools | Lib/fontTools/misc/transform.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py | MIT |
def build_n_ary_tree(leaves, n):
"""Build N-ary tree from sequence of leaf nodes.
Return a list of lists where each non-leaf node is a list containing
max n nodes.
"""
if not leaves:
return []
assert n > 1
depth = ceil(log(len(leaves), n))
if depth <= 1:
return list(l... | Build N-ary tree from sequence of leaf nodes.
Return a list of lists where each non-leaf node is a list containing
max n nodes.
| build_n_ary_tree | python | fonttools/fonttools | Lib/fontTools/misc/treeTools.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/treeTools.py | MIT |
def dot(self, other):
"""Performs vector dot product, returning the sum of
``a[0] * b[0], a[1] * b[1], ...``"""
assert len(self) == len(other)
return sum(a * b for a, b in zip(self, other)) | Performs vector dot product, returning the sum of
``a[0] * b[0], a[1] * b[1], ...`` | dot | python | fonttools/fonttools | Lib/fontTools/misc/vector.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/vector.py | MIT |
def isclose(self, other: "Vector", **kwargs) -> bool:
"""Return True if the vector is close to another Vector."""
assert len(self) == len(other)
return all(math.isclose(a, b, **kwargs) for a, b in zip(self, other)) | Return True if the vector is close to another Vector. | isclose | python | fonttools/fonttools | Lib/fontTools/misc/vector.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/vector.py | MIT |
def visitObject(self, obj, *args, **kwargs):
"""Called to visit an object. This function loops over all non-private
attributes of the objects and calls any user-registered (via
@register_attr() or @register_attrs()) visit() functions.
If there is no user-registered visit function, of if... | Called to visit an object. This function loops over all non-private
attributes of the objects and calls any user-registered (via
@register_attr() or @register_attrs()) visit() functions.
If there is no user-registered visit function, of if there is and it
returns True, or it returns Non... | visitObject | python | fonttools/fonttools | Lib/fontTools/misc/visitor.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/visitor.py | MIT |
def visitList(self, obj, *args, **kwargs):
"""Called to visit any value that is a list."""
for value in obj:
self.visit(value, *args, **kwargs) | Called to visit any value that is a list. | visitList | python | fonttools/fonttools | Lib/fontTools/misc/visitor.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/visitor.py | MIT |
def visitDict(self, obj, *args, **kwargs):
"""Called to visit any value that is a dictionary."""
for value in obj.values():
self.visit(value, *args, **kwargs) | Called to visit any value that is a dictionary. | visitDict | python | fonttools/fonttools | Lib/fontTools/misc/visitor.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/visitor.py | MIT |
def visit(self, obj, *args, **kwargs):
"""This is the main entry to the visitor. The visitor will visit object
obj.
The visitor will first determine if there is a registered (via
@register()) visit function for the type of object. If there is, it
will be called, and (visitor, ob... | This is the main entry to the visitor. The visitor will visit object
obj.
The visitor will first determine if there is a registered (via
@register()) visit function for the type of object. If there is, it
will be called, and (visitor, obj, *args, **kwargs) will be passed to
the ... | visit | python | fonttools/fonttools | Lib/fontTools/misc/visitor.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/visitor.py | MIT |
def totree(
value: PlistEncodable,
sort_keys: bool = True,
skipkeys: bool = False,
use_builtin_types: Optional[bool] = None,
pretty_print: bool = True,
indent_level: int = 1,
) -> etree.Element:
"""Convert a value derived from a plist into an XML tree.
Args:
value: Any kind of v... | Convert a value derived from a plist into an XML tree.
Args:
value: Any kind of value to be serialized to XML.
sort_keys: Whether keys of dictionaries should be sorted.
skipkeys (bool): Whether to silently skip non-string dictionary
keys.
use_builtin_types (bool): If tru... | totree | python | fonttools/fonttools | Lib/fontTools/misc/plistlib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py | MIT |
def fromtree(
tree: etree.Element,
use_builtin_types: Optional[bool] = None,
dict_type: Type[MutableMapping[str, Any]] = dict,
) -> Any:
"""Convert an XML tree to a plist structure.
Args:
tree: An ``etree`` ``Element``.
use_builtin_types: If True, binary data is deserialized to
... | Convert an XML tree to a plist structure.
Args:
tree: An ``etree`` ``Element``.
use_builtin_types: If True, binary data is deserialized to
bytes strings. If False, it is wrapped in :py:class:`Data`
objects. Defaults to True if not provided. Deprecated.
dict_type: Wha... | fromtree | python | fonttools/fonttools | Lib/fontTools/misc/plistlib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py | MIT |
def load(
fp: IO[bytes],
use_builtin_types: Optional[bool] = None,
dict_type: Type[MutableMapping[str, Any]] = dict,
) -> Any:
"""Load a plist file into an object.
Args:
fp: An opened file.
use_builtin_types: If True, binary data is deserialized to
bytes strings. If Fals... | Load a plist file into an object.
Args:
fp: An opened file.
use_builtin_types: If True, binary data is deserialized to
bytes strings. If False, it is wrapped in :py:class:`Data`
objects. Defaults to True if not provided. Deprecated.
dict_type: What type to use for di... | load | python | fonttools/fonttools | Lib/fontTools/misc/plistlib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py | MIT |
def loads(
value: bytes,
use_builtin_types: Optional[bool] = None,
dict_type: Type[MutableMapping[str, Any]] = dict,
) -> Any:
"""Load a plist file from a string into an object.
Args:
value: A bytes string containing a plist.
use_builtin_types: If True, binary data is deserialized t... | Load a plist file from a string into an object.
Args:
value: A bytes string containing a plist.
use_builtin_types: If True, binary data is deserialized to
bytes strings. If False, it is wrapped in :py:class:`Data`
objects. Defaults to True if not provided. Deprecated.
... | loads | python | fonttools/fonttools | Lib/fontTools/misc/plistlib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py | MIT |
def dump(
value: PlistEncodable,
fp: IO[bytes],
sort_keys: bool = True,
skipkeys: bool = False,
use_builtin_types: Optional[bool] = None,
pretty_print: bool = True,
) -> None:
"""Write a Python object to a plist file.
Args:
value: An object to write.
fp: A file opened fo... | Write a Python object to a plist file.
Args:
value: An object to write.
fp: A file opened for writing.
sort_keys (bool): Whether keys of dictionaries should be sorted.
skipkeys (bool): Whether to silently skip non-string dictionary
keys.
use_builtin_types (bool):... | dump | python | fonttools/fonttools | Lib/fontTools/misc/plistlib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py | MIT |
def dumps(
value: PlistEncodable,
sort_keys: bool = True,
skipkeys: bool = False,
use_builtin_types: Optional[bool] = None,
pretty_print: bool = True,
) -> bytes:
"""Write a Python object to a string in plist format.
Args:
value: An object to write.
sort_keys (bool): Whether... | Write a Python object to a string in plist format.
Args:
value: An object to write.
sort_keys (bool): Whether keys of dictionaries should be sorted.
skipkeys (bool): Whether to silently skip non-string dictionary
keys.
use_builtin_types (bool): If true, byte strings will... | dumps | python | fonttools/fonttools | Lib/fontTools/misc/plistlib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py | MIT |
def build(f, font, tableTag=None):
"""Convert a Monotype font layout file to an OpenType layout object
A font object must be passed, but this may be a "dummy" font; it is only
used for sorting glyph sets when making coverage tables and to hold the
OpenType layout table while it is being built.
Arg... | Convert a Monotype font layout file to an OpenType layout object
A font object must be passed, but this may be a "dummy" font; it is only
used for sorting glyph sets when making coverage tables and to hold the
OpenType layout table while it is being built.
Args:
f: A file object.
... | build | python | fonttools/fonttools | Lib/fontTools/mtiLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/mtiLib/__init__.py | MIT |
def main(args=None, font=None):
"""Convert a FontDame OTL file to TTX XML
Writes XML output to stdout.
Args:
args: Command line arguments (``--font``, ``--table``, input files).
"""
import sys
from fontTools import configLogger
from fontTools.misc.testTools import MockFont
... | Convert a FontDame OTL file to TTX XML
Writes XML output to stdout.
Args:
args: Command line arguments (``--font``, ``--table``, input files).
| main | python | fonttools/fonttools | Lib/fontTools/mtiLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/mtiLib/__init__.py | MIT |
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>`__)
are used in all OpenType Layout lookups apart from the Extension type, and
define the glyphs involve... | Builds a 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 ... | buildCoverage | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildLookup(subtables, flags=0, markFilterSet=None, table=None, extension=False):
"""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>`__)
wraps the individual rules in a layout operation ... | 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>`__)
wraps the individual rules in a layout operation (substitution or
positioning) in a data structure expressing their overall lookup type -
... | buildLookup | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildMarkClasses_(self, marks):
"""{"cedilla": ("BOTTOM", ast.Anchor), ...} --> {"BOTTOM":0, "TOP":1}
Helper for MarkBasePostBuilder, MarkLigPosBuilder, and
MarkMarkPosBuilder. Seems to return the same numeric IDs
for mark classes as the AFDKO makeotf tool.
"""
ids =... | {"cedilla": ("BOTTOM", ast.Anchor), ...} --> {"BOTTOM":0, "TOP":1}
Helper for MarkBasePostBuilder, MarkLigPosBuilder, and
MarkMarkPosBuilder. Seems to return the same numeric IDs
for mark classes as the AFDKO makeotf tool.
| buildMarkClasses_ | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def add_subtable_break(self, location):
"""Add an explicit subtable break.
Args:
location: A string or tuple representing the location in the
original source which produced this break, or ``None`` if
no location is provided.
"""
log.warning(
... | Add an explicit subtable break.
Args:
location: A string or tuple representing the location in the
original source which produced this break, or ``None`` if
no location is provided.
| add_subtable_break | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the alternate
substitution lookup.
"""
subtables = self.build_subst_subtables(
self.alternates, buildAlternateSubstSubtable
)
return self.buildLo... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the alternate
substitution lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the chained
contextual positioning lookup.
"""
subtables = []
rulesets = self.rulesets()
chaining = any(ruleset.hasPrefixOrSuffix for ruleset in rulesets)
... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the chained
contextual positioning lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the ligature
substitution lookup.
"""
subtables = self.build_subst_subtables(
self.ligatures, buildLigatureSubstSubtable
)
return self.buildLooku... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the ligature
substitution lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def add_attachment(self, location, glyphs, entryAnchor, exitAnchor):
"""Adds attachment information to the cursive positioning lookup.
Args:
location: A string or tuple representing the location in the
original source which produced this lookup. (Unused.)
glyphs:... | Adds attachment information to the cursive positioning lookup.
Args:
location: A string or tuple representing the location in the
original source which produced this lookup. (Unused.)
glyphs: A list of glyph names sharing these entry and exit
anchor locat... | add_attachment | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the cursive
positioning lookup.
"""
attachments = [{}]
for key in self.attachments:
if key[0] == self.SUBTABLE_BREAK_:
attachments.append... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the cursive
positioning lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the mark-to-base
positioning lookup.
"""
subtables = []
for subtable in self.get_subtables_():
markClasses = self.buildMarkClasses_(subtable[0])
... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the mark-to-base
positioning lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the mark-to-ligature
positioning lookup.
"""
subtables = []
for subtable in self.get_subtables_():
markClasses = self.buildMarkClasses_(subtable[0])
... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the mark-to-ligature
positioning lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the mark-to-mark
positioning lookup.
"""
subtables = []
for subtable in self.get_subtables_():
markClasses = self.buildMarkClasses_(subtable[0])
... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the mark-to-mark
positioning lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the chained
contextual substitution lookup.
"""
subtables = []
for prefix, suffix, mapping in self.rules:
st = ot.ReverseChainSingleSubst()
s... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the chained
contextual substitution lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def addPair(self, gc1, value1, gc2, value2):
"""Add a pair positioning rule.
Args:
gc1: A set of glyph names for the "left" glyph
value1: An ``otTables.ValueRecord`` object for the left glyph's
positioning.
gc2: A set of glyph names for the "right" gl... | Add a pair positioning rule.
Args:
gc1: A set of glyph names for the "left" glyph
value1: An ``otTables.ValueRecord`` object for the left glyph's
positioning.
gc2: A set of glyph names for the "right" glyph
value2: An ``otTables.ValueRecord`` obje... | addPair | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def addGlyphPair(self, location, glyph1, value1, glyph2, value2):
"""Add a glyph pair positioning rule to the current lookup.
Args:
location: A string or tuple representing the location in the
original source which produced this rule.
glyph1: A glyph name for the... | Add a glyph pair positioning rule to the current lookup.
Args:
location: A string or tuple representing the location in the
original source which produced this rule.
glyph1: A glyph name for the "left" glyph in the pair.
value1: A ``otTables.ValueRecord`` for... | addGlyphPair | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def build(self):
"""Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the pair positioning
lookup.
"""
builders = {}
builder = ClassPairPosSubtableBuilder(self)
for glyphclass1, value1, glyphclass2, value2 in self.pairs:
... | Build the lookup.
Returns:
An ``otTables.Lookup`` object representing the pair positioning
lookup.
| build | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def add_pos(self, location, glyph, otValueRecord):
"""Add a single positioning rule.
Args:
location: A string or tuple representing the location in the
original source which produced this lookup.
glyph: A glyph name.
otValueRection: A ``otTables.Value... | Add a single positioning rule.
Args:
location: A string or tuple representing the location in the
original source which produced this lookup.
glyph: A glyph name.
otValueRection: A ``otTables.ValueRecord`` used to position the
glyph.
| add_pos | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildSingleSubstSubtable(mapping):
"""Builds a single substitution (GSUB1) subtable.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.SingleSubstBuilder` instead.
Args:
mapping: A dictionary mapping inp... | Builds a single substitution (GSUB1) subtable.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.SingleSubstBuilder` instead.
Args:
mapping: A dictionary mapping input glyph names to output glyph names.
Ret... | buildSingleSubstSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildMultipleSubstSubtable(mapping):
"""Builds a multiple substitution (GSUB2) subtable.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.MultipleSubstBuilder` instead.
Example::
# sub uni06C0 by uni06... | Builds a multiple substitution (GSUB2) subtable.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.MultipleSubstBuilder` instead.
Example::
# sub uni06C0 by uni06D5.fina hamza.above
# sub uni06C2 by uni... | buildMultipleSubstSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildAlternateSubstSubtable(mapping):
"""Builds an alternate substitution (GSUB3) subtable.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.AlternateSubstBuilder` instead.
Args:
mapping: A dictionary m... | Builds an alternate substitution (GSUB3) subtable.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.AlternateSubstBuilder` instead.
Args:
mapping: A dictionary mapping input glyph names to a list of output
... | buildAlternateSubstSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildLigatureSubstSubtable(mapping):
"""Builds a ligature substitution (GSUB4) subtable.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.LigatureSubstBuilder` instead.
Example::
# sub f f i by f_f_i;
... | Builds a ligature substitution (GSUB4) subtable.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.LigatureSubstBuilder` instead.
Example::
# sub f f i by f_f_i;
# sub f i by f_i;
subtable = bu... | buildLigatureSubstSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildAnchor(x, y, point=None, deviceX=None, deviceY=None):
"""Builds an Anchor table.
This determines the appropriate anchor format based on the passed parameters.
Args:
x (int): X coordinate.
y (int): Y coordinate.
point (int): Index of glyph contour point, if provided.
... | Builds an Anchor table.
This determines the appropriate anchor format based on the passed parameters.
Args:
x (int): X coordinate.
y (int): Y coordinate.
point (int): Index of glyph contour point, if provided.
deviceX (``otTables.Device``): X coordinate device table, if provide... | buildAnchor | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildBaseArray(bases, numMarkClasses, glyphMap):
"""Builds a base array record.
As part of building mark-to-base positioning rules, you will need to define
a ``BaseArray`` record, which "defines for each base glyph an array of
anchors, one for each mark class." This function builds the base array
... | Builds a base array record.
As part of building mark-to-base positioning rules, you will need to define
a ``BaseArray`` record, which "defines for each base glyph an array of
anchors, one for each mark class." This function builds the base array
subtable.
Example::
bases = {"a": {0: a3, 1... | buildBaseArray | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildComponentRecord(anchors):
"""Builds a component record.
As part of building mark-to-ligature positioning rules, you will need to
define ``ComponentRecord`` objects, which contain "an array of offsets...
to the Anchor tables that define all the attachment points used to attach
marks to the ... | Builds a component record.
As part of building mark-to-ligature positioning rules, you will need to
define ``ComponentRecord`` objects, which contain "an array of offsets...
to the Anchor tables that define all the attachment points used to attach
marks to the component." This function builds the compo... | buildComponentRecord | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildCursivePosSubtable(attach, glyphMap):
"""Builds a cursive positioning (GPOS3) subtable.
Cursive positioning lookups are made up of a coverage table of glyphs,
and a set of ``EntryExitRecord`` records containing the anchors for
each glyph. This function builds the cursive positioning subtable.
... | Builds a cursive positioning (GPOS3) subtable.
Cursive positioning lookups are made up of a coverage table of glyphs,
and a set of ``EntryExitRecord`` records containing the anchors for
each glyph. This function builds the cursive positioning subtable.
Example::
subtable = buildCursivePosSubt... | buildCursivePosSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildDevice(deltas):
"""Builds a Device record as part of a ValueRecord or Anchor.
Device tables specify size-specific adjustments to value records
and anchors to reflect changes based on the resolution of the output.
For example, one could specify that an anchor's Y position should be
increase... | Builds a Device record as part of a ValueRecord or Anchor.
Device tables specify size-specific adjustments to value records
and anchors to reflect changes based on the resolution of the output.
For example, one could specify that an anchor's Y position should be
increased by 1 pixel when displayed at 8... | buildDevice | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildLigatureArray(ligs, numMarkClasses, glyphMap):
"""Builds a LigatureArray subtable.
As part of building a mark-to-ligature lookup, you will need to define
the set of anchors (for each mark class) on each component of the ligature
where marks can be attached. For example, for an Arabic divine na... | Builds a LigatureArray subtable.
As part of building a mark-to-ligature lookup, you will need to define
the set of anchors (for each mark class) on each component of the ligature
where marks can be attached. For example, for an Arabic divine name ligature
(lam lam heh), you may want to specify mark att... | buildLigatureArray | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildMarkArray(marks, glyphMap):
"""Builds a mark array subtable.
As part of building mark-to-* positioning rules, you will need to define
a MarkArray subtable, which "defines the class and the anchor point
for a mark glyph." This function builds the mark array subtable.
Example::
mar... | Builds a mark array subtable.
As part of building mark-to-* positioning rules, you will need to define
a MarkArray subtable, which "defines the class and the anchor point
for a mark glyph." This function builds the mark array subtable.
Example::
mark = {
"acute": (0, buildAnchor(3... | buildMarkArray | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildMarkBasePosSubtable(marks, bases, glyphMap):
"""Build a single MarkBasePos (GPOS4) subtable.
This builds a mark-to-base lookup subtable containing all of the referenced
marks and bases.
Example::
# a1, a2, a3, a4, a5 = buildAnchor(500, 100), ...
marks = {"acute": (0, a1), "g... | Build a single MarkBasePos (GPOS4) subtable.
This builds a mark-to-base lookup subtable containing all of the referenced
marks and bases.
Example::
# a1, a2, a3, a4, a5 = buildAnchor(500, 100), ...
marks = {"acute": (0, a1), "grave": (0, a1), "cedilla": (1, a2)}
bases = {"a": {0:... | buildMarkBasePosSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildMarkLigPosSubtable(marks, ligs, glyphMap):
"""Build a single MarkLigPos (GPOS5) subtable.
This builds a mark-to-base lookup subtable containing all of the referenced
marks and bases.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`f... | Build a single MarkLigPos (GPOS5) subtable.
This builds a mark-to-base lookup subtable containing all of the referenced
marks and bases.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.lookupBuilders.MarkLigPosBuilder` instead.
... | buildMarkLigPosSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildPairPosGlyphs(pairs, glyphMap):
"""Builds a list of glyph-based pair adjustment (GPOS2 format 1) subtables.
This organises a list of pair positioning adjustments into subtables based
on common value record formats.
Note that if you are implementing a layout compiler, you may find it more
... | Builds a list of glyph-based pair adjustment (GPOS2 format 1) subtables.
This organises a list of pair positioning adjustments into subtables based
on common value record formats.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:py:class:`fontTools.otlLib.... | buildPairPosGlyphs | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildPairPosGlyphsSubtable(pairs, glyphMap, valueFormat1=None, valueFormat2=None):
"""Builds a single glyph-based pair adjustment (GPOS2 format 1) subtable.
This builds a PairPos subtable from a dictionary of glyph pairs and
their positioning adjustments. See also :func:`buildPairPosGlyphs`.
Note ... | Builds a single glyph-based pair adjustment (GPOS2 format 1) subtable.
This builds a PairPos subtable from a dictionary of glyph pairs and
their positioning adjustments. See also :func:`buildPairPosGlyphs`.
Note that if you are implementing a layout compiler, you may find it more
flexible to use
:... | buildPairPosGlyphsSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildSinglePos(mapping, glyphMap):
"""Builds a list of single adjustment (GPOS1) subtables.
This builds a list of SinglePos subtables from a dictionary of glyph
names and their positioning adjustments. The format of the subtables are
determined to optimize the size of the resulting subtables.
S... | Builds a list of single adjustment (GPOS1) subtables.
This builds a list of SinglePos subtables from a dictionary of glyph
names and their positioning adjustments. The format of the subtables are
determined to optimize the size of the resulting subtables.
See also :func:`buildSinglePosSubtable`.
N... | buildSinglePos | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildSinglePosSubtable(values, glyphMap):
"""Builds a single adjustment (GPOS1) subtable.
This builds a list of SinglePos subtables from a dictionary of glyph
names and their positioning adjustments. The format of the subtable is
determined to optimize the size of the output.
See also :func:`bu... | Builds a single adjustment (GPOS1) subtable.
This builds a list of SinglePos subtables from a dictionary of glyph
names and their positioning adjustments. The format of the subtable is
determined to optimize the size of the output.
See also :func:`buildSinglePos`.
Note that if you are implementing... | buildSinglePosSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildValue(value):
"""Builds a positioning value record.
Value records are used to specify coordinates and adjustments for
positioning and attaching glyphs. Many of the positioning functions
in this library take ``otTables.ValueRecord`` objects as arguments.
This function builds value records f... | Builds a positioning value record.
Value records are used to specify coordinates and adjustments for
positioning and attaching glyphs. Many of the positioning functions
in this library take ``otTables.ValueRecord`` objects as arguments.
This function builds value records from dictionaries.
Args:
... | buildValue | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildAttachList(attachPoints, glyphMap):
"""Builds an AttachList subtable.
A GDEF table may contain an Attachment Point List table (AttachList)
which stores the contour indices of attachment points for glyphs with
attachment points. This routine builds AttachList subtables.
Args:
attac... | Builds an AttachList subtable.
A GDEF table may contain an Attachment Point List table (AttachList)
which stores the contour indices of attachment points for glyphs with
attachment points. This routine builds AttachList subtables.
Args:
attachPoints (dict): A mapping between glyph names and a ... | buildAttachList | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildLigCaretList(coords, points, glyphMap):
"""Builds a ligature caret list table.
Ligatures appear as a single glyph representing multiple characters; however
when, for example, editing text containing a ``f_i`` ligature, the user may
want to place the cursor between the ``f`` and the ``i``. The ... | Builds a ligature caret list table.
Ligatures appear as a single glyph representing multiple characters; however
when, for example, editing text containing a ``f_i`` ligature, the user may
want to place the cursor between the ``f`` and the ``i``. The ligature caret
list in the GDEF table specifies the ... | buildLigCaretList | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def buildMarkGlyphSetsDef(markSets, glyphMap):
"""Builds a mark glyph sets definition table.
OpenType Layout lookups may choose to use mark filtering sets to consider
or ignore particular combinations of marks. These sets are specified by
setting a flag on the lookup, but the mark filtering sets are de... | Builds a mark glyph sets definition table.
OpenType Layout lookups may choose to use mark filtering sets to consider
or ignore particular combinations of marks. These sets are specified by
setting a flag on the lookup, but the mark filtering sets are defined in
the ``GDEF`` table. This routine builds t... | buildMarkGlyphSetsDef | python | fonttools/fonttools | Lib/fontTools/otlLib/builder.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py | MIT |
def maxCtxFont(font):
"""Calculate the usMaxContext value for an entire font."""
maxCtx = 0
for tag in ("GSUB", "GPOS"):
if tag not in font:
continue
table = font[tag].table
if not table.LookupList:
continue
for lookup in table.LookupList.Lookup:
... | Calculate the usMaxContext value for an entire font. | maxCtxFont | python | fonttools/fonttools | Lib/fontTools/otlLib/maxContextCalc.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/maxContextCalc.py | MIT |
def maxCtxSubtable(maxCtx, tag, lookupType, st):
"""Calculate usMaxContext based on a single lookup table (and an existing
max value).
"""
# single positioning, single / multiple substitution
if (tag == "GPOS" and lookupType == 1) or (
tag == "GSUB" and lookupType in (1, 2, 3)
):
... | Calculate usMaxContext based on a single lookup table (and an existing
max value).
| maxCtxSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/maxContextCalc.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/maxContextCalc.py | MIT |
def maxCtxContextualSubtable(maxCtx, st, ruleType, chain=""):
"""Calculate usMaxContext based on a contextual feature subtable."""
if st.Format == 1:
for ruleset in getattr(st, "%s%sRuleSet" % (chain, ruleType)):
if ruleset is None:
continue
for rule in getattr(r... | Calculate usMaxContext based on a contextual feature subtable. | maxCtxContextualSubtable | python | fonttools/fonttools | Lib/fontTools/otlLib/maxContextCalc.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/maxContextCalc.py | MIT |
def maxCtxContextualRule(maxCtx, st, chain):
"""Calculate usMaxContext based on a contextual feature rule."""
if not chain:
return max(maxCtx, st.GlyphCount)
elif chain == "Reverse":
return max(maxCtx, 1 + st.LookAheadGlyphCount)
return max(maxCtx, st.InputGlyphCount + st.LookAheadGlyph... | Calculate usMaxContext based on a contextual feature rule. | maxCtxContextualRule | python | fonttools/fonttools | Lib/fontTools/otlLib/maxContextCalc.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/maxContextCalc.py | MIT |
def main(args=None):
"""Optimize the layout tables of an existing font"""
from argparse import ArgumentParser
from fontTools import configLogger
parser = ArgumentParser(
prog="otlLib.optimize",
description=main.__doc__,
formatter_class=RawTextHelpFormatter,
)
parser.add... | Optimize the layout tables of an existing font | main | python | fonttools/fonttools | Lib/fontTools/otlLib/optimize/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/optimize/__init__.py | MIT |
def addComponent(
self,
glyphName: str,
transformation: Tuple[float, float, float, float, float, float],
) -> None:
"""Add a sub glyph. The 'transformation' argument must be a 6-tuple
containing an affine transformation, or a Transform object from the
fontTools.misc.t... | Add a sub glyph. The 'transformation' argument must be a 6-tuple
containing an affine transformation, or a Transform object from the
fontTools.misc.transform module. More precisely: it should be a
sequence containing 6 numbers.
| addComponent | python | fonttools/fonttools | Lib/fontTools/pens/basePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/basePen.py | MIT |
def addVarComponent(
self,
glyphName: str,
transformation: DecomposedTransform,
location: Dict[str, float],
) -> None:
"""Add a VarComponent sub glyph. The 'transformation' argument
must be a DecomposedTransform from the fontTools.misc.transform module,
and th... | Add a VarComponent sub glyph. The 'transformation' argument
must be a DecomposedTransform from the fontTools.misc.transform module,
and the 'location' argument must be a dictionary mapping axis tags
to their locations.
| addVarComponent | python | fonttools/fonttools | Lib/fontTools/pens/basePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/basePen.py | MIT |
def __init__(
self,
glyphSet,
*args,
skipMissingComponents=None,
reverseFlipped=False,
**kwargs,
):
"""Takes a 'glyphSet' argument (dict), in which the glyphs that are referenced
as components are looked up by their name.
If the optional 'reve... | Takes a 'glyphSet' argument (dict), in which the glyphs that are referenced
as components are looked up by their name.
If the optional 'reverseFlipped' argument is True, components whose transformation
matrix has a negative determinant will be decomposed with a reversed path direction
t... | __init__ | python | fonttools/fonttools | Lib/fontTools/pens/basePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/basePen.py | MIT |
def addComponent(self, glyphName, transformation):
"""Transform the points of the base glyph and draw it onto self."""
from fontTools.pens.transformPen import TransformPen
try:
glyph = self.glyphSet[glyphName]
except KeyError:
if not self.skipMissingComponents:
... | Transform the points of the base glyph and draw it onto self. | addComponent | python | fonttools/fonttools | Lib/fontTools/pens/basePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/basePen.py | MIT |
def _qCurveToOne(self, pt1, pt2):
"""This method implements the basic quadratic curve type. The
default implementation delegates the work to the cubic curve
function. Optionally override with a native implementation.
"""
pt0x, pt0y = self.__currentPoint
pt1x, pt1y = pt1
... | This method implements the basic quadratic curve type. The
default implementation delegates the work to the cubic curve
function. Optionally override with a native implementation.
| _qCurveToOne | python | fonttools/fonttools | Lib/fontTools/pens/basePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/basePen.py | MIT |
def decomposeSuperBezierSegment(points):
"""Split the SuperBezier described by 'points' into a list of regular
bezier segments. The 'points' argument must be a sequence with length
3 or greater, containing (x, y) coordinates. The last point is the
destination on-curve point, the rest of the points are o... | Split the SuperBezier described by 'points' into a list of regular
bezier segments. The 'points' argument must be a sequence with length
3 or greater, containing (x, y) coordinates. The last point is the
destination on-curve point, the rest of the points are off-curve points.
The start point should not ... | decomposeSuperBezierSegment | python | fonttools/fonttools | Lib/fontTools/pens/basePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/basePen.py | MIT |
def decomposeQuadraticSegment(points):
"""Split the quadratic curve segment described by 'points' into a list
of "atomic" quadratic segments. The 'points' argument must be a sequence
with length 2 or greater, containing (x, y) coordinates. The last point
is the destination on-curve point, the rest of th... | Split the quadratic curve segment described by 'points' into a list
of "atomic" quadratic segments. The 'points' argument must be a sequence
with length 2 or greater, containing (x, y) coordinates. The last point
is the destination on-curve point, the rest of the points are off-curve
points. The start p... | decomposeQuadraticSegment | python | fonttools/fonttools | Lib/fontTools/pens/basePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/basePen.py | MIT |
def outline(self, transform=None, evenOdd=False):
"""Converts the current contours to ``FT_Outline``.
Args:
transform: An optional 6-tuple containing an affine transformation,
or a ``Transform`` object from the ``fontTools.misc.transform``
module.
... | Converts the current contours to ``FT_Outline``.
Args:
transform: An optional 6-tuple containing an affine transformation,
or a ``Transform`` object from the ``fontTools.misc.transform``
module.
evenOdd: Pass ``True`` for even-odd fill instead of non-zero... | outline | python | fonttools/fonttools | Lib/fontTools/pens/freetypePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/freetypePen.py | MIT |
def bbox(self):
"""Computes the exact bounding box of an outline.
Returns:
A tuple of ``(xMin, yMin, xMax, yMax)``.
"""
bbox = FT_BBox()
outline = self.outline()
FT_Outline_Get_BBox(ctypes.byref(outline), ctypes.byref(bbox))
return (bbox.xMin / 64.0, ... | Computes the exact bounding box of an outline.
Returns:
A tuple of ``(xMin, yMin, xMax, yMax)``.
| bbox | python | fonttools/fonttools | Lib/fontTools/pens/freetypePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/freetypePen.py | MIT |
def setTestPoint(self, testPoint, evenOdd=False):
"""Set the point to test. Call this _before_ the outline gets drawn."""
self.testPoint = testPoint
self.evenOdd = evenOdd
self.firstPoint = None
self.intersectionCount = 0 | Set the point to test. Call this _before_ the outline gets drawn. | setTestPoint | python | fonttools/fonttools | Lib/fontTools/pens/pointInsidePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/pointInsidePen.py | MIT |
def getResult(self):
"""After the shape has been drawn, getResult() returns True if the test
point lies within the (black) shape, and False if it doesn't.
"""
winding = self.getWinding()
if self.evenOdd:
result = winding % 2
else: # non-zero
resul... | After the shape has been drawn, getResult() returns True if the test
point lies within the (black) shape, and False if it doesn't.
| getResult | python | fonttools/fonttools | Lib/fontTools/pens/pointInsidePen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/pointInsidePen.py | MIT |
def addPoint(
self,
pt: Tuple[float, float],
segmentType: Optional[str] = None,
smooth: bool = False,
name: Optional[str] = None,
identifier: Optional[str] = None,
**kwargs: Any,
) -> None:
"""Add a point to the current sub path."""
raise NotIm... | Add a point to the current sub path. | addPoint | python | fonttools/fonttools | Lib/fontTools/pens/pointPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/pointPen.py | MIT |
def addComponent(self, baseGlyphName, transformation, identifier=None, **kwargs):
"""Transform the points of the base glyph and draw it onto self.
The `identifier` parameter and any extra kwargs are ignored.
"""
from fontTools.pens.transformPen import TransformPointPen
try:
... | Transform the points of the base glyph and draw it onto self.
The `identifier` parameter and any extra kwargs are ignored.
| addComponent | python | fonttools/fonttools | Lib/fontTools/pens/pointPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/pointPen.py | MIT |
def lerpRecordings(recording1, recording2, factor=0.5):
"""Linearly interpolate between two recordings. The recordings
must be decomposed, i.e. they must not contain any components.
Factor is typically between 0 and 1. 0 means the first recording,
1 means the second recording, and 0.5 means the average... | Linearly interpolate between two recordings. The recordings
must be decomposed, i.e. they must not contain any components.
Factor is typically between 0 and 1. 0 means the first recording,
1 means the second recording, and 0.5 means the average of the
two recordings. Other values are possible, and can ... | lerpRecordings | python | fonttools/fonttools | Lib/fontTools/pens/recordingPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/recordingPen.py | MIT |
def reversedContour(contour, outputImpliedClosingLine=False):
"""Generator that takes a list of pen's (operator, operands) tuples,
and yields them with the winding direction reversed.
"""
if not contour:
return # nothing to do, stop iteration
# valid contours must have at least a starting ... | Generator that takes a list of pen's (operator, operands) tuples,
and yields them with the winding direction reversed.
| reversedContour | python | fonttools/fonttools | Lib/fontTools/pens/reverseContourPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/reverseContourPen.py | MIT |
def main(args):
"""Report font glyph shape geometricsl statistics"""
if args is None:
import sys
args = sys.argv[1:]
import argparse
parser = argparse.ArgumentParser(
"fonttools pens.statisticsPen",
description="Report font glyph shape geometricsl statistics",
)
... | Report font glyph shape geometricsl statistics | main | python | fonttools/fonttools | Lib/fontTools/pens/statisticsPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/statisticsPen.py | MIT |
def _moveTo(self, pt):
"""
>>> pen = SVGPathPen(None)
>>> pen.moveTo((0, 0))
>>> pen._commands
['M0 0']
>>> pen = SVGPathPen(None)
>>> pen.moveTo((10, 0))
>>> pen._commands
['M10 0']
>>> pen = SVGPathPen(None)
>>> pen.moveTo((0, 1... |
>>> pen = SVGPathPen(None)
>>> pen.moveTo((0, 0))
>>> pen._commands
['M0 0']
>>> pen = SVGPathPen(None)
>>> pen.moveTo((10, 0))
>>> pen._commands
['M10 0']
>>> pen = SVGPathPen(None)
>>> pen.moveTo((0, 10))
>>> pen._commands
... | _moveTo | python | fonttools/fonttools | Lib/fontTools/pens/svgPathPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/svgPathPen.py | MIT |
def _lineTo(self, pt):
"""
# duplicate point
>>> pen = SVGPathPen(None)
>>> pen.moveTo((10, 10))
>>> pen.lineTo((10, 10))
>>> pen._commands
['M10 10']
# vertical line
>>> pen = SVGPathPen(None)
>>> pen.moveTo((10, 10))
>>> pen.line... |
# duplicate point
>>> pen = SVGPathPen(None)
>>> pen.moveTo((10, 10))
>>> pen.lineTo((10, 10))
>>> pen._commands
['M10 10']
# vertical line
>>> pen = SVGPathPen(None)
>>> pen.moveTo((10, 10))
>>> pen.lineTo((10, 0))
>>> pen._comma... | _lineTo | python | fonttools/fonttools | Lib/fontTools/pens/svgPathPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/svgPathPen.py | MIT |
def _curveToOne(self, pt1, pt2, pt3):
"""
>>> pen = SVGPathPen(None)
>>> pen.curveTo((10, 20), (30, 40), (50, 60))
>>> pen._commands
['C10 20 30 40 50 60']
"""
t = "C"
t += pointToString(pt1, self._ntos) + " "
t += pointToString(pt2, self._ntos) + ... |
>>> pen = SVGPathPen(None)
>>> pen.curveTo((10, 20), (30, 40), (50, 60))
>>> pen._commands
['C10 20 30 40 50 60']
| _curveToOne | python | fonttools/fonttools | Lib/fontTools/pens/svgPathPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/svgPathPen.py | MIT |
def _qCurveToOne(self, pt1, pt2):
"""
>>> pen = SVGPathPen(None)
>>> pen.qCurveTo((10, 20), (30, 40))
>>> pen._commands
['Q10 20 30 40']
>>> from fontTools.misc.roundTools import otRound
>>> pen = SVGPathPen(None, ntos=lambda v: str(otRound(v)))
>>> pen.qC... |
>>> pen = SVGPathPen(None)
>>> pen.qCurveTo((10, 20), (30, 40))
>>> pen._commands
['Q10 20 30 40']
>>> from fontTools.misc.roundTools import otRound
>>> pen = SVGPathPen(None, ntos=lambda v: str(otRound(v)))
>>> pen.qCurveTo((3, 3), (7, 5), (11, 4))
>>> p... | _qCurveToOne | python | fonttools/fonttools | Lib/fontTools/pens/svgPathPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/svgPathPen.py | MIT |
def _closePath(self):
"""
>>> pen = SVGPathPen(None)
>>> pen.closePath()
>>> pen._commands
['Z']
"""
self._commands.append("Z")
self._lastCommand = "Z"
self._lastX = self._lastY = None |
>>> pen = SVGPathPen(None)
>>> pen.closePath()
>>> pen._commands
['Z']
| _closePath | python | fonttools/fonttools | Lib/fontTools/pens/svgPathPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/svgPathPen.py | MIT |
def _endPath(self):
"""
>>> pen = SVGPathPen(None)
>>> pen.endPath()
>>> pen._commands
[]
"""
self._lastCommand = None
self._lastX = self._lastY = None |
>>> pen = SVGPathPen(None)
>>> pen.endPath()
>>> pen._commands
[]
| _endPath | python | fonttools/fonttools | Lib/fontTools/pens/svgPathPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/svgPathPen.py | MIT |
def main(args=None):
"""Generate per-character SVG from font and text"""
if args is None:
import sys
args = sys.argv[1:]
from fontTools.ttLib import TTFont
import argparse
parser = argparse.ArgumentParser(
"fonttools pens.svgPathPen", description="Generate SVG from text"
... | Generate per-character SVG from font and text | main | python | fonttools/fonttools | Lib/fontTools/pens/svgPathPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/svgPathPen.py | MIT |
def __init__(self, outPen, transformation):
"""The 'outPen' argument is another pen object. It will receive the
transformed coordinates. The 'transformation' argument can either
be a six-tuple, or a fontTools.misc.transform.Transform object.
"""
super(TransformPen, self).__init__... | The 'outPen' argument is another pen object. It will receive the
transformed coordinates. The 'transformation' argument can either
be a six-tuple, or a fontTools.misc.transform.Transform object.
| __init__ | python | fonttools/fonttools | Lib/fontTools/pens/transformPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/transformPen.py | MIT |
def __init__(self, outPointPen, transformation):
"""The 'outPointPen' argument is another point pen object.
It will receive the transformed coordinates.
The 'transformation' argument can either be a six-tuple, or a
fontTools.misc.transform.Transform object.
"""
super().__... | The 'outPointPen' argument is another point pen object.
It will receive the transformed coordinates.
The 'transformation' argument can either be a six-tuple, or a
fontTools.misc.transform.Transform object.
| __init__ | python | fonttools/fonttools | Lib/fontTools/pens/transformPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/transformPen.py | MIT |
def glyph(
self,
componentFlags: int = 0x04,
dropImpliedOnCurves: bool = False,
*,
round: Callable[[float], int] = otRound,
) -> Glyph:
"""
Returns a :py:class:`~._g_l_y_f.Glyph` object representing the glyph.
Args:
componentFlags: Flags t... |
Returns a :py:class:`~._g_l_y_f.Glyph` object representing the glyph.
Args:
componentFlags: Flags to use for component glyphs. (default: 0x04)
dropImpliedOnCurves: Whether to remove implied-oncurve points. (default: False)
| glyph | python | fonttools/fonttools | Lib/fontTools/pens/ttGlyphPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/ttGlyphPen.py | MIT |
def addPoint(
self,
pt: Tuple[float, float],
segmentType: Optional[str] = None,
smooth: bool = False,
name: Optional[str] = None,
identifier: Optional[str] = None,
**kwargs: Any,
) -> None:
"""
Add a point to the current sub path.
"""
... |
Add a point to the current sub path.
| addPoint | python | fonttools/fonttools | Lib/fontTools/pens/ttGlyphPen.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/pens/ttGlyphPen.py | MIT |
def _main(args=None):
"""Convert an OpenType font from quadratic to cubic curves"""
parser = argparse.ArgumentParser(prog="qu2cu")
parser.add_argument("--version", action="version", version=fontTools.__version__)
parser.add_argument(
"infiles",
nargs="+",
metavar="INPUT",
... | Convert an OpenType font from quadratic to cubic curves | _main | python | fonttools/fonttools | Lib/fontTools/qu2cu/cli.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/qu2cu/cli.py | MIT |
def elevate_quadratic(p0, p1, p2):
"""Given a quadratic bezier curve, return its degree-elevated cubic."""
# https://pomax.github.io/bezierinfo/#reordering
p1_2_3 = p1 * (2 / 3)
return (
p0,
(p0 * (1 / 3) + p1_2_3),
(p2 * (1 / 3) + p1_2_3),
p2,
) | Given a quadratic bezier curve, return its degree-elevated cubic. | elevate_quadratic | python | fonttools/fonttools | Lib/fontTools/qu2cu/qu2cu.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/qu2cu/qu2cu.py | MIT |
def merge_curves(curves, start, n):
"""Give a cubic-Bezier spline, reconstruct one cubic-Bezier
that has the same endpoints and tangents and approxmates
the spline."""
# Reconstruct the t values of the cut segments
prod_ratio = 1.0
sum_ratio = 1.0
ts = [1]
for k in range(1, n):
... | Give a cubic-Bezier spline, reconstruct one cubic-Bezier
that has the same endpoints and tangents and approxmates
the spline. | merge_curves | python | fonttools/fonttools | Lib/fontTools/qu2cu/qu2cu.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/qu2cu/qu2cu.py | MIT |
def quadratic_to_curves(
quads: List[List[Point]],
max_err: float = 0.5,
all_cubic: bool = False,
) -> List[Tuple[Point, ...]]:
"""Converts a connecting list of quadratic splines to a list of quadratic
and cubic curves.
A quadratic spline is specified as a list of points. Either each point is
... | Converts a connecting list of quadratic splines to a list of quadratic
and cubic curves.
A quadratic spline is specified as a list of points. Either each point is
a 2-tuple of X,Y coordinates, or each point is a complex number with
real/imaginary components representing X,Y coordinates.
The first... | quadratic_to_curves | python | fonttools/fonttools | Lib/fontTools/qu2cu/qu2cu.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/qu2cu/qu2cu.py | MIT |
def spline_to_curves(q, costs, tolerance=0.5, all_cubic=False):
"""
q: quadratic spline with alternating on-curve / off-curve points.
costs: cumulative list of encoding cost of q in terms of number of
points that need to be encoded. Implied on-curve points do not
contribute to the cost. If all... |
q: quadratic spline with alternating on-curve / off-curve points.
costs: cumulative list of encoding cost of q in terms of number of
points that need to be encoded. Implied on-curve points do not
contribute to the cost. If all points need to be encoded, then
costs will be range(1, len(q)+1)... | spline_to_curves | python | fonttools/fonttools | Lib/fontTools/qu2cu/qu2cu.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/qu2cu/qu2cu.py | MIT |
def subset(self, glyphs):
"""Returns ascending list of remaining coverage values."""
indices = self.intersect(glyphs)
self.glyphs = [g for g in self.glyphs if g in glyphs]
return indices | Returns ascending list of remaining coverage values. | subset | python | fonttools/fonttools | Lib/fontTools/subset/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/subset/__init__.py | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.