-
Notifications
You must be signed in to change notification settings - Fork 792
Expand file tree
/
Copy pathOverview.bs
More file actions
executable file
·343 lines (200 loc) · 14.1 KB
/
Overview.bs
File metadata and controls
executable file
·343 lines (200 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<h1>CSS Inline Layout Module Level 3</h1>
<style media="print" type="text/css">
img#edge { width: 80%; height: 70%;}
dt.label { display: run-in; }
</style>
<pre class='metadata'>
Shortname: css-inline
Level: 3
Status: ED
Group: csswg
TR: http://www.w3.org/TR/css-inline/
ED: http://dev.w3.org/csswg/css-inline/
Previous version: http://www.w3.org/TR/2002/WD-css3-linebox-20020515/
!Issues list: <a href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Linebox&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED">CSS3 Line Layout issues in Bugzilla</a>
Editor: Dave Cramer, Hachette Livre, dauwhe@gmail.com
Editor: Elika J. Etemad, Invited Expert, http://fantasai.inkedblade.net/contact
Editor: Steve Zilles, Adobe, szilles@adobe.com
Abstract: The CSS formatting model provides for a flow of elements and text inside of a container to be wrapped into lines. The formatting of elements and text within a line, its positioning in the inline progression direction, and the breaking of lines are described in [[CSS3TEXT]]. This module describes the positioning in the block progression direction both of elements and text within lines and of the lines themselves. This positioning is often relative to a baseline. It also describes special features for formatting of first lines and drop caps. It extends on the model in [[CSS2]].
Ignored Terms: guru, ji, line-height-shift-adjustment, text-script, after, before
Link Defaults: css-fonts-3 (property) font-family
</pre>
<h2>Line Heights and Baseline Alignment</h2>
<p class="issue">This section is being rewritten. Refer to <a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">section 10.8</a> of [[CSS21]] for the normative CSS definition or the <a href="http://www.w3.org/TR/2002/WD-css3-linebox-20020515/">2002 Working Draft</a> if you want pretty pictures. (But ignore the old text, half of it's wrong. We're not specifying which half, that's to be determined.)</p>
<h2 id="Initial">Initial Lines and Initial Letters</h2>
<h3 id="DropInitial">An Introduction to Initial Letters</h3>
Large, decorative letters have been used to start new sections of text since before the invention of printing. In fact, their use predates lowercase letters entirely.
A <dfn>drop initial</dfn> is a larger-than-usual letter at the start of a paragraph, with a baseline at least one line lower than the first baseline of the paragraph. The size of the drop initial is usually indicated by how many lines it occuppies. Two- and three-line drop initials are very common.
<figure>
<img alt="3-line drop cap with E Acute" src="Dropcap-E-acute-3line.png" width="480">
<p class="caption">Three-line drop initial with E acute. Since the cap-height of the drop initial aligns with the cap-height of the main text, the accent extends above the paragraph.</p>
</figure>
</div>
The exact size and position of a drop cap depends on the alignment of its glyph. [TK] Reference points on the drop cap must align precisely with reference points in the text. In Western scripts, the top reference points are the cap height of the initial letter and of the first line of text. The bottom reference points are the alphabetic baseline of the initial letter and the baseline of the Nth line of text. <a href="#f2">Figure 2</a> shows a simple two-line drop cap, with the relevant reference lines marked.
<figure id="f2">
<img src="Dropcap-lines.png" width="600" alt="drop cap showing alignment"/>
<p class="caption">Two-line drop cap showing baselines (green lines), cap-height (red line), and ascender (cyan line).</p>
</figure>
The alignment constraints for drop initials depend on the writing system. In Japanese, the initial letter extends from the <a>block-start</a> edge of the first line to the <a>block-end</a> edge of the Nth line.
<figure>
<img src="Initial-2line-JapaneseVertical六.png" width="480" alt="Japanese Vertical Initial"/>
<p class="caption">Two-line drop initial in vertical writing mode</p>
</figure>
<figure>
<img src="CJK-Initial.001.png" width="480" alt="Diagram of Japanese initial letter in vertical writing mode"/>
<p class="caption">Diagram of Japanese initial letter in vertical writing mode</p>
</figure>
Note: In some cases, the exclusion area for the drop initial is larger than its glyph in order to preserve inline-axis alignment. This effect is out-of-scope for this level. However, extra spacing can still be given using margins.
<h3 id="selecting-drop-initials">Selecting Initial Letters</h3>
Initial letters are typically a single letter, which can be selected by the <code>::first-letter</code> pseudo-element, as defined in [[SELECT]].
<p>Authors who need more control over which characters are included in an initial letter, or who want to apply initial-letter formatting to replaced elements or multiple words can also apply the 'initial-letter' property to the first inline-level child of a block container.
<div class="example">
<pre>
<p>This paragraph has a dropped “T”.
<p><img alt="H" src="illuminated-h.svg">ere we have an illuminated “H”.
<p><span>Words may also</span> be given initial letter styling at the beginning of a paragraph.
</pre>
<pre>
::first-letter, /* style first paragraph's T */
img, /* style illuminated H */
span /* drop Words may also */
{ initial-letters: 2; }
</pre>
</div>
<h3 id="sizing-drop-initials">Creating Initial Letters: the 'initial-letter' property</h3>
This property takes two arguments. The first argument defines the size of the initial letter, in terms of how many lines it occupies. The optional second argument argument defines the number of lines the initial letter should sink. An N-line initial letter sinks to the Nth text baseline. If not specified, it duplicates the first argument.
<pre class="propdef">
Name: <dfn id="propdef-initial-letter">initial-letter</dfn>
Value: normal | [<<integer>> <<integer>>?]
Initial: normal
Applies to: <code>::first-letter</code> pseudo elements and inline level first child of a block container
Inherited: no
Percentages: N/A
Media: visual
Computed value: as described
</pre>
<div class="example">
<figure>
<img alt="3-line drop cap with C" src="Dropcap-C-3line.png" width="480">
<p class="caption">Three-line drop initial.</p>
</figure>
<pre>
p::first-letter {
initial-letter: 3;
}
</pre>
</div>
Some styles of drop initials do not align with the first line of text. For example, “sunken caps” both sink below the first baseline, and extend above the first line of text. In these cases, the size of the initial cap needs to be defined. The optional second argument of 'initial-letter' specifies the size of an initial letter, as if it were an n-line drop cap.
<div class="example">
<figure>
<img src="SunkenCapA.png" width="480" alt="sunken drop initial"/>
<p class="caption">Sunken cap. The letter drops two lines, but is the size of a three-line initial letter.</p>
</figure>
<pre>
p::first-letter {
initial-letter: 3 2;
}
</pre>
</div>
If the second argument is ''1'', that creates a pure raised initial letter (often called “raised cap” or “stick-up cap.” It “sinks” to the first text baseline.
<div class="example">
<figure>
<img src="RaisedCap.png" width="480" alt="raised cap"/>
<p class="caption">Raised cap. The initial letter is the size of a 3-line initial, but does not drop.</p>
</figure>
<pre>
p::first-letter {
initial-letter: 3 1;
}
</pre>
</div>
<h3 id="aligning-initial-letter">Alignment of Initial Letters</h3>
As mentioned earlier, the alignment of initial letters depends on the script used. The 'initial-letter-align' property can be used to specify the proper alignment.
<pre class="propdef" id="initial-letter-align">
Name: <dfn id="propdef-initial-letter-align">initial-letter-align</dfn>
Value: [ auto | alphabetic | hanging | ideographic ]
Initial: auto
Applies to: <code>::first-letter</code> pseudo elements and inline level first child of a block container
Inherited: no
Percentages: N/A
Media: visual
Computed value: ???
</pre>
<dl dfn-type="value" dfn-for="initial-letter-align">
<dt>auto</dt>
<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>
<dt>alphabetic</dt>
<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>
<dt>hanging</dt>
<dd>The hanging baseline of the initial letter aligns with the hanging baseline of the first line of text. </dd>
<dt>ideographic</dt>
<dd>The initial letter is centered in the N-line area. </dd>
</dl>
<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>
<div class="example">
The vertical writing mode example from <a href="#f2">Figure 2</a> could be coded as:
<pre>
span.initial {
initial-letter: 2;
initial-letter-alignment: ideographic;
}
</pre>
</div>
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 image must be synthesized from the content edges.
Issue: Need to decide whether using margin edges or content edges for alignment. Writing Modes uses the margin edges for baseline alignment of replaced elements. There are cases for both content-alignment and margin-alignment for text. In both cases the margin box needs to be excluded.
<h3>Sizing Initial Letters</h3>
<p>The size of a drop initial is determined by the need to satisfy the required alignment. For an N-line drop initial in a Western script, the cap-height of the letter needs to be (N – 1) times the line-height, plus the cap-height of the surrounding text. Note this height is <b>not</b> the font size of the drop initial.</p>
<p>Actually calculating this font size is tricky. For an N-line drop initial, we find the drop initial font size to be:</p>
<figure>
<img src="InitialCapEquation.png" width="604" alt="Equation to calcuate drop initial font size"/>
</figure>
<!--
<pre>
Font size of drop cap = ((N-1) * line-height + [cap-height of para] * [font size of paragraph])/[cap-height ratio of drop initial font]
</pre>
-->
<!--
<div>
<math display="block"><mrow><mi>Font size of drop initial</mi><mo>=</mo></mrow><mfrac><mrow><mo>(</mo><mi>N</mi><mo>-</mo><mn>1</mn><mo>)</mo><mo>×</mo><mi>line-height</mi><mo>+</mo><mo>(</mo><mi>cap-height ratio of para font</mi><mo>×</mo><mi>font size of para</mi><mo>)</mo></mrow><mrow><mi>cap-height ratio of drop initial font</mi></mrow></mfrac></math>
</div>
-->
<div class="example">
A three-line drop initial in Adobe Minion Pro would have a font size of 61.2pt, given 12pt text, 16pt line-height and a cap-height of 651/1000 (from the font’s OS/2 table).
</div>
The line height used in this calculation is the 'line-height' of the containing block (or, in the case where a baseline grid is in use, the baseline-to-baseline spacing required by the baseline grid [[CSS3-LINE-GRID]]). The contents of the lines spanned, and therefore any variation in their heights and positions, is not accounted for.
<h3 id="initial-letter-exclusions">Space Around Initial Letters</h3>
If an initial letter has a descender, it could crash into the (n+1)th line of text. This is not desirable.
<figure>
<img alt="3-line drop cap with J, with descender crashing into fourth line of text" src="Dropcap-J-3line-crash.png" width="480">
<p class="caption">Incorrect: three-line initial letter with descender</p>
</figure>
Text should be excluded around the glyph bounding boxes of the initial letters:
<figure>
<img alt="3-line drop cap with J, but four-line exclusion" src="Dropcap-J-3line-exclude.png" width="480">
<p class="caption">Correct: text excluded around glyph bounding box</p>
</figure>
<h3 id="initial-letter-paragraphs">Clearing Initial Letters</h3>
<h4 id="raised-sunken-caps">Raised and sunken caps</h4>
An initial letter does not affect the position of its containing element. For “raised caps” or “sunken caps,” the effect is created as if the text around the initial letter was pushed down, rather than the letter extending up into previous elements.
<figure>
<img src="initial-letter-drop-para-compare.png" alt="raised cap para after normal para" width="600"/>
<p class="caption">Raised cap (<code>initial-letter: 3 1</code>) on right; note that the position of the “C” is the same in both cases, but on the right all text is moved down relative to the initial letter.</p>
</figure>
Issue: Handle glyph ink above cap height of font.
<h4 id="short-para-initial-letter">Short paragraphs with initial letters</h4>
A paragraph with an initial letter may have fewer lines of text than the initial letter occupies. The initial letter acts as if it is a float, and the subsequent para must wrap around it.
<figure>
<img src="initial-letter-short-para.png" alt="short para with initial letter" width="600"/>
<p class="caption">The red text is a short paragraph with an initial letter. Note the subsequent paragraph wraps around the initial letter just as text in the paragraph with the initial letter does.</p>
</figure>
If the subsequent paragraph starts with an initial letter, then it must clear the previous paragraph’s initial letter.
<figure>
<img src="initial-letter-short-para-initial.png" alt="short para with initial letter followed by para with initial" width="600"/>
<p class="caption">The red text is a short paragraph with an initial letter. The subsequent paragraph clears because it also has an initial letter.</p>
</figure>
<p class="issue">Define appropriate behavior for non-western scripts. The editors would appreciate any examples of drop initials in such scripts.</p>
<h2 class="no-num" id="ack">Acknowledgments</h2>
<p>Special thanks goes to the initial authors,
Eric A. Meyer and Michel Suignard.
<p>In additions to the authors, this specification would not have been possible without the help from:
<p>David Baron, John Daggett, Stephen Deach, Sujal Parikh, Grzegorz Zygmunt, Chris Wilson, David M Brown.