[cairo] SVG with pixel (not points) sizes?
behdad at behdad.org
Thu Aug 16 09:09:21 PDT 2012
On 08/16/2012 11:07 AM, Simon Sapin wrote:
> 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.
That's not true.
> em and ex aside, all units have a fixed ratio with each other:
> 1in = 72pt = 6pc = 2.54cm = 25.4mm = 90px
No. The 90px is an example. The text says:
"For example, suppose that the user agent can determine from its environment
that "1px" corresponds to "0.2822222mm" (i.e., 90dpi)."
The user agent may determine that the display is 140dpi, then 140px=1in.
> (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 :/
CSS pixels are different, and hardcoded at 96dpi. Not SVG from what I
understand. And definitely not SVG "user units".
More information about the cairo