[cairo] SVG with pixel (not points) sizes?

Simon Sapin simon.sapin at exyr.org
Thu Aug 16 08:07:52 PDT 2012

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...


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.


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



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

Simon Sapin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: units.svg
Type: image/svg+xml
Size: 735 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120816/821a8012/attachment.svg>

More information about the cairo mailing list