vec-io 0.7.0__py3-none-win_arm64.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.
- vec_io/__init__.py +60 -0
- vec_io/__main__.py +8 -0
- vec_io/arrays.py +99 -0
- vec_io/canvas.py +2059 -0
- vec_io/cells.py +538 -0
- vec_io/cli.py +1161 -0
- vec_io/convert.py +481 -0
- vec_io/css_tokens.py +313 -0
- vec_io/document.py +2060 -0
- vec_io/draw.py +1246 -0
- vec_io/eps/__init__.py +597 -0
- vec_io/eps/fonts.py +302 -0
- vec_io/errors.py +26 -0
- vec_io/filter.py +1025 -0
- vec_io/flate.py +87 -0
- vec_io/flatten.py +707 -0
- vec_io/fonts/__init__.py +562 -0
- vec_io/fonts/cff.py +681 -0
- vec_io/fonts/cff2.py +210 -0
- vec_io/fonts/charstring.py +523 -0
- vec_io/fonts/colr.py +591 -0
- vec_io/fonts/ctan.py +74 -0
- vec_io/fonts/download.py +796 -0
- vec_io/fonts/encodings.py +255 -0
- vec_io/fonts/fontdb.py +806 -0
- vec_io/fonts/fontshare.py +109 -0
- vec_io/fonts/fontshare_families.txt +102 -0
- vec_io/fonts/fontsource.py +70 -0
- vec_io/fonts/fontsource_families.txt +121 -0
- vec_io/fonts/glyphlist.txt +3764 -0
- vec_io/fonts/google.py +464 -0
- vec_io/fonts/google_families.txt +1961 -0
- vec_io/fonts/opentype.py +1556 -0
- vec_io/fonts/program.py +155 -0
- vec_io/fonts/sfnt.py +1255 -0
- vec_io/fonts/type1.py +912 -0
- vec_io/fonts/urw.py +141 -0
- vec_io/fonts/variations.py +759 -0
- vec_io/fonts/web.py +153 -0
- vec_io/fonts/woff2.py +369 -0
- vec_io/geometry.py +1250 -0
- vec_io/image/__init__.py +305 -0
- vec_io/image/avif.py +269 -0
- vec_io/image/bmp.py +308 -0
- vec_io/image/codecs.py +121 -0
- vec_io/image/gif.py +122 -0
- vec_io/image/icc.py +242 -0
- vec_io/image/jbig2.py +278 -0
- vec_io/image/jpx.py +349 -0
- vec_io/image/jxl.py +443 -0
- vec_io/image/resource.py +925 -0
- vec_io/image/tiff.py +263 -0
- vec_io/image/webp.py +183 -0
- vec_io/items.py +250 -0
- vec_io/limits.py +369 -0
- vec_io/lines.py +384 -0
- vec_io/native/__init__.py +469 -0
- vec_io/native/__main__.py +184 -0
- vec_io/native/_api.py +1218 -0
- vec_io/native/bin/windows-arm64.dll +0 -0
- vec_io/native/brotli.py +37 -0
- vec_io/native/emit.py +348 -0
- vec_io/native/filters.py +206 -0
- vec_io/native/jpeg.py +179 -0
- vec_io/native/manifest.json +54 -0
- vec_io/native/pdfread.py +237 -0
- vec_io/native/png.py +514 -0
- vec_io/native/woff2.py +35 -0
- vec_io/network.py +190 -0
- vec_io/notebook.py +37 -0
- vec_io/options.py +515 -0
- vec_io/output_plan.py +173 -0
- vec_io/paint.py +1291 -0
- vec_io/pdf/__init__.py +1 -0
- vec_io/pdf/copier.py +141 -0
- vec_io/pdf/images.py +252 -0
- vec_io/pdf/objects.py +326 -0
- vec_io/pdf/pdfa.py +212 -0
- vec_io/pdf/writer.py +215 -0
- vec_io/pdffile.py +962 -0
- vec_io/pdfread/__init__.py +226 -0
- vec_io/pdfread/ccitt.py +38 -0
- vec_io/pdfread/cmap.py +694 -0
- vec_io/pdfread/cmap_resources.txt +210 -0
- vec_io/pdfread/cmaps.zip +0 -0
- vec_io/pdfread/colors.py +385 -0
- vec_io/pdfread/content.py +929 -0
- vec_io/pdfread/convert.py +45 -0
- vec_io/pdfread/errors.py +25 -0
- vec_io/pdfread/file.py +717 -0
- vec_io/pdfread/fonts.py +1099 -0
- vec_io/pdfread/functions.py +345 -0
- vec_io/pdfread/images.py +805 -0
- vec_io/pdfread/meshes.py +80 -0
- vec_io/pdfread/origin.py +334 -0
- vec_io/pdfread/parser.py +232 -0
- vec_io/pdfread/reader.py +810 -0
- vec_io/pdfread/resources.py +527 -0
- vec_io/pdfread/security.py +296 -0
- vec_io/pdfread/shadings.py +470 -0
- vec_io/pdfread/strings.py +58 -0
- vec_io/py.typed +0 -0
- vec_io/raster/__init__.py +893 -0
- vec_io/raster/groups.py +392 -0
- vec_io/raster/resources.py +447 -0
- vec_io/recorder.py +1199 -0
- vec_io/records.py +411 -0
- vec_io/resample.py +232 -0
- vec_io/resources.py +70 -0
- vec_io/scene.py +916 -0
- vec_io/shapes.py +308 -0
- vec_io/simplify.py +442 -0
- vec_io/svg/__init__.py +11 -0
- vec_io/svg/basic_shapes.py +386 -0
- vec_io/svg/clipmask.py +277 -0
- vec_io/svg/common.py +188 -0
- vec_io/svg/css.py +1246 -0
- vec_io/svg/filters.py +813 -0
- vec_io/svg/fontface.py +177 -0
- vec_io/svg/images.py +139 -0
- vec_io/svg/markers.py +68 -0
- vec_io/svg/painter.py +271 -0
- vec_io/svg/parse.py +624 -0
- vec_io/svg/properties.py +1038 -0
- vec_io/svg/references.py +84 -0
- vec_io/svg/render.py +584 -0
- vec_io/svg/servers.py +164 -0
- vec_io/svg/text.py +1034 -0
- vec_io/svg/text_paint.py +330 -0
- vec_io/svg/tree.py +491 -0
- vec_io/svg/values.py +741 -0
- vec_io/svg/writer.py +1001 -0
- vec_io/text/__init__.py +1861 -0
- vec_io/text/bidi.py +410 -0
- vec_io/text/breaking.py +1056 -0
- vec_io/text/harfbuzz.py +222 -0
- vec_io/text/hyph_en_us.py +387 -0
- vec_io/text/hyph_fr.py +123 -0
- vec_io/text/hyphenation.py +165 -0
- vec_io/text/mirroring.py +92 -0
- vec_io/text/path.py +116 -0
- vec_io/text/segment.py +139 -0
- vec_io/text/shaping.py +700 -0
- vec_io/text/ucd_grapheme.py +338 -0
- vec_io/text/ucd_ignorable.py +19 -0
- vec_io/text/ucd_linebreak.py +608 -0
- vec_io/text/ucd_scripts.py +514 -0
- vec_io/threads.py +133 -0
- vec_io/transfer.py +477 -0
- vec_io/trim.py +170 -0
- vec_io/types.py +167 -0
- vec_io/units.py +738 -0
- vec_io-0.7.0.dist-info/METADATA +133 -0
- vec_io-0.7.0.dist-info/RECORD +157 -0
- vec_io-0.7.0.dist-info/WHEEL +4 -0
- vec_io-0.7.0.dist-info/entry_points.txt +2 -0
- vec_io-0.7.0.dist-info/licenses/LICENSE +28 -0
vec_io/__init__.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""vec_io: create PDF files and images in Python, with no dependencies (a bundled C library
|
|
2
|
+
does the heavy lifting).
|
|
3
|
+
|
|
4
|
+
Basic usage::
|
|
5
|
+
|
|
6
|
+
import vec_io
|
|
7
|
+
|
|
8
|
+
doc = vec_io.Document(unit="mm")
|
|
9
|
+
page = doc.add_page(size="A4")
|
|
10
|
+
page.draw_rect(20, 20, 50, 30, fill="tomato")
|
|
11
|
+
page.draw_text("Hello", 20, 70)
|
|
12
|
+
doc.save("hello.pdf")
|
|
13
|
+
page.save("hello.png", dpi=150)
|
|
14
|
+
|
|
15
|
+
vec_io.convert("drawing.svg", "drawing.pdf")
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from .convert import convert
|
|
19
|
+
from .document import Bookmark, Document, Page
|
|
20
|
+
from .errors import ArgumentError, StateError, VecIOError, VecIOWarning
|
|
21
|
+
from .filter import Filter
|
|
22
|
+
from .flatten import FlattenWarning
|
|
23
|
+
from .fonts.download import FontDownloadError, FontDownloadWarning
|
|
24
|
+
from .fonts.fontdb import FontDB, NoFontError
|
|
25
|
+
from .fonts.sfnt import FontError
|
|
26
|
+
from .geometry import Matrix, Path
|
|
27
|
+
from .image import Image
|
|
28
|
+
from .image.resource import ImageError, ImageWarning
|
|
29
|
+
from .limits import LimitError, Limits
|
|
30
|
+
from .native import NativeLibraryError
|
|
31
|
+
from .network import NetworkError, NetworkWarning
|
|
32
|
+
from .options import (AVIF, JPEG, JXL, PDF, PNG, TIFF, Flatten, Fonts, ImagePolicy,
|
|
33
|
+
OptionError, Simplify, View)
|
|
34
|
+
from .paint import (CMYK, Color, ColorLike, LinearGradient, Marker, Mask, Paint, PathMarker,
|
|
35
|
+
Pattern, RadialGradient, Spot)
|
|
36
|
+
from .pdffile import PageBoxes, PDFFile, PDFPage
|
|
37
|
+
from .pdfread import PDFReadError, PDFReadWarning, open_pdf
|
|
38
|
+
from .raster import RasterizationError
|
|
39
|
+
from .svg import SVGDocument, SVGParseError, SVGWarning
|
|
40
|
+
from .text import Content, Font, GlyphRun, Span
|
|
41
|
+
from .text.breaking import TextLayout
|
|
42
|
+
from .types import Style
|
|
43
|
+
|
|
44
|
+
__all__ = ["convert", "SVGDocument", "open_pdf", "PDFFile", "PDFPage", "PageBoxes",
|
|
45
|
+
"Document", "Page", "Bookmark", "Style",
|
|
46
|
+
"Fonts", "Flatten", "Simplify", "View", "ImagePolicy", "PDF", "PNG", "JPEG", "JXL", "AVIF",
|
|
47
|
+
"TIFF",
|
|
48
|
+
"Color", "ColorLike", "CMYK", "Spot", "Paint", "LinearGradient", "RadialGradient",
|
|
49
|
+
"Pattern", "Mask", "Marker", "PathMarker", "Filter",
|
|
50
|
+
"Matrix", "Path", "Font", "GlyphRun", "Span", "Content", "TextLayout", "FontDB",
|
|
51
|
+
"Image", "Limits",
|
|
52
|
+
"VecIOError", "ArgumentError", "StateError", "LimitError", "OptionError",
|
|
53
|
+
"SVGParseError", "PDFReadError", "RasterizationError",
|
|
54
|
+
"FontError", "NoFontError", "FontDownloadError", "ImageError",
|
|
55
|
+
"NativeLibraryError", "NetworkError",
|
|
56
|
+
"VecIOWarning", "PDFReadWarning", "FlattenWarning", "FontDownloadWarning",
|
|
57
|
+
"NetworkWarning", "ImageWarning", "SVGWarning",
|
|
58
|
+
"__version__"]
|
|
59
|
+
|
|
60
|
+
__version__ = "0.7.0"
|
vec_io/__main__.py
ADDED
vec_io/arrays.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Array arguments: sequences of numbers (``None`` for missing values) or any object
|
|
2
|
+
exporting the buffer protocol (``array.array``, ``memoryview``, numpy arrays, ...). Buffers
|
|
3
|
+
are read through :class:`memoryview` and converted in C; numpy is never imported."""
|
|
4
|
+
|
|
5
|
+
import array
|
|
6
|
+
import math
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from .errors import ArgumentError
|
|
10
|
+
from .native import emit
|
|
11
|
+
|
|
12
|
+
__all__ = ["doubles", "buffer_shape", "rows", "grid"]
|
|
13
|
+
|
|
14
|
+
_FORMATS = {"d": ("f", 8), "f": ("f", 4), "b": ("i", 1), "B": ("u", 1), "h": ("i", 2),
|
|
15
|
+
"H": ("u", 2), "i": ("i", 4), "I": ("u", 4), "l": ("i", 0), "L": ("u", 0),
|
|
16
|
+
"q": ("i", 8), "Q": ("u", 8), "n": ("i", 0), "N": ("u", 0), "?": ("b", 1)}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _view(value):
|
|
20
|
+
"""A memoryview of ``value`` when it has a numeric buffer, else ``None``."""
|
|
21
|
+
if isinstance(value, (str, bytes, bytearray)):
|
|
22
|
+
return None
|
|
23
|
+
try:
|
|
24
|
+
mv = memoryview(value)
|
|
25
|
+
except TypeError:
|
|
26
|
+
return None
|
|
27
|
+
fmt = mv.format.lstrip("@=<>!")
|
|
28
|
+
return mv if fmt in _FORMATS else None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def color_scale(value):
|
|
32
|
+
"""What the numbers of a color buffer are multiplied by: ``1 / 255`` for integers
|
|
33
|
+
(8-bit components), 1 for floats and other values."""
|
|
34
|
+
mv = _view(value)
|
|
35
|
+
if mv is None or _FORMATS[mv.format.lstrip("@=<>!")][0] == "f":
|
|
36
|
+
return 1.0
|
|
37
|
+
return 1.0 / 255.0
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def buffer_shape(value):
|
|
41
|
+
"""Shape of a numeric buffer, or ``None`` for other values."""
|
|
42
|
+
mv = _view(value)
|
|
43
|
+
return None if mv is None else tuple(mv.shape)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _convert(mv):
|
|
47
|
+
"""All items of a numeric buffer as ``array('d')`` (row-major)."""
|
|
48
|
+
order = mv.format[0] if mv.format[0] in "@=<>!" else "@"
|
|
49
|
+
kind, size = _FORMATS[mv.format.lstrip("@=<>!")]
|
|
50
|
+
size = size or mv.itemsize
|
|
51
|
+
n = mv.nbytes // mv.itemsize if mv.itemsize else 0
|
|
52
|
+
little = order in "<" or (order in "@=" and sys.byteorder == "little")
|
|
53
|
+
if not n:
|
|
54
|
+
return array.array("d")
|
|
55
|
+
if kind == "f" and size == 8 and little == (sys.byteorder == "little"):
|
|
56
|
+
out = array.array("d")
|
|
57
|
+
out.frombytes(mv.tobytes() if not mv.c_contiguous else mv.cast("B"))
|
|
58
|
+
return out
|
|
59
|
+
data = mv if mv.c_contiguous else mv.tobytes()
|
|
60
|
+
return emit.to_doubles(data, kind, size, little, size, n)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def doubles(value, what="values"):
|
|
64
|
+
"""``value`` (a sequence or a 1-D buffer) as ``array('d')``; ``None`` becomes NaN.
|
|
65
|
+
Raises ``ArgumentError`` naming ``what`` for anything else."""
|
|
66
|
+
if isinstance(value, array.array) and value.typecode == "d":
|
|
67
|
+
return value
|
|
68
|
+
mv = _view(value)
|
|
69
|
+
if mv is not None:
|
|
70
|
+
if mv.ndim != 1:
|
|
71
|
+
raise ArgumentError(f"{what}: expected a 1-D sequence")
|
|
72
|
+
return _convert(mv)
|
|
73
|
+
nan = math.nan
|
|
74
|
+
try:
|
|
75
|
+
if isinstance(value, (str, bytes)):
|
|
76
|
+
raise TypeError
|
|
77
|
+
return array.array("d", [nan if v is None else float(v) for v in value])
|
|
78
|
+
except (TypeError, ValueError):
|
|
79
|
+
raise ArgumentError(f"{what} must be numbers (or None), not {value!r}"[:200]) from None
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def rows(value):
|
|
83
|
+
"""A 2-D buffer as a list of ``array('d')`` rows, or ``None`` for other values."""
|
|
84
|
+
mv = _view(value)
|
|
85
|
+
if mv is None or mv.ndim != 2:
|
|
86
|
+
return None
|
|
87
|
+
h, w = mv.shape
|
|
88
|
+
flat = _convert(mv)
|
|
89
|
+
return [flat[i * w:(i + 1) * w] for i in range(h)]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def grid(value):
|
|
93
|
+
"""``(height, width, k, array('d'))`` of a 2-D (k = 1) or 3-D buffer, or ``None``."""
|
|
94
|
+
mv = _view(value)
|
|
95
|
+
if mv is None or mv.ndim not in (2, 3):
|
|
96
|
+
return None
|
|
97
|
+
h, w = mv.shape[:2]
|
|
98
|
+
k = mv.shape[2] if mv.ndim == 3 else 1
|
|
99
|
+
return h, w, k, _convert(mv)
|