From e5cd30c6d0dc2896e86fa348cfb11470ecf38663 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 2 Apr 2021 21:21:27 +0200 Subject: [PATCH] SVG dimension text offset depending on scale --- src/serializers/SvgSerializer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/serializers/SvgSerializer.cpp b/src/serializers/SvgSerializer.cpp index 7650ac46c9..9971d3f148 100644 --- a/src/serializers/SvgSerializer.cpp +++ b/src/serializers/SvgSerializer.cpp @@ -1060,6 +1060,11 @@ void SvgSerializer::write(const geometry_data& data) { z_rotation -= 180; } + std::string text_offset = "8"; + if (scale_) { + text_offset = "1"; + } + util::string_buffer path; // dominant-baseline="central" is not well supported in IE. // so we add a 0.35 offset to the dy of the tspans @@ -1073,7 +1078,7 @@ void SvgSerializer::write(const geometry_data& data) { xcoords.push_back(path.add(center.X())); path.add(" "); ycoords.push_back(path.add(center.Y())); - path.add(") translate(0 -8)\">"); + path.add(") translate(0 -" + text_offset + ")\">"); std::vector labels{};