[SOLVED]New SVG graphics with text are an utter disaster in Firefox

Discussions about the wiki documentation of FreeCAD and its translation.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

[SOLVED]New SVG graphics with text are an utter disaster in Firefox

Postby NormandC » Sat Apr 20, 2019 2:16 am

Couldn't you test in other browsers before implementing this? Apparently this is caused by my Firefox profile for unknown reasons. Sorry for the noise. :roll: at myself

This is a HUGE usability issue.

Feature_editing#Different_sketches

Screenshot from Firefox 66.0.3:
FC_wiki_SVG_fucked_up_in_FF_01.png
FC_wiki_SVG_fucked_up_in_FF_01.png (82.96 KiB) Viewed 551 times
Last edited by NormandC on Sat Apr 20, 2019 5:37 pm, edited 6 times in total.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: New SVG graphics with text are an utter disaster in Firefox

Postby NormandC » Sat Apr 20, 2019 2:42 am

Yorik wrote:ping
kkremitzki wrote:ping
Any idea if this is fixable? The old SVG image for the Basic Part Design Tutorial had the same issue, which is why I switched it to a PNG image. This is the SVG: https://www.freecadweb.org/wiki/File:Tu ... _Sheet.svg

I could only find this thread on Stack Overflow: https://stackoverflow.com/questions/458 ... fox-and-ie
But contrary to what they say, this is still an issue in FF 66.0.3.
galou_breizh
Posts: 319
Joined: Wed Sep 15, 2010 9:38 am

Re: New SVG graphics with text are an utter disaster in Firefox

Postby galou_breizh » Sat Apr 20, 2019 7:29 am

I have no issues on Firefox v66 and Ubuntu 18.04.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: New SVG graphics with text are an utter disaster in Firefox

Postby NormandC » Sat Apr 20, 2019 7:33 am

Please post a screenshot.
User avatar
kkremitzki
Posts: 1987
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: New SVG graphics with text are an utter disaster in Firefox

Postby kkremitzki » Sat Apr 20, 2019 5:00 pm

NormandC wrote:
Sat Apr 20, 2019 2:16 am
Couldn't you test in other browsers before implementing this???
I haven't made any changes to the wiki recently, could you provide more context on what brought this issue about?
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: New SVG graphics with text are an utter disaster in Firefox

Postby NormandC » Sat Apr 20, 2019 5:12 pm

Sorry if I wasn't clear, the whole topic is about new SVG files on the wiki added by vocx. The SVG files contain text, and in Firefox the text is blown up out of proportion.

I pinged you since you're pretty knowledgeable about the wiki.

See how one SVG displays in Firefox, compared to Chromium:

Firefox
Image


Chromium
FC_wiki_SVG_OK_in_Chromium_01.png
FC_wiki_SVG_OK_in_Chromium_01.png (71.71 KiB) Viewed 495 times
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [SOLVED]New SVG graphics with text are an utter disaster in Firefox

Postby NormandC » Sat Apr 20, 2019 5:32 pm

galou_breizh wrote:
Sat Apr 20, 2019 7:29 am
I have no issues on Firefox v66 and Ubuntu 18.04.
As I was puzzled with this reply, and too impatient to wait for Galou's screenshot, I thought of creating a fresh Firefox profile. The SVG files display properly sized text inside SVG files. :?

A quick examination of my own profile's preferences VS. the fresh one don't show anything different regarding text size.

I remain puzzled. Will search further. Sorry for the noise.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [SOLVED]New SVG graphics with text are an utter disaster in Firefox

Postby NormandC » Sat Apr 20, 2019 5:46 pm

I don't know if the original intent was to make images that can be translatable; but it's a good thing, intended or not. I'll be able to edit the SVG files in Inkscape to translate relevant text strings.
vocx
Posts: 4081
Joined: Thu Oct 18, 2018 9:18 pm

Re: [SOLVED]New SVG graphics with text are an utter disaster in Firefox

Postby vocx » Mon Apr 22, 2019 6:37 pm

NormandC wrote:
Sat Apr 20, 2019 5:46 pm
I don't know if the original intent was to make images that can be translatable; but it's a good thing, intended or not. I'll be able to edit the SVG files in Inkscape to translate relevant text strings.
SVGs are preferred for simple diagrams that include text because they are vector images and can be scaled without loss of detail. They can be made bigger or smaller and they won't distort like bitmap images (PNG, TIFF, JPEG). Also, SVGs are text files, so they are smaller than bitmaps for an image of equivalent size and resolution; for example, a PNG of 400 KB, may be only 35 KB in SVG. This may not be a problem for small files, but when you have thousands of images it may save significant space to use SVG. In particular, FreeCAD's documentation could be smaller if SVGs are used instead of bitmaps (whenever it makes sense, of course).

SVG can also be opened and edited in a program like Inkscape to fix things, precisely like changing or translating strings.

If you are going to translate the strings, I recommend you check that you have a <text> element in your SVG. The actual code produced by Inkscape is something like this, <text><tspan>Actual text here</tspan></text>.

Code: Select all

<text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       x="83.119522"
       y="-16.792206"
       id="text20531-6"><tspan
         sodipodi:role="line"
         id="tspan20529-0"
         x="83.119522"
         y="-16.792206"
         style="font-size:3.52777767px;stroke-width:0.26458332px">Solid</tspan></text>
I have experienced some issues with the text tool of Inkscape. If you just click on the page, it will create a text-tspan element; however, if you drag a box to create text, it may create the following structure <flowRoot><flowRegion><rect /></flowRegion><flowPara>Actual text here</flowPara></flowRoot>.

Code: Select all

<flowRoot
       xml:space="preserve"
       id="flowRoot1999"
       style="font-style:normal;font-weight:normal;font-size:15px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       transform="scale(0.26458333)"><flowRegion
         id="flowRegion2001"><rect
           id="rect2003"
           width="108.57143"
           height="57.142857"
           x="215.71428"
           y="233.94826" /></flowRegion><flowPara
         id="flowPara2007">Some flow text</flowPara></flowRoot>
In my experience, these flowRoot-flowPara nodes don't display quite well in different viewers and maybe also browsers, so I suggest you avoid them, and use the text-tspan combination instead.

--------

As to why the file Tutorial_Drawing_Sheet.svg may have looked wrong before, it's hard to tell. It's an SVG file generated from TechDraw, which uses the Qt functions to generate SVG. These functions may have added some transformations to the elements of the SVG.

Code: Select all

transform="rotate(-60.0,200.0,150.0) translate(200.0,150.0) scale(4.0,-4.0)">
These transformations may cause problems when displaying the SVG in different viewers, so they should be avoided. In this case, the SVG should be manually edited to remove transformations and see if that fixes the display issue. It's hard work of course.
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [SOLVED]New SVG graphics with text are an utter disaster in Firefox

Postby NormandC » Wed Apr 24, 2019 3:25 am

vocx wrote:
Mon Apr 22, 2019 6:37 pm
As to why the file Tutorial_Drawing_Sheet.svg may have looked wrong before, it's hard to tell. It's an SVG file generated from TechDraw
No, it was made in the old Drawing workbench. Look at the date of creation, it was uploaded in 2014.

This SVG displays correctly now with a new Firefox profile. I had migrated the same FF profile over multiple Ubuntu versions, it may be 5 years or more old...