diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-11-29 09:14:08 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-11-29 11:32:14 +0100 |
commit | d34036e60c4e7d13feccd089f7749d35d956b358 (patch) | |
tree | 1d58eab69e4cf374d9415996a77d887e2f301717 /svgio/qa/cppunit/data | |
parent | 236a96c7cff4cbf8a4ee2499739e7a938b6bae64 (diff) |
SVG import: add support for semi-transparent text
<tspan fill-opacity="..."> from SVG was ignored so far, only taking RGB
colors from the 'fill' attribute, but ignoring transparency.
The problem is that an SVG file is imported by mapping it to
drawinglayer primitives, but TextSimplePortionPrimitive2D takes a
basegfx::BColor as the font color, which doesn't handle transparency.
Fix the problem by rendering SVG similar to how commit
81b0d5393ca4cf2ff0954e53b05928cde047c2e0 (svx: add rendering for
semi-transparent shape text, 2019-11-20) did it for shape text: wrap the
text primitive in a UnifiedTransparencePrimitive2D when opacity is not
1.
Note that the drawinglayer primitive works with transparency and SVG
works with opacity, which is the opposite of each other, but both are
0..1 ranges.
Change-Id: If5c48613b70eac662b54b8c9da835cd0a966ba89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143429
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'svgio/qa/cppunit/data')
-rw-r--r-- | svgio/qa/cppunit/data/tspan-fill-opacity.svg | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/svgio/qa/cppunit/data/tspan-fill-opacity.svg b/svgio/qa/cppunit/data/tspan-fill-opacity.svg new file mode 100644 index 000000000000..ef6d5352a8d2 --- /dev/null +++ b/svgio/qa/cppunit/data/tspan-fill-opacity.svg @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg version="1.2" width="210mm" height="297mm" viewBox="0 0 21000 29700" preserveAspectRatio="xMidYMid" fill-rule="evenodd" stroke-width="28.222" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" xmlns:presentation="http://sun.com/xmlns/staroffice/presentation" xmlns:smil="http://www.w3.org/2001/SMIL20/" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xml:space="preserve"> + <g class="ClosedBezierShape"> + <rect stroke="none" fill="none" x="9737" y="6537" width="7527" height="3527"/> + <g style="opacity: 0.30"> + <path fill="none" stroke="rgb(255,0,0)" stroke-width="25" stroke-linejoin="round" d="M 9875,6550 C 9806,6550 9750,6606 9750,6675 L 9750,9925 C 9750,9994 9806,10050 9875,10050 L 17125,10050 C 17194,10050 17250,9994 17250,9925 L 17250,6675 C 17250,6606 17194,6550 17125,6550 L 17000,6550 9875,6550 Z"/> + </g> + </g> + <g class="TextShape"> + <rect stroke="none" fill="none" x="9825" y="6550" width="4076" height="955"/> + <text> + <tspan x="9825" y="7939" font-family="Arial Narrow, sans-serif" font-size="800px" fill-opacity="0.30" fill="rgb(255,0,0)" stroke="none">hello</tspan> + </text> + </g> +</svg> |