Skip to content

Commit b065d57

Browse files
committed
[css-text] Improve text-justify rules.
1 parent 4655559 commit b065d57

3 files changed

Lines changed: 139 additions & 99 deletions

File tree

css-text/Overview.html

Lines changed: 88 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
rel=dcterms.rights>
1111
<meta content="CSS Text Module Level 3 (CSS3 Text)" name=dcterms.title>
1212
<meta content=text name=dcterms.type>
13-
<meta content=2013-05-10 name=dcterms.date>
13+
<meta content=2013-05-11 name=dcterms.date>
1414
<meta content="Elika J. Etemad" name=dcterms.creator>
1515
<meta content="Koji Ishii" name=dcterms.creator>
1616
<meta content=W3C name=dcterms.publisher>
@@ -43,12 +43,12 @@
4343

4444
<h1>CSS Text Module Level 3</h1>
4545

46-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 10 May 2013</h2>
46+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 11 May 2013</h2>
4747

4848
<dl>
4949
<dt>This version:</dt>
5050
<!--
51-
<dd><a href="http://www.w3.org/TR/2013/WD-css3-text-20130510/">http://www.w3.org/TR/2013/WD-css3-text-20130510/</a></dd>
51+
<dd><a href="http://www.w3.org/TR/2013/WD-css3-text-20130511/">http://www.w3.org/TR/2013/WD-css3-text-20130511/</a></dd>
5252
-->
5353

5454
<dd><a
@@ -2036,9 +2036,9 @@ <h3 id=text-justify><span class=secno>7.3. </span> Justification Method:
20362036
for Japanese, using cursive elongation for Arabic, using ‘<code
20372037
class=css>inter-word</code>’ for English, etc. Another possibility is
20382038
to use a justification method that is a simple universal compromise for
2039-
all writing systems, such as primarily expanding <i>word separators</i>
2040-
along with expanding between CJK and Southeast Asian <a
2041-
href="#letter0"><i>letters</i></a>.
2039+
all writing systems, such as primarily expanding <a
2040+
href="#word-separator"><i>word separators</i></a> along with expanding
2041+
between CJK and Southeast Asian <a href="#letter0"><i>letters</i></a>.
20422042

20432043
<div class=figure id=fig-text-justify-cursive>
20442044
<p> <img
@@ -2072,9 +2072,11 @@ <h3 id=text-justify><span class=secno>7.3. </span> Justification Method:
20722072
class=css>inter-word</code></dfn>
20732073

20742074
<dd>Justification primarily varies the used ‘<a
2075-
href="#word-spacing0"><code class=property>word-spacing</code></a>’.
2076-
This behavior is typical for languages that separate words using spaces,
2077-
like English or Korean.
2075+
href="#word-spacing0"><code class=property>word-spacing</code></a>’;
2076+
the first-level <a href="#expansion-opportunity"><i>expansion
2077+
opportunities</i></a> are at <a href="#word-separator"><i>word
2078+
separators</i></a>. This behavior is typical for languages that separate
2079+
words using spaces, like English or Korean.
20782080
<div class=figure id=fig-text-justify-distribute>
20792081
<p> <img alt="Extra space is equally distributed mainly to spaces."
20802082
class=example src=text-justify-interword.png>
@@ -2099,8 +2101,11 @@ <h3 id=text-justify><span class=secno>7.3. </span> Justification Method:
20992101
class=css>distribute</code></dfn>
21002102

