Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: ui/gfx/render_text_harfbuzz.cc

Issue 2927953003: Use CTFontCreateForString for RenderTextHarfbuzz on Mac (Closed)
Patch Set: Fix views::Label tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/font_fallback_win.cc ('k') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1d068b3ba7301458a77afa9c4d8d19e75920a082 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,13 +1504,14 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text,
return;
}
-#if defined(OS_WIN)
+ std::string preferred_fallback_family;
+
+#if defined(OS_WIN) || defined(OS_MACOSX)
Font fallback_font(primary_font);
- std::string 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))
@@ -1525,8 +1522,10 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text,
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(),
@@ -1553,14 +1552,10 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text,
for (const auto& font : fallback_font_list) {
std::string font_name = font.GetFontName();
- if (font_name == primary_font.GetFontName())
- continue;
-#if defined(OS_WIN)
- if (font_name == fallback_family)
- continue;
-#endif
- if (fallback_fonts.find(font) != fallback_fonts.end())
+ if (font_name == primary_font.GetFontName() ||
+ font_name == preferred_fallback_family || fallback_fonts.count(font)) {
continue;
+ }
fallback_fonts.insert(font);
« no previous file with comments | « ui/gfx/font_fallback_win.cc ('k') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698