svg-ultralight 0.48.0__py3-none-any.whl → 0.50.1__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.
Potentially problematic release.
This version of svg-ultralight might be problematic. Click here for more details.
- svg_ultralight/__init__.py +108 -105
- svg_ultralight/animate.py +40 -40
- svg_ultralight/attrib_hints.py +13 -14
- svg_ultralight/bounding_boxes/__init__.py +5 -5
- svg_ultralight/bounding_boxes/bound_helpers.py +189 -189
- svg_ultralight/bounding_boxes/padded_text_initializers.py +207 -207
- svg_ultralight/bounding_boxes/supports_bounds.py +166 -166
- svg_ultralight/bounding_boxes/type_bound_collection.py +71 -71
- svg_ultralight/bounding_boxes/type_bound_element.py +65 -65
- svg_ultralight/bounding_boxes/type_bounding_box.py +396 -396
- svg_ultralight/bounding_boxes/type_padded_text.py +411 -411
- svg_ultralight/constructors/__init__.py +14 -14
- svg_ultralight/constructors/new_element.py +115 -115
- svg_ultralight/font_tools/__init__.py +5 -5
- svg_ultralight/font_tools/comp_results.py +295 -293
- svg_ultralight/font_tools/font_info.py +793 -792
- svg_ultralight/image_ops.py +156 -156
- svg_ultralight/inkscape.py +261 -261
- svg_ultralight/layout.py +290 -291
- svg_ultralight/main.py +183 -198
- svg_ultralight/metadata.py +122 -122
- svg_ultralight/nsmap.py +36 -36
- svg_ultralight/py.typed +5 -0
- svg_ultralight/query.py +254 -249
- svg_ultralight/read_svg.py +58 -0
- svg_ultralight/root_elements.py +87 -87
- svg_ultralight/string_conversion.py +244 -244
- svg_ultralight/strings/__init__.py +21 -13
- svg_ultralight/strings/svg_strings.py +106 -67
- svg_ultralight/transformations.py +140 -141
- svg_ultralight/unit_conversion.py +247 -248
- {svg_ultralight-0.48.0.dist-info → svg_ultralight-0.50.1.dist-info}/METADATA +208 -214
- svg_ultralight-0.50.1.dist-info/RECORD +34 -0
- svg_ultralight-0.50.1.dist-info/WHEEL +4 -0
- svg_ultralight-0.48.0.dist-info/RECORD +0 -34
- svg_ultralight-0.48.0.dist-info/WHEEL +0 -5
- svg_ultralight-0.48.0.dist-info/top_level.txt +0 -1
svg_ultralight/__init__.py
CHANGED
|
@@ -1,105 +1,108 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
:author:
|
|
4
|
-
:created: 12
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from svg_ultralight.bounding_boxes.bound_helpers import (
|
|
8
|
-
bbox_dict,
|
|
9
|
-
cut_bbox,
|
|
10
|
-
new_bbox_rect,
|
|
11
|
-
new_bbox_union,
|
|
12
|
-
new_bound_union,
|
|
13
|
-
new_element_union,
|
|
14
|
-
pad_bbox,
|
|
15
|
-
parse_bound_element,
|
|
16
|
-
)
|
|
17
|
-
from svg_ultralight.bounding_boxes.padded_text_initializers import (
|
|
18
|
-
pad_text,
|
|
19
|
-
pad_text_ft,
|
|
20
|
-
pad_text_mix,
|
|
21
|
-
)
|
|
22
|
-
from svg_ultralight.bounding_boxes.supports_bounds import SupportsBounds
|
|
23
|
-
from svg_ultralight.bounding_boxes.type_bound_collection import BoundCollection
|
|
24
|
-
from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
|
|
25
|
-
from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
|
|
26
|
-
from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
|
|
27
|
-
from svg_ultralight.constructors.new_element import (
|
|
28
|
-
deepcopy_element,
|
|
29
|
-
new_element,
|
|
30
|
-
new_sub_element,
|
|
31
|
-
update_element,
|
|
32
|
-
)
|
|
33
|
-
from svg_ultralight.font_tools.comp_results import check_font_tools_alignment
|
|
34
|
-
from svg_ultralight.inkscape import (
|
|
35
|
-
write_pdf,
|
|
36
|
-
write_pdf_from_svg,
|
|
37
|
-
write_png,
|
|
38
|
-
write_png_from_svg,
|
|
39
|
-
write_root,
|
|
40
|
-
)
|
|
41
|
-
from svg_ultralight.main import new_svg_root, write_svg
|
|
42
|
-
from svg_ultralight.metadata import new_metadata
|
|
43
|
-
from svg_ultralight.nsmap import NSMAP, new_qname
|
|
44
|
-
from svg_ultralight.query import (
|
|
45
|
-
clear_svg_ultralight_cache,
|
|
46
|
-
get_bounding_box,
|
|
47
|
-
get_bounding_boxes,
|
|
48
|
-
)
|
|
49
|
-
from svg_ultralight.
|
|
50
|
-
from svg_ultralight.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
|
|
1
|
+
"""Import functions into the package namespace.
|
|
2
|
+
|
|
3
|
+
:author: ShayHill
|
|
4
|
+
:created: 2019-12-22
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from svg_ultralight.bounding_boxes.bound_helpers import (
|
|
8
|
+
bbox_dict,
|
|
9
|
+
cut_bbox,
|
|
10
|
+
new_bbox_rect,
|
|
11
|
+
new_bbox_union,
|
|
12
|
+
new_bound_union,
|
|
13
|
+
new_element_union,
|
|
14
|
+
pad_bbox,
|
|
15
|
+
parse_bound_element,
|
|
16
|
+
)
|
|
17
|
+
from svg_ultralight.bounding_boxes.padded_text_initializers import (
|
|
18
|
+
pad_text,
|
|
19
|
+
pad_text_ft,
|
|
20
|
+
pad_text_mix,
|
|
21
|
+
)
|
|
22
|
+
from svg_ultralight.bounding_boxes.supports_bounds import SupportsBounds
|
|
23
|
+
from svg_ultralight.bounding_boxes.type_bound_collection import BoundCollection
|
|
24
|
+
from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
|
|
25
|
+
from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
|
|
26
|
+
from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
|
|
27
|
+
from svg_ultralight.constructors.new_element import (
|
|
28
|
+
deepcopy_element,
|
|
29
|
+
new_element,
|
|
30
|
+
new_sub_element,
|
|
31
|
+
update_element,
|
|
32
|
+
)
|
|
33
|
+
from svg_ultralight.font_tools.comp_results import check_font_tools_alignment
|
|
34
|
+
from svg_ultralight.inkscape import (
|
|
35
|
+
write_pdf,
|
|
36
|
+
write_pdf_from_svg,
|
|
37
|
+
write_png,
|
|
38
|
+
write_png_from_svg,
|
|
39
|
+
write_root,
|
|
40
|
+
)
|
|
41
|
+
from svg_ultralight.main import new_svg_root, write_svg
|
|
42
|
+
from svg_ultralight.metadata import new_metadata
|
|
43
|
+
from svg_ultralight.nsmap import NSMAP, new_qname
|
|
44
|
+
from svg_ultralight.query import (
|
|
45
|
+
clear_svg_ultralight_cache,
|
|
46
|
+
get_bounding_box,
|
|
47
|
+
get_bounding_boxes,
|
|
48
|
+
)
|
|
49
|
+
from svg_ultralight.read_svg import get_bounding_box_from_root, parse
|
|
50
|
+
from svg_ultralight.root_elements import new_svg_root_around_bounds
|
|
51
|
+
from svg_ultralight.string_conversion import (
|
|
52
|
+
format_attr_dict,
|
|
53
|
+
format_number,
|
|
54
|
+
format_numbers,
|
|
55
|
+
)
|
|
56
|
+
from svg_ultralight.transformations import (
|
|
57
|
+
mat_apply,
|
|
58
|
+
mat_dot,
|
|
59
|
+
mat_invert,
|
|
60
|
+
transform_element,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
__all__ = [
|
|
64
|
+
"NSMAP",
|
|
65
|
+
"BoundCollection",
|
|
66
|
+
"BoundElement",
|
|
67
|
+
"BoundingBox",
|
|
68
|
+
"PaddedText",
|
|
69
|
+
"SupportsBounds",
|
|
70
|
+
"bbox_dict",
|
|
71
|
+
"check_font_tools_alignment",
|
|
72
|
+
"clear_svg_ultralight_cache",
|
|
73
|
+
"cut_bbox",
|
|
74
|
+
"deepcopy_element",
|
|
75
|
+
"format_attr_dict",
|
|
76
|
+
"format_number",
|
|
77
|
+
"format_numbers",
|
|
78
|
+
"get_bounding_box",
|
|
79
|
+
"get_bounding_box_from_root",
|
|
80
|
+
"get_bounding_boxes",
|
|
81
|
+
"mat_apply",
|
|
82
|
+
"mat_dot",
|
|
83
|
+
"mat_invert",
|
|
84
|
+
"new_bbox_rect",
|
|
85
|
+
"new_bbox_union",
|
|
86
|
+
"new_bound_union",
|
|
87
|
+
"new_element",
|
|
88
|
+
"new_element_union",
|
|
89
|
+
"new_metadata",
|
|
90
|
+
"new_qname",
|
|
91
|
+
"new_sub_element",
|
|
92
|
+
"new_svg_root",
|
|
93
|
+
"new_svg_root_around_bounds",
|
|
94
|
+
"pad_bbox",
|
|
95
|
+
"pad_text",
|
|
96
|
+
"pad_text_ft",
|
|
97
|
+
"pad_text_mix",
|
|
98
|
+
"parse",
|
|
99
|
+
"parse_bound_element",
|
|
100
|
+
"transform_element",
|
|
101
|
+
"update_element",
|
|
102
|
+
"write_pdf",
|
|
103
|
+
"write_pdf_from_svg",
|
|
104
|
+
"write_png",
|
|
105
|
+
"write_png_from_svg",
|
|
106
|
+
"write_root",
|
|
107
|
+
"write_svg",
|
|
108
|
+
]
|
svg_ultralight/animate.py
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
"""One script to animate a list of pngs.
|
|
2
|
-
|
|
3
|
-
Requires: pillow, which is an optional project dependency.
|
|
4
|
-
|
|
5
|
-
:author: Shay Hill
|
|
6
|
-
:created: 7/26/2020
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
from __future__ import annotations
|
|
10
|
-
|
|
11
|
-
try:
|
|
12
|
-
from PIL import Image
|
|
13
|
-
except ModuleNotFoundError as exc:
|
|
14
|
-
MSG = "`pip install pillow` to use svg_ultralight.animate module"
|
|
15
|
-
raise ModuleNotFoundError(MSG) from exc
|
|
16
|
-
from typing import TYPE_CHECKING
|
|
17
|
-
|
|
18
|
-
if TYPE_CHECKING:
|
|
19
|
-
import os
|
|
20
|
-
from collections.abc import Iterable
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def write_gif(
|
|
24
|
-
gif: str | os.PathLike[str],
|
|
25
|
-
pngs: Iterable[str] | Iterable[os.PathLike[str]] | Iterable[str | os.PathLike[str]],
|
|
26
|
-
duration: float = 100,
|
|
27
|
-
loop: int = 0,
|
|
28
|
-
) -> None:
|
|
29
|
-
"""Create a gif from a sequence of pngs.
|
|
30
|
-
|
|
31
|
-
:param gif: output filename (include .gif extension)
|
|
32
|
-
:param pngs: png filenames
|
|
33
|
-
:param duration: milliseconds per frame
|
|
34
|
-
:param loop: how many times to loop gif. 0 -> forever
|
|
35
|
-
:effects: write file to gif
|
|
36
|
-
"""
|
|
37
|
-
images = [Image.open(x) for x in pngs]
|
|
38
|
-
images[0].save(
|
|
39
|
-
gif, save_all=True, append_images=images[1:], duration=duration, loop=loop
|
|
40
|
-
)
|
|
1
|
+
"""One script to animate a list of pngs.
|
|
2
|
+
|
|
3
|
+
Requires: pillow, which is an optional project dependency.
|
|
4
|
+
|
|
5
|
+
:author: Shay Hill
|
|
6
|
+
:created: 7/26/2020
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
from PIL import Image
|
|
13
|
+
except ModuleNotFoundError as exc:
|
|
14
|
+
MSG = "`pip install pillow` to use svg_ultralight.animate module"
|
|
15
|
+
raise ModuleNotFoundError(MSG) from exc
|
|
16
|
+
from typing import TYPE_CHECKING
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
import os
|
|
20
|
+
from collections.abc import Iterable
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def write_gif(
|
|
24
|
+
gif: str | os.PathLike[str],
|
|
25
|
+
pngs: Iterable[str] | Iterable[os.PathLike[str]] | Iterable[str | os.PathLike[str]],
|
|
26
|
+
duration: float = 100,
|
|
27
|
+
loop: int = 0,
|
|
28
|
+
) -> None:
|
|
29
|
+
"""Create a gif from a sequence of pngs.
|
|
30
|
+
|
|
31
|
+
:param gif: output filename (include .gif extension)
|
|
32
|
+
:param pngs: png filenames
|
|
33
|
+
:param duration: milliseconds per frame
|
|
34
|
+
:param loop: how many times to loop gif. 0 -> forever
|
|
35
|
+
:effects: write file to gif
|
|
36
|
+
"""
|
|
37
|
+
images = [Image.open(x) for x in pngs]
|
|
38
|
+
images[0].save(
|
|
39
|
+
gif, save_all=True, append_images=images[1:], duration=duration, loop=loop
|
|
40
|
+
)
|
svg_ultralight/attrib_hints.py
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
"""Type hints for pass-through arguments to lxml constructors.
|
|
2
|
-
|
|
3
|
-
:author: Shay Hill
|
|
4
|
-
:created: 2025-07-09
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from collections.abc import Mapping
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
OptionalElemAttribMapping = Union[Mapping[str, ElemAttrib], None]
|
|
1
|
+
"""Type hints for pass-through arguments to lxml constructors.
|
|
2
|
+
|
|
3
|
+
:author: Shay Hill
|
|
4
|
+
:created: 2025-07-09
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from collections.abc import Mapping
|
|
8
|
+
|
|
9
|
+
# Types svg_ultralight can format to pass through to lxml constructors.
|
|
10
|
+
ElemAttrib = str | float | None
|
|
11
|
+
|
|
12
|
+
# Type for an optional dictionary of element attributes.
|
|
13
|
+
OptionalElemAttribMapping = Mapping[str, ElemAttrib] | None
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"""Help Pyright find types.
|
|
2
|
-
|
|
3
|
-
:author: Shay Hill
|
|
4
|
-
:created: 2023-02-02
|
|
5
|
-
"""
|
|
1
|
+
"""Help Pyright find types.
|
|
2
|
+
|
|
3
|
+
:author: Shay Hill
|
|
4
|
+
:created: 2023-02-02
|
|
5
|
+
"""
|