Skip to content

Commit 26ec9cb

Browse files
committed
[css-inline] Restructure initial-letter-align
1 parent e562b64 commit 26ec9cb

2 files changed

Lines changed: 162 additions & 71 deletions

File tree

css-inline/Overview.bs

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,8 @@ The 'initial-letter' property does not apply to boxes that are not positioned at
390390
An <a>initial letter</a> is laid out following the steps outlined below:
391391

392392
<ol>
393-
<li>Find font size based on 'initial-letter-align' alignment points and font metrics.
394-
Note that no layout information is required in this step.
393+
<li>Find the used font size based on its 'initial-letter' size, 'initial-letter-align' alignment points, and font metrics.
394+
Note that no layout is required in this step.
395395
The font size used for sizing the <a>initial letter</a> contents <em>does not</em> affect its computed 'font-size' property
396396
(and therefore has no effect on the computation of ''em'' length values, etc.).
397397

@@ -426,39 +426,40 @@ As mentioned earlier, the alignment of initial letters depends on the script use
426426

427427
<pre class="propdef" id="initial-letter-align">
428428
Name: <dfn id="propdef-initial-letter-align">initial-letter-align</dfn>
429-
Value: auto | alphabetic | ideographic | margin-box | content-box
430-
Initial: auto
429+
Value: border-box? [ alphabetic | ideographic | hebrew ] | border-box
430+
Initial: alphabetic
431431
Applies to: <code>::first-letter</code> pseudo elements and inline level first child of a block container
432-
Inherited: no
432+
Inherited: yes
433433
Percentages: N/A
434434
Media: visual
435435
Computed value: specified value
436436
</pre>
437437

438+
This property specifies the alignment points used to size and position an <a>initial letter</a>.
439+
Two sets of alignment points are necessary:
440+
the <a>over</a> and <a>under</a> alignment points of the <a>initial letter</a>
441+
are matched to corresponding <a>over</a> and <a>under</a> points of the surrounding text.
438442

439-
<dl dfn-type="value" dfn-for="initial-letter-align">
440-
<dt>auto</dt>
441-
<dd>The user agent selects the value which corresponds to the language of the text. Western languages would default to ''alphabetic'', CJK languages to ''ideographic'', and some Indic languages to ''hanging''. </dd>
442-
443-
<dt>alphabetic</dt>
444-
<dd>As described above, the cap height of the initial letter aligns with the cap height of the first line of text. The baseline of the initial letter aligns with the baseline of the Nth text baseline.</dd>
445-
446-
<dt>ideographic</dt>
447-
<dd>The initial letter is centered in the N-line area.
443+
Values have the following meanings:
448444

449-
<dt>margin-box</dt>
450-
<dd>Uses the <a>line-over</a> and <a>line-under</a> margin edges
451-
as the <a>over</a> and <a>under</a> alignment points, respectively.
452-
453-
<dt>content-box</dt>
454-
<dd>Uses the <a>line-over</a> and <a>line-under</a> content edges
455-
as the <a>over</a> and <a>under</a> alignment points, respectively.
456-
(In most cases, these will correspond to
457-
the <a>over</a> and <a>under</a> edges of the glyph bounding box.)
445+
<dl dfn-type="value" dfn-for="initial-letter-align">
446+
<dt><dfn>alphabetic</dfn>
447+
<dd>Use the alphabetic and cap-height baselines of the surrounding text
448+
to align the <a>initial letter</a>.
449+
450+
<dt><dfn>ideographic</dfn>
451+
<dd>Use the ideographic character face bottom and top edge baselines of the surrounding text
452+
to align the <a>initial letter</a>.
453+
454+
<dt><dfn>hebrew</dfn>
455+
<dd>Use the alphabetic and (as yet theoretical) hebrew hanging baseline of the surrounding text
456+
to align the <a>initial letter</a>.
457+
458+
<dt><dfn>border-box</dfn>
459+
<dd>Uses the <a>initial letter box</a>’s <a>line-over</a> and <a>line-under</a> border edges
460+
as the <a>over</a> and <a>under</a> alignment points, respectively.
458461
</dl>
459462

460-
<p class="issue">Input from those knowledgeable about non-Western typographic traditions would be very helpful in describing the appropriate alignments. More values may be required for this property.</p>
461-
462463
<div class="example">
463464
The vertical writing mode example from <a href="#f2">Figure 2</a> could be coded as:
464465

@@ -468,19 +469,48 @@ span.initial {
468469
initial-letter-alignment: ideographic;
469470
}
470471
</pre>
472+
</div>
471473

474+
Except when ''border-box'' is specified,
475+
the alignment points of the <a>initial letter</a>
476+
are automatically determined from its contents:
477+
<ol>
478+
<li>If the <a>initial letter</a> is an atomic inline,
479+
use its <a>over</a> and <a>under</a> content-box edges.
480+
<li>Else if the <a>initial letter</a> contains any character from the Han, Hangul, Kana, or Yi <a>Unicode scripts</a>,
481+
use the ideographic character face bottom and top edge baselines.
482+
<li>Else if the <a>initial letter</a> contains any character from the Hebrew <a>Unicode scripts</a>,
483+
use the ideographic character face bottom and top edge baselines.
484+
<li>Else use the alphabetic and cap-height baselines.
485+
</ol>
486+
487+
Note: The ordering of keywords in this property is fixed in case ''border-box''
488+
is expanded to ''[ border-box | alphabetic | ideographic | hebrew ]''
489+
to allow explicitly specifying the <a>initial letter</a>’s alignment points.
490+
491+
<h4 id="initial-letter-align-defaults">
492+
UA Default Stylesheet for 'initial-letter-align'</h4>
493+
494+
In order to provide the better behavior by default,
495+
UAs must include in their default UA style sheet the following rules:
472496

473-
</div>
497+
<pre>
498+
[lang=zh], [lang=ja], [lang=ko], [lang=ii] {
499+
initial-letter-align: ideographic;
500+
}
501+
[lang|=iw], [lang|=yi], [lang|=lad], [lang|=jrb] {
502+
initial-letter-align: hebrew;
503+
}
504+
</pre>
474505

475-
If 'initial-letter' is applied to an image or other atomic element that does not provide the necessary alignment information, the alignment points for the atomic inline must be synthesized from the content edges.
506+
Issue: We don't have a way to do subtag selection with attr selectors.
507+
(It's a feature of '':lang()'' in Selectors 4,
508+
but we don't want to use that because we want to hit the language root,
509+
not all of the descendant elements.)
510+
These selectors should also include the relevant script subtags.
476511

477-
Note: For 'vertical-align', the alignment points of an atomic inline are synthesized from the margin edges. [[CSS3-WRITING-MODES]]
512+
</div>
478513

479-
<!--
480-
]]]]]]]]]]]]
481-
]]]]]=======
482-
============
483-
-->
484514
<h3 id="sizing-initial-letters">
485515
Sizing Initial Letters</h3>
486516

0 commit comments

Comments
 (0)