Commit 0cce9e79 authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Fix emoji drawing coordinate in vertical text

Due to issues we have with retrieving correct font metrics on Mac OS,
due to [1, 2] when computing the vertical origin for Emoji Color Emoji
we receive an incorrect vertical origin with a 0 y-value, which leads to
an emoji glyph being placed too high.

Fallback to retrieving the slightly inflated SkFont.getBounds when
SkPath + getBounds() returns an empty rectangle, as it does for Apple
Color Emoji.

Added emoji-vertical-origin-visual.html test as part of own tests, but
in the style of a WPT test. As far as I can tell, we cannot yet run
pixel tests as part of WPT but I do not see a way to verify our
rendering as a ref test.

[1] https://bugs.chromium.org/p/skia/issues/detail?id=8779
[2] https://bugs.chromium.org/p/skia/issues/detail?id=5328

Test: fast/text/emoji-vertical-origin-visual.html
Bug: 933264
Change-Id: I3487bf832b857764fb638a3f2df5803137d3fd66
Reviewed-on: https://chromium-review.googlesource.com/c/1480463
Commit-Queue: Koji Ishii <kojii@chromium.org>
Auto-Submit: Dominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634836}
parent ccb112ce
......@@ -116,6 +116,12 @@ void SkFontGetBoundsForGlyph(const SkFont& font, Glyph glyph, SkRect* bounds) {
SkPath path;
font.getPath(glyph, &path);
*bounds = path.getBounds();
// For Apple Color Emoji path bounds are returning empty rectangles, see
// https://bugs.chromium.org/p/skia/issues/detail?id=8779
// OpenTypeVerticalData::GetVerticalTranslationsForGlyphs needs a non-empty
// rectangle for vertical origin computation, hence fall back to bounds here.
if (UNLIKELY(bounds->isEmpty()))
font.getWidths(&glyph, 1, nullptr, bounds);
#else
font.getWidths(&glyph, 1, nullptr, bounds);
#endif
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Writing Modes: Emoji in writing-mode: vertical-lr or vertical-rl</title>
<link rel="author" title="The Chromium Authors">
<link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#block-flow">
<meta name="assert" content="Emoji must be correctly positioned as part of a vertical run.">
<meta name="flags" content="">
<style>
body {
font-size: 64px;
}
</style>
</head>
<!-- The diamond emoji needs to be rendered between the Ahem characters and must
not cover the top or bottom adjacent character. -->
<p style="writing-mode: vertical-lr;">あ🔷あ</p>
<p style="writing-mode: vertical-rl;">あ🔷あ</p>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment