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.
Files changed (87) hide show
  1. {python_fontbro-0.32.1/python_fontbro.egg-info → python_fontbro-0.33.0}/PKG-INFO +1 -1
  2. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/metadata.py +1 -1
  3. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/version.py +27 -7
  4. {python_fontbro-0.32.1 → python_fontbro-0.33.0/python_fontbro.egg-info}/PKG-INFO +1 -1
  5. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_version.py +18 -0
  6. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/LICENSE.txt +0 -0
  7. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/MANIFEST.in +0 -0
  8. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/README.md +0 -0
  9. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/__init__.py +0 -0
  10. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/bitmap.py +0 -0
  11. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/color.py +0 -0
  12. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/data/family-classifications.json +0 -0
  13. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/data/features.json +0 -0
  14. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/data/unicode-blocks.json +0 -0
  15. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/data/unicode-scripts.json +0 -0
  16. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/embedding_permissions.py +0 -0
  17. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/exceptions.py +0 -0
  18. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/family_classification.py +0 -0
  19. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/features.py +0 -0
  20. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/files.py +0 -0
  21. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/fingerprint.py +0 -0
  22. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/flags.py +0 -0
  23. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/font.py +0 -0
  24. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/glyphs.py +0 -0
  25. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/math.py +0 -0
  26. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/metrics.py +0 -0
  27. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/monospace.py +0 -0
  28. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/names.py +0 -0
  29. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/pixel.py +0 -0
  30. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/py.typed +0 -0
  31. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/render.py +0 -0
  32. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/sanitize.py +0 -0
  33. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/style_flags.py +0 -0
  34. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/subset.py +0 -0
  35. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/support.py +0 -0
  36. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/tables.py +0 -0
  37. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/unicode.py +0 -0
  38. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/utils.py +0 -0
  39. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/fontbro/variable.py +0 -0
  40. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/pyproject.toml +0 -0
  41. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/SOURCES.txt +0 -0
  42. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/dependency_links.txt +0 -0
  43. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/requires.txt +0 -0
  44. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/python_fontbro.egg-info/top_level.txt +0 -0
  45. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/setup.cfg +0 -0
  46. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/setup.py +0 -0
  47. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_bitmap.py +0 -0
  48. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_characters.py +0 -0
  49. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_clone.py +0 -0
  50. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_close.py +0 -0
  51. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_collection.py +0 -0
  52. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_color.py +0 -0
  53. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_context_manager.py +0 -0
  54. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_embedding_permissions.py +0 -0
  55. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_exceptions.py +0 -0
  56. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_family_classification.py +0 -0
  57. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_family_name.py +0 -0
  58. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_features.py +0 -0
  59. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_filename.py +0 -0
  60. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_fingerprint.py +0 -0
  61. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_format.py +0 -0
  62. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_glyphs.py +0 -0
  63. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_image.py +0 -0
  64. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_init.py +0 -0
  65. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_instantiation.py +0 -0
  66. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_issues.py +0 -0
  67. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_italic_angle.py +0 -0
  68. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_monospace.py +0 -0
  69. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_names.py +0 -0
  70. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_pixel.py +0 -0
  71. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_rename.py +0 -0
  72. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_sanitize.py +0 -0
  73. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_save.py +0 -0
  74. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_str.py +0 -0
  75. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_style_flags.py +0 -0
  76. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_style_name.py +0 -0
  77. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_subset.py +0 -0
  78. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_support.py +0 -0
  79. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_svg.py +0 -0
  80. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_tables.py +0 -0
  81. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_unicode.py +0 -0
  82. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_unicode_blocks_and_scripts.py +0 -0
  83. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_update_unicode_data.py +0 -0
  84. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_variable.py +0 -0
  85. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_vertical_metrics.py +0 -0
  86. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_weight.py +0 -0
  87. {python_fontbro-0.32.1 → python_fontbro-0.33.0}/tests/test_width.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fontbro
3
- Version: 0.32.1
3
+ Version: 0.33.0
4
4
  Summary: friendly font operations on top of fontTools.
5
5
  Author-email: Fabio Caccamo <fabio.caccamo@gmail.com>
6
6
  Maintainer-email: Fabio Caccamo <fabio.caccamo@gmail.com>
@@ -4,4 +4,4 @@ __description__ = "friendly font operations on top of fontTools."
4
4
  __email__ = "fabio.caccamo@gmail.com"
5
5
  __license__ = "MIT"
6
6
  __title__ = "python-fontbro"
7
- __version__ = "0.32.1"
7
+ __version__ = "0.33.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
- ) -> float:
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 a value that
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 0.0
110
+ return default
91
111
  version = float(f"{match[1]}.{match[2]}")
92
- if not 0 < version <= _VERSION_MAX_VALUE:
93
- return 0.0
112
+ if not 0 <= version <= _VERSION_MAX_VALUE:
113
+ return default
94
114
  return normalize_version(version)
95
115
 
96
116
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fontbro
3
- Version: 0.32.1
3
+ Version: 0.33.0
4
4
  Summary: friendly font operations on top of fontTools.
5
5
  Author-email: Fabio Caccamo <fabio.caccamo@gmail.com>
6
6
  Maintainer-email: Fabio Caccamo <fabio.caccamo@gmail.com>
@@ -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),