Skip to content

Commit d46ebfe

Browse files
committed
[css-inline] Add <lenth>|<percentage> to initial-letter-wrap as requested by Google
1 parent 3ace90c commit d46ebfe

2 files changed

Lines changed: 83 additions & 8 deletions

File tree

css-inline/Overview.bs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,11 @@ Note: 'initial-letter-wrap' is at risk.
628628

629629
<pre class="propdef">
630630
Name: <dfn id="propdef-initial-letter-wrap">initial-letter-wrap</dfn>
631-
Value: none | first | all | grid
631+
Value: none | first | all | grid | <<length>> | <<percentage>>
632632
Initial: none
633633
Applies to: <code>::first-letter</code> pseudo-elements and inline-level first child of a block container
634634
Inherited: yes
635-
Percentages: N/A
635+
Percentages: relative to <a>logical width</a> of (last fragment of) initial letter
636636
Media: visual
637637
Computed value: as specified
638638
</pre>
@@ -700,6 +700,40 @@ is larger than its glyph in order to preserve inline-axis alignment.
700700
Note: This value is also at-risk.
701701

702702

703+
<dt><dfn><<length>></dfn>
704+
<dt><dfn><<percentage>></dfn>
705+
<dd>This value behaves the same as ''first''
706+
except that the adjustment to the first line is given explicitly
707+
instead of being inferred from the glyph shape.
708+
709+
Issue: This really needs font-relative lengths to be relative to the used size.
710+
711+
Note: This value exists because it is easier to implement.
712+
Authors are encouraged to use the ''first'' value
713+
and to set margins to control spacing,
714+
and to use this as a fallback for glyph detection if necessary.
715+
716+
<div class="example">
717+
In the following example, UAs that support ''first'' will use the glyph outline
718+
plus the specified margin in order to place the first line,
719+
whereas UAs that only support <<length>> or <<percentage>> values
720+
will pull in the first line by 40% of the initial letter's width
721+
(and then add the margin to that point).
722+
<pre>
723+
h1 + p:first-letter {
724+
initial-letter: 3; /* 3-line drop-cap */
725+
initial-letter-wrap: first;
726+
margin-right: 0.1em;
727+
}
728+
@supports (not (initial-letter-wrap: first)) {
729+
/* Classes auto-generated on paragraphs to match first letter. */
730+
p.A:first-letter {
731+
initial-letter-wrap: -40%; /* Start of glyph outline, assuming correct font. */
732+
}
733+
}
734+
</pre>
735+
</div>
736+
703737
</dl>
704738

705739
Issue: Edit figure to show how auto behaves in varying contexts

