svg-ultralight 0.45.2__tar.gz → 0.45.4__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.

Files changed (62) hide show
  1. {svg_ultralight-0.45.2/src/svg_ultralight.egg-info → svg_ultralight-0.45.4}/PKG-INFO +1 -1
  2. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/dev-requirements.txt +2 -2
  3. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/pyproject.toml +2 -2
  4. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/bounding_boxes/type_padded_text.py +36 -0
  5. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/transformations.py +4 -3
  6. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4/src/svg_ultralight.egg-info}/PKG-INFO +1 -1
  7. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight.egg-info/SOURCES.txt +1 -0
  8. svg_ultralight-0.45.4/tests/test_bound_element.py +84 -0
  9. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/.gitignore +0 -0
  10. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/.pre-commit-config.yaml +0 -0
  11. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/README.md +0 -0
  12. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/experiments/encode_fonts3.txt +0 -0
  13. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/experiments/font_css.py +0 -0
  14. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/setup.cfg +0 -0
  15. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/__init__.py +0 -0
  16. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/animate.py +0 -0
  17. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/attrib_hints.py +0 -0
  18. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/bounding_boxes/__init__.py +0 -0
  19. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/bounding_boxes/bound_helpers.py +0 -0
  20. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/bounding_boxes/padded_text_initializers.py +0 -0
  21. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/bounding_boxes/supports_bounds.py +0 -0
  22. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/bounding_boxes/type_bound_collection.py +0 -0
  23. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/bounding_boxes/type_bound_element.py +0 -0
  24. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/bounding_boxes/type_bounding_box.py +0 -0
  25. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/constructors/__init__.py +0 -0
  26. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/constructors/new_element.py +0 -0
  27. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/font_tools/__init__.py +0 -0
  28. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/font_tools/comp_results.py +0 -0
  29. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/font_tools/font_info.py +0 -0
  30. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/font_tools/globs.py +0 -0
  31. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/image_ops.py +0 -0
  32. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/inkscape.py +0 -0
  33. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/layout.py +0 -0
  34. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/main.py +0 -0
  35. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/metadata.py +0 -0
  36. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/nsmap.py +0 -0
  37. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/py.typed +0 -0
  38. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/query.py +0 -0
  39. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/root_elements.py +0 -0
  40. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/string_conversion.py +0 -0
  41. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/strings/__init__.py +0 -0
  42. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/strings/svg_strings.py +0 -0
  43. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight/unit_conversion.py +0 -0
  44. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight.egg-info/dependency_links.txt +0 -0
  45. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight.egg-info/requires.txt +0 -0
  46. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/src/svg_ultralight.egg-info/top_level.txt +0 -0
  47. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/__init__.py +0 -0
  48. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/conftest.py +0 -0
  49. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/resources/arrow.svg +0 -0
  50. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_bounding.py +0 -0
  51. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_inkscape.py +0 -0
  52. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_layout.py +0 -0
  53. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_matrices.py +0 -0
  54. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_metadata.py +0 -0
  55. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_new_element.py +0 -0
  56. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_padded_text_initializers.py +0 -0
  57. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_padding.py +0 -0
  58. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_queries.py +0 -0
  59. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_root_elements.py +0 -0
  60. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_string_conversion.py +0 -0
  61. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tests/test_svg_ultralight.py +0 -0
  62. {svg_ultralight-0.45.2 → svg_ultralight-0.45.4}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: svg-ultralight
3
- Version: 0.45.2
3
+ Version: 0.45.4
4
4
  Summary: a sensible way to create svg files with Python
5
5
  Author-email: Shay Hill <shay_public@hotmail.com>
6
6
  License: MIT
@@ -91,7 +91,7 @@ questionary==2.1.0
91
91
  # via commitizen
92
92
  soupsieve==2.7
93
93
  # via beautifulsoup4
94
- svg-path-data==0.3.0
94
+ svg-path-data==0.3.2
95
95
  # via svg-ultralight (pyproject.toml)
96
96
  termcolor==3.1.0
97
97
  # via commitizen
@@ -99,7 +99,7 @@ tomlkit==0.13.3
99
99
  # via commitizen
