|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"Intrigued by the bug report from Ryan Foster [2], I read
the CSS 3 spec. on units, and read -- to my surprise -- the following : em the font size of the element (or, to the parent element's font size if set on the 'font-size' property) ex the x-height of the element's font Is there any reason why "ex" does not also reference the parent element's font size if set on the 'font-size' property, as if "ex" units are used to specify font-size, there would appear to be a problem of self-reference (see example below). Philip TAYLOR -------- Example : <HTML> <HEAD> <TITLE>Title</TITLE> </HEAD> <BODY> <DIV> <! -- No explicit font so far --> <SPAN style="font-size: 0.5em">ABCDabcd</SPAN> <SPAN style="font-size: 1.0ex">ABCDabcd</SPAN> </DIV> </BODY< </HTML> The style declaration for the second span is would appear to be self-referential, since "the font's x-height" [1] cannot be known until the font-size has been computed ... ** Phil. -------- [1] The 'ex' unit is defined by the font's x-height. The x-height is so called because it is often equal to the height of the lowercase "x". However, an 'ex' is defined even for fonts that don't contain an "x". Should we say that ex is 0.5em if no better value exists? -------- [2] Ryan Foster wrote: > When set to CSS3, the CSS Validator states: > > Value Error : min-width > <http://jigsaw.w3.org/css-validator/nullvisudet.html#propdef-min-width> > Unknown dimension 15ch > > While the CSS3 Values and Units <http://www.w3.org/TR/css3-values/> draft specification states <http://www.w3.org/TR/css3-values/#relative0>: > > ch: The width of the "0" (ZERO, U+0030) glyph found in the font for > the font size used to render. If the "0" glyph is not found in the > font, the average character width may be used. How is the "average > character width" found? > > The Validator should mark "ch" as a valid unit when set to CSS3. The same error occurs in the development version (http://qa-dev.w3.org:8001/css-validator/). |
|
|
Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size" [CSS21][css3-values]On Monday 2009-10-26 16:59 +0000, Philip TAYLOR wrote:
> Is there any reason why "ex" does not also reference > the parent element's font size if set on the 'font-size' > property, as if "ex" units are used to specify font-size, > there would appear to be a problem of self-reference > (see example below). This looks to me like a bug in both CSS 2.1 and css3-values. (Gecko implements 'ex' like 'em.) -David -- L. David Baron http://dbaron.org/ Mozilla Corporation http://www.mozilla.com/ |
|
|
Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"I believe you are correct in your perception of a self-referential problem here.
In the absence of an explicit x-height value, a value of 0.5 em would indeed be a reasonable default. (Note that this is not half the cap height: that value itself might average ~ 0.7 em; an aveage x-height might be about 0.7x the cap height.) Cheers, T On Mon, Oct 26, 2009 at 9:59 AM, Philip TAYLOR <P.Taylor@...> wrote: > Intrigued by the bug report from Ryan Foster [2], I read > the CSS 3 spec. on units, and read -- to my surprise -- the > following : > > em the font size of the element (or, > to the parent element's font size > if set on the 'font-size' property) > > ex the x-height of the element's font > > Is there any reason why "ex" does not also reference > the parent element's font size if set on the 'font-size' > property, as if "ex" units are used to specify font-size, > there would appear to be a problem of self-reference > (see example below). > > Philip TAYLOR > -------- > Example : > > <HTML> > <HEAD> > <TITLE>Title</TITLE> > </HEAD> > <BODY> > <DIV> > <! -- No explicit font so far --> > <SPAN style="font-size: 0.5em">ABCDabcd</SPAN> > <SPAN style="font-size: 1.0ex">ABCDabcd</SPAN> > </DIV> > </BODY< > </HTML> > > The style declaration for the second span is would > appear to be self-referential, since "the font's x-height" [1] > cannot be known until the font-size has been computed ... > > ** Phil. > -------- > [1] The 'ex' unit is defined by the font's x-height. > The x-height is so called because it is often equal > to the height of the lowercase "x". However, an 'ex' > is defined even for fonts that don't contain an "x". > Should we say that ex is 0.5em if no better value exists? > -------- > [2] Ryan Foster wrote: > >> When set to CSS3, the CSS Validator states: >> >> Value Error : min-width >> >> <http://jigsaw.w3.org/css-validator/nullvisudet.html#propdef-min-width> >> Unknown dimension 15ch >> >> While the CSS3 Values and Units <http://www.w3.org/TR/css3-values/> draft >> specification states <http://www.w3.org/TR/css3-values/#relative0>: >> >> ch: The width of the "0" (ZERO, U+0030) glyph found in the font for >> the font size used to render. If the "0" glyph is not found in the >> font, the average character width may be used. How is the "average >> character width" found? >> >> The Validator should mark "ch" as a valid unit when set to CSS3. The same >> error occurs in the development version >> (http://qa-dev.w3.org:8001/css-validator/). > > |
|
|
Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"On Monday 26 October 2009, Thomas Phinney wrote:
> I believe you are correct in your perception of a self-referential > problem here. > > In the absence of an explicit x-height value, a value of 0.5 em would > indeed be a reasonable default. (Note that this is not half the cap > height: that value itself might average ~ 0.7 em; an aveage x-height > might be about 0.7x the cap height.) > On Mon, Oct 26, 2009 at 9:59 AM, Philip TAYLOR <P.Taylor@...> wrote: > > Intrigued by the bug report from Ryan Foster [2], I read > > the CSS 3 spec. on units, and read -- to my surprise -- the > > following : > > > > em the font size of the element (or, > > to the parent element's font size > > if set on the 'font-size' property) > > > > ex the x-height of the element's font > > > > Is there any reason why "ex" does not also reference > > the parent element's font size if set on the 'font-size' > > property, as if "ex" units are used to specify font-size, > > there would appear to be a problem of self-reference > > (see example below). The working group decided that this was an oversight and the ex definition will be changed to say the same as the em definition. We didn't check all implementations, but those we checked already do it this way. (Indeed, it would be hard to imagine how else it could work.) > > -------- > > [1] The 'ex' unit is defined by the font's x-height. > > The x-height is so called because it is often equal > > to the height of the lowercase "x". However, an 'ex' > > is defined even for fonts that don't contain an "x". > > Should we say that ex is 0.5em if no better value exists? > > -------- On that last sentence of the quoted text (which is marked as an issue in the working draft): The WG currently believes that the text of CSS 2.1 ("In the cases where it is impossible or impractical to determine the x-height, a value of 0.5em should be used.") is still the best and can be inserted unchanged at that point in the CSS3 module. Bert -- Bert Bos ( W 3 C ) http://www.w3.org/ http://www.w3.org/people/bos W3C/ERCIM bert@... 2004 Rt des Lucioles / BP 93 +33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France |
|
|
Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"Bert Bos wrote: >> On Mon, Oct 26, 2009 at 9:59 AM, Philip TAYLOR<P.Taylor@...> >>> Is there any reason why "ex" does not also reference >>> the parent element's font size if set on the 'font-size' >>> property, as if "ex" units are used to specify font-size, >>> there would appear to be a problem of self-reference >>> (see example below). > > The working group decided that this was an oversight and the ex > definition will be changed to say the same as the em definition. We > didn't check all implementations, but those we checked already do it > this way. (Indeed, it would be hard to imagine how else it could work.) Thank you for the confirmation, Bert. It was certainly the case in the past that browsers treated "ex" inconsistently, as a result of which we [1] ceased using them, relying instead (and with far greater success) on the use of "em" units even in a vertical context where "ex"s would have been preferable. However, I am quite willing to believe that the current generation of browsers now treat "ex" units consistently. > On that last sentence of the quoted text (which is marked as an issue in > the working draft): The WG currently believes that the text of CSS 2.1 > ("In the cases where it is impossible or impractical to determine the > x-height, a value of 0.5em should be used.") is still the best and can > be inserted unchanged at that point in the CSS3 module. I am a little unhappy with "or impractical"; does this not leave a rather large loophole for browser inconsistencies ? Philip Taylor -------- [1] The Web team at Royal Holloway, University of London |
|
|
Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"On Friday 30 October 2009, Philip TAYLOR wrote:
> Bert Bos wrote: > > On that last sentence of the quoted text (which is marked as an > > issue in the working draft): The WG currently believes that the > > text of CSS 2.1 ("In the cases where it is impossible or > > impractical to determine the x-height, a value of 0.5em should be > > used.") is still the best and can be inserted unchanged at that > > point in the CSS3 module. > > I am a little unhappy with "or impractical"; does this not > leave a rather large loophole for browser inconsistencies ? A loophole, yes; a large one, I don't know. If I remember correctly, the existence of that loophole is indeed why that remark in red is in the Values and Units draft. In general, we try to remove in the new modules all the vagueness that needs to be in CSS 2.1 to allow the specification to become a Rec. But not all fuzzy language can always be removed. We usually hope that competition in the market will push implementers to do the best their platform allows. You think the only cases are possible and impossible, and impractical doesn't really exist? > > Philip Taylor > -------- > [1] The Web team at Royal Holloway, University of London Bert -- Bert Bos ( W 3 C ) http://www.w3.org/ http://www.w3.org/people/bos W3C/ERCIM bert@... 2004 Rt des Lucioles / BP 93 +33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France |
|
|
Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"Philip TAYLOR wrote:
>> On that last sentence of the quoted text (which is marked as an >> issue in the working draft): The WG currently believes that the text >> of CSS 2.1 ("In the cases where it is impossible or impractical to >> determine the x-height, a value of 0.5em should be used.") is still >> the best and can be inserted unchanged at that point in the CSS3 >> module. > > I am a little unhappy with "or impractical"; does this not leave a > rather large loophole for browser inconsistencies ? Practically speaking, no. Fonts in CSS need to be defined independent of font type. For some font types, it may be hard to determine the x-height but for the majority of font types (OpenType, TrueType, SVG, Type1) determining x-height is a simple matter. The wording is fine I think. John Daggett Mozilla Japan CSS3 Fonts editor ----- Original Message ----- From: "Philip TAYLOR" <P.Taylor@...> To: "Bert Bos" <bert@...> Cc: "W3C Style List" <www-style@...> Sent: Friday, October 30, 2009 8:09:25 AM GMT -06:00 Guadalajara / Mexico City / Monterrey Subject: Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size" Bert Bos wrote: >> On Mon, Oct 26, 2009 at 9:59 AM, Philip TAYLOR<P.Taylor@...> >>> Is there any reason why "ex" does not also reference >>> the parent element's font size if set on the 'font-size' >>> property, as if "ex" units are used to specify font-size, >>> there would appear to be a problem of self-reference >>> (see example below). > > The working group decided that this was an oversight and the ex > definition will be changed to say the same as the em definition. We > didn't check all implementations, but those we checked already do it > this way. (Indeed, it would be hard to imagine how else it could work.) Thank you for the confirmation, Bert. It was certainly the case in the past that browsers treated "ex" inconsistently, as a result of which we [1] ceased using them, relying instead (and with far greater success) on the use of "em" units even in a vertical context where "ex"s would have been preferable. However, I am quite willing to believe that the current generation of browsers now treat "ex" units consistently. > On that last sentence of the quoted text (which is marked as an issue in > the working draft): The WG currently believes that the text of CSS 2.1 > ("In the cases where it is impossible or impractical to determine the > x-height, a value of 0.5em should be used.") is still the best and can > be inserted unchanged at that point in the CSS3 module. I am a little unhappy with "or impractical"; does this not leave a rather large loophole for browser inconsistencies ? Philip Taylor -------- [1] The Web team at Royal Holloway, University of London |
|
|
Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"John Daggett wrote: > Philip TAYLOR wrote: >> I am a little unhappy with "or impractical"; does this not leave a >> rather large loophole for browser inconsistencies ? > > Practically speaking, no. Fonts in CSS need to be defined independent of font type. For some font types, it may be hard to determine the x-height but for the majority of font types (OpenType, TrueType, SVG, Type1) determining x-height is a simple matter. The wording is fine I think. OK, I defer to your expert opinion John. Philip Taylor |
|
|
Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"On Oct 30, 2009, at 7:03 AM, Bert Bos wrote: > On that last sentence of the quoted text (which is marked as an > issue in > the working draft): The WG currently believes that the text of CSS 2.1 > ("In the cases where it is impossible or impractical to determine the > x-height, a value of 0.5em should be used.") is still the best and can > be inserted unchanged at that point in the CSS3 module. Should a note about this also be added to 'font-size-adjust'? [1] That part of that module does not actually mention 'ex' units, but if I understand it correctly, it would need the same bit of info from the font, and would also need to guess at it, if it is "impossible or impractical to determine the x-height" by reading it directly from the font metrics. Or maybe the wording of 'font-size-adjust' can be adjusted to describe what it is doing in terms of equalizing the 'ex' measurement of all the fonts in the font-family list? For instance, maybe "aspect ratio" can be defined as "1ex, as measured in ems" (thus, if '0.5' is the 'aspect ratio' for a given font, then it is actually '1ex', measured as '0.5em'). In this case, no other explanation about the undetermined x-heights is needed in the fonts module, because that explanation is already in the "CSS Values and Units" module. I also think that would be a bit easier to comprehend than the current opening explanation, which speaks of "the relative height of lowercase letters", and then later uses a lower case "b" as an example (which has an extender making it taller than 1ex). [1] http://www.w3.org/TR/2009/WD-css3-fonts-20090618/#relative-sizing-the-font-size-adjust-pro |
| Free embeddable forum powered by Nabble | Forum Help |