css-inline/Overview.html

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ <h3 class="heading settled" data-level="2.8" id="initial-letter-wrapping"><span
707707
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-initial-letter-wrap">initial-letter-wrap<a class="self-link" href="#propdef-initial-letter-wrap"></a></dfn>
708708
<tr class="value">
709709
<th>Value:
710-
<td class="prod">none <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> first <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> all <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> grid
710+
<td class="prod">none <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> first <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> all <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> grid <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#length-value">&lt;length></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#percentage-value">&lt;percentage></a>
711711
<tr>
712712
<th>Initial:
713713
<td>none
@@ -719,7 +719,7 @@ <h3 class="heading settled" data-level="2.8" id="initial-letter-wrapping"><span
719719
<td>yes
720720
<tr>
721721
<th>Percentages:
722-
<td>N/A
722+
<td>relative to <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#logical-width">logical width</a> of (last fragment of) initial letter
723723
<tr>
724724
<th>Media:
725725
<td>visual
@@ -779,6 +779,35 @@ <h3 class="heading settled" data-level="2.8" id="initial-letter-wrapping"><span
779779
<p class="note" role="note">Note: In this example, the exclusion area for the drop initial
780780
is larger than its glyph in order to preserve inline-axis alignment.</p>
781781
<p class="note" role="note">Note: This value is also at-risk.</p>
782+
<dt><dfn class="css" data-dfn-for="initial-letter-wrap" data-dfn-type="value" data-export="" id="valdef-initial-letter-wrap-length"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#length-value">&lt;length></a><a class="self-link" href="#valdef-initial-letter-wrap-length"></a></dfn>
783+
<dt><dfn class="css" data-dfn-for="initial-letter-wrap" data-dfn-type="value" data-export="" id="valdef-initial-letter-wrap-percentage"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#percentage-value">&lt;percentage></a><a class="self-link" href="#valdef-initial-letter-wrap-percentage"></a></dfn>
784+
<dd>
785+
This value behaves the same as <a class="css" data-link-type="maybe" href="#valdef-initial-letter-wrap-first">first</a> except that the adjustment to the first line is given explicitly
786+
instead of being inferred from the glyph shape.
787+
<p class="issue" id="issue-645378a9"><a class="self-link" href="#issue-645378a9"></a> This really needs font-relative lengths to be relative to the used size.</p>
788+
<p class="note" role="note">Note: This value exists because it is easier to implement.
789+
Authors are encouraged to use the <a class="css" data-link-type="maybe" href="#valdef-initial-letter-wrap-first">first</a> value
790+
and to set margins to control spacing,
791+
and to use this as a fallback for glyph detection if necessary.</p>
792+
<div class="example" id="example-e11c0dc6">
793+
<a class="self-link" href="#example-e11c0dc6"></a> In the following example, UAs that support <a class="css" data-link-type="maybe" href="#valdef-initial-letter-wrap-first">first</a> will use the glyph outline
794+
plus the specified margin in order to place the first line,
795+
whereas UAs that only support <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#length-value">&lt;length></a> or <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#percentage-value">&lt;percentage></a> values
796+
will pull in the first line by 40% of the initial letter’s width
797+
(and then add the margin to that point).
798+
<pre>h1 + p:first-letter {
799+
initial-letter: 3; /* 3-line drop-cap */
800+
initial-letter-wrap: first;
801+
margin-right: 0.1em;
802+
}
803+
@supports (not (initial-letter-wrap: first)) {
804+
/* Classes auto-generated on paragraphs to match first letter. */
805+
p.A:first-letter {
806+
initial-letter-wrap: -40%; /* Start of glyph outline, assuming correct font. */
807+
}
808+
}
809+
</pre>
810+
</div>
782811
</dl>
783812
<p class="issue" id="issue-c4ff3304"><a class="self-link" href="#issue-c4ff3304"></a> Edit figure to show how auto behaves in varying contexts</p>
784813
<div class="example" id="example-768e3a03">
@@ -1018,7 +1047,12 @@ <h3 class="no-num heading settled" id="index-defined-here"><span class="content"
10181047
<li><a href="#initial-letter">initial letter box</a><span>, in §2.3</span>
10191048
<li><a href="#propdef-initial-letter-wrap">initial-letter-wrap</a><span>, in §2.8</span>
10201049
<li><a href="#valdef-initial-letter-integer">&lt;integer></a><span>, in §2.3</span>
1021-
<li><a href="#valdef-baseline-shift-length">&lt;length></a><span>, in §1.2.2</span>
1050+
<li>
1051+
&lt;length>
1052+
<ul>
1053+
<li><a href="#valdef-baseline-shift-length">value for baseline-shift</a><span>, in §1.2.2</span>
1054+
<li><a href="#valdef-initial-letter-wrap-length">value for initial-letter-wrap</a><span>, in §2.8</span>
1055+
</ul>
10221056
<li>
10231057
mathematical
10241058
<ul>
@@ -1029,7 +1063,12 @@ <h3 class="no-num heading settled" id="index-defined-here"><span class="content"
10291063
<li><a href="#valdef-initial-letter-wrap-none">none</a><span>, in §2.8</span>
10301064
<li><a href="#valdef-initial-letter-normal">normal</a><span>, in §2.3</span>
10311065
<li><a href="#valdef-initial-letter-number">&lt;number></a><span>, in §2.3</span>
1032-
<li><a href="#valdef-baseline-shift-percentage">&lt;percentage></a><span>, in §1.2.2</span>
1066+
<li>
1067+
&lt;percentage>
1068+
<ul>
1069+
<li><a href="#valdef-baseline-shift-percentage">value for baseline-shift</a><span>, in §1.2.2</span>
1070+
<li><a href="#valdef-initial-letter-wrap-percentage">value for initial-letter-wrap</a><span>, in §2.8</span>
1071+
</ul>
10331072
<li><a href="#raised-initial">raised initial</a><span>, in §2.1.3</span>
10341073
<li><a href="#valdef-baseline-shift-sub">sub</a><span>, in §1.2.2</span>
10351074
<li><a href="#sunken-initial">sunken initial</a><span>, in §2.1.2</span>
@@ -1102,6 +1141,7 @@ <h3 class="no-num heading settled" id="index-defined-elsewhere"><span class="con
11021141
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a>
11031142
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#line-over">line-over</a>
11041143
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#line-under">line-under</a>
1144+
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#logical-width">logical width</a>
11051145
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#valdef-text-orientation-mixed">mixed</a>
11061146
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#over">over</a>
11071147
<li><a href="https://drafts.csswg.org/css-writing-modes-3/#valdef-text-orientation-sideways">sideways</a>
@@ -1245,11 +1285,11 @@ <h2 class="no-num heading settled" id="property-index"><span class="content">Pro
12451285
<td>specified value
12461286
<tr>
12471287
<th scope="row"><a class="css" data-link-type="property" href="#propdef-initial-letter-wrap">initial-letter-wrap</a>
1248-
<td>none | first | all | grid
1288+
<td>none | first | all | grid | &lt;length> | &lt;percentage>
12491289
<td>none
12501290
<td>::first-letter pseudo-elements and inline-level first child of a block container
12511291
<td>yes
1252-
<td>N/A
1292+
<td>relative to logical width of (last fragment of) initial letter
12531293
<td>visual
12541294
<td>no
12551295
<td>as specified
@@ -1274,6 +1314,7 @@ <h2 class="no-num heading settled" id="issues-index"><span class="content">Issue
12741314
<div class="issue"> Are there other things we need to consider here?<a href="#issue-bef56215"></a></div>
12751315
<div class="issue"> Do we need an unconditional <a class="css" data-link-type="maybe" href="#valdef-initial-letter-wrap-first">first</a>?
12761316
(I.e. Should we rename this value to <a class="css" data-link-type="maybe" href="#valdef-dominant-baseline-auto">auto</a> and add a <a class="css" data-link-type="maybe" href="#valdef-initial-letter-wrap-first">first</a> value that does not check for spaces?)<a href="#issue-a826765c"></a></div>
1317+
<div class="issue"> This really needs font-relative lengths to be relative to the used size.<a href="#issue-645378a9"></a></div>
12771318
<div class="issue"> Edit figure to show how auto behaves in varying contexts<a href="#issue-c4ff3304"></a></div>
12781319
<div class="issue"> Handle glyph ink above cap height of font.<a href="#issue-f77cbeb9"></a></div>
12791320
<div class="issue"> Is this the behavior we want? What if the float is on the same line as the initial letter?<a href="#issue-2ad0a0cb"></a></div>

0 commit comments

Comments
 (0)