signwriting 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.
@@ -1,4 +1,5 @@
1
- from functools import lru_cache
1
+ import os
2
+ from functools import cache
2
3
  from pathlib import Path
3
4
  from typing import Tuple, List, Literal, Union
4
5
 
@@ -13,13 +14,13 @@ from signwriting.formats.swu_to_fsw import swu2fsw
13
14
  RGBA = Tuple[int, int, int, int]
14
15
 
15
16
 
16
- @lru_cache(maxsize=None)
17
+ @cache
17
18
  def get_font(font_name: str) -> ImageFont.FreeTypeFont:
18
19
  font_path = Path(__file__).parent / f'{font_name}.ttf'
19
20
  return ImageFont.truetype(str(font_path), 30)
20
21
 
21
22
 
22
- @lru_cache(maxsize=None)
23
+ @cache
23
24
  def get_symbol_size(symbol: str):
24
25
  font = get_font('SuttonSignWritingLine')
25
26
  line_id = symbol_line(key2id(symbol))
@@ -27,6 +28,17 @@ def get_symbol_size(symbol: str):
27
28
  return right - left, bottom - top
28
29
 
29
30
 
31
+ def _clear_caches_after_fork():
32
+ # ImageFont objects cached by lru_cache can become corrupted after fork(),
33
+ # causing garbage data (e.g., wrong image dimensions). Clear caches in child
34
+ # processes so fonts are reloaded fresh.
35
+ get_font.cache_clear()
36
+ get_symbol_size.cache_clear()
37
+
38
+
39
+ os.register_at_fork(after_in_child=_clear_caches_after_fork)
40
+
41
+
30
42
  # pylint: disable=too-many-locals, too-many-arguments
31
43
  def signwriting_to_image(fsw: Union[str, List[str]], antialiasing=True, trust_box=True, embedded_color=False,
32
44
  line_color: RGBA = (0, 0, 0, 255),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: signwriting
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Python utilities for SignWriting.
5
5
  Author-email: Amit Moryossef <amitmoryossef@gmail.com>
6
6
  Description-Content-Type: text/markdown
@@ -59,9 +59,9 @@ signwriting/visualizer/SuttonSignWritingOneD.ttf,sha256=R-1Kih4jwVOovKdSbVDh9BmA
59
59
  signwriting/visualizer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  signwriting/visualizer/server.py,sha256=qWgN7kIei7BE1K-kpiS5Dx47t1qNKuU5YfrjKs7douo,1603
61
61
  signwriting/visualizer/test_visualize.py,sha256=eH4D89bEb8DpRgNVpd3uLIHuIw5kPosWlVl9ry0y9g4,4059
62
- signwriting/visualizer/visualize.py,sha256=srMllB8y2u_xM3698YqmY-ychEvaemsM4d06hOVLf68,4029
63
- signwriting-0.1.2.dist-info/licenses/LICENSE,sha256=5DdbOXGaeoF-PL0-HkJOUmegksP13HD8FRy6-1m-D-o,1081
64
- signwriting-0.1.2.dist-info/METADATA,sha256=TZyELOmzKObrhRxv4nTyZu1ZfZtr1TOqim4XyVQpJlI,5969
65
- signwriting-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
66
- signwriting-0.1.2.dist-info/top_level.txt,sha256=MbwynBxqcjJN-XMzTmwzp7wgQ0mzu7X-bjVQZMrOvGw,12
67
- signwriting-0.1.2.dist-info/RECORD,,
62
+ signwriting/visualizer/visualize.py,sha256=BiDWcRyv36N8rgZZJDcmE5O3f8_xiAVoC7jV1atNUno,4362
63
+ signwriting-0.1.3.dist-info/licenses/LICENSE,sha256=5DdbOXGaeoF-PL0-HkJOUmegksP13HD8FRy6-1m-D-o,1081
64
+ signwriting-0.1.3.dist-info/METADATA,sha256=hGcPEGjgsLqjC1w3FfeFVumbJontpSMfY7OV44-l2MA,5969
65
+ signwriting-0.1.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
66
+ signwriting-0.1.3.dist-info/top_level.txt,sha256=MbwynBxqcjJN-XMzTmwzp7wgQ0mzu7X-bjVQZMrOvGw,12
67
+ signwriting-0.1.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5