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 traverse(self, colr: COLR, callback): """Depth-first traversal of graph rooted at self, callback on each node.""" if not callable(callback): raise TypeError("callback must be callable") for path in dfs_base_table( self, iter_subtables_fn=lambda paint: paint.iterPaint...
Depth-first traversal of graph rooted at self, callback on each node.
traverse
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/otTables.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/otTables.py
MIT
def fixLookupOverFlows(ttf, overflowRecord): """Either the offset from the LookupList to a lookup overflowed, or an offset from a lookup to a subtable overflowed. The table layout is:: GPSO/GUSB Script List Feature List LookUpList Looku...
Either the offset from the LookupList to a lookup overflowed, or an offset from a lookup to a subtable overflowed. The table layout is:: GPSO/GUSB Script List Feature List LookUpList Lookup[0] and contents SubT...
fixLookupOverFlows
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/otTables.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/otTables.py
MIT
def fixSubTableOverFlows(ttf, overflowRecord): """ An offset has overflowed within a sub-table. We need to divide this subtable into smaller parts. """ table = ttf[overflowRecord.tableType].table lookup = table.LookupList.Lookup[overflowRecord.LookupListIndex] subIndex = overflowRecord.SubTableI...
An offset has overflowed within a sub-table. We need to divide this subtable into smaller parts.
fixSubTableOverFlows
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/otTables.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/otTables.py
MIT
def dfs_base_table( root: BaseTable, root_accessor: Optional[str] = None, skip_root: bool = False, predicate: Optional[Callable[[SubTablePath], bool]] = None, iter_subtables_fn: Optional[ Callable[[BaseTable], Iterable[BaseTable.SubTableEntry]] ] = None, ) -> Iterable[SubTablePath]: ...
Depth-first search tree of BaseTables. Args: root (BaseTable): the root of the tree. root_accessor (Optional[str]): attribute name for the root table, if any (mostly useful for debugging). skip_root (Optional[bool]): if True, the root itself is not visited, only its ...
dfs_base_table
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/otTraverse.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/otTraverse.py
MIT
def bfs_base_table( root: BaseTable, root_accessor: Optional[str] = None, skip_root: bool = False, predicate: Optional[Callable[[SubTablePath], bool]] = None, iter_subtables_fn: Optional[ Callable[[BaseTable], Iterable[BaseTable.SubTableEntry]] ] = None, ) -> Iterable[SubTablePath]: ...
Breadth-first search tree of BaseTables. Args: root the root of the tree. root_accessor (Optional[str]): attribute name for the root table, if any (mostly useful for debugging). skip_root (Optional[bool]): if True, the root itself is not visited, only its ...
bfs_base_table
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/otTraverse.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/otTraverse.py
MIT
def getUnicodeRanges(self): """Return the set of 'ulUnicodeRange*' bits currently enabled.""" bits = set() ul1, ul2 = self.ulUnicodeRange1, self.ulUnicodeRange2 ul3, ul4 = self.ulUnicodeRange3, self.ulUnicodeRange4 for i in range(32): if ul1 & (1 << i): ...
Return the set of 'ulUnicodeRange*' bits currently enabled.
getUnicodeRanges
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/O_S_2f_2.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/O_S_2f_2.py
MIT
def setUnicodeRanges(self, bits): """Set the 'ulUnicodeRange*' fields to the specified 'bits'.""" ul1, ul2, ul3, ul4 = 0, 0, 0, 0 for bit in bits: if 0 <= bit < 32: ul1 |= 1 << bit elif 32 <= bit < 64: ul2 |= 1 << (bit - 32) eli...
Set the 'ulUnicodeRange*' fields to the specified 'bits'.
setUnicodeRanges
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/O_S_2f_2.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/O_S_2f_2.py
MIT
def recalcUnicodeRanges(self, ttFont, pruneOnly=False): """Intersect the codepoints in the font's Unicode cmap subtables with the Unicode block ranges defined in the OpenType specification (v1.7), and set the respective 'ulUnicodeRange*' bits if there is at least ONE intersection. ...
Intersect the codepoints in the font's Unicode cmap subtables with the Unicode block ranges defined in the OpenType specification (v1.7), and set the respective 'ulUnicodeRange*' bits if there is at least ONE intersection. If 'pruneOnly' is True, only clear unused bits with NO intersecti...
recalcUnicodeRanges
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/O_S_2f_2.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/O_S_2f_2.py
MIT
def getCodePageRanges(self): """Return the set of 'ulCodePageRange*' bits currently enabled.""" bits = set() if self.version < 1: return bits ul1, ul2 = self.ulCodePageRange1, self.ulCodePageRange2 for i in range(32): if ul1 & (1 << i): bit...
Return the set of 'ulCodePageRange*' bits currently enabled.
getCodePageRanges
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/O_S_2f_2.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/O_S_2f_2.py
MIT
def setCodePageRanges(self, bits): """Set the 'ulCodePageRange*' fields to the specified 'bits'.""" ul1, ul2 = 0, 0 for bit in bits: if 0 <= bit < 32: ul1 |= 1 << bit elif 32 <= bit < 64: ul2 |= 1 << (bit - 32) else: ...
Set the 'ulCodePageRange*' fields to the specified 'bits'.
setCodePageRanges
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/O_S_2f_2.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/O_S_2f_2.py
MIT
def recalcAvgCharWidth(self, ttFont): """Recalculate xAvgCharWidth using metrics from ttFont's 'hmtx' table. Set it to 0 if the unlikely event 'hmtx' table is not found. """ avg_width = 0 hmtx = ttFont.get("hmtx") if hmtx is not None: widths = [width for widt...
Recalculate xAvgCharWidth using metrics from ttFont's 'hmtx' table. Set it to 0 if the unlikely event 'hmtx' table is not found.
recalcAvgCharWidth
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/O_S_2f_2.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/O_S_2f_2.py
MIT
def intersectUnicodeRanges(unicodes, inverse=False): """Intersect a sequence of (int) Unicode codepoints with the Unicode block ranges defined in the OpenType specification v1.7, and return the set of 'ulUnicodeRanges' bits for which there is at least ONE intersection. If 'inverse' is True, return the t...
Intersect a sequence of (int) Unicode codepoints with the Unicode block ranges defined in the OpenType specification v1.7, and return the set of 'ulUnicodeRanges' bits for which there is at least ONE intersection. If 'inverse' is True, return the the bits for which there is NO intersection. >>> interse...
intersectUnicodeRanges
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/O_S_2f_2.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/O_S_2f_2.py
MIT
def __bool__(self) -> bool: """ >>> p = Program() >>> bool(p) False >>> bc = array.array("B", [0]) >>> p.fromBytecode(bc) >>> bool(p) True >>> p.bytecode.pop() 0 >>> bool(p) False >>> p = Program() >>> asm =...
>>> p = Program() >>> bool(p) False >>> bc = array.array("B", [0]) >>> p.fromBytecode(bc) >>> bool(p) True >>> p.bytecode.pop() 0 >>> bool(p) False >>> p = Program() >>> asm = ['SVTCA[0]'] >>> p.fromAssembl...
__bool__
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/ttProgram.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/ttProgram.py
MIT
def decompileDeltas_(numDeltas, data, offset=0): """(numDeltas, data, offset) --> ([delta, delta, ...], newOffset)""" result = [] pos = offset while len(result) < numDeltas if numDeltas is not None else pos < len(data): runHeader = data[pos] pos += 1 n...
(numDeltas, data, offset) --> ([delta, delta, ...], newOffset)
decompileDeltas_
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/TupleVariation.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/TupleVariation.py
MIT
def getCoordWidth(self): """Return 2 if coordinates are (x, y) as in gvar, 1 if single values as in cvar, or 0 if empty. """ firstDelta = next((c for c in self.coordinates if c is not None), None) if firstDelta is None: return 0 # empty or has no impact if ty...
Return 2 if coordinates are (x, y) as in gvar, 1 if single values as in cvar, or 0 if empty.
getCoordWidth
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/TupleVariation.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/TupleVariation.py
MIT
def _getOffsets(self): """ Calculate offsets to VDMX_Group records. For each ratRange return a list of offset values from the beginning of the VDMX table to a VDMX_Group. """ lenHeader = sstruct.calcsize(VDMX_HeaderFmt) lenRatRange = sstruct.calcsize(VDMX_RatRange...
Calculate offsets to VDMX_Group records. For each ratRange return a list of offset values from the beginning of the VDMX table to a VDMX_Group.
_getOffsets
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/V_D_M_X_.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/V_D_M_X_.py
MIT
def getcmap(self, platformID, platEncID): """Returns the first subtable which matches the given platform and encoding. Args: platformID (int): The platform ID. Use 0 for Unicode, 1 for Macintosh (deprecated for new fonts), 2 for ISO (deprecated) and 3 for Windows...
Returns the first subtable which matches the given platform and encoding. Args: platformID (int): The platform ID. Use 0 for Unicode, 1 for Macintosh (deprecated for new fonts), 2 for ISO (deprecated) and 3 for Windows. encodingID (int): Encoding ID. Inte...
getcmap
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_c_m_a_p.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_c_m_a_p.py
MIT
def buildReversed(self): """Builds a reverse mapping dictionary Iterates over all Unicode cmap tables and returns a dictionary mapping glyphs to sets of codepoints, such as:: { 'one': {0x31} 'A': {0x41,0x391} } ...
Builds a reverse mapping dictionary Iterates over all Unicode cmap tables and returns a dictionary mapping glyphs to sets of codepoints, such as:: { 'one': {0x31} 'A': {0x41,0x391} } The values are sets of Unicode...
buildReversed
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_c_m_a_p.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_c_m_a_p.py
MIT
def isUnicode(self): """Returns true if the characters are interpreted as Unicode codepoints.""" return self.platformID == 0 or ( self.platformID == 3 and self.platEncID in [0, 1, 10] )
Returns true if the characters are interpreted as Unicode codepoints.
isUnicode
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_c_m_a_p.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_c_m_a_p.py
MIT
def setGlyphOrder(self, glyphOrder): """Sets the glyph order Args: glyphOrder ([str]): List of glyph names in order. """ self.glyphOrder = glyphOrder self._reverseGlyphOrder = {}
Sets the glyph order Args: glyphOrder ([str]): List of glyph names in order.
setGlyphOrder
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def getGlyphID(self, glyphName): """Returns the ID of the glyph with the given name. Raises a ``ValueError`` if the glyph is not found in the font. """ glyphOrder = self.glyphOrder id = getattr(self, "_reverseGlyphOrder", {}).get(glyphName) if id is None or id >= len(gly...
Returns the ID of the glyph with the given name. Raises a ``ValueError`` if the glyph is not found in the font.
getGlyphID
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def _getPhantomPoints(self, glyphName, hMetrics, vMetrics=None): """Compute the four "phantom points" for the given glyph from its bounding box and the horizontal and vertical advance widths and sidebearings stored in the ttFont's "hmtx" and "vmtx" tables. 'hMetrics' should be ttFont['h...
Compute the four "phantom points" for the given glyph from its bounding box and the horizontal and vertical advance widths and sidebearings stored in the ttFont's "hmtx" and "vmtx" tables. 'hMetrics' should be ttFont['hmtx'].metrics. 'vMetrics' should be ttFont['vmtx'].metrics if there...
_getPhantomPoints
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def _getCoordinatesAndControls( self, glyphName, hMetrics, vMetrics=None, *, round=otRound ): """Return glyph coordinates and controls as expected by "gvar" table. The coordinates includes four "phantom points" for the glyph metrics, as mandated by the "gvar" spec. The glyp...
Return glyph coordinates and controls as expected by "gvar" table. The coordinates includes four "phantom points" for the glyph metrics, as mandated by the "gvar" spec. The glyph controls is a namedtuple with the following attributes: - numberOfContours: -1 for composite glyphs...
_getCoordinatesAndControls
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def _setCoordinates(self, glyphName, coord, hMetrics, vMetrics=None): """Set coordinates and metrics for the given glyph. "coord" is an array of GlyphCoordinates which must include the "phantom points" as the last four coordinates. Both the horizontal/vertical advances and left/top sid...
Set coordinates and metrics for the given glyph. "coord" is an array of GlyphCoordinates which must include the "phantom points" as the last four coordinates. Both the horizontal/vertical advances and left/top sidebearings in "hmtx" and "vmtx" tables (if any) are updated from four phan...
_setCoordinates
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def _synthesizeVMetrics(self, glyphName, ttFont, defaultVerticalOrigin): """This method is wrong and deprecated. For rationale see: https://github.com/fonttools/fonttools/pull/2266/files#r613569473 """ vMetrics = getattr(ttFont.get("vmtx"), "metrics", None) if vMetrics is...
This method is wrong and deprecated. For rationale see: https://github.com/fonttools/fonttools/pull/2266/files#r613569473
_synthesizeVMetrics
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def getPhantomPoints(self, glyphName, ttFont, defaultVerticalOrigin=None): """Old public name for self._getPhantomPoints(). See: https://github.com/fonttools/fonttools/pull/2266""" hMetrics = ttFont["hmtx"].metrics vMetrics = self._synthesizeVMetrics(glyphName, ttFont, defaultVerticalOri...
Old public name for self._getPhantomPoints(). See: https://github.com/fonttools/fonttools/pull/2266
getPhantomPoints
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def getCoordinatesAndControls(self, glyphName, ttFont, defaultVerticalOrigin=None): """Old public name for self._getCoordinatesAndControls(). See: https://github.com/fonttools/fonttools/pull/2266""" hMetrics = ttFont["hmtx"].metrics vMetrics = self._synthesizeVMetrics(glyphName, ttFont, ...
Old public name for self._getCoordinatesAndControls(). See: https://github.com/fonttools/fonttools/pull/2266
getCoordinatesAndControls
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def setCoordinates(self, glyphName, ttFont): """Old public name for self._setCoordinates(). See: https://github.com/fonttools/fonttools/pull/2266""" hMetrics = ttFont["hmtx"].metrics vMetrics = getattr(ttFont.get("vmtx"), "metrics", None) self._setCoordinates(glyphName, hMetrics,...
Old public name for self._setCoordinates(). See: https://github.com/fonttools/fonttools/pull/2266
setCoordinates
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def flagBest(x, y, onCurve): """For a given x,y delta pair, returns the flag that packs this pair most efficiently, as well as the number of byte cost of such flag.""" flag = flagOnCurve if onCurve else 0 cost = 0 # do x if x == 0: flag = flag | flagXsame elif -255 <= x <= 255: ...
For a given x,y delta pair, returns the flag that packs this pair most efficiently, as well as the number of byte cost of such flag.
flagBest
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def recalcBounds(self, glyfTable, *, boundsDone=None): """Recalculates the bounds of the glyph. Each glyph object stores its bounding box in the ``xMin``/``yMin``/``xMax``/``yMax`` attributes. These bounds must be recomputed when the ``coordinates`` change. The ``table__g_l_y_f`` bounds...
Recalculates the bounds of the glyph. Each glyph object stores its bounding box in the ``xMin``/``yMin``/``xMax``/``yMax`` attributes. These bounds must be recomputed when the ``coordinates`` change. The ``table__g_l_y_f`` bounds must be provided to resolve component bounds.
recalcBounds
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def tryRecalcBoundsComposite(self, glyfTable, *, boundsDone=None): """Try recalculating the bounds of a composite glyph that has certain constrained properties. Namely, none of the components have a transform other than an integer translate, and none uses the anchor points. Each...
Try recalculating the bounds of a composite glyph that has certain constrained properties. Namely, none of the components have a transform other than an integer translate, and none uses the anchor points. Each glyph object stores its bounding box in the ``xMin``/``yMin``/``xMax`...
tryRecalcBoundsComposite
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def getCoordinates(self, glyfTable, *, round=noRound): """Return the coordinates, end points and flags This method returns three values: A :py:class:`GlyphCoordinates` object, a list of the indexes of the final points of each contour (allowing you to split up the coordinates list into c...
Return the coordinates, end points and flags This method returns three values: A :py:class:`GlyphCoordinates` object, a list of the indexes of the final points of each contour (allowing you to split up the coordinates list into contours) and a list of flags. On simple glyphs, this meth...
getCoordinates
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def getComponentNames(self, glyfTable): """Returns a list of names of component glyphs used in this glyph This method can be used on simple glyphs (in which case it returns an empty list) or composite glyphs. """ if not hasattr(self, "data"): if self.isComposite(): ...
Returns a list of names of component glyphs used in this glyph This method can be used on simple glyphs (in which case it returns an empty list) or composite glyphs.
getComponentNames
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def trim(self, remove_hinting=False): """Remove padding and, if requested, hinting, from a glyph. This works on both expanded and compacted glyphs, without expanding it.""" if not hasattr(self, "data"): if remove_hinting: if self.isComposite(): ...
Remove padding and, if requested, hinting, from a glyph. This works on both expanded and compacted glyphs, without expanding it.
trim
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def draw(self, pen, glyfTable, offset=0): """Draws the glyph using the supplied pen object. Arguments: pen: An object conforming to the pen protocol. glyfTable: A :py:class:`table__g_l_y_f` object, to resolve components. offset (int): A horizontal offset....
Draws the glyph using the supplied pen object. Arguments: pen: An object conforming to the pen protocol. glyfTable: A :py:class:`table__g_l_y_f` object, to resolve components. offset (int): A horizontal offset. If provided, all coordinates are ...
draw
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def drawPoints(self, pen, glyfTable, offset=0): """Draw the glyph using the supplied pointPen. As opposed to Glyph.draw(), this will not change the point indices. """ if self.isComposite(): for component in self.components: glyphName, transform = component.ge...
Draw the glyph using the supplied pointPen. As opposed to Glyph.draw(), this will not change the point indices.
drawPoints
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def dropImpliedOnCurvePoints(*interpolatable_glyphs: Glyph) -> Set[int]: """Drop impliable on-curve points from the (simple) glyph or glyphs. In TrueType glyf outlines, on-curve points can be implied when they are located at the midpoint of the line connecting two consecutive off-curve points. If more...
Drop impliable on-curve points from the (simple) glyph or glyphs. In TrueType glyf outlines, on-curve points can be implied when they are located at the midpoint of the line connecting two consecutive off-curve points. If more than one glyphs are passed, these are assumed to be interpolatable masters ...
dropImpliedOnCurvePoints
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def getComponentInfo(self): """Return information about the component This method returns a tuple of two values: the glyph name of the component's base glyph, and a transformation matrix. As opposed to accessing the attributes directly, ``getComponentInfo`` always returns a six-element ...
Return information about the component This method returns a tuple of two values: the glyph name of the component's base glyph, and a transformation matrix. As opposed to accessing the attributes directly, ``getComponentInfo`` always returns a six-element tuple of the component's transf...
getComponentInfo
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def _hasOnlyIntegerTranslate(self): """Return True if it's a 'simple' component. That is, it has no anchor points and no transform other than integer translate. """ return ( not hasattr(self, "firstPt") and not hasattr(self, "transform") and float(sel...
Return True if it's a 'simple' component. That is, it has no anchor points and no transform other than integer translate.
_hasOnlyIntegerTranslate
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def zeros(count): """Creates a new ``GlyphCoordinates`` object with all coordinates set to (0,0)""" g = GlyphCoordinates() g._a.frombytes(bytes(count * 2 * g._a.itemsize)) return g
Creates a new ``GlyphCoordinates`` object with all coordinates set to (0,0)
zeros
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def copy(self): """Creates a new ``GlyphCoordinates`` object which is a copy of the current one.""" c = GlyphCoordinates() c._a.extend(self._a) return c
Creates a new ``GlyphCoordinates`` object which is a copy of the current one.
copy
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def __setitem__(self, k, v): """Sets a point's coordinates to a two element tuple (x,y)""" if isinstance(k, slice): indices = range(*k.indices(len(self))) # XXX This only works if len(v) == len(indices) for j, i in enumerate(indices): self[i] = v[j] ...
Sets a point's coordinates to a two element tuple (x,y)
__setitem__
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def __eq__(self, other): """ >>> g = GlyphCoordinates([(1,2)]) >>> g2 = GlyphCoordinates([(1.0,2)]) >>> g3 = GlyphCoordinates([(1.5,2)]) >>> g == g2 True >>> g == g3 False >>> g2 == g3 False """ if type(self) != type(other):...
>>> g = GlyphCoordinates([(1,2)]) >>> g2 = GlyphCoordinates([(1.0,2)]) >>> g3 = GlyphCoordinates([(1.5,2)]) >>> g == g2 True >>> g == g3 False >>> g2 == g3 False
__eq__
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def __ne__(self, other): """ >>> g = GlyphCoordinates([(1,2)]) >>> g2 = GlyphCoordinates([(1.0,2)]) >>> g3 = GlyphCoordinates([(1.5,2)]) >>> g != g2 False >>> g != g3 True >>> g2 != g3 True """ result = self.__eq__(other) ...
>>> g = GlyphCoordinates([(1,2)]) >>> g2 = GlyphCoordinates([(1.0,2)]) >>> g3 = GlyphCoordinates([(1.5,2)]) >>> g != g2 False >>> g != g3 True >>> g2 != g3 True
__ne__
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_l_y_f.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_l_y_f.py
MIT
def compileOffsets_(offsets): """Packs a list of offsets into a 'gvar' offset table. Returns a pair (bytestring, tableFormat). Bytestring is the packed offset table. Format indicates whether the table uses short (tableFormat=0) or long (tableFormat=1) integers. The returned tabl...
Packs a list of offsets into a 'gvar' offset table. Returns a pair (bytestring, tableFormat). Bytestring is the packed offset table. Format indicates whether the table uses short (tableFormat=0) or long (tableFormat=1) integers. The returned tableFormat should get packed into the flags ...
compileOffsets_
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_g_v_a_r.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_g_v_a_r.py
MIT
def addTag(self, tag): """Add 'tag' to the list of langauge tags if not already there. Returns the integer index of 'tag' in the list of all tags. """ try: return self.tags.index(tag) except ValueError: self.tags.append(tag) return len(self.ta...
Add 'tag' to the list of langauge tags if not already there. Returns the integer index of 'tag' in the list of all tags.
addTag
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_l_t_a_g.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_l_t_a_g.py
MIT
def recalc(self, ttFont): """Recalculate the font bounding box, and most other maxp values except for the TT instructions values. Also recalculate the value of bit 1 of the flags field and the font bounding box of the 'head' table. """ glyfTable = ttFont["glyf"] hmtxTable...
Recalculate the font bounding box, and most other maxp values except for the TT instructions values. Also recalculate the value of bit 1 of the flags field and the font bounding box of the 'head' table.
recalc
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_m_a_x_p.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_m_a_x_p.py
MIT
def setName(self, string, nameID, platformID, platEncID, langID): """Set the 'string' for the name record identified by 'nameID', 'platformID', 'platEncID' and 'langID'. If a record with that nameID doesn't exist, create it and append to the name table. 'string' can be of type `str` (`u...
Set the 'string' for the name record identified by 'nameID', 'platformID', 'platEncID' and 'langID'. If a record with that nameID doesn't exist, create it and append to the name table. 'string' can be of type `str` (`unicode` in PY2) or `bytes`. In the latter case, it is assumed to be a...
setName
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_n_a_m_e.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_n_a_m_e.py
MIT
def removeNames(self, nameID=None, platformID=None, platEncID=None, langID=None): """Remove any name records identified by the given combination of 'nameID', 'platformID', 'platEncID' and 'langID'. """ args = { argName: argValue for argName, argValue in ( ...
Remove any name records identified by the given combination of 'nameID', 'platformID', 'platEncID' and 'langID'.
removeNames
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_n_a_m_e.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_n_a_m_e.py
MIT
def removeUnusedNames(ttFont): """Remove any name records which are not in NameID range 0-255 and not utilized within the font itself.""" visitor = NameRecordVisitor() visitor.visit(ttFont) toDelete = set() for record in ttFont["name"].names: # Name IDs 26 to ...
Remove any name records which are not in NameID range 0-255 and not utilized within the font itself.
removeUnusedNames
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_n_a_m_e.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_n_a_m_e.py
MIT
def _findUnusedNameID(self, minNameID=256): """Finds an unused name id. The nameID is assigned in the range between 'minNameID' and 32767 (inclusive), following the last nameID in the name table. """ names = self.names nameID = 1 + max([n.nameID for n in names] + [minNam...
Finds an unused name id. The nameID is assigned in the range between 'minNameID' and 32767 (inclusive), following the last nameID in the name table.
_findUnusedNameID
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_n_a_m_e.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_n_a_m_e.py
MIT
def addName(self, string, platforms=((1, 0, 0), (3, 1, 0x409)), minNameID=255): """Add a new name record containing 'string' for each (platformID, platEncID, langID) tuple specified in the 'platforms' list. The nameID is assigned in the range between 'minNameID'+1 and 32767 (inclusive), ...
Add a new name record containing 'string' for each (platformID, platEncID, langID) tuple specified in the 'platforms' list. The nameID is assigned in the range between 'minNameID'+1 and 32767 (inclusive), following the last nameID in the name table. If no 'platforms' are specified, two ...
addName
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_n_a_m_e.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_n_a_m_e.py
MIT
def _makeWindowsName(name, nameID, language): """Create a NameRecord for the Microsoft Windows platform 'language' is an arbitrary IETF BCP 47 language identifier such as 'en', 'de-CH', 'de-AT-1901', or 'fa-Latn'. If Microsoft Windows does not support the desired language, the result will be None. ...
Create a NameRecord for the Microsoft Windows platform 'language' is an arbitrary IETF BCP 47 language identifier such as 'en', 'de-CH', 'de-AT-1901', or 'fa-Latn'. If Microsoft Windows does not support the desired language, the result will be None. Future versions of fonttools might return a NameRecor...
_makeWindowsName
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_n_a_m_e.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_n_a_m_e.py
MIT
def toUnicode(self, errors="strict"): """ If self.string is a Unicode string, return it; otherwise try decoding the bytes in self.string to a Unicode string using the encoding of this entry as returned by self.getEncoding(); Note that self.getEncoding() returns 'ascii' if the en...
If self.string is a Unicode string, return it; otherwise try decoding the bytes in self.string to a Unicode string using the encoding of this entry as returned by self.getEncoding(); Note that self.getEncoding() returns 'ascii' if the encoding is unknown to the library. Certai...
toUnicode
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_n_a_m_e.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_n_a_m_e.py
MIT
def getGlyphOrder(self): """This function will get called by a ttLib.TTFont instance. Do not call this function yourself, use TTFont().getGlyphOrder() or its relatives instead! """ if not hasattr(self, "glyphOrder"): raise ttLib.TTLibError("illegal use of getGlyphOrde...
This function will get called by a ttLib.TTFont instance. Do not call this function yourself, use TTFont().getGlyphOrder() or its relatives instead!
getGlyphOrder
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/_p_o_s_t.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/_p_o_s_t.py
MIT
def _moduleFinderHint(): """Dummy function to let modulefinder know what tables may be dynamically imported. Generated by MetaTools/buildTableList.py. >>> _moduleFinderHint() """ from . import B_A_S_E_ from . import C_B_D_T_ from . import C_B_L_C_ from . import C_F_F_ from . imp...
Dummy function to let modulefinder know what tables may be dynamically imported. Generated by MetaTools/buildTableList.py. >>> _moduleFinderHint()
_moduleFinderHint
python
fonttools/fonttools
Lib/fontTools/ttLib/tables/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ttLib/tables/__init__.py
MIT
def convertUFO1OrUFO2KerningToUFO3Kerning(kerning, groups, glyphSet=()): """Convert kerning data in UFO1 or UFO2 syntax into UFO3 syntax. Args: kerning: A dictionary containing the kerning rules defined in the UFO font, as used in :class:`.UFOReader` objects. groups: A...
Convert kerning data in UFO1 or UFO2 syntax into UFO3 syntax. Args: kerning: A dictionary containing the kerning rules defined in the UFO font, as used in :class:`.UFOReader` objects. groups: A dictionary containing the groups defined in the UFO font, as used in ...
convertUFO1OrUFO2KerningToUFO3Kerning
python
fonttools/fonttools
Lib/fontTools/ufoLib/converters.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/converters.py
MIT
def findKnownKerningGroups(groups): """Find all kerning groups in a UFO1 or UFO2 font that use known prefixes. In some cases, not all kerning groups will be referenced by the kerning pairs in a UFO. The algorithm for locating groups in :func:`convertUFO1OrUFO2KerningToUFO3Kerning` will miss these u...
Find all kerning groups in a UFO1 or UFO2 font that use known prefixes. In some cases, not all kerning groups will be referenced by the kerning pairs in a UFO. The algorithm for locating groups in :func:`convertUFO1OrUFO2KerningToUFO3Kerning` will miss these unreferenced groups. By scanning for known p...
findKnownKerningGroups
python
fonttools/fonttools
Lib/fontTools/ufoLib/converters.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/converters.py
MIT
def makeUniqueGroupName(name, groupNames, counter=0): """Make a kerning group name that will be unique within the set of group names. If the requested kerning group name already exists within the set, this will return a new name by adding an incremented counter to the end of the requested name. Ar...
Make a kerning group name that will be unique within the set of group names. If the requested kerning group name already exists within the set, this will return a new name by adding an incremented counter to the end of the requested name. Args: name: The requested kerning group name....
makeUniqueGroupName
python
fonttools/fonttools
Lib/fontTools/ufoLib/converters.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/converters.py
MIT
def test(): """ Tests for :func:`.convertUFO1OrUFO2KerningToUFO3Kerning`. No known prefixes. >>> testKerning = { ... "A" : { ... "A" : 1, ... "B" : 2, ... "CGroup" : 3, ... "DGroup" : 4 ... }, ... "BGroup" : { ... "A" ...
Tests for :func:`.convertUFO1OrUFO2KerningToUFO3Kerning`. No known prefixes. >>> testKerning = { ... "A" : { ... "A" : 1, ... "B" : 2, ... "CGroup" : 3, ... "DGroup" : 4 ... }, ... "BGroup" : { ... "A" : 5, ... ...
test
python
fonttools/fonttools
Lib/fontTools/ufoLib/converters.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/converters.py
MIT
def handleClash1(userName, existing=[], prefix="", suffix=""): """A helper function that resolves collisions with existing names when choosing a filename. This function attempts to append an unused integer counter to the filename. Args: userName (str): The input file name. ...
A helper function that resolves collisions with existing names when choosing a filename. This function attempts to append an unused integer counter to the filename. Args: userName (str): The input file name. existing: A case-insensitive list of all existing file names. ...
handleClash1
python
fonttools/fonttools
Lib/fontTools/ufoLib/filenames.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/filenames.py
MIT
def handleClash2(existing=[], prefix="", suffix=""): """A helper function that resolves collisions with existing names when choosing a filename. This function is a fallback to :func:`handleClash1`. It attempts to append an unused integer counter to the filename. Args: userName (str): T...
A helper function that resolves collisions with existing names when choosing a filename. This function is a fallback to :func:`handleClash1`. It attempts to append an unused integer counter to the filename. Args: userName (str): The input file name. existing: A case-insensi...
handleClash2
python
fonttools/fonttools
Lib/fontTools/ufoLib/filenames.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/filenames.py
MIT
def draw(self, pen, outputImpliedClosingLine=False): """ Draw this glyph onto a *FontTools* Pen. """ pointPen = PointToSegmentPen( pen, outputImpliedClosingLine=outputImpliedClosingLine ) self.drawPoints(pointPen)
Draw this glyph onto a *FontTools* Pen.
draw
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def __init__( self, path, glyphNameToFileNameFunc=None, ufoFormatVersion=None, validateRead=True, validateWrite=True, expectContentsFile=False, ): """ 'path' should be a path (string) to an existing local directory, or an instance of fs...
'path' should be a path (string) to an existing local directory, or an instance of fs.base.FS class. The optional 'glyphNameToFileNameFunc' argument must be a callback function that takes two arguments: a glyph name and a list of all existing filenames (if any exist). It should...
__init__
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def rebuildContents(self, validateRead=None): """ Rebuild the contents dict by loading contents.plist. ``validateRead`` will validate the data, by default it is set to the class's ``validateRead`` value, can be overridden. """ if validateRead is None: validat...
Rebuild the contents dict by loading contents.plist. ``validateRead`` will validate the data, by default it is set to the class's ``validateRead`` value, can be overridden.
rebuildContents
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def getReverseContents(self): """ Return a reversed dict of self.contents, mapping file names to glyph names. This is primarily an aid for custom glyph name to file name schemes that want to make sure they don't generate duplicate file names. The file names are converted to lower...
Return a reversed dict of self.contents, mapping file names to glyph names. This is primarily an aid for custom glyph name to file name schemes that want to make sure they don't generate duplicate file names. The file names are converted to lowercase so we can reliably check for...
getReverseContents
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def readLayerInfo(self, info, validateRead=None): """ ``validateRead`` will validate the data, by default it is set to the class's ``validateRead`` value, can be overridden. """ if validateRead is None: validateRead = self._validateRead infoDict = self._getPli...
``validateRead`` will validate the data, by default it is set to the class's ``validateRead`` value, can be overridden.
readLayerInfo
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def writeLayerInfo(self, info, validateWrite=None): """ ``validateWrite`` will validate the data, by default it is set to the class's ``validateWrite`` value, can be overridden. """ if validateWrite is None: validateWrite = self._validateWrite if self.ufoForma...
``validateWrite`` will validate the data, by default it is set to the class's ``validateWrite`` value, can be overridden.
writeLayerInfo
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def getGLIF(self, glyphName): """ Get the raw GLIF text for a given glyph name. This only works for GLIF files that are already on disk. This method is useful in situations when the raw XML needs to be read from a glyph set for a particular glyph before fully parsing it ...
Get the raw GLIF text for a given glyph name. This only works for GLIF files that are already on disk. This method is useful in situations when the raw XML needs to be read from a glyph set for a particular glyph before fully parsing it into an object structure via the readGlyp...
getGLIF
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def readGlyph(self, glyphName, glyphObject=None, pointPen=None, validate=None): """ Read a .glif file for 'glyphName' from the glyph set. The 'glyphObject' argument can be any kind of object (even None); the readGlyph() method will attempt to set the following attributes on it: ...
Read a .glif file for 'glyphName' from the glyph set. The '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 ...
readGlyph
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def writeGlyph( self, glyphName, glyphObject=None, drawPointsFunc=None, formatVersion=None, validate=None, ): """ Write a .glif file for 'glyphName' to the glyph set. The 'glyphObject' argument can be any kind of object (even None); the...
Write a .glif file for 'glyphName' to the glyph set. The '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 width of the glyph height ...
writeGlyph
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def deleteGlyph(self, glyphName): """Permanently delete the glyph from the glyph set on disk. Will raise KeyError if the glyph is not present in the glyph set. """ fileName = self.contents[glyphName] self.fs.remove(fileName) if self._existingFileNames is not None: ...
Permanently delete the glyph from the glyph set on disk. Will raise KeyError if the glyph is not present in the glyph set.
deleteGlyph
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def getUnicodes(self, glyphNames=None): """ Return a dictionary that maps glyph names to lists containing the unicode value[s] for that glyph, if any. This parses the .glif files partially, so it is a lot faster than parsing all files completely. By default this checks all glyphs...
Return a dictionary that maps glyph names to lists containing the unicode value[s] for that glyph, if any. This parses the .glif files partially, so it is a lot faster than parsing all files completely. By default this checks all glyphs, but a subset can be passed with glyphNames. ...
getUnicodes
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def getComponentReferences(self, glyphNames=None): """ Return a dictionary that maps glyph names to lists containing the base glyph name of components in the glyph. This parses the .glif files partially, so it is a lot faster than parsing all files completely. By default this che...
Return a dictionary that maps glyph names to lists containing the base glyph name of components in the glyph. This parses the .glif files partially, so it is a lot faster than parsing all files completely. By default this checks all glyphs, but a subset can be passed with glyphNames. ...
getComponentReferences
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def getImageReferences(self, glyphNames=None): """ Return a dictionary that maps glyph names to the file name of the image referenced by the glyph. This parses the .glif files partially, so it is a lot faster than parsing all files completely. By default this checks all glyphs, b...
Return a dictionary that maps glyph names to the file name of the image referenced by the glyph. This parses the .glif files partially, so it is a lot faster than parsing all files completely. By default this checks all glyphs, but a subset can be passed with glyphNames.
getImageReferences
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def glyphNameToFileName(glyphName, existingFileNames): """ Wrapper around the userNameToFileName function in filenames.py Note that existingFileNames should be a set for large glyphsets or performance will suffer. """ if existingFileNames is None: existingFileNames = set() return us...
Wrapper around the userNameToFileName function in filenames.py Note that existingFileNames should be a set for large glyphsets or performance will suffer.
glyphNameToFileName
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def readGlyphFromString( aString, glyphObject=None, pointPen=None, formatVersions=None, validate=True, ): """ Read .glif data from a string into a glyph object. The 'glyphObject' argument can be any kind of object (even None); the readGlyphFromString() method will attempt to set the...
Read .glif data from a string into a glyph object. 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 width of the glyph height the advance height of t...
readGlyphFromString
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def _writeGlyphToBytes( glyphName, glyphObject=None, drawPointsFunc=None, writer=None, formatVersion=None, validate=True, ): """Return .glif data for a glyph as a UTF-8 encoded bytes string.""" try: formatVersion = GLIFFormatVersion(formatVersion) except ValueError: f...
Return .glif data for a glyph as a UTF-8 encoded bytes string.
_writeGlyphToBytes
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def writeGlyphToString( glyphName, glyphObject=None, drawPointsFunc=None, formatVersion=None, validate=True, ): """ Return .glif data for a glyph as a string. The XML declaration's encoding is always set to "UTF-8". The 'glyphObject' argument can be any kind of object (even None); ...
Return .glif data for a glyph as a string. The XML declaration's encoding is always set to "UTF-8". 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...
writeGlyphToString
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def validateLayerInfoVersion3ValueForAttribute(attr, value): """ This performs very basic validation of the value for attribute following the UFO 3 fontinfo.plist specification. The results of this should not be interpretted as *correct* for the font that they are part of. This merely indicates that...
This performs very basic validation of the value for attribute following the UFO 3 fontinfo.plist specification. The results of this should not be interpretted as *correct* for the font that they are part of. This merely indicates that the value is of the proper type and, where the specification de...
validateLayerInfoVersion3ValueForAttribute
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def validateLayerInfoVersion3Data(infoData): """ This performs very basic validation of the value for infoData following the UFO 3 layerinfo.plist specification. The results of this should not be interpretted as *correct* for the font that they are part of. This merely indicates that the values ...
This performs very basic validation of the value for infoData following the UFO 3 layerinfo.plist specification. The results of this should not be interpretted as *correct* for the font that they are part of. This merely indicates that the values are of the proper type and, where the specification ...
validateLayerInfoVersion3Data
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def _number(s): """ Given a numeric string, return an integer or a float, whichever the string indicates. _number("1") will return the integer 1, _number("1.0") will return the float 1.0. >>> _number("1") 1 >>> _number("1.0") 1.0 >>> _number("a") # doctest: +IGNORE_EXCEPTION_DETAIL...
Given a numeric string, return an integer or a float, whichever the string indicates. _number("1") will return the integer 1, _number("1.0") will return the float 1.0. >>> _number("1") 1 >>> _number("1.0") 1.0 >>> _number("a") # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most re...
_number
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def _fetchUnicodes(glif): """ Get a list of unicodes listed in glif. """ parser = _FetchUnicodesParser() parser.parse(glif) return parser.unicodes
Get a list of unicodes listed in glif.
_fetchUnicodes
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def _fetchImageFileName(glif): """ The image file name (if any) from glif. """ parser = _FetchImageFileNameParser() try: parser.parse(glif) except _DoneParsing: pass return parser.fileName
The image file name (if any) from glif.
_fetchImageFileName
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def _fetchComponentBases(glif): """ Get a list of component base glyphs listed in glif. """ parser = _FetchComponentBasesParser() try: parser.parse(glif) except _DoneParsing: pass return list(parser.bases)
Get a list of component base glyphs listed in glif.
_fetchComponentBases
python
fonttools/fonttools
Lib/fontTools/ufoLib/glifLib.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/glifLib.py
MIT
def lookupKerningValue( pair, kerning, groups, fallback=0, glyphToFirstGroup=None, glyphToSecondGroup=None ): """Retrieve the kerning value (if any) between a pair of elements. The elments can be either individual glyphs (by name) or kerning groups (by name), or any combination of the two. Args: ...
Retrieve the kerning value (if any) between a pair of elements. The elments can be either individual glyphs (by name) or kerning groups (by name), or any combination of the two. Args: pair: A tuple, in logical order (first, second) with respect to the reading direction, to query ...
lookupKerningValue
python
fonttools/fonttools
Lib/fontTools/ufoLib/kerning.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/kerning.py
MIT
def deprecated(msg=""): """Decorator factory to mark functions as deprecated with given message. >>> @deprecated("Enough!") ... def some_function(): ... "I just print 'hello world'." ... print("hello world") >>> some_function() hello world >>> some_function.__doc__ == "I just prin...
Decorator factory to mark functions as deprecated with given message. >>> @deprecated("Enough!") ... def some_function(): ... "I just print 'hello world'." ... print("hello world") >>> some_function() hello world >>> some_function.__doc__ == "I just print 'hello world'." True
deprecated
python
fonttools/fonttools
Lib/fontTools/ufoLib/utils.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/utils.py
MIT
def isDictEnough(value): """ Some objects will likely come in that aren't dicts but are dict-ish enough. """ if isinstance(value, Mapping): return True for attr in ("keys", "values", "items"): if not hasattr(value, attr): return False return True
Some objects will likely come in that aren't dicts but are dict-ish enough.
isDictEnough
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def identifierValidator(value): """ Version 3+. >>> identifierValidator("a") True >>> identifierValidator("") False >>> identifierValidator("a" * 101) False """ validCharactersMin = 0x20 validCharactersMax = 0x7E if not isinstance(value, str): return False if...
Version 3+. >>> identifierValidator("a") True >>> identifierValidator("") False >>> identifierValidator("a" * 101) False
identifierValidator
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def colorValidator(value): """ Version 3+. >>> colorValidator("0,0,0,0") True >>> colorValidator(".5,.5,.5,.5") True >>> colorValidator("0.5,0.5,0.5,0.5") True >>> colorValidator("1,1,1,1") True >>> colorValidator("2,0,0,0") False >>> colorValidator("0,2,0,0") F...
Version 3+. >>> colorValidator("0,0,0,0") True >>> colorValidator(".5,.5,.5,.5") True >>> colorValidator("0.5,0.5,0.5,0.5") True >>> colorValidator("1,1,1,1") True >>> colorValidator("2,0,0,0") False >>> colorValidator("0,2,0,0") False >>> colorValidator("0,0,2...
colorValidator
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def pngValidator(path=None, data=None, fileObj=None): """ Version 3+. This checks the signature of the image data. """ assert path is not None or data is not None or fileObj is not None if path is not None: with open(path, "rb") as f: signature = f.read(8) elif data is n...
Version 3+. This checks the signature of the image data.
pngValidator
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def layerContentsValidator(value, ufoPathOrFileSystem): """ Check the validity of layercontents.plist. Version 3+. """ if isinstance(ufoPathOrFileSystem, fs.base.FS): fileSystem = ufoPathOrFileSystem else: fileSystem = fs.osfs.OSFS(ufoPathOrFileSystem) bogusFileMessage = "la...
Check the validity of layercontents.plist. Version 3+.
layerContentsValidator
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def groupsValidator(value): """ Check the validity of the groups. Version 3+ (though it's backwards compatible with UFO 1 and UFO 2). >>> groups = {"A" : ["A", "A"], "A2" : ["A"]} >>> groupsValidator(groups) (True, None) >>> groups = {"" : ["A"]} >>> valid, msg = groupsValidator(groups...
Check the validity of the groups. Version 3+ (though it's backwards compatible with UFO 1 and UFO 2). >>> groups = {"A" : ["A", "A"], "A2" : ["A"]} >>> groupsValidator(groups) (True, None) >>> groups = {"" : ["A"]} >>> valid, msg = groupsValidator(groups) >>> valid False >>> p...
groupsValidator
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def kerningValidator(data): """ Check the validity of the kerning data structure. Version 3+ (though it's backwards compatible with UFO 1 and UFO 2). >>> kerning = {"A" : {"B" : 100}} >>> kerningValidator(kerning) (True, None) >>> kerning = {"A" : ["B"]} >>> valid, msg = kerningValidat...
Check the validity of the kerning data structure. Version 3+ (though it's backwards compatible with UFO 1 and UFO 2). >>> kerning = {"A" : {"B" : 100}} >>> kerningValidator(kerning) (True, None) >>> kerning = {"A" : ["B"]} >>> valid, msg = kerningValidator(kerning) >>> valid False...
kerningValidator
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def fontLibValidator(value): """ Check the validity of the lib. Version 3+ (though it's backwards compatible with UFO 1 and UFO 2). >>> lib = {"foo" : "bar"} >>> fontLibValidator(lib) (True, None) >>> lib = {"public.awesome" : "hello"} >>> fontLibValidator(lib) (True, None) >>...
Check the validity of the lib. Version 3+ (though it's backwards compatible with UFO 1 and UFO 2). >>> lib = {"foo" : "bar"} >>> fontLibValidator(lib) (True, None) >>> lib = {"public.awesome" : "hello"} >>> fontLibValidator(lib) (True, None) >>> lib = {"public.glyphOrder" : ["A",...
fontLibValidator
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def glyphLibValidator(value): """ Check the validity of the lib. Version 3+ (though it's backwards compatible with UFO 1 and UFO 2). >>> lib = {"foo" : "bar"} >>> glyphLibValidator(lib) (True, None) >>> lib = {"public.awesome" : "hello"} >>> glyphLibValidator(lib) (True, None) ...
Check the validity of the lib. Version 3+ (though it's backwards compatible with UFO 1 and UFO 2). >>> lib = {"foo" : "bar"} >>> glyphLibValidator(lib) (True, None) >>> lib = {"public.awesome" : "hello"} >>> glyphLibValidator(lib) (True, None) >>> lib = {"public.markColor" : "1,0...
glyphLibValidator
python
fonttools/fonttools
Lib/fontTools/ufoLib/validators.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/validators.py
MIT
def getFileModificationTime(self, path): """ Returns the modification time for the file at the given path, as a floating point number giving the number of seconds since the epoch. The path must be relative to the UFO path. Returns None if the file does not exist. """ ...
Returns the modification time for the file at the given path, as a floating point number giving the number of seconds since the epoch. The path must be relative to the UFO path. Returns None if the file does not exist.
getFileModificationTime
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def _getPlist(self, fileName, default=None): """ Read a property list relative to the UFO filesystem's root. Raises UFOLibError if the file is missing and default is None, otherwise default is returned. The errors that could be raised during the reading of a plist are un...
Read a property list relative to the UFO filesystem's root. Raises UFOLibError if the file is missing and default is None, otherwise default is returned. The errors that could be raised during the reading of a plist are unpredictable and/or too large to list, so, a blind try: e...
_getPlist
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def _writePlist(self, fileName, obj): """ Write a property list to a file relative to the UFO filesystem's root. Do this sort of atomically, making it harder to corrupt existing files, for example when plistlib encounters an error halfway during write. This also checks to see if...
Write a property list to a file relative to the UFO filesystem's root. Do this sort of atomically, making it harder to corrupt existing files, for example when plistlib encounters an error halfway during write. This also checks to see if text matches the text that is already in the ...
_writePlist
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def _upConvertKerning(self, validate): """ Up convert kerning and groups in UFO 1 and 2. The data will be held internally until each bit of data has been retrieved. The conversion of both must be done at once, so the raw data is cached and an error is raised if one bit of...
Up convert kerning and groups in UFO 1 and 2. The data will be held internally until each bit of data has been retrieved. The conversion of both must be done at once, so the raw data is cached and an error is raised if one bit of data becomes obsolete before it is called. ...
_upConvertKerning
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT