diff --git a/css-inline-3/Overview.bs b/css-inline-3/Overview.bs
index 803680d39913..319be8f18498 100644
--- a/css-inline-3/Overview.bs
+++ b/css-inline-3/Overview.bs
@@ -981,7 +981,7 @@ Line Spacing: the 'line-height' property
Initial: normal
Applies to: non-replaced inline boxes and SVG text content elements
Inherited: yes
- Percentages: computed relative to ''1em''
+ Percentages: see below
Computed value: the specified keyword, a number, or a computed <> value
Animation type: by computed value type
@@ -1002,7 +1002,7 @@ Line Spacing: the 'line-height' property
normal
Determine the [=preferred line height=]
- automatically based on font metrics.
+ automatically based on the metrics of the used font.
<>
@@ -1012,14 +1012,15 @@ Line Spacing: the 'line-height' property
<>
The [=preferred line height=] is this number
- multiplied by the element's computed 'font-size'.
+ multiplied by the element's used 'font-size'.
Negative values are illegal.
The [=computed value=] is the same as the [=specified value=].
<>
The [=preferred line height=]
- and [=computed value=] of the property
+ is this percentage of the element's used 'font-size'.
+ The [=computed value=] of the property
is this percentage of the element's computed 'font-size'.
Negative values are illegal.
diff --git a/css-text-4/Overview.bs b/css-text-4/Overview.bs
index f7b418cf494a..6eaaac1ba5ea 100644
--- a/css-text-4/Overview.bs
+++ b/css-text-4/Overview.bs
@@ -9737,6 +9737,174 @@ Aligning a block of text within its container: the 'text-group-align' property
+
+Text fitting: the 'text-fit' property
+
+
+
+
+ Name: text-fit
+ Value: [ none | grow | shrink ] [consistent | per-line | per-line-all]? <>?
+ Initial: none
+ Applies to: block containers
+ Inherited: no
+ Percentages: N/A
+ Computed value: specified keywords or computed <> value
+ Canonical order: per grammar
+ Animation type: discrete
+
+
+ The 'text-fit' property describes how [=inline-level=] contents are
+ scaled if they do not fit to the [=line box=].
+
+
Values have the following meanings:
+
+
+ - none
+
-
+ The user agent doesn't scale [=inline-level=] contents to fit to
+ the [=line box=].
+
+
+ - grow
+
-
+ The user agent scales up [=inline-level=] contents to fit to the
+ [=line box=].
+
+
+ - shrink
+
-
+ The user agent scales down [=inline-level=] contents to fit to the
+ [=line box=].
+
+
+ - consistent
+
-
+ Specifies that all lines in the container are scaled with a single
+ scaling factor.
+ This keyword has no effect if ''text-fit/none'' is specified.
+ If none of ''text-fit/consistent'', ''text-fit/per-line'', or
+ ''text-fit/per-line-all'' are specified, ''text-fit/consistent'' is
+ assumed.
+
+
+ - per-line
+
-
+ Specifies that each line is scaled with its own scaling factor.
+ However, the last line of the block and lines that end in a forced
+ break are not scaled.
+ This keyword has no effect if ''text-fit/none'' is specified.
+
+
+ - per-line-all
+
-
+ Specifies that each line is scaled with its own scaling factor,
+ including the last line of the block and lines that end in a forced
+ break.
+ This keyword has no effect if ''text-fit/none'' is specified.
+
+
+ - <percentage>
+
-
+ Specifies the limit of the scaling factor.
+ If ''text-fit/grow'' is specified and the value is 100% or greater,
+ it is the maximum scaling factor.
+ If ''text-fit/shrink'' is specified and the value is between 0% and
+ 100% inclusive, it is the minimum scaling factor.
+ Otherwise, or if this component is omitted, there is no limit on
+ the scaling factor.
+
+
+
+ This property provides a functionality to make [=inline-level=] contents
+ exactly fill the inline size of the [=line box=].
+ Unlike ''text-align/justify'' of the 'text-align' property, which achieves
+ this by adjusting spacing between characters, this property scales the
+ font size.
+
+
When ''text-fit/grow'' or ''text-fit/shrink'' is specified,
+ a [=line scaling factor=] is computed for each [=line box=].
+ If ''text-fit/consistent'' applies, all [=line boxes=] are scaled by the
+ smallest computed [=line scaling factor=].
+ Otherwise, each [=line box=] is scaled by its own [=line scaling factor=].
+
+
This property does not affect the 'font-size' [=computed value=],
+ and thus does not affect font-size-relative <> values of other properties.
+ For example, "line-height: 1.5em" and "letter-spacing: 0.1em" are not
+ affected by this scaling.
+
+ The [=used value=] of the text 'font-size' is its [=computed value=]
+ multiplied by the [=line scaling factor=].
+
+
Scaling can change the [=block size=] of a [=line box=],
+ which can in turn change its position along the [=block-axis=].
+ If any feature is active that would cause the [=inline size=] of the
+ [=line box=] to change based on its [=block-axis=] position (such as
+ 'float' or 'initial-letter'), scaling is disabled for the block.
+
+
+ If the [=inline size=] of a block container depends on the size of
+ the viewport, its apparent [=inline size=] may not change even if
+ the user changes the page zoom level.
+ In that case, if text is fitted with this feature, the text size may
+ not change at all even though the zoom level has changed.
+ There is no agreement yet on how to deal with this issue. See
+
csswg#12886.
+
+
+ Computing line scaling factor
+
+ The parts of the [=line box=]'s contents that can be scaled by this
+ property are called scalable parts.
+ These include:
+
+
+ -
+ Text, including text in [=inline boxes=], but excluding trailing
+ white space.
+
+
-
+ Spacing whose [=inline size=] is proportional to the 'font-size'
+ used value.
+ E.g. percentage-based 'letter-spacing' or 'word-spacing', and 'text-autospace'.
+
+
+
+ 'text-indent', 'line-padding', non-percentage-based 'letter-spacing' and
+ 'word-spacing', and [=atomic inlines=] are not [=scalable parts=].
+ The [=inline-axis=] 'padding', 'border', and 'margin' of inline boxes are
+ also not [=scalable parts=].
+
+
A line scaling factor is the ratio by which the
+ [=scalable parts=] of a line must be scaled in order to make its
+ [=inline-level=] content exactly fit the [=line box=]’s [=inline size=].
+
+
A [=line scaling factor=] is computed from:
+
+
+ - The total [=inline size=] of the [=scalable parts=] in the line.
+
-
+ The remaining space in the [=line box=], including any trailing whitespace
+ (which may be negative if the content overflows the [=line box=]).
+
+
+ If a <> is specified, it clamps the [=line scaling factor=].
+
+
+ A simple calculation for the [=line scaling factor=] would be
+ (A + B) / A, where A is the total [=inline size=] of
+ [=scalable parts=] and B is the remaining space.
+ However, due to [[css-fonts-4#font-optical-sizing-def|optical sizing]], the
+ [=inline size=] of text might not be perfectly proportional to its
+ 'font-size'.
+ The exact method for determining a reasonable [=line scaling factor=]
+ is up to the implementation.
+
+
The [=line scaling factor=] for a [=line box=] with no
+ [=scalable parts=] is 1.
+
Spacing
@@ -9779,7 +9947,7 @@ Word Spacing: the 'word-spacing' property
Initial: normal
Applies to: text
Inherited: yes
- Percentages: relative to computed 'font-size', i.e. ''1em''
+ Percentages: relative to used 'font-size'
Computed value: an absolute length and/or a percentage
Animation type: by computed value type
Canonical order: n/a
@@ -9977,7 +10145,7 @@ Tracking: the 'letter-spacing' property
Initial: normal
Applies to: inline boxes and text
Inherited: yes
- Percentages: relative to computed 'font-size', i.e. ''1em''
+ Percentages: relative to used 'font-size'
Computed value: an absolute length and/or a percentage
Animation type: by computed value type
Canonical order: n/a
@@ -10624,7 +10792,7 @@ Inter-script Spacing
i.e. without any intervening non-zero [=margin=], [=border=], or [=padding=]
or intervening characters (such as a quotation mark or a space).
The amount of space introduced by these keywords is 1/8 of the CJK advance measure,
- i.e ''0.125ic''.
+ i.e ''0.125ic'' if the [=used value=] of 'font-size' is same as its [=computed value=].
Note: Spacing conventions vary, but values typically range from 1/4ic to as low as 1/8ic,
with 1/4ic being more common in historical contexts due to metal type limitations
@@ -12133,6 +12301,13 @@ Text Processing Order of Operations
* 'letter-spacing', 'word-spacing', 'text-spacing', and 'line-padding'
* [[#hanging-punctuation-property|hanging punctuation]]
+
+ [[#text-fit-property|text fitting]]
+
+ * font/glyph selection
+ and positioning [[!CSS-FONTS-3]] may be done again
+ * 'letter-spacing', 'word-spacing', and 'text-spacing' may be updated.
+
[[#justification|justification]]
(which may affect glyph selection and/or text wrapping, looping back into that step)
@@ -13303,7 +13478,7 @@ Changes
Changes specific to Level 4 are listed below.
Significant changes since the 29 May 2024 Working Draft include:
- * None yet.
+ * Add 'text-fit' property.
Significant changes since the 19 February 2024 Working Draft include:
* Renamed the 'text-spacing-trim' value trim-auto to ''trim-both''.
diff --git a/css-text-decor-4/Overview.bs b/css-text-decor-4/Overview.bs
index e24aded38875..b97d522f42ec 100644
--- a/css-text-decor-4/Overview.bs
+++ b/css-text-decor-4/Overview.bs
@@ -365,7 +365,8 @@ Text Decoration Line Thickness: the 'text-decoration-thickness' property
Note: A length will inherit as a fixed value,
and will not scale with the font.
- A percentage value specifies the thickness of text decoration lines as a percentage of ''1em''.
+ A percentage value specifies the thickness of text decoration lines as a percentage of
+ the used 'font-size'.
Note: A percentage will inherit as a relative value,
and will therefore scale with changes in the font as it inherits.
@@ -706,7 +707,8 @@ Text Underline Offset: the 'text-underline-offset' property
Note: A length will inherit as a fixed value,
and will not scale with the font.
- A percentage value specifies the offset of underlines as a percentage of ''1em''.
+ A percentage value specifies the offset of underlines as a percentage of the used
+ 'font-size'.
Note: A percentage will inherit as a relative value,
and will therefore scale with changes in the font as it inherits.