From 29661048af03edf0c093f339e03afc41803c6238 Mon Sep 17 00:00:00 2001 From: fantasai Date: Tue, 21 Feb 2023 13:28:22 -0500 Subject: [PATCH] [css-text-4] Redesign text-spacing * Remove non-useful keyword combinations #4246 #8288 * Split into longhands #4246 #7183 #8288 * Ensure off values for each thing #8288 #6950 * Add insert|replace to allow replacing incorrect space characters #318 #8263 #7183 * Make space-first the initial value #2462 * Allow hanging-punctuation to hang leading ideographic spaces #2462 * Move no-compress to text-justify #7079 See https://lists.w3.org/Archives/Public/www-style/2023Feb/0002.html --- css-text-4/Overview.bs | 364 ++++++++++++++++++++++++----------------- 1 file changed, 218 insertions(+), 146 deletions(-) diff --git a/css-text-4/Overview.bs b/css-text-4/Overview.bs index c89952a7b70..10eac1cdd20 100644 --- a/css-text-4/Overview.bs +++ b/css-text-4/Overview.bs @@ -6756,7 +6756,7 @@ Justification Method: the 'text-justify' property
 	Name: text-justify
-	Value: auto | none | inter-word | inter-character
+	Value: [ auto | none | inter-word | inter-character ] || no-compress
 	Initial: auto
 	Applies to: text
 	Inherited: yes
@@ -6954,6 +6954,21 @@ Justification Method: the 'text-justify' property
 			Note: This value is intended for use in [=ruby annotations=],
 			providing a reasonable default alignment.
 			See [[CSS-RUBY-1]].
+
+		
no-compress +
+ Justification must not compress spacing controlled by + 'text-spacing-trim' or 'text-autospace'. + (If this value is not specified, + the justification process may reduce such spacing + except when the spacing is at the start or end of the line.) + + Note: An example of compression rules is given for Japanese + in 3.8 Line Adjustment in [[JLREQ]]. + + Issue: This keyword used to be part of 'text-spacing'; + it might need renaming to be more specific now that it's here, + as it implies that e.g. U+0020 cannot be compressed.

@@ -7276,12 +7291,19 @@ Spacing - CSS offers control over text spacing - via the 'word-spacing' and 'letter-spacing' properties, + CSS offers control over regular text spacing + via the 'word-spacing', 'letter-spacing', and 'line-padding' properties, which specify additional space around [=word separators=] - or between [=typographic character units=], + between [=typographic character units=], + or at the start/end of the line, respectively. + It also provides contextual control over spacing + via the 'text-spacing-trim' property, + which allows for contextual fullwidth vs halfwidth setting of CJK punctuation; + and the 'text-autospace' property, + which allows automatic insertion of extra space + at script changes or around punctuation.

Word Spacing: the 'word-spacing' property

@@ -7975,146 +7997,58 @@ Line Start/End Padding: the 'line-padding' property
-

-Character Class Spacing: the 'text-spacing' property

+

+Automatic Contextual Spacing: the 'text-autospace' property

-	Name: text-spacing
-	Value: normal | none | auto | no-compress ||
-	       [ trim-start | space-start | space-first ] ||
-	       [ trim-end | space-end | allow-end ] ||
-	       [ trim-adjacent | space-adjacent ] ||
-	       ideograph-alpha || ideograph-numeric || punctuation
+	Name: text-autospace
+	Value: normal | <>
 	Initial: normal
-	Applies to: block containers
+	Applies to: text
 	Inherited: yes
 	Percentages: N/A
 	Computed value: specified keyword(s)
 	Animation type: discrete
 	
