ezhpgl 0.1.0a1__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.
Files changed (104) hide show
  1. ezhpgl-0.1.0a1/Cargo.lock +213 -0
  2. ezhpgl-0.1.0a1/Cargo.toml +16 -0
  3. ezhpgl-0.1.0a1/LICENSE +21 -0
  4. ezhpgl-0.1.0a1/PKG-INFO +119 -0
  5. ezhpgl-0.1.0a1/README.md +98 -0
  6. ezhpgl-0.1.0a1/crates/ezhpgl-core/Cargo.toml +14 -0
  7. ezhpgl-0.1.0a1/crates/ezhpgl-core/LICENSE +21 -0
  8. ezhpgl-0.1.0a1/crates/ezhpgl-core/README.md +98 -0
  9. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/attributes.rs +367 -0
  10. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/clip.rs +188 -0
  11. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/command.rs +207 -0
  12. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/curves.rs +210 -0
  13. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/detect.rs +54 -0
  14. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/diagnostics.rs +32 -0
  15. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/document.rs +307 -0
  16. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/export.rs +551 -0
  17. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/interpreter/drawing.rs +497 -0
  18. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/interpreter/labels.rs +207 -0
  19. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/interpreter.rs +704 -0
  20. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/lexer.rs +678 -0
  21. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/lib.rs +35 -0
  22. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/pe.rs +173 -0
  23. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/polygon.rs +216 -0
  24. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/stream.rs +335 -0
  25. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/text.rs +586 -0
  26. ezhpgl-0.1.0a1/crates/ezhpgl-core/src/transform.rs +486 -0
  27. ezhpgl-0.1.0a1/crates/ezhpgl-core/tests/containers.rs +255 -0
  28. ezhpgl-0.1.0a1/crates/ezhpgl-core/tests/drawing.rs +529 -0
  29. ezhpgl-0.1.0a1/crates/ezhpgl-core/tests/interpreter.rs +305 -0
  30. ezhpgl-0.1.0a1/crates/ezhpgl-core/tests/labels.rs +373 -0
  31. ezhpgl-0.1.0a1/crates/ezhpgl-core/tests/lexer.rs +421 -0
  32. ezhpgl-0.1.0a1/crates/ezhpgl-core/tests/pe.rs +203 -0
  33. ezhpgl-0.1.0a1/crates/ezhpgl-core/tests/transforms.rs +267 -0
  34. ezhpgl-0.1.0a1/crates/ezhpgl-python/Cargo.toml +17 -0
  35. ezhpgl-0.1.0a1/crates/ezhpgl-python/LICENSE +21 -0
  36. ezhpgl-0.1.0a1/crates/ezhpgl-python/src/lib.rs +344 -0
  37. ezhpgl-0.1.0a1/crates/ezhpgl-python/src/plot/labels.rs +200 -0
  38. ezhpgl-0.1.0a1/crates/ezhpgl-python/src/plot.rs +756 -0
  39. ezhpgl-0.1.0a1/docs/api.md +179 -0
  40. ezhpgl-0.1.0a1/docs/architecture.md +50 -0
  41. ezhpgl-0.1.0a1/docs/cli.md +50 -0
  42. ezhpgl-0.1.0a1/docs/development.md +37 -0
  43. ezhpgl-0.1.0a1/docs/drawing.md +134 -0
  44. ezhpgl-0.1.0a1/docs/profile.md +136 -0
  45. ezhpgl-0.1.0a1/docs/supported-commands.md +40 -0
  46. ezhpgl-0.1.0a1/docs/text-and-containers.md +158 -0
  47. ezhpgl-0.1.0a1/examples/curves-and-fills.hpgl +11 -0
  48. ezhpgl-0.1.0a1/examples/labels.hpgl +9 -0
  49. ezhpgl-0.1.0a1/examples/linework.hpgl +10 -0
  50. ezhpgl-0.1.0a1/examples/mixed-pages.pcl +0 -0
  51. ezhpgl-0.1.0a1/examples/transformed.hpgl +7 -0
  52. ezhpgl-0.1.0a1/pyproject.toml +51 -0
  53. ezhpgl-0.1.0a1/python/ezhpgl/__init__.py +87 -0
  54. ezhpgl-0.1.0a1/python/ezhpgl/__main__.py +3 -0
  55. ezhpgl-0.1.0a1/python/ezhpgl/_core.pyi +436 -0
  56. ezhpgl-0.1.0a1/python/ezhpgl/cli.py +91 -0
  57. ezhpgl-0.1.0a1/python/ezhpgl/py.typed +0 -0
  58. ezhpgl-0.1.0a1/python/ezhpgl/raw.py +32 -0
  59. ezhpgl-0.1.0a1/scripts/check_dist.py +83 -0
  60. ezhpgl-0.1.0a1/scripts/check_public_docs.py +30 -0
  61. ezhpgl-0.1.0a1/scripts/check_release.py +137 -0
  62. ezhpgl-0.1.0a1/scripts/create_fixtures.py +54 -0
  63. ezhpgl-0.1.0a1/tests/fixtures/begin_plot.hpgl +1 -0
  64. ezhpgl-0.1.0a1/tests/fixtures/comment.hpgl +1 -0
  65. ezhpgl-0.1.0a1/tests/fixtures/concatenated.hpgl +1 -0
  66. ezhpgl-0.1.0a1/tests/fixtures/decimals.hpgl +1 -0
  67. ezhpgl-0.1.0a1/tests/fixtures/df_reset.hpgl +1 -0
  68. ezhpgl-0.1.0a1/tests/fixtures/dt_custom.hpgl +1 -0
  69. ezhpgl-0.1.0a1/tests/fixtures/dt_digit.hpgl +1 -0
  70. ezhpgl-0.1.0a1/tests/fixtures/dt_print.hpgl +1 -0
  71. ezhpgl-0.1.0a1/tests/fixtures/dt_reset.hpgl +1 -0
  72. ezhpgl-0.1.0a1/tests/fixtures/dt_space.hpgl +1 -0
  73. ezhpgl-0.1.0a1/tests/fixtures/empty.hpgl +0 -0
  74. ezhpgl-0.1.0a1/tests/fixtures/empty_parameter.hpgl +1 -0
  75. ezhpgl-0.1.0a1/tests/fixtures/exponent.hpgl +1 -0
  76. ezhpgl-0.1.0a1/tests/fixtures/in_reset.hpgl +1 -0
  77. ezhpgl-0.1.0a1/tests/fixtures/invalid_dt.hpgl +1 -0
  78. ezhpgl-0.1.0a1/tests/fixtures/label.hpgl +1 -0
  79. ezhpgl-0.1.0a1/tests/fixtures/label_binary.hpgl +1 -0
  80. ezhpgl-0.1.0a1/tests/fixtures/label_commands.hpgl +1 -0
  81. ezhpgl-0.1.0a1/tests/fixtures/line.hpgl +1 -0
  82. ezhpgl-0.1.0a1/tests/fixtures/lowercase.hpgl +1 -0
  83. ezhpgl-0.1.0a1/tests/fixtures/manifest.json +252 -0
  84. ezhpgl-0.1.0a1/tests/fixtures/missing_comment_quote.hpgl +1 -0
  85. ezhpgl-0.1.0a1/tests/fixtures/missing_final_terminator.hpgl +1 -0
  86. ezhpgl-0.1.0a1/tests/fixtures/missing_label_terminator.hpgl +1 -0
  87. ezhpgl-0.1.0a1/tests/fixtures/missing_pe_terminator.hpgl +1 -0
  88. ezhpgl-0.1.0a1/tests/fixtures/padding.hpgl +2 -0
  89. ezhpgl-0.1.0a1/tests/fixtures/pcl_container.hpgl +1 -0
  90. ezhpgl-0.1.0a1/tests/fixtures/pdf_signature.hpgl +1 -0
  91. ezhpgl-0.1.0a1/tests/fixtures/pe_empty.hpgl +1 -0
  92. ezhpgl-0.1.0a1/tests/fixtures/pe_raw.hpgl +1 -0
  93. ezhpgl-0.1.0a1/tests/fixtures/unsupported_grammar.hpgl +1 -0
  94. ezhpgl-0.1.0a1/tests/fixtures/whitespace.hpgl +2 -0
  95. ezhpgl-0.1.0a1/tests/golden/commands.hpgl +1 -0
  96. ezhpgl-0.1.0a1/tests/golden/commands.json +5 -0
  97. ezhpgl-0.1.0a1/tests/golden/plot.hpgl +1 -0
  98. ezhpgl-0.1.0a1/tests/golden/plot.json +44 -0
  99. ezhpgl-0.1.0a1/tests/python/test_drawing.py +113 -0
  100. ezhpgl-0.1.0a1/tests/python/test_labels_containers.py +148 -0
  101. ezhpgl-0.1.0a1/tests/python/test_plot.py +187 -0
  102. ezhpgl-0.1.0a1/tests/python/test_raw.py +190 -0
  103. ezhpgl-0.1.0a1/tests/python/test_transforms.py +138 -0
  104. ezhpgl-0.1.0a1/tests/release/test_checks.py +71 -0
