- From: Chris Lilley <chris@w3.org>
- Date: Mon, 27 Jan 2014 07:59:51 +0100
- To: Paul LeBeau <paul.lebeau@gmail.com>
- CC: www-svg <www-svg@w3.org>
Hello Paul,
Monday, January 27, 2014, 6:03:16 AM, you wrote:
> So it turns out that Adobe InDesign - before SVG export was removed
> post-CS3 - generated files with rgb() component values that are
> floats rather than integers. I discovered this after a user of my
> rendering library reported a rendering "bug".
>
> After experimenting, I see that all three of Chrome, FF and IE
> allow float values in percentage components,
Yes. As per the CSS spec.
> but not normal components.
Again, yes.
> In the following test file, the first rect is displayed, but not the second.
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"
> width="100%" height="100%"
> viewBox="0 0 200 200">
>
> <!-- Test float values in rgb() colour declarations.
> The Adobe InDesign SVG export filter (present in CS3 and earlier) generated
> these erroneous type of values. -->
> <rect x="50" y="50" width="50" height="80" fill="rgb(100.5%,-4%, 33.3%)" />
> <rect x="100" y="50" width="50" height="80" fill="rgb(255, 0, 85.3)" />
>
> <text x="100" y="160" text-anchor="middle" font-size="8">Accept
> bad Adobe InDesign colour declarations</text>
> </svg>
> How did it come about that the browsers all support floats in
> percentages?
Because they all follow the relevant specifications.
"SVG supports all of the syntax alternatives for <color> defined in
CSS2 syntax and basic data types ([CSS2], section 4.3.6), with the
exception that SVG allows an expanded list of recognized color
keywords names."
www.w3.org/TR/SVG11/types.html#DataTypeColor
"The format of an RGB value in the functional notation is 'rgb('
followed by a comma-separated list of three numerical values (either
three integer values or three percentage values) followed by ')'.
The integer value 255 corresponds to 100%, and to F or FF in the
hexadecimal notation: rgb(255,255,255) = rgb(100%,100%,100%) = #FFF.
Whitespace characters are allowed around the numerical values. "
http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#color-units
"4.3.3 Percentages
The format of a percentage value (denoted by <percentage> in this
specification) is an optional sign character ('+' or '-', with '+'
being the default) immediately followed by a <number> immediately
followed by '%'."
http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#percentage-units
"<number> (real number value): The specification of real number
values is different for property values than for XML attribute
values.
CSS2 [CSS2] states that a property value which is a <number> is
specified in decimal notation (i.e., a <decimal-number>), which
consists of either an <integer>, or an optional sign character
followed by zero or more digits followed by a dot (.) followed by
one or more digits. Thus, for conformance with CSS2, any property
in SVG which accepts <number> values is specified in decimal
notation only."
http://www.w3.org/TR/2003/REC-SVG11-20030114/types.html
"Some value types may have integer values (denoted by <integer>) or
real number values (denoted by <number>). Real numbers and integers
are specified in decimal notation only. An <integer> consists of one
or more digits "0" to "9". A <number> can either be an <integer>, or
it can be zero or more digits followed by a dot (.) followed by one
or more digits. Both integers and real numbers may be preceded by a
"-" or "+" to indicate the sign."
http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#q13
> All versions of the spec, including SVG2, specify that
> they should be integers. Is it just a case of choosing to be
> permissive? If so, why do non-percent components not get the same treatment?
Huh, that looks like an error that crept in during SVG 1.1 second
edition. The first edition just referred to CSS (which has always
allowed floats in percentages); the second edition similarly refers to
CSS2 and also adds a grammar which, as you point out, is a subset of
the allowed syntax because it uses <integer> instead of <number>:
color ::= "#" hexdigit hexdigit hexdigit (hexdigit hexdigit hexdigit)?
| "rgb(" wsp* integer comma integer comma integer wsp* ")"
| "rgb(" wsp* integer "%" comma integer "%" comma integer "%" wsp* ")"
| color-keyword
hexdigit ::= [0-9A-Fa-f]
comma ::= wsp* "," wsp*
SVG2 repeats this error
"color ::=
"#" hexdigit hexdigit hexdigit (hexdigit hexdigit hexdigit)?
| ~"rgb(" wsp* integer comma integer comma integer wsp* ")"
| ~"rgb(" wsp* integer "%" comma integer "%" comma integer "%" wsp* ")"
| ~"hsl(" wsp* integer comma integer comma integer wsp* ")"
| ~"hsla(" wsp* integer comma integer comma integer comma integer wsp* ")"
| color-keyword
http://www.w3.org/TR/SVG2/color.html#color
I will record that as an erratum for SVG 1.1 second edition, and
ensure it gets fixed in SVG2.
Thanks for your careful review, Paul
--
Best regards,
Chris mailto:chris@w3.org
Received on Monday, 27 January 2014 06:59:52 UTC