inkscape adds messed font family to style attribute

Bug #1029080 reported by darkweasel on 2012-07-25
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Medium
Tavmjong Bah

Bug Description

What I want to do is actually pretty simple: I created with Inkscape an SVG file with a lot of text in the DejaVu Sans font, which is not present on all systems, so I want these systems to use, generically, "sans-serif". To do this, I edited the file with a text editor and replaced all occurences of font-family:'DejaVu Sans'; with font-family:'DejaVu Sans',sans-serif; - which I believe is normally the correct way to do this.

When I edited (actually, just moved/changed alignments of) some text elements with Inkscape again, the font families on these elements were afterwards pretty messed up - this is what Inkscape generated:
font-family:'"DejaVu Sans", sans-serif'
This does not display correctly on systems where DejaVu Sans is not installed.

I tried to workaround this by adding a style element to the SVG file with the following content:
text {font-family: 'DejaVu Sans', sans-serif;}
and removing the font families on the elements themselves.

However, when editing these in Inkscape, it adds the messed up thing with " again. Or even worse, when exporting to plain SVG, it adds it to all elements in the file and removes the style element. I also tried removing the -inkscape-font-specification thngs in the style attributes, but this did not help.

Of course it may be possible for me to change these things again after exporting to plain SVG, but then I would have to do this after every change I make (I want to upload it to Wikimedia Commons as plain SVG).

I hope this bug report is comprehensible (I am not a native speaker of English) and not too rant-like, but all these efforts to get this working have now frustrated me pretty much, which is why I’m now filing a bug report.

I have attached a zip file with two SVG files. tramreto-skema.svg is the Inkscape SVG edited by hand, and tramlinioj en Vieno.svg is what Inkscape makes out of it - which displays in an ugly serif font on systems without DejaVu Sans installed.

Best regards.

darkweasel (darkweasel) wrote :
su_v (suv-lp) on 2012-07-27
tags: added: fonts
su_v (suv-lp) on 2012-07-27
tags: added: css
Tavmjong Bah (tavmjong-free) wrote :

Inkscape trunk (0.91) handles font family fallback lists better than 0.48. You can now directly enter a fallback list into the font-family name entry box in the Text toolbar.

Getting quoting to work properly is a work in progress. You actually don't need quotes around 'DejaVu Sans'. (Quotes are only needed under very special circumstances.)

There are several problems here:

1. Properties set in style sheets should not be written out in style attributes (style="...."). This should not be too hard to implement after the recent SPStyle work. I plan on introducing an enum to keep track of where a property is set.

2. Inkscape is automatically putting single quotes around 'font-family' and '-inkscape-font-specification', this means that quotes around individual family names must be double quotes (levels of quoting alternate between single and double quotes). But the style attribute in Inkscape uses double quotes (style="...") thus, according to XML (IIRC), the inner double quotes must be converted to ". The outer single quotes are not needed.

BTW, with trunk, you can clean up the SVG by enabling the removal of unneeded style properties under the Input/Output->SVG Output tab in the Inkscape Preferences dialog. (Make sure you have a backup before you try this as I don't know how well it has been tested.)

su_v (suv-lp) on 2014-08-08
Changed in inkscape:
importance: Undecided → Medium
milestone: none → 0.91
status: New → In Progress
assignee: nobody → Tavmjong Bah (tavmjong-free)
su_v (suv-lp) wrote :

Removing milestone for now, based on comment #2 («Getting quoting to work properly is a work in progress. (…)»).

Changed in inkscape:
milestone: 0.91 → none
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments