Skip to content

Commit f6dd9cd

Browse files
committed
[css-fonts-5] Copy font-size-adjust definition from css-fonts-4
1 parent 5902e88 commit f6dd9cd

File tree

3 files changed

+181
-0
lines changed

3 files changed

+181
-0
lines changed

css-fonts-5/Overview.bs

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,187 @@ Issue(4044):
9393
<h3 id="font-size-adjust-prop">
9494
Relative sizing: the 'font-size-adjust' property</h3>
9595

96+
<pre class="propdef">
97+
Name: font-size-adjust
98+
Value: none | <<number>>
99+
Initial: none
100+
Applies to: all elements and text
101+
Inherited: yes
102+
Percentages: N/A
103+
Computed value: a number or the keyword ''font-size-adjust/none''
104+
Animation type: by computed value type
105+
</pre>
106+
107+
For any given font size, the apparent size and effective legibility of text
108+
varies across fonts.
109+
For bicameral scripts such as Latin or Cyrillic that
110+
distinguish between upper and lowercase letters,
111+
the relative height of lowercase letters
112+
compared to their uppercase counterparts
113+
is a determining factor of legibility.
114+
This is commonly referred to as the <dfn>aspect value</dfn>
115+
and is equal to the x-height of a font
116+
divided by the font size.
117+
118+
Note: For text which uses diacritics,
119+
too large an x-height will actually decrease legibility
120+
as the diacritics become cramped.
121+
122+
In situations where font fallback occurs,
123+
fallback fonts might not share the same aspect value
124+
as the desired font family
125+
and will thus be less readable.
126+
The 'font-size-adjust' property is a way
127+
to preserve the readability of text when font fallback occurs.
128+
It does this by adjusting the font-size
129+
so that the x-height is the same
130+
regardless of the font used.
131+
132+
<div class="example">
133+
The style defined below defines Verdana as the desired font family,
134+
but if Verdana is not available Futura or Times will be used.
135+
One paragraph also has font-size-adjust specified.
136+
137+
<pre>
138+
p {
139+
font-family: Verdana, Futura, Times;
140+
}
141+
p.adj {
142+
font-size-adjust: 0.545;
143+
}
144+
145+
&lt;p>Lorem ipsum dolor sit amet, ...&lt;/p>
146+
&lt;p class="adj">Lorem ipsum dolor sit amet, ...&lt;/p>
147+
</pre>
148+
149+
Verdana has a relatively high aspect value of 0.545,
150+
meaning lowercase letters are relatively tall
151+
compared to uppercase letters,
152+
so at small sizes text appears legible.
153+
Times has a lower aspect value of 0.447,
154+
and so if fallback occurs,
155+
the text will be less legible at small sizes than Verdana
156+
unless font-size-adjust is also specified.
157+
</div>
158+
159+
How text rendered in each of these fonts compares is shown below,
160+
the columns show text rendered in Verdana, Futura and Times.
161+
The same font-size value is used across cells
162+
within each row and red lines are included to show the differences in x-height.
163+
In the upper half, each row is rendered in the same font-size value.
164+
The same is true for the lower half,
165+
but in this half the 'font-size-adjust' property is also set
166+
to 0.545,
167+
so that the actual font size is adjusted
168+
to preserve the x-height of Verdana across each row.
169+
Note how small text remains relatively legible across each row in the lower half.
170+
171+
<figure>
172+
<img alt="text with and without 'font-size-adjust'" src="images/fontsizeadjust.png" >
173+
<figcaption>Text with and without the use of 'font-size-adjust'</figcaption>
174+
</figure>
175+
176+
This property allows authors to specify an <a>aspect value</a> for an element
177+
that will effectively preserve the x-height of the first choice font,
178+
whether it is substituted or not.
179+
Values have the following meanings:
180+
181+
<dl dfn-type=value dfn-for=font-size-adjust>
182+
<dt><dfn id="font-size-adjust-none-value">none</dfn>
183+
<dd>
184+
Do not preserve the font's x-height.
185+
186+
<dt><dfn id="aspect-ratio-value"><<number>></dfn>
187+
188+
<dd>
189+
Specifies the <a>aspect value</a> used in the calculation below
190+
to calculate the adjusted font size:
191+
192+
<pre>c = ( a / a' ) s</pre>
193+
194+
where:
195+
196+
<pre>
197+
s = font-size value
198+
a = <a>aspect value</a> as specified by the 'font-size-adjust' property
199+
a' = <a>aspect value</a> of actual font
200+
c = adjusted font-size to use
201+
</pre>
202+
203+
Negative values are invalid.
204+
205+
This value applies to any font that is selected
206+
but in typical usage it should be based on the <a>aspect value</a>
207+
of the first font in the font-family list.
208+
If this is specified accurately,
209+
the <code>(a/a')</code> term in the formula above
210+
is effectively 1 for the first font
211+
and no adjustment occurs.
212+
If the value is specified inaccurately,
213+
text rendered using the first font in the family list
214+
will display differently in older user agents
215+
that don't support 'font-size-adjust'.
216+
</dl>
217+
218+
The value of 'font-size-adjust' affects the used value of 'font-size'
219+
but does not affect the computed value.
220+
It affects the size of relative units
221+
that are based on font metrics
222+
such as <code>ex</code> and <code>ch</code>
223+
but does not affect the size of <code>em</code> units.
224+
Since numeric values of 'line-height'
225+
refer to the computed size of 'font-size',
226+
'font-size-adjust' does not affect the used value of 'line-height'.
227+
228+
Note: In CSS, authors often specify 'line-height'
229+
as a multiple of the 'font-size'.
230+
Since the 'font-size-adjust' property affects the used value of 'font-size',
231+
authors should take care setting the line height
232+
when 'font-size-adjust' is used.
233+
Setting the line height too tightly can result in
234+
overlapping lines of text in this situation.
235+
236+
237+
<div class="example">
238+
Authors can calculate the <a>aspect value</a> for a given font
239+
by comparing spans with the same content
240+
but different 'font-size-adjust' properties.
241+
If the same font-size is used, the spans will match
242+
when the 'font-size-adjust' value is accurate for the given font.
243+
244+
Two spans with borders are used to determine the <a>aspect value</a> of a font.
245+
The 'font-size' is the same for both spans
246+
but the 'font-size-adjust' property is specified only for the right span.
247+
Starting with a value of 0.5,
248+
the aspect value can be adjusted
249+
until the borders around the two letters line up.
250+
251+
<pre>
252+
p {
253+
font-family: Futura;
254+
font-size: 500px;
255+
}
256+
257+
span {
258+
border: solid 1px red;
259+
}
260+
261+
.adjust {
262+
font-size-adjust: 0.5;
263+
}
264+
265+
&lt;p>&lt;span>b&lt;/span>&lt;span class="adjust">b&lt;/span>&lt;/p>
266+
</pre>
267+
268+
<figure>
269+
<img alt="Futura with an aspect value of 0.5" src="images/beforefontsizeadjust.png" >
270+
<figcaption>Futura with an <a>aspect value</a> of 0.5</figcaption>
271+
</figure>
272+
273+
The box on the right is a bit bigger than the one on the left, so the <a>aspect value</a> of this font is something less than 0.5.
274+
Adjust the value until the boxes align.
275+
</div>
276+
96277
The 'font-size-adjust' property is applied after the 'size-adjust' descriptor.
97278

98279
Note: The consequence of applying 'font-size-adjust' after 'size-adjust' is that
3.14 KB
Loading
47 KB
Loading

0 commit comments

Comments
 (0)