diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:50:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:50:49 +0000 |
commit | c853ffb5b2f75f5a889ed2e3ef89b818a736e87a (patch) | |
tree | 7d13a0883bb7936b84d6ecdd7bc332b41ed04bee /testfiles/rendering_tests | |
parent | Initial commit. (diff) | |
download | inkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.tar.xz inkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.zip |
Adding upstream version 1.3+ds.upstream/1.3+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testfiles/rendering_tests')
62 files changed, 1227 insertions, 0 deletions
diff --git a/testfiles/rendering_tests/CMakeLists.txt b/testfiles/rendering_tests/CMakeLists.txt new file mode 100644 index 0000000..c081440 --- /dev/null +++ b/testfiles/rendering_tests/CMakeLists.txt @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +function(add_rendering_test rendering_test) + cmake_parse_arguments(ARG "" "FUZZ;DISABLE" "" ${ARGN}) + set(testname "render_${rendering_test}") + add_test(NAME ${testname} + COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/test.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/inkscape ${CMAKE_CURRENT_SOURCE_DIR}/${rendering_test} ${ARG_FUZZ} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/testfiles/rendering_tests) + set_tests_properties(${testname} PROPERTIES ENVIRONMENT "${INKSCAPE_TEST_PROFILE_DIR_ENV}/${testname};${CMAKE_CTEST_ENV}") + if(${ARG_DISABLE}) + set_tests_properties(${testname} PROPERTIES DISABLED "True") + endif() +endfunction() + +find_package(PkgConfig REQUIRED) +pkg_search_module(HARFBUZZ REQUIRED harfbuzz) + +# Add your test here (do not put the .svg extension) + +# -- Generic tests -- +add_rendering_test(test-empty) +add_rendering_test(test-dont-crash) +add_rendering_test(test-use FUZZ 0.03) + +# -- Selector tests -- +add_rendering_test(selector-important-002) +add_rendering_test(selector-important-003) + +add_rendering_test(multi-style) +add_rendering_test(style-parsing) + +# -- Text tests -- +## Many (if not all) of these tests are sensitive to the text rendering stack: FreeType, HarfBuzz, Pango. +add_rendering_test(text-flow FUZZ 0.5) + +# add_rendering_test(test-baseline-shift) +## Small differences with code adapted for Pango 1.44. + +add_rendering_test(test-glyph-y-pos FUZZ 0.1) +## to be fixed since an update happened between harfbuzz 1.5.1(OK) and 1.6.0(FAIL). +## If you re-enable the test, you may have to *slightly* fix the expected rendering (hoping the fix happens upstream). +## Please also check that the rendering with harfbuzz <=1.5.1 is not *too* wrong (for older systems) +## cf Tav's post : https://www.patreon.com/posts/into-sinkhole-19021727 +## and bug https://bugzilla.gnome.org/show_bug.cgi?id=787526 + +# add_rendering_test(text-shaping) +## Expected rendering generated with Pango 1.44. Currently fails with +## CI as CI uses Pango 1.40. Enable after updating CI to Ubuntu 20.04. + +add_rendering_test(text-glyphs-combining FUZZ 0.1) +## Expected rendering generated with Pango 1.44. + +add_rendering_test(text-glyphs-vertical FUZZ 0.1) +## Expected rendering generated with Pango 1.44. + +# -- LPE tests -- +add_rendering_test(test-powerstroke-join) + +# <symbol> geometric properties (SVG 2.0 feature) +add_rendering_test(symbol-svg2-geometry-properties) +add_rendering_test(symbol-svg2-ref) + +# Tests to run for 64-bit builds only. These fail in 32-bit builds (possibly due to rounding issues) +# TODO: Figure out actual cause and see if we can fix it +if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + add_rendering_test(test-rtl-vertical FUZZ 0.1) + + # .otf font with compressed SVG glyphs + add_rendering_test(text-gzipped-svg-glyph FUZZ 0.03) +endif() diff --git a/testfiles/rendering_tests/README b/testfiles/rendering_tests/README new file mode 100644 index 0000000..6ebcb4c --- /dev/null +++ b/testfiles/rendering_tests/README @@ -0,0 +1,26 @@ +HOWTO + +# Add a rendering test: + - create the svg file + - 0.92: + - inkscape <yourfile>.svg -d 96 -e expected_rendering/<yourfile>.png + - inkscape <yourfile>.svg -d 384 -e expected_rendering/<yourfile>-large.png + - 1.0: + - inkscape -d 96 --export-filename=expected_rendering/<yourfile>.png <yourfile>.svg + - inkscape -d 384 --export-filename=expected_rendering/<yourfile>-large.png <yourfile>.svg + - add the test in CMakeLists.txt + - use stable if possible to generate the reference png files + - git add <yourfile>.svg expected_rendering/<yourfile>-large.png expected_rendering/<yourfile>.png + +# Fix a failing test (due to a change in code): + - DO *NOT* MODIFY the expected rendering (or the svg) before getting advice from inkscape-devel@ + - fix your code if possible + - IF you change introduces a greater compatibility with css or browsers + - AND you cannot reasonably "update" files from older versions to match the appearance + - AND inkscape-devel@ has a consensus that it's the only way + -> do as you must + - manually double check the changes + +# Fix a failing test (due to a change in pixman or cairo): + - update renderings. Use a *stable* version to generate the renderings, NOT TRUNK + - manually check appearances diff --git a/testfiles/rendering_tests/drawing-pattern-test.svg b/testfiles/rendering_tests/drawing-pattern-test.svg new file mode 100644 index 0000000..7e82a95 --- /dev/null +++ b/testfiles/rendering_tests/drawing-pattern-test.svg @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + width="100" + height="100" + version="1.1" + id="svg1" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <defs + id="defs1"> + <pattern + width="1" + height="1" + id="pattern1" + patternTransform="scale(30,30)" + patternUnits="userSpaceOnUse"> + <rect + x="0" + y="0" + width="1" + height="1" + id="rect2" + fill="url(#grad2)" /> + <ellipse + id="eliipse1" + cx="0.5" + cy="0.5" + rx="0.5" + ry="0.5" + fill="url(#grad1)" /> + </pattern> + <linearGradient + id="grad1" + x1="0" + y1="0" + x2="1" + y2="1" + gradientUnits="userSpaceOnUse"> + <stop + offset="0%" + style="stop-color:rgb(0,255,255)" + id="stop1" /> + <stop + style="stop-color:rgb(0,0,255)" + id="stop2" + offset="100%" /> + </linearGradient> + <linearGradient + id="grad2" + x1="0" + y1="1" + x2="1" + y2="0" + gradientUnits="userSpaceOnUse"> + <stop + offset="0%" + style="stop-color:rgb(255,255,0)" + id="stop3" /> + <stop + style="stop-color:rgb(0,255,0)" + id="stop4" + offset="100%" /> + </linearGradient> + </defs> + <rect + width="100" + height="100" + x="0" + y="0" + id="rect3" + fill="url(#pattern1)" /> +</svg> diff --git a/testfiles/rendering_tests/expected_rendering/multi-style.png b/testfiles/rendering_tests/expected_rendering/multi-style.png Binary files differnew file mode 100644 index 0000000..7c7c2fb --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/multi-style.png diff --git a/testfiles/rendering_tests/expected_rendering/selector-important-002-large.png b/testfiles/rendering_tests/expected_rendering/selector-important-002-large.png Binary files differnew file mode 100644 index 0000000..e92eef0 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/selector-important-002-large.png diff --git a/testfiles/rendering_tests/expected_rendering/selector-important-002.png b/testfiles/rendering_tests/expected_rendering/selector-important-002.png Binary files differnew file mode 100644 index 0000000..b0af9bd --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/selector-important-002.png diff --git a/testfiles/rendering_tests/expected_rendering/selector-important-003-large.png b/testfiles/rendering_tests/expected_rendering/selector-important-003-large.png Binary files differnew file mode 100644 index 0000000..91cb3af --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/selector-important-003-large.png diff --git a/testfiles/rendering_tests/expected_rendering/selector-important-003.png b/testfiles/rendering_tests/expected_rendering/selector-important-003.png Binary files differnew file mode 100644 index 0000000..dfe3dbc --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/selector-important-003.png diff --git a/testfiles/rendering_tests/expected_rendering/style-parsing.png b/testfiles/rendering_tests/expected_rendering/style-parsing.png Binary files differnew file mode 100644 index 0000000..5b60834 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/style-parsing.png diff --git a/testfiles/rendering_tests/expected_rendering/symbol-svg2-geometry-properties.png b/testfiles/rendering_tests/expected_rendering/symbol-svg2-geometry-properties.png Binary files differnew file mode 100644 index 0000000..ca5e83e --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/symbol-svg2-geometry-properties.png diff --git a/testfiles/rendering_tests/expected_rendering/symbol-svg2-ref.png b/testfiles/rendering_tests/expected_rendering/symbol-svg2-ref.png Binary files differnew file mode 100644 index 0000000..5892726 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/symbol-svg2-ref.png diff --git a/testfiles/rendering_tests/expected_rendering/test-baseline-shift-large.png b/testfiles/rendering_tests/expected_rendering/test-baseline-shift-large.png Binary files differnew file mode 100644 index 0000000..29369a8 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-baseline-shift-large.png diff --git a/testfiles/rendering_tests/expected_rendering/test-baseline-shift.png b/testfiles/rendering_tests/expected_rendering/test-baseline-shift.png Binary files differnew file mode 100644 index 0000000..45aed90 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-baseline-shift.png diff --git a/testfiles/rendering_tests/expected_rendering/test-dont-crash.png b/testfiles/rendering_tests/expected_rendering/test-dont-crash.png Binary files differnew file mode 100644 index 0000000..a2d005e --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-dont-crash.png diff --git a/testfiles/rendering_tests/expected_rendering/test-empty-large.png b/testfiles/rendering_tests/expected_rendering/test-empty-large.png Binary files differnew file mode 100644 index 0000000..34acf1f --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-empty-large.png diff --git a/testfiles/rendering_tests/expected_rendering/test-empty.png b/testfiles/rendering_tests/expected_rendering/test-empty.png Binary files differnew file mode 100644 index 0000000..2e0a5fe --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-empty.png diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png Binary files differnew file mode 100644 index 0000000..57066fe --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png Binary files differnew file mode 100644 index 0000000..38c0117 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png diff --git a/testfiles/rendering_tests/expected_rendering/test-powerstroke-join-large.png b/testfiles/rendering_tests/expected_rendering/test-powerstroke-join-large.png Binary files differnew file mode 100644 index 0000000..72d8821 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-powerstroke-join-large.png diff --git a/testfiles/rendering_tests/expected_rendering/test-powerstroke-join.png b/testfiles/rendering_tests/expected_rendering/test-powerstroke-join.png Binary files differnew file mode 100644 index 0000000..1eeec07 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-powerstroke-join.png diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png Binary files differnew file mode 100644 index 0000000..d473a59 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png Binary files differnew file mode 100644 index 0000000..49db6cb --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png diff --git a/testfiles/rendering_tests/expected_rendering/test-use-large.png b/testfiles/rendering_tests/expected_rendering/test-use-large.png Binary files differnew file mode 100644 index 0000000..c1f4597 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-use-large.png diff --git a/testfiles/rendering_tests/expected_rendering/test-use.png b/testfiles/rendering_tests/expected_rendering/test-use.png Binary files differnew file mode 100644 index 0000000..a995136 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-use.png diff --git a/testfiles/rendering_tests/expected_rendering/text-flow.png b/testfiles/rendering_tests/expected_rendering/text-flow.png Binary files differnew file mode 100644 index 0000000..bef670d --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/text-flow.png diff --git a/testfiles/rendering_tests/expected_rendering/text-glyphs-combining-large.png b/testfiles/rendering_tests/expected_rendering/text-glyphs-combining-large.png Binary files differnew file mode 100644 index 0000000..5568888 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/text-glyphs-combining-large.png diff --git a/testfiles/rendering_tests/expected_rendering/text-glyphs-combining.png b/testfiles/rendering_tests/expected_rendering/text-glyphs-combining.png Binary files differnew file mode 100644 index 0000000..32a6781 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/text-glyphs-combining.png diff --git a/testfiles/rendering_tests/expected_rendering/text-glyphs-vertical-large.png b/testfiles/rendering_tests/expected_rendering/text-glyphs-vertical-large.png Binary files differnew file mode 100644 index 0000000..f49cbbd --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/text-glyphs-vertical-large.png diff --git a/testfiles/rendering_tests/expected_rendering/text-glyphs-vertical.png b/testfiles/rendering_tests/expected_rendering/text-glyphs-vertical.png Binary files differnew file mode 100644 index 0000000..cab1c0b --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/text-glyphs-vertical.png diff --git a/testfiles/rendering_tests/expected_rendering/text-gzipped-svg-glyph.png b/testfiles/rendering_tests/expected_rendering/text-gzipped-svg-glyph.png Binary files differnew file mode 100644 index 0000000..8e8a184 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/text-gzipped-svg-glyph.png diff --git a/testfiles/rendering_tests/expected_rendering/text-shaping-large.png b/testfiles/rendering_tests/expected_rendering/text-shaping-large.png Binary files differnew file mode 100644 index 0000000..e84ebf5 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/text-shaping-large.png diff --git a/testfiles/rendering_tests/expected_rendering/text-shaping.png b/testfiles/rendering_tests/expected_rendering/text-shaping.png Binary files differnew file mode 100644 index 0000000..346ab77 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/text-shaping.png diff --git a/testfiles/rendering_tests/fonts/Estedad-Medium.ttf b/testfiles/rendering_tests/fonts/Estedad-Medium.ttf Binary files differnew file mode 100644 index 0000000..d4844c2 --- /dev/null +++ b/testfiles/rendering_tests/fonts/Estedad-Medium.ttf diff --git a/testfiles/rendering_tests/fonts/GeomTest-Regular.otf b/testfiles/rendering_tests/fonts/GeomTest-Regular.otf Binary files differnew file mode 100644 index 0000000..a008cbf --- /dev/null +++ b/testfiles/rendering_tests/fonts/GeomTest-Regular.otf diff --git a/testfiles/rendering_tests/fonts/GeomTest-gzipped-SVG-glyphs.otf b/testfiles/rendering_tests/fonts/GeomTest-gzipped-SVG-glyphs.otf Binary files differnew file mode 100755 index 0000000..d8a89e3 --- /dev/null +++ b/testfiles/rendering_tests/fonts/GeomTest-gzipped-SVG-glyphs.otf diff --git a/testfiles/rendering_tests/fonts/LICENSES b/testfiles/rendering_tests/fonts/LICENSES new file mode 100644 index 0000000..71bfc0e --- /dev/null +++ b/testfiles/rendering_tests/fonts/LICENSES @@ -0,0 +1,10 @@ + +All fonts in this directory are licensed under open licenses. + +Lohit (https://pagure.io/lohit SIL Open Font 1.1) +NotoSans (https://www.google.com/get/noto/ Open Font License 1.1) +Estedad (https://github.com/aminabedi68/Estedad/ SIL Open Font 1.1) + +GeomTest Released under Open Font Licens 1.1. Copyright Tavmjong Bah 2015,2019 + + diff --git a/testfiles/rendering_tests/fonts/Lohit-Telugu.ttf b/testfiles/rendering_tests/fonts/Lohit-Telugu.ttf Binary files differnew file mode 100644 index 0000000..3869703 --- /dev/null +++ b/testfiles/rendering_tests/fonts/Lohit-Telugu.ttf diff --git a/testfiles/rendering_tests/fonts/NotoSans-Regular.ttf b/testfiles/rendering_tests/fonts/NotoSans-Regular.ttf Binary files differnew file mode 100644 index 0000000..b031a49 --- /dev/null +++ b/testfiles/rendering_tests/fonts/NotoSans-Regular.ttf diff --git a/testfiles/rendering_tests/fonts/NotoSansCJKjp-Regular.otf b/testfiles/rendering_tests/fonts/NotoSansCJKjp-Regular.otf Binary files differnew file mode 100644 index 0000000..296fbeb --- /dev/null +++ b/testfiles/rendering_tests/fonts/NotoSansCJKjp-Regular.otf diff --git a/testfiles/rendering_tests/fonts/NotoSansHebrew-Regular.ttf b/testfiles/rendering_tests/fonts/NotoSansHebrew-Regular.ttf Binary files differnew file mode 100644 index 0000000..9bf03ab --- /dev/null +++ b/testfiles/rendering_tests/fonts/NotoSansHebrew-Regular.ttf diff --git a/testfiles/rendering_tests/multi-style-import-1.css b/testfiles/rendering_tests/multi-style-import-1.css new file mode 100644 index 0000000..e6fb1e0 --- /dev/null +++ b/testfiles/rendering_tests/multi-style-import-1.css @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* overwritten later */ +rect { fill: red; } +.c1 { fill: red; } + +/* not overwritten */ +#background { fill: white; } +.c5 { fill: #00ccff; } diff --git a/testfiles/rendering_tests/multi-style-import-2.css b/testfiles/rendering_tests/multi-style-import-2.css new file mode 100644 index 0000000..3e0dd9b --- /dev/null +++ b/testfiles/rendering_tests/multi-style-import-2.css @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +rect { fill: blue; } +.c1 { fill: #990099; } + +/* overwritten later */ +.c4 { fill: red; } diff --git a/testfiles/rendering_tests/multi-style.svg b/testfiles/rendering_tests/multi-style.svg new file mode 100644 index 0000000..842f946 --- /dev/null +++ b/testfiles/rendering_tests/multi-style.svg @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="80" + height="80" + viewBox="0 0 80 80" + version="1.1"> + <style + id="first"> +rect { fill: #800000; } +/* class "c1" is redefined several times, only the last one counts */ +.c1 { fill: #ff0000; } +.c2 { fill: #ff9900; } +</style> + <defs> + <style + id="insidedefs"> +rect { fill: #ffff00; } +.c1 { fill: #008000; } +.c3 { fill: #00ff00; } +</style> + </defs> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <rect + id="background" + width="80" + height="80" /> + <rect + width="20" + height="20" /> + <rect + width="20" + height="20" + x="30" + class="c1" /> + <rect + width="20" + height="20" + x="60" + class="c2" /> + <rect + width="20" + height="20" + class="c3" + y="30" /> + <rect + class="c4" + width="20" + height="20" + x="30" + y="30" /> + <rect + class="c5" + width="20" + height="20" + x="60" + y="30" /> + <style + id="insidegroup"> +@import "multi-style-import-1.css"; +/* nested CSS selector (with XML entity because not using CDATA) */ +g.g1 > rect { fill: #00ffcc; } +</style> + <rect + class="c5" + width="20" + height="20" + y="60" /> + <rect + width="20" + height="20" + x="30" + y="60" /> + <g + class="g1"> + <rect + width="20" + height="20" + x="60" + y="60" /> + </g> + </g> + <style + id="last"><!-- using CDATA --><![CDATA[ +@import "multi-style-import-2.css"; +.c4 { fill: #ff00ff; } +]]></style> +</svg> diff --git a/testfiles/rendering_tests/selector-important-002.svg b/testfiles/rendering_tests/selector-important-002.svg new file mode 100644 index 0000000..e5a66b6 --- /dev/null +++ b/testfiles/rendering_tests/selector-important-002.svg @@ -0,0 +1,58 @@ +<svg xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + width="480" height="360" + style="fill:orange !important"> + + <title>Style "!important" — 002</title> + + <style type="text/css"> + + <!-- Later rule overrides same specificity previous rule. --> + #groupA use { fill: red !important; } + #groupA use { fill: blue !important; } + + #groupB .classB { fill: red !important; } + #groupB .classB { fill: blue !important; } + + #groupC #MyRectC { fill: red !important; } + #groupC #MyRectC { fill: blue !important; } + + #groupD { fill: blue !important; } + #classD { fill: red !important; } + + #groupE use { fill: blue !important; } + #groupE { fill: red !important; } + </style> + + <defs> + <rect id="MyRect" width="40" height="40"/> + </defs> + + <!-- + <text id="title" x="240" y="50" style="fill:black; font-size:24px; text-anchor:middle;">Style "!important" — 002</text> + <a href="https://svgwg.org/svg2-draft/stylling.html"> + <text id="source" x="240" y="70" style="fill:black; font-size:12px; text-anchor:middle;">https://svgwg.org/svg2-draft/styling.html</text> + </a> + --> + + <g id="groupA"> + <use id="MyRectA" class="classA" x="20" y="100" xlink:href="#MyRect" /> + </g> + + <g id="groupB"> + <use id="MyRectB" class="classB" x="120" y="100" xlink:href="#MyRect" /> + </g> + + <g id="groupC"> + <use id="MyRectC" class="classC" x="220" y="100" xlink:href="#MyRect" /> + </g> + + <g id="groupD"> + <use id="MyRectD" class="classD" x="320" y="100" xlink:href="#MyRect" /> + </g> + + <g id="groupE"> + <use id="MyRectE" class="classE" x="420" y="100" xlink:href="#MyRect" /> + </g> + +</svg> diff --git a/testfiles/rendering_tests/selector-important-003.svg b/testfiles/rendering_tests/selector-important-003.svg new file mode 100644 index 0000000..831319f --- /dev/null +++ b/testfiles/rendering_tests/selector-important-003.svg @@ -0,0 +1,57 @@ +<svg xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + width="480" height="360"> + + <title>Style "!important" — 003</title> + + <style type="text/css"> + + /* !important is not inherited. */ + g #groupA { fill: red !important; } + use { fill: blue; } + + /* Attributes cannot have !important. */ + #MyRectB { fill: blue; } + + /* Inline can have !important. */ + #MyRectC { fill: red !important; } + + /* Bad property shouldn't set !important. */ + #MyRectD { fill: XXX !important; } + + /* Bad inline property shouldn't set !important. */ + #MyRectE { fill: blue; } + </style> + + <defs> + <rect id="MyRect" width="40" height="40"/> + </defs> + + <!-- + <text id="title" x="240" y="50" style="fill:black; font-size:24px; text-anchor:middle;">Style "!important" — 003</text> + <a href="https://svgwg.org/svg2-draft/stylling.html"> + <text id="source" x="240" y="70" style="fill:black; font-size:12px; text-anchor:middle;">https://svgwg.org/svg2-draft/styling.html</text> + </a> + --> + + <g id="groupA"> + <use id="MyRectA" class="classA" x="20" y="100" xlink:href="#MyRect" /> + </g> + + <g id="groupB"> + <use id="MyRectB" class="classB" x="120" y="100" xlink:href="#MyRect" fill="red !important"/> + </g> + + <g id="groupC"> + <use id="MyRectC" class="classC" x="220" y="100" xlink:href="#MyRect" style="fill: blue !important"/> + </g> + + <g id="groupD"> + <use id="MyRectD" class="classD" x="320" y="100" xlink:href="#MyRect" style="fill: blue"/> + </g> + + <g id="groupE"> + <use id="MyRectE" class="classE" x="420" y="100" xlink:href="#MyRect" style="fill: XXX !important"/> + </g> + +</svg> diff --git a/testfiles/rendering_tests/style-parsing.svg b/testfiles/rendering_tests/style-parsing.svg new file mode 100644 index 0000000..33e32cb --- /dev/null +++ b/testfiles/rendering_tests/style-parsing.svg @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- +Test with leading semicolon in style. +https://gitlab.com/inkscape/inkscape/-/issues/1278 +--> +<svg xmlns="http://www.w3.org/2000/svg" + width="100%" height="100%" viewBox="0 0 500 200"> + <style type="text/css"> + rect { fill: red; } + #MyRect1 { ; fill: green; } + </style> + + <rect x="50" y="50" width="100" height="100" style=";fill:blue"/> + <rect x="200" y="50" width="100" height="100" id="MyRect1" /> + <rect x="350" y="50" width="100" height="100" style="stroke-width:0px;;;fill:blue" /> +</svg> diff --git a/testfiles/rendering_tests/symbol-svg2-geometry-properties.svg b/testfiles/rendering_tests/symbol-svg2-geometry-properties.svg new file mode 100644 index 0000000..a346366 --- /dev/null +++ b/testfiles/rendering_tests/symbol-svg2-geometry-properties.svg @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + viewBox="0 0 95 120"> + +<defs> + <symbol id="mySym" width="10" height="10" viewBox="0 0 2 2"> + <rect width="2" height="2" style="fill:blue" /> + </symbol> + <svg id="mySvg" width="10" height="10" viewBox="0 0 2 2"> + <rect width="2" height="2" style="fill:green" /> + </svg> + <symbol id="mySymShifted" x="15" y="20" width="10" height="10" viewBox="0 0 2 2"> + <rect width="2" height="2" style="fill:magenta" /> + </symbol> + <svg id="mySvgShifted" x="15" y="20" width="10" height="10" viewBox="0 0 2 2"> + <rect width="2" height="2" style="fill:cyan" /> + </svg> + <image id="myImg" width="10" height="10" preserveAspectRatio="none" + xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFc + SJAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jn + m+48GgAAAA1JREFUCJlj+F+v9R8ABtECqHp0jnoAAAAASUVORK5CYII="> + </image> + <rect id="myRect" width="10" height="10" style="fill:gray" /> + <rect id="myRectXY" width="10" height="10" style="fill:#cc0" x="20" y="30" /> +</defs> + +<rect width="100%" height="100%" fill="white" /> + +<path d="M0,10 h80 M10,0 v20 M25,0 v20 M40,0 v20 M55,0 v20 M70,0 v20" fill="none" stroke="pink" /> + +<use href="#mySym" x="5" y="5" style="opacity:1.0" /> +<use href="#mySvg" x="20" y="5" style="opacity:0.8" /> +<use href="#mySym" x="35" y="5" style="opacity:0.6" /> +<use href="#mySvg" x="50" y="5" style="opacity:0.4" /> +<use href="#mySym" x="65" y="5" style="opacity:0.2" /> + +<path d="M0,10 h80 M10,0 v20 M25,0 v20 M40,0 v20 M55,0 v20 M70,0 v20" fill="none" stroke="orange" transform="translate(15, 20)" /> + +<use xlink:href="#mySymShifted" x="5" y="5" style="opacity:1.0" /> +<use xlink:href="#mySvgShifted" x="20" y="5" style="opacity:0.8" /> +<use xlink:href="#mySymShifted" x="35" y="5" style="opacity:0.6" /> +<use xlink:href="#mySvgShifted" x="50" y="5" style="opacity:0.4" /> +<use xlink:href="#mySymShifted" x="65" y="5" style="opacity:0.2" /> + +<path d="M0,10 h80 M10,0 v20 M25,0 v20 M40,0 v20 M55,0 v20 M70,0 v20" fill="none" stroke="pink" transform="translate(0, 40)" /> + +<!-- with transform --> +<use xlink:href="#mySymShifted" x="5" y="5" style="opacity:1.0" transform="rotate(90, 7.5, 32.5)" /> +<use xlink:href="#mySvgShifted" x="20" y="5" style="opacity:0.8" transform="rotate(90, 22.5, 32.5)" /> +<use xlink:href="#mySymShifted" x="35" y="5" style="opacity:0.6" transform="rotate(90, 37.5, 32.5)" /> +<use xlink:href="#mySvgShifted" x="50" y="5" style="opacity:0.4" transform="rotate(90, 52.5, 32.5)" /> +<use xlink:href="#mySymShifted" x="65" y="5" style="opacity:0.2" transform="rotate(90, 67.5, 32.5)" /> + +<path d="M0,10 h80 M10,0 v20 M25,0 v20 M40,0 v20 M55,0 v20 M70,0 v20" fill="none" stroke="orange" transform="translate(15, 60)" /> + +<!-- without x/y --> +<use xlink:href="#mySymShifted" style="opacity:1.0" transform="rotate(90, 0.0, 50.0)" /> +<use xlink:href="#mySvgShifted" style="opacity:0.8" transform="rotate(90, 7.5, 57.5)" /> +<use xlink:href="#mySymShifted" style="opacity:0.6" transform="rotate(90, 15.0, 65.0)" /> +<use xlink:href="#mySvgShifted" style="opacity:0.4" transform="rotate(90, 22.5, 72.5)" /> +<use xlink:href="#mySymShifted" style="opacity:0.2" transform="rotate(90, 30.0, 80.0)" /> + +<path d="M0,10 h80 M10,0 v20 M25,0 v20 M40,0 v20 M55,0 v20 M70,0 v20" fill="none" stroke="pink" transform="translate(0, 80)" /> + +<!-- with width/height --> +<use xlink:href="#mySym" width="20" height="30" x="10" y="165" style="opacity:1.0" transform="scale(0.5)" /> +<use xlink:href="#mySvg" width="20" height="30" x="40" y="165" style="opacity:0.8" transform="scale(0.5)" /> +<use xlink:href="#mySym" width="20" height="30" x="70" y="165" style="opacity:0.6" transform="scale(0.5)" /> +<use xlink:href="#mySvg" width="20" height="30" x="100" y="165" style="opacity:0.4" transform="scale(0.5)" /> +<use xlink:href="#mySym" width="20" height="30" x="130" y="165" style="opacity:0.2" transform="scale(0.5)" /> + +<path d="M0,10 h80 M10,0 v20 M25,0 v20 M40,0 v20 M55,0 v20 M70,0 v20" fill="none" stroke="orange" transform="translate(15, 100)" /> + +<!-- image/rect --> +<use xlink:href="#myImg" x="20" y="105" /> +<use xlink:href="#myImg" x="35" y="105" width="20" height="30" /><!-- width/height ignored --> +<use xlink:href="#myRect" x="50" y="105" /> +<use xlink:href="#myRect" x="65" y="105" width="20" height="30" /><!-- width/height ignored --> +<use xlink:href="#myRectXY" x="60" y="75" /><!-- cumulated x/y --> + +</svg> diff --git a/testfiles/rendering_tests/symbol-svg2-ref.svg b/testfiles/rendering_tests/symbol-svg2-ref.svg new file mode 100644 index 0000000..25dfd3f --- /dev/null +++ b/testfiles/rendering_tests/symbol-svg2-ref.svg @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + viewBox="0 0 50 65"> + +<defs> + <symbol id="mySymNoViewBoxTopLeft"> + <rect width="10" height="10" style="fill:#00f" /> + </symbol> + <symbol id="mySymNoViewBoxXYCenter" x="-5" y="-5"> + <rect width="10" height="10" style="fill:#66f" /> + </symbol> + <symbol id="mySymTopLeft" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#ccf" /> + </symbol> + <symbol id="mySymXYCenter" x="-5" y="-5" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#f00" /> + </symbol> + <symbol id="mySymXYTopRight" x="-10" y="0" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#f66" /> + </symbol> + <symbol id="mySymXYBottomLeft" x="0" y="-10" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#fcc" /> + </symbol> + <symbol id="mySymRefXRefYAbsoluteCenter" refX="2" refY="2" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#0f0" /> + </symbol> + <symbol id="mySymRefXRefYPercentTopRight" refX="100%" refY="0%" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#0c0" /> + </symbol> + <symbol id="mySymRefXRefYPercentBottomLeft" refX="0%" refY="100%" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#060" /> + </symbol> + <symbol id="mySymRefXRefYNamedCenter" refX="center" refY="center" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#fc0" /> + </symbol> + <symbol id="mySymRefXRefYNamedTopRight" refX="right" refY="top" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#c90" /> + </symbol> + <symbol id="mySymRefXRefYNamedBottomLeft" refX="left" refY="bottom" width="10" height="10" viewBox="0 0 4 4"> + <rect width="4" height="4" style="fill:#960" /> + </symbol> +</defs> + +<use xlink:href="#mySymNoViewBoxXYCenter" x="10" y="10" /> +<use xlink:href="#mySymNoViewBoxTopLeft" x="20" y="5" /> +<use xlink:href="#mySymTopLeft" x="35" y="5" /> + +<use xlink:href="#mySymXYCenter" x="10" y="25" /> +<use xlink:href="#mySymXYTopRight" x="30" y="20" /> +<use xlink:href="#mySymXYBottomLeft" x="35" y="30" /> + +<use xlink:href="#mySymRefXRefYAbsoluteCenter" x="10" y="40" /> +<use xlink:href="#mySymRefXRefYPercentTopRight" x="30" y="35" /> +<use xlink:href="#mySymRefXRefYPercentBottomLeft" x="35" y="45" /> + +<use xlink:href="#mySymRefXRefYNamedCenter" x="10" y="55" /> +<use xlink:href="#mySymRefXRefYNamedTopRight" x="30" y="50" /> +<use xlink:href="#mySymRefXRefYNamedBottomLeft" x="35" y="60" /> + +</svg> diff --git a/testfiles/rendering_tests/test-baseline-shift.svg b/testfiles/rendering_tests/test-baseline-shift.svg new file mode 100644 index 0000000..7d20d22 --- /dev/null +++ b/testfiles/rendering_tests/test-baseline-shift.svg @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> + +<svg width="600" height="600" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + version="1.1" + viewBox="0 0 600 600"> + <style type="text/css"> + @font-face { + font-family: "Noto Sans"; + src: url("fonts/NotoSans-Regular.ttf"); + } + + text { + font-family: Noto Sans; + font-size: 36px; + } + + .title { + text-anchor: middle; + } + </style> + + <g> + <text x="50" y="200">subscript: H<tspan style="font-size:65%;baseline-shift:sub">2</tspan>O</text> + <text x="50" y="300">superscript: m<tspan style="font-size:65%;baseline-shift:super">2</tspan></text> + <text x="530" y="200" style="writing-mode:tb-rl">subscript: H<tspan style="font-size:65%;baseline-shift:sub">2</tspan>O</text> + <text x="430" y="200" style="writing-mode:tb-rl">superscript: m<tspan style="font-size:65%;baseline-shift:super">2</tspan></text> + </g> + + <text class="title" x="50%" y="120">Sub- and Superscript</text> + +</svg> diff --git a/testfiles/rendering_tests/test-dont-crash.svg b/testfiles/rendering_tests/test-dont-crash.svg new file mode 100644 index 0000000..9eabd33 --- /dev/null +++ b/testfiles/rendering_tests/test-dont-crash.svg @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + viewBox="0 0 210 297" + height="297mm" + width="210mm"> + <g + id="layer1" + inkscape:groupmode="layer" + inkscape:label="Layer 1"> + <!-- missing xlink:href attribute - don't care how it's rendered (place it + off-page), but Inkscape should not crash --> + <image + y="-100" + x="-100" + height="50" + width="50" /> + + <!-- missing points attribute --> + <polygon /> + <polyline /> + + <!-- empty points attribute --> + <polygon points="" /> + <polyline points="" /> + + <!-- odd number of coordinates with 0 valid points --> + <polygon points="0" /> + <polyline points="0" /> + + <!-- odd number of coordinates with trailing comma --> + <polygon points="0," /> + <polyline points="0," /> + + <!-- only one point --> + <polygon points="0,0" /> + <polyline points="0,0" /> + + <!-- odd number of coordinates with 1 valid point --> + <polygon points="0 0 100" /> + <polyline points="0 0 100" /> + + <!-- nan (https://gitlab.com/inkscape/inkscape/-/issues/4021) --> + <polygon points="0,0 nan,nan" /> + <polyline points="0,0 nan,nan" /> + + </g> +</svg> diff --git a/testfiles/rendering_tests/test-empty.svg b/testfiles/rendering_tests/test-empty.svg new file mode 100644 index 0000000..3b5ee5a --- /dev/null +++ b/testfiles/rendering_tests/test-empty.svg @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="210mm" + height="297mm" + viewBox="0 0 210 297" + version="1.1" + id="svg8" + inkscape:version="0.92.1 r15371" + sodipodi:docname="test-empty.svg"> + <defs + id="defs2" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.7" + inkscape:cx="132.86611" + inkscape:cy="438.52092" + inkscape:document-units="mm" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1920" + inkscape:window-height="1055" + inkscape:window-x="1920" + inkscape:window-y="0" + inkscape:window-maximized="1" /> + <metadata + id="metadata5"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <rect + style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.64583325;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.98039216" + id="rect7" + width="92.226196" + height="75.595238" + x="52.160713" + y="46.023808" + rx="6.6565199" + ry="6.6565199" /> + </g> +</svg> diff --git a/testfiles/rendering_tests/test-glyph-y-pos.svg b/testfiles/rendering_tests/test-glyph-y-pos.svg new file mode 100644 index 0000000..6f44ef8 --- /dev/null +++ b/testfiles/rendering_tests/test-glyph-y-pos.svg @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> + +<svg width="600" height="600" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + version="1.1" + viewBox="0 0 600 600"> + <style type="text/css"> + @font-face { + font-family: "Noto Sans"; + src: url("fonts/NotoSans-Regular.ttf"); + } + + text { + font-family: Noto Sans; + font-size: 36px; + } + .title { + text-anchor: middle; + } + </style> + + <rect x="0" y="0" width="600" height="600" style="fill:white"/> + <g> + <text x="50" y="200">G̃g̃X̃x̃</text> + <text x="300" y="200" style="writing-mode:vertical-lr;">G̃g̃X̃x̃</text> + <text x="500" y="200" style="writing-mode:vertical-lr;text-orientation:upright">G̃g̃X̃x̃</text> + </g> + + <text class="title" x="50%" y="120">Composed Glyphs</text> + +</svg> diff --git a/testfiles/rendering_tests/test-powerstroke-join.svg b/testfiles/rendering_tests/test-powerstroke-join.svg new file mode 100644 index 0000000..2c05fb3 --- /dev/null +++ b/testfiles/rendering_tests/test-powerstroke-join.svg @@ -0,0 +1,6 @@ +<svg xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns="http://www.w3.org/2000/svg" height="103.10469" width="114.42079"> + <defs id="defs8"> + <inkscape:path-effect end_linecap_type="zerowidth" scale_width="1" miter_limit="4" linejoin_type="extrp_arc" start_linecap_type="zerowidth" interpolator_beta="0.2" interpolator_type="CubicBezierSmooth" sort_points="true" offset_points="0.2,6 | 1,6 | 1.8,6" lpeversion="1" is_visible="true" id="path-effect12" effect="powerstroke" /> + </defs> + <path inkscape:original-d="M 37.025152,63.80944 C 62.629473,85.82239 121.42349,99.11534 92.9073,25.53973 73.516303,45.478852 29.421533,5.937486 9.304592,36.285332" inkscape:path-effect="#path-effect12"/> +</svg> diff --git a/testfiles/rendering_tests/test-rtl-vertical.svg b/testfiles/rendering_tests/test-rtl-vertical.svg new file mode 100644 index 0000000..aa6610b --- /dev/null +++ b/testfiles/rendering_tests/test-rtl-vertical.svg @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> + +<svg width="600" height="600" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + version="1.1" + viewBox="0 0 600 600"> + <style type="text/css"> + @font-face { + font-family: "Estedad"; + src: url("fonts/Estedad-Medium.ttf"); + } + + @font-face { + font-family: "Noto Sans"; + src: url("fonts/NotoSans-Regular.ttf"); + } + + text { + font-family: Estedad; + font-size: 36px; + } + + .title { + font-family: "Noto Sans"; + text-anchor: middle; + } + </style> + + <rect x="0" y="0" width="600" height="600" style="fill:white"/> + <g> + <text x="50" y="200">أبجد</text> + <text x="300" y="200" style="writing-mode:vertical-lr;">أبجد</text> + <text x="500" y="200" style="writing-mode:vertical-lr;text-orientation:upright">أبجد</text> + </g> + + <text class="title" x="50%" y="120">RTL text in vertical mode</text> + +</svg> diff --git a/testfiles/rendering_tests/test-use-ref.svg b/testfiles/rendering_tests/test-use-ref.svg new file mode 100644 index 0000000..0e6edf3 --- /dev/null +++ b/testfiles/rendering_tests/test-use-ref.svg @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + version="1.1" + id="root" + width="100" + height="100" + viewBox="0 0 100 100"> + <style> + .magenta { + stroke:none; + fill:#ff00ff; + } + </style> + <defs> + <marker + id="arrow" + style="overflow:visible;" + refX="0.0" + refY="0.0" + orient="auto"> + <path + style="stroke:#ff00ff;stroke-width:1pt;fill:#ff00ff" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + transform="scale(0.4) rotate(180) translate(10,0)" /> + </marker> + <linearGradient + id="gradientBase"> + <stop + style="stop-color:#ff00ff;stop-opacity:1;" + offset="0" /> + <stop + style="stop-color:#ff00ff;stop-opacity:0;" + offset="1" /> + </linearGradient> + <linearGradient + id="gradient" + xlink:href="#gradientBase" + x1="10" + y1="50" + x2="90" + y2="50" + gradientUnits="userSpaceOnUse" /> + <filter + id="filter" + style="color-interpolation-filters:sRGB" + x="-1.2" + y="-1.2" + width="3.4" + height="3.4"> + <feGaussianBlur + stdDeviation="5" /> + </filter> + </defs> + <rect + class="green" + style="filter:url(#filter)" + x="15" + y="15" + width="10" + height="10" /> + <rect + id="rect" + class="magenta" + x="10" + y="80" + width="10" + height="10" /> + <use + xlink:href="#rect" + transform="translate(15)" /> + <use + xlink:href="#rect" + transform="translate(30)" /> + <use + xlink:href="#rect" + transform="translate(45)" /> + <rect + style="fill:url(#gradient);stroke:none" + x="10" + y="45" + width="80" + height="10" /> + <path + style="fill:none;stroke:#ff00ff;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#arrow)" + d="M 90,20 H 45" /> +</svg> diff --git a/testfiles/rendering_tests/test-use.svg b/testfiles/rendering_tests/test-use.svg new file mode 100644 index 0000000..7e8a8ac --- /dev/null +++ b/testfiles/rendering_tests/test-use.svg @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + version="1.1" + width="100" + height="100" + viewBox="0 0 100 100"> + <style> + .green { + stroke:none; + fill:#00ff00; + } + </style> + <use + xlink:href="test-use-ref.svg#root" /> +</svg> diff --git a/testfiles/rendering_tests/test.sh b/testfiles/rendering_tests/test.sh new file mode 100755 index 0000000..658b578 --- /dev/null +++ b/testfiles/rendering_tests/test.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later + +MY_LOCATION=$(dirname "$0") +source "${MY_LOCATION}/../utils/functions.sh" + +ensure_command "compare" +ensure_command "bc" + +if [ "$#" -lt 2 ]; then + echo "Pass the path of the inkscape executable as parameter then the name of the test" $# + exit 1 +fi + +INKSCAPE_EXE="$1" +TEST="$2" +FUZZ="$3" +EXIT_STATUS=0 +EXPECTED="$(dirname "$TEST")/expected_rendering/$(basename "$TEST")" +TESTNAME="$(basename "$TEST")" + +if [ "$FUZZ" = "" ]; then + METRIC="AE" +else + METRIC="RMSE" +fi + +perform_test() +{ + local SUFFIX="$1" + local DPI="$2" + ${INKSCAPE_EXE} --export-png-use-dithering false --export-filename="${TESTNAME}${SUFFIX}.png" -d "$DPI" "${TEST}.svg" + + COMPARE_OUTPUT="$(compare -metric "$METRIC" "${TESTNAME}${SUFFIX}.png" "${EXPECTED}${SUFFIX}.png" "${TESTNAME}-compare${SUFFIX}.png" 2>&1)" + + if [ "$FUZZ" = "" ]; then + if [ "$COMPARE_OUTPUT" = 0 ]; then + echo "${TESTNAME}${SUFFIX}" "PASSED; absolute difference is exactly zero." + rm "${TESTNAME}${SUFFIX}.png" "${TESTNAME}-compare${SUFFIX}.png" + else + echo "${TESTNAME} FAILED; absolute difference ${COMPARE_OUTPUT} is greater than zero." + EXIT_STATUS=1 + fi + else + RELATIVE_ERROR=$(get_compare_result "$COMPARE_OUTPUT") + PERCENTAGE_ERROR=$(fraction_to_percentage "$RELATIVE_ERROR") + if (( $(is_relative_error_within_tolerance "$RELATIVE_ERROR" "$FUZZ") )) + then + echo "${TESTNAME}${SUFFIX}" "PASSED; error of ${PERCENTAGE_ERROR}% is within ${FUZZ}% tolerance." + rm "${TESTNAME}${SUFFIX}.png" "${TESTNAME}-compare${SUFFIX}.png" + else + echo "${TESTNAME} FAILED; error of ${PERCENTAGE_ERROR}% exceeds ${FUZZ}% tolerance." + EXIT_STATUS=1 + fi + fi +} + +perform_test "" 96 + +if [ -f "${EXPECTED}-large.png" ]; then + perform_test "-large" 384 +else + echo "${TESTNAME}-large" "SKIPPED" +fi + +exit $EXIT_STATUS diff --git a/testfiles/rendering_tests/text-flow.svg b/testfiles/rendering_tests/text-flow.svg new file mode 100644 index 0000000..9cade53 --- /dev/null +++ b/testfiles/rendering_tests/text-flow.svg @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg width="3300" height="1280" viewBox="0 0 330 128" version="1.1" xmlns="http://www.w3.org/2000/svg"> +<style type="text/css"> + @font-face { + font-family: "Noto Sans"; + src: url("fonts/NotoSans-Regular.ttf"); + } + text { + line-height: 1.2; + font-family: Noto Sans; + font-size: 3.8px; + fill: white; + stroke: none; + shape-padding: 5px; + shape-subtract:url(#bullseye) url(#target1) url(#target2) url(#target3) url(#target4); + text-align: justify; + } + .outside { + fill: red; + } + .inside { + fill: white; + shape-margin: 5px; + stroke-width: 10px; + stroke: red; + paint-order: stroke markers fill; + } + .check_padding { + fill: green; + } +</style> + <circle class="outside" id="shape1" cx="64" cy="64" r="64" /> + <circle class="check_padding" cx="64" cy="64" r="59" /> + <circle class="inside" id="bullseye" cx="64" cy="64" r="20" /> + + <rect class="outside" id="column1" width="42" height="128" x="136" y="0" /> + <rect class="outside" id="column2" width="42" height="128" x="186" y="0" /> + <rect class="check_padding" width="32" height="118" x="141" y="5" /> + <rect class="check_padding" width="32" height="118" x="191" y="5" /> + + <path class="outside" id="combined" d="M 236,0 v 128 h 42 v -128 Z M 286,0 v 128 h 42 v -128 Z" /> + <rect class="check_padding" width="32" height="118" x="241" y="5" /> + <rect class="check_padding" width="32" height="118" x="291" y="5" /> + + <circle class="inside" id="target1" cx="140" cy="20" r="10" /> + <circle class="inside" id="target2" cx="196" cy="60" r="5" /> + <circle class="inside" id="target3" cx="250" cy="40" r="5" /> + <circle class="inside" id="target4" cx="250" cy="80" r="5" /> + + <text style="shape-inside:url(#shape1);">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Why do we use it?It is a long established fact that a reader will be distracted by the readable....</text> + + <text style="shape-inside:url(#column1) url(#column2);">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Why do we use it?It is a long established fact that a reader will be distracted by the readable....</text> + + <text style="shape-inside:url(#combined);">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Why do we use it?It is a long established fact that a reader will be distracted by the readable....</text> +</svg> diff --git a/testfiles/rendering_tests/text-glyphs-combining.svg b/testfiles/rendering_tests/text-glyphs-combining.svg new file mode 100644 index 0000000..646ee05 --- /dev/null +++ b/testfiles/rendering_tests/text-glyphs-combining.svg @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + width="100%" + height="100%" + viewBox="0 0 600 600"> + + <style type="text/css"> + + @font-face { + font-family: "Noto Sans"; + src: url("fonts/NotoSans-Regular.ttf"); + } + + text { + font-family: "Noto Sans"; + font-size: 30px; + } + + </style> + + <rect x="0" y="0" width="600" height="600" style="fill:white"/> + + <text x="25%" y="10%">õőo̓ơọo̫o̳o̻o̓o͋o͗o͡</text> + <text x="25%" y="25%" style="writing-mode:vertical-lr">õőo̓ơọo̫o̳o̻o̓o͋o͗o͡</text> + <text x="50%" y="25%" style="writing-mode:vertical-lr;text-orientation:upright">õőo̓ơọo̫o̳o̻o̓o͋o͗o͡</text> + <text x="75%" y="25%" style="writing-mode:vertical-lr;text-orientation:sideways">õőo̓ơọo̫o̳o̻o̓o͋o͗o͡</text> + + <!-- Show reference point --> + <circle cx="25%" cy="10%" r="2" style="fill:lightblue"/> + <circle cx="25%" cy="25%" r="2" style="fill:lightblue"/> + <circle cx="50%" cy="25%" r="2" style="fill:lightblue"/> + <circle cx="75%" cy="25%" r="2" style="fill:lightblue"/> + +</svg> diff --git a/testfiles/rendering_tests/text-glyphs-vertical.svg b/testfiles/rendering_tests/text-glyphs-vertical.svg new file mode 100644 index 0000000..585a404 --- /dev/null +++ b/testfiles/rendering_tests/text-glyphs-vertical.svg @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + width="100%" + height="100%" + viewBox="0 0 600 600"> + + <style type="text/css"> + + @font-face { + font-family: "Noto Sans"; + src: url("fonts/NotoSans-Regular.ttf"); + } + + @font-face { + font-family: "Noto Sans CJK JP"; + src: url("fonts/NotoSansCJKjp-Regular.otf"); + } + + @font-face { + font-family: "GeomTest"; + src: url("fonts/GeomTest-Regular.otf"); + } + + text { + font-family: "Noto Sans"; + font-size: 30px; + } + + .geomtest { + font-family: GeomTest; + } + + .cjk { + font-family: "Noto Sans CJK JP"; + } + </style> + + <rect x="0" y="0" width="600" height="600" style="fill:white"/> + + <text x="100" y="100"><tspan class="cjk">㆕㆖㆘</tspan><tspan class="geomtest">A回ーऄ</tspan>G̃g̃X̃x̃</text> + <text x="115" y="200" style="writing-mode:vertical-lr"><tspan class="cjk">㆕㆖㆘</tspan><tspan class="geomtest">A回ーऄ</tspan>G̃g̃X̃x̃</text> + <text x="305" y="200" style="writing-mode:vertical-lr;text-orientation:upright"><tspan class="cjk">㆕㆖㆘</tspan><tspan class="geomtest">A回ーऄ</tspan>G̃g̃X̃x̃</text> + <text x="495" y="200" style="writing-mode:vertical-lr;text-orientation:sideways"><tspan class="cjk">㆕㆖㆘</tspan><tspan class="geomtest">A回ーऄ</tspan>G̃g̃X̃x̃</text> + + <!-- Show reference point --> + <circle cx="100" cy="100" r="2" style="fill:lightblue"/> + <circle cx="115" cy="200" r="2" style="fill:lightblue"/> + <circle cx="305" cy="200" r="2" style="fill:lightblue"/> + <circle cx="495" cy="200" r="2" style="fill:lightblue"/> + +</svg> diff --git a/testfiles/rendering_tests/text-gzipped-svg-glyph.svg b/testfiles/rendering_tests/text-gzipped-svg-glyph.svg new file mode 100644 index 0000000..88ba336 --- /dev/null +++ b/testfiles/rendering_tests/text-gzipped-svg-glyph.svg @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + width="100%" + height="100%" + viewBox="0 0 110 40"> + + <style type="text/css"> + + @font-face { + font-family: "GeomTest"; + src: url("fonts/GeomTest-gzipped-SVG-glyphs.otf"); + } + + text { + font-family: "GeomTest"; + font-size: 30px; + } + + </style> + + <text x="10" y="30">ABC</text> + +</svg> diff --git a/testfiles/rendering_tests/text-shaping.svg b/testfiles/rendering_tests/text-shaping.svg new file mode 100644 index 0000000..80aa95a --- /dev/null +++ b/testfiles/rendering_tests/text-shaping.svg @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + width="100%" + height="100%" + viewBox="0 0 600 600"> + + <style type="text/css"> + + @font-face { + font-family: "Estedad"; + src: url("fonts/Estedad-Medium.ttf"); + } + + @font-face { + font-family: "Noto Sans Hebrew"; + src: url("fonts/NotoSansHebrew-Regular.ttf"); + } + + @font-face { + font-family: "Noto Sans"; + src: url("fonts/NotoSans-Regular.ttf"); + } + + @font-face { + font-family: "Noto Sans CJK JP"; + src: url("fonts/NotoSansCJKjp-Regular.otf"); + } + + @font-face { + font-family: "Lohit Telugu"; + src: url("fonts/Lohit-Telugu.ttf"); + } + + </style> + + <g style="fill:none;stroke:black;stroke-width:0.5px;font-size:42px;font-family:serif;text-anchor:middle"> + + <!-- bug https://gitlab.com/inkscape/inkscape/-/issues/469 --> + <text xml:space="preserve" + x="300" + y="50" + style="font-family:Estedad;direction:rtl">نیرو</text> + + <text xml:space="preserve" + x="300" + y="100" + style="font-family:Estedad;direction:rtl">بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ</text> + + <text xml:space="preserve" + x="300" + y="150" + style="font-family:'Noto Sans Hebrew';direction:rtl">שָׁלוֹם</text> + + <text xml:space="preserve" + x="300" + y="200" + style="font-family:'Noto Sans Hebrew';direction:rtl">חִירִיק</text> + + <text xml:space="preserve" + x="300" + y="250" + style="font-family:'Noto Sans'">â â̂ â â̂</text> + + <text xml:space="preserve" + x="300" + y="300" + style="font-family:'Noto Sans'">a ḁ ą ą</text> + + <text xml:space="preserve" + x="300" + y="350" + style="font-family:'Noto Sans CJK JP'">ヘ ペ ペ</text> + + <text xml:space="preserve" + x="300" + y="400" + style="font-family:'Lohit Telugu'">తెలుగులో</text> + + <!-- Teluga bug https://gitlab.com/inkscape/inkscape/-/issues/394 --> + <text xml:space="preserve" + x="300" + y="450" + style="font-family:'Lohit Telugu'">గ్రంథాలయం</text> + + <!-- Teluga bug https://launchpadlibrarian.net/167162208/inkscape-telugu-text.svg --> + <text xml:space="preserve" + x="300" + y="500" + style="font-family:'Lohit Telugu'">ఇంక్స్కేప్</text> + </g> +</svg> |