svg-ultralight 0.47.0__tar.gz → 0.48.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.47.0/src/svg_ultralight.egg-info → svg_ultralight-0.48.0}/PKG-INFO +2 -2
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/pyproject.toml +3 -3
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/bound_helpers.py +3 -15
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/padded_text_initializers.py +2 -1
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/font_tools/font_info.py +11 -3
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0/src/svg_ultralight.egg-info}/PKG-INFO +2 -2
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/.gitignore +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/.pre-commit-config.yaml +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/README.md +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/dev-requirements.txt +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/experiments/encode_fonts3.txt +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/experiments/font_css.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/setup.cfg +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/__init__.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/animate.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/attrib_hints.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/__init__.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/supports_bounds.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/type_bound_collection.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/type_bound_element.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/type_bounding_box.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/type_padded_text.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/constructors/__init__.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/constructors/new_element.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/font_tools/__init__.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/font_tools/comp_results.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/image_ops.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/inkscape.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/layout.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/main.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/metadata.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/nsmap.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/py.typed +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/query.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/root_elements.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/string_conversion.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/strings/__init__.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/strings/svg_strings.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/transformations.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/unit_conversion.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight.egg-info/SOURCES.txt +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight.egg-info/dependency_links.txt +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight.egg-info/requires.txt +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight.egg-info/top_level.txt +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/__init__.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/conftest.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/resources/arrow.svg +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_bound_element.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_bounding.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_inkscape.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_layout.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_matrices.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_metadata.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_new_element.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_padded_text_initializers.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_padding.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_queries.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_root_elements.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_string_conversion.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tests/test_svg_ultralight.py +0 -0
- {svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/tox.ini +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: svg-ultralight
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.48.0
|
|
4
4
|
Summary: a sensible way to create svg files with Python
|
|
5
5
|
Author-email: Shay Hill <shay_public@hotmail.com>
|
|
6
|
-
License: MIT
|
|
6
|
+
License-Expression: MIT
|
|
7
7
|
Requires-Python: >=3.9
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: cssutils
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "svg-ultralight"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.48.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
|
-
license =
|
|
6
|
+
license = "MIT"
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
requires-python = ">=3.9"
|
|
9
9
|
dependencies = [
|
|
@@ -53,7 +53,7 @@ convention = "pep257"
|
|
|
53
53
|
|
|
54
54
|
[tool.commitizen]
|
|
55
55
|
name = "cz_conventional_commits"
|
|
56
|
-
version = "0.
|
|
56
|
+
version = "0.48.0"
|
|
57
57
|
tag_format = "$version"
|
|
58
58
|
version_files = ["pyproject.toml:^version"]
|
|
59
59
|
annotated_tag = true
|
{svg_ultralight-0.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/bound_helpers.py
RENAMED
|
@@ -16,6 +16,7 @@ from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
|
|
|
16
16
|
from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox, HasBoundingBox
|
|
17
17
|
from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
|
|
18
18
|
from svg_ultralight.constructors import new_element
|
|
19
|
+
from svg_ultralight.layout import PadArg, expand_pad_arg
|
|
19
20
|
|
|
20
21
|
if TYPE_CHECKING:
|
|
21
22
|
import os
|
|
@@ -94,19 +95,6 @@ def new_bound_union(*blems: SupportsBounds | EtreeElement) -> BoundElement:
|
|
|
94
95
|
return BoundElement(group, bbox)
|
|
95
96
|
|
|
96
97
|
|
|
97
|
-
def _expand_pad(pad: float | tuple[float, ...]) -> tuple[float, float, float, float]:
|
|
98
|
-
"""Expand a float pad argument into a 4-tuple."""
|
|
99
|
-
if isinstance(pad, (int, float)):
|
|
100
|
-
return pad, pad, pad, pad
|
|
101
|
-
if len(pad) == 1:
|
|
102
|
-
return pad[0], pad[0], pad[0], pad[0]
|
|
103
|
-
if len(pad) == 2:
|
|
104
|
-
return pad[0], pad[1], pad[0], pad[1]
|
|
105
|
-
if len(pad) == 3:
|
|
106
|
-
return pad[0], pad[1], pad[2], pad[1]
|
|
107
|
-
return pad[0], pad[1], pad[2], pad[3]
|
|
108
|
-
|
|
109
|
-
|
|
110
98
|
def cut_bbox(
|
|
111
99
|
bbox: SupportsBounds,
|
|
112
100
|
*,
|
|
@@ -133,7 +121,7 @@ def cut_bbox(
|
|
|
133
121
|
return BoundingBox(x, y, width, height)
|
|
134
122
|
|
|
135
123
|
|
|
136
|
-
def pad_bbox(bbox: SupportsBounds, pad:
|
|
124
|
+
def pad_bbox(bbox: SupportsBounds, pad: PadArg) -> BoundingBox:
|
|
137
125
|
"""Return a new bounding box with padding.
|
|
138
126
|
|
|
139
127
|
:param bbox: the original bounding box or bounded element.
|
|
@@ -146,7 +134,7 @@ def pad_bbox(bbox: SupportsBounds, pad: float | tuple[float, ...]) -> BoundingBo
|
|
|
146
134
|
len = 4 : 0, 1, 2, 3
|
|
147
135
|
:return: a new bounding box with padding applied.
|
|
148
136
|
"""
|
|
149
|
-
top, right, bottom, left =
|
|
137
|
+
top, right, bottom, left = expand_pad_arg(pad)
|
|
150
138
|
return cut_bbox(
|
|
151
139
|
bbox, x=bbox.x - left, y=bbox.y - top, x2=bbox.x2 + right, y2=bbox.y2 + bottom
|
|
152
140
|
)
|
|
@@ -49,6 +49,7 @@ DEFAULT_Y_BOUNDS_REFERENCE = "{[|gjpqyf"
|
|
|
49
49
|
# element.
|
|
50
50
|
DEFAULT_FONT_SIZE_FOR_PAD_TEXT = 12.0 # Default font size for pad_text if not specified
|
|
51
51
|
|
|
52
|
+
|
|
52
53
|
def pad_text(
|
|
53
54
|
inkscape: str | os.PathLike[str],
|
|
54
55
|
text_elem: EtreeElement,
|
|
@@ -80,7 +81,7 @@ def pad_text(
|
|
|
80
81
|
if font is not None:
|
|
81
82
|
_ = update_element(text_elem, **get_svg_font_attributes(font))
|
|
82
83
|
if "font-size" not in text_elem.attrib:
|
|
83
|
-
text_elem.attrib["font-size"] = format_number(
|
|
84
|
+
text_elem.attrib["font-size"] = format_number(DEFAULT_FONT_SIZE_FOR_PAD_TEXT)
|
|
84
85
|
rmargin_ref = deepcopy(text_elem)
|
|
85
86
|
capline_ref = deepcopy(text_elem)
|
|
86
87
|
_ = rmargin_ref.attrib.pop("id", None)
|
|
@@ -123,7 +123,15 @@ if TYPE_CHECKING:
|
|
|
123
123
|
logging.getLogger("fontTools").setLevel(logging.ERROR)
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
_ESCAPE_CHARS = {
|
|
126
|
+
_ESCAPE_CHARS = {
|
|
127
|
+
"&": "&",
|
|
128
|
+
"<": "<",
|
|
129
|
+
">": ">",
|
|
130
|
+
'"': """,
|
|
131
|
+
"'": "'",
|
|
132
|
+
"{": "{", # valid, but stops MS File Explorer from thumbnailing an svg
|
|
133
|
+
"}": "}", # valid, but stops MS File Explorer from thumbnailing an svg
|
|
134
|
+
}
|
|
127
135
|
|
|
128
136
|
|
|
129
137
|
def _sanitize_svg_data_text(text: str) -> str:
|
|
@@ -376,8 +384,8 @@ class FTFontInfo:
|
|
|
376
384
|
:param dx: An optional x translation to apply to the glyph.
|
|
377
385
|
:return: The svg path data for the character.
|
|
378
386
|
"""
|
|
387
|
+
glyph_name = self.get_glyph_name(char)
|
|
379
388
|
glyph_set = self.font.getGlyphSet()
|
|
380
|
-
glyph_name = self.font.getBestCmap().get(ord(char))
|
|
381
389
|
path_pen = PathPen(glyph_set)
|
|
382
390
|
_ = glyph_set[glyph_name].draw(path_pen)
|
|
383
391
|
svgd = path_pen.svgd
|
|
@@ -397,8 +405,8 @@ class FTFontInfo:
|
|
|
397
405
|
same, but when they disagree, this method is more accurate. Additionally,
|
|
398
406
|
some fonts do not have a glyf table, so this method is more robust.
|
|
399
407
|
"""
|
|
408
|
+
glyph_name = self.get_glyph_name(char)
|
|
400
409
|
glyph_set = self.font.getGlyphSet()
|
|
401
|
-
glyph_name = self.font.getBestCmap().get(ord(char))
|
|
402
410
|
bounds_pen = BoundsPen(glyph_set)
|
|
403
411
|
_ = glyph_set[glyph_name].draw(bounds_pen)
|
|
404
412
|
pen_bounds = cast("None | tuple[int, int, int, int]", bounds_pen.bounds)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: svg-ultralight
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.48.0
|
|
4
4
|
Summary: a sensible way to create svg files with Python
|
|
5
5
|
Author-email: Shay Hill <shay_public@hotmail.com>
|
|
6
|
-
License: MIT
|
|
6
|
+
License-Expression: MIT
|
|
7
7
|
Requires-Python: >=3.9
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: cssutils
|
|
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.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/bounding_boxes/__init__.py
RENAMED
|
File without changes
|
{svg_ultralight-0.47.0 → svg_ultralight-0.48.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.47.0 → svg_ultralight-0.48.0}/src/svg_ultralight/constructors/new_element.py
RENAMED
|
File without changes
|
|
File without changes
|
{svg_ultralight-0.47.0 → svg_ultralight-0.48.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
|
|
File without changes
|
|
File without changes
|
{svg_ultralight-0.47.0 → svg_ultralight-0.48.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
|