-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-text-decor] Text underlines' positions cannot be fine-tuned #459
Comments
Perhaps percentages should be allowed, resolved against the font-size of the element. Also, because font-family is inherited, text-decoration-thickness should be inherited too. |
Text decoration line properties generally doesn't inherit, because they control the decoration line across an inline box as a while. I know WebKit and Blink mis-implemented those properties as inherited, but I believe that is undesired. Unless there is a good reason, I don't think |
I think you're misunderstanding this proposal. This proposal has two pieces (which keep position and thickness separate):
|
Hmm, okay, yeah I probably misunderstood the proposal. So the |
Yes, the offset should start at the baseline. Positive values should be "farther away from the text." I'd like to amend the proposal to use a unitless number which would scale with font-size instead of <length>. It should be "A value of '1' represents 1px at font-size: 16px, and scales linearly with font-size." That way, when it's inherited, this value would react correctly to different fonts. |
Myles reminded me to comment here: Might also be worth trawling www-style for past discussions on these, in case there are some good ideas. Certainly these requests have come up, but were deferred from L3. |
+1 to add a new property for offset. |
and probably for CJK (or when @r12a: now I wonder, since Latin and CJK want different point to start the offset from, if there were any other requirements in other writing systems? |
Instead of At least for serif (or broken/blackletter) faces, it may even make sense to introduce two units, one for the stem / base stroke (downstroke, Seeing that |
I really like this idea. If stroke width is possible to implement as a unit, I think it would also make for a much better way of selecting font weight in the new variable fonts, instead of the current numbers, which force you to take a stab in the dark. |
There was #487 for percentages in
|
Just to confirm I'm reading this right:
|
I'm not clear exactly how this works, but baselines are different not only for CJK fonts but also for indic fonts (at least nominally), which have a hanging baseline, ie. at the location of the horizontal bar in अंतर्राष्ट्रीयकरण गतिविधि So i'm not clear whether the starting point for the offset, if it was measured from the baseline, would need to be adjusted for each type of script in the document. If so, things would become particularly problematic where you have a combination of scripts with different baselines on a line. Not only would you need to markup up text so that each part gets its own correct offset, but you'd also have to figure out how to have a single underline at the same location under a mixed script phrase, eg. अंतर्राष्ट्रीयकरण गतिविधि, W3C or 国際化活動 W3C Hopefully i'm missing something and this won't be an issue? |
Me neither, so this is a topic i18n needs to think about. Once we understand requirements for each languages, I think we can come up with how this should work, but we don't understand that yet. I think we know:
and you're right that mixed case needs a separate consideration. I'm guessing we should align to the primary script, but it's the case for J, and how to determine the primary script is another question. I discussed with @upsuper offline that CLREQ should have description about underline, great if we can understand underline requirements for other languages as well. |
When writing vertically, Chinese text usually put underline to the left of the text as per CNS (Taiwan) standard (de facto in other area as well) but then it seems Japanese usually put it to the right. |
@c933103 Do “underlines” in vertical text correlate by any chance with preferred direction of line progression, i.e. |
No. Japanese and trandition Chinese both use vertical-rl, but they have different underline position. |
Thanks, that’s how I remembered it, just wanted to make sure. |
i'm a little concerned that this issue is developing separate threads for line positioning and line thickness, and inclined to think that we should split out one or both into separate issues. |
As @litherum notes, the underline position and thickness values in a font's post table are liable to be junk data, since many font makers simply leave these as tool defaults. They are also font level settings that make no account for the possibility of multiple scripts and writing systems supported by a font that might require localised underline position and thickness. Obviously, in this situation, it makes sense for CSS to come up with some reasonable fallback method to automate underlining, but I still think it would be preferable for the font developer to provide good and localised data. I've introduced this idea to the ad hoc OpenType working group, and will see what kind of traction I can get. Mostly likely implementation would be new fields in the BASE table, using existing OTL script (and maybe language system) tagging for localisation. Having new data separate from the post table values should encourage font developers to provide better data, especially if font tools require them to make explicit decisions rather than providing default values. That is, this data should only be included in fonts if a developer has explicitly defined it; in the absence of this new data, CSS should fall back to automated underline position and thickness. Make sense? PS. Everything I've written here regarding underline also applies to strikethrough. |
I've renamed the issue to only discuss positioning here. We can discuss thickness in #239 |
There are a few distinct things here:
Item 1 is not required for item 3, but item 1 is required for item 2. Item 3 is more valuable in the presence if item 2, but is still valuable even without item 2. We have gotten many requests from web developers who just want to tweak the underline a little bit because of the specific typographic situation their page employs. Performing items 1 and 2, while ultimately helpful, will take a long time (and many different people) to complete. Therefore, blocking item 3 on them seems unnecessary, since item 3 solves a real need and is fairly simple. In addition, if we spec item 3 now, it will still be meaningful even after completing items 1 and 2. |
I've drafted up a proposal in https://drafts.csswg.org/css-text-decor-4/#underline-offset Didn't tackle the stroke-width unit issue. Please file a separate issue against css-values for that. :) |
What about letting the author decide whether the the user agent should use the underline (and similar) information from the font itself? @font-face
{
/* Standard font properties */
src: url('font.woff');
/* A new property, bikeshed later ;) */
underline: from-source;
} Web font factories should (or could) know whether this makes sense or not for a certain font and not specify it if they do not know. This could be in addition or an alternative to |
@phistuck It's valuable to let web authors opt-in to metrics in the font file, and a new value to the |
|
The CSSWG resolved to add If there are problems with specific details of how it's specced, please file new issues. Thanks! |
Designers often want to control the thickness and position of underlines. Typographically, these underlines often are the thickness of certain particular strokes inside glyphs, which browsers / text libraries have no concept of. Therefore, information required for higher quality sizing / placement must come from somewhere else.
Naively, this additional information could come from the "post" table inside font files. However, because this information is often unused, many font files have garbage data in these fields. (As an aside, I committed a patch to WebKit to use these fields, but had to revert it 7 hours later because of the low-quality data.)
Therefore, this information should come from page authors. There should be a new property:
text-decoration-thickness: auto | <length> | file
The
auto
value is the default, and represents browsers' current behavior. Thefile
keyword means to use the values from the primary font file itself (where "primary" means "the same font file which determines the horizontal and vertical text metrics for the element"). If a font file format is used which does not include these values, thenfile
behaves likeauto
.In addition, two new values should be added to
text-underline-position
, thereby making the syntax:text-underline-position: auto | [ under || [ left | right ] ] | <length> | file
With this syntax, it is impossible to specify both a
<length>
as well asunder
, which is on purpose. The<length>
only applies to regular underlines, not to overlines, under-underlines, nor strikethroughs.In addition, because of the semantic meaning of text decorations, browsers should be able to clamp these values to implementation-dependent sane ranges.
The text was updated successfully, but these errors were encountered: