Quick way to remove px in text

If you remove this px in XML editor the font won’t resize when loaded into a FZ part. It saves using a text editor. Also every duplicate of that text won’t have the px either.

Also FZ won’t take Droid Sans fonts anymore. OCRA is fine.

Since when? Or maybe better, what context is the Droid Sans font not useable?

Not unless it was fixed in 0.9.4. :slightly_smiling_face: , I’ve got 0.9.3
I did a fresh download of the FZ template download.zip and installed the 5 fonts, and no matter what I try with any of the 3 Droid Sans fonts I always get the FZ part Edit error when loading that svg, in that it doesn’t like that font and will convert it. OCRA works fine using the same method.

Ah!, could be 0.9.3 specific, or parts editor specific. I have been using Droid Sans with 0.9.4, but have not been using part editor (or Inkscape much) to do it. Or it could be the way your svg editor is manipulating the text elements. I have been seeing cases (from FritzingCheckPart) where the fonts are being defined twice for elements. Once the normal svg way, and again with an inkscape specific extension. I have not any close checking, but it looks like the svg should work, since the normal font definition exists. The inkscape extension should be just ignored (or removed).

You know more about code than me :slightly_smiling_face:, but this code errors when loaded into FZ Edit

<text
     xml:space="preserve"
     style="font-size:36;line-height:6.61458px;font-family:'Droid Sans';-inkscape-font-specification:'Droid Sans, Normal';letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
     x="22.109161"
     y="42.882252"
     id="text3357"><tspan
       id="tspan3355"
       style="stroke-width:0.264583px"
       x="22.109161"
       y="42.882252">cat</tspan></text>
</svg>

This one is fine.

<text
     xml:space="preserve"
     style="font-size:36;line-height:6.61458px;font-family:OCRA;-inkscape-font-specification:'OCRA, Normal';letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
     x="7.1957135"
     y="46.110741"
     id="text3345"><tspan
       id="tspan3343"
       style="stroke-width:0.264583px"
       x="7.1957135"
       y="46.110741">cat</tspan></text>
</svg>

I don’t know if this is a thing, but text has a tspan in INK, whatever that is.
I think I remember the Droid problem from years ago, so i think I always used ORCA.
I guess it’s not a problem, because FZ fixes it in the FZ part EDIT when loading the svg.

tspan is standard svg. A way to have multiple sub strings in a text element. Used for things like multiple line text, or sometimes to change the size/font/etc of a single word.

Looking at examples in core parts that are using Droid Sans, they do NOT have the single quotes. Try it as:

<text
     xml:space="preserve"
     style="font-size:36;line-height:6.61458px;font-family:Droid Sans;-inkscape-font-specification:Droid Sans, Normal;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
     x="22.109161"

In 0.9.4, I successfully load in parts editor “XBee USB Mini Adapter” and “RFID Reader” after placing them in a sketch from core parts. Both use Droid Sans in (at least) breadboard view.

<text y="257.6214" fill="#ffffff" x="288.37717" gorn="0.3.0.0.18.0.0.5.0.0.0" id="tspan508573-3-7" stroke-width="10.41667175" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Droid Sans;-inkscape-font-specification:Droid Sans;letter-spacing:0;word-spacing:0;"  font-size="27.77781296">471</text>```
<text fill="#E6E6E6" font-family="Droid Sans" transform="matrix(1 0 0 1 21.5344 32.4695)" font-size="5" >Part</text>

Damn, I deleted those 4 quotes and now it works. Looks like INK adds the stuff FZ doesn’t like.

Changing the units in INK from px to mm or inch stops the FZ drawing rescale, so as a quick experiment to remove the px I tried it with text. I selected the “change/edit text” button in INK and changed the units in the toolbar to 36 mm(about 136px), and even though the units have changed it still adds the px to the code. In the code it shows 36px, and nowhere is there a 136px, so who knows how it’s actually drawing text 36mm high when it says 36px.

Another case. The “px” on the font-sizes is another. Neither of which is necessarily bad svg.

The units (mm or in) need to be on the height and width attributes of the svg element. Not on the text element. FZ wants bare numbers on the size in the text element. Which is not what svg says/allows. Here is an example, with the scaling set to mils (1000 px per inch).

So to change from px to real units, change the height and width attribute values of the svg header element to the number of “mm” or “in” that are equal to the number of pixels shown in the viewBox (for the whole image). Do not change the viewBox. Just width and height.

And remove the “px” from the attributes in the text elements.

<svg
  xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  version="1.2"
  baseProfile="tiny"
  x="0"
  y="0"
  width="1in"
  height="1in"
  viewBox="0 0 1000 1000"
>

That’s pretty much what they said. They said that somewhere else in the doc it’s set to 1mm per 1px, and that text is always px.

I can’t find that, but then again I don’t know code

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   width="97mm"
   height="65.75mm"
   viewBox="0 0 97 65.75"
   version="1.1"
   id="svg6"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <defs
     id="defs2" />

The quotes on some fonts seams to be std too, even though his example was a bit different.

https://inkscape.org/forums/beyond/text-xml-code-does-not-reflect-inkscape-setting/

The FZ template download has been around for ages and mustn’t of been causing problems with Illustrator, but with INK it’s a problem.

Droid Sans is driving me nuts.
This DOESN’T work

<text
     xml:space="preserve"
     style="font-size:36;line-height:6.61458px;font-family:Droid Sans Mono;-inkscape-font-specification:Droid Sans Mono, Normal;font-variant-ligatures:none;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
     x="10"
     y="50"
     id="text1362"><tspan
       id="tspan1360"
       style="stroke-width:0.264583px"
       x="10"
       y="50">cat</tspan></text>