100
100
  tox==4.27.0
101
101
  # via svg-ultralight (pyproject.toml)
102
- types-html5lib==1.1.11.20250516
102
+ types-html5lib==1.1.11.20250708
103
103
  # via types-lxml
104
104
  types-lxml==2025.3.30
105
105
  # via svg-ultralight (pyproject.toml)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "svg-ultralight"
3
- version = "0.45.2"
3
+ version = "0.45.4"
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.45.2"
56
+ version = "0.45.4"
57
57
  tag_format = "$version"
58
58
  version_files = ["pyproject.toml:^version"]
59
59
  annotated_tag = true
@@ -64,6 +64,7 @@ enough to lay out text on a business card.
64
64
 
65
65
  from __future__ import annotations
66
66
 
67
+ import math
67
68
  from typing import TYPE_CHECKING
68
69
 
69
70
  from paragraphs import par
@@ -223,6 +224,41 @@ class PaddedText(BoundElement):
223
224
  """
224
225
  self.base_bpad = value / self.unpadded_bbox.scale[1]
225
226
 
227
+ @property
228
+ def scale(self) -> tuple[float, float]:
229
+ """Get scale of the bounding box.
230
+
231
+ :return: uniform scale of the bounding box
232
+
233
+ Use caution, the scale attribute can cause errors in intuition. Changing
234
+ width or height will change the scale attribute, but not the x or y values.
235
+ The scale setter, on the other hand, will work in the tradational manner.
236
+ I.e., x => x*scale, y => y*scale, x2 => x*scale, y2 => y*scale, width =>
237
+ width*scale, height => height*scale, scale => scale*scale. This matches how
238
+ scale works in almost every other context.
239
+ """
240
+ xx, xy, yx, yy, *_ = self.unpadded_bbox.transformation
241
+ return math.sqrt(xx * xx + xy * xy), math.sqrt(yx * yx + yy * yy)
242
+
243
+ @scale.setter
244
+ def scale(self, value: tuple[float, float]) -> None:
245
+ """Scale the bounding box by a uniform factor.
246
+
247
+ :param value: new scale value
248
+
249
+ Don't miss this! You are setting the scale, not scaling the scale! If you
250
+ have a previously defined scale other than 1, this is probably not what you
251
+ want. Most of the time, you will want to use the *= operator.
252
+
253
+ `scale = 2` -> ignore whatever scale was previously defined and set scale to 2
254
+ `scale *= 2` -> make it twice as big as it was.
255
+ """
256
+ new_scale = (
257
+ value[0] / self.unpadded_bbox.scale[0],
258
+ value[1] / self.unpadded_bbox.scale[1],
259
+ )
260
+ self.transform(scale=new_scale)
261
+
226
262
  @property
227
263
  def width(self) -> float:
228
264
  """The width of this line of text with padding.
@@ -6,6 +6,7 @@
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
+ import numbers
9
10
  import re
10
11
  from contextlib import suppress
11
12
  from typing import TYPE_CHECKING, cast
