[webkit-changes] [WebKit/WebKit] eb50f3: Cap height is incorrect on platforms using FreeType.

ChangSeok Oh noreply at github.com
Tue Apr 11 22:32:28 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: eb50f369243c6fcb130ba92cb3bb75e119512284
      https://github.com/WebKit/WebKit/commit/eb50f369243c6fcb130ba92cb3bb75e119512284
  Author: ChangSeok Oh <changseok at webkit.org>
  Date:   2023-04-11 (Tue, 11 Apr 2023)

  Changed paths:
    M LayoutTests/fast/css-generated-content/initial-letter-first-line-wrapping-expected.html
    M LayoutTests/platform/glib/TestExpectations
    M LayoutTests/platform/glib/fast/text/combining-enclosing-keycap-expected.txt
    M LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-basic-expected.txt
    M LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-border-padding-expected.txt
    M LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-clearance-expected.txt
    M LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-descender-expected.txt
    M LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-raised-expected.txt
    M LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-sunken-expected.txt
    M LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-basic-expected.txt
    M LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-border-padding-expected.txt
    M LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-clearance-expected.txt
    M LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-descender-expected.txt
    M LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-raised-expected.txt
    M LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-sunken-expected.txt
    M Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

  Log Message:
  -----------
  Cap height is incorrect on platforms using FreeType.
https://bugs.webkit.org/show_bug.cgi?id=255082

Reviewed by Carlos Garcia Campos.

FreeType platforms use the height of cairo_font_extents_t as cap-height
for the given font. Unfortunately, that is not the cap-height we want. According
to the Cairo document [1], cairo_font_extents_t.height is the vertical distance
between baselines, which contains ascent, descent, and some margin. That is far
from the cap-height the CSS standard defines [2], and results in the failure of
font-size-adjust-009.html.

To fix this, we use the cap-height FreeType provided since its version 2 [3].
As we did for x-height, we fall back to cairo_text_extends_t if we cannot get
the cap-height from FreeType.

[1] https://www.cairographics.org/manual/cairo-cairo-scaled-font-t.html#cairo-font-extents-t
[2] https://www.w3.org/TR/css-values-4/#font-relative-lengths
[3] https://freetype.org/freetype2/docs/reference/ft2-truetype_tables.html#tt_os2

The following tests are manually verified by matching the results to ones of the mac port.

Test:
+ imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-009.html
+ fast/css-generated-content/initial-letter-basic.html
+ fast/css-generated-content/initial-letter-border-padding.html
+ fast/css-generated-content/initial-letter-clearance.html
+ fast/css-generated-content/initial-letter-descender.html
* fast/css-generated-content/initial-letter-first-line-wrapping.html:
+ fast/css-generated-content/initial-letter-raised.html
+ fast/css-generated-content/initial-letter-sunken.html
* fast/text/combining-enclosing-keycap.html

The following tests are marked as expected image test failures. Before this patch,
they passed because they rendered nothing (i.e., an empty page) due to inaccurate
font heights. To make them pass, custom fonts (e.g., color fonts) via
@font-face: font-family should work for Canvas. We handle them in a separate bug.

- http/tests/canvas/color-fonts/ctm-sbix.html
- http/tests/canvas/color-fonts/fill-color-sbix.html
- http/tests/canvas/color-fonts/fill-gradient-sbix.html
- http/tests/canvas/color-fonts/linedash-sbix.html
- http/tests/canvas/color-fonts/stroke-gradient-sbix.html
- http/tests/canvas/color-fonts/text-sbix.html

* LayoutTests/fast/css-generated-content/initial-letter-first-line-wrapping-expected.html: Updated.
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/glib/fast/text/combining-enclosing-keycap-expected.txt: Updated.
* LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-basic-expected.txt: Updated.
* LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-border-padding-expected.txt: Updated.
* LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-clearance-expected.txt: Updated.
* LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-descender-expected.txt: Updated.
* LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-raised-expected.txt: Updated.
* LayoutTests/platform/gtk/fast/css-generated-content/initial-letter-sunken-expected.txt: Updated.
* LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-basic-expected.txt: Updated.
* LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-border-padding-expected.txt: Updated.
* LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-clearance-expected.txt: Updated.
* LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-descender-expected.txt: Updated.
* LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-raised-expected.txt: Updated.
* LayoutTests/platform/wpe/fast/css-generated-content/initial-letter-sunken-expected.txt: Updated.
* Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp:
(WebCore::heightOfCharacter):
(WebCore::Font::platformInit):

Canonical link: https://commits.webkit.org/262860@main




More information about the webkit-changes mailing list