21012103
<dd>Justification primarily varies the used ‘<a
2102-
href="#letter-spacing0"><code class=property>letter-spacing</code></a>
2103-
(excepting between <a href="#letter0"><i>letters</i></a> in <a
2104+
href="#letter-spacing0"><code
2105+
class=property>letter-spacing</code></a>’; the first-level <a
2106+
href="#expansion-opportunity"><i>expansion opportunities</i></a> are
2107+
between adjacent <a href="#character"><i>characters</i></a> (except
2108+
between <a href="#letter0"><i>letters</i></a> in <a
21042109
href="#cursive-scripts"><i>cursive scripts</i></a> such as Arabic). This
21052110
value is sometimes used in e.g. Japanese.
21062111
<div class=figure id=fig-text-justify-distribute>
@@ -2164,35 +2169,72 @@ <h3 id=text-justify><span class=secno>7.3. </span> Justification Method:
21642169
href="#expansion-opportunity"><i>expansion opportunities</i></a> and
21652170
limits were assigned weights and assessed with other line breaking
21662171
considerations. This algorithm could follow the guidelines by giving more
2167-
weight to <i>word separators</i> than letter spacing.
2172+
weight to <a href="#word-separator"><i>word separators</i></a> than
2173+
letter spacing.
21682174
</div>
21692175

21702176
<p>CSS defines <dfn id=expansion-opportunity
21712177
title="expansion opportunity">expansion opportunities</dfn> as points
2172-
where the justification algorithm may alter spacing within the text. These
2173-
<a href="#expansion-opportunity"><i>expansion opportunities</i></a> fall
2174-
into priority levels as defined by the justification method. Within a
2175-
line, expansion and compression primarily target the first-priority
2176-
expansion opportunities; secondary expansion opportunities may be adjusted
2177-
at a lower priority.
2178-
2179-
<p>Expansion and compression limits are given by the <a
2180-
href="#letter-spacing">letter-spacing</a> and <a
2181-
href="#word-spacing">word-spacing</a> properties. How any remaining space
2182-
is distributed once all <a href="#expansion-opportunity"><i>expansion
2183-
opportunities</i></a> reach their limits is up to the UA. If the inline
2184-
contents of a line cannot be stretched to the full width of the line box,
2185-
then they must be aligned as specified by the ‘<a
2186-
href="#text-align-last0"><code
2178+
where the justification algorithm may alter spacing within the text. <a
2179+
href="#expansion-opportunity"><i>Expansion opportunities</i></a> are
2180+
divided into different priority levels: within a level, all <a
2181+
href="#expansion-opportunity"><i>expansion opportunities</i></a> are
2182+
expanded or compressed by the same amount, in proportion to the <a
2183+
href="#expansion-opportunity"><i>expansion opportunity</i></a>’s
2184+
<code class=property>font-size</code>’. In the case of an <a
2185+
href="#expansion-opportunity"><i>expansion opportunity</i></a> introduced
2186+
by a single <a href="#character"><i>character</i></a>, (as with ‘<a
2187+
href="#word-spacing0"><code class=property>word-spacing</code></a>’) the
2188+
<code class=property>font-size</code>’ of that <a
2189+
href="#character"><i>character</i></a> is used; in the case of an <a
2190+
href="#expansion-opportunity"><i>expansion opportunity</i></a> between <a
2191+
href="#character"><i>characters</i></a>, (as with ‘<a
2192+
href="#letter-spacing0"><code class=property>letter-spacing</code></a>’)
2193+
the ‘<code class=property>font-size</code>’ of the innermost element
2194+
containing their boundary is used.
2195+
2196+
<p>Characters from the Unicode Symbols (S*) and Punctuation (P*) classes
2197+
are generally treated the same as a <a href="#letter0"><i>letter</i></a>;
2198+
in the case of ‘<code class=css>inter-word</code>’, as a Latin <a
2199+
href="#letter0"><i>letter</i></a>, in the case of ‘<code
2200+
class=css>distribute</code>’, as a Han <a
2201+
href="#letter0"><i>letter</i></a>, and in the case of ‘<a
2202+
href="#auto1"><code class=css>auto</code></a>’, as a <a
2203+
href="#letter0"><i>letter</i></a> of the dominant script. However, by
2204+
typographic tradition there may be additional rules controlling the
2205+
justification of symbols and punctuation. Therefore, the UA may reassign
2206+
specific characters or introduce additional levels of prioritization to
2207+
handle <a href="#expansion-opportunity"><i>expansion opportunities</i></a>
2208+
involving symbols and punctuation.
2209+
2210+
<p class=example> For example, there are traditionally no <a
2211+
href="#expansion-opportunity"><i>expansion opportunities</i></a> between
2212+
consecutive EM DASH U+2014, HORIZONTAL BAR U+2015, HORIZONTAL ELLIPSIS
2213+
U+2026, or TWO DOT LEADER U+2025 characters <a href="#JLREQ"
2214+
rel=biblioentry>[JLREQ]<!--{{JLREQ}}--></a>; thus a UA might assign these
2215+
characters to a "never" prioritization level. As another example, certain
2216+
fullwidth punctuation characters are considered to contain an <a
2217+
href="#expansion-opportunity"><i>expansion opportunity</i></a> in
2218+
Japanese. The UA might therefore assign these characters to a higher
2219+
prioritization level than the opportunities between ideographic
2220+
characters.
2221+
2222+
<p>The <a href="#word-spacing">word-spacing</a> property can specify limits
2223+
on <a href="#expansion-opportunity"><i>expansion opportunities</i></a>
2224+
introduced by <a href="#word-separator"><i>word separators</i></a>. How
2225+
any remaining space is distributed once all <a
2226+
href="#expansion-opportunity"><i>expansion opportunities</i></a> reach
2227+
their limits is up to the UA. If the inline contents of a line cannot be
2228+
stretchedto the full width of the line box, then they must be aligned as
2229+
specified by the ‘<a href="#text-align-last0"><code
21872230
class=property>text-align-last</code></a>’ property. (If ‘<a
21882231
href="#text-align-last0"><code
21892232
class=property>text-align-last</code></a>’ is ‘<code
21902233
class=css>justify</code>’, then they must be aligned as for ‘<code
21912234
class=css>center</code>’ if ‘<a href="#text-justify0"><code
21922235
class=property>text-justify</code></a>’ is ‘<code
2193-
class=css>distribute</code>’ and as ‘<code class=css>start</code>
2194-
otherwise.)</p>
2195-
<!--
2236+
class=css>distribute</code>’, and as ‘<code class=css>start</code>
2237+
otherwise.) <!--
21962238
<p>The <i>expansion opportunity</i> priorities for values of 'text-justify'
21972239
are given in the table below. Since justification behavior
21982240
varies by writing system, <i>expansion opportunities</i> are organized by
@@ -2315,25 +2357,7 @@ <h3 id=text-justify><span class=secno>7.3. </span> Justification Method:
23152357
classes.
23162358
The default justification priority of these <i>expansion opportunities</i> is given above.
23172359
-->
2318-
2319-
<p>Characters from the Unicode Symbols (S*) and Punctuation (P*) classes
2320-
are generally treated the same as any <a
2321-
href="#letter0"><i>letter</i></a>. However, there may be additional rules
2322-
controlling their justification behavior due to typographic tradition.
2323-
Therefore, the UA may reassign specific characters or introduce additional
2324-
levels of prioritization to handle <a
2325-
href="#expansion-opportunity"><i>expansion opportunities</i></a> involving
2326-
symbols and punctuation. For example, there are traditionally no <a
2327-
href="#expansion-opportunity"><i>expansion opportunities</i></a> between
2328-
consecutive EM DASH U+2014, HORIZONTAL BAR U+2015, HORIZONTAL ELLIPSIS
2329-
U+2026, or TWO DOT LEADER U+2025 characters <a href="#JLREQ"
2330-
rel=biblioentry>[JLREQ]<!--{{JLREQ}}--></a>; thus a UA might assign these
2331-
characters to a "never" prioritization level. As another example, certain
2332-
fullwidth punctuation characters are considered to contain an <a
2333-
href="#expansion-opportunity"><i>expansion opportunity</i></a> in
2334-
Japanese. The UA might therefore assign these characters to a higher
2335-
prioritization level than the opportunities between ideographic
2336-
characters. <!--
2360+
<!--
23372361
<p id="justify-cursive">For justification of <i>cursive scripts</i>,
23382362
words may be expanded through kashida elongation or other cursive
23392363
expansion processes. Kashida may be applied in discrete units or
@@ -2543,15 +2567,17 @@ <h3 id=word-spacing><span class=secno>8.1. </span> Word Spacing: the ‘<a
25432567
<pre>p { word-spacing: 0.5ch; }</pre>
25442568
</div>
25452569

