RichAnno scrambled on SVG export

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

RichAnno scrambled on SVG export

Post by uwestoehr »

- open this example file:
TD-test.FCStd
testfile
(138.06 KiB) Downloaded 46 times
- use the menu TechDraw -> Export page as SVG

result:
td-test.svg
SVG result
(138.39 KiB) Downloaded 66 times

As you can see, the RichTextAnno is scrambled in the SVG.

- now use the menu File -> Export PDF

result: everything looks fine:
td-test.pdf
PDF result
(187.61 KiB) Downloaded 41 times
This issue is independent in the SVG namespace issue.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: RichAnno scrambled on SVG export

Post by wandererfan »

uwestoehr wrote: Sat Feb 01, 2020 10:00 pm As you can see, the RichTextAnno is scrambled in the SVG.
The font size for RTA is being written in "user coordinates" (10x in our case), but being interpreted as "absolute coordinates" when read.

Not sure why plain Annotation is not affected by this.

Will have to change the way RTA font size is written to Svg.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: RichAnno scrambled on SVG export

Post by wandererfan »

uwestoehr wrote: Sat Feb 01, 2020 10:00 pm As you can see, the RichTextAnno is scrambled in the SVG.
2 of 3 issues (text size & position) fixed by this git commit d68fcb8cc5.

If I've understood what I read, there is no easy fix to the line spacing problem. We'll need
to split the text into individual lines and position each one separately.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: RichAnno scrambled on SVG export

Post by uwestoehr »

wandererfan wrote: Wed Feb 05, 2020 12:41 am 2 of 3 issues (text size & position) fixed by this git commit d68fcb8cc5.
I tested and this is what I get now:
actual result
actual result
firefox_WGGBqjAb7u.png (11.15 KiB) Viewed 1340 times

This is what I got before your commit:
former result
former result
firefox_v6VKy3gfHV.png (13.61 KiB) Viewed 1340 times

Here is the SVG for the box as it should look:
TD-test-correct-box.svg
SVG of only the correctly-looking box
(35.04 KiB) Downloaded 57 times
(I exported the TD page to PDF, then opened the PDF with Inkscape, cleaned it up and saved it as plain SVG.) This SVG shows correct on all 3 browsers I can test (Chrome, Firefox and Edge). This should helps us to find out how to export the RichText box to SVG.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: RichAnno scrambled on SVG export

Post by Kunda1 »

Can we make TechDraw unit test to spot any future regressions of RichTextAnno ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: RichAnno scrambled on SVG export

Post by wandererfan »

Kunda1 wrote: Wed Feb 05, 2020 3:54 pm Can we make TechDraw unit test to spot any future regressions of RichTextAnno ?
Open to suggestions. Not sure how unit test will tell if result "looks right".
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: RichAnno scrambled on SVG export

Post by wandererfan »

uwestoehr wrote: Wed Feb 05, 2020 11:05 am (I exported the TD page to PDF, then opened the PDF with Inkscape, cleaned it up and saved it as plain SVG.) This SVG shows correct on all 3 browsers I can test (Chrome, Firefox and Edge). This should helps us to find out how to export the RichText box to SVG.
The problem is that we don't make the Svg in the case of RichTextAnno. We rely on a chain of QTextEdit/QTextDocument/QSvgGenerator and I don't know how many other Qt routines to produce Svg that is equivalent to the original rich text.

I'm leaning towards exporting the RichTextAnno as plain text. This seems to be reliable in terms of delivering a useful result, but of course most of the formatting is lost. That seems better than delivering corrupted text.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: RichAnno scrambled on SVG export

Post by wandererfan »

uwestoehr wrote: Sat Feb 01, 2020 10:00 pm As you can see, the RichTextAnno is scrambled in the SVG.
This commit git commit f00fca547 changes Svg export of RichTextAnno to use plain text. Plain Text appears in approximately the right place on the page and is easily changed in Inkscape.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: RichAnno scrambled on SVG export

Post by uwestoehr »

wandererfan wrote: Fri Feb 14, 2020 12:57 pm This commit git commit f00fca547 changes Svg export of RichTextAnno to use plain text. Plain Text appears in approximately the right place on the page and is easily changed in Inkscape.
But this does destroy the rich text feature and when inserting rich text, I explicitly want this. :?
If there is no border, OK, but now the text size, shape and decorations are all lost. So in fact it is a plain text annotation.

There is also a regression because when you open the example file of my initial commit you get on opening this error:

Code: Select all

Reading failed from embedded file: PartShape8.brp (133002 bytes, 49082 bytes compressed)
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: RichAnno scrambled on SVG export

Post by wandererfan »

uwestoehr wrote: Fri Feb 14, 2020 3:17 pm But this does destroy the rich text feature and when inserting rich text, I explicitly want this. :?
If there is no border, OK, but now the text size, shape and decorations are all lost. So in fact it is a plain text annotation.
At the moment, the choice is between scrambled rich text or plain text. Rich text to Svg isn't on the table.
There is also a regression because when you open the example file of my initial commit you get on opening
this error:

Code: Select all

Reading failed from embedded file: PartShape8.brp (133002 bytes, 49082 bytes compressed)
Not sure what this means. We don't read any brep files in TD.
Post Reply