Commit 1cd147a1 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Fix unittest HarfBuzz_UniscribeFallback on Windows 10

The main goal of this CL is to remove an usage of PlatformFontWin.

The test RenderTextTest.HarfBuzz_UniscribeFallback is creating a
PlatformFontWin class and directly manipulate the HFontRef/HFONT
to put the localized name.

The initial goal of test was to ensure the fast-path for font fallback
is called. ShapeRuns is trying the following fonts:

  1) PrimaryFont / SecondaryFont
  2) GetFallbackFont (for a given text)
     a) win7  : Use of Uniscribe fallback
     b) win10 : Use of DWrite fallback
  3) GetFallbackFonts (enumerate all fonts)

The test was designed to force the fallback to hit 2), while impossible
to succeed with 3).

Unfortunately, on windows 10, the "Meiryo" font is not installed by default
and it's part of the Japaneese extension. The font constructor replace it
by Arial which is making the path 3) to be hitted and the test to
(incorrectly) pass.

We are adding checks that the font name and localized font name are kept
correctly. We are adding a windows 10 localized font.

R=asvitkine@chromium.org
CC=​​​​dfried@chromium.org, robliao@chromium.org

Bug: 944227


Change-Id: I7990e973d6702abee998ccafeee753b947cca0bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1554001
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#648702}
parent 6fafa044
......@@ -63,7 +63,6 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont {
static bool IsDirectWriteEnabled();
private:
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution);
......@@ -112,7 +111,6 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont {
private:
friend class base::RefCounted<HFontRef>;
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution);
......
......@@ -44,7 +44,6 @@
#if defined(OS_WIN)
#include "base/win/windows_version.h"
#include "ui/gfx/platform_font_win.h"
#endif
#if defined(OS_MACOSX)
......@@ -4189,12 +4188,35 @@ TEST_F(RenderTextTest, HarfBuzz_FontListFallback) {
// Ensure that the fallback fonts of the Uniscribe font are tried for shaping.
#if defined(OS_WIN)
TEST_F(RenderTextTest, HarfBuzz_UniscribeFallback) {
std::string font_name;
std::string localized_font_name;
base::win::Version version = base::win::GetVersion();
if (version < base::win::VERSION_WIN10) {
// The font 'Meiryo' exists on windows 7 and windows 8. see:
// https://docs.microsoft.com/en-us/typography/fonts/windows_7_font_list
// https://docs.microsoft.com/en-us/typography/fonts/windows_8_font_list
font_name = "Meiryo";
// Japanese name for Meiryo.
localized_font_name = "\u30e1\u30a4\u30ea\u30aa";
} else {
ASSERT_GE(version, base::win::VERSION_WIN10);
// The font 'Malgun Gothic' exists on windows 10. see:
// https://docs.microsoft.com/en-us/typography/fonts/windows_10_font_list
font_name = "Malgun Gothic";
// Korean name for Malgun Gothic.
localized_font_name = "\ub9d1\uc740 \uace0\ub515";
}
// The localized name won't be found in the system's linked fonts, forcing
// RTHB to try the Uniscribe font and its fallbacks.
RenderTextHarfBuzz* render_text = GetRenderText();
PlatformFontWin* font_win = new PlatformFontWin("Meiryo", 12);
// Japanese name for Meiryo. This name won't be found in the system's linked
// fonts, forcing RTHB to try the Uniscribe font and its fallbacks.
font_win->font_ref_->font_name_ = "\u30e1\u30a4\u30ea\u30aa";
FontList font_list((Font(font_win)));
Font font(localized_font_name, 12);
FontList font_list(font);
// Ensures the font didn't got substituted.
EXPECT_NE(font.GetFontName(), font_name);
EXPECT_EQ(font.GetActualFontNameForTesting(), localized_font_name);
render_text->SetFontList(font_list);
// An invalid Unicode character that somehow yields Korean character "han".
......
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