python-fontbro 0.32.1__tar.gz → 0.33.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_fontbro-0.32.1/python_fontbro.egg-info → python_fontbro-0.33.0}/PKG-INFO +1 -1
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/metadata.py +1 -1
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/version.py +27 -7
- {python_fontbro-0.32.1 → python_fontbro-0.33.0/python_fontbro.egg-info}/PKG-INFO +1 -1
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_version.py +18 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/LICENSE.txt +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/MANIFEST.in +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/README.md +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/__init__.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/bitmap.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/color.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/data/family-classifications.json +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/data/features.json +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/data/unicode-blocks.json +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/data/unicode-scripts.json +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/embedding_permissions.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/exceptions.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/family_classification.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/features.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/files.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/fingerprint.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/flags.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/font.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/glyphs.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/math.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/metrics.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/monospace.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/names.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/pixel.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/py.typed +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/render.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/sanitize.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/style_flags.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/subset.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/support.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/tables.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/unicode.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/utils.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/variable.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/pyproject.toml +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/SOURCES.txt +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/dependency_links.txt +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/requires.txt +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/top_level.txt +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/setup.cfg +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/setup.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_bitmap.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_characters.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_clone.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_close.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_collection.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_color.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_context_manager.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_embedding_permissions.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_exceptions.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_family_classification.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_family_name.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_features.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_filename.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_fingerprint.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_format.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_glyphs.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_image.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_init.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_instantiation.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_issues.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_italic_angle.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_monospace.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_names.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_pixel.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_rename.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_sanitize.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_save.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_str.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_style_flags.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_style_name.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_subset.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_support.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_svg.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_tables.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_unicode.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_unicode_blocks_and_scripts.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_update_unicode_data.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_variable.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_vertical_metrics.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_weight.py +0 -0
- {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_width.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any, overload
|
|
5
5
|
|
|
6
6
|
from fontTools.misc.fixedTools import fixedToStr, floatToFixed
|
|
7
7
|
from fontTools.ttLib import TTFont
|
|
@@ -74,23 +74,43 @@ def format_version(
|
|
|
74
74
|
return f"{prefix}{major}.{minor}"
|
|
75
75
|
|
|
76
76
|
|
|
77
|
+
@overload
|
|
77
78
|
def parse_version(
|
|
78
79
|
value: str | None,
|
|
79
|
-
|
|
80
|
+
*,
|
|
81
|
+
default: float = ...,
|
|
82
|
+
) -> float: ...
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@overload
|
|
86
|
+
def parse_version(
|
|
87
|
+
value: str | None,
|
|
88
|
+
*,
|
|
89
|
+
default: None,
|
|
90
|
+
) -> float | None: ...
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def parse_version(
|
|
94
|
+
value: str | None,
|
|
95
|
+
*,
|
|
96
|
+
default: float | None = 0.0,
|
|
97
|
+
) -> float | None:
|
|
80
98
|
"""
|
|
81
99
|
Parses the version value from the given version name record value,
|
|
82
100
|
eg. "Version 1.015;git-0a5106e0b" -> 1.015.
|
|
83
101
|
The value is matched from the beginning of the string to avoid reading
|
|
84
102
|
unrelated numbers (eg. a date or a tool version).
|
|
85
|
-
Returns 0.0 if the value cannot be parsed, or if it holds
|
|
86
|
-
cannot be stored as a font version.
|
|
103
|
+
Returns the default (0.0) if the value cannot be parsed, or if it holds
|
|
104
|
+
a value that cannot be stored as a font version. A zero version
|
|
105
|
+
(eg. "Version 0.000") is parsed as 0.0: with default=None it can be told
|
|
106
|
+
apart from a value that cannot be parsed.
|
|
87
107
|
"""
|
|
88
108
|
match = _VERSION_PATTERN.match((value or "").strip())
|
|
89
109
|
if not match:
|
|
90
|
-
return
|
|
110
|
+
return default
|
|
91
111
|
version = float(f"{match[1]}.{match[2]}")
|
|
92
|
-
if not 0
|
|
93
|
-
return
|
|
112
|
+
if not 0 <= version <= _VERSION_MAX_VALUE:
|
|
113
|
+
return default
|
|
94
114
|
return normalize_version(version)
|
|
95
115
|
|
|
96
116
|
|
|
@@ -76,6 +76,24 @@ class VersionTestCase(AbstractTestCase):
|
|
|
76
76
|
with self.subTest(f"Test with value: {value!r}", value=value):
|
|
77
77
|
self.assertEqual(parse_version(value), expected_value)
|
|
78
78
|
|
|
79
|
+
def test_parse_version_with_default(self):
|
|
80
|
+
values = [
|
|
81
|
+
("Version 1.015", 1.015),
|
|
82
|
+
# a zero version is a version (eg. a font in development)
|
|
83
|
+
("Version 0.000", 0.0),
|
|
84
|
+
("0.000", 0.0),
|
|
85
|
+
# invalid values
|
|
86
|
+
(None, None),
|
|
87
|
+
("", None),
|
|
88
|
+
("Regular", None),
|
|
89
|
+
("1", None),
|
|
90
|
+
("Version 32768.0", None),
|
|
91
|
+
]
|
|
92
|
+
for value, expected_value in values:
|
|
93
|
+
with self.subTest(f"Test with value: {value!r}", value=value):
|
|
94
|
+
self.assertEqual(parse_version(value, default=None), expected_value)
|
|
95
|
+
self.assertEqual(parse_version("Regular", default=1.0), 1.0)
|
|
96
|
+
|
|
79
97
|
def test_normalize_version(self):
|
|
80
98
|
values = [
|
|
81
99
|
(1.0149993896484375, 1.015),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|