@@ -116,16 +117,16 @@ def new_transformation_matrix(
116
117
  """
117
118
  transformation = transformation or (1, 0, 0, 1, 0, 0)
118
119
 
119
- if isinstance(scale, float):
120
+ if isinstance(scale, (float, int, numbers.Real)):
120
121
  scale_x, scale_y = (scale, scale)
121
122
  elif scale is None:
122
123
  scale_x, scale_y = (1, 1)
123
124
  else:
124
- scale_x, scale_y = cast("tuple[float, float]", scale)
125
+ scale_x, scale_y = scale
125
126
 
126
127
  dx = dx or 0
127
128
  dy = dy or 0
128
- return mat_dot((scale_x, 0, 0, scale_y, dx, dy), transformation)
129
+ return mat_dot((float(scale_x), 0, 0, float(scale_y), dx, dy), transformation)
129
130
 
130
131
 
131
132
  def transform_element(elem: EtreeElement, matrix: _Matrix) -> EtreeElement:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: svg-ultralight
3
- Version: 0.45.2
3
+ Version: 0.45.4
4
4
  Summary: a sensible way to create svg files with Python
5
5
  Author-email: Shay Hill <shay_public@hotmail.com>
6
6
  License: MIT
@@ -44,6 +44,7 @@ src/svg_ultralight/strings/__init__.py
44
44
  src/svg_ultralight/strings/svg_strings.py
45
45
  tests/__init__.py
46
46
  tests/conftest.py
47
+ tests/test_bound_element.py
47
48
  tests/test_bounding.py
48
49
  tests/test_inkscape.py
49
50
  tests/test_layout.py
@@ -0,0 +1,84 @@
1
+ """Test methods for BoundElement instances.
2
+
3
+ :author: Shay Hill
4
+ :created: 2025-07-29
5
+ """
6
+
7
+ from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
8
+ from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
9
+ from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
10
+ from svg_ultralight.constructors import new_element
11
+
12
+
13
+ class TestTransforms:
14
+ """Test methods for BoundElement instances."""
15
+
16
+ def test_matrix(self) -> None:
17
+ """Test the transform method."""
18
+ bbox = BoundingBox(0, 0, 100, 100)
19
+ bbox.transform(transformation=(1, 2, 3, 4, 5, 6))
20
+ assert bbox.transformation == (1, 2, 3, 4, 5, 6)
21
+
22
+ def test_scale_float(self) -> None:
23
+ """Test the scale method with a float."""
24
+ bbox = BoundingBox(0, 0, 100, 100)
25
+ bbox.transform(scale=2.0)
26
+ assert bbox.transformation == (2.0, 0.0, 0.0, 2.0, 0.0, 0.0)
27
+
28
+ def test_scale_int(self) -> None:
29
+ """Test the scale method with an int."""
30
+ bbox = BoundingBox(0, 0, 100, 100)
31
+ bbox.transform(scale=2)
32
+ assert bbox.transformation == (2.0, 0.0, 0.0, 2.0, 0.0, 0.0)
33
+
34
+
35
+ class TestSetScale:
36
+ """Test methods for BoundElement instances."""
37
+
38
+ def test_sets_not_transforms(self) -> None:
39
+ """The new scale is the new scale, regardless of the old scale."""
40
+ bbox = BoundingBox(0, 0, 100, 100)
41
+ bbox.scale = (2, 2)
42
+ assert bbox.scale == (2.0, 2.0)
43
+ bbox.scale = (3, 3)
44
+ assert bbox.scale == (3.0, 3.0)
45
+
46
+
47
+ class TestBoundElement:
48
+ """Test methods for BoundElement instances."""
49
+
50
+ def test_set_scale(self) -> None:
51
+ """Test the set_scale method."""
52
+ elem = new_element("rect", width=100, height=100)
53
+ bbox = BoundingBox(0, 0, 100, 100)
54
+ blem = BoundElement(elem, bbox)
55
+ blem.scale = (2, 2)
56
+ assert blem.scale == (2.0, 2.0)
57
+
58
+ def test_transform(self) -> None:
59
+ """Test the transform method."""
60
+ elem = new_element("rect", width=100, height=100)
61
+ bbox = BoundingBox(0, 0, 100, 100)
62
+ blem = BoundElement(elem, bbox)
63
+ blem.transform(scale=5)
64
+ assert blem.scale == (5.0, 5.0)
65
+
66
+
67
+ class TestPaddedText:
68
+ """Text that padded text instances scale like bound elements."""
69
+
70
+ def test_set_scale(self) -> None:
71
+ """Test the set_scale method."""
72
+ elem = new_element("rect", width=100, height=100)
73
+ bbox = BoundingBox(0, 0, 100, 100)
74
+ blem = PaddedText(elem, bbox, 1, 2, 3, 4)
75
+ blem.scale = (2, 2)
76
+ assert blem.scale == (2.0, 2.0)
77
+
78
+ def test_transform(self) -> None:
79
+ """Test the transform method."""
80
+ elem = new_element("rect", width=100, height=100)
81
+ bbox = BoundingBox(0, 0, 100, 100)
82
+ blem = PaddedText(elem, bbox, 1, 2, 3, 4)
83
+ blem.transform(scale=5)
84
+ assert blem.scale == (5.0, 5.0)
File without changes