</svg>

This DOES work

  <text
     xml:space="preserve"
     style="font-size:36;line-height:6.61458px;font-family:Droid Sans;-inkscape-font-specification:Droid Sans, Normal;font-variant-ligatures:none;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
     x="10"
     y="50"
     id="text1366"><tspan
       id="tspan1364"
       style="stroke-width:0.264583px"
       x="10"
       y="50">cat</tspan></text>
</svg>

The page you referenced is using the font-family attribute. There, the «double» quotes are needed any time the font name has spaces in it. That matches the second text example I showed earlier. Your sample, and my first example are using the style attribute. For that, the whole attribute value, which includes the font-family as a sub element, is surrounded by double quotes. Those quotes mean that the extra quotes around the font family name are not needed (though standard svg allows it). When I am working in mm, I usually set the scaling to to be 1mm for 100px. either (or many more combinations) works, as long as the coordinates and sizes in the image match.

The font-size (and other) values will always be in pixels, but FZ does not want the “px” units to be specified. No “px” wanted in the svg file. I think that is what you meant, but the wording left it open to put the px on the font-size (and other) values, which FZ does not handle properly.

“Droid Sans Mono” is not the same font as “Droid Sans”. For FZ, I never use anything except “Droid Sans” and “OCRA”.

The problem is that “Droid Sans Mono” is a supposedly usable font in the FZ templates download.zip. Someone needs to delete that.
https://fritzing.org/learning/tutorials/creating-custom-parts/download-fonts-and-templates

I’m struggling with this :slightly_smiling_face:, I don’t think I can get beginners to go that fancy.
The problem is that if I can’t dumb it down and make stuff simple in my vids, there’s not much chance of getting beginners to make parts - it’s why we are always making parts for people -, so I need to show the easiest way.

Well at least after 4 years I kinda now know how fonts work. :slightly_smiling_face:

My process is for fixing up a file that was created and saved with units as px, with an “assumed” number of px per inch. Or for manually creating an svg from scratch. I have seen other processes to calculate and modify the height and width values to get to the same place. Using different tools. The preferred way is to tell the editor (Inkscape, Illustrator, etc) what the units are to start with, and let it deal with them from then on. My notes belong in a reference someplace, on how to fix things up after they went wrong. Which is probably not part of your videos, except as a reference to the forum here and wiki.

My process for scaling is actually very simple … if you are used to working with plain text files (not just word processor documents). It is a matter of setting 2 values, with the unit string added to the end, based on 2 other numbers. All of which are in the first few lines of of the svg file. Removing the px units from the rest of the file is separate, and can be done many ways, using many tools. A search and replace with a text editor is one way, and again is simple, if you are used to that sort of tool. Well, that and understand that an svg image is a normal text file, that is nothing like a jpeg, or other bitmap format.

That’s the way I’m teaching people to use INK, ie, use mm or inch not px, it’s just text that is the problem.

If you think about FZ it’s kind-of a dichotomy, ie, it looks simple and intuitive to use - what’s simpler than seeing the object you are holding -, yet part making is the total opposite, ie, not for beginners. I basically want to dumb down and shorten these vids so people will actually watch them. Basically beginners have short attention spans and start knowing nothing.

I know what it’s like being a total blank newby, like when I started serious hobby electronics 4 years ago I tried doing an automotive Arduino ECU, and when I was reading how to do it, 50% of the words in each sentence I didn’t understand - I didn’t not even know what a pull-up meant -. I figure part making is going to put a lot of people off FZ, so rather than them trial & error it - that’s how I did it because there was no one here 4 years ago to ask -, I figured I’ll just show the easy way once rather than explaining the same thing 100 times - I probably spent 1000hrs here helping, and 90% of it is probably repeating the same thing -. Sorry just having a vent :slightly_smiling_face:

Well that sux. As soon as you move the duplicate of the text it puts the px and quotes back. :face_with_symbols_over_mouth:

One case of this (which is a problem if left alone) is if font-size is inline and then converted (by Inkscape) to a style command. Inkscape leaves the inline font-size definition but no longer updates it so if you have

font-size=“25px”
style("font-size:35px;…

Inkscape will render fontsize 35 from the style and Fritzing will render fontsize 25 from the inline (ignoring the style.) Check part uses the one from style and deletes the inline to avoid this (as well as removing the px.)

I think your problem here is missing quotes.

font-family:‘Droid Sans’;

wants to be

font-family:"‘Droid Sans’";

to work I think. Something (likely Frtizing) wants the single quotes quoted for some reason. There is also another version of DroidSans without the space, but it has a different spacing when rendered in Fritzing so I avoid it (it is scheduled to get complained about when I manage to finish the new version of check part.)

Peter

I’ve totally given-up on Droid Sans, in my tutorial I’m telling people to ignore it and let FZ fix it when you bring the svg into parts editor, and not worry about the warning. :slightly_smiling_face:

Does FritzingCheckPart automatically remove the px in one hit.

That font-family specification is part of a style attribute, which already has the double quotes around the whole style string. Another set of double quotes in the middle of that breaks things. In the style string, no extra quotes are need to handle the font name with embedded spaces. The outer style quotes are enough. Tested it. svg allows using the single quotes inside of the double quoted string, but it works (in Inkscape and my viewer program) without. Fritzing chokes if they are there.