svg-ultralight 0.45.6__tar.gz → 0.47.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.
Potentially problematic release.
This version of svg-ultralight might be problematic. Click here for more details.
- {svg_ultralight-0.45.6/src/svg_ultralight.egg-info → svg_ultralight-0.47.0}/PKG-INFO +1 -1
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/pyproject.toml +2 -2
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/padded_text_initializers.py +11 -3
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/font_tools/font_info.py +3 -4
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/image_ops.py +22 -4
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0/src/svg_ultralight.egg-info}/PKG-INFO +1 -1
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight.egg-info/SOURCES.txt +0 -1
- svg_ultralight-0.45.6/src/svg_ultralight/font_tools/globs.py +0 -7
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/.gitignore +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/.pre-commit-config.yaml +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/README.md +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/dev-requirements.txt +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/experiments/encode_fonts3.txt +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/experiments/font_css.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/setup.cfg +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/__init__.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/animate.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/attrib_hints.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/__init__.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/bound_helpers.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/supports_bounds.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/type_bound_collection.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/type_bound_element.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/type_bounding_box.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/type_padded_text.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/constructors/__init__.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/constructors/new_element.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/font_tools/__init__.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/font_tools/comp_results.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/inkscape.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/layout.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/main.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/metadata.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/nsmap.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/py.typed +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/query.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/root_elements.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/string_conversion.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/strings/__init__.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/strings/svg_strings.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/transformations.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/unit_conversion.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight.egg-info/dependency_links.txt +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight.egg-info/requires.txt +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight.egg-info/top_level.txt +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/__init__.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/conftest.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/resources/arrow.svg +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_bound_element.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_bounding.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_inkscape.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_layout.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_matrices.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_metadata.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_new_element.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_padded_text_initializers.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_padding.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_queries.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_root_elements.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_string_conversion.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tests/test_svg_ultralight.py +0 -0
- {svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "svg-ultralight"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.47.0"
|
|
4
4
|
description = "a sensible way to create svg files with Python"
|
|
5
5
|
authors = [{ name = "Shay Hill", email = "shay_public@hotmail.com" }]
|
|
6
6
|
license = { text = "MIT" }
|
|
@@ -53,7 +53,7 @@ convention = "pep257"
|
|
|
53
53
|
|
|
54
54
|
[tool.commitizen]
|
|
55
55
|
name = "cz_conventional_commits"
|
|
56
|
-
version = "0.
|
|
56
|
+
version = "0.47.0"
|
|
57
57
|
tag_format = "$version"
|
|
58
58
|
version_files = ["pyproject.toml:^version"]
|
|
59
59
|
annotated_tag = true
|
|
@@ -10,6 +10,12 @@ Three variants:
|
|
|
10
10
|
line_gap while correcting some of the layout differences between fontTools and
|
|
11
11
|
Inkscape.
|
|
12
12
|
|
|
13
|
+
There is a default font size for pad_text if an element is passed. There is also a
|
|
14
|
+
default for the other pad_text_ functions, but it taken from the font file and is
|
|
15
|
+
usually 1024, so it won't be easy to miss. The default for standard pad_text is to
|
|
16
|
+
prevent surprises if Inksape defaults to font-size 12pt while your browser defaults
|
|
17
|
+
to 16px.
|
|
18
|
+
|
|
13
19
|
:author: Shay Hill
|
|
14
20
|
:created: 2025-06-09
|
|
15
21
|
"""
|
|
@@ -25,7 +31,6 @@ from svg_ultralight.font_tools.font_info import (
|
|
|
25
31
|
get_padded_text_info,
|
|
26
32
|
get_svg_font_attributes,
|
|
27
33
|
)
|
|
28
|
-
from svg_ultralight.font_tools.globs import DEFAULT_FONT_SIZE
|
|
29
34
|
from svg_ultralight.query import get_bounding_boxes
|
|
30
35
|
from svg_ultralight.string_conversion import format_attr_dict, format_number
|
|
31
36
|
|
|
@@ -40,6 +45,9 @@ if TYPE_CHECKING:
|
|
|
40
45
|
|
|
41
46
|
DEFAULT_Y_BOUNDS_REFERENCE = "{[|gjpqyf"
|
|
42
47
|
|
|
48
|
+
# A default font size for pad_text if font-size is not specified in the reference
|
|
49
|
+
# element.
|
|
50
|
+
DEFAULT_FONT_SIZE_FOR_PAD_TEXT = 12.0 # Default font size for pad_text if not specified
|
|
43
51
|
|
|
44
52
|
def pad_text(
|
|
45
53
|
inkscape: str | os.PathLike[str],
|
|
@@ -93,7 +101,7 @@ def pad_text(
|
|
|
93
101
|
def pad_text_ft(
|
|
94
102
|
font: str | os.PathLike[str],
|
|
95
103
|
text: str,
|
|
96
|
-
font_size: float =
|
|
104
|
+
font_size: float | None = None,
|
|
97
105
|
ascent: float | None = None,
|
|
98
106
|
descent: float | None = None,
|
|
99
107
|
*,
|
|
@@ -144,7 +152,7 @@ def pad_text_mix(
|
|
|
144
152
|
inkscape: str | os.PathLike[str],
|
|
145
153
|
font: str | os.PathLike[str],
|
|
146
154
|
text: str,
|
|
147
|
-
font_size: float =
|
|
155
|
+
font_size: float | None = None,
|
|
148
156
|
ascent: float | None = None,
|
|
149
157
|
descent: float | None = None,
|
|
150
158
|
*,
|
|
@@ -110,7 +110,6 @@ from svg_path_data import format_svgd_shortest, get_cpts_from_svgd, get_svgd_fro
|
|
|
110
110
|
|
|
111
111
|
from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
|
|
112
112
|
from svg_ultralight.constructors.new_element import new_element
|
|
113
|
-
from svg_ultralight.font_tools.globs import DEFAULT_FONT_SIZE
|
|
114
113
|
from svg_ultralight.string_conversion import format_numbers
|
|
115
114
|
|
|
116
115
|
if TYPE_CHECKING:
|
|
@@ -499,7 +498,7 @@ class FTTextInfo:
|
|
|
499
498
|
self,
|
|
500
499
|
font: str | os.PathLike[str] | FTFontInfo,
|
|
501
500
|
text: str,
|
|
502
|
-
font_size: float,
|
|
501
|
+
font_size: float | None = None,
|
|
503
502
|
ascent: float | None = None,
|
|
504
503
|
descent: float | None = None,
|
|
505
504
|
) -> None:
|
|
@@ -509,7 +508,7 @@ class FTTextInfo:
|
|
|
509
508
|
else:
|
|
510
509
|
self._font = FTFontInfo(font)
|
|
511
510
|
self._text = text.rstrip(" ")
|
|
512
|
-
self._font_size = font_size
|
|
511
|
+
self._font_size = font_size or self._font.units_per_em
|
|
513
512
|
self._ascent = ascent
|
|
514
513
|
self._descent = descent
|
|
515
514
|
|
|
@@ -638,7 +637,7 @@ def get_font_size_given_height(font: str | os.PathLike[str], height: float) -> f
|
|
|
638
637
|
def get_padded_text_info(
|
|
639
638
|
font: str | os.PathLike[str],
|
|
640
639
|
text: str,
|
|
641
|
-
font_size: float =
|
|
640
|
+
font_size: float | None = None,
|
|
642
641
|
ascent: float | None = None,
|
|
643
642
|
descent: float | None = None,
|
|
644
643
|
*,
|
|
@@ -32,6 +32,7 @@ from lxml import etree
|
|
|
32
32
|
|
|
33
33
|
from svg_ultralight import NSMAP
|
|
34
34
|
from svg_ultralight.bounding_boxes.bound_helpers import bbox_dict
|
|
35
|
+
from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
|
|
35
36
|
from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
|
|
36
37
|
from svg_ultralight.constructors import new_element
|
|
37
38
|
|
|
@@ -113,11 +114,11 @@ def _get_svg_embedded_image_str(image: ImageType) -> str:
|
|
|
113
114
|
return "data:image/png;base64," + base64_encoded_result_str
|
|
114
115
|
|
|
115
116
|
|
|
116
|
-
def
|
|
117
|
+
def new_image_blem(
|
|
117
118
|
filename: str | os.PathLike[str],
|
|
118
119
|
bbox: BoundingBox | None = None,
|
|
119
120
|
center: tuple[float, float] | None = None,
|
|
120
|
-
) ->
|
|
121
|
+
) -> BoundElement:
|
|
121
122
|
"""Create a new svg image element inside a bounding box.
|
|
122
123
|
|
|
123
124
|
:param filename: filename of source image
|
|
@@ -125,7 +126,7 @@ def new_image_elem_in_bbox(
|
|
|
125
126
|
:param center: center point for cropping. Proportions of image width and image
|
|
126
127
|
height, so the default value, (0.5, 0.5), is the true center of the image.
|
|
127
128
|
(0.4, 0.5) would crop 20% off the right side of the image.
|
|
128
|
-
:return:
|
|
129
|
+
:return: a BoundElement element with the cropped image embedded
|
|
129
130
|
"""
|
|
130
131
|
image = Image.open(filename)
|
|
131
132
|
if bbox is None:
|
|
@@ -135,4 +136,21 @@ def new_image_elem_in_bbox(
|
|
|
135
136
|
svg_image.set(
|
|
136
137
|
etree.QName(NSMAP["xlink"], "href"), _get_svg_embedded_image_str(image)
|
|
137
138
|
)
|
|
138
|
-
return svg_image
|
|
139
|
+
return BoundElement(svg_image, bbox)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def new_image_elem_in_bbox(
|
|
143
|
+
filename: str | os.PathLike[str],
|
|
144
|
+
bbox: BoundingBox | None = None,
|
|
145
|
+
center: tuple[float, float] | None = None,
|
|
146
|
+
) -> EtreeElement:
|
|
147
|
+
"""Create a new svg image element inside a bounding box.
|
|
148
|
+
|
|
149
|
+
:param filename: filename of source image
|
|
150
|
+
:param bbox: bounding box for the image
|
|
151
|
+
:param center: center point for cropping. Proportions of image width and image
|
|
152
|
+
height, so the default value, (0.5, 0.5), is the true center of the image.
|
|
153
|
+
(0.4, 0.5) would crop 20% off the right side of the image.
|
|
154
|
+
:return: an etree image element with the cropped image embedded
|
|
155
|
+
"""
|
|
156
|
+
return new_image_blem(filename, bbox, center).elem
|
|
@@ -39,7 +39,6 @@ src/svg_ultralight/constructors/new_element.py
|
|
|
39
39
|
src/svg_ultralight/font_tools/__init__.py
|
|
40
40
|
src/svg_ultralight/font_tools/comp_results.py
|
|
41
41
|
src/svg_ultralight/font_tools/font_info.py
|
|
42
|
-
src/svg_ultralight/font_tools/globs.py
|
|
43
42
|
src/svg_ultralight/strings/__init__.py
|
|
44
43
|
src/svg_ultralight/strings/svg_strings.py
|
|
45
44
|
tests/__init__.py
|
|
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
|
{svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/__init__.py
RENAMED
|
File without changes
|
{svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/bound_helpers.py
RENAMED
|
File without changes
|
{svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/bounding_boxes/supports_bounds.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/constructors/new_element.py
RENAMED
|
File without changes
|
|
File without changes
|
{svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight/font_tools/comp_results.py
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
|
{svg_ultralight-0.45.6 → svg_ultralight-0.47.0}/src/svg_ultralight.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
|