Chromium Code Reviews| Index: ui/gfx/render_text_harfbuzz.cc |
| diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc |
| index fe492c69f1600ce59f5cab612018ef778e7541f8..6541a6a4c9991386a7a46c85af3428d6ed355177 100644 |
| --- a/ui/gfx/render_text_harfbuzz.cc |
| +++ b/ui/gfx/render_text_harfbuzz.cc |
| @@ -36,10 +36,6 @@ |
| #include "ui/gfx/text_utils.h" |
| #include "ui/gfx/utf16_indexing.h" |
| -#if defined(OS_WIN) |
| -#include "ui/gfx/font_fallback_win.h" |
| -#endif |
| - |
| namespace gfx { |
| namespace { |
| @@ -1508,25 +1504,28 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text, |
| return; |
| } |
| -#if defined(OS_WIN) |
| +#if defined(OS_WIN) || defined(OS_MACOSX) |
| Font fallback_font(primary_font); |
| - std::string fallback_family; |
| + std::string preferred_fallback_family; |
| const base::char16* run_text = &(text[run->range.start()]); |
| if (GetFallbackFont(primary_font, run_text, run->range.length(), |
| &fallback_font)) { |
| - fallback_family = fallback_font.GetFontName(); |
| + preferred_fallback_family = fallback_font.GetFontName(); |
| if (CompareFamily(text, fallback_font, fallback_font.GetFontRenderParams(), |
| run, &best_font, &best_render_params, |
| &best_missing_glyphs)) |
| return; |
| } |
| + |
|
Alexei Svitkine (slow)
2017/06/20 14:59:34
Nit: Remove empty line.
tapted
2017/06/20 23:52:57
Done.
|
| #endif |
| std::vector<Font> fallback_font_list = GetFallbackFonts(primary_font); |
| #if defined(OS_WIN) |
| - // Append fonts in the fallback list of the fallback font. |
| - if (!fallback_family.empty()) { |
| + // Append fonts in the fallback list of the preferred fallback font. |
| + // TODO(tapted): Investigate whether there's a case that benefits from this on |
| + // Mac. |
| + if (!preferred_fallback_family.empty()) { |
| std::vector<Font> fallback_fonts = GetFallbackFonts(fallback_font); |
| fallback_font_list.insert(fallback_font_list.end(), fallback_fonts.begin(), |
| fallback_fonts.end()); |
| @@ -1538,7 +1537,7 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text, |
| // could be a raster font like System, which would not give us a reasonable |
| // fallback font list. |
| if (!base::LowerCaseEqualsASCII(primary_font.GetFontName(), "segoe ui") && |
| - !base::LowerCaseEqualsASCII(fallback_family, "segoe ui")) { |
| + !base::LowerCaseEqualsASCII(preferred_fallback_family, "segoe ui")) { |
| std::vector<Font> default_fallback_families = |
| GetFallbackFonts(Font("Segoe UI", 13)); |
| fallback_font_list.insert(fallback_font_list.end(), |
| @@ -1555,8 +1554,8 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text, |
| if (font_name == primary_font.GetFontName()) |
| continue; |
| -#if defined(OS_WIN) |
| - if (font_name == fallback_family) |
| +#if defined(OS_WIN) || defined(OS_MACOSX) |
|
Alexei Svitkine (slow)
2017/06/20 14:59:34
Nit: Suggest moving preferred_fallback_family outs
tapted
2017/06/20 23:52:57
Nice - Done. Collapsed the 3 `if`.
|
| + if (font_name == preferred_fallback_family) |
| continue; |
| #endif |
| if (fallback_fonts.find(font) != fallback_fonts.end()) |