- This property controls spacing between adjacent characters - on the same line within the same inline formatting context - using a set of character-class-based rules. - Such spacing can either be created between or trimmed from the affected glyphs. - Values are defined as follows: - -
-
normal -
- Specifies the baseline behavior, - equivalent to ''space-start trim-end trim-adjacent ideograph-alpha ideograph-numeric''. - -
none -
- Turns off all text-spacing features. - All fullwidth characters are set with full-width glyphs. - -
auto -
- The user agent chooses a set of typographically high quality spacing values. - Different user agents running on different platforms may pick different values. - - Note: These spacing values may or may not match OS platform conventions. - - Note: The behavior of ''text-spacing/auto'' might not be achievable - with any combination of other values of 'text-spacing'. - -
no-compress -
- Justification must not compress text-spacing. - (If this value is not specified, the justification process may reduce autospacing - except when the spacing is at the start or end of the line.) - - Note: An example of compression rules is given for Japanese - in 3.8 Line Adjustment in [[JLREQ]]. - -
space-start -
- Set fullwidth opening punctuation with full-width glyphs (spaced) - at the start of each line. - -
trim-start -
- Set fullwidth opening punctuation with half-width glyphs (flush) - at the start of each line. + Controls spacing between adjacent characters + on the same line within the same [=inline formatting context=] + using a set of character-class-based rules, + allowing for automatic control over inter-script spacing + and for spacing around punctuation. -
space-first -
- Behaves as ''space-start'' on the first line the block container - and each line after a forced line break - but as ''trim-start'' on all other lines. - -
- This value exists for UA compat requirements, - and is not recommended for general authoring use. - This value exists to improve formatting of existing Japanese ePUB content, - for which ''trim-start'' would have been appropriate typographically, - except that they are typeset - to expect the first line to be set as ''space-first''. - - Specifically, - due to the lack of reliable 'hanging-punctuation' support across ePUB readers, - such content uses U+3000 ideographic space in place of 'text-indent', - but omits it when the paragraph begins with punctuation - that is desired to hang in the indent - in order to create the hanging punctuation effect. - Using ''trim-start'' on the first line - would thus trim away the effective indent in such content - and thus obscure that line's distinction - as the first line of a new paragraph. - - Note that this ePUB typesetting practice - is not recommended for CSS in general - (i.e. where not dictated by compat): - authors should use 'hanging-punctuation' and 'text-indent' - to control paragraph formatting - rather than tweaking the text content of the document. - This preserves the text’s true semantics in the document source - and allows the style sheet designer - to freely switch among the various spacing/indentation styles - without needing to alter the content. - See [[#japanese-start-edges]] for examples. - - UAs are encouraged to use this value - as part of their UA default style sheet for Japanese ePUB content: - to preserve the paragraph distinctions in such content - while applying ''trim-start'' behavior to wrapped lines - (which creates better optical alignment along the start edge - and helps emphasize paragraph breaks denoted by indentation). + Values are defined as follows: - ISSUE: Whether this value should also be part of the UA defaults for Web content - is currently under discussion. -
+
+		<> = no-autospace |
+		              [ ideograph-alpha || ideograph-numeric || punctuation ]
+		              || [ insert | replace ]
+	
-
allow-end +
+
normal
- Set fullwidth closing punctuation with half-width glyphs (flush) - at the end of each line - if it does not otherwise fit prior to justification; - otherwise set the punctuation with full-width glyphs. + Same behavior as ''ideograph-alpha ideograph-numeric''. -
space-end +
no-autospace
- Set fullwidth closing punctuation with full-width glyphs (spaced) - at the end of each line. + No automatic space is inserted. -
trim-end +
insert
- Set fullwidth closing punctuation with half-width glyphs (flush) - at the end of each line. + The specified spacing is automatically inserted + if there are no space characters of any kind ([=Unicode general category=] Z) already there. -
space-adjacent +
replace
- Set fullwidth opening punctuation with full-width glyphs (spaced) - when not at the start of the line. - Set fullwidth closing punctuation with full-width glyphs (spaced) - when not at the end of the line. + The specified spacing is automatically inserted + even if there is already a [=space=] (U+0020) at that point; + additionally, the [=space=] (U+0020) is removed. + Other types of space characters ([=Unicode general category=] Z) + suppress automatic spacing, as for ''text-autospace/insert''. -
trim-adjacent -
- Collapse spacing between punctuation glyphs - as described below. + Note: This is for correcting text which is using the easy-to-type U+0020 + instead of proper spacing.
ideograph-alpha
@@ -8137,29 +8071,15 @@ Character Class Spacing: the 'text-spacing' property where required by French typographic guidelines. Otherwise this value has no effect. However future specifications may add automatic spacing behavior for other languages. - - ISSUE: Integrate rules for correcting incorrect spaces? - Issue 318
This property is additive with the 'word-spacing' and 'letter-spacing' properties. That is, the amount of spacing contributed by the 'letter-spacing' setting (if any) - is added to the spacing created by 'text-spacing'. + is added to the spacing created by 'text-autospace'. The same applies to 'word-spacing'. At element boundaries, the amount of extra spacing introduced between characters is determined by and rendered within the innermost element that contains the boundary. - If the extra spacing is applied to a particular glyph, - then the spacing is determined by the innermost element containing that glyph. - - Note: Values other than ''text-spacing/normal'', ''text-spacing/none'', ''trim-start'', ''trim-end'', and ''space-end'' - are at-risk and may be dropped from this level of CSS. - They are defined here currently to help work out a complete design of this feature. - - Support for this property is optional. - It is strongly recommended for UAs that wish to support CJK typography. - - Issue: It was requested to add a value for doubling the space after periods.

