Re: SVG with pixel (not points) sizes?

Simon Sapin <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Le 16/08/2012 16:00, Behdad Esfahbod a écrit :
> In HarfBuzz someone's requesting that I let them generate SVG files that have
> pixel sizes, not points.  We currently don't have API for that in cairo.  Is
> it feasible to add?
>
> I have not actually checked what the SVG spec allows, but apparently browsers
> allow that...

Hi,

In SVG the width and height attributes are of <length> type and accept a 
number of units, pt and px among them. If I’m reading the spec 
correctly, 1pt is always 1.25px so you should be able to just divide a 
pixel size by 1.25 before giving it to cairo.

http://www.w3.org/TR/SVG/struct.html#SVGElementWidthAttribute
http://www.w3.org/TR/SVG/types.html#DataTypeLength
http://www.w3.org/TR/SVG/coords.html#Units


em and ex aside, all units have a fixed ratio with each other:

1in = 72pt = 6pc = 2.54cm = 25.4mm = 90px

(The spec uses px as the base unit but the ratio are the same.)

The weird thing is that in CSS the ratio are the same, except for px:
1in = 96px

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

...

I did some testing after writing the above. Gecko, WebKit and Opera use 
96px/in, Inkscape, rsvg and ImageMagick use 90 :/

-- 
Simon Sapin

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
units.svg (image/svg+xml, 736 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.