-
Notifications
You must be signed in to change notification settings - Fork 708
[css-fonts-5] font-size-adjust: ic-height #8792
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
Comments
Note that when the fallback uses So the fallback used is the "average" vertical advance, which in turn is based on the font's ascent + descent, as there's no vertical-mode equivalent to the OS/2 table's I think this is better than falling back to ic-width because of the possibility of significantly non-square fonts. I know most common fonts will have square or near-square glyphs for 水 and other ideographs, but in a highly-stylised (e.g. condensed or expanded) font this might not be true. So Gecko's implementation is instead based on the assumption that in vertical mode, all characters will simply get the same fixed advance (height) if specific vertical metrics are not present. |
Thanks for the explanation. If I understand correctly, the advance height differs slightly from the height (i.e., the sum of ascent and descent). The advance height indicates the next vertical pen position after a glyph so that it can include some marginal space as well as ascent and descent [1]. So, strictly speaking, the aveCharWidth can also cause a difference from what the spec states. [1] https://freetype.org/freetype2/docs/glyphs/glyphs-3.html
O.K. If we keep ic-height, the spec at least needs to be updated, clarifying a fallback behavior. Otherwise, it would confuse web designers in the fallback situation. So far, we have the following options.
Any other ideas? |
Another option would be to use, as a fallback, the distance between the ideographic top and ideographic bottom baselines (if they exist). |
In theory, I guess that could be reasonable. In practice, I don't recall ever running across a font that lacked vertical-layout metrics, but did define the various ideographic baselines, so I'm not sure how useful it'd be as a fallback. |
https://bugs.webkit.org/show_bug.cgi?id=264064 Reviewed by NOBODY (OOPS!). This change brings the ic-height metric support for font-size-adjust [1] into ports using OpenType. As initializing glyphs' vertical data is expensive, we defer it until the vertical data is requested. If a used font does not provide height of the cjk water glyph, we use its width as a fallback [2] because the glyph usually has the same width and height. [1] https://www.w3.org/TR/css-fonts-5/#valdef-font-size-adjust-ic-height [2] w3c/csswg-drafts#8792 Test: imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-ic-height.html * LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-ic-height-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-ic-height-ref.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-ic-height.html: Added. * Source/WebCore/platform/graphics/Font.cpp: (WebCore::m_shouldNotBeUsedForArabic): (WebCore::Font::platformGlyphInit): (WebCore::Font::platformGlyphVerticalDataInit): (WebCore::Font::heightForGlyph const): * Source/WebCore/platform/graphics/Font.h: (WebCore::Font::widthForGlyph const): * Source/WebCore/platform/graphics/FontMetrics.h: (WebCore::FontMetrics::ideogramHeight const): (WebCore::FontMetrics::reset): * Source/WebCore/platform/graphics/FontSizeAdjust.h: (WebCore::FontSizeAdjust::resolve const): * Source/WebCore/rendering/RenderFileUploadControl.cpp: (WebCore::RenderFileUploadControl::paintControl): * Source/WebCore/style/StyleFontSizeFunctions.cpp: (WebCore::Style::adjustedFontSize):
This CL adds the ic-height metric support to font-size-adjust [1]. The ic-height metric lets developers adjust font size relative to the height of the CJK water glyph. A note-worthy is the fallback case where the used font does not provide vertical font info. Such vertical font info is often missing, but the current specification does not describe the fallback behavior. As a temporary measure, we use the advance width of the CJK water glyph instead until the standard fallback behavior is established [2] if we cannot get its advance height from the font. That would be a sensible approximation since the CJK water glyph has the same width and height in most fonts. [1] https://www.w3.org/TR/css-fonts-5/#valdef-font-size-adjust-ic-height [2] w3c/csswg-drafts#8792 Test: external/wpt/css/css-fonts/animations/font-size-adjust-composition.html external/wpt/css/css-fonts/font-size-adjust-ic-height.html (new) external/wpt/css/css-fonts/parsing/font-size-adjust-computed.html external/wpt/css/css-fonts/parsing/font-size-adjust-valid.html Bug: 1219875 Change-Id: Ie90a6241cb7e8a55fcaf65df5a4edc1058028ebe
This CL adds the ic-height metric support to font-size-adjust [1]. The ic-height metric lets developers adjust font size relative to the height of the CJK water glyph. A note-worthy is the fallback case where the used font does not provide vertical font info. Such vertical font info is often missing, but the current specification does not describe the fallback behavior. As a temporary measure, we use the advance width of the CJK water glyph instead until the standard fallback behavior is established [2] if we cannot get its advance height from the font. That would be a sensible approximation since the CJK water glyph has the same width and height in most fonts. [1] https://www.w3.org/TR/css-fonts-5/#valdef-font-size-adjust-ic-height [2] w3c/csswg-drafts#8792 Test: animations/responsive/interpolation/font-size-adjust-responsive.html external/wpt/css/css-fonts/animations/font-size-adjust-composition.html external/wpt/css/css-fonts/font-size-adjust-ic-height.html (new) external/wpt/css/css-fonts/parsing/font-size-adjust-computed.html external/wpt/css/css-fonts/parsing/font-size-adjust-valid.html Bug: 1219875 Change-Id: Ie90a6241cb7e8a55fcaf65df5a4edc1058028ebe
I hope we can resolve this issue soon. This is a blocker for me to implement I noticed that the Noto Sans CJK JP font in the WPT repo [1] supports vertical-layout information. Here are some numbers I got from the font with a font-size of 200px:
Given this information, I think the advance width of "水" is the most sensible alternative for 'ic-height' if we decide to keep it in the spec. If that doesn't work, my last preference is a disregard (i.e., no effect) as the fallback behavior. To sum up, my preference goes in the following order:
[1] /fonts/noto/cjk/NotoSansCJKjp-Regular-subset-chws.otf |
What do Blink and WebKit use as the vertical advance of "水" if they're rendering |
Blink and WebKit use the font height (i.e., Ascent + Descent) as the fallback. I do not object to having the font height as the fallback for
|
Originally, I intended to remove ic-height, but our conversation so far suggests retaining it and using a fallback if its necessary metric can't be obtained from a font. This contradicts the majority opinion in #6384, which leans towards no adjustment if a required metric is absent in a font. I think we need a more coherent and consistent resolution here, not just for |
This CL adds the ic-height metric support to font-size-adjust [1]. The ic-height metric lets developers adjust font size relative to the height of the CJK water glyph. A note-worthy is the fallback case where the used font does not provide vertical font info. Such vertical font info is often missing, but the current specification does not describe the fallback behavior. As a temporary measure, we use the advance width of the CJK water glyph instead until the standard fallback behavior is established [2] if we cannot get its advance height from the font. That would be a sensible approximation since the CJK water glyph has the same width and height in most fonts. [1] https://www.w3.org/TR/css-fonts-5/#valdef-font-size-adjust-ic-height [2] w3c/csswg-drafts#8792 Test: animations/responsive/interpolation/font-size-adjust-responsive.html external/wpt/css/css-fonts/animations/font-size-adjust-composition.html external/wpt/css/css-fonts/font-size-adjust-ic-height.html (new) external/wpt/css/css-fonts/parsing/font-size-adjust-computed.html external/wpt/css/css-fonts/parsing/font-size-adjust-valid.html Bug: 1219875 Change-Id: Ie90a6241cb7e8a55fcaf65df5a4edc1058028ebe
This CL adds the ic-height metric support to font-size-adjust [1]. The ic-height metric lets developers adjust font size relative to the height of the CJK water glyph. A note-worthy is the fallback case where the used font does not provide vertical font info. Such vertical font info is often missing, but the current specification does not describe the fallback behavior. As a temporary measure, we use the advance width of the CJK water glyph instead until the standard fallback behavior is established [2] if we cannot get its advance height from the font. That would be a sensible approximation since the CJK water glyph has the same width and height in most fonts. [1] https://www.w3.org/TR/css-fonts-5/#valdef-font-size-adjust-ic-height [2] w3c/csswg-drafts#8792 Test: animations/responsive/interpolation/font-size-adjust-responsive.html external/wpt/css/css-fonts/animations/font-size-adjust-composition.html external/wpt/css/css-fonts/font-size-adjust-ic-height.html (new) external/wpt/css/css-fonts/parsing/font-size-adjust-computed.html external/wpt/css/css-fonts/parsing/font-size-adjust-valid.html Bug: 1219875 Change-Id: Ie90a6241cb7e8a55fcaf65df5a4edc1058028ebe
This change introduces support for the ic-height metric in font-size-adjust [1], allowing developers to adjust font size based on the height of the CJK water glyph. Notably, in cases where the chosen font lacks the CJK water glyph or vertical font information, there is no specified fallback behavior in the current specification. We adopt the approach of combining ascent and descent for fallback, similar to Gecko's method [2], until a standard fallback behavior is defined [3]. [1] https://www.w3.org/TR/css-fonts-5/#valdef-font-size-adjust-ic-height [2] w3c/csswg-drafts#8792 (comment) [3] w3c/csswg-drafts#6384 Test: animations/responsive/interpolation/font-size-adjust-responsive.html external/wpt/css/css-fonts/animations/font-size-adjust-composition.html external/wpt/css/css-fonts/font-size-adjust-ic-height.html (new) external/wpt/css/css-fonts/parsing/font-size-adjust-computed.html external/wpt/css/css-fonts/parsing/font-size-adjust-valid.html Bug: 1219875 Change-Id: Ie90a6241cb7e8a55fcaf65df5a4edc1058028ebe
This change introduces support for the ic-height metric in font-size-adjust [1], allowing developers to adjust font size based on the height of the CJK water glyph. Notably, in cases where the chosen font lacks the CJK water glyph or vertical font information, there is no specified fallback behavior in the current specification. We adopt the approach of combining ascent and descent for fallback, similar to Gecko's method [2], until a standard fallback behavior is defined [3]. [1] https://www.w3.org/TR/css-fonts-5/#valdef-font-size-adjust-ic-height [2] w3c/csswg-drafts#8792 (comment) [3] w3c/csswg-drafts#6384 Test: animations/responsive/interpolation/font-size-adjust-responsive.html external/wpt/css/css-fonts/animations/font-size-adjust-composition.html external/wpt/css/css-fonts/font-size-adjust-ic-height.html (new) external/wpt/css/css-fonts/parsing/font-size-adjust-computed.html external/wpt/css/css-fonts/parsing/font-size-adjust-valid.html Bug: 1219875 Change-Id: Ie90a6241cb7e8a55fcaf65df5a4edc1058028ebe
Related Spec: https://www.w3.org/TR/css-fonts-5/#valdef-font-size-adjust-ic-height
Related Issues: #6288, #6384
Since #6288, the ic metric split into ic-width and ic-height. And the latest draft describes them as follows.
While implementing these metrics in Blink and WebKit, it was questionable whether having these two metrics for the ideogram is worth it. Here is my rationale:
Proposed solution:
I propose removing ic-height from the spec as its merit of keeping ic-height seems low for now.
[1] https://searchfox.org/mozilla-central/source/gfx/thebes/gfxDWriteFonts.cpp#345
[2] https://searchfox.org/mozilla-central/source/gfx/thebes/gfxFont.cpp#1058
The text was updated successfully, but these errors were encountered: