@@ -2284,17 +2284,13 @@ <h4 id=justify-cursive><span class=secno>7.3.4. </span> Cursive Scripts</h4>
22842284
22852285 < h4 id =justify-alt > < span class =secno > 7.3.5. </ span > Possible Algorithms</ h4 >
22862286
2287- < p > The UA may enable or break optional ligatures or use other font features
2288- such as alternate glyphs or glyph compression to help justify the text
2289- under any method. This behavior is not controlled by this level of CSS.
2290-
2291- < div class =note >
2292- < p > The guidelines in this level of CSS do not describe a complete
2293- justification algorithm. They are merely a minimum set of requirements
2294- that a complete algorithm should meet. Limiting the set of requirements
2295- gives UAs some latitude in choosing a justification algorithm that meets
2296- their needs and desired balance of quality, speed, and complexity.
2287+ < p > The guidelines in this level of CSS do not describe a complete
2288+ justification algorithm. They are merely a minimum set of requirements
2289+ that a complete algorithm should meet. Limiting the set of requirements
2290+ gives UAs some latitude in choosing a justification algorithm that meets
2291+ their needs and desired balance of quality, speed, and complexity.
22972292
2293+ < div class =example >
22982294 < p > For instance, a basic but fast ‘< code class =css > inter-word</ code > ’
22992295 justification algorithm might use a simple greedy method for determining
23002296 line breaks, then distribute leftover space. This algorithm could follow
@@ -2309,201 +2305,34 @@ <h4 id=justify-alt><span class=secno>7.3.5. </span> Possible Algorithms</h4>
23092305 considerations. This algorithm could follow the guidelines by giving more
23102306 weight to < a href ="#word-separator "> < i > word separators</ i > </ a > than
23112307 letter spacing.
2312-
2313- < p > It's not defined whether expansion or compression is preferred, so a UA
2314- may, for example, bias towards compression for CJK languages but towards
2315- expansion for Western alphabetic languages.
23162308 </ div >
2317- <!--
2318- <p>The <i>expansion opportunity</i> priorities for values of 'text-justify'
2319- are given in the table below. Since justification behavior
2320- varies by writing system, <i>expansion opportunities</i> are organized by
2321- <a href="#script-groups">script categories</a>.
2322- An <i>expansion opportunity</i> exists between two <i>letters</i> at a
2323- priority level when at least one of them belongs to a script category
2324- at that level and the other does not belong to a higher priority level.
2325- All scripts in the same priority level must be treated exactly the same.
2326- Word separators (spaces) and other symbols and punctuation are treated
2327- specially, see below.
2328-
2329- <table class="data">
2330- <caption>Prioritization of Expansion Points</caption>
2331- <colgroup class="header"></colgroup>
2332- <colgroup span=6></colgroup>
2333- <thead>
2334- <tr>
2335- <td></td>
2336- <th>''inter-word''</th>
2337- <th>''inter-ideograph''</th>
2338- <th>''distribute''</th>
2339- <th>''inter-cluster''</th>
2340- <th>''kashida''</th>
2341- <th>''auto''</th>
2342- </tr>
2343- </thead>
2344- <tbody>
2345- <tr>
2346- <th scope="row"><a href="#block-scripts">block</a></th>
2347- <td>2</td>
2348- <td><strong>1</strong></td>
2349- <td><strong>1</strong></td>
2350- <td>3</td>
2351- <td>3</td>
2352- <td><strong>2</strong>*</td>
2353- </tr>
2354-
2355- <tr>
2356- <th scope="row"><a href="#clustered-scripts">clustered</a></th>
2357- <td>2</td>
2358- <td>2</td>
2359- <td><strong>1</strong></td>
2360- <td><strong>2</strong></td>
2361- <td>3</td>
2362- <td><strong>2</strong>*</td>
2363- </tr>
2364-
2365- <tr>
2366- <th scope="row"><a href="#cursive-scripts">cursive</a></th>
2367- <td>2</td>
2368- <td>2</td>
2369- <td>2</td>
2370- <td>3</td>
2371- <td><strong>1</strong></td>
2372- <td>3*</td>
2373- </tr>
2374-
2375- <tr>
2376- <th scope="row"><a href="#discrete-scripts">discrete</a></th>
2377- <td>2</td>
2378- <td>2</td>
2379- <td><strong>1</strong></td>
2380- <td>3</td>
2381- <td>3</td>
2382- <td>3*</td>
2383- </tr>
2384-
2385- <tr>
2386- <th scope="row"><a href="#connected-scripts">connected</a></th>
2387- <td>never</td>
2388- <td>never</td>
2389- <td>never</td>
2390- <td>never</td>
2391- <td>never</td>
2392- <td>never</td>
2393- </tr>
2394- </tbody>
2395-
2396- <tbody>
2397- <tr>
2398- <th scope="row">spaces</th>
2399- <td><strong>1</strong></td>
2400- <td><strong>1</strong></td>
2401- <td><strong>1</strong></td>
2402- <td><strong>1</strong></td>
2403- <td>2</td>
2404- <td><strong>1</strong>*</td>
2405- </tr>
2406-
2407- <tr>
2408- <th scope="row">symbols</th>
2409- <td>2</td>
2410- <td><strong>1</strong></td>
2411- <td><strong>1</strong></td>
2412- <td><strong>2</strong></td>
2413- <td>3</td>
2414- <td>*</td>
2415- </tr>
2416- </tbody>
2417- </table>
2418-
2419- <p id="auto-justify"><small>* The ''auto'' column defined above is informative; it
2420- suggests a prioritization that presents a universal compromise among
2421- justification methods.</small></p>
2422- <p id="justify-spaces">The <dfn title="spaces-category">spaces</dfn> category represents
2423- <i>expansion opportunities</i> at <a href="#word-separator">word separators</a>.
2424- (See <a href="#word-spacing">'word-spacing'</a>.)
2425- Except when 'text-justify' is ''distribute'', the UA may treat
2426- spaces differently than other <i>expansion opportunities</i> in the same priority,
2427- but must not change their priority with respect to <i>expansion opportunities</i>
2428- in other priority levels. For example, in Japanese ''inter-ideograph''
2429- justification (which treats CJK characters at a higher priority than
2430- Latin characters), word spaces traditionally have a higher priority
2431- than inter-CJK spacing, and the UA may split the 1st-priority level
2432- to implement that. However the UA is not allowed to drop either spaces
2433- or CJK characters to the same priority as Latin characters.
2434- <p id="justify-symbols">The <dfn id="punctuation-symbols">symbols</dfn>
2435- category represents the <i>expansion opportunity</i> existing at or between
2436- any pair of characters from the Unicode Symbols (S*) and Punctuation (P*)
2437- classes.
2438- The default justification priority of these <i>expansion opportunities</i> is given above.
2439- -->
2440- <!--
2441- <p id="justify-cursive">For justification of <i>cursive scripts</i>,
2442- words may be expanded through kashida elongation or other cursive
2443- expansion processes. Kashida may be applied in discrete units or
2444- continuously, and the prioritization of kashida opportunities is UA-dependent:
2445- for example, the UA may apply more at the end of the line. The
2446- UA should not apply kashida to fonts for which it is inappropriate.
2447- It may instead rely on other justification methods that lengthen
2448- or shorten Arabic segments (e.g. by substituting in swash forms or
2449- optional ligatures). Because elongation rules depend on the typeface
2450- style, the UA should rely on on the font whenever possible rather
2451- than inserting kashida based on a font-independent style rule. The UA
2452- should limit elongation so that, e.g. in multi-script lines a short
2453- stretch of Arabic will not be forced to soak up too much of the
2454- extra space by itself. If the UA does not support cursive elongation,
2455- then, as with connected scripts, no <i>expansion opportunities</i> exist between
2456- characters of these scripts.
2457- -->
24582309
24592310 < div class =example >
2460- < p > 3.8 Line Adjustment in < a href ="#JLREQ "
2311+ < p > A UA can also tailor its justification rules by language, to produce
2312+ results more closely aligned to the typography of that language. For
2313+ example, it's not defined whether expansion or compression is preferred,
2314+ so a UA may, for example, bias towards compression for CJK languages but
2315+ towards expansion for Western alphabetic languages.
2316+
2317+ < p > As another example, 3.8 Line Adjustment in < a href ="#JLREQ "
24612318 rel =biblioentry > [JLREQ]<!--{{JLREQ}}--> </ a > gives an example of a set of
2462- rules for how a text formatter can justify Japanese text. It describes
2463- rules for cases where the ‘< a href ="#text-justify0 "> < code
2319+ rules for how a text formatter can justify Japanese text. A UA could use
2320+ this algorithm when the ‘< a href ="#text-justify0 "> < code
24642321 class =property > text-justify</ code > </ a > ’ property is ‘< a
2465- href ="#auto1 "> < code class =css > auto</ code > </ a > ’.</ p >
2466- <!--
2467- <p>It produces an effect similar to cases where
2468- the computed value of 'text-spacing' property does not specify
2469- ''trim-end'' or ''space-end''.
2470- If the UA wants to prohibit this behavior,
2471- rule b. of 3.8.3 should be omitted.</p>
2472- -- >
2322+ href ="#auto1 "> < code class =css > auto</ code > </ a > ’. However, since the
2323+ rules described in the document specifically target Japanese, they may
2324+ produce non-optimal results when used to justify other languages such as
2325+ English. The UA could adapt the rules to accommodate other scripts by,
2326+ for instance, omitting the rule to compress half-width spaces (rule a. of
2327+ 3.8.3). Or it could keep the rule, but only enable it when the content
2328+ language is known to be Japanese.
2329+ </ div >
24732330
2474- < p > Note that the rules described in the document specifically target
2475- Japanese. Therefore they may produce non-optimal results when used to
2476- justify other languages such as English. To make the rules more
2477- applicable to other scripts, the UA could, for instance, omit the rule to
2478- compress half-width spaces (rule a. of 3.8.3).</ p >
2479- <!--
2480- <p>JIS X-4051 [[JIS4051]] defines how a text formatter can justify Japanese text.
2481- Here is one example of the interpretation of JIS X-4051 with slight modification.</p>
2482- <ol>
2483- <li>If no justification is necessary, neither compression nor expansion occur.</li>
2484- <li>If justification is necessary,
2485- take the first soft wrap opportunity beyond the end of line
2486- and apply the following rules (in order) to compress until it fits.
2487- <ol style="list-style-type:lower-alpha">
2488- <li>Compress space characters up to the minimum value specified by 'word-spacing' property, or up to 1/4em.</li>
2489- <li>Compress <a href="#fullwidth-middle-dot-punctuation">fullwidth middle dot punctuations</a>
2490- and <a href="#fullwidth-colon-punctuation">fullwidth colon punctuations</a>
2491- up to 1/2em, by trimming the same amount of spaces from both sides of the characters.</li>
2492- <li>Compress the left side of <a href="#fullwidth-opening-punctuation">fullwidth opening punctuations</a>
2493- and the right side of <a href="#fullwidth-closing-punctuation">fullwidth closing punctuations</a>
2494- up to 1/2em.</li>
2495- <li>Compress spaces created by 'text-spacing' property up to 1/8em.</li>
2496- </ol></li>
2497- <li>If the compression fails to fit the line,
2498- take the last soft wrap opportunity before the end of line,
2499- and apply the following rules (in order) to expand until it fits.
2500- <ol style="list-style-type:lower-alpha">
2501- <li>Expand space characters up to the maximum value specified by 'word-spacing' property, or up to 1/2em.</li>
2502- <li>Expand spaces created by 'text-spacing' property up to 1/2em.</li>
2503- <li>Expand all expansion opportunities as defined above in equal percent of the size of each character.</li>
2504- </ol></li>
2505- </ol>
2506- --> </ div >
2331+ < p > The UA may enable or break optional ligatures or use other font features
2332+ such as alternate glyphs or glyph compression to help justify the text
2333+ under any method. This behavior is not controlled by this level of CSS.
2334+ However, UAs < em > must not</ em > break required ligatures or otherwise
2335+ disable features required to correctly shape complex scripts.
25072336
25082337 < h2 id =spacing > < span class =secno > 8. </ span > Spacing</ h2 >
25092338
0 commit comments