Summary: | SVG export text often stretches beyond rectangle (class diagram) | ||
---|---|---|---|
Product: | [Applications] umbrello | Reporter: | 1234ab <nevenincs007> |
Component: | exporter | Assignee: | Umbrello Development Group <umbrello-devel> |
Status: | REPORTED --- | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 2.33.2 (KDE releases 20.12.2) | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
original image (png export, looks like how it should)
svg image, in svg format difference between Inkscape and Gwenview (not a problem this time but may be other times) Trying out the lengthAdjust property, svg format lengthAdjust property in Firefox and gnome image viewer |
Description
1234ab
2022-04-22 19:54:59 UTC
Created attachment 148309 [details]
svg image, in svg format
Created attachment 148310 [details]
difference between Inkscape and Gwenview (not a problem this time but may be other times)
But with all of the apps I looked at (except maybe Gimp, it looks like everything fits there, and except Krita, there it reaaally doesn't fit, like a third of the text is outside), e.g. Console::hMeter's last 2 characters are outside it's a shame, because otherwise svg's are much better then rasterizing them (select text, high resolution, etc.) related: https://bugs.kde.org/show_bug.cgi?id=349234 so I don't know what settings (inside an svg) are available to solve this, I don't think it's a great idea to make the box longer (it looks pretty good this way, it's exactly the same as the png export version) it would also probably be a bad idea to make the text 1 point smaller when exported with svg, because of the same reason the best would probably be something like making the letters take up 3-4% less space horizontally in the svg export (while staying the same font and size), but probably there isn't a way to do that in svg, idk I think I found something useful, https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/lengthAdjust I'll try to experiment with it, if I can get it to work Created attachment 148344 [details]
Trying out the lengthAdjust property, svg format
Here I tried out that property, added it to 2 text elements: to "KEY_DOWN: const int" and to the hMeter method (the longest). The first one should now be exactly the same size as the underline, and the second should fit into the box
I tried this with the Gnome image viewer (it didn't work), and Firefox (it did work)
I'll attach screenshots
also, it looks like something is very different from how it looks on KDE, idk what (it looks like even noto sans is available here too)
Created attachment 148345 [details]
lengthAdjust property in Firefox and gnome image viewer
after quite a bit of clicking, I found the method we'd need to override, though it doesn't seem easy https://code.woboq.org/qt5/qtsvg/src/svg/qsvggenerator.cpp.html#_ZN15QSvgPaintEngine12drawTextItemERK7QPointFRK9QTextItem in this method we could add the 2 tags (textLength and lenghAdjust), and the actual length could be gotten like this: https://code.woboq.org/qt5/qtbase/src/gui/painting/qpainter.cpp.html#6492 (`ti.width`), though maybe it needs to be transformed somehow adding to the compatibility list, this svg file that I posted on 2022-04-24 18:52 UTC, the one that I modified by hand and added 2 textLengths and lengthAdjusts, works well in: LibreOffice, Falkon, FIrefox, Inkscape doesn't work (shows as if I didn't do any modifications): Gnome Image Viewer (eye of gnome is the real name? dunno), Gwenview, KolourPaint (whatever that is), GIMP so it seems like applications supporting these properties is a hit or miss, though I think it's still worth thinking about also about LibreOffice: it literally displays them in different lengths based on how much I zoom in, and there's like at least 20-30% length difference XD; however with these properties it always has the correct length librsvg, which EOG uses, plans to implement support: https://gitlab.gnome.org/GNOME/librsvg/-/issues/838 here is the related thing from the qt side: https://bugreports.qt.io/browse/QTBUG-79042 (they only claim to support tinysvg 1.2, while these need 1.1 and the full version) gwenview (and kolourpaint) depend on libqt5svg (which I assume means that they use it for svg import) and gimp if I found correctly seems to use a custom script https://github.com/GNOME/gimp/blob/708f075f804caa5cbd11cae2f85f3726456aedcb/plug-ins/common/file-svg.c |