Inter-script Spacing

@@ -8181,6 +8101,108 @@ Inter-script Spacing A future level of this module may introduce control over the amount of spacing. +

+CJK Punctuation Spacing: the 'text-spacing-trim' property

+ +
+	Name: text-spacing-trim
+	Value: <> | auto
+	Initial: space-first
+	Applies to: text
+	Inherited: yes
+	Percentages: N/A
+	Computed value: specified keyword(s)
+	Animation type: discrete
+	
+ + Controls spacing around CJK punctuation characters + on the same line within the same [=inline formatting context=] + using a set of character-class-based rules, + allowing them to be set halfwidth or fullwidth + based on their position and neighbors within the line. + + Values are defined as follows: + +
+		<> = space-all |  trim-auto | [ allow-end || space-first ]
+	
+ +
+ +
space-all +
+ All fullwidth punctuation characters are set with full-width glyphs (spaced). + +
trim-auto +
+ Set fullwidth opening punctuation with half-width glyphs (flush) + at the start of each line; + set fullwidth closing punctuation with half-width glyphs (flush) + at the end of each line; + and collapse spacing between punctuation glyphs + as described below. + +
space-first +
+ Set fullwidth opening punctuation with full-width glyphs (spaced) + on the first line the [=block container=]. + Otherwise as ''trim-auto'' + (unless ''text-spacing-trim/allow-end'' is also specified). + +
+ This value exists for compat requirements. + + This value exists to manage formatting of existing Chinese and Japanese content, + for which ''trim-auto'' would have been appropriate typographically, + except that they are already written + to expect the first line to be set as for ''space-all''. + + Specifically, + due to the lack of reliable 'hanging-punctuation' support across UAs, + existing content (especially ePub content) + uses U+3000 ideographic space in place of 'text-indent', + but omits it when the paragraph begins with punctuation + that is desired to hang in the indent + in order to create the hanging punctuation effect. + Using ''trim-auto'' on the first line + would thus trim away the effective indent in such content + and thus obscure that line's distinction + as the first line of a new paragraph. + + Note that this typesetting practice + of using ideographic spaces for indentation + (sometimes and not always) + is contrary to the separation of content and style offered by HTML and CSS. + Using 'hanging-punctuation' and 'text-indent' + to control paragraph formatting + rather than tweaking the text content of the document + preserves the text’s true semantics in the document source + and allows the style sheet designer + to freely switch among the various spacing/indentation styles + without needing to alter the content. + See [[#japanese-start-edges]] for examples. +
+ +
allow-end +
+ Set fullwidth closing punctuation with half-width glyphs (flush) + at the end of each line + if it does not otherwise fit prior to justification, + else set the punctuation with full-width glyphs. + Otherwise as ''trim-auto'' + (unless ''space-first'' is also specified). + +
auto +
+ The user agent chooses a set of typographically high quality spacing values. + Different user agents running on different platforms may pick different values. + + Note: These spacing values may or may not match OS platform conventions. + + ISSUE: Do we need ''text-spacing-trim/auto''? It would be weird for the author to choose platform-dependent behavior at the start of the first line, and it should otherwise use ''text-spacing-trim/trim-auto''. +
+ +

