vec-io 0.3.0__tar.gz → 0.4.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 vec-io might be problematic. Click here for more details.
- {vec_io-0.3.0 → vec_io-0.4.0}/API.md +154 -66
- {vec_io-0.3.0 → vec_io-0.4.0}/PKG-INFO +4 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/README.md +3 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/fuzz_native.py +39 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/helpers.py +20 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/scene_oracle.py +29 -10
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/svg_oracle.py +15 -4
- vec_io-0.4.0/tests/test_actual_text.py +262 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_cmyk.py +3 -3
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_convert.py +3 -3
- vec_io-0.4.0/tests/test_css_browser.py +343 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_document_write.py +1 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_dpi.py +9 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_features.py +9 -5
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_filters.py +1 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_font_fixes.py +101 -0
- vec_io-0.4.0/tests/test_image_formats.py +422 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_jxl.py +5 -5
- vec_io-0.4.0/tests/test_network.py +235 -0
- vec_io-0.4.0/tests/test_paint_browser.py +354 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_raster.py +14 -14
- vec_io-0.4.0/tests/test_text_browser.py +258 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_trim.py +9 -9
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/__init__.py +4 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/__main__.py +25 -9
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/canvas.py +90 -34
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/convert.py +28 -16
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/document.py +79 -28
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/draw.py +14 -7
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/filter.py +6 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/flatten.py +55 -10
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/__init__.py +14 -8
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/cff.py +171 -34
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/download.py +19 -55
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/fontdb.py +52 -7
- vec_io-0.4.0/vec_io/fonts/opentype.py +1180 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/image/avif.py +67 -4
- vec_io-0.4.0/vec_io/image/bmp.py +297 -0
- vec_io-0.4.0/vec_io/image/gif.py +122 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/image/resource.py +156 -24
- vec_io-0.4.0/vec_io/image/webp.py +166 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/README.md +8 -7
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/_api.py +9 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/bin/linux-aarch64.so +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/bin/linux-x86_64.so +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/bin/macos-arm64.dylib +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/bin/windows-arm64.dll +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/bin/windows-x86_64.dll +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/manifest.json +12 -12
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/pdfread.py +11 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/cull.c +9 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/filters.c +18 -11
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/interp.c +47 -7
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/paint.c +71 -4
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/pdfread.c +32 -12
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/pio.h +8 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/pio_api.h +22 -4
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/raster.h +5 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/res.c +6 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/scene.c +11 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/scene.h +12 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/svgw.c +30 -3
- vec_io-0.4.0/vec_io/network.py +147 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/options.py +11 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/paint.py +21 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdf/images.py +3 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/convert.py +1 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/resources.py +0 -2
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/raster/resources.py +6 -1
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/resample.py +1 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/scene.py +21 -1
- vec_io-0.4.0/vec_io/svg/basic_shapes.py +250 -0
- vec_io-0.4.0/vec_io/svg/css.py +1043 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/svg/filters.py +5 -4
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/svg/parse.py +248 -18
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/svg/render.py +1182 -155
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/svg/writer.py +14 -3
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/text/__init__.py +525 -71
- vec_io-0.4.0/vec_io/text/bidi.py +413 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/text/breaking.py +39 -16
- vec_io-0.4.0/vec_io/text/harfbuzz.py +222 -0
- vec_io-0.4.0/vec_io/text/shaping.py +402 -0
- vec_io-0.4.0/vec_io/units.py +596 -0
- vec_io-0.3.0/vec_io/fonts/opentype.py +0 -384
- vec_io-0.3.0/vec_io/svg/css.py +0 -366
- vec_io-0.3.0/vec_io/units.py +0 -184
- {vec_io-0.3.0 → vec_io-0.4.0}/EXAMPLES.md +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/LICENSE +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/examples/bubble_chart.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/examples/canvas_demo.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/examples/drawing_demo.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/examples/heatmap.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/examples/scatter_plot.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/examples/showcase.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/examples/text.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/examples/text_layout.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/pyproject.toml +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/abc.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/abc.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/big.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/big.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/binary.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/binary.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/bits2.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/bits2.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/dictwords.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/dictwords.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/empty.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/empty.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/four.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/four.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/handmade.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/handmade.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/ints.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/ints.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/mixed.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/mixed.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/multi.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/multi.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/one.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/one.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/random.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/random.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/text11.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/text11.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/text_q2.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/text_q2.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/three.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/three.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/w10.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/w10.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/w24.br +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/brotli/w24.out.z +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/clipping.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/css.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/empty.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/filters.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/fonts_face.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/gradients.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/images.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/markers.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/masks.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/opacity.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/paths.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/patterns.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/rasterized.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/shapes.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/strokes.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/structure.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/text-wrap.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/text_basic.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/text_layout.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/text_path.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/text_unicode.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/transforms.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/units.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/use_symbol.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/corpus/viewbox.svg +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/fonts/PioTest-Bold.ttf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/fonts/PioTest-Regular.ttf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/fuzz_pdfread.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/jbig2_encoder.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/jpx_fixtures.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/make_crypt_fixtures.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/maps.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfbuild.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/cmyk8.j2k +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/cmyk8.jp2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/gray12.j2k +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/gray16.jp2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/gray4-signed.j2k +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/graya16.jp2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/gs-r2.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/gs-r3.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/icc-gray8.jp2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r2.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r3.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r4-aes-nometa.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r4-aes.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r4-pdfdoc.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r4-rc4.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r5.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r6-empty.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r6-utf8.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/qpdf-r6.pdf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/rgb8.j2k +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/rgb8.jp2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/rgba8.jp2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/ycc420.jp2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/pdfread/ycc422-offset.jp2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/shapes.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_api.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_avif.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_canvas_features.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_ccitt.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_cells.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_cmap.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_codecs.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_compile.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_deflate.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_encodings.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_eps.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_flatten.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_font_sources.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_fonts_io.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_google_fonts.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_jpx_jbig2.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_marker_runs.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_native.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_native_emit.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_native_jpeg.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_native_limits.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_native_png.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_output.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_output_fixes.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_parsing.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_pdf_security.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_pdfa.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_pdfread.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_reader_fixes.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_resize.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_scene.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_shapes.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_simplify.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_svg_semantics.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_svg_writer.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_text.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_text_as_paths.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_textlayout.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_threads.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_type1.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_units.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_varfonts.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/test_woff2.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/testfont.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/varfonts/VarTest.otf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/varfonts/VarTest.ttf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/woff2/make.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/woff2/pair.woff2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/woff2/rich-null.woff2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/woff2/rich.ttf +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tests/woff2/rich.woff2 +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tools/build_native.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/tools/gen_api.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/arrays.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/cells.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/eps/__init__.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/eps/fonts.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/errors.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/flate.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/cff2.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/ctan.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/encodings.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/fontshare.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/fontshare_families.txt +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/fontsource.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/fontsource_families.txt +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/glyphlist.txt +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/google.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/google_families.txt +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/sfnt.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/type1.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/urw.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/variations.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/fonts/woff2.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/geometry.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/image/__init__.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/image/codecs.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/image/jbig2.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/image/jpx.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/image/jxl.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/items.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/lines.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/__init__.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/brotli.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/deflate.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/emit.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/filters.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/jpeg.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/png.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/alloc.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/brotli.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/brotli.h +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/brotli_dict.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/ccitt.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/crowding.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/crypt.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/data.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/deflate.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/emit.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/epsw.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/flat.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/image.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/items.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/jpeg.h +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/jpeg_dec.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/jpeg_enc.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/jpx.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/lex.h +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/math.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/matrix.h +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/mesh.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/path.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/png.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/quant.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/rt.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/scan.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/shade.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/shade.h +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/signatures.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/stroke.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/src/woff2.c +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/native/woff2.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdf/__init__.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdf/objects.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdf/pdfa.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdf/writer.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/__init__.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/ccitt.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/cffinfo.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/cmap.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/cmap_resources.txt +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/colors.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/content.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/errors.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/file.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/fonts.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/functions.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/images.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/meshes.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/parser.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/reader.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/security.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/shadings.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/pdfread/strings.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/py.typed +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/raster/__init__.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/raster/groups.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/shapes.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/simplify.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/svg/__init__.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/text/path.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/threads.py +0 -0
- {vec_io-0.3.0 → vec_io-0.4.0}/vec_io/trim.py +0 -0
|
@@ -34,8 +34,10 @@ Complete reference. Worked examples are in [EXAMPLES.md](EXAMPLES.md).
|
|
|
34
34
|
its own definition and is scaled into the page. `vec_io.units` parses CSS dimensions:
|
|
35
35
|
`split_length(value, units=None)` gives `(number, unit)` or raises `ValueError`;
|
|
36
36
|
`to_points(value, unit_scale, what="length")` gives points; `parse_angle(value,
|
|
37
|
-
strict=False)` gives degrees; `parse_length` is the lenient SVG form
|
|
38
|
-
`
|
|
37
|
+
strict=False)` gives degrees; `parse_length` is the lenient SVG form (math functions
|
|
38
|
+
evaluated); `evaluate_math(text, resolve=None)` gives a math function's `{unit: number}`
|
|
39
|
+
sum, `simplify_math(value)` replaces those that need no context by their results.
|
|
40
|
+
Tables: `PX_PER_UNIT`, `ANGLE_UNITS`, `RELATIVE_UNITS`.
|
|
39
41
|
* **Lengths.** A number is in the unit of its context, a string carries its unit (`"2in"`,
|
|
40
42
|
`"5mm"`, `"12pt"`; a paper size's side, `"a4"`, where a width or height is asked): on a
|
|
41
43
|
`Page`, the document's unit; in a `View` (so in `convert` and on the command line), CSS
|
|
@@ -67,12 +69,12 @@ Complete reference. Worked examples are in [EXAMPLES.md](EXAMPLES.md).
|
|
|
67
69
|
convert between sRGB (gamma-encoded, 0–1; clipped on the way back) and Oklab;
|
|
68
70
|
`oklch_to_oklab(L, C, H)` takes the hue in degrees; `lchuv_to_srgb(L, C, H)` converts CIE
|
|
69
71
|
LCh(uv) (D65, lightness 0–100) to sRGB as R's `hcl()` does.
|
|
70
|
-
* **Sources.** Files are given as paths; images and SVGs may also be bytes
|
|
71
|
-
Relative references resolve against `base_dir`; without it only `data:`
|
|
72
|
-
With it, any local file the process can read may be embedded
|
|
73
|
-
paths, `file:` URLs on this machine)
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
* **Sources.** Files are given as paths; images and SVGs may also be bytes, `data:` URIs or
|
|
73
|
+
http(s) URLs. Relative references resolve against `base_dir`; without it only `data:`
|
|
74
|
+
URIs and URLs are loaded. With it, any local file the process can read may be embedded
|
|
75
|
+
(`../` paths, absolute paths, `file:` URLs on this machine); `file:` URLs naming another
|
|
76
|
+
host are never read. URLs are fetched unless `network=False`; for untrusted SVG pass
|
|
77
|
+
`network=False` and `base_dir=None` ([Network and other files](#network-and-other-files)).
|
|
76
78
|
* **Types.** The package is typed (`py.typed`). Aliases: `vec_io.ColorLike` (a color argument),
|
|
77
79
|
`vec_io.Paint` (a color, gradient, pattern or `None`), `vec_io.Content` (text layout
|
|
78
80
|
content). Chainable methods return the object's own type.
|
|
@@ -88,9 +90,9 @@ Complete reference. Worked examples are in [EXAMPLES.md](EXAMPLES.md).
|
|
|
88
90
|
## 2. Converting SVG
|
|
89
91
|
|
|
90
92
|
```python
|
|
91
|
-
convert(source, output=None, *, format=None, base_dir=None, fonts=None, filters=
|
|
92
|
-
text_as_paths=False, pdf_a=None, default_dpi=None, page=None,
|
|
93
|
-
annotations=True, **options) -> bytes
|
|
93
|
+
convert(source, output=None, *, format=None, base_dir=None, fonts=None, filters=True,
|
|
94
|
+
network=True, text_as_paths=False, pdf_a=None, default_dpi=None, page=None,
|
|
95
|
+
password=None, annotations=True, **options) -> bytes
|
|
94
96
|
```
|
|
95
97
|
|
|
96
98
|
Converts an SVG (or PDF) document to PDF, EPS, SVG, PNG, JPEG, JPEG XL or AVIF, returns the
|
|
@@ -102,17 +104,22 @@ bytes and writes them to `output` (a path or a binary file object) when given. I
|
|
|
102
104
|
|---|---|
|
|
103
105
|
| `source` | SVG text or bytes (gzip-compressed SVGZ too), a path, a binary file object, or an `SVGDocument`. A string not starting with `<` is a path. |
|
|
104
106
|
| `format` | `"pdf"`, `"eps"`, `"svg"`, `"png"`, `"jpeg"`, `"jxl"` or `"avif"`; default: the extension of an `output` path (none: PDF; an unknown one: `OptionError`), else `"pdf"`. |
|
|
105
|
-
| `base_dir` | Directory of relative `<image
|
|
107
|
+
| `base_dir` | Directory of relative references (`<image>`, `<use>`, style sheets, `@font-face`); default: a source path's directory; `None`: none read ([Network and other files](#network-and-other-files)). |
|
|
108
|
+
| `network` | Fetch the http and https URLs the SVG refers to, and download fonts (default `True`; [Network and other files](#network-and-other-files)). |
|
|
106
109
|
| `fonts` | A `Fonts` ([Fonts](#16-fonts)). |
|
|
107
|
-
| `filters` | Apply SVG filters (rasterizes filtered elements; [Filters](#14-filters)). |
|
|
110
|
+
| `filters` | Apply SVG filters (default `True`; rasterizes filtered elements; [Filters](#14-filters)). |
|
|
108
111
|
| `text_as_paths` | Text drawn as glyph outlines, no font written ([Fonts](#16-fonts)). |
|
|
112
|
+
| `media`, `color_scheme` | What `@media` and `<style media>` are evaluated for: `"print"` (default) or `"screen"`, and `prefers-color-scheme` `"light"` (default) or `"dark"`. |
|
|
109
113
|
| `pdf_a` | PDF: `"2b"`, `"2u"` or `"3b"` ([PDF/A](#pdfa)). |
|
|
110
|
-
| `default_dpi` | The document's `default_dpi`: the resolution of image output without `dpi` (default
|
|
114
|
+
| `default_dpi` | The document's `default_dpi`: the resolution of image output without `dpi` (default `"2x"`: 192 dpi, two pixels per CSS pixel). |
|
|
111
115
|
| `page`, `password`, `annotations` | PDF input ([Reading PDF](#reading-pdf)). |
|
|
112
116
|
| `options` | The output's options, as `Document.write` takes them: `compression`, `simplify`, `images`, `flatten`, `font_hinting`, `dpi`, `view`, `background`, `png`, `jpeg`, `jxl`, `avif` ([18.1](#181-options)). Numbers in a `View` are CSS pixels. |
|
|
113
117
|
|
|
114
|
-
`SVGDocument(source
|
|
115
|
-
|
|
118
|
+
`SVGDocument(source, *, base_dir=None, network=True, media="print", color_scheme="light")`
|
|
119
|
+
parses SVG once (`vec_io.svg.parse`),
|
|
120
|
+
with the style sheets it loads (`@import`, `<?xml-stylesheet?>`, relative to `base_dir`);
|
|
121
|
+
`SVGParseError` reports input that is not usable SVG, `OptionError` an option that cannot be
|
|
122
|
+
used ([Errors](#19-errors)).
|
|
116
123
|
|
|
117
124
|
```python
|
|
118
125
|
vec_io.convert("drawing.svg", "drawing.pdf")
|
|
@@ -121,6 +128,28 @@ vec_io.convert("figure.svg", "figure.pdf", view={"trim": True, "margin": "2mm"})
|
|
|
121
128
|
vec_io.convert("figure.svg", "figure.pdf", view=vec_io.View(size="us", margin="1in"))
|
|
122
129
|
```
|
|
123
130
|
|
|
131
|
+
### Network and other files
|
|
132
|
+
|
|
133
|
+
What an SVG refers to is loaded from `data:` URIs, local files (relative to `base_dir`) and,
|
|
134
|
+
with `network=True` (the default), http and https URLs: `<image>`, `<use>` of an element of
|
|
135
|
+
another document (`other.svg#id`: the document is loaded and the element drawn with its own
|
|
136
|
+
references and style sheets), `@import` style sheets, `<?xml-stylesheet?>`, `@font-face`
|
|
137
|
+
`src: url(…)`, and font downloads ([Font downloads](#font-downloads)). Each file or URL is
|
|
138
|
+
loaded once per document; references between documents may form cycles. A document from a
|
|
139
|
+
URL resolves its relative references on its server and never reads local files.
|
|
140
|
+
|
|
141
|
+
`vec_io.network` sets the limits: 64 MB per resource (`MAX_RESOURCE`), 256 MB per document
|
|
142
|
+
(`MAX_DOCUMENT`), 200 URLs per document (`MAX_RESOURCES`), 30 s per request (`TIMEOUT`);
|
|
143
|
+
redirects stay on http and https (never from https to http); a generic user agent. A URL
|
|
144
|
+
that cannot be fetched gives a `NetworkWarning` and is drawn as missing. `network=False`
|
|
145
|
+
fetches nothing and turns font downloads off, whatever `Fonts(downloads=…)` says (a
|
|
146
|
+
`Fonts(db=…)` keeps its own setting).
|
|
147
|
+
|
|
148
|
+
**Security.** An untrusted SVG can make the process fetch any URL, including ones on the
|
|
149
|
+
local network, and, with a `base_dir`, read any local file the process can read into the
|
|
150
|
+
output. For untrusted input pass `network=False` and `base_dir=None` (CLI: `--no-network`,
|
|
151
|
+
and a document read from stdin).
|
|
152
|
+
|
|
124
153
|
### Reading PDF
|
|
125
154
|
|
|
126
155
|
```python
|
|
@@ -147,7 +176,7 @@ above. `Canvas.draw_pdf` places a page ([5.5](#55-images-and-svg)).
|
|
|
147
176
|
|---|---|
|
|
148
177
|
| File | cross-reference tables and streams, incremental updates, object streams; a damaged table rebuilt by scanning the file; encryption (standard handler, RC4 and AES, revisions 2–6) |
|
|
149
178
|
| Filters | Flate, LZW (PNG and TIFF predictors), ASCII85, ASCIIHex, RunLength, CCITT fax; DCT, JPEG 2000, JBIG2 and JPEG XL images kept encoded for PDF output |
|
|
150
|
-
| Content | paths, clips, device colours, graphics states (alpha, soft masks, blend modes
|
|
179
|
+
| Content | paths, clips, device colours, graphics states (alpha, soft masks, blend modes; image output composites every group as isolated), forms and transparency groups, images (masks, soft masks, colour keys, `Decode`, 1–16 bits), tiling patterns, shadings 1–7, optional content (the default configuration), Type 3 glyphs |
|
|
151
180
|
| Colour | Gray, RGB, CMYK; ICC by component count; CalGray, CalRGB and Lab to sRGB; Indexed; Separation (a spot colour when its alternate is CMYK) and DeviceN through their tint transforms; functions 0, 2, 3, 4 |
|
|
152
181
|
| Fonts | TrueType, Type 1, Type 1C, OpenType and Type 3 simple fonts; CID fonts (CFF, TrueType, `CIDToGIDMap`), embedded and predefined CMaps; glyphs placed by the PDF's widths; fonts that are not embedded drawn with an installed or downloaded family of their name (the standard 14 with URW's metric-compatible families) |
|
|
153
182
|
|
|
@@ -190,8 +219,10 @@ vec_io --download-font FAMILY …
|
|
|
190
219
|
| `--font-downloads MODE` | Downloads of families that are not installed: `on` (default, or `VEC_IO_FONT_DOWNLOADS`), `off`, or `cache` (downloaded families only) ([Font downloads](#font-downloads)). |
|
|
191
220
|
| `--no-font-downloads` | Same as `--font-downloads off`. |
|
|
192
221
|
| `--download-font FAMILY` | Download every style of a family into the cache from the first source that has it and print its files, without converting (repeatable; no `INPUT`). Exit status 1 when one fails. |
|
|
193
|
-
| `--filters` |
|
|
222
|
+
| `--no-filters` | Do not apply SVG filters (applied by default). |
|
|
223
|
+
| `--no-network` | Fetch no URL and download no font ([Network and other files](#network-and-other-files)). |
|
|
194
224
|
| `--text-as-paths` | Text drawn as glyph outlines, no font written. |
|
|
225
|
+
| `--media MEDIA`, `--color-scheme SCHEME` | What `@media` rules are evaluated for: `print` (default) or `screen`; `light` (default) or `dark`. |
|
|
195
226
|
| `--quality N` | PDF: store rasterized content as JPEG (JPEG XL with `--jxl`) of quality N (1–100); images: the quality of the image (JPEG default 90, JPEG XL and AVIF default lossless, PNG a lossy palette). |
|
|
196
227
|
| `--jxl` | Write the PDF's images as JPEG XL ([JPEG XL](#jpeg-xl)). |
|
|
197
228
|
| `--pdf-a LEVEL` | Write PDF/A: `2b`, `2u` or `3b`. |
|
|
@@ -206,7 +237,7 @@ vec_io --download-font FAMILY …
|
|
|
206
237
|
| `--align A[,V]` | With both sides and `fit`: where the content sits in the room left: `start`, `center` (default) or `end`; two values: horizontal, vertical (start: left, top). |
|
|
207
238
|
| `--trim` | Cut to the content. Blank is transparent or white. |
|
|
208
239
|
| `--margin M` | Blank space on each side (CSS pixels or a length, `2mm`): around the content with `--trim`, inside the size given, else added around the page. |
|
|
209
|
-
| `--dpi N` | The output's resolution: images rendered at it (default
|
|
240
|
+
| `--dpi N` | The output's resolution, in dpi or `Nx` (N × 96): images rendered at it (default `2x`, 192 dpi); PDF, EPS and SVG images resampled to it (default: kept as they are). |
|
|
210
241
|
| `--dpi-mode MODE` | PDF, EPS, SVG with `--dpi`: `down` (default: images finer than `--dpi` resampled down to it) or `match` (every image resampled to it). |
|
|
211
242
|
| `--dpi-threshold F` | PDF, EPS, SVG with `--dpi`: images within a factor F of `--dpi` kept (default 1.5; at least 1). |
|
|
212
243
|
| `--dpi-average MODE` | PDF, EPS, SVG with `--dpi`: `srgb` (default: the stored values averaged) or `linear` (light averaged) when images are shrunk. |
|
|
@@ -234,9 +265,9 @@ The command line builds the option objects `convert` takes (`Fonts`, `View`, `Fl
|
|
|
234
265
|
|
|
235
266
|
```python
|
|
236
267
|
Document(unit="pt", *, title=None, author=None, subject=None, keywords=None, creator=None,
|
|
237
|
-
fonts=None, base_dir=None, filters=
|
|
238
|
-
icc_profile=None, pdf_a=None, creation_date=None,
|
|
239
|
-
default_dpi=
|
|
268
|
+
fonts=None, base_dir=None, filters=True, network=True, color_mode="rgb",
|
|
269
|
+
ink_limit=None, icc_profile=None, pdf_a=None, creation_date=None,
|
|
270
|
+
text_as_paths=False, default_dpi="2x")
|
|
240
271
|
```
|
|
241
272
|
|
|
242
273
|
A document records what is drawn on its pages: commands, the images and fonts as they were
|
|
@@ -251,14 +282,18 @@ The constructor takes document-level choices. `unit` is the document's unit
|
|
|
251
282
|
([Conventions](#1-conventions)). The metadata arguments fill the PDF document information.
|
|
252
283
|
`base_dir` resolves relative paths given to `draw_image`, `draw_svg`, `add_font`, `attach`
|
|
253
284
|
and `icc_profile` (default: the working directory), and the references of SVGs placed from
|
|
254
|
-
text or bytes. `filters` applies to SVGs placed with `draw_svg`. `
|
|
285
|
+
text or bytes. `filters` (default on) applies to SVGs placed with `draw_svg`. `network`
|
|
286
|
+
fetches the URLs they refer to and downloads fonts (default on; [Network and other
|
|
287
|
+
files](#network-and-other-files)). `fonts` (a `Fonts`, or a
|
|
255
288
|
dict of its fields) says where fonts come from; `Fonts(db=…)` shares a `FontDB` between
|
|
256
289
|
documents ([Fonts](#16-fonts)). `text_as_paths=True` draws text as the outlines of its
|
|
257
290
|
glyphs ([Fonts](#16-fonts)). `creation_date` (a `datetime`; naive means local time) is
|
|
258
291
|
written as the creation and modification date; PDF/A files default to the current time,
|
|
259
292
|
other files have no date unless one is given. `default_dpi` is the resolution of image
|
|
260
293
|
output when none is given (`Page.render`, `write` to an image format); PDF, EPS and SVG
|
|
261
|
-
output never use it.
|
|
294
|
+
output never use it. A resolution (`dpi`, `default_dpi`, `ImagePolicy(dpi=…)`,
|
|
295
|
+
`Flatten(dpi=…)`) is a number of dots per inch or `"Nx"`, N image pixels per CSS pixel
|
|
296
|
+
(N × 96: `"2x"` is 192).
|
|
262
297
|
|
|
263
298
|
| Print parameter | Meaning |
|
|
264
299
|
|---|---|
|
|
@@ -286,7 +321,7 @@ mode: only its luminosity matters, and viewers disagree on the luminosity of ink
|
|
|
286
321
|
| `points_per_unit` | Points per document unit: `1` for `pt`, `0.75` for `px` (read-only). |
|
|
287
322
|
|
|
288
323
|
The constructor's `unit`, `title`, `author`, `subject`, `keywords`, `creator`, `base_dir`,
|
|
289
|
-
`filters`, `color_mode`, `pdf_a`, `creation_date`, `text_as_paths` and `default_dpi` are
|
|
324
|
+
`filters`, `network`, `color_mode`, `pdf_a`, `creation_date`, `text_as_paths` and `default_dpi` are
|
|
290
325
|
attributes of the same names. A document without pages gets an empty A4 page when written. A PDF of some of the pages
|
|
291
326
|
keeps the bookmarks and links of those pages (a bookmark of another page is left out, its
|
|
292
327
|
children kept).
|
|
@@ -393,7 +428,7 @@ or pattern closed inside one opened in it, raises `RuntimeError`.
|
|
|
393
428
|
| `line_dash` | `None` | sequence of lengths |
|
|
394
429
|
| `line_dash_offset` | `0.0` | |
|
|
395
430
|
| `opacity` | `1.0` | multiplies every paint (0–1) |
|
|
396
|
-
| `font_family` | `"
|
|
431
|
+
| `font_family` | `"system-ui"` | CSS family list (`system-ui`: the platform's interface font, [Fonts](#16-fonts)) |
|
|
397
432
|
| `font_size` | `12.0` | the document's unit |
|
|
398
433
|
| `font_weight` | `"normal"` | `normal`, `bold`, `1`–`1000` |
|
|
399
434
|
| `font_style` | `"normal"` | `normal`, `italic`, `oblique`, `oblique 10deg` |
|
|
@@ -402,7 +437,10 @@ or pattern closed inside one opened in it, raises `RuntimeError`.
|
|
|
402
437
|
| `font_optical_sizing` | `"auto"` | `auto` (the `opsz` axis follows the font size) or `none` |
|
|
403
438
|
| `font_kerning` | `"auto"` | `auto`/`normal`: pair kerning; `none` |
|
|
404
439
|
| `font_embed` | `True` | `False`: a standard 14 font, not embedded, when the family names one ([Fonts](#16-fonts)) |
|
|
405
|
-
| `
|
|
440
|
+
| `font_variant` | `"normal"` | CSS `font-variant` keywords: `small-caps`, `oldstyle-nums`, `tabular-nums`, `common-ligatures`, … ([shaping](#shaping)) |
|
|
441
|
+
| `font_feature_settings` | `""` | `'"tnum" 1, "ss01"'` or `{"tnum": 1}` |
|
|
442
|
+
| `direction` | `"ltr"` | `ltr`, `rtl`, `auto` (from the first strong character): the paragraph direction of the bidi algorithm |
|
|
443
|
+
| `text_align` | `"start"` | `start`/`left`, `center`/`middle`, `end`/`right`; `start` and `end` follow `direction` |
|
|
406
444
|
| `letter_spacing` | `0.0` | |
|
|
407
445
|
| `word_spacing` | `0.0` | |
|
|
408
446
|
| `fill_rule` | `"nonzero"` | `nonzero`, `evenodd` |
|
|
@@ -484,7 +522,9 @@ page.draw_path("M10 10 L80 20", fill=None, stroke="black", markers=(None, None,
|
|
|
484
522
|
`text` is a string, rich content (a list of strings and `Span` objects,
|
|
485
523
|
[Text layout](#6-text-layout)) or a `GlyphRun`, drawn on one line (newlines become spaces).
|
|
486
524
|
Spans without a color use the fill. One line is shaped as a paragraph is: fonts chosen per
|
|
487
|
-
character, pairs kerned (`font_kerning`),
|
|
525
|
+
character, pairs kerned (`font_kerning`), OpenType features and complex scripts
|
|
526
|
+
([shaping](#shaping)), right-to-left runs reordered (`direction`), words shaped one by one,
|
|
527
|
+
runs of spaces as one space, soft hyphens and U+200B not drawn, so `measure_text(s)` is
|
|
488
528
|
the width of `s` laid out on one line. Fonts are embedded as needed ([Fonts](#16-fonts)).
|
|
489
529
|
|
|
490
530
|
Text on a path is shaped the same way and starts at `offset` along the path (a length, or
|
|
@@ -499,8 +539,8 @@ path; underlines, strikethroughs and links of spans are not drawn.
|
|
|
499
539
|
|
|
500
540
|
| Method | |
|
|
501
541
|
|---|---|
|
|
502
|
-
| `draw_image(source, x, y, width=None, height=None, preserve_aspect_ratio="xMidYMid meet", opacity=1.0, smooth=None)` |
|
|
503
|
-
| `draw_svg(svg, x=0, y=0, width=None, height=None, base_dir=None, clip=True)` | Place SVG text, bytes, a path or an `SVGDocument`. Default size: its CSS pixel size. `clip` clips to its viewport. |
|
|
542
|
+
| `draw_image(source, x, y, width=None, height=None, preserve_aspect_ratio="xMidYMid meet", opacity=1.0, smooth=None)` | An image of the formats of SVG's `<image>` ([SVG support](#15-svg-support)) from a path, bytes, a `data:` URI or (with `network`) an http(s) URL. Without a size, one pixel per unit; with one dimension the aspect ratio is kept. `smooth=False` keeps pixels sharp when scaled. Returns `False` if the image cannot be loaded. |
|
|
543
|
+
| `draw_svg(svg, x=0, y=0, width=None, height=None, base_dir=None, clip=True, media="print", color_scheme="light")` | Place SVG text, bytes, a path or an `SVGDocument`. Default size: its CSS pixel size. `clip` clips to its viewport. `media`, `color_scheme`: as for `convert`. |
|
|
504
544
|
| `draw_pdf(source, page=0, x=0, y=0, width=None, height=None, box="crop", annotations=True, password=None)` | Place a page of a PDF (a path, bytes or a binary file) as a form, clipped to its `box` (`crop`, `media`, `bleed`, `trim`, `art`). Default size: the box's, in points (rotated); one dimension keeps the aspect ratio. A page placed again in the document is the same form ([Reading PDF](#reading-pdf)). |
|
|
505
545
|
|
|
506
546
|
A `vec_io.draw` drawing draws itself: `drawing.draw(page, x, y, width=None, height=None)`
|
|
@@ -521,7 +561,7 @@ Context managers; everything drawn in the body is affected.
|
|
|
521
561
|
|
|
522
562
|
| Method | |
|
|
523
563
|
|---|---|
|
|
524
|
-
| `group(opacity=1.0, rasterize=False, dpi=None, quality=None, simplify=None, filter=None)` | Transparency group. `filter`: a `Filter` run on the body's pixels at `dpi` ([Filters](#14-filters)). `rasterize=True` makes the PDF hold the body as an image at `dpi` (default 300; [Rasterization](#12-rasterization)). `quality`: 1–100 for JPEG (JPEG XL with `ImagePolicy(jxl=True)`), `False` for lossless, `None` for the output's `ImagePolicy`. `simplify`: see [Simplification](#13-simplification); with it and no opacity or `rasterize`, the body is drawn directly, not as a group. Drawing attributes are restored afterwards; if the body raises, nothing is drawn. |
|
|
564
|
+
| `group(opacity=1.0, rasterize=False, dpi=None, quality=None, simplify=None, filter=None, blend="normal", isolate=False)` | Transparency group. `blend`: a CSS `mix-blend-mode` name (`normal`, `multiply`, `screen`, `overlay`, `darken`, `lighten`, `color-dodge`, `color-burn`, `hard-light`, `soft-light`, `difference`, `exclusion`, `hue`, `saturation`, `color`, `luminosity`; `vec_io.paint.BLEND_MODES`) blending the group with what is under it (PDF `/BM`, SVG `mix-blend-mode`, EPS an image); `isolate=True`: an isolated group (blend modes inside it blend with its content only); a group whose content sets a blend mode is isolated. `filter`: a `Filter` run on the body's pixels at `dpi` ([Filters](#14-filters)). `rasterize=True` makes the PDF hold the body as an image at `dpi` (default 300; [Rasterization](#12-rasterization)). `quality`: 1–100 for JPEG (JPEG XL with `ImagePolicy(jxl=True)`), `False` for lossless, `None` for the output's `ImagePolicy`. `simplify`: see [Simplification](#13-simplification); with it and no opacity or `rasterize`, the body is drawn directly, not as a group. Drawing attributes are restored afterwards; if the body raises, nothing is drawn. |
|
|
525
565
|
| `rasterized(dpi=None, opacity=1.0, post_process=None, region=None, quality=None, simplify=None)` | Lower-level rasterization. `post_process(surface)` edits the pixels (premultiplied float32 RGBA in `surface.pixels`); the body is then rasterized while it is drawn, and both outputs show that image. `region` `(x0, y0, x1, y1)` fixes the rasterized area. |
|
|
526
566
|
| `clip(path, rule=None)` | The body clipped to `path` ([5.3](#53-paths-and-painting)). |
|
|
527
567
|
| `mask(m)` | The body seen through `Mask` `m` ([7](#7-paints-and-recorded-content)): white shows it, black hides it. Drawing attributes are restored afterwards. |
|
|
@@ -551,7 +591,7 @@ page.render(dpi=None, simplify=None, background=None) -> Image
|
|
|
551
591
|
|
|
552
592
|
Renders the page from what it records: images from their samples (nothing is encoded to be
|
|
553
593
|
decoded again), rasterized groups as vectors, at `dpi` (default the document's
|
|
554
|
-
`default_dpi`,
|
|
594
|
+
`default_dpi`, `"2x"`: two pixels per CSS pixel).
|
|
555
595
|
`background` is a color put under the page, or `None` (transparent). `simplify` decimates
|
|
556
596
|
lines for this resolution; nothing is left out, since rasterizing hidden content costs less
|
|
557
597
|
than finding it ([Simplification](#13-simplification)). `dpi` must be positive.
|
|
@@ -632,7 +672,8 @@ The text style comes from the canvas state: `font`, `fill_style` (or `text_box`'
|
|
|
632
672
|
```python
|
|
633
673
|
Span(text, font_family=None, font_size=None, font_weight=None, font_style=None,
|
|
634
674
|
color=None, url=None, letter_spacing=None, word_spacing=None, underline=False,
|
|
635
|
-
baseline_shift=None, font_scale=None, strikethrough=False
|
|
675
|
+
baseline_shift=None, font_scale=None, strikethrough=False, font_variant=None,
|
|
676
|
+
font_features=None)
|
|
636
677
|
```
|
|
637
678
|
|
|
638
679
|
A run of text with its own style; `None` inherits the canvas state. `url` makes the run a
|
|
@@ -640,7 +681,8 @@ link; `underline` draws a line under it; `strikethrough` draws one through it at
|
|
|
640
681
|
strikeout position and thickness (OS/2 `yStrikeoutPosition`, `yStrikeoutSize`; without them
|
|
641
682
|
0.28 em up, as thick as the underline), as SVG's `line-through` is drawn. `font_scale`
|
|
642
683
|
multiplies the size. `baseline_shift` raises the run: `"super"` (0.33 em of the canvas font
|
|
643
|
-
size), `"sub"` (−0.2 em) or a number of em (positive up).
|
|
684
|
+
size), `"sub"` (−0.2 em) or a number of em (positive up). `font_variant` and
|
|
685
|
+
`font_features` add to the font's. Exponents: `["10", Span("5", baseline_shift="super", font_scale=0.7)]`.
|
|
644
686
|
|
|
645
687
|
| `TextLayout` member | |
|
|
646
688
|
|---|---|
|
|
@@ -651,8 +693,10 @@ size), `"sub"` (−0.2 em) or a number of em (positive up). Exponents: `["10", S
|
|
|
651
693
|
| `line_text(k)` | Text of line `k`. |
|
|
652
694
|
|
|
653
695
|
Kerning and justification are written as `TJ` adjustments, so the text stays selectable and
|
|
654
|
-
searchable.
|
|
655
|
-
|
|
696
|
+
searchable. Paragraphs get their bidi levels from the canvas `direction` (each paragraph
|
|
697
|
+
from its first strong character with `auto`); lines are reordered once broken, and
|
|
698
|
+
`start`/`end` alignment follow the paragraph's direction. Speed: 1,800 words in about
|
|
699
|
+
0.02 s (greedy) or 0.035 s (optimal), fonts already loaded. Not supported: hyphenation
|
|
656
700
|
dictionaries.
|
|
657
701
|
|
|
658
702
|
### 6.1 Shaping without a page: `vec_io.text`
|
|
@@ -674,11 +718,12 @@ para.draw(page, x, y, fill="black")
|
|
|
674
718
|
|
|
675
719
|
| Name | |
|
|
676
720
|
|---|---|
|
|
677
|
-
| `Font(family="
|
|
678
|
-
| `shape(content, font, db=None, *, kerning=True, ligatures=False, letter_spacing=0, word_spacing=0)` | `GlyphRun` of a string or rich content on one line. |
|
|
721
|
+
| `Font(family="system-ui", size=12, weight=400, style="normal", stretch="normal", variations=None, optical_sizing="auto", embed=True, unit=1, variant=None, features=None, synthesis="weight style")` | A font description: CSS values as for the canvas attributes; `embed=False` uses a standard 14 font when the family names one; `unit`: CSS px per unit of `size` (a number or a unit name, for `opsz`); `variant`: `font-variant` keywords; `features`: `font-feature-settings`; `synthesis`: `font-synthesis` (`"none"`: no synthetic bold or italic). Immutable and hashable; `replace(**changes)`. |
|
|
722
|
+
| `shape(content, font, db=None, *, kerning=True, ligatures=False, letter_spacing=0, word_spacing=0, direction="ltr")` | `GlyphRun` of a string or rich content on one line, glyphs in visual order (`direction`: `ltr`, `rtl`, `auto`). |
|
|
679
723
|
| `measure(content, font, db=None, **options)` | `Extent(width, ascent, descent)` of that run. |
|
|
680
|
-
| `layout(content, font, width, height=None, db=None, *, align, line_height, overflow, breaking, kerning, ligatures, paragraph_spacing, first_indent, letter_spacing, word_spacing)` | `Paragraphs`: the [layout](#6-text-layout) options; `draw(canvas, x, y, fill=None)`, `width`, `height`, `lines`, `baselines`, `overflow`, `remainder`, `line_text(k)`, `line_cells()` (placed `Line`s). |
|
|
681
|
-
| `GlyphRun` | `text`, `width`, `ascent`, `descent`, `extent`; `segments` (`Segment`: one face and style, with `gids`, `texts`, `chars`, `advances`, `adjusts`); `glyphs` (`Glyph`: `face`, `gid`, `advance`, `adjust`, `text`, `char`, `style`, `synth`). |
|
|
724
|
+
| `layout(content, font, width, height=None, db=None, *, align, line_height, overflow, breaking, kerning, ligatures, paragraph_spacing, first_indent, letter_spacing, word_spacing, direction="ltr")` | `Paragraphs`: the [layout](#6-text-layout) options; `draw(canvas, x, y, fill=None)`, `width`, `height`, `lines`, `baselines`, `overflow`, `remainder`, `line_text(k)`, `line_cells()` (placed `Line`s). |
|
|
725
|
+
| `GlyphRun` | `text`, `width`, `ascent`, `descent`, `extent`; `segments` (`Segment`: one face and style, with `gids`, `texts`, `chars`, `advances`, `adjusts`, `offsets`); `glyphs` (`Glyph`: `face`, `gid`, `advance`, `adjust`, `text`, `char`, `style`, `synth`, `dx`/`dy` (drawn off its pen position: marks, GPOS placements), `level` (bidi)). |
|
|
726
|
+
| `baseline_position(face, size, name)` | Height of a CSS baseline (`middle`, `central`, `hanging`, `mathematical`, `ideographic`, `text-before-edge`, `text-after-edge`, `text-top`, `text-bottom`) above the alphabetic one: the `BASE` table, else as browsers derive it (half the x-height, the middle of ascent and descent, 0.8 and 0.5 of the ascent, the descent, the ascent). |
|
|
682
727
|
| `default_db()` | The process-wide `FontDB` (installed fonts, `VEC_IO_FONT_DIRS`, and font downloads as `VEC_IO_FONT_DOWNLOADS` says). |
|
|
683
728
|
| `NoFontError` | `ValueError`: no outline font at all for the text. |
|
|
684
729
|
|
|
@@ -897,7 +942,8 @@ Element keywords (not inherited): `transform` (a `Matrix` or SVG transform text)
|
|
|
897
942
|
(the element as one transparency group, folded into the paint when it has one), `clip_path`
|
|
898
943
|
(a shape element, `ClipPath`, `Path` or path data), `mask` (an element or `Mask` drawing the
|
|
899
944
|
luminance), `filter` (a `Filter`, run at `rasterize`'s dpi or 300), `rasterize` (`True`
|
|
900
|
-
or a dpi), `quality` (of a rasterized element), `simplify
|
|
945
|
+
or a dpi), `quality` (of a rasterized element), `simplify`, `mix_blend_mode` (a CSS blend
|
|
946
|
+
mode: the element blended as one group), `isolation` (`"isolate"`). `Path`, `Line`, `Polyline` and
|
|
901
947
|
`Polygon` also take `marker_start`, `marker_mid`, `marker_end` and `markers` (all three):
|
|
902
948
|
`Marker` elements. Other keywords raise `TypeError`. `set(**keywords)` changes them (`None` inherits again,
|
|
903
949
|
except for `fill` and `stroke`, where it paints nothing).
|
|
@@ -933,7 +979,7 @@ centered).
|
|
|
933
979
|
| `Text` | `Text(text, font_size, x=0, y=0, line_height=1.2, path=None, offset=0, side="left", method="align", …)`: a string (`\n` stacks lines `line_height` em apart) or rich content (strings, `TSpan`, `Span`) on one line; with `path` (a shape element, `Path` or path data), along it ([5.4](#54-text)) |
|
|
934
980
|
| `TSpan` | `TSpan(text, font_family=…, font_size=…, font_weight=…, font_style=…, fill=…, underline=…, strikethrough=…, baseline_shift=…, url=…)`: a styled run (a `Span`) |
|
|
935
981
|
| `TextBox` | `TextBox(content, x, y, width, height=None, …)`: wrapped text, box top-left at `(x, y)`; the [layout](#6-text-layout) options as keywords |
|
|
936
|
-
| `Image` | `Image(x, y, width, height, path=None, data=None, preserve_aspect_ratio="xMidYMid meet", smooth=None, …)`:
|
|
982
|
+
| `Image` | `Image(x, y, width, height, path=None, data=None, preserve_aspect_ratio="xMidYMid meet", smooth=None, …)`: an image of the formats of `draw_image` |
|
|
937
983
|
| `SVG` | `SVG(source, x=0, y=0, width=None, height=None, base_dir=None, …)`: an SVG document drawn in the box, with everything SVG has, CSS style sheets included (filters when enabled) |
|
|
938
984
|
| `Use` | `Use(element, x=0, y=0, …)`: the element drawn again, moved; its keywords apply where the element sets none |
|
|
939
985
|
| `Markers`, `Lines`, `Segments`, `Area`, `Rects`, `Polygons` | the bulk calls ([8](#8-markers), [9](#9-lines-segments-and-areas)); `fill`, `stroke`, `stroke_width` and `opacity` may be columns |
|
|
@@ -1302,7 +1348,7 @@ SVG's Filter Effects 1, with the same semantics:
|
|
|
1302
1348
|
| `ConvolveMatrix` | `kernel`, `order=3`, `divisor`, `bias`, `target_x`, `target_y`, `edge_mode`, `preserve_alpha` |
|
|
1303
1349
|
| `Turbulence` | `base_frequency`, `octaves`, `seed`, `type` (`turbulence`, `fractalNoise`), `stitch`, `transform` |
|
|
1304
1350
|
| `DiffuseLighting`, `SpecularLighting` | `light` (`DistantLight(azimuth, elevation)`, `PointLight(x, y, z)`, `SpotLight(x, y, z, points_at, specular_exponent, limiting_cone_angle)`), `surface_scale`, `constant`, (`exponent`), `color` |
|
|
1305
|
-
| `Image` | `source` (
|
|
1351
|
+
| `Image` | `source` (image bytes or a path, the formats of `draw_image`), `preserve_aspect_ratio`, `smooth` |
|
|
1306
1352
|
| `DisplacementMap` | `scale`, `x_channel`, `y_channel` (`R`, `G`, `B`, `A`), `input2` |
|
|
1307
1353
|
|
|
1308
1354
|
Every primitive also takes `input` (`"SourceGraphic"`, `"SourceAlpha"` or an earlier
|
|
@@ -1315,12 +1361,12 @@ The pixel work is C (`src/filters.c`).
|
|
|
1315
1361
|
SVG `filter` properties are read into the same `Filter` (`primitiveUnits`, `filterUnits`,
|
|
1316
1362
|
`color-interpolation-filters`, `flood-color`, `lighting-color`; `feImage` references to
|
|
1317
1363
|
elements are transparent; `kernelUnitLength` is ignored) and drawn through
|
|
1318
|
-
`group(filter=…)`. In SVG they are
|
|
1364
|
+
`group(filter=…)`. In SVG they are on by default, as in browsers:
|
|
1319
1365
|
|
|
1320
|
-
| Scope |
|
|
1366
|
+
| Scope | Disable |
|
|
1321
1367
|
|---|---|
|
|
1322
|
-
| Conversion | `convert(…, filters=
|
|
1323
|
-
| Document | `Document(filters=
|
|
1368
|
+
| Conversion | `convert(…, filters=False)`; CLI `--no-filters` |
|
|
1369
|
+
| Document | `Document(filters=False)` (SVGs placed with `draw_svg` and `draw.SVG`) |
|
|
1324
1370
|
| Element and descendants | SVG `data-filters="true"` / `"false"`. Overrides the scope above. |
|
|
1325
1371
|
|
|
1326
1372
|
## 15. SVG support
|
|
@@ -1328,22 +1374,23 @@ elements are transparent; `kernelUnitLength` is ignored) and drawn through
|
|
|
1328
1374
|
| Area | Support |
|
|
1329
1375
|
|---|---|
|
|
1330
1376
|
| Shapes | `rect` (rounded), `circle`, `ellipse`, `line`, `polyline`, `polygon`, `path` (all commands, arcs) |
|
|
1331
|
-
| Structure | `g`, nested `svg`, `use`, `symbol`, `defs`, `a`, `switch`, `viewBox`, `preserveAspectRatio`, `transform
|
|
1332
|
-
| Styling | presentation attributes, `style`, `<style
|
|
1333
|
-
|
|
|
1334
|
-
|
|
|
1377
|
+
| Structure | `g`, nested `svg`, `use`, `symbol`, `defs`, `a`, `switch`, `viewBox`, `preserveAspectRatio`, `transform` (attribute, or the CSS property with units; the `translate`, `rotate` and `scale` properties; `transform-origin` and `transform-box`, default `view-box` and `0 0` as in browsers; 3-D functions projected); a zero-size `viewBox` disables rendering; at most 300,000 elements are instantiated through `<use>` per document (further instances are skipped); `<use>` of an element of another file or URL (`other.svg#a`, [Network and other files](#network-and-other-files)); other references (`url()`, `href` of paint servers) are within the document |
|
|
1378
|
+
| Styling | presentation attributes, `style`, `<style>`, `font` and `marker` shorthands, inheritance, `inherit`, `currentColor`, `!important`; geometry properties (`cx`, `cy`, `r`, `rx`, `ry`, `x`, `y`, `width`, `height` of `rect`, `circle`, `ellipse`, `image`, `use`, nested `svg`, and `d` of `path` as `path("…")` or `none`) set by their attributes or by CSS (a rule beats the attribute; not inherited; unitless numbers taken, as Chrome) |
|
|
1379
|
+
| Selectors | type, class, id, attribute (`=`, `~=`, `\|=`, `^=`, `$=`, `*=`, ` i`/` s` flags); descendant, child, sibling combinators; `:root`, `:empty`, `:first-child`, `:last-child`, `:only-child`, `:nth-child()`/`:nth-last-child()` (with `of S`), `:first-of-type`, `:last-of-type`, `:only-of-type`, `:nth-of-type()`/`:nth-last-of-type()`, `:not()`, `:is()`, `:where()` (no specificity), `:has()`, `:lang()`, `:link`; user-action pseudo-classes (`:hover`, `:focus`, …) and pseudo-elements never match; an invalid selector drops its rule |
|
|
1380
|
+
| CSS | nesting (`&`, nested rules and `@media`); custom properties (`--name`, inherited, also through `<use>`) and `var(--name, fallback)` in any property or attribute (cycles invalid); `calc()`, `min()`, `max()`, `clamp()`, `round()` and the other math functions, mixed units and percentages, wherever a length, number or angle is taken; units `vw`, `vh`, `vmin`, `vmax` (the root viewport), `Q`, `ex`, `ch`, `cap` (the font's metrics), `lh`, `rlh`; `@media` evaluated for print (or screen) and a light (or dark) color scheme, no pointing device, viewport sizes matching; `<style media="…">`; `@font-face`; `@import` and `<?xml-stylesheet?>` style sheets, from files or URLs ([Network and other files](#network-and-other-files)); `@import` of Google Fonts CSS gives Google families ([Font downloads](#font-downloads)) |
|
|
1381
|
+
| Painting | `fill`, `stroke` (CSS Color 4 colors, `device-cmyk()`), `fill-rule`, `stroke-width`/`-linecap`/`-linejoin`/`-miterlimit`/`-dasharray`/`-dashoffset`, `paint-order`, `opacity`, `fill-opacity`, `stroke-opacity`; `context-fill`/`context-stroke` in marker content (the marked shape's fill and stroke); `pathLength` (scales the dashes, their offset and a `textPath`'s `startOffset`; not markers; 0 makes dashes endless as Chrome, negative or invalid is ignored); `vector-effect: non-scaling-stroke` (stroke width and dashes in the root's CSS pixels whatever the transform); `shape-rendering: crispEdges` or `optimizeSpeed` (image output draws the shape without antialiasing; PDF and EPS unchanged; SVG output keeps it) |
|
|
1335
1382
|
| Paint servers | `linearGradient`, `radialGradient` (focal point, `href` inheritance, `gradientTransform`, `spreadMethod`, `stop-opacity`), `pattern` |
|
|
1336
|
-
| Compositing | group opacity, `clipPath` (any shapes and text, `objectBoundingBox`, nested), luminance `
|
|
1383
|
+
| Compositing | group opacity; `mix-blend-mode` (the 16 modes; the element blended as a group, the root isolated as in browsers; CSS only, not an attribute, as Chrome) and `isolation: isolate`; `clipPath` (any shapes and text, `objectBoundingBox`, nested); `clip-path` basic shapes (`inset()` with `round`, `circle()`, `ellipse()`, `polygon()`, `path()`, positions and `closest-side`/`farthest-side`) with a reference box (`fill-box` default, `stroke-box`, `view-box`; the CSS layout boxes are the fill box); `mask` (`mask-type: luminance` or `alpha`; the `mask` and `mask-image` properties naming a `<mask>`); a `clip-path` or `mask` naming a missing element, or an element of another kind, applies none; an invalid basic shape clips nothing |
|
|
1337
1384
|
| Markers | `marker-start`/`-mid`/`-end`, `orient` (`auto`, `auto-start-reverse`, angles in `deg`, `grad`, `rad`, `turn`; a bare number is degrees), `viewBox`, `markerUnits`, `overflow`; drawn through `PathMarker` |
|
|
1338
|
-
| Text | `text`, `tspan`, `tref`, `textPath` (`startOffset`, `side`, `path`, `method="stretch"`); `x`/`y`/`dx`/`dy`/`rotate` lists; `textLength`, `lengthAdjust`; `text-anchor`; `inline-size` (SVG 2 wrapping: lines aligned by `text-anchor`, the first baseline at `y`; edge spaces kept under `xml:space="preserve"` or `white-space: pre`); `font` and `font-*` (`font-kerning` included); `letter-spacing`, `word-spacing`, `text-decoration` (applies to descendants, painted with the declaring element's fill and stroke; `line-through` at the font's strikeout position and thickness), `dominant-baseline`, `baseline-shift` (`sub`, `super`, lengths, percentages; nested shifts add up), `xml:space` (inherited) |
|
|
1339
|
-
| Images | PNG (all color types and depths, interlacing, transparency), JPEG (embedded unchanged), [JPEG XL](#jpeg-xl) (with libjxl), SVG; `data:` URIs
|
|
1385
|
+
| Text | `text`, `tspan`, `tref`, `textPath` (`startOffset`, `side`, `path`, `method="stretch"`); `x`/`y`/`dx`/`dy`/`rotate` lists; `textLength`, `lengthAdjust`; `text-anchor`; `inline-size` (SVG 2 wrapping: lines aligned by `text-anchor`, the first baseline at `y`; edge spaces kept under `xml:space="preserve"` or `white-space: pre`); `font` and `font-*` (`font-kerning` included; default family `system-ui`); `font-variant` and its longhands, `font-feature-settings`, `font-size-adjust`, `font-synthesis` ([shaping](#shaping)); `text-transform` (`uppercase`, `lowercase`, `capitalize`, `full-width`); `letter-spacing`, `word-spacing`, `text-decoration` (the shorthand or `-line`, `-style` (`solid`, `double`, `dotted`, `dashed`, `wavy`), `-thickness` (a length, a percentage of the em, `from-font`); applies to descendants, painted with the declaring element's fill and stroke as in browsers, so `text-decoration-color`, `text-underline-offset` and `text-underline-position` are not used; `line-through` at the font's strikeout position and thickness), `dominant-baseline` and `alignment-baseline` (each character on its element's `alignment-baseline`, else the `dominant-baseline`, as Chrome; on `text` too, which SVG 1.1 does not allow; positions from the font: [`baseline_position`](#61-shaping-without-a-page-vec_iotext)), `baseline-shift` (`sub`, `super`, lengths, percentages; nested shifts add up), `direction` and `unicode-bidi` (the bidi algorithm per text chunk; `text-anchor` follows the direction), `writing-mode` vertical (`vertical-rl`, `vertical-lr`, `tb`, `tb-rl`: upright CJK with `vmtx` advances and `vert` forms, other text sideways on the central baseline; `text-orientation`, `glyph-orientation-vertical`), `xml:space` (inherited) |
|
|
1386
|
+
| Images | PNG (all color types and depths, interlacing, transparency), JPEG (embedded unchanged), GIF (the first frame; palette, transparency, interlacing), BMP (1–32 bits, RLE4/RLE8, bit fields, alpha), ICO (the largest image), [JPEG XL](#jpeg-xl) (with libjxl), WebP (with libwebp: lossy, lossless, alpha, an animation's first frame), AVIF (with libavif, the first frame), SVG; `data:` URIs, local files, http(s) URLs. PDF stores GIF, BMP, ICO and lossless WebP lossless, lossy WebP and AVIF as JPEG at the output's `ImagePolicy(quality=…)`, else 90. Without its library a WebP, AVIF or JPEG XL image warns once (`ImageWarning`) and is drawn as missing (`VEC_IO_LIBWEBP`, `VEC_IO_LIBAVIF`, `VEC_IO_LIBJXL` give a library's path). `image-rendering: pixelated`/`crisp-edges` |
|
|
1340
1387
|
| Filters | see [Filters](#14-filters) |
|
|
1341
1388
|
| vec_io attributes | `data-rasterize`, `data-simplify`, `data-quality`, `data-filters` |
|
|
1342
1389
|
| Input | UTF-8 or declared encodings, SVGZ, common HTML entities |
|
|
1343
1390
|
|
|
1344
1391
|
Document size: `width`/`height` in any CSS unit, else `viewBox`, else
|
|
1345
1392
|
300 × 150. `em`, `ex` and `rem` on the root `<svg>` refer to its own font size; elsewhere
|
|
1346
|
-
`rem`
|
|
1393
|
+
`rem` and `rlh` refer to the root's font, `vw` and `vh` to the root's size.
|
|
1347
1394
|
|
|
1348
1395
|
## 16. Fonts
|
|
1349
1396
|
|
|
@@ -1362,8 +1409,12 @@ Fonts are embedded as subsets, always. For each character, the font is the first
|
|
|
1362
1409
|
next family. Generic families resolve to the first installed family of their list
|
|
1363
1410
|
(`serif`: Times New Roman, Liberation Serif, DejaVu Serif, …; `sans-serif`: Arial,
|
|
1364
1411
|
Helvetica, Liberation Sans, DejaVu Sans, …; `monospace`: Courier New, Liberation Mono,
|
|
1365
|
-
DejaVu Sans Mono,
|
|
1366
|
-
|
|
1412
|
+
DejaVu Sans Mono, …; `system-ui`, the default family: on macOS SF Pro Text below 20 pt
|
|
1413
|
+
and SF Pro Display from there, else Helvetica Neue; on Windows Segoe UI; elsewhere
|
|
1414
|
+
fontconfig's `system-ui` match (the desktop's interface font: Adwaita Sans, Cantarell,
|
|
1415
|
+
Noto Sans, Ubuntu…), then Noto Sans, DejaVu Sans), else to the best installed face of
|
|
1416
|
+
all; for text with no font at all, to Noto Sans (`sans-serif`, `system-ui`), Noto Serif
|
|
1417
|
+
or Noto Sans Mono from Google Fonts.
|
|
1367
1418
|
2. The generic family the list implies (`serif` for Times-like names, `monospace` for
|
|
1368
1419
|
Courier-like ones, else `sans-serif`).
|
|
1369
1420
|
3. Any installed font that has the character (Greek, Cyrillic, CJK, …), then any family
|
|
@@ -1406,10 +1457,42 @@ their text cannot be selected or searched. Text filled with a flat color draws e
|
|
|
1406
1457
|
from a form defined once (SVG: a `<use>` of a definition); text with a gradient or pattern,
|
|
1407
1458
|
stroked or clipping text are paths. A page of 4,500 characters in Liberation Sans is about
|
|
1408
1459
|
11 KB this way (4.5 KB as text); a plot's few labels add a few KB.
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1460
|
+
### Shaping
|
|
1461
|
+
|
|
1462
|
+
One shaper serves Canvas text, paragraphs, `vec_io.text` and SVG text.
|
|
1463
|
+
|
|
1464
|
+
- Pair kerning (GPOS `kern`, else the `kern` table) applies to every text
|
|
1465
|
+
(`font-kerning: none` and `font_kerning="none"` turn it off).
|
|
1466
|
+
- Standard ligatures (`liga`) apply to paragraphs and to `vec_io.text.shape` with
|
|
1467
|
+
`ligatures=True`; `font-variant` asks for others (`clig`, `calt`, `dlig`, `hlig`); other
|
|
1468
|
+
text shows one glyph per character.
|
|
1469
|
+
- `font-variant` (and `font-variant-caps`, `-numeric`, `-ligatures`, `-position`,
|
|
1470
|
+
`-east-asian`, `-alternates`) map to OpenType features (`smcp`, `c2sc`, `pcap`, `onum`,
|
|
1471
|
+
`lnum`, `tnum`, `pnum`, `frac`, `zero`, `liga`, `dlig`, `subs`, `sups`, `jp78`…);
|
|
1472
|
+
`font-feature-settings` applies after them. Small capitals are synthesized when the font
|
|
1473
|
+
has none, as browsers do: capitals at 0.7 of the size, written as a font of their own
|
|
1474
|
+
so that they extract as the lowercase text.
|
|
1475
|
+
- The built-in shaper applies GSUB lookups of every type (single, multiple, alternate,
|
|
1476
|
+
ligature, contextual, chained, extension, reverse chained) and GPOS lookups (single,
|
|
1477
|
+
pair, cursive, mark-to-base, mark-to-ligature, mark-to-mark, contextual), with lookup
|
|
1478
|
+
flags and mark filtering sets; `ccmp`, `locl`, `rlig`, `mark`, `mkmk`, `curs` are always
|
|
1479
|
+
on; marks get no advance and sit on their anchors.
|
|
1480
|
+
- Complex scripts (Arabic, Syriac, N'Ko, Mongolian, the Indic scripts, Sinhala, Thai, Lao,
|
|
1481
|
+
Tibetan, Myanmar, Khmer, Javanese, Balinese…) are shaped by HarfBuzz when it is
|
|
1482
|
+
installed (an optional system library loaded with ctypes: `libharfbuzz`;
|
|
1483
|
+
`VEC_IO_LIBHARFBUZZ` gives its path, `VEC_IO_NO_LIBHARFBUZZ=1` turns it off); without it
|
|
1484
|
+
they are drawn by the built-in shaper, unjoined and unreordered, with a `VecIOWarning`
|
|
1485
|
+
(once per script). Latin, Greek, Cyrillic, CJK and Hebrew need no HarfBuzz.
|
|
1486
|
+
- Right-to-left and mixed text is ordered by the Unicode Bidirectional Algorithm (UAX #9:
|
|
1487
|
+
embeddings, overrides, isolates, brackets, mirrored characters).
|
|
1488
|
+
- Text extraction: each glyph's ToUnicode entry is its characters (a ligature its
|
|
1489
|
+
components; in a cluster of several glyphs, each glyph its own character); glyphs are
|
|
1490
|
+
written in visual order. A cluster whose glyphs, read in that order (reversed right to
|
|
1491
|
+
left), are not its characters (an Indic vowel sign drawn before its consonant, a vowel
|
|
1492
|
+
split around one) is shown in marked content, `/Span <</ActualText (…)>> BDC … EMC`,
|
|
1493
|
+
giving its characters, so viewers copy and search them in logical order. Right-to-left
|
|
1494
|
+
runs need none: viewers reorder them. Text on a path (glyph by glyph) and
|
|
1495
|
+
`text_as_paths` get no spans.
|
|
1413
1496
|
A subset costs a few KB: a plot page's labels and bold title in Arial (two faces) add
|
|
1414
1497
|
about 4 KB, compressed (20 KB with the hinting).
|
|
1415
1498
|
|
|
@@ -1459,6 +1542,7 @@ Downloads are on by default:
|
|
|
1459
1542
|
| `Fonts(downloads=None)` (default) | `VEC_IO_FONT_DOWNLOADS`: `1`/`on` (default), `0`/`off`, or `cache` |
|
|
1460
1543
|
| `Fonts(downloads=True)` / `False` | Downloads on / off. |
|
|
1461
1544
|
| `Fonts(downloads="cache")` | Families already downloaded only; no network. |
|
|
1545
|
+
| `Document(network=False)`, `convert(network=False)`, CLI `--no-network` | Downloads off, whatever `downloads` says. |
|
|
1462
1546
|
|
|
1463
1547
|
`Document(fonts=…)` and `convert(fonts=…)` take a `Fonts`; `FontDB` takes
|
|
1464
1548
|
`font_downloads` itself. The CLI has `--font-downloads MODE`, `--no-font-downloads` and
|
|
@@ -1471,8 +1555,9 @@ Downloads are on by default:
|
|
|
1471
1555
|
named after it are stand-ins only when installed), `Nimbus Sans` fetches Nimbus Sans.
|
|
1472
1556
|
Other names ("SF Pro", a typo) never cause a request. In SVG, the families of an
|
|
1473
1557
|
`@import url(https://fonts.googleapis.com/css2?family=…)` count as Google families, and
|
|
1474
|
-
`@font-face` sources on `fonts.gstatic.com` are fetched into the cache; other
|
|
1475
|
-
|
|
1558
|
+
`@font-face` sources on `fonts.gstatic.com` are fetched into the cache; other URLs are
|
|
1559
|
+
fetched as the document's other resources ([Network and other
|
|
1560
|
+
files](#network-and-other-files)).
|
|
1476
1561
|
* **Styles.** A static face is chosen by CSS matching among the faces the source has
|
|
1477
1562
|
(Lato at weight 450 fetches Lato Regular); a variable file serves every weight, width,
|
|
1478
1563
|
slant and optical size exactly as an installed copy. A Fontsource style is several files,
|
|
@@ -1739,7 +1824,7 @@ without transparency are written as they are.
|
|
|
1739
1824
|
drawn per placement; others keep their reuse.
|
|
1740
1825
|
* Fallback (`Flatten.fallback`): for content that cannot be flattened (a gradient over a
|
|
1741
1826
|
different gradient, an image over an image or a gradient, a soft mask of varying alpha, a
|
|
1742
|
-
tiling pattern, a dashed stroke whose outline takes more than 2^24 points) and for grid
|
|
1827
|
+
blend mode, a tiling pattern, a dashed stroke whose outline takes more than 2^24 points) and for grid
|
|
1743
1828
|
cells of `cell` inches (default 0.25) holding more than `budget` pieces
|
|
1744
1829
|
(default 256; adjacent cells form one region): `"raster"`
|
|
1745
1830
|
(default) draws the region as an image of what the page shows there, at `dpi`
|
|
@@ -1824,6 +1909,8 @@ exported by `vec_io`.
|
|
|
1824
1909
|
| `PDFReadWarning` | Content of a PDF left out, once per kind and file ([Reading PDF](#reading-pdf)). |
|
|
1825
1910
|
| `FlattenWarning` | `Flatten(fallback="opaque")`: content drawn opaque because it could not be flattened, once per output ([Transparency flattening](#transparency-flattening)). |
|
|
1826
1911
|
| `FontDownloadWarning` | A family text asked for could not be downloaded; the next source or family is used. |
|
|
1912
|
+
| `NetworkWarning` | A URL a document refers to could not be fetched, once per URL and document; what refers to it is drawn as missing ([Network and other files](#network-and-other-files)). |
|
|
1913
|
+
| `ImageWarning` | WebP, AVIF or JPEG XL images without their library, once per format; drawn as missing. |
|
|
1827
1914
|
|
|
1828
1915
|
## 20. Modules
|
|
1829
1916
|
|
|
@@ -1838,13 +1925,14 @@ exported by `vec_io`.
|
|
|
1838
1925
|
| `filter.py` | `Filter` and its primitives: the filter graph, run on a group's pixels |
|
|
1839
1926
|
| `geometry.py` | `Matrix`, the packed `Path`, path data, arcs |
|
|
1840
1927
|
| `lines.py`, `shapes.py`, `cells.py` | lines, segments and areas; rectangles and polygons; cells |
|
|
1841
|
-
| `text/` | shaping, measuring and layout from a font database (`Font`, `GlyphRun`, `Span`, `shape`, `measure`, `layout`); `text/breaking.py`: line breaking of paragraphs; `text/path.py`: glyphs along a path |
|
|
1928
|
+
| `text/` | shaping, measuring and layout from a font database (`Font`, `GlyphRun`, `Span`, `shape`, `measure`, `layout`); `text/breaking.py`: line breaking of paragraphs; `text/path.py`: glyphs along a path; `text/shaping.py`: features, scripts, the built-in shaper; `text/bidi.py`: the bidi algorithm; `text/harfbuzz.py`: HarfBuzz through ctypes |
|
|
1842
1929
|
| `fonts/` | standard and embedded fonts; `fontdb` (discovery and matching), `download` (font downloads: switch, cache, network), `google`, `urw`, `ctan`, `fontsource`, `fontshare` (the download sources), `sfnt`, `cff`, `cff2`, `variations`, `opentype`, `woff2` |
|
|
1843
1930
|
| `convert.py` | `convert`, and the options of each output kind (`output_kind`, `output_settings`, `write_pages`) |
|
|
1844
1931
|
| `options.py` | the option objects (`Fonts`, `Flatten`, `View`, `ImagePolicy`, `PNG`, `JPEG`, `JXL`, `AVIF`) and `OptionError` |
|
|
1845
1932
|
| `errors.py` | `VecIOError`, `VecIOWarning` |
|
|
1846
1933
|
| `svg/` | SVG reading and writing: `parse` (XML, CSS cascade, `SVGDocument`), `css`, `render` (SVG semantics drawn through a `Canvas`), `filters` (`<filter>` as a `Filter`), `writer` (SVG output of scenes, written by the C library) |
|
|
1847
|
-
| `image/` | `Image`; `codecs`, `jxl`, `avif`, `resource` (loading, `ImageResource`) |
|
|
1934
|
+
| `image/` | `Image`; `codecs`, `jxl`, `avif`, `webp`, `gif`, `bmp` (BMP and ICO), `resource` (decoding, loading, `ImageResource`) |
|
|
1935
|
+
| `network.py` | fetching http(s) URLs: a document's `Fetcher` and its limits, the font downloads' requests |
|
|
1848
1936
|
| `pdf/` | `objects` (PDF values, numbered when written), `writer`, `images` (image XObjects), `pdfa` |
|
|
1849
1937
|
| `eps/` | EPS output: header, prolog and resources (`__init__`; the content written by the C library), fonts as Type 42, CFF or glyph outlines (`fonts`) |
|
|
1850
1938
|
| `pdfread/` | reading PDF: `file` (cross-reference, objects, filters, encryption), `content` (the interpreter), `resources`, `colors`, `functions`, `shadings`, `images`, `fonts`, `reader` (pages, annotations, links, outlines) |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: vec_io
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Create PDFs in Python: drawing APIs, SVG conversion, rasterization and more
|
|
5
5
|
Project-URL: Repository, https://github.com/ajgouhier/vec_io
|
|
6
6
|
Author-email: Arthur Gouhier <ajgouhier@gmail.com>
|
|
@@ -133,7 +133,9 @@ dicts of their fields.
|
|
|
133
133
|
* Text needs an outline font: fonts are always embedded (the standard 14 PDF fonts only
|
|
134
134
|
when named with `embed=False`), and with no font installed, supplied or downloaded,
|
|
135
135
|
text raises `NoFontError`.
|
|
136
|
-
* Filters can only be reproduced as pixels,
|
|
136
|
+
* Filters can only be reproduced as pixels (on by default, as in browsers; `filters=False`
|
|
137
|
+
turns them off).
|
|
138
|
+
* URLs an SVG refers to are fetched (`network=False` turns that off, for untrusted input).
|
|
137
139
|
* Animation and scripting are ignored: the initial state is drawn.
|
|
138
140
|
|
|
139
141
|
## Development
|
|
@@ -118,7 +118,9 @@ dicts of their fields.
|
|
|
118
118
|
* Text needs an outline font: fonts are always embedded (the standard 14 PDF fonts only
|
|
119
119
|
when named with `embed=False`), and with no font installed, supplied or downloaded,
|
|
120
120
|
text raises `NoFontError`.
|
|
121
|
-
* Filters can only be reproduced as pixels,
|
|
121
|
+
* Filters can only be reproduced as pixels (on by default, as in browsers; `filters=False`
|
|
122
|
+
turns them off).
|
|
123
|
+
* URLs an SVG refers to are fetched (`network=False` turns that off, for untrusted input).
|
|
122
124
|
* Animation and scripting are ignored: the initial state is drawn.
|
|
123
125
|
|
|
124
126
|
## Development
|
|
@@ -238,11 +238,22 @@ class FuzzTests(unittest.TestCase):
|
|
|
238
238
|
page.font_family = "Fuzz"
|
|
239
239
|
page.font_size = 12
|
|
240
240
|
page.fill_text("AB", 5, 45)
|
|
241
|
+
page._scene.span("A\u0915\u093f(\\)") # marked content around a text object
|
|
242
|
+
page.fill_text("AB", 5, 60)
|
|
243
|
+
page._scene.emc()
|
|
241
244
|
with page.mask() as m:
|
|
242
245
|
page.fill_rect(0, 0, 60, 90)
|
|
243
246
|
with page.mask(m):
|
|
244
247
|
page.fill_rect(0, 0, 120, 90)
|
|
245
248
|
page.draw_segments([5, 50], [5, 80], [100, 20], [60, 10], stroke=["red", (0, 0, 1, 0.3)], stroke_width=[1, 3])
|
|
249
|
+
with page.group(blend="multiply"):
|
|
250
|
+
page.fill_rect(10, 10, 60, 40, fill=(0.2, 0.6, 0.9, 0.7))
|
|
251
|
+
with page.group(blend="hue", opacity=0.6):
|
|
252
|
+
page.fill_rect(30, 20, 60, 40, fill="orange")
|
|
253
|
+
page.draw_markers([40, 60], [30, 50], SHAPES["circle"], 6, fill="lime")
|
|
254
|
+
page._scene.smooth(False)
|
|
255
|
+
page.fill_rect(70.3, 10.6, 20.2, 15.5, fill="purple")
|
|
256
|
+
page._scene.smooth(True)
|
|
246
257
|
scene = page._end_substream(saved)
|
|
247
258
|
return doc, page, scene, S.write(scene, doc._res)
|
|
248
259
|
|
|
@@ -1037,6 +1048,34 @@ class ReaderFuzzTests(unittest.TestCase):
|
|
|
1037
1048
|
for _rec in records(buf):
|
|
1038
1049
|
pass
|
|
1039
1050
|
|
|
1051
|
+
def test_gif_lzw(self):
|
|
1052
|
+
"""GIF's LZW (the GIF mode of the LZW decoder) and the GIF, BMP and ICO readers on
|
|
1053
|
+
mutated files and random code sizes and limits."""
|
|
1054
|
+
from test_image_formats import PAL, gif_lzw, make_bmp, make_gif
|
|
1055
|
+
from vec_io.image.resource import decode_image
|
|
1056
|
+
from vec_io.native import pdfread as P
|
|
1057
|
+
|
|
1058
|
+
rng = random.Random(25)
|
|
1059
|
+
plain = [bytes(rng.randrange(4) for _ in range(n)) for n in (0, 1, 50, 5000)]
|
|
1060
|
+
streams = [(gif_lzw(p, size), size) for p in plain for size in (2, 3, 8)]
|
|
1061
|
+
files = [make_gif(7, 5, [k % 4 for k in range(35)], PAL, transparent=1,
|
|
1062
|
+
interlace=True),
|
|
1063
|
+
make_bmp(3, 2, 24, [bytes(9)] * 2),
|
|
1064
|
+
make_bmp(4, 2, 8, None, palette=bytes(16), compression=1,
|
|
1065
|
+
raw_pixels=bytes([3, 1, 0, 0, 0, 2, 1, 0, 0, 3, 2, 3, 2, 0, 0, 1]))]
|
|
1066
|
+
for _ in busy(SECONDS):
|
|
1067
|
+
if rng.random() < 0.6:
|
|
1068
|
+
data, size = rng.choice(streams)
|
|
1069
|
+
size = rng.choice((size, size, 1, 11, rng.randrange(1, 12)))
|
|
1070
|
+
limit = rng.choice((0, 1, 35, 5000, 1 << 20))
|
|
1071
|
+
out = P.gif_lzw(mutate(rng, data), size, limit)
|
|
1072
|
+
self.assertLessEqual(len(out), limit)
|
|
1073
|
+
else:
|
|
1074
|
+
try:
|
|
1075
|
+
decode_image(mutate(rng, rng.choice(files)))
|
|
1076
|
+
except (ValueError, MemoryError, IndexError, struct.error):
|
|
1077
|
+
pass
|
|
1078
|
+
|
|
1040
1079
|
def test_pdf_filters(self):
|
|
1041
1080
|
"""LZW, RunLength, ASCII85, ASCIIHex, predictors, sample unpacking, resampling and
|
|
1042
1081
|
CCITT on mutated data and random parameters, under random limits."""
|