SVG import: add support for semi-transparent text

Desktop / LibreOffice - Miklos Vajna [collabora.com] - 29 November 2022 10:32 UTC

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

d34036e60c4e SVG import: add support for semi-transparent text
svgio/inc/svgcharacternode.hxx | 2 +-
svgio/qa/cppunit/SvgImportTest.cxx | 24 ++++++++++++++++++++++++
svgio/qa/cppunit/data/tspan-fill-opacity.svg | 15 +++++++++++++++
svgio/source/svgreader/svgcharacternode.cxx | 19 +++++++++++++++++--
4 files changed, 57 insertions(+), 3 deletions(-)

Upstream: cgit.freedesktop.org


  • Share