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 interpolateFromValuesAndScalars(values, scalars): """Interpolate from values and scalars coefficients. If the values are master-values, then the scalars should be fetched from getMasterScalars(). If the values are deltas, then the scalars should be fetched from getScalars()...
Interpolate from values and scalars coefficients. If the values are master-values, then the scalars should be fetched from getMasterScalars(). If the values are deltas, then the scalars should be fetched from getScalars(); in which case this is the same as interpolateFromDeltas...
interpolateFromValuesAndScalars
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def interpolateFromDeltas(self, loc, deltas): """Interpolate from deltas, at location loc.""" scalars = self.getScalars(loc) return self.interpolateFromDeltasAndScalars(deltas, scalars)
Interpolate from deltas, at location loc.
interpolateFromDeltas
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def interpolateFromMasters(self, loc, masterValues, *, round=noRound): """Interpolate from master-values, at location loc.""" scalars = self.getMasterScalars(loc) return self.interpolateFromValuesAndScalars(masterValues, scalars)
Interpolate from master-values, at location loc.
interpolateFromMasters
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def interpolateFromMastersAndScalars(self, masterValues, scalars, *, round=noRound): """Interpolate from master-values, and scalars fetched from getScalars(), which is useful when you want to interpolate multiple master-values with the same location.""" deltas = self.getDeltas(masterValu...
Interpolate from master-values, and scalars fetched from getScalars(), which is useful when you want to interpolate multiple master-values with the same location.
interpolateFromMastersAndScalars
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def interpolate_cff2_metrics(varfont, topDict, glyphOrder, loc): """Unlike TrueType glyphs, neither advance width nor bounding box info is stored in a CFF2 charstring. The width data exists only in the hmtx and HVAR tables. Since LSB data cannot be interpolated reliably from the master LSB values in the...
Unlike TrueType glyphs, neither advance width nor bounding box info is stored in a CFF2 charstring. The width data exists only in the hmtx and HVAR tables. Since LSB data cannot be interpolated reliably from the master LSB values in the hmtx table, we traverse the charstring to determine the actual boun...
interpolate_cff2_metrics
python
fonttools/fonttools
Lib/fontTools/varLib/mutator.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/mutator.py
MIT
def instantiateVariableFont(varfont, location, inplace=False, overlap=True): """Generate a static instance from a variable TTFont and a dictionary defining the desired location along the variable font's axes. The location values must be specified as user-space coordinates, e.g.: .. code-block:: ...
Generate a static instance from a variable TTFont and a dictionary defining the desired location along the variable font's axes. The location values must be specified as user-space coordinates, e.g.: .. code-block:: {'wght': 400, 'wdth': 100} By default, a new TTFont object is returned. If ``...
instantiateVariableFont
python
fonttools/fonttools
Lib/fontTools/varLib/mutator.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/mutator.py
MIT
def plotModelFromMasters(model, masterValues, fig, **kwargs): """Plot a variation model and set of master values corresponding to the locations to the model into a pyplot figure. Variation model must have axisOrder of size 1 or 2.""" if len(model.axisOrder) == 1: _plotModelFromMasters2D(model, ...
Plot a variation model and set of master values corresponding to the locations to the model into a pyplot figure. Variation model must have axisOrder of size 1 or 2.
plotModelFromMasters
python
fonttools/fonttools
Lib/fontTools/varLib/plot.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/plot.py
MIT
def buildVFStatTable(ttFont: TTFont, doc: DesignSpaceDocument, vfName: str) -> None: """Build the STAT table for the variable font identified by its name in the given document. Knowing which variable we're building STAT data for is needed to subset the STAT locations to only include what the variable f...
Build the STAT table for the variable font identified by its name in the given document. Knowing which variable we're building STAT data for is needed to subset the STAT locations to only include what the variable font actually ships. .. versionadded:: 5.0 .. seealso:: - :func:`getStatAxe...
buildVFStatTable
python
fonttools/fonttools
Lib/fontTools/varLib/stat.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/stat.py
MIT
def getStatAxes(doc: DesignSpaceDocument, userRegion: Region) -> List[Dict]: """Return a list of axis dicts suitable for use as the ``axes`` argument to :func:`fontTools.otlLib.builder.buildStatTable()`. .. versionadded:: 5.0 """ # First, get the axis labels with explicit ordering # then append...
Return a list of axis dicts suitable for use as the ``axes`` argument to :func:`fontTools.otlLib.builder.buildStatTable()`. .. versionadded:: 5.0
getStatAxes
python
fonttools/fonttools
Lib/fontTools/varLib/stat.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/stat.py
MIT
def getStatLocations(doc: DesignSpaceDocument, userRegion: Region) -> List[Dict]: """Return a list of location dicts suitable for use as the ``locations`` argument to :func:`fontTools.otlLib.builder.buildStatTable()`. .. versionadded:: 5.0 """ axesByName = {axis.name: axis for axis in doc.axes} ...
Return a list of location dicts suitable for use as the ``locations`` argument to :func:`fontTools.otlLib.builder.buildStatTable()`. .. versionadded:: 5.0
getStatLocations
python
fonttools/fonttools
Lib/fontTools/varLib/stat.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/stat.py
MIT
def _visit(self, func): """Recurse down from self, if type of an object is ot.Device, call func() on it. Works on otData-style classes.""" if type(self) == ot.Device: func(self) elif isinstance(self, list): for that in self: _visit(that, func) elif hasattr(self, "getC...
Recurse down from self, if type of an object is ot.Device, call func() on it. Works on otData-style classes.
_visit
python
fonttools/fonttools
Lib/fontTools/varLib/varStore.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/varStore.py
MIT
def _Device_recordVarIdx(self, s): """Add VarIdx in this Device table (if any) to the set s.""" if self.DeltaFormat == 0x8000: s.add((self.StartSize << 16) + self.EndSize)
Add VarIdx in this Device table (if any) to the set s.
_Device_recordVarIdx
python
fonttools/fonttools
Lib/fontTools/varLib/varStore.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/varStore.py
MIT
def _Device_mapVarIdx(self, mapping, done): """Map VarIdx in this Device table (if any) through mapping.""" if id(self) in done: return done.add(id(self)) if self.DeltaFormat == 0x8000: varIdx = mapping[(self.StartSize << 16) + self.EndSize] self.StartSize = varIdx >> 16 ...
Map VarIdx in this Device table (if any) through mapping.
_Device_mapVarIdx
python
fonttools/fonttools
Lib/fontTools/varLib/varStore.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/varStore.py
MIT
def _characteristic_overhead(columns): """Returns overhead in bytes of encoding this characteristic as a VarData.""" c = 4 + 6 # 4 bytes for LOffset, 6 bytes for VarData header c += bit_count(columns) * 2 return c
Returns overhead in bytes of encoding this characteristic as a VarData.
_characteristic_overhead
python
fonttools/fonttools
Lib/fontTools/varLib/varStore.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/varStore.py
MIT
def VarStore_optimize(self, use_NO_VARIATION_INDEX=True, quantization=1): """Optimize storage. Returns mapping from old VarIdxes to new ones.""" # Overview: # # For each VarData row, we first extend it with zeroes to have # one column per region in VarRegionList. We then group the # rows into _...
Optimize storage. Returns mapping from old VarIdxes to new ones.
VarStore_optimize
python
fonttools/fonttools
Lib/fontTools/varLib/varStore.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/varStore.py
MIT
def _add_fvar(font, axes, instances: List[InstanceDescriptor]): """ Add 'fvar' table to font. axes is an ordered dictionary of DesignspaceAxis objects. instances is list of dictionary objects with 'location', 'stylename', and possibly 'postscriptfontname' entries. """ assert axes asse...
Add 'fvar' table to font. axes is an ordered dictionary of DesignspaceAxis objects. instances is list of dictionary objects with 'location', 'stylename', and possibly 'postscriptfontname' entries.
_add_fvar
python
fonttools/fonttools
Lib/fontTools/varLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/__init__.py
MIT
def _add_avar(font, axes, mappings, axisTags): """ Add 'avar' table to font. axes is an ordered dictionary of AxisDescriptor objects. """ assert axes assert isinstance(axes, OrderedDict) log.info("Generating avar") avar = newTable("avar") interesting = False vals_triples = {...
Add 'avar' table to font. axes is an ordered dictionary of AxisDescriptor objects.
_add_avar
python
fonttools/fonttools
Lib/fontTools/varLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/__init__.py
MIT
def drop_implied_oncurve_points(*masters: TTFont) -> int: """Drop impliable on-curve points from all the simple glyphs in masters. In TrueType glyf outlines, on-curve points can be implied when they are located exactly at the midpoint of the line connecting two consecutive off-curve points. The input ...
Drop impliable on-curve points from all the simple glyphs in masters. In TrueType glyf outlines, on-curve points can be implied when they are located exactly at the midpoint of the line connecting two consecutive off-curve points. The input masters' glyf tables are assumed to contain same-named glyphs tha...
drop_implied_oncurve_points
python
fonttools/fonttools
Lib/fontTools/varLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/__init__.py
MIT
def build_many( designspace: DesignSpaceDocument, master_finder=lambda s: s, exclude=[], optimize=True, skip_vf=lambda vf_name: False, colr_layer_reuse=True, drop_implied_oncurves=False, ): """ Build variable fonts from a designspace file, version 5 which can define several VFs, ...
Build variable fonts from a designspace file, version 5 which can define several VFs, or version 4 which has implicitly one VF covering the whole doc. If master_finder is set, it should be a callable that takes master filename as found in designspace file and map it to master font binary as to be ...
build_many
python
fonttools/fonttools
Lib/fontTools/varLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/__init__.py
MIT
def build( designspace, master_finder=lambda s: s, exclude=[], optimize=True, colr_layer_reuse=True, drop_implied_oncurves=False, ): """ Build variation font from a designspace file. If master_finder is set, it should be a callable that takes master filename as found in designsp...
Build variation font from a designspace file. If master_finder is set, it should be a callable that takes master filename as found in designspace file and map it to master font binary as to be opened (eg. .ttf or .otf).
build
python
fonttools/fonttools
Lib/fontTools/varLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/__init__.py
MIT
def load_masters(designspace, master_finder=lambda s: s): """Ensure that all SourceDescriptor.font attributes have an appropriate TTFont object loaded, or else open TTFont objects from the SourceDescriptor.path attributes. The paths can point to either an OpenType font, a TTX file, or a UFO. In the ...
Ensure that all SourceDescriptor.font attributes have an appropriate TTFont object loaded, or else open TTFont objects from the SourceDescriptor.path attributes. The paths can point to either an OpenType font, a TTX file, or a UFO. In the latter case, use the provided master_finder callable to map from...
load_masters
python
fonttools/fonttools
Lib/fontTools/varLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/__init__.py
MIT
def addGSUBFeatureVariations(vf, designspace, featureTags=(), *, log_enabled=False): """Add GSUB FeatureVariations table to variable font, based on DesignSpace rules. Args: vf: A TTFont object representing the variable font. designspace: A DesignSpaceDocument object. featureTags: Option...
Add GSUB FeatureVariations table to variable font, based on DesignSpace rules. Args: vf: A TTFont object representing the variable font. designspace: A DesignSpaceDocument object. featureTags: Optional feature tag(s) to use for the FeatureVariations records. If unset, the key 'c...
addGSUBFeatureVariations
python
fonttools/fonttools
Lib/fontTools/varLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/__init__.py
MIT
def main(args=None): """Build variable fonts from a designspace file and masters""" from argparse import ArgumentParser from fontTools import configLogger parser = ArgumentParser(prog="varLib", description=main.__doc__) parser.add_argument("designspace") output_group = parser.add_mutually_exclu...
Build variable fonts from a designspace file and masters
main
python
fonttools/fonttools
Lib/fontTools/varLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/__init__.py
MIT
def updateNameTable(varfont, axisLimits): """Update instatiated variable font's name table using STAT AxisValues. Raises ValueError if the STAT table is missing or an Axis Value table is missing for requested axis locations. First, collect all STAT AxisValues that match the new default axis locations ...
Update instatiated variable font's name table using STAT AxisValues. Raises ValueError if the STAT table is missing or an Axis Value table is missing for requested axis locations. First, collect all STAT AxisValues that match the new default axis locations (excluding "elided" ones); concatenate the st...
updateNameTable
python
fonttools/fonttools
Lib/fontTools/varLib/instancer/names.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/instancer/names.py
MIT
def expand( cls, v: Union[ "AxisTriple", float, # pin axis at single value, same as min==default==max Tuple[float, float], # (min, max), restrict axis and keep default Tuple[float, float, float], # (min, default, max) ], ) -> "AxisTriple": ...
Convert a single value or a tuple into an AxisTriple. If the input is a single value, it is interpreted as a pin at that value. If the input is a tuple, it is interpreted as (min, max) or (min, default, max).
expand
python
fonttools/fonttools
Lib/fontTools/varLib/instancer/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/instancer/__init__.py
MIT
def limitRangeAndPopulateDefaults(self, fvarTriple) -> "AxisTriple": """Return a new AxisTriple with the default value filled in. Set default to fvar axis default if the latter is within the min/max range, otherwise set default to the min or max value, whichever is closer to the fvar ax...
Return a new AxisTriple with the default value filled in. Set default to fvar axis default if the latter is within the min/max range, otherwise set default to the min or max value, whichever is closer to the fvar axis default. If the default value is already set, return self.
limitRangeAndPopulateDefaults
python
fonttools/fonttools
Lib/fontTools/varLib/instancer/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/instancer/__init__.py
MIT
def instantiateGvarGlyph(varfont, glyphname, axisLimits, optimize=True): """Remove? https://github.com/fonttools/fonttools/pull/2266""" gvar = varfont["gvar"] glyf = varfont["glyf"] hMetrics = varfont["hmtx"].metrics vMetrics = getattr(varfont.get("vmtx"), "metrics", None) _instantiateGvarGl...
Remove? https://github.com/fonttools/fonttools/pull/2266
instantiateGvarGlyph
python
fonttools/fonttools
Lib/fontTools/varLib/instancer/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/instancer/__init__.py
MIT
def verticalMetricsKeptInSync(varfont): """Ensure hhea vertical metrics stay in sync with OS/2 ones after instancing. When applying MVAR deltas to the OS/2 table, if the ascender, descender and line gap change but they were the same as the respective hhea metrics in the original font, this context mana...
Ensure hhea vertical metrics stay in sync with OS/2 ones after instancing. When applying MVAR deltas to the OS/2 table, if the ascender, descender and line gap change but they were the same as the respective hhea metrics in the original font, this context manager ensures that hhea metrcs also get updated ...
verticalMetricsKeptInSync
python
fonttools/fonttools
Lib/fontTools/varLib/instancer/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/instancer/__init__.py
MIT
def setRibbiBits(font): """Set the `head.macStyle` and `OS/2.fsSelection` style bits appropriately.""" english_ribbi_style = font["name"].getName(names.NameID.SUBFAMILY_NAME, 3, 1, 0x409) if english_ribbi_style is None: return styleMapStyleName = english_ribbi_style.toStr().lower() if ...
Set the `head.macStyle` and `OS/2.fsSelection` style bits appropriately.
setRibbiBits
python
fonttools/fonttools
Lib/fontTools/varLib/instancer/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/instancer/__init__.py
MIT
def invalid_fea_glyph_name(name): """Check if the glyph name is valid according to FEA syntax.""" if name[0] not in Lexer.CHAR_NAME_START_: return True if any(c not in Lexer.CHAR_NAME_CONTINUATION_ for c in name[1:]): return True return False
Check if the glyph name is valid according to FEA syntax.
invalid_fea_glyph_name
python
fonttools/fonttools
Lib/fontTools/voltLib/__main__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/voltLib/__main__.py
MIT
def sanitize_glyph_name(name): """Sanitize the glyph name to ensure it is valid according to FEA syntax.""" sanitized = "" for i, c in enumerate(name): if i == 0 and c not in Lexer.CHAR_NAME_START_: sanitized += "a" + c elif c not in Lexer.CHAR_NAME_CONTINUATION_: san...
Sanitize the glyph name to ensure it is valid according to FEA syntax.
sanitize_glyph_name
python
fonttools/fonttools
Lib/fontTools/voltLib/__main__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/voltLib/__main__.py
MIT
def main(args=None): """Build tables from a MS VOLT project into an OTF font""" parser = argparse.ArgumentParser( description="Use fontTools to compile MS VOLT projects." ) parser.add_argument( "input", metavar="INPUT", help="Path to the input font/VTP file to process", ...
Build tables from a MS VOLT project into an OTF font
main
python
fonttools/fonttools
Lib/fontTools/voltLib/__main__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/voltLib/__main__.py
MIT
def read_unidata_file(filename, local_ucd_path=None) -> List[str]: """Read a UCD file from https://unicode.org or optionally from a local directory. Return the list of lines. """ if local_ucd_path is not None: with open(pjoin(local_ucd_path, filename), "r", encoding="utf-8-sig") as f: ...
Read a UCD file from https://unicode.org or optionally from a local directory. Return the list of lines.
read_unidata_file
python
fonttools/fonttools
MetaTools/buildUCD.py
https://github.com/fonttools/fonttools/blob/master/MetaTools/buildUCD.py
MIT
def parse_unidata_header(file_lines: List[str]): """Read the top header of data files, until the first line that does not start with '#'. """ header = [] for line in file_lines: if line.startswith("#"): header.append(line) else: break return "".join(header...
Read the top header of data files, until the first line that does not start with '#'.
parse_unidata_header
python
fonttools/fonttools
MetaTools/buildUCD.py
https://github.com/fonttools/fonttools/blob/master/MetaTools/buildUCD.py
MIT
def parse_range_properties(infile: List[str], default=None, is_set=False): """Parse a Unicode data file containing a column with one character or a range of characters, and another column containing a property value separated by a semicolon. Comments after '#' are ignored. If the ranges defined in the ...
Parse a Unicode data file containing a column with one character or a range of characters, and another column containing a property value separated by a semicolon. Comments after '#' are ignored. If the ranges defined in the data file are not continuous, assign the 'default' property to the unassigned ...
parse_range_properties
python
fonttools/fonttools
MetaTools/buildUCD.py
https://github.com/fonttools/fonttools/blob/master/MetaTools/buildUCD.py
MIT
def parse_semicolon_separated_data(infile): """Parse a Unicode data file where each line contains a lists of values separated by a semicolon (e.g. "PropertyValueAliases.txt"). The number of the values on different lines may be different. Returns a list of lists each containing the values as strings. ...
Parse a Unicode data file where each line contains a lists of values separated by a semicolon (e.g. "PropertyValueAliases.txt"). The number of the values on different lines may be different. Returns a list of lists each containing the values as strings.
parse_semicolon_separated_data
python
fonttools/fonttools
MetaTools/buildUCD.py
https://github.com/fonttools/fonttools/blob/master/MetaTools/buildUCD.py
MIT
def build_ranges( filename, local_ucd=None, output_path=None, default=None, is_set=False, aliases=None ): """Fetch 'filename' UCD data file from Unicode official website, parse the property ranges and values and write them as two Python lists to 'fontTools.unicodedata.<filename>.py'. 'aliases' is a...
Fetch 'filename' UCD data file from Unicode official website, parse the property ranges and values and write them as two Python lists to 'fontTools.unicodedata.<filename>.py'. 'aliases' is an optional mapping of property codes (short names) to long name aliases (list of strings, with the first item bei...
build_ranges
python
fonttools/fonttools
MetaTools/buildUCD.py
https://github.com/fonttools/fonttools/blob/master/MetaTools/buildUCD.py
MIT
def parse_property_value_aliases(property_tag, local_ucd=None): """Fetch the current 'PropertyValueAliases.txt' from the Unicode website, parse the values for the specified 'property_tag' and return a dictionary of name aliases (list of strings) keyed by short value codes (strings). To load the data fi...
Fetch the current 'PropertyValueAliases.txt' from the Unicode website, parse the values for the specified 'property_tag' and return a dictionary of name aliases (list of strings) keyed by short value codes (strings). To load the data file from a local directory, you can use the 'local_ucd' argument. ...
parse_property_value_aliases
python
fonttools/fonttools
MetaTools/buildUCD.py
https://github.com/fonttools/fonttools/blob/master/MetaTools/buildUCD.py
MIT
def GetCoordinates(font, glyphName): """font, glyphName --> glyph coordinates as expected by "gvar" table The result includes four "phantom points" for the glyph metrics, as mandated by the "gvar" spec. """ glyphTable = font["glyf"] glyph = glyphTable.glyphs.get(glyphName) if glyph is None:...
font, glyphName --> glyph coordinates as expected by "gvar" table The result includes four "phantom points" for the glyph metrics, as mandated by the "gvar" spec.
GetCoordinates
python
fonttools/fonttools
Snippets/interpolate.py
https://github.com/fonttools/fonttools/blob/master/Snippets/interpolate.py
MIT
def svg2glif(svg, name, width=0, height=0, unicodes=None, transform=None, version=2): """Convert an SVG outline to a UFO glyph with given 'name', advance 'width' and 'height' (int), and 'unicodes' (list of int). Return the resulting string in GLIF format (default: version 2). If 'transform' is provided,...
Convert an SVG outline to a UFO glyph with given 'name', advance 'width' and 'height' (int), and 'unicodes' (list of int). Return the resulting string in GLIF format (default: version 2). If 'transform' is provided, apply a transformation matrix before the conversion (must be tuple of 6 floats, or a Fon...
svg2glif
python
fonttools/fonttools
Snippets/svg2glif.py
https://github.com/fonttools/fonttools/blob/master/Snippets/svg2glif.py
MIT
def decomponentize_tt(font: TTFont) -> None: """ Decomposes all composite glyphs of a TrueType font. """ if not font.sfntVersion == "\x00\x01\x00\x00": raise NotImplementedError( "Decomponentization is only supported for TrueType fonts." ) glyph_set = font.getGlyphSet() ...
Decomposes all composite glyphs of a TrueType font.
decomponentize_tt
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def round_path( path: pathops.Path, rounder: t.Callable[[float], float] = otRound ) -> pathops.Path: """ Rounds the points coordinate of a ``pathops.Path`` Args: path (pathops.Path): The ``pathops.Path`` rounder (Callable[[float], float], optional): The rounding function. Defaults to ot...
Rounds the points coordinate of a ``pathops.Path`` Args: path (pathops.Path): The ``pathops.Path`` rounder (Callable[[float], float], optional): The rounding function. Defaults to otRound. Returns: pathops.Path: The rounded path
round_path
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def simplify_path(path: pathops.Path, glyph_name: str, clockwise: bool) -> pathops.Path: """ Simplify a ``pathops.Path by`` removing overlaps, fixing contours direction and, optionally, removing tiny paths Args: path (pathops.Path): The ``pathops.Path`` to simplify glyph_name (str): The...
Simplify a ``pathops.Path by`` removing overlaps, fixing contours direction and, optionally, removing tiny paths Args: path (pathops.Path): The ``pathops.Path`` to simplify glyph_name (str): The glyph name clockwise (bool): The winding direction. Must be ``True`` for TrueType glyph...
simplify_path
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def quadratics_to_cubics( font: TTFont, tolerance: float = 1.0, correct_contours: bool = False ) -> t.Dict[str, T2CharString]: """ Get CFF charstrings using Qu2CuPen Args: font (TTFont): The TTFont object. tolerance (float, optional): The tolerance for the conversion. Defaults to 1.0. ...
Get CFF charstrings using Qu2CuPen Args: font (TTFont): The TTFont object. tolerance (float, optional): The tolerance for the conversion. Defaults to 1.0. correct_contours (bool, optional): Whether to correct the contours with pathops. Defaults to False. Returns: ...
quadratics_to_cubics
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def build_font_info_dict(font: TTFont) -> t.Dict[str, t.Any]: """ Builds CFF topDict from a TTFont object. Args: font (TTFont): The TTFont object. Returns: dict: The CFF topDict. """ font_revision = str(round(font["head"].fontRevision, 3)).split(".") major_version = str(fo...
Builds CFF topDict from a TTFont object. Args: font (TTFont): The TTFont object. Returns: dict: The CFF topDict.
build_font_info_dict
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def get_post_values(font: TTFont) -> t.Dict[str, t.Any]: """ Setup CFF post table values Args: font (TTFont): The TTFont object. Returns: dict: The post table values. """ post_table = font["post"] post_info = { "italicAngle": otRound(post_table.italicAngle), ...
Setup CFF post table values Args: font (TTFont): The TTFont object. Returns: dict: The post table values.
get_post_values
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def get_hmtx_values( font: TTFont, charstrings: t.Dict[str, T2CharString] ) -> t.Dict[str, t.Tuple[int, int]]: """ Get the horizontal metrics for a font. Args: font (TTFont): The TTFont object. charstrings (dict): The charstrings dictionary. Returns: dict: The horizontal me...
Get the horizontal metrics for a font. Args: font (TTFont): The TTFont object. charstrings (dict): The charstrings dictionary. Returns: dict: The horizontal metrics.
get_hmtx_values
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def build_otf( font: TTFont, charstrings_dict: t.Dict[str, T2CharString], ps_name: t.Optional[str] = None, font_info: t.Optional[t.Dict[str, t.Any]] = None, private_dict: t.Optional[t.Dict[str, t.Any]] = None, ) -> None: """ Builds an OpenType font with FontBuilder. Args: font (...
Builds an OpenType font with FontBuilder. Args: font (TTFont): The TTFont object. charstrings_dict (dict): The charstrings dictionary. ps_name (str, optional): The PostScript name of the font. Defaults to None. font_info (dict, optional): The font info dictionary. Defaults to N...
build_otf
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def find_fonts( input_path: Path, recursive: bool = False, recalc_timestamp: bool = False ) -> t.List[TTFont]: """ Returns a list of TTFont objects found in the input path. Args: input_path (Path): The input file or directory. recursive (bool): If input_path is a directory, search for f...
Returns a list of TTFont objects found in the input path. Args: input_path (Path): The input file or directory. recursive (bool): If input_path is a directory, search for fonts recursively in subdirectories. recalc_timestamp (bool): Weather to recalculate the font's timesta...
find_fonts
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def main(args=None) -> None: """ Convert TrueType flavored fonts to CFF flavored fonts. INPUT_PATH argument can be a file or a directory. If it is a directory, all the TrueType flavored fonts found in the directory will be converted. """ parser = argparse.ArgumentParser( description=__...
Convert TrueType flavored fonts to CFF flavored fonts. INPUT_PATH argument can be a file or a directory. If it is a directory, all the TrueType flavored fonts found in the directory will be converted.
main
python
fonttools/fonttools
Snippets/ttf2otf.py
https://github.com/fonttools/fonttools/blob/master/Snippets/ttf2otf.py
MIT
def disableConfigLogger(): """Session-scoped fixture to make fontTools.configLogger function no-op. Logging in python maintains a global state. When in the tests we call a main() function from modules subset or ttx, a call to configLogger is made that modifies this global state (to configures a handler...
Session-scoped fixture to make fontTools.configLogger function no-op. Logging in python maintains a global state. When in the tests we call a main() function from modules subset or ttx, a call to configLogger is made that modifies this global state (to configures a handler for the fontTools logger). To...
disableConfigLogger
python
fonttools/fonttools
Tests/conftest.py
https://github.com/fonttools/fonttools/blob/master/Tests/conftest.py
MIT
def test_CFF_deepcopy(self): """Test that deepcopying a TTFont with a CFF table does not recurse infinitely.""" ttx_path = os.path.join( os.path.dirname(__file__), "..", "varLib", "data", "master_ttx_interpolatable_otf", "Te...
Test that deepcopying a TTFont with a CFF table does not recurse infinitely.
test_CFF_deepcopy
python
fonttools/fonttools
Tests/cffLib/cffLib_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/cffLib/cffLib_test.py
MIT
def setUpClass(cls): """Do the curve conversion ahead of time, and run tests on results.""" with open(os.path.join(DATADIR, "curves.json"), "r") as fp: curves = json.load(fp) cls.single_splines = [curve_to_quadratic(c, MAX_ERR) for c in curves] cls.single_errors = [ ...
Do the curve conversion ahead of time, and run tests on results.
setUpClass
python
fonttools/fonttools
Tests/cu2qu/cu2qu_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/cu2qu/cu2qu_test.py
MIT
def tearDownClass(cls): """Print stats from conversion, as determined during tests.""" for tag, results in cls.results: print( "\n%s\n%s" % ( tag, "\n".join( "%s: %s (%d)" % (k, "#" * (v // 10 + ...
Print stats from conversion, as determined during tests.
tearDownClass
python
fonttools/fonttools
Tests/cu2qu/cu2qu_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/cu2qu/cu2qu_test.py
MIT
def test_results_unchanged(self): """Tests that the results of conversion haven't changed since the time of this test's writing. Useful as a quick check whenever one modifies the conversion algorithm. """ expected = {2: 6, 3: 26, 4: 82, 5: 232, 6: 360, 7: 266, 8: 28} re...
Tests that the results of conversion haven't changed since the time of this test's writing. Useful as a quick check whenever one modifies the conversion algorithm.
test_results_unchanged
python
fonttools/fonttools
Tests/cu2qu/cu2qu_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/cu2qu/cu2qu_test.py
MIT
def test_results_unchanged_multiple(self): """Test that conversion results are unchanged for multiple curves.""" expected = {5: 11, 6: 35, 7: 49, 8: 5} results = collections.defaultdict(int) for splines in self.compat_splines: n = len(splines[0]) - 2 for spline ...
Test that conversion results are unchanged for multiple curves.
test_results_unchanged_multiple
python
fonttools/fonttools
Tests/cu2qu/cu2qu_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/cu2qu/cu2qu_test.py
MIT
def test_does_not_exceed_tolerance(self): """Test that conversion results do not exceed given error tolerance.""" results = collections.defaultdict(int) for error in self.single_errors: results[round(error, 1)] += 1 self.assertLessEqual(error, MAX_ERR) self.resul...
Test that conversion results do not exceed given error tolerance.
test_does_not_exceed_tolerance
python
fonttools/fonttools
Tests/cu2qu/cu2qu_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/cu2qu/cu2qu_test.py
MIT
def test_does_not_exceed_tolerance_multiple(self): """Test that error tolerance isn't exceeded for multiple curves.""" results = collections.defaultdict(int) for errors in self.compat_errors: for error in errors: results[round(error, 1)] += 1 self.ass...
Test that error tolerance isn't exceeded for multiple curves.
test_does_not_exceed_tolerance_multiple
python
fonttools/fonttools
Tests/cu2qu/cu2qu_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/cu2qu/cu2qu_test.py
MIT
def curve_spline_dist(cls, bezier, spline, total_steps=20): """Max distance between a bezier and quadratic spline at sampled points.""" error = 0 n = len(spline) - 2 steps = total_steps // n for i in range(0, n - 1): p1 = spline[0] if i == 0 else p3 p2 = ...
Max distance between a bezier and quadratic spline at sampled points.
curve_spline_dist
python
fonttools/fonttools
Tests/cu2qu/cu2qu_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/cu2qu/cu2qu_test.py
MIT
def _axesAsDict(axes): """ Make the axis data we have available in """ axesDict = {} for axisDescriptor in axes: d = { "name": axisDescriptor.name, "tag": axisDescriptor.tag, "minimum": axisDescriptor.minimum, "maximum": axisDescriptor.maximum,...
Make the axis data we have available in
_axesAsDict
python
fonttools/fonttools
Tests/designspaceLib/designspace_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/designspaceLib/designspace_test.py
MIT
def map_doc(): """Generate a document with a few axes to test the mapping functions""" doc = DesignSpaceDocument() doc.addAxis( AxisDescriptor( tag="wght", name="Weight", minimum=100, maximum=900, default=100, map=[(100, 10), (9...
Generate a document with a few axes to test the mapping functions
map_doc
python
fonttools/fonttools
Tests/designspaceLib/designspace_v5_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/designspaceLib/designspace_v5_test.py
MIT
def test_optional_min_max(unbounded_condition): """Check that split functions can handle conditions that are partially unbounded without tripping over None values and missing keys.""" doc = DesignSpaceDocument() doc.addAxisDescriptor( name="Weight", tag="wght", minimum=400, maximum=1000, defaul...
Check that split functions can handle conditions that are partially unbounded without tripping over None values and missing keys.
test_optional_min_max
python
fonttools/fonttools
Tests/designspaceLib/split_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/designspaceLib/split_test.py
MIT
def test_getStatNames_on_ds4_doesnt_make_up_bad_names(datadir): """See this issue on GitHub: https://github.com/googlefonts/ufo2ft/issues/630 When as in the example, there's no STAT data present, the getStatName shouldn't try making up a postscript name. """ doc = DesignSpaceDocument.fromfile(datad...
See this issue on GitHub: https://github.com/googlefonts/ufo2ft/issues/630 When as in the example, there's no STAT data present, the getStatName shouldn't try making up a postscript name.
test_getStatNames_on_ds4_doesnt_make_up_bad_names
python
fonttools/fonttools
Tests/designspaceLib/statNames_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/designspaceLib/statNames_test.py
MIT
def test_conditionset_multiple_features(self): """Test that using the same `conditionset` for multiple features reuses the `FeatureVariationRecord`.""" features = """ languagesystem DFLT dflt; conditionset test { wght 600 1000; wdth 150 2...
Test that using the same `conditionset` for multiple features reuses the `FeatureVariationRecord`.
test_conditionset_multiple_features
python
fonttools/fonttools
Tests/feaLib/builder_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/feaLib/builder_test.py
MIT
def test_condition_set_avar(self): """Test that the `avar` table is consulted when normalizing user-space values.""" features = """ languagesystem DFLT dflt; lookup conditional_sub { sub e by a; } conditional_sub; conditionset te...
Test that the `avar` table is consulted when normalizing user-space values.
test_condition_set_avar
python
fonttools/fonttools
Tests/feaLib/builder_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/feaLib/builder_test.py
MIT
def test_variable_anchors_round_trip(self): """Test that calling `addOpenTypeFeatures` with parsed feature file does not discard variations from variable anchors.""" features = """\ feature curs { pos cursive one <anchor 0 (wdth=100,wght=200:12 wdth=150,wght=900:42)> ...
Test that calling `addOpenTypeFeatures` with parsed feature file does not discard variations from variable anchors.
test_variable_anchors_round_trip
python
fonttools/fonttools
Tests/feaLib/builder_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/feaLib/builder_test.py
MIT
def test_main(tmpdir: Path): """Check that calling the main function on an input TTF works.""" glyphs = ".notdef space A Aacute B D".split() features = """ @A = [A Aacute]; @B = [B D]; feature kern { pos @A @B -50; } kern; """ fb = FontBuilder(1000) fb.setupGlyphOrder(gly...
Check that calling the main function on an input TTF works.
test_main
python
fonttools/fonttools
Tests/otlLib/optimize_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/otlLib/optimize_test.py
MIT
def test_no_crash_with_missing_gpos(tmpdir: Path): """Test that the optimize script gracefully handles TTFs with no GPOS.""" # Create a test TTF. glyphs = ".notdef space A Aacute B D".split() fb = FontBuilder(1000) fb.setupGlyphOrder(glyphs) # Confirm that it has no GPOS. assert "GPOS" not...
Test that the optimize script gracefully handles TTFs with no GPOS.
test_no_crash_with_missing_gpos
python
fonttools/fonttools
Tests/otlLib/optimize_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/otlLib/optimize_test.py
MIT
def set_env(**environ): """ Temporarily set the process environment variables. >>> with set_env(PLUGINS_DIR=u'test/plugins'): ... "PLUGINS_DIR" in os.environ True >>> "PLUGINS_DIR" in os.environ False :type environ: dict[str, unicode] :param environ: Environment variables to set...
Temporarily set the process environment variables. >>> with set_env(PLUGINS_DIR=u'test/plugins'): ... "PLUGINS_DIR" in os.environ True >>> "PLUGINS_DIR" in os.environ False :type environ: dict[str, unicode] :param environ: Environment variables to set
set_env
python
fonttools/fonttools
Tests/otlLib/optimize_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/otlLib/optimize_test.py
MIT
def get_kerning_by_blocks(blocks: List[Tuple[int, int]]) -> Tuple[List[str], str]: """Generate a highly compressible font by generating a bunch of rectangular blocks on the diagonal that can easily be sliced into subtables. Returns the list of glyphs and feature code of the font. """ value = 0 ...
Generate a highly compressible font by generating a bunch of rectangular blocks on the diagonal that can easily be sliced into subtables. Returns the list of glyphs and feature code of the font.
get_kerning_by_blocks
python
fonttools/fonttools
Tests/otlLib/optimize_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/otlLib/optimize_test.py
MIT
def test_optimization_mode( caplog, blocks: List[Tuple[int, int]], level: Optional[int], expected_subtables: int, expected_bytes: int, ): """Check that the optimizations are off by default, and that increasing the optimization level creates more subtables and a smaller byte size. """ ...
Check that the optimizations are off by default, and that increasing the optimization level creates more subtables and a smaller byte size.
test_optimization_mode
python
fonttools/fonttools
Tests/otlLib/optimize_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/otlLib/optimize_test.py
MIT
def test_quad_no_oncurve(self): """When passed a contour which has no on-curve points, the Cu2QuPointPen will treat it as a special quadratic contour whose first point has 'None' coordinates. """ self.maxDiff = None pen = DummyPointPen() quadpen = Cu2QuPointPen(pe...
When passed a contour which has no on-curve points, the Cu2QuPointPen will treat it as a special quadratic contour whose first point has 'None' coordinates.
test_quad_no_oncurve
python
fonttools/fonttools
Tests/pens/cu2quPen_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/pens/cu2quPen_test.py
MIT
def __init__(self, glyph=None): """If another glyph (i.e. any object having a 'draw' method) is given, its outline data is copied to self. """ self._pen = self.DrawingPen() self.outline = self._pen.commands if glyph: self.appendGlyph(glyph)
If another glyph (i.e. any object having a 'draw' method) is given, its outline data is copied to self.
__init__
python
fonttools/fonttools
Tests/pens/utils.py
https://github.com/fonttools/fonttools/blob/master/Tests/pens/utils.py
MIT
def draw(self, pen): """Use another SegmentPen to replay the glyph's outline commands.""" if self.outline: for cmd, args, kwargs in self.outline: getattr(pen, cmd)(*args, **kwargs)
Use another SegmentPen to replay the glyph's outline commands.
draw
python
fonttools/fonttools
Tests/pens/utils.py
https://github.com/fonttools/fonttools/blob/master/Tests/pens/utils.py
MIT
def __eq__(self, other): """Return True if 'other' glyph's outline is the same as self.""" if hasattr(other, "outline"): return self.outline == other.outline elif hasattr(other, "draw"): return self.outline == self.__class__(other).outline return NotImplemented
Return True if 'other' glyph's outline is the same as self.
__eq__
python
fonttools/fonttools
Tests/pens/utils.py
https://github.com/fonttools/fonttools/blob/master/Tests/pens/utils.py
MIT
def drawPoints(self, pointPen): """Use another PointPen to replay the glyph's outline commands.""" if self.outline: for cmd, args, kwargs in self.outline: getattr(pointPen, cmd)(*args, **kwargs)
Use another PointPen to replay the glyph's outline commands.
drawPoints
python
fonttools/fonttools
Tests/pens/utils.py
https://github.com/fonttools/fonttools/blob/master/Tests/pens/utils.py
MIT
def _repr_pen_commands(commands): """ >>> print(_repr_pen_commands([ ... ('moveTo', tuple(), {}), ... ('lineTo', ((1.0, 0.1),), {}), ... ('curveTo', ((1.0, 0.1), (2.0, 0.2), (3.0, 0.3)), {}) ... ])) pen.moveTo() pen.lineTo((1, 0.1)) pen.curveTo((1, 0.1), (2, 0.2), (3, 0.3...
>>> print(_repr_pen_commands([ ... ('moveTo', tuple(), {}), ... ('lineTo', ((1.0, 0.1),), {}), ... ('curveTo', ((1.0, 0.1), (2.0, 0.2), (3.0, 0.3)), {}) ... ])) pen.moveTo() pen.lineTo((1, 0.1)) pen.curveTo((1, 0.1), (2, 0.2), (3, 0.3)) >>> print(_repr_pen_commands([ ...
_repr_pen_commands
python
fonttools/fonttools
Tests/pens/utils.py
https://github.com/fonttools/fonttools/blob/master/Tests/pens/utils.py
MIT
def normalise_table(font, tag, padding=4): """Return normalised table data. Keep 'font' instance unmodified.""" assert tag in ("glyf", "loca", "head") assert tag in font if tag == "head": origHeadFlags = font["head"].flags font["head"].flags |= 1 << 11 tableData = font["head"].co...
Return normalised table data. Keep 'font' instance unmodified.
normalise_table
python
fonttools/fonttools
Tests/ttLib/woff2_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/ttLib/woff2_test.py
MIT
def normalise_font(font, padding=4): """Return normalised font data. Keep 'font' instance unmodified.""" # drop DSIG but keep a copy DSIG_copy = copy.deepcopy(font["DSIG"]) del font["DSIG"] # override TTFont attributes origFlavor = font.flavor origRecalcBBoxes = font.recalcBBoxes origRec...
Return normalised font data. Keep 'font' instance unmodified.
normalise_font
python
fonttools/fonttools
Tests/ttLib/woff2_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/ttLib/woff2_test.py
MIT
def test_xml_from_xml(testfile, tableTag): """Check XML from object read from XML.""" _skip_if_requirement_missing(testfile) xml_expected = read_expected_ttx(testfile, tableTag) font = load_ttx(xml_expected) name = os.path.splitext(testfile)[0] setupfile = getpath("%s.ttx.%s.setup" % (name, ta...
Check XML from object read from XML.
test_xml_from_xml
python
fonttools/fonttools
Tests/ttLib/tables/tables_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/ttLib/tables/tables_test.py
MIT
def testUnicodes_hex_present(self): """Test that a present <unicode> element must have a 'hex' attribute; by testing that an invalid <unicode> element raises an appropriate error. """ # illegal glif = """ <glyph name="a" format="1"> <unicode /> <outline> </out...
Test that a present <unicode> element must have a 'hex' attribute; by testing that an invalid <unicode> element raises an appropriate error.
testUnicodes_hex_present
python
fonttools/fonttools
Tests/ufoLib/GLIF1_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/ufoLib/GLIF1_test.py
MIT
def testReadGlyphInvalidXml(self): """Test that calling readGlyph() to read a .glif with invalid XML raises a library error, instead of an exception from the XML dependency that is used internally. In addition, check that the raised exception describes the glyph by name and gives the loc...
Test that calling readGlyph() to read a .glif with invalid XML raises a library error, instead of an exception from the XML dependency that is used internally. In addition, check that the raised exception describes the glyph by name and gives the location of the broken .glif file.
testReadGlyphInvalidXml
python
fonttools/fonttools
Tests/ufoLib/glifLib_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/ufoLib/glifLib_test.py
MIT
def test_read_invalid_xml(self): """Test that calling readGlyphFromString() with invalid XML raises a library error, instead of an exception from the XML dependency that is used internally.""" invalid_xml = b"<abc></def>" empty_glyph = _Glyph() with pytest.raises(GlifLi...
Test that calling readGlyphFromString() with invalid XML raises a library error, instead of an exception from the XML dependency that is used internally.
test_read_invalid_xml
python
fonttools/fonttools
Tests/ufoLib/glifLib_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/ufoLib/glifLib_test.py
MIT
def test_read_ensure_x_y(self): """Ensure that a proper GlifLibError is raised when point coordinates are missing, regardless of validation setting.""" s = """<?xml version='1.0' encoding='utf-8'?> <glyph name="A" format="2"> <outline> <contour> <point x="545" y="0" type="line"/> ...
Ensure that a proper GlifLibError is raised when point coordinates are missing, regardless of validation setting.
test_read_ensure_x_y
python
fonttools/fonttools
Tests/ufoLib/glifLib_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/ufoLib/glifLib_test.py
MIT
def getDemoFontPath(): """Return the path to Data/DemoFont.ufo/.""" testdata = os.path.join(os.path.dirname(__file__), "testdata") return os.path.join(testdata, "DemoFont.ufo")
Return the path to Data/DemoFont.ufo/.
getDemoFontPath
python
fonttools/fonttools
Tests/ufoLib/testSupport.py
https://github.com/fonttools/fonttools/blob/master/Tests/ufoLib/testSupport.py
MIT
def test_empty_vhvar_size(): """HVAR/VHVAR should be present but empty when there are no glyph metrics variations, and should use a direct mapping for optimal encoding.""" # Make a designspace that varies the outlines of 'A' but not its advance. doc = DesignSpaceDocument() doc.addAxis( Axi...
HVAR/VHVAR should be present but empty when there are no glyph metrics variations, and should use a direct mapping for optimal encoding.
test_empty_vhvar_size
python
fonttools/fonttools
Tests/varLib/builder_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/builder_test.py
MIT
def check_ttx_dump(self, font, expected_ttx, tables, suffix): """Ensure the TTX dump is the same after saving and reloading the font.""" path = self.temp_path(suffix=suffix) font.save(path) self.expect_ttx(TTFont(path), expected_ttx, tables)
Ensure the TTX dump is the same after saving and reloading the font.
check_ttx_dump
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GSUB_only_ttf(self): """Only GSUB, and only in the base master. The variable font will inherit the GSUB table from the base master. """ suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = sel...
Only GSUB, and only in the base master. The variable font will inherit the GSUB table from the base master.
test_varlib_interpolate_layout_GSUB_only_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_no_GSUB_ttf(self): """The base master has no GSUB table. The variable font will end up without a GSUB table. """ suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout2.designspace") ufo_dir = self.get_test_input("master_ufo")...
The base master has no GSUB table. The variable font will end up without a GSUB table.
test_varlib_interpolate_layout_no_GSUB_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GSUB_only_no_axes_ttf(self): """Only GSUB, and only in the base master. Designspace file has no <axes> element. The variable font will inherit the GSUB table from the base master. """ ds_path = self.get_test_input("InterpolateLayout3.de...
Only GSUB, and only in the base master. Designspace file has no <axes> element. The variable font will inherit the GSUB table from the base master.
test_varlib_interpolate_layout_GSUB_only_no_axes_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_size_feat_same_val_ttf(self): """Only GPOS; 'size' feature; same values in all masters.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.get_test_input("master_ufo") ttx_dir = self.get_te...
Only GPOS; 'size' feature; same values in all masters.
test_varlib_interpolate_layout_GPOS_only_size_feat_same_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_1_same_val_ttf(self): """Only GPOS; LookupType 1; same values in all masters.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.get_test_input("master_ufo") ttx_dir = self.get_t...
Only GPOS; LookupType 1; same values in all masters.
test_varlib_interpolate_layout_GPOS_only_LookupType_1_same_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_1_diff_val_ttf(self): """Only GPOS; LookupType 1; different values in each master.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.get_test_input("master_ufo") ttx_dir = self....
Only GPOS; LookupType 1; different values in each master.
test_varlib_interpolate_layout_GPOS_only_LookupType_1_diff_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_1_diff2_val_ttf(self): """Only GPOS; LookupType 1; different values and items in each master.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.get_test_input("master_ufo") ttx_...
Only GPOS; LookupType 1; different values and items in each master.
test_varlib_interpolate_layout_GPOS_only_LookupType_1_diff2_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_2_spec_pairs_same_val_ttf( self, ): """Only GPOS; LookupType 2 specific pairs; same values in all masters.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.get_test_input("...
Only GPOS; LookupType 2 specific pairs; same values in all masters.
test_varlib_interpolate_layout_GPOS_only_LookupType_2_spec_pairs_same_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_2_spec_pairs_diff_val_ttf( self, ): """Only GPOS; LookupType 2 specific pairs; different values in each master.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.get_test_in...
Only GPOS; LookupType 2 specific pairs; different values in each master.
test_varlib_interpolate_layout_GPOS_only_LookupType_2_spec_pairs_diff_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_2_spec_pairs_diff2_val_ttf( self, ): """Only GPOS; LookupType 2 specific pairs; different values and items in each master.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self....
Only GPOS; LookupType 2 specific pairs; different values and items in each master.
test_varlib_interpolate_layout_GPOS_only_LookupType_2_spec_pairs_diff2_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_2_class_pairs_same_val_ttf( self, ): """Only GPOS; LookupType 2 class pairs; same values in all masters.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.get_test_input("ma...
Only GPOS; LookupType 2 class pairs; same values in all masters.
test_varlib_interpolate_layout_GPOS_only_LookupType_2_class_pairs_same_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_2_class_pairs_diff_val_ttf( self, ): """Only GPOS; LookupType 2 class pairs; different values in each master.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.get_test_inpu...
Only GPOS; LookupType 2 class pairs; different values in each master.
test_varlib_interpolate_layout_GPOS_only_LookupType_2_class_pairs_diff_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT
def test_varlib_interpolate_layout_GPOS_only_LookupType_2_class_pairs_diff2_val_ttf( self, ): """Only GPOS; LookupType 2 class pairs; different values and items in each master.""" suffix = ".ttf" ds_path = self.get_test_input("InterpolateLayout.designspace") ufo_dir = self.ge...
Only GPOS; LookupType 2 class pairs; different values and items in each master.
test_varlib_interpolate_layout_GPOS_only_LookupType_2_class_pairs_diff2_val_ttf
python
fonttools/fonttools
Tests/varLib/interpolate_layout_test.py
https://github.com/fonttools/fonttools/blob/master/Tests/varLib/interpolate_layout_test.py
MIT