length unit in svg output

Post questions on how to use or achieve an effect in Inkscape.
triplett
Posts: 2
Joined: Mon Dec 08, 2014 2:07 pm

length unit in svg output

Postby triplett » Mon Dec 08, 2014 2:29 pm

I need an SVG editor to make minor changes to svg files generated by another program (gramps). The result will be displayed on the web as SVG.

Inkscape seems to work well, except that the length unit in the output is always in units of pixels, even if I select cm as the unit in document properties.
The file from gramps uses cm, and pt for text. if I just open the file
with inkscape and write it out again, this is unchanged. But as soon as I alter anything all dimensions change to px.

The text gets smaller relative to other elements as it changes from 14pt to 14 px. Should I file a bug report for this?
Fortunately for my purposes it is fairly easy to fix with a global search and replace in a text editor.

Non-text elements appear the correct size on my computer, but it needs to display on systems with any pixel size. Also, it will displayed on the same page as.html

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: length unit in svg output

Postby tylerdurden » Mon Dec 08, 2014 11:17 pm

Try the new pre-release?

Sizing1.jpg
Sizing1.jpg (177.31 KiB) Viewed 3191 times


Sizing1.svg
(3.4 KiB) Downloaded 270 times


Code for above svg document (easy to view SVGs in text editors like TextPad).
NB units and text size:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="10cm"
   height="10cm"
   id="svg2"
   version="1.1"
   inkscape:version="0.91pre2 r13516"
   viewBox="0 0 9.9999997 9.9999997"
   sodipodi:docname="Sizing1.svg">
  <defs
     id="defs4" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="1.9021778"
     inkscape:cx="173.38755"
     inkscape:cy="175.09948"
     inkscape:document-units="cm"
     inkscape:current-layer="layer1"
     showgrid="false"
     units="cm"
     inkscape:window-width="1037"
     inkscape:window-height="773"
     inkscape:window-x="163"
     inkscape:window-y="72"
     inkscape:window-maximized="0" />
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-698.03154)">
    <text
       xml:space="preserve"
       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:0.39511113pt;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, 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"
       x="0.91988134"
       y="699.41138"
       id="text4137"
       sodipodi:linespacing="125%"><tspan
         sodipodi:role="line"
         x="0.91988134"
         y="699.41138"
         id="tspan4141">v.91: Text can be set to points</tspan></text>
    <rect
       style="opacity:1;fill:#00ffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       id="rect4145"
       width="7.4999995"
       height="1.5"
       x="1.3501484"
       y="705.58344" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:0.31044445pt;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, 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"
       x="1.4391689"
       y="706.28082"
       id="text4147"
       sodipodi:linespacing="125%"><tspan
         sodipodi:role="line"
         id="tspan4149"
         x="1.4391689"
         y="706.28082">Page default units, objects can be set </tspan><tspan
         sodipodi:role="line"
         x="1.4391689"
         y="706.76587"
         id="tspan4151">to cm, in., etc...  ----&gt;</tspan></text>
  </g>
</svg>


also, FWIW, Points are generally 72/in. Px in Inkscape are 90/in.

Chime back and let us know how this might help or not... :D
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

triplett
Posts: 2
Joined: Mon Dec 08, 2014 2:07 pm

Re: length unit in svg output

Postby triplett » Sat Dec 13, 2014 10:38 am

Thanks for the answer. I will try the new version, but in the meantime I have read the css 2 standard and realized that
they have redefined a pixel to be an absolute unit of size.

from http://www.w3.org/TR/CSS21/syndata.html#length-units
4.3.2 Lengths

Absolute length units are fixed in relation to each other. They are mainly useful when the output environment is known. The absolute units consist of the physical units (in, cm, mm, pt, pc) and the px unit:

in: inches — 1in is equal to 2.54cm.
cm: centimeters
mm: millimeters
pt: points — the points used by CSS are equal to 1/72nd of 1in.
pc: picas — 1pc is equal to 12pt.
px: pixel units — 1px is equal to 0.75pt.
---
For lower-resolution devices ... it is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel.
...
Note that this definition of the pixel unit and the physical units differs from previous versions of CSS. In particular, in previous versions of CSS the pixel unit and the physical units were not related by a fixed ratio: the physical units were always tied to their physical measurements while the pixel unit would vary to most closely match the reference pixel. (This change was made because too much existing content relies on the assumption of 96dpi, and breaking that assumption breaks the content.)


As far as I can figure out,
This means it does not matter if inkscape converts everything to pixels (apart from the errors in the conversion). Regardless of what units the svg uses,
they should be equivalent to the units in html. Everything on the screen WILL get bigger or smaller depending on the pixel size of the screen, unless this size is an exact multiple or submultiple of 0.75pt, but the change in size will be similar for the svg and html. I say similar because svg allows fractions of a pixel, unlike html, so there will be a difference of +/- 1 device pixel due to rounding - this could maybe make a visible difference to very small lengths such as line widths, I suppose.

I am sure other people have figure this all out years ago, I am very new to the game.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: length unit in svg output

Postby Lazur » Sat Dec 13, 2014 11:03 am

In the release notes of the upcoming 0.91, em units will be supported by the text tool.
Responsive designing may not be far away.
But who knows? It would mean to render the same vector image to different screen pixels on different displays. My guess is that there will be soon some standard like video codecs. And more problems on hinting the fonts.
At least until all screens will have today's printer's resolution.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: length unit in svg output

Postby ragstian » Sat Dec 13, 2014 11:26 am

Hi.

Lazur;
At least until all screens will have today's printer's resolution.


It's getting closer, my 15" laptop screen's resolution is 3840 x 2160 pixels which translates into approximately 280 pixels per inch.
Hard to see individual pixels.

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar


Return to “Help with using Inkscape”