Repository navigation
[css-text-4] turning things on and off, and default values of the text-spacing property #8288
Description
Opening a new issue to track a follow up discussion of a previous one.
In #6950 (comment), @MurakamiShinyu wrote:
The
text-spacing: normaldefinition is now:
normal-- Specifies the baseline behavior, equivalent tospace-start trim-end trim-adjacent ideograph-alpha ideograph-numeric.I am a little confused about the "baseline behavior.
Before ideograph-alpha and ideograph-numeric were added to
normaldefinition, the meaning was clear to me, that is, the each value included in the definition ofnormalis the default value, so when we specify the text-spacing property partially changed fromnormalwe can specify just changed values and omit values that are included in thenormaldefinition.
For example, when justtext-spacing: trim-startis specified, it implies omitted normal values, trim-end and trim-adjacent. i.e.,text-spacing: trim-startwas equivalent totext-spacing: trim-start trim-end trim-adjacent.However, after ideograph-alpha and ideograph-numeric were added to
normaldefinition, it is no longer that simple. Istext-spacing: trim-startequivalent totext-spacing: trim-start trim-end trim-adjacent ideograph-alpha ideograph-numeric? That will be useful when we want to change only trim-start/space-start/space-first behavior and keep othernormalbehavior, but if so, how do we change just ideograph-alpha/ideograph-numeric behavior fromnormal?Then I decided to interpret it as follows:
text-spacing: trim-startis still equivalent totext-spacing: trim-start trim-end trim-adjacent. The omitted default *-start/first, *-end, and *-adjacent are kept but ideograph-alpha and ideograph-numeric are turned off.- ideograph-alpha and ideograph-numeric are turned on only when these values are explicitly specified, or
normal(orauto, probably) is specified.(I implemented it in Vivliostyle.js as per this interpretation. vivliostyle/vivliostyle.js#1080)
However this spec is not very clear and not very useful.
It would be better adding a new keyword,
no-interscript-space, to turn off the interscript spacing.The
ideograph-alpha || ideograph-numericpart of the value definition becomes[no-interscript-space | ideograph-alpha || ideograph-numeric]and we can specify only this part to the text-spacing property when keeping other default (normal) behavior.
He then followed up with:
Or maybe it would be better to change the
ideograph-alpha || ideograph-numericvalue toideograph-alpha <number> || ideograph-numeric <number>where the<number>represents the space width as a multiple of the fullwidth advance measure. Thenormaldefinition would containideograph-alpha 0.125 ideograph-numeric 0.125. Examples:
text-spacing: ideograph-alpha 0 ideograph-numeric 0turns off the ideograph-alpha/ideograph-numeric spacing and keeps othernormalbehavior.text-spacing: trim-startonly changes the *-start/first part ofnormalbehavior. i.e, is equivalent totext-spacing: trim-start trim-end trim-adjacent ideograph-alpha 0.125 ideograph-numeric 0.125.
Activity
frivoal commentedon Jan 9, 2023
I suspect we should (re)design
text-spacingas if it had several longhands (and possibly add them, in a later extension). One (or 2?) are about line start and end, one about inter character spacing… So, on the short hand, if you specify a value for one of the longhands but not the others, the others go back to their initial value. Not sure we need the longhands now, but we should design so that we can have them.One oddity of the current value spaces is that some topics have an explicit no-op value, while other are just part of the global
none.space-startis the no-op oftrim-startandspace-firstspace-endis the no-op oftrim-endandallow-endspace-adjacentis the no-op oftrim-adjacentbut
ideograph-alphaandideograph-numericandpunctuationdon't have an explicit no-opSo, the implied behavior is:
space-start,trim-start, orspace-first, behave asnormal, i.e.space-firstspace-end,allow-end, ortrim-end, behave asnormal, i.e.trim-endspace-adjacentnortrim-adjacent, behave asnormal, i.e.trim-adjacentSo far so good, and that would map pretty well to longhand-like behavior. But how do we group the rest?
ideograph-alphaandideograph-numericprobably belong in the same group, and if you specify neither you should get default/normalbehavior, which is both of them, notnone. So we need a none-like value (which @MurakamiShinyu proposed asno-interscript-space).I suspect
punctuationis a separate group on its own. Since it is default off, we don't have to have an explicit off value, but if everything else does, maybe it should too.Maybe same thing for no-compress, though I am less sure, it's it's kind of flipped.
This gives the following longhands (maybe exposed to authors, maybe conceptual only):
text-spacing-start: auto | space-start | trim-start | space-firstwith initial valuespace-firsttext-spacing-end: auto | space-end | allow-end | trim-endwith initial valuetrim-endtext-spacing-adjacent: auto | space-adjacent | trim-adjacentwith initial valuetrim-adjacenttext-spacing-interscript: auto | no-interscript-space | [ideograph-alpha || ideograph-numeric]with initial valueideograph-alpha ideograph-numerictext-spacing-punctionation: auto | no-punctuation | punctuationwith initial valueno-punctuationtext-spacing-compression: auto | no-compresswith initial valueautoOn top of that, we can have the following shorthand:
In this set up:
autoontext-spacingmaps toautoon every longhandnormalontext-spacingsets each longhand to its initial value:space-first,trim-end,trim-adjacent,ideograph-alpha ideograph-numeric,no-punctuation, andauto(ontext-spacing-compression)noneontext-spacingmaps tospace-start,space-end,space-adjacent,no-interscript-space,no-punctuation, andno-compresson the respective longhandstext-spacing, those that map to a longhand property get set, and other longhands get reset to their initial value.Possibly with some bikeshedding on the value names, I think this would be a pretty reasonable design.
fantasai commentedon Jan 26, 2023
A few notes:
no-compressover totext-justify.punctuationshould fit in.frivoal commentedon Jan 26, 2023
Note to anyone reading this issue who hasn't seen #4246: I suggest reading #4246 (comment), as that's effectively a continuation of the suggestion above, simplified to cover only the (most) useful combinations.
[css-text-4] Redesign text-spacing
fantasai commentedon Feb 28, 2023
I believe this has been fixed by the refactoring in #4246. @frivoal please close out if you agree. :)