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 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_scalar_avar(self):
"""Test that the `avar` table is consulted when normalizing user-space
values."""
features = """
languagesystem DFLT dflt;
feature kern {
pos cursive one <anchor 0 (wght=200:12 wght=900:22 wdth=150,wght=900:42... | Test that the `avar` table is consulted when normalizing user-space
values. | test_variable_scalar_avar | python | fonttools/fonttools | Tests/feaLib/builder_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/feaLib/builder_test.py | MIT |
def test_ligatureCaretByPos_variable_scalar(self):
"""Test that the `avar` table is consulted when normalizing user-space
values."""
features = """
table GDEF {
LigatureCaretByPos f_i (wght=200:400 wght=900:1000) 380;
} GDEF;
"""
font = s... | Test that the `avar` table is consulted when normalizing user-space
values. | test_ligatureCaretByPos_variable_scalar | 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 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="2">
<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/GLIF2_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/ufoLib/GLIF2_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 |
def test_varlib_interpolate_layout_GPOS_only_LookupType_3_same_val_ttf(self):
"""Only GPOS; LookupType 3; 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 3; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_3_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_3_diff_val_ttf(self):
"""Only GPOS; LookupType 3; 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 3; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_3_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_4_same_val_ttf(self):
"""Only GPOS; LookupType 4; 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 4; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_4_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_4_diff_val_ttf(self):
"""Only GPOS; LookupType 4; 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 4; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_4_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_5_same_val_ttf(self):
"""Only GPOS; LookupType 5; 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 5; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_5_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_5_diff_val_ttf(self):
"""Only GPOS; LookupType 5; 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 5; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_5_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_6_same_val_ttf(self):
"""Only GPOS; LookupType 6; 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 6; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_6_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_6_diff_val_ttf(self):
"""Only GPOS; LookupType 6; 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 6; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_6_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_7_same_val_ttf(self):
"""Only GPOS; LookupType 7; 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 7; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_7_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_7_diff_val_ttf(self):
"""Only GPOS; LookupType 7; 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 7; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_7_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_8_same_val_ttf(self):
"""Only GPOS; LookupType 8; 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 8; same values in all masters. | test_varlib_interpolate_layout_GPOS_only_LookupType_8_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_8_diff_val_ttf(self):
"""Only GPOS; LookupType 8; 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 8; different values in each master. | test_varlib_interpolate_layout_GPOS_only_LookupType_8_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 reload_font(font):
"""(De)serialize to get final binary layout."""
buf = BytesIO()
font.save(buf)
# Close the font to release filesystem resources so that on Windows the tearDown
# method can successfully remove the temporary directory created during setUp.
font.close()
buf.seek(0)
r... | (De)serialize to get final binary layout. | reload_font | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_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/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_ttf_reuse_nameid_2(self):
"""Instances at the default location can reuse name ID 2 or 17."""
self._run_varlib_build_test(
designspace_name="BuildReuseNameId2",
font_name="TestFamily",
tables=["fvar"],
expected_ttx_name="BuildReuseName... | Instances at the default location can reuse name ID 2 or 17. | test_varlib_build_ttf_reuse_nameid_2 | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_no_axes_ttf(self):
"""Designspace file does not contain an <axes> element."""
ds_path = self.get_test_input("InterpolateLayout3.designspace")
with self.assertRaisesRegex(DesignSpaceDocumentError, "No axes defined"):
build(ds_path) | Designspace file does not contain an <axes> element. | test_varlib_build_no_axes_ttf | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_avar_single_axis(self):
"""Designspace file contains a 'weight' axis with <map> elements
modifying the normalization mapping. An 'avar' table is generated.
"""
test_name = "BuildAvarSingleAxis"
self._run_varlib_build_test(
designspace_name=test_name,
... | Designspace file contains a 'weight' axis with <map> elements
modifying the normalization mapping. An 'avar' table is generated.
| test_varlib_avar_single_axis | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_avar_with_identity_maps(self):
"""Designspace file contains two 'weight' and 'width' axes both with
<map> elements.
The 'width' axis only contains identity mappings, however the resulting
avar segment will not be empty but will contain the default axis value
maps... | Designspace file contains two 'weight' and 'width' axes both with
<map> elements.
The 'width' axis only contains identity mappings, however the resulting
avar segment will not be empty but will contain the default axis value
maps: {-1.0: -1.0, 0.0: 0.0, 1.0: 1.0}.
This is to wo... | test_varlib_avar_with_identity_maps | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_avar_empty_axis(self):
"""Designspace file contains two 'weight' and 'width' axes, but
only one axis ('weight') has some <map> elements.
Even if no <map> elements are defined for the 'width' axis, the
resulting avar segment still contains the default axis value maps:
... | Designspace file contains two 'weight' and 'width' axes, but
only one axis ('weight') has some <map> elements.
Even if no <map> elements are defined for the 'width' axis, the
resulting avar segment still contains the default axis value maps:
{-1.0: -1.0, 0.0: 0.0, 1.0: 1.0}.
Th... | test_varlib_avar_empty_axis | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_avar2(self):
"""Designspace file contains a 'weight' axis with <map> elements
modifying the normalization mapping as well as <mappings> element
modifying it post-normalization. An 'avar' table is generated.
"""
test_name = "BuildAvar2"
self._run_varlib_bui... | Designspace file contains a 'weight' axis with <map> elements
modifying the normalization mapping as well as <mappings> element
modifying it post-normalization. An 'avar' table is generated.
| test_varlib_avar2 | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations(self):
"""Designspace file contains <rules> element, used to build
GSUB FeatureVariations table.
"""
self._run_varlib_build_test(
designspace_name="FeatureVars",
font_name="TestFamily",
tables=["fvar", "GSUB"],
... | Designspace file contains <rules> element, used to build
GSUB FeatureVariations table.
| test_varlib_build_feature_variations | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_custom_tag(self):
"""Designspace file contains <rules> element, used to build
GSUB FeatureVariations table.
"""
self._run_varlib_build_test(
designspace_name="FeatureVarsCustomTag",
font_name="TestFamily",
table... | Designspace file contains <rules> element, used to build
GSUB FeatureVariations table.
| test_varlib_build_feature_variations_custom_tag | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_whole_range(self):
"""Designspace file contains <rules> element specifying the entire design
space, used to build GSUB FeatureVariations table.
"""
self._run_varlib_build_test(
designspace_name="FeatureVarsWholeRange",
font... | Designspace file contains <rules> element specifying the entire design
space, used to build GSUB FeatureVariations table.
| test_varlib_build_feature_variations_whole_range | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_whole_range_empty(self):
"""Designspace file contains <rules> element without a condition, specifying
the entire design space, used to build GSUB FeatureVariations table.
"""
self._run_varlib_build_test(
designspace_name="FeatureVarsWh... | Designspace file contains <rules> element without a condition, specifying
the entire design space, used to build GSUB FeatureVariations table.
| test_varlib_build_feature_variations_whole_range_empty | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_with_existing_rclt(self):
"""Designspace file contains <rules> element, used to build GSUB
FeatureVariations table. <rules> is specified to do its OT processing
"last", so a 'rclt' feature will be used or created. This test covers
the case when a ... | Designspace file contains <rules> element, used to build GSUB
FeatureVariations table. <rules> is specified to do its OT processing
"last", so a 'rclt' feature will be used or created. This test covers
the case when a 'rclt' already exists in the masters.
We dynamically add a 'rclt' fea... | test_varlib_build_feature_variations_with_existing_rclt | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.py | MIT |
def test_varlib_build_feature_variations_without_latn_dflt_feature(self):
"""Test that when a script does not have a dflt language, it gets one
when we later add variations, we can attach them to it."""
def add_features(font, savepath):
features = """
languagesystem DFLT... | Test that when a script does not have a dflt language, it gets one
when we later add variations, we can attach them to it. | test_varlib_build_feature_variations_without_latn_dflt_feature | python | fonttools/fonttools | Tests/varLib/varLib_test.py | https://github.com/fonttools/fonttools/blob/master/Tests/varLib/varLib_test.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.