@@ -0,0 +1,213 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "ezhpgl-core"
7
+ version = "0.1.0-alpha.1"
8
+ dependencies = [
9
+ "serde",
10
+ "serde_json",
11
+ ]
12
+
13
+ [[package]]
14
+ name = "ezhpgl-python"
15
+ version = "0.1.0-alpha.1"
16
+ dependencies = [
17
+ "ezhpgl-core",
18
+ "pyo3",
19
+ ]
20
+
21
+ [[package]]
22
+ name = "heck"
23
+ version = "0.5.0"
24
+ source = "registry+https://github.com/rust-lang/crates.io-index"
25
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
26
+
27
+ [[package]]
28
+ name = "itoa"
29
+ version = "1.0.18"
30
+ source = "registry+https://github.com/rust-lang/crates.io-index"
31
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
32
+
33
+ [[package]]
34
+ name = "libc"
35
+ version = "0.2.191"
36
+ source = "registry+https://github.com/rust-lang/crates.io-index"
37
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
38
+
39
+ [[package]]
40
+ name = "memchr"
41
+ version = "2.8.3"
42
+ source = "registry+https://github.com/rust-lang/crates.io-index"
43
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
44
+
45
+ [[package]]
46
+ name = "once_cell"
47
+ version = "1.21.4"
48
+ source = "registry+https://github.com/rust-lang/crates.io-index"
49
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
50
+
51
+ [[package]]
52
+ name = "portable-atomic"
53
+ version = "1.15.0"
54
+ source = "registry+https://github.com/rust-lang/crates.io-index"
55
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
56
+
57
+ [[package]]
58
+ name = "proc-macro2"
59
+ version = "1.0.107"
60
+ source = "registry+https://github.com/rust-lang/crates.io-index"
61
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
62
+ dependencies = [
63
+ "unicode-ident",
64
+ ]
65
+
66
+ [[package]]
67
+ name = "pyo3"
68
+ version = "0.29.3"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "700d18fa267b73b9b521fd7e13580e2f446916f176cacee1ab63fcc8191f1655"
71
+ dependencies = [
72
+ "libc",
73
+ "once_cell",
74
+ "portable-atomic",
75
+ "pyo3-build-config",
76
+ "pyo3-ffi",
77
+ "pyo3-macros",
78
+ ]
79
+
80
+ [[package]]
81
+ name = "pyo3-build-config"
82
+ version = "0.29.3"
83
+ source = "registry+https://github.com/rust-lang/crates.io-index"
84
+ checksum = "7b3fc0c4d08f6bb10e71fe39dfb9e2f59c6eb6854e22ec8092f50c69a4499adb"
85
+ dependencies = [
86
+ "target-lexicon",
87
+ ]
88
+
89
+ [[package]]
90
+ name = "pyo3-ffi"
91
+ version = "0.29.3"
92
+ source = "registry+https://github.com/rust-lang/crates.io-index"
93
+ checksum = "dfc0b8e19df29aad7086cf977bb0c2a2f143e30567eb113e9cf72b62ca698330"
94
+ dependencies = [
95
+ "libc",
96
+ "pyo3-build-config",
97
+ ]
98
+
99
+ [[package]]
100
+ name = "pyo3-macros"
101
+ version = "0.29.3"
102
+ source = "registry+https://github.com/rust-lang/crates.io-index"
103
+ checksum = "6100e8a4b5eba53afaa5ed078364851a0b2499c553a44c31026b929049b49dc6"
104
+ dependencies = [
105
+ "proc-macro2",
106
+ "pyo3-macros-backend",
107
+ "quote",
108
+ "syn 2.0.119",
109
+ ]
110
+
111
+ [[package]]
112
+ name = "pyo3-macros-backend"
113
+ version = "0.29.3"
114
+ source = "registry+https://github.com/rust-lang/crates.io-index"
115
+ checksum = "6143877a16e82b5a727b7127ff4cd86858a24a28d745d72f43e6f227c7b1bdb3"
116
+ dependencies = [
117
+ "heck",
118
+ "proc-macro2",
119
+ "quote",
120
+ "syn 2.0.119",
121
+ ]
122
+
123
+ [[package]]
124
+ name = "quote"
125
+ version = "1.0.47"
126
+ source = "registry+https://github.com/rust-lang/crates.io-index"
127
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
128
+ dependencies = [
129
+ "proc-macro2",
130
+ ]
131
+
132
+ [[package]]
133
+ name = "serde"
134
+ version = "1.0.229"
135
+ source = "registry+https://github.com/rust-lang/crates.io-index"
136
+ checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
137
+ dependencies = [
138
+ "serde_core",
139
+ "serde_derive",
140
+ ]
141
+
142
+ [[package]]
143
+ name = "serde_core"
144
+ version = "1.0.229"
145
+ source = "registry+https://github.com/rust-lang/crates.io-index"
146
+ checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
147
+ dependencies = [
148
+ "serde_derive",
149
+ ]
150
+
151
+ [[package]]
152
+ name = "serde_derive"
153
+ version = "1.0.229"
154
+ source = "registry+https://github.com/rust-lang/crates.io-index"
155
+ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
156
+ dependencies = [
157
+ "proc-macro2",
158
+ "quote",
159
+ "syn 3.0.9",
160
+ ]
161
+
162
+ [[package]]
163
+ name = "serde_json"
164
+ version = "1.0.154"
165
+ source = "registry+https://github.com/rust-lang/crates.io-index"
166
+ checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
167
+ dependencies = [
168
+ "itoa",
169
+ "memchr",
170
+ "serde",
171
+ "serde_core",
172
+ "zmij",
173
+ ]
174
+
175
+ [[package]]
176
+ name = "syn"
177
+ version = "2.0.119"
178
+ source = "registry+https://github.com/rust-lang/crates.io-index"
179
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
180
+ dependencies = [
181
+ "proc-macro2",
182
+ "quote",
183
+ "unicode-ident",
184
+ ]
185
+
186
+ [[package]]
187
+ name = "syn"
188
+ version = "3.0.9"
189
+ source = "registry+https://github.com/rust-lang/crates.io-index"
190
+ checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
191
+ dependencies = [
192
+ "proc-macro2",
193
+ "quote",
194
+ "unicode-ident",
195
+ ]
196
+
197
+ [[package]]
198
+ name = "target-lexicon"
199
+ version = "0.13.5"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
202
+
203
+ [[package]]
204
+ name = "unicode-ident"
205
+ version = "1.0.27"
206
+ source = "registry+https://github.com/rust-lang/crates.io-index"
207
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
208
+
209
+ [[package]]
210
+ name = "zmij"
211
+ version = "1.0.23"
212
+ source = "registry+https://github.com/rust-lang/crates.io-index"
213
+ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
@@ -0,0 +1,16 @@
1
+ [workspace]
2
+ members = ["crates/ezhpgl-python"]
3
+ default-members = ["crates/ezhpgl-core"]
4
+ exclude = ["fuzz"]
5
+ resolver = "2"
6
+
7
+ [workspace.package]
8
+ version = "0.1.0-alpha.1"
9
+ edition = "2021"
10
+ rust-version = "1.85"
11
+ license = "MIT"
12
+ repository = "https://github.com/monozukuri-ai/ezhpgl"
13
+
14
+ [workspace.dependencies]
15
+ ezhpgl-core = { path = "crates/ezhpgl-core", version = "0.1.0-alpha.1" }
16
+ pyo3 = { version = "0.29.3", features = ["abi3-py310"] }
ezhpgl-0.1.0a1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ezhpgl contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.4
2
+ Name: ezhpgl
3
+ Version: 0.1.0a1
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: Implementation :: CPython
8
+ Requires-Dist: pytest>=8,<10 ; extra == 'test'
9
+ Provides-Extra: test
10
+ License-File: LICENSE
11
+ Summary: Rust-backed HP-GL parsing, labels, bounded PCL/PJL extraction and JSON/SVG export
12
+ Keywords: hpgl,hpgl2,plt,cad,parser
13
+ License-Expression: MIT
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
16
+ Project-URL: Documentation, https://github.com/monozukuri-ai/ezhpgl/tree/main/docs
17
+ Project-URL: Homepage, https://github.com/monozukuri-ai/ezhpgl
18
+ Project-URL: Issues, https://github.com/monozukuri-ai/ezhpgl/issues
19
+ Project-URL: Repository, https://github.com/monozukuri-ai/ezhpgl
20
+
21
+ # ezhpgl
22
+
23
+ A Rust-backed HP-GL and HP-GL/2 parser for Python. Read plot files, inspect their
24
+ geometry and source commands, and export JSON or SVG.
25
+
26
+ - Lines, encoded polylines, arcs, ellipses, Bézier curves, polygons and hatch fills.
27
+ - Pen attributes, coordinate transforms, clipping and separate plot pages.
28
+ - Labels with original bytes, placement information and substitute-font previews.
29
+ - A documented subset of PCL/PJL containers, with diagnostics for omitted content.
30
+ - Read-only Python objects, source byte ranges and configurable resource limits.
31
+
32
+ ## Installation
33
+
34
+ Requires CPython 3.10 or newer. This is an alpha release:
35
+
36
+ ```bash
37
+ python -m pip install --pre ezhpgl
38
+ ```
39
+
40
+ Conventional GIL-enabled CPython is supported. Building from source requires
41
+ Rust 1.85 or newer and maturin; see [development](docs/development.md).
42
+
43
+ ## Quick start
44
+
45
+ ```python
46
+ import ezhpgl
47
+
48
+ plot = ezhpgl.parse(b"IN;SP1;PA0,0;PD1600,0,1600,800,0,800,0,0;PU;")
49
+ print(plot.completeness, plot.stats())
50
+ plot.write_svg("drawing.svg")
51
+ plot.write_json("drawing.json")
52
+
53
+ # Or read a file:
54
+ # plot = ezhpgl.readfile("drawing.plt")
55
+ for page in plot.pages:
56
+ for operation in page.operations:
57
+ print(operation.geometry.kind, operation.style.pen, operation.source.span)
58
+ ```
59
+
60
+ Coordinates are physical millimetres, with Y pointing up. The generic profile
61
+ uses 40 plotter units per millimetre. Paper size and plot extents are unknown
62
+ unless supplied explicitly:
63
+
64
+ ```python
65
+ profile = ezhpgl.DeviceProfile(plot_size_mm=(200, 100), paper_size_mm=(210, 297))
66
+ plot = ezhpgl.readfile("drawing.plt", profile=profile)
67
+ ```
68
+
69
+ `plot_size_mm` supplies the hard clipping rectangle and default scaling points.
70
+ `paper_size_mm` is separate metadata. Nonzero `RO` and percentage `IR` need known
71
+ plot extents. See [profile rules](docs/profile.md).
72
+
73
+ ## Command line
74
+
75
+ ```bash
76
+ ezhpgl inspect drawing.hpgl
77
+ ezhpgl commands drawing.hpgl --tolerant
78
+ ezhpgl export drawing.plt --format svg --page 1 -o drawing.svg
79
+ ezhpgl export drawing.plt --format json -o drawing.json
80
+ ```
81
+
82
+ `export` interprets geometry and supported containers. `inspect` and `commands`
83
+ inspect standalone command syntax. Exit codes are `0` for complete, `2` for a
84
+ partial result, and `1` for an error. See [CLI options](docs/cli.md).
85
+
86
+ ## Supported scope and limitations
87
+
88
+ The parser uses an explicit generic plotter profile. It does not emulate every
89
+ printer or recover the original CAD layers, dimensions or model scale.
90
+
91
+ - Automatic `PS` plot sizing and several device-control commands are unsupported.
92
+ Supplying a profile does not make an unsupported command executable.
93
+ - Text previews use substitute fonts. Native fonts, Japanese/multibyte labels,
94
+ and downloaded fonts are unsupported.
95
+ - PCL/PJL support is limited. Supported raster blocks are omitted with diagnostics;
96
+ HP RTL image decoding and full printer emulation are unsupported.
97
+ - Unsupported commands raise in strict mode. With `strict=False`, interpretation
98
+ stops at the first uncertain command and returns the valid prefix as `partial`.
99
+ - Known text approximations and omissions can also produce `partial` in strict
100
+ mode while interpretation continues. Inspect diagnostic codes and actions.
101
+ - A `.plt` extension does not establish the file format. Raw lexical completeness
102
+ does not imply that all commands can be interpreted or rendered.
103
+
104
+ See the [support matrix](docs/supported-commands.md) for command-level coverage.
105
+
106
+ ## Documentation
107
+
108
+ - [Python API](docs/api.md)
109
+ - [CLI](docs/cli.md)
110
+ - [Coordinates, clipping and pages](docs/profile.md)
111
+ - [Curves, pens and polygons](docs/drawing.md)
112
+ - [Labels and PCL/PJL containers](docs/text-and-containers.md)
113
+ - [Architecture](docs/architecture.md)
114
+ - [Development](docs/development.md)
115
+
116
+ ## License
117
+
118
+ [MIT](LICENSE). The parser is independently implemented in Rust with PyO3 bindings.
119
+
@@ -0,0 +1,98 @@
1
+ # ezhpgl
2
+
3
+ A Rust-backed HP-GL and HP-GL/2 parser for Python. Read plot files, inspect their
4
+ geometry and source commands, and export JSON or SVG.
5
+
6
+ - Lines, encoded polylines, arcs, ellipses, Bézier curves, polygons and hatch fills.
7
+ - Pen attributes, coordinate transforms, clipping and separate plot pages.
8
+ - Labels with original bytes, placement information and substitute-font previews.
9
+ - A documented subset of PCL/PJL containers, with diagnostics for omitted content.
10
+ - Read-only Python objects, source byte ranges and configurable resource limits.
11
+
12
+ ## Installation
13
+
14
+ Requires CPython 3.10 or newer. This is an alpha release:
15
+
16
+ ```bash
17
+ python -m pip install --pre ezhpgl
18
+ ```
19
+
20
+ Conventional GIL-enabled CPython is supported. Building from source requires
21
+ Rust 1.85 or newer and maturin; see [development](docs/development.md).
22
+
23
+ ## Quick start
24
+
25
+ ```python
26
+ import ezhpgl
27
+
28
+ plot = ezhpgl.parse(b"IN;SP1;PA0,0;PD1600,0,1600,800,0,800,0,0;PU;")
29
+ print(plot.completeness, plot.stats())
30
+ plot.write_svg("drawing.svg")
31
+ plot.write_json("drawing.json")
32
+
33
+ # Or read a file:
34
+ # plot = ezhpgl.readfile("drawing.plt")
35
+ for page in plot.pages:
36
+ for operation in page.operations:
37
+ print(operation.geometry.kind, operation.style.pen, operation.source.span)
38
+ ```
39
+
40
+ Coordinates are physical millimetres, with Y pointing up. The generic profile
41
+ uses 40 plotter units per millimetre. Paper size and plot extents are unknown
42
+ unless supplied explicitly:
43
+
44
+ ```python
45
+ profile = ezhpgl.DeviceProfile(plot_size_mm=(200, 100), paper_size_mm=(210, 297))
46
+ plot = ezhpgl.readfile("drawing.plt", profile=profile)
47
+ ```
48
+
49
+ `plot_size_mm` supplies the hard clipping rectangle and default scaling points.
50
+ `paper_size_mm` is separate metadata. Nonzero `RO` and percentage `IR` need known
51
+ plot extents. See [profile rules](docs/profile.md).
52
+
53
+ ## Command line
54
+
55
+ ```bash
56
+ ezhpgl inspect drawing.hpgl
57
+ ezhpgl commands drawing.hpgl --tolerant
58
+ ezhpgl export drawing.plt --format svg --page 1 -o drawing.svg
59
+ ezhpgl export drawing.plt --format json -o drawing.json
60
+ ```
61
+
62
+ `export` interprets geometry and supported containers. `inspect` and `commands`
63
+ inspect standalone command syntax. Exit codes are `0` for complete, `2` for a
64
+ partial result, and `1` for an error. See [CLI options](docs/cli.md).
65
+
66
+ ## Supported scope and limitations
67
+
68
+ The parser uses an explicit generic plotter profile. It does not emulate every
69
+ printer or recover the original CAD layers, dimensions or model scale.
70
+
71
+ - Automatic `PS` plot sizing and several device-control commands are unsupported.
72
+ Supplying a profile does not make an unsupported command executable.
73
+ - Text previews use substitute fonts. Native fonts, Japanese/multibyte labels,
74
+ and downloaded fonts are unsupported.
75
+ - PCL/PJL support is limited. Supported raster blocks are omitted with diagnostics;
76
+ HP RTL image decoding and full printer emulation are unsupported.
77
+ - Unsupported commands raise in strict mode. With `strict=False`, interpretation
78
+ stops at the first uncertain command and returns the valid prefix as `partial`.
79
+ - Known text approximations and omissions can also produce `partial` in strict
80
+ mode while interpretation continues. Inspect diagnostic codes and actions.
81
+ - A `.plt` extension does not establish the file format. Raw lexical completeness
82
+ does not imply that all commands can be interpreted or rendered.
83
+
84
+ See the [support matrix](docs/supported-commands.md) for command-level coverage.
85
+
86
+ ## Documentation
87
+
88
+ - [Python API](docs/api.md)
89
+ - [CLI](docs/cli.md)
90
+ - [Coordinates, clipping and pages](docs/profile.md)
91
+ - [Curves, pens and polygons](docs/drawing.md)
92
+ - [Labels and PCL/PJL containers](docs/text-and-containers.md)
93
+ - [Architecture](docs/architecture.md)
94
+ - [Development](docs/development.md)
95
+
96
+ ## License
97
+
98
+ [MIT](LICENSE). The parser is independently implemented in Rust with PyO3 bindings.
@@ -0,0 +1,14 @@
1
+ [package]
2
+ name = "ezhpgl-core"
3
+ version.workspace = true
4
+ edition.workspace = true
5
+ rust-version.workspace = true
6
+ license.workspace = true
7
+ repository.workspace = true
8
+ description = "HP-GL command parser, plot interpreter and JSON/SVG exporter"
9
+ readme = "README.md"
10
+ include = ["src/**", "tests/**", "examples/**", "Cargo.toml", "LICENSE", "../../README.md"]
11
+
12
+ [dependencies]
13
+ serde = { version = "1.0", features = ["derive", "rc"] }
14
+ serde_json = "1.0"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ezhpgl contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,98 @@
1
+ # ezhpgl
2
+
3
+ A Rust-backed HP-GL and HP-GL/2 parser for Python. Read plot files, inspect their
4
+ geometry and source commands, and export JSON or SVG.
5
+
6
+ - Lines, encoded polylines, arcs, ellipses, Bézier curves, polygons and hatch fills.
7
+ - Pen attributes, coordinate transforms, clipping and separate plot pages.
8
+ - Labels with original bytes, placement information and substitute-font previews.
9
+ - A documented subset of PCL/PJL containers, with diagnostics for omitted content.
10
+ - Read-only Python objects, source byte ranges and configurable resource limits.
11
+
12
+ ## Installation
13
+
14
+ Requires CPython 3.10 or newer. This is an alpha release:
15
+
16
+ ```bash
17
+ python -m pip install --pre ezhpgl
18
+ ```
19
+
20
+ Conventional GIL-enabled CPython is supported. Building from source requires
21
+ Rust 1.85 or newer and maturin; see [development](docs/development.md).
22
+
23
+ ## Quick start
24
+
25
+ ```python
26
+ import ezhpgl
27
+
28
+ plot = ezhpgl.parse(b"IN;SP1;PA0,0;PD1600,0,1600,800,0,800,0,0;PU;")
29
+ print(plot.completeness, plot.stats())
30
+ plot.write_svg("drawing.svg")
31
+ plot.write_json("drawing.json")
32
+
33
+ # Or read a file:
34
+ # plot = ezhpgl.readfile("drawing.plt")
35
+ for page in plot.pages:
36
+ for operation in page.operations:
37
+ print(operation.geometry.kind, operation.style.pen, operation.source.span)
38
+ ```
39
+
40
+ Coordinates are physical millimetres, with Y pointing up. The generic profile
41
+ uses 40 plotter units per millimetre. Paper size and plot extents are unknown
42
+ unless supplied explicitly:
43
+
44
+ ```python
45
+ profile = ezhpgl.DeviceProfile(plot_size_mm=(200, 100), paper_size_mm=(210, 297))
46
+ plot = ezhpgl.readfile("drawing.plt", profile=profile)
47
+ ```
48
+
49
+ `plot_size_mm` supplies the hard clipping rectangle and default scaling points.
50
+ `paper_size_mm` is separate metadata. Nonzero `RO` and percentage `IR` need known
51
+ plot extents. See [profile rules](docs/profile.md).
52
+
53
+ ## Command line
54
+
55
+ ```bash
56
+ ezhpgl inspect drawing.hpgl
57
+ ezhpgl commands drawing.hpgl --tolerant
58
+ ezhpgl export drawing.plt --format svg --page 1 -o drawing.svg
59
+ ezhpgl export drawing.plt --format json -o drawing.json
60
+ ```
61
+
62
+ `export` interprets geometry and supported containers. `inspect` and `commands`
63
+ inspect standalone command syntax. Exit codes are `0` for complete, `2` for a
64
+ partial result, and `1` for an error. See [CLI options](docs/cli.md).
65
+
66
+ ## Supported scope and limitations
67
+
68
+ The parser uses an explicit generic plotter profile. It does not emulate every
69
+ printer or recover the original CAD layers, dimensions or model scale.
70
+
71
+ - Automatic `PS` plot sizing and several device-control commands are unsupported.
72
+ Supplying a profile does not make an unsupported command executable.
73
+ - Text previews use substitute fonts. Native fonts, Japanese/multibyte labels,
74
+ and downloaded fonts are unsupported.
75
+ - PCL/PJL support is limited. Supported raster blocks are omitted with diagnostics;
76
+ HP RTL image decoding and full printer emulation are unsupported.
77
+ - Unsupported commands raise in strict mode. With `strict=False`, interpretation
78
+ stops at the first uncertain command and returns the valid prefix as `partial`.
79
+ - Known text approximations and omissions can also produce `partial` in strict
80
+ mode while interpretation continues. Inspect diagnostic codes and actions.
81
+ - A `.plt` extension does not establish the file format. Raw lexical completeness
82
+ does not imply that all commands can be interpreted or rendered.
83
+
84
+ See the [support matrix](docs/supported-commands.md) for command-level coverage.
85
+
86
+ ## Documentation
87
+
88
+ - [Python API](docs/api.md)
89
+ - [CLI](docs/cli.md)
90
+ - [Coordinates, clipping and pages](docs/profile.md)
91
+ - [Curves, pens and polygons](docs/drawing.md)
92
+ - [Labels and PCL/PJL containers](docs/text-and-containers.md)
93
+ - [Architecture](docs/architecture.md)
94
+ - [Development](docs/development.md)
95
+
96
+ ## License
97
+
98
+ [MIT](LICENSE). The parser is independently implemented in Rust with PyO3 bindings.