prefig 0.4.3.dev20250823053253__py3-none-any.whl → 0.4.5__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.
- prefig/core/circle.py +13 -4
- prefig/core/diagram.py +16 -0
- prefig/core/label.py +14 -4
- prefig/core/point.py +7 -1
- prefig/core/polygon.py +4 -1
- prefig/core/rectangle.py +5 -2
- {prefig-0.4.3.dev20250823053253.dist-info → prefig-0.4.5.dist-info}/METADATA +2 -2
- {prefig-0.4.3.dev20250823053253.dist-info → prefig-0.4.5.dist-info}/RECORD +11 -11
- {prefig-0.4.3.dev20250823053253.dist-info → prefig-0.4.5.dist-info}/LICENSE +0 -0
- {prefig-0.4.3.dev20250823053253.dist-info → prefig-0.4.5.dist-info}/WHEEL +0 -0
- {prefig-0.4.3.dev20250823053253.dist-info → prefig-0.4.5.dist-info}/entry_points.txt +0 -0
prefig/core/circle.py
CHANGED
|
@@ -47,9 +47,12 @@ def circle(element, diagram, parent, outline_status):
|
|
|
47
47
|
if element.get('stroke') is not None:
|
|
48
48
|
element.set('stroke', 'black')
|
|
49
49
|
if element.get('fill') is not None:
|
|
50
|
-
element.
|
|
50
|
+
if element.get('fill').strip().lower() != 'none':
|
|
51
|
+
element.set('fill', 'lightgray')
|
|
52
|
+
else:
|
|
53
|
+
element.set('fill', 'none')
|
|
51
54
|
else:
|
|
52
|
-
element.set('stroke', element.get('stroke', '
|
|
55
|
+
element.set('stroke', element.get('stroke', 'black'))
|
|
53
56
|
element.set('fill', element.get('fill', 'none'))
|
|
54
57
|
element.set('thickness', element.get('thickness', '2'))
|
|
55
58
|
util.add_attr(circle, util.get_2d_attr(element))
|
|
@@ -120,7 +123,10 @@ def ellipse(element, diagram, parent, outline_status):
|
|
|
120
123
|
if element.get('stroke') is not None:
|
|
121
124
|
element.set('stroke', 'black')
|
|
122
125
|
if element.get('fill') is not None:
|
|
123
|
-
|
|
126
|
+
if elementl.get('fill').strip().lower() != 'none':
|
|
127
|
+
element.set('fill', 'lightgray')
|
|
128
|
+
else:
|
|
129
|
+
element.set('fill', 'none')
|
|
124
130
|
else:
|
|
125
131
|
element.set('stroke', element.get('stroke', 'none'))
|
|
126
132
|
element.set('fill', element.get('fill', 'none'))
|
|
@@ -283,7 +289,10 @@ def angle(element, diagram, parent, outline_status):
|
|
|
283
289
|
element.set('stroke', element.get('stroke', 'black'))
|
|
284
290
|
if diagram.output_format() == 'tactile':
|
|
285
291
|
if element.get('fill') is not None:
|
|
286
|
-
element.
|
|
292
|
+
if element.get('fill').strip().lower() != 'none':
|
|
293
|
+
element.set('fill', 'lightgray')
|
|
294
|
+
else:
|
|
295
|
+
element.set('fill', 'none')
|
|
287
296
|
else:
|
|
288
297
|
element.set('fill', element.get('fill', 'none'))
|
|
289
298
|
element.set('thickness', element.get('thickness','2'))
|
prefig/core/diagram.py
CHANGED
|
@@ -109,6 +109,15 @@ class Diagram:
|
|
|
109
109
|
if data_directory is not None:
|
|
110
110
|
self.external = data_directory
|
|
111
111
|
|
|
112
|
+
templates = self.diagram_element.xpath('.//templates')
|
|
113
|
+
if len(templates) > 0:
|
|
114
|
+
templates_element = templates[0]
|
|
115
|
+
for template in templates:
|
|
116
|
+
templates_parent = template.getparent()
|
|
117
|
+
templates_parent.remove(template)
|
|
118
|
+
for child in templates_element:
|
|
119
|
+
self.defaults[child.tag] = child
|
|
120
|
+
|
|
112
121
|
if self.defaults.get('macros', None) is not None:
|
|
113
122
|
label.add_macros(self.defaults.get('macros').text)
|
|
114
123
|
|
|
@@ -487,6 +496,13 @@ class Diagram:
|
|
|
487
496
|
def get_root(self):
|
|
488
497
|
return self.root
|
|
489
498
|
|
|
499
|
+
def apply_defaults(self, tag, element):
|
|
500
|
+
default = self.defaults.get(tag, None)
|
|
501
|
+
if default is not None:
|
|
502
|
+
for attr, value in default.attrib.items():
|
|
503
|
+
if element.get(attr, None) is None:
|
|
504
|
+
element.set(attr, value)
|
|
505
|
+
|
|
490
506
|
# when a graphical component is outlined, we first add the component's path
|
|
491
507
|
# to <defs> so that it can be reused, then we stroke it with a thick white
|
|
492
508
|
def add_outline(self, element, path, parent, outline_width = None):
|
prefig/core/label.py
CHANGED
|
@@ -15,6 +15,8 @@ import tempfile
|
|
|
15
15
|
|
|
16
16
|
log = logging.getLogger('prefigure')
|
|
17
17
|
|
|
18
|
+
allowed_fonts = {'serif','sans-serif','monospace'}
|
|
19
|
+
|
|
18
20
|
def init(format, environment):
|
|
19
21
|
global math_labels
|
|
20
22
|
global text_measurements
|
|
@@ -465,10 +467,18 @@ def position_svg_label(element, diagram, ctm, group):
|
|
|
465
467
|
# These lists contain: font, size, italics, bold, color
|
|
466
468
|
label_color = element.get("color", None)
|
|
467
469
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
diagram.apply_defaults('label', element)
|
|
471
|
+
|
|
472
|
+
font_family = element.get('font', 'sans-serif').lower().strip()
|
|
473
|
+
if font_family not in allowed_fonts:
|
|
474
|
+
font_family = 'sans-serif'
|
|
475
|
+
|
|
476
|
+
font_size = un.valid_eval(element.get('font-size', '14'))
|
|
477
|
+
|
|
478
|
+
std_font_face = [font_family, font_size, False, False, label_color]
|
|
479
|
+
it_font_face = [font_family, font_size, True, False, label_color]
|
|
480
|
+
b_font_face = [font_family, font_size, False, True, label_color]
|
|
481
|
+
it_b_font_face = [font_family, font_size, True, True, label_color]
|
|
472
482
|
|
|
473
483
|
label = element
|
|
474
484
|
|
prefig/core/point.py
CHANGED
|
@@ -34,7 +34,13 @@ def point(element, diagram, parent, outline_status = None):
|
|
|
34
34
|
return
|
|
35
35
|
|
|
36
36
|
if diagram.output_format() == 'tactile':
|
|
37
|
-
|
|
37
|
+
if element.get('size', None) is not None:
|
|
38
|
+
size = un.valid_eval(element.get('size'))
|
|
39
|
+
size = max(size, 9)
|
|
40
|
+
size = str(size)
|
|
41
|
+
else:
|
|
42
|
+
size = '9'
|
|
43
|
+
element.set('size', size)
|
|
38
44
|
else:
|
|
39
45
|
element.set('size', element.get('size', '4'))
|
|
40
46
|
size = util.get_attr(element, 'size', '1')
|
prefig/core/polygon.py
CHANGED
|
@@ -53,7 +53,10 @@ def polygon(element, diagram, parent,
|
|
|
53
53
|
if element.get('stroke') is not None:
|
|
54
54
|
element.set('stroke', 'black')
|
|
55
55
|
if element.get('fill') is not None:
|
|
56
|
-
element.
|
|
56
|
+
if element.get('fill').strip().lower() != 'none':
|
|
57
|
+
element.set('fill', 'lightgray')
|
|
58
|
+
else:
|
|
59
|
+
element.set('fill', 'none')
|
|
57
60
|
util.set_attr(element, 'stroke', 'none')
|
|
58
61
|
util.set_attr(element, 'fill', 'none')
|
|
59
62
|
util.set_attr(element, 'thickness', '2')
|
prefig/core/rectangle.py
CHANGED
|
@@ -75,8 +75,11 @@ def rectangle(element, diagram, parent, outline_status):
|
|
|
75
75
|
fill = element.get('fill')
|
|
76
76
|
if stroke is not None and stroke != 'none':
|
|
77
77
|
element.set('stroke', 'black')
|
|
78
|
-
if fill is not None
|
|
79
|
-
|
|
78
|
+
if fill is not None:
|
|
79
|
+
if fill.strip().lower() != 'none':
|
|
80
|
+
element.set('fill', 'lightgray')
|
|
81
|
+
else:
|
|
82
|
+
element.set('fill', 'none')
|
|
80
83
|
else:
|
|
81
84
|
util.set_attr(element, 'stroke', 'none')
|
|
82
85
|
util.set_attr(element, 'fill', 'none')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prefig
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.5
|
|
4
4
|
Summary: An authoring system for mathematical diagrams
|
|
5
5
|
Home-page: https://prefigure.org
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -92,7 +92,7 @@ PreFigure may be installed locally as a Python package in the usual way using `p
|
|
|
92
92
|
apt install nodejs
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
6. For
|
|
95
|
+
6. For building PDF versions of diagrams, you will need to install `rsvg-convert`, which PreFigure uses to convert SVGs into PDFs. On Ubuntu, you can say
|
|
96
96
|
|
|
97
97
|
```
|
|
98
98
|
apt install librsvg2-bin
|
|
@@ -7,19 +7,19 @@ prefig/core/area.py,sha256=U-AxXvaZJWgVccpLlh-aaRfM_QtTa09NR2TqAd8Yk0o,3710
|
|
|
7
7
|
prefig/core/arrow.py,sha256=h8lFm1rMdpiZRyQu5kvAiptBmMYr5aKCZuB5JypAGDM,11283
|
|
8
8
|
prefig/core/axes.py,sha256=3J6eWNXRWTlbFVNfWkv_-Hyq4L7UP54EQ5u1r82Cfy0,31830
|
|
9
9
|
prefig/core/calculus.py,sha256=Q4kSGTTTeQYEEVKgmYWpFP0JLHmCsBchB5OF9qSclQk,498
|
|
10
|
-
prefig/core/circle.py,sha256=
|
|
10
|
+
prefig/core/circle.py,sha256=zWm0emJ2YzH4EcaOqgxMgg-_t4Qcrd2Itfo6_s_61uo,16054
|
|
11
11
|
prefig/core/clip.py,sha256=X3TcFYPuZwjZ9SFBWMc1MYY__6XTJqLafPeOLFNOdIE,806
|
|
12
12
|
prefig/core/compat.py,sha256=_dI4aGtDrfhcw33r1SQS6kMwwgJj8dJ2A2GcLmtwX7o,729
|
|
13
13
|
prefig/core/coordinates.py,sha256=vEAJ8kL9S1VylxWysqY5qW2WyCMyHj42yFkuAzjfqFs,3518
|
|
14
14
|
prefig/core/definition.py,sha256=7LiaCxQwwEPdcnMpcMgrkZEfAoTc5ng8LO6Nf50Htwg,1033
|
|
15
|
-
prefig/core/diagram.py,sha256
|
|
15
|
+
prefig/core/diagram.py,sha256=-8zjo6FgDs74OLMkd3rgncBHrEue3S86hwQ3ISh-nj4,23253
|
|
16
16
|
prefig/core/diffeqs.py,sha256=aLXcmTsnfTG6L2-RiNfSaijzwmJF6xJcQpNQdDAWTQo,7127
|
|
17
17
|
prefig/core/graph.py,sha256=q81dyJy3CxMWvMNhm74SZ9yjfltatdckmajxegA0z0A,10064
|
|
18
18
|
prefig/core/grid_axes.py,sha256=v98C5tb9knNViGYGDrWL_ULb7Y78vMSQ6OJO7Xd0DXY,12165
|
|
19
19
|
prefig/core/group.py,sha256=KByOibuslP9TqSygNfPSaN4zU5oSRYaH2CPnR21ogTg,5825
|
|
20
20
|
prefig/core/image.py,sha256=eQKy0mNvCE6J8EA1S5Y08YF3lrb7kCeGG4wrjBQ_-pI,4373
|
|
21
21
|
prefig/core/implicit.py,sha256=JyFKpKj6Xi1PF-3BeZpd7t0aNe8jH9Wf_E2rghvt-Ug,6179
|
|
22
|
-
prefig/core/label.py,sha256=
|
|
22
|
+
prefig/core/label.py,sha256=iIL0QXyNOGbWSA8xLoPgkkxghTcyHRmdDQw07mvBGjY,25100
|
|
23
23
|
prefig/core/label_tools.py,sha256=jOawiyrKC5iQs0vq7133xNXqrkJbMqDZVHflT-hOruo,9167
|
|
24
24
|
prefig/core/legend.py,sha256=0mVfyU3LvqgDCYUOlCeBD04maV-rj2h0fs1aOEBBt6c,13340
|
|
25
25
|
prefig/core/line.py,sha256=HBB9cvJawKAtdubISn5maRrzFFzV0NQuBgwoQoxeXcw,6055
|
|
@@ -28,10 +28,10 @@ prefig/core/network.py,sha256=1izAX2AKvnj2knElrdLeojE_0Q0zO0aQM-EsEwor0Os,27217
|
|
|
28
28
|
prefig/core/parametric_curve.py,sha256=WIg6BC4AIx6Hs_1Bl18BJYPY7vaCn80qyDn6OixK3Z0,3431
|
|
29
29
|
prefig/core/parse.py,sha256=plLmR0KKrUjYx0PmHHo5HZonaaT3tW4qjiDOtzuhSkQ,4542
|
|
30
30
|
prefig/core/path.py,sha256=8BbWAUzZqe1YD0gO4QtDENaINavAAC1mlU-y3UV-vu0,20312
|
|
31
|
-
prefig/core/point.py,sha256=
|
|
32
|
-
prefig/core/polygon.py,sha256=
|
|
31
|
+
prefig/core/point.py,sha256=n95dHgEjynMauBzfSXbQPnZqyUEWRm4HA9fUTh-e_8M,8912
|
|
32
|
+
prefig/core/polygon.py,sha256=BJ-n9XnxSHb3UFu7lCqOEb48uyGvGGwsA_65dR8_6X4,11429
|
|
33
33
|
prefig/core/read.py,sha256=Q1Nsluwysg3M5wtUmwIirfNo-Rw9-dFJPEeM4pDCpyo,1988
|
|
34
|
-
prefig/core/rectangle.py,sha256=
|
|
34
|
+
prefig/core/rectangle.py,sha256=TzdVckcPfNV8fI1xs8FgHadx06wn2P6A504oyDO3xGY,3567
|
|
35
35
|
prefig/core/repeat.py,sha256=DAO5w4BxUMGU-8ymsv8EwsifI0zPa_cgIRUcWWS8BWU,2755
|
|
36
36
|
prefig/core/riemann_sum.py,sha256=T2dQgJIY17QuuPDOB8XWIP8HYmg5jOQ-LroFH7tiGAU,3012
|
|
37
37
|
prefig/core/shape.py,sha256=Qb_-upbSHwEoYrrAnbCoFFFuVIb3JgJLdyP9ckD5evc,8675
|
|
@@ -61,8 +61,8 @@ prefig/resources/schema/pf_schema.rng,sha256=SmYGLT9X6w6LEWulHHz2RgD6Q2v1sV24Wjc
|
|
|
61
61
|
prefig/resources/template/pf_publication.xml,sha256=eEv8HACv610Apw5DSVNy0reLfELYqHlNy9Oq0GH7C_c,200
|
|
62
62
|
prefig/scripts/__init__.py,sha256=qJcPi1WRh9UAwu4zIFJbmxWalAMilMYqgi6LxRkF7bI,25
|
|
63
63
|
prefig/scripts/install_mj.py,sha256=5A6-oc1xbIXka5mkFE70vlp9-Rh_QoxOxGMrQi9Hkio,1219
|
|
64
|
-
prefig-0.4.
|
|
65
|
-
prefig-0.4.
|
|
66
|
-
prefig-0.4.
|
|
67
|
-
prefig-0.4.
|
|
68
|
-
prefig-0.4.
|
|
64
|
+
prefig-0.4.5.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
65
|
+
prefig-0.4.5.dist-info/METADATA,sha256=O4Lwxg5UK9KRXGZtJwe5-lOEtIyx3svbGQsRDaMhmlo,8698
|
|
66
|
+
prefig-0.4.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
67
|
+
prefig-0.4.5.dist-info/entry_points.txt,sha256=OP4ZQT71q2b0Zfbie-oM2Z1HlxpkuX7qaxJnzwsBOVQ,42
|
|
68
|
+
prefig-0.4.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|