[reportlab-users] SVG font-size values lack units (invalid CSS)

Robin Becker robin at reportlab.com
Mon Feb 16 12:59:08 EST 2009


Peter wrote:
........

>

> The images don't look identical to those from the PNG output from

> renderPM (the fonts sizes differ a little), but this does look pretty

> close and it now works on all the browsers I have tested.

>

well I just looked at the definitions currently being talked about for svg 1.1
and font-size appears here

http://www.w3.org/TR/SVG11/propidx.html

there the allowed value types for font-size are

<absolute-size> | <relative-size> | <length> | <percentage> | inherit


and following the link for length gives this definition



> <length>: A length is a distance measurement. The format of a <length> is a <number> optionally followed immediately by a unit identifier. (Note that the specification of a <number> is different for property values than for XML attribute values.)

> If the <length> is expressed as a value without a unit identifier (e.g., 48), then the <length> represents a distance in the current user coordinate system.

> If one of the unit identifiers is provided (e.g., 12mm), then the <length> is processed according to the description in Units.

> Percentage values (e.g., 10%) depend on the particular property or attribute to which the percentage value has been assigned. Two common cases are: (a) when a percentage value represents a percent of the viewport (refer to the section that discusses Units in general), and (b) when a percentage value represents a percent of the bounding box on a given object (refer to the section that describes Object bounding box units).

> Within the SVG DOM, a <length> is represented as an SVGLength or an SVGAnimatedLength.




I take the definition to allow font-size to be allowed not to be followed by a unit.

That said it's not at all obvious how these lengths should be properly interpreted.

For PDF the default coordinate system is certainly defined in point units ie
1=1pt. For our bitmaps we decided to make 1 pixel == 1point, but I believe you
can specify a dpi value. For SVG I'm not sure. According to

http://www.w3.org/TR/SVG11/coords.html#InitialCoordinateSystem

the SVG User agent (browser?) is supposed to set up the default view port and
the default coordinate system consistently so that 1unit=1pixel. That should be
consistent with our current usage. However, looking at the standard examples
it's obvious that SVG is not obeying these rules. I believe the default unit
should be pixels.

Has anyone else got any better ideas?
--
Robin Becker


More information about the reportlab-users mailing list