Re: [css4-fonts] font-size: auto

I like the idea, but (as you pointed) "auto" doesn't seem a safe name. In 
fact, no single keyword would do the trick since it would prevent you to 
define a size range (ie: not smaller than 8pt, not bigger than 12pt) and the 
precise algorithm to use to shrink/grow the font size.

I propose :

    div.comment-box {
        font-size: fit-box 8pt 12pt;
    }

    div.comment-line {
        font-size: fit-line 8pt 12pt;
    }

    div.word-art {
        font-size: fit-line;
        // font-size: fit-line 0px none;
    }

The shrink to 'fit-box' algorithm returns the biggest font size for which 
the there's no text overflow outside the box.
The shrink to 'fit-line' algorithm returns the biggest font size for which 
the no text line is wrapped by layout.

The computed value of 'font-size' should be the font-size used to draw the 
glyphs, in pixels. The 'font-size' property is inherited by computed value, 
so that fitting algorithms are not inherited.

The effect of fit-box/fit-line on "inline" boxes is to inherit the font size 
from the parent element.




-----Message d'origine----- 
From: Christoph Päper
Sent: Wednesday, February 15, 2012 12:43 PM
To: www-style list
Subject: [css4-fonts] font-size: auto

Sometimes you have a one-line box (or maybe 2 lines of text) with a fixed 
width and the text within should fill all of this. This could be done with 
either manually adjusting letter-spacing and word-spacing or with manually 
increasing the font-size until just before the last word breaks to the next 
line. This, however, does not work reliably since you can never know which 
font will be used in the end. For letter and word spacing the automated 
variant is known as justified text, i.e. “text-align: justify”, but for font 
sizing there is none.

Therefore I would like to suggest for level 4 of the Font module to make the 
‘font-size’ property accept at least one new keyword, e.g. ‘auto’, 
‘line-fill’, ‘width’ or ‘fill-x’, that facilitates the described behavior.

I’m not sure there are also valid usecases for
a) shrinking the size until the complete text fits within one line,
b) increasing the size until the parent box’s height is used to the maximum 
extent by lines of text,
so I’m leaving that to level 5 or others to propose. Beware, though, that if 
these are future things to address ‘auto’ may not be the best choice for the 
suggested line fill keyword. 

Received on Wednesday, 15 February 2012 14:37:29 UTC