Skip to content
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] Results for text-underline-position: under #1055

Closed
r12a opened this issue Feb 22, 2017 · 9 comments
Closed

[css-text-decor] Results for text-underline-position: under #1055

r12a opened this issue Feb 22, 2017 · 9 comments
Labels
Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-text-decor-3 Current Work i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response.

Comments

@r12a
Copy link
Contributor

r12a commented Feb 22, 2017

https://drafts.csswg.org/css-text-decor-3/#text-underline-position-property

Here are the results of applying text-underline-position: under to some random text with a bunch of arabic script fonts i have on my system in Canary (today). I also applied text-decoration-skip: ink just because it shows collisions more clearly (it didn't affect the results). All text is set to 30px font-size.

screen shot 2017-02-22 at 17 53 41

The result is font-dependent. Some don't clear the bottom of the text. (And generally the line seems a little thick to me.) I didn't find any difference whether the language was set to en, ar, fa, or ur.

The following shows that for vowelled text the result is unfortunately much worse.

screen shot 2017-02-22 at 18 20 04

@r12a r12a added css-text-decor-3 Current Work i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. labels Feb 22, 2017
@r12a
Copy link
Contributor Author

r12a commented Feb 22, 2017

Fwiw, here are some similar tests for Tibetan, however, i should say that i don't know whether users of the Tibetan script do actually use underline. I didn't find any in the materials i have here.

screen shot 2017-02-22 at 19 09 19

@khaledhosny
Copy link

My guess is that it is using the font descender for the underline position not the actual extents of the text box, which would explain why the results vary so much between fonts. Using a fixed value makes sense I guess since you don’t generally want the underline position to change between different lines based on their context, but may be the descender is not the best choice at least for Arabic since glyphs tend to go past the ascender and descender rather often, no idea what would replace it though.

@r12a
Copy link
Contributor Author

r12a commented Feb 22, 2017

I'm not sure whether a fixed value would work either. You see the variation in letter size above, even though all font-size is set to 30px. I suppose that with a fixed line fonts like Scheherazade would have a very wide gap between the line and the text, whereas others could still hit the line, unless there was some way to tie the distance to the actual size of the glyphs.

Also, there's the problem that the nastaliq fonts are much more greedy for vertical space than the naskh or ruq'a styles.

@behnam
Copy link
Member

behnam commented Feb 22, 2017

The following shows that for vowelled text the result is unfortunately much worse.

@r12a, actually, IMHO, some of those results are actually the best you can get out of the font. For example, the Noto Nastaliq Urdu:

image

Using a fixed value makes sense I guess since you don’t generally want the underline position to change between different lines based on their context, but may be the descender is not the best choice at least for Arabic since glyphs tend to go past the ascender and descender rather often, no idea what would replace it though.

@khaledhosny, as we have seen in various examples, it does happen that some letters (or diacratics) cross the descender line in Arabic script text, and I thought we agreed that there's nothing wrong with that.

And, about the font property value not being set correctly, what do you think about why the descender is being set too high (or too low) for Arabic fonts?

@khaledhosny
Copy link

I'm not sure whether a fixed value would work either.

I meant a fixed font-dependent value.

And, about the font property value not being set correctly, what do you think about why the descender is being set too high (or too low) for Arabic fonts?

Since ascender and descender are mainly for line spacing, some designers will adjust them to get larger line spacing by default and some will do the other way around, so I’m not really sure about re-purposing it for underline position, but it might be the best we can get so far.

Some fonts in the examples here might just have buggy descenders, for example Nafees Nastaliq has very small descender in both OS/2 table’s TypoDescent (used mostly by modern applications) and hhea table (used commonly on Mac) but much larger value in OS/2’s WinDesent (used commonly by Windows applications, especially old ones), which might be a result of the font being tested mainly on Windows rather than an intentional choice.

@kojiishi
Copy link
Contributor

This is so great, thank you @r12a for starting this thread.

We have a bug that we render under-underline too low for CJK on some fonts, because these fonts have internal leading not only for ascender but also for descenders too, and drawing at the descenders (in the font metrics) looks terribly poor.

I was thinking to fix the position to be the bottom of em-box (i.e., bottom of "p") for East Asian scripts and was wondering how it affects other scripts, but IIUC it'll make Arabic underlines worse?

Also, a bit off-topic, but since we take the metrics from the primary font, how often does Arabic use font-family: Times, some-arabic-font; i.e., put Latin font before Arabic font? This happens a lot in East Asian pages, which makes this issue more complicated for me.

@khaledhosny
Copy link

Also, a bit off-topic, but since we take the metrics from the primary font, how often does Arabic use font-family: Times, some-arabic-font; i.e., put Latin font before Arabic font? This happens a lot in East Asian pages, which makes this issue more complicated for me.

I happens quite often in Arabic as well.

@fantasai
Copy link
Collaborator

Older drafts of css-text-decor-3 have more guidance on underline positioning, fwiw. I don't think it handles fallback fonts, but that seems like an oversight since it delves into varying font settings across elements. https://www.w3.org/TR/2013/WD-css-text-decor-3-20130103/#line-position Some of that guidance could be helpful here for dealing with fallback fonts. Of course, that section was removed because implementers didn't want it...

I don't think there's anything we can do about bad font metrics. I'm happy to put guidance in the spec about which font metrics to use, but certainly the glyph bounding box--which is the only metric that would avoid collisions entirely--is not an acceptable answer here since it can place the underline on top of text in the next line when the font designer has chosen to bleed the glyphs outside the ascent/descent. I suspect the best place to put an underline will vary a lot by typeface: the more cursive ones will require greater levels of collision in order for the text not to look absurdly disjoint from the underline, whereas the more print-like ones will be able to accommodate a nearby underline without so many problems since they maintain a more consistent inked "baseline".

Wrt Tibetan, SIL has some examples: http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-chapter09#964d1526 Afaict from @r12a's examples, it seems more important to avoid collisions with the top of the next line than to avoid collisions with the bottom of the current one, and what we choose to do here should ideally reflect that constraint.

@fantasai
Copy link
Collaborator

fantasai commented Feb 8, 2018

i18n comment: Turn this into a note/warning/example about under not being entirely under.

@fantasai fantasai added Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. Needs Edits and removed Commenter Response Pending labels Feb 8, 2018
fantasai added a commit that referenced this issue Feb 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-text-decor-3 Current Work i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response.
Projects
None yet
Development

No branches or pull requests

5 participants