Fullwidth Punctuation Collapsing

@@ -8188,7 +8210,7 @@ Fullwidth Punctuation Collapsing as a standard Han character (e.g. 水 U+6C34). However, many fullwidth punctuation glyphs only take up part of the fullwidth design space. Thus such punctuation are not always set fullwidth. - Several values of 'text-spacing' allow the author to control + Several values of 'text-spacing-trim' allow the author to control when such characters are set half-width (typically half the width of an ideograph) and when they are set full-width. @@ -8231,7 +8253,7 @@ Fullwidth Punctuation Collapsing the font has proportional ideographs and the fullwidth advance width cannot be reliably determined by measuring glyphs. - Unless 'text-spacing' is set to ''space-adjacent'' or ''text-spacing/none'' + Unless 'text-spacing-trim' is set to ''space-all'' (or the font has proportional fullwidth punctuation glyphs), the UA must collapse the space typically associated with such full width glyphs when placed adjacently on a line @@ -8447,7 +8469,7 @@ Japanese Paragraph-start Conventions in CSS p { /* Flush alignment */ margin: 0; text-indent: 1em; - text-spacing: trim-start; + text-spacing-trim: trim-auto; } @@ -8457,7 +8479,7 @@ Japanese Paragraph-start Conventions in CSS p { /* Fullwidth alignment */ margin: 0; text-indent: 1em; - text-spacing: normal; + text-spacing-trim: space-all; } @@ -8467,7 +8489,7 @@ Japanese Paragraph-start Conventions in CSS p { /* Hanging alignment */ margin: 0; text-indent: 1em; - text-spacing: trim-start; + text-spacing-trim: trim-auto; hanging-punctuation: first; } @@ -8475,6 +8497,55 @@ Japanese Paragraph-start Conventions in CSS +

+Character Class Spacing Shorthand: the 'text-spacing' property

+ +
+	Name: text-spacing
+	Value: normal | none | auto | <> || <>
+	Initial: see individual properties
+	Applies to: text
+	Inherited: yes
+	Percentages: N/A
+	Computed value: specified keyword(s)
+	Animation type: discrete
+	
+ + This property is a shorthand + for setting 'text-spacing-trim' and 'text-autospace' in a single declaration. + Values are defined as follows: + +
+
normal +
+ Specifies the baseline behavior, + setting each [=sub-property=] to its [=initial value=]. + Equivalent to ''space-first ideograph-alpha ideograph-numeric''. + +
none +
+ Turns off all text-spacing features: + sets 'text-spacing-trim' to ''space-all'' + and 'text-autospace' to ''no-autospace''. + +
auto +
+ Sets both 'text-spacing-trim' and 'text-autospace' to ''text-autospace/auto''. + +
<> +
+ Sets 'text-spacing-trim' to the specified value. + If no <> value is given, + 'text-autospace' is set to its [=initial value=]. + +
<> +
+ Sets 'text-autospace' to the specified value. + If no <> value is given, + 'text-spacing-trim' is set to its [=initial value=]. +
+ +

Shaping Across Element Boundaries

@@ -9021,11 +9092,12 @@ Hanging Punctuation: the 'hanging-punctuation' property
first
- An opening bracket or quote at the start + An opening bracket, quote, or ideographic space at the start of the [[CSS2/selector#first-line-pseudo|first formatted line]] of an element [=hangs=]. This applies to all characters in the Unicode categories Ps, Pf, Pi - plus the ASCII quote marks U+0027 ' APOSTROPHE and U+0022 " QUOTATION MARK. + plus the ASCII quote marks U+0027 ' APOSTROPHE and U+0022 " QUOTATION MARK + and the IDEOGRAPHIC SPACE U+3000. hanging-punctuation/hanging-punctuation-first-001.xht