[cairo] SVG output without "pt" in the coordinates - how?
emmanuel.pacaud at lapp.in2p3.fr
Fri Oct 24 06:28:55 PDT 2008
Le vendredi 24 octobre 2008 à 08:10 -0400, Behdad Esfahbod a écrit :
> > Can this be done in any other way than cutting the "pt" simply off in
> > the output filter function? That seems rather harsh.
> > Is there a reason behind only supporting one mode (SVG allows "em, ex,
> > px, pt, pc, cm, mm, in, and percentages")
As cairo doesn't have any notion of units, I don't see the point in
allowing the use of different units in the SVG output.
> , or is it simply how it is
> > for now?
> I'm pretty SVG-illiterate, so bear with me. What's the unit the viewBox and
> the body content coordinates are expressed in? If that's always points, then
> I think cairo is doing the right thing.
> For most of the physical units SVG allows (pc, cm, mm, in), it's a matter of a
> fixed ratio to pt. I don't know what the percentage refers to. I also don't
> know what the font-specific units em and ex refer to. For px, again, it's
> probably assuming a 72dpi device? In which case it's the same as pt.
>From the SVG specification:
"the em and ex unit identifiers are relative to the current font's
font-size and x-height, respectively."
"The other absolute unit identifiers from CSS (i.e., pt, pc, cm, mm, in)
are all defined as an appropriate multiple of one px unit (which,
according to the previous item, is defined to be equal to one user
unit), based on what the SVG user agent determines is the size of a px
unit (possibly passed from the parent processor or environment at
initialization time). For example, suppose that the user agent can
determine from its environment that "1px" corresponds to
"0.2822222mm" (i.e., 90dpi). Then, for all processing of SVG content:
* "1pt" equals "1.25px" (and therefore 1.25 user units)
* "1pc" equals "15px" (and therefore 15 user units)
* "1mm" would be "3.543307px" (3.543307 user units)
* "1cm" equals "35.43307px" (and therefore 35.43307 user units)
* "1in" equals "90px" (and therefore 90 user units)
In the SVG files produced by cairo, the use of the viewbox attribute
makes "pt" the default unit, instead of "px".
If you want to render these files with 1 px = 1 pt, just set the ppi of
your renderer to 72.
More information about the cairo