Page 1 of 1

Remove px in font style

Posted: Fri Oct 21, 2016 7:49 pm
by Old Grey
Is there another way to do fonts so that the style doesn't have px in it?

We import svgs into a electronics circuit program called Fritzing as part pictures, but every time we try to add text to them, or touch any text already in the drawing, Inkscape adds all these extra artifacts that confuse Fritzing so that they lose their format and become tiny.

What someone figured out was that if we remove the px's it accepts them.

This is what it is before, and FZ accepts, in Inks XML Editor
class text
fill #8c8c8c
font-family 'Droid Sans'
font-size 0.881944
id text83
stroke none
stroke-width 0
text-anchor middle
x 0
y 0

Rotate that same text 90ยบ and
class text
font-size 0.881944
id text83
style font-size:0.881944px;font-family:'Droid Sans';text-anchor:middle;fill:#8c8c8c;stroke:none;stroke-width:0
transform matrix(0,-0.99999987,1.0000001,0,0,0)
x 0.32448483
y 0.3141495

Just trying to type some text you get something like this.

font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.41111481px;line-height:125%;font-family:'Droid Sans';-inkscape-font-specification:'Droid Sans, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1

Re: Remove px in font style

Posted: Sat Oct 22, 2016 12:57 am
by tylerdurden
I'm not sure if Inkscape will have a way to change the output units in the xml.

For the time being, you could zap the px from your documents en-masse with a text editor like Textpad.

Re: Remove px in font style

Posted: Sat Oct 22, 2016 5:00 am
by Old Grey
I was hopping you wouldn't say that, as it's what we have to do now.

Code: Select all

style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5px;line-height:125%;font-family:'Droid Sans';-inkscape-font-specification:'Droid Sans, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"

We have to manually delete every px.

I think the original part was made with Coral Draw when it was free, which was fine, but now that we have switched to Ink text is a problem.

Re: Remove px in font style

Posted: Sat Oct 22, 2016 8:00 am
by tylerdurden
By manually, I hope you don't mean one-by-one... a good text editor program should be able to find and replace (replaced in this case with nothing), even across documents.

FWIW, this may go back to the way units are handled in Inkscape, svg and css. AIUI, svg does not require explicit unit identifiers (e.g. px) but css does.. so to be css compliant, Inkscape adds the identifier. ( I could be way off on this, maybe a dev can chime in.)

There was a point I think, when setting the text units in preferences also wrote the selected unit identifier in the xml (e.g. pt), but that was in a development build.

If I understand correctly, the optimal xml for this case would have no unit identifier (no px, pt, em, mm, etc.)?

Re: Remove px in font style

Posted: Sat Oct 22, 2016 10:43 am
by Old Grey
I'm no expert, and only found out you can open a svg with Wordpad this morning, so yes one by one.

Yeah, it always seams to add that px.

I tried Edit/Preferences/Text to mm, but it stays px.

We also have to save it as Plain svg, so I don't know if there is another svg we can save it as to strip the px.

I don't know much about coding or svg - only heard they existed not long ago -, so I have to defer to the experts.

Re: Remove px in font style

Posted: Sat Oct 22, 2016 11:47 am
by tylerdurden
Ok, that's progress.

I suggest editing xml with a programmer's text editor (I use an older "free" version of Textpad... http://www.textpad.com/download/textpad45.html ).

Text editors are optimized for this kind of work and so much better than wordpad. One perk is the ability to find and replace across documents, so you could remove "px" from many at once if you like.

TextPad_2016-10-21_21-26-34.png
TextPad_2016-10-21_21-26-34.png (50.24 KiB) Viewed 3418 times

Re: Remove px in font style

Posted: Sat Oct 22, 2016 12:50 pm
by Moini
For the next version, there is this in the release notes:
"Units are now recognized in the text and tspan 'x', 'y', 'dx', and 'dy' attributes."

Not sure if that would help, but it sounds like it could at least be related...

see http://wiki.inkscape.org/wiki/index.php ... VG_and_CSS

Re: Remove px in font style

Posted: Sat Oct 22, 2016 9:21 pm
by Old Grey
I'm no expert so I don't know, but according to tylerdurden I need the CSS conformity stripped from the svg.

I tried the Optimised svg with the CSS converted to XML, but the px is still there.

Ink is so technical for a beginner like me that I don't really understand what most of it does.

Re: Remove px in font style

Posted: Sat Oct 22, 2016 10:55 pm
by tylerdurden
Nice thing, is that Inkscape is open and "text"... you CAN use a text editor to modify the files, and it's pretty easy in this case.

Future versions, or custom versions might offer the option of no inline unit identifiers.

From a developer discussion:
There are two practical approaches for dealing with units in SVG:

1. Set the overall scale using the SVG root 'width'/'height' and 'viewBox' attributes and don't use absolute units inside the SVG file. Example: <svg width='20mm' height="20mm' viewBox="0 0 20 20" ...>. Here one 'user unit' is fixed to have a real world value of 1mm.

2. Fix the overall scale to '1' by using the same values for the SVG root 'width'/'height' and 'viewBox' attributes. Example: <svg width="200" height="200" viewBox="0 0 200 200". Here lengths using absolute unit identifiers will have their expected meanings inside the file. (Except Inkscape 0.91 and earlier uses incorrectly 90px per inch.)


My guess (and I'm really not knowledgeable here) is that while many folks are using Inkscape as an all-purpose vector illustration tool, SVG is primarily a web graphic format, and compliance with CSS is a priority. If both methods above are compliant, maybe Inkscape could be built to make the method user-selectable.