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 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 userNameToFileName(userName: str, existing=(), prefix="", suffix=""):
"""Converts from a user name to a file name.
Takes care to avoid illegal characters, reserved file names, ambiguity between
upper- and lower-case characters, and clashes with existing files.
Args:
userName (str): The... | Converts from a user name to a file name.
Takes care to avoid illegal characters, reserved file names, ambiguity between
upper- and lower-case characters, and clashes with existing files.
Args:
userName (str): The input file name.
existing: A case-insensitive list of all existing f... | userNameToFileName | python | fonttools/fonttools | Lib/fontTools/ufoLib/filenames.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/filenames.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 |
def readBytesFromPath(self, path):
"""
Returns the bytes in the file at the given path.
The path must be relative to the UFO's filesystem root.
Returns None if the file does not exist.
"""
try:
return self.fs.readbytes(fsdecode(path))
except fs.errors.... |
Returns the bytes in the file at the given path.
The path must be relative to the UFO's filesystem root.
Returns None if the file does not exist.
| readBytesFromPath | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getReadFileForPath(self, path, encoding=None):
"""
Returns a file (or file-like) object for the file at the given path.
The path must be relative to the UFO path.
Returns None if the file does not exist.
By default the file is opened in binary mode (reads bytes).
If e... |
Returns a file (or file-like) object for the file at the given path.
The path must be relative to the UFO path.
Returns None if the file does not exist.
By default the file is opened in binary mode (reads bytes).
If encoding is passed, the file is opened in text mode (reads str)... | getReadFileForPath | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def _readMetaInfo(self, validate=None):
"""
Read metainfo.plist and return raw data. Only used for internal operations.
``validate`` will validate the read data, by default it is set
to the class's validate value, can be overridden.
"""
if validate is None:
v... |
Read metainfo.plist and return raw data. Only used for internal operations.
``validate`` will validate the read data, by default it is set
to the class's validate value, can be overridden.
| _readMetaInfo | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def readMetaInfo(self, validate=None):
"""
Read metainfo.plist and set formatVersion. Only used for internal operations.
``validate`` will validate the read data, by default it is set
to the class's validate value, can be overridden.
"""
data = self._readMetaInfo(validat... |
Read metainfo.plist and set formatVersion. Only used for internal operations.
``validate`` will validate the read data, by default it is set
to the class's validate value, can be overridden.
| readMetaInfo | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def readGroups(self, validate=None):
"""
Read groups.plist. Returns a dict.
``validate`` will validate the read data, by default it is set to the
class's validate value, can be overridden.
"""
if validate is None:
validate = self._validate
# handle up ... |
Read groups.plist. Returns a dict.
``validate`` will validate the read data, by default it is set to the
class's validate value, can be overridden.
| readGroups | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getKerningGroupConversionRenameMaps(self, validate=None):
"""
Get maps defining the renaming that was done during any
needed kerning group conversion. This method returns a
dictionary of this form::
{
"side1" : {"old group name" : "new group n... |
Get maps defining the renaming that was done during any
needed kerning group conversion. This method returns a
dictionary of this form::
{
"side1" : {"old group name" : "new group name"},
"side2" : {"old group name" : "new group n... | getKerningGroupConversionRenameMaps | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def readInfo(self, info, validate=None):
"""
Read fontinfo.plist. It requires an object that allows
setting attributes with names that follow the fontinfo.plist
version 3 specification. This will write the attributes
defined in the file into the object.
``validate`` will... |
Read fontinfo.plist. It requires an object that allows
setting attributes with names that follow the fontinfo.plist
version 3 specification. This will write the attributes
defined in the file into the object.
``validate`` will validate the read data, by default it is set to the... | readInfo | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def readKerning(self, validate=None):
"""
Read kerning.plist. Returns a dict.
``validate`` will validate the kerning data, by default it is set to the
class's validate value, can be overridden.
"""
if validate is None:
validate = self._validate
# hand... |
Read kerning.plist. Returns a dict.
``validate`` will validate the kerning data, by default it is set to the
class's validate value, can be overridden.
| readKerning | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def readLib(self, validate=None):
"""
Read lib.plist. Returns a dict.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
"""
if validate is None:
validate = self._validate
data = self._getPlist(... |
Read lib.plist. Returns a dict.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
| readLib | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def readFeatures(self):
"""
Read features.fea. Return a string.
The returned string is empty if the file is missing.
"""
try:
with self.fs.open(FEATURES_FILENAME, "r", encoding="utf-8-sig") as f:
return f.read()
except fs.errors.ResourceNotFoun... |
Read features.fea. Return a string.
The returned string is empty if the file is missing.
| readFeatures | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def _readLayerContents(self, validate):
"""
Rebuild the layer contents list by checking what glyphsets
are available on disk.
``validate`` will validate the layer contents.
"""
if self._formatVersion < UFOFormatVersion.FORMAT_3_0:
return [(DEFAULT_LAYER_NAME,... |
Rebuild the layer contents list by checking what glyphsets
are available on disk.
``validate`` will validate the layer contents.
| _readLayerContents | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getLayerNames(self, validate=None):
"""
Get the ordered layer names from layercontents.plist.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
"""
if validate is None:
validate = self._validate
... |
Get the ordered layer names from layercontents.plist.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
| getLayerNames | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getDefaultLayerName(self, validate=None):
"""
Get the default layer name from layercontents.plist.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
"""
if validate is None:
validate = self._valida... |
Get the default layer name from layercontents.plist.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
| getDefaultLayerName | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getGlyphSet(self, layerName=None, validateRead=None, validateWrite=None):
"""
Return the GlyphSet associated with the
glyphs directory mapped to layerName
in the UFO. If layerName is not provided,
the name retrieved with getDefaultLayerName
will be used.
``va... |
Return the GlyphSet associated with the
glyphs directory mapped to layerName
in the UFO. If layerName is not provided,
the name retrieved with getDefaultLayerName
will be used.
``validateRead`` will validate the read data, by default it is set to the
class's val... | getGlyphSet | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getCharacterMapping(self, layerName=None, validate=None):
"""
Return a dictionary that maps unicode values (ints) to
lists of glyph names.
"""
if validate is None:
validate = self._validate
glyphSet = self.getGlyphSet(
layerName, validateRead=v... |
Return a dictionary that maps unicode values (ints) to
lists of glyph names.
| getCharacterMapping | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getDataDirectoryListing(self):
"""
Returns a list of all files in the data directory.
The returned paths will be relative to the UFO.
This will not list directory names, only file names.
Thus, empty directories will be skipped.
"""
try:
self._dataF... |
Returns a list of all files in the data directory.
The returned paths will be relative to the UFO.
This will not list directory names, only file names.
Thus, empty directories will be skipped.
| getDataDirectoryListing | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getImageDirectoryListing(self, validate=None):
"""
Returns a list of all image file names in
the images directory. Each of the images will
have been verified to have the PNG signature.
``validate`` will validate the data, by default it is set to the
class's validate ... |
Returns a list of all image file names in
the images directory. Each of the images will
have been verified to have the PNG signature.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
| getImageDirectoryListing | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def readData(self, fileName):
"""
Return bytes for the file named 'fileName' inside the 'data/' directory.
"""
fileName = fsdecode(fileName)
try:
try:
dataFS = self._dataFS
except AttributeError:
# in case readData is called... |
Return bytes for the file named 'fileName' inside the 'data/' directory.
| readData | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def readImage(self, fileName, validate=None):
"""
Return image data for the file named fileName.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
"""
if validate is None:
validate = self._validate
... |
Return image data for the file named fileName.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
| readImage | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def copyFromReader(self, reader, sourcePath, destPath):
"""
Copy the sourcePath in the provided UFOReader to destPath
in this writer. The paths must be relative. This works with
both individual files and directories.
"""
if not isinstance(reader, UFOReader):
r... |
Copy the sourcePath in the provided UFOReader to destPath
in this writer. The paths must be relative. This works with
both individual files and directories.
| copyFromReader | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def writeBytesToPath(self, path, data):
"""
Write bytes to a path relative to the UFO filesystem's root.
If writing to an existing UFO, check to see if data matches the data
that is already in the file at path; if so, the file is not rewritten
so that the modification date is pre... |
Write bytes to a path relative to the UFO filesystem's root.
If writing to an existing UFO, check to see if data matches the data
that is already in the file at path; if so, the file is not rewritten
so that the modification date is preserved.
If needed, the directory tree for t... | writeBytesToPath | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def getFileObjectForPath(self, path, mode="w", encoding=None):
"""
Returns a file (or file-like) object for the
file at the given path. The path must be relative
to the UFO path. Returns None if the file does
not exist and the mode is "r" or "rb.
An encoding may be passed... |
Returns a file (or file-like) object for the
file at the given path. The path must be relative
to the UFO path. Returns None if the file does
not exist and the mode is "r" or "rb.
An encoding may be passed if the file is opened in text mode.
Note: The caller is responsi... | getFileObjectForPath | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def removePath(self, path, force=False, removeEmptyParents=True):
"""
Remove the file (or directory) at path. The path
must be relative to the UFO.
Raises UFOLibError if the path doesn't exist.
If force=True, ignore non-existent paths.
If the directory where 'path' is loc... |
Remove the file (or directory) at path. The path
must be relative to the UFO.
Raises UFOLibError if the path doesn't exist.
If force=True, ignore non-existent paths.
If the directory where 'path' is located becomes empty, it will
be automatically removed, unless 'removeE... | removePath | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def setModificationTime(self):
"""
Set the UFO modification time to the current time.
This is never called automatically. It is up to the
caller to call this when finished working on the UFO.
"""
path = self._path
if path is not None and os.path.exists(path):
... |
Set the UFO modification time to the current time.
This is never called automatically. It is up to the
caller to call this when finished working on the UFO.
| setModificationTime | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def setKerningGroupConversionRenameMaps(self, maps):
"""
Set maps defining the renaming that should be done
when writing groups and kerning in UFO 1 and UFO 2.
This will effectively undo the conversion done when
UFOReader reads this data. The dictionary should have
this f... |
Set maps defining the renaming that should be done
when writing groups and kerning in UFO 1 and UFO 2.
This will effectively undo the conversion done when
UFOReader reads this data. The dictionary should have
this form::
{
"side1" : {"gro... | setKerningGroupConversionRenameMaps | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def writeGroups(self, groups, validate=None):
"""
Write groups.plist. This method requires a
dict of glyph groups as an argument.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
"""
if validate is None:
... |
Write groups.plist. This method requires a
dict of glyph groups as an argument.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
| writeGroups | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def writeInfo(self, info, validate=None):
"""
Write info.plist. This method requires an object
that supports getting attributes that follow the
fontinfo.plist version 2 specification. Attributes
will be taken from the given object and written
into the file.
``val... |
Write info.plist. This method requires an object
that supports getting attributes that follow the
fontinfo.plist version 2 specification. Attributes
will be taken from the given object and written
into the file.
``validate`` will validate the data, by default it is set ... | writeInfo | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def writeKerning(self, kerning, validate=None):
"""
Write kerning.plist. This method requires a
dict of kerning pairs as an argument.
This performs basic structural validation of the kerning,
but it does not check for compliance with the spec in
regards to conflicting pa... |
Write kerning.plist. This method requires a
dict of kerning pairs as an argument.
This performs basic structural validation of the kerning,
but it does not check for compliance with the spec in
regards to conflicting pairs. The assumption is that the
kerning data being ... | writeKerning | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def writeLib(self, libDict, validate=None):
"""
Write lib.plist. This method requires a
lib dict as an argument.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
"""
if validate is None:
valid... |
Write lib.plist. This method requires a
lib dict as an argument.
``validate`` will validate the data, by default it is set to the
class's validate value, can be overridden.
| writeLib | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
def writeFeatures(self, features, validate=None):
"""
Write features.fea. This method requires a
features string as an argument.
"""
if validate is None:
validate = self._validate
if self._formatVersion == UFOFormatVersion.FORMAT_1_0:
raise UFOLibE... |
Write features.fea. This method requires a
features string as an argument.
| writeFeatures | python | fonttools/fonttools | Lib/fontTools/ufoLib/__init__.py | https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py | MIT |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.