2546-
<p><dfn id=word-separator>Word-separator characters</dfn> include the space
2547-
(U+0020), the no-break space (U+00A0), the Ethiopic word space (U+1361),
2548-
the Aegean word separators (U+10100,U+10101), the Ugaritic word divider
2549-
(U+1039F), and the Phoenician Word Separator (U+1091F). If there are no
2550-
word-separator characters, or if the word-separating character has a zero
2551-
advance width (such as the zero width space U+200B) then the user agent
2552-
must not create an additional spacing between words. General punctuation
2553-
and fixed-width spaces (such as U+3000 and U+2000 through U+200A) are not
2554-
considered word-separator characters.
2570+
<p><dfn id=word-separator
2571+
title="word-separator character | word separator">Word-separator
2572+
characters</dfn> include the space (U+0020), the no-break space (U+00A0),
2573+
the Ethiopic word space (U+1361), the Aegean word separators
2574+
(U+10100,U+10101), the Ugaritic word divider (U+1039F), and the Phoenician
2575+
Word Separator (U+1091F). If there are no word-separator characters, or if
2576+
a word-separating character has a zero advance width (such as the zero
2577+
width space U+200B) then the user agent must not create an additional
2578+
spacing between words. General punctuation and fixed-width spaces (such as
2579+
U+3000 and U+2000 through U+200A) are not considered word-separator
2580+
characters.
25552581

25562582
<h3 id=letter-spacing><span class=secno>8.2. </span> Tracking: the ‘<a
25572583
href="#letter-spacing0"><code class=property>letter-spacing</code></a>
@@ -2631,9 +2657,10 @@ <h3 id=letter-spacing><span class=secno>8.2. </span> Tracking: the ‘<a
26312657

26322658
<p>Letter-spacing must not be applied at the beginning or at the end of a
26332659
line. The total letter spacing between two adjacent <a
2634-
href="#character"><i>characters</i></a> (after bidi reordering) is given
2635-
by and rendered within the innermost element that <em>contains</em> the
2636-
boundary between the two <a href="#character"><i>characters</i></a>.
2660+
href="#character"><i>characters</i></a> (after bidi reordering) is
2661+
specified by and rendered within the innermost element that
2662+
<em>contains</em> the boundary between the two <a
2663+
href="#character"><i>characters</i></a>.
26372664

26382665
<p>For the purpose of letter-spacing, each consecutive run of atomic
26392666
inlines (such as image and/or inline blocks) is treated as a single <a

0 commit comments

Comments
 (0)