Skip to content

Commit c2b6b2a

Browse files
authored
Add the second percentage parameter to advance-override
1 parent 3673fec commit c2b6b2a

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

css-fonts-5/Overview.bs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Initial: normal
170170

171171
<pre class='descdef'>
172172
Name: advance-override
173-
Value: normal | <<percentage>>
173+
Value: normal | [ <<percentage>> <<percentage>>? ]
174174
For: @font-face
175175
Initial: normal
176176
</pre>
@@ -193,8 +193,11 @@ given percentage multiplied by the used font size. Negative values are invalid a
193193

194194
For the 'advance-override' descriptor, when the descriptor value is a percentage, the
195195
advance from one <a>typographic character unit</a> to the next is multiplied by the percentage.
196+
When the second percentage value is present, it is used to override the advances of upright
197+
glyphs in vertical text layout (as defined in [[CSS-WRITING-MODES-3#intro-text-layout]]); in all
198+
other cases, the first percentage is used.
196199

197-
Note: Using the 'ascent-override', 'descent-override', and 'line-grap-override' descriptors can
200+
Note: Using the 'ascent-override', 'descent-override', and 'line-gap-override' descriptors can
198201
achieve a similar effect as specifying a percentage for 'line-height' property. Also, using the
199202
'advance-override' has a similar effect as using the 'letter-spacing' property. However,
200203
contrary to 'letter-spacing', 'advance-override' scales the spacing, rather than adding a
@@ -236,6 +239,32 @@ within an individual element e.g. for characters not supported by the primary fo
236239
In this example, the used advance between the glyphs is 69.328125 pixels * 1.4 = 97.059375 pixels.
237240
</div>
238241

242+
<div class="example">
243+
In certain scripts like CJK, or when the 'text-orientation' value is ''text-orientation/upright'', glyphs remain
244+
upright in vertical text. For 'advance-override' to work properly, we need to scale the height of each glyph
245+
instead of the width. We use the second percentage parameter for this scenario.
246+
247+
<xmp>
248+
@font-face {
249+
font-family: "My Heiti SC";
250+
src: local("Heiti SC Light");
251+
advance-override: 140% 130%;
252+
}
253+
254+
...
255+
<div style="writing-mode: vertical-rl">
256+
<p style="font: 96px 'Heiti SC'">你好</p>
257+
<p style="font: 96px 'My Heiti SC'">你好</p>
258+
</div>
259+
</xmp>
260+
The rendering will look like this:
261+
<figure>
262+
<img alt="Overridden advance of upright vertical Heiti SC glyphs" src="images/Heiti_Upright_Vertical_Overridden_Advance.png">
263+
</figure>
264+
In this example, the natural advance between the glyphs is 96 pixels, whereas the overridden advance is 96 pixels * 1.3 = 124.8 pixels.
265+
266+
</div>
267+
239268
<div class="example">
240269
The percentage is resolved against different font sizes for different elements.
241270

44.8 KB
Loading

0 commit comments

Comments
 (0)