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

Unified Diff: ui/gfx/render_text_harfbuzz.cc

Issue 674233003: RenderTextHarfBuzz: Try fallback fonts of the Uniscribe font while shaping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix include Created 6 years, 2 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/render_text_harfbuzz.h ('k') | ui/gfx/render_text_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 642c76e2fdac1146b25cc741cbfb180c2320f810..1aba788a0eb14c26e2679169cb3306e7b4365b2f 100644
--- a/ui/gfx/render_text_harfbuzz.cc
+++ b/ui/gfx/render_text_harfbuzz.cc
@@ -1091,6 +1091,7 @@ bool RenderTextHarfBuzz::CompareFamily(
void RenderTextHarfBuzz::ShapeRun(internal::TextRunHarfBuzz* run) {
const Font& primary_font = font_list().GetPrimaryFont();
+ const std::string primary_family = primary_font.GetFontName();
run->font_size = primary_font.GetFontSize();
std::string best_family;
@@ -1105,26 +1106,46 @@ void RenderTextHarfBuzz::ShapeRun(internal::TextRunHarfBuzz* run) {
#if defined(OS_WIN)
Font uniscribe_font;
+ std::string uniscribe_family;
const base::char16* run_text = &(GetLayoutText()[run->range.start()]);
if (GetUniscribeFallbackFont(primary_font, run_text, run->range.length(),
- &uniscribe_font) &&
- CompareFamily(run, uniscribe_font.GetFontName(),
- uniscribe_font.GetFontRenderParams(),
- &best_family, &best_render_params, &best_missing_glyphs))
- return;
+ &uniscribe_font)) {
+ uniscribe_family = uniscribe_font.GetFontName();
+ if (CompareFamily(run, uniscribe_family,
+ uniscribe_font.GetFontRenderParams(),
+ &best_family, &best_render_params, &best_missing_glyphs))
+ return;
+ }
#endif
- // Skip the first fallback font, which is |primary_font|.
std::vector<std::string> fallback_families =
- GetFallbackFontFamilies(primary_font.GetFontName());
- for (size_t i = 1; i < fallback_families.size(); ++i) {
+ GetFallbackFontFamilies(primary_family);
+
+#if defined(OS_WIN)
+ // Append fonts in the fallback list of the Uniscribe font.
+ if (!uniscribe_family.empty()) {
+ std::vector<std::string> uniscribe_fallbacks =
+ GetFallbackFontFamilies(uniscribe_family);
+ fallback_families.insert(fallback_families.end(),
+ uniscribe_fallbacks.begin(), uniscribe_fallbacks.end());
+ }
+#endif
+
+ // Try shaping with the fallback fonts.
+ for (auto family : fallback_families) {
Nico 2014/11/21 17:52:40 This should be `const auto&` according to the styl
ckocagil 2014/11/25 21:09:25 I will fix this in https://codereview.chromium.org
+ if (family == primary_family)
+ continue;
+#if defined(OS_WIN)
+ if (family == uniscribe_family)
+ continue;
+#endif
FontRenderParamsQuery query(false);
- query.families.push_back(fallback_families[i]);
+ query.families.push_back(family);
query.pixel_size = run->font_size;
query.style = run->font_style;
FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL);
- if (CompareFamily(run, fallback_families[i], fallback_render_params,
- &best_family, &best_render_params, &best_missing_glyphs))
+ if (CompareFamily(run, family, fallback_render_params, &best_family,
+ &best_render_params, &best_missing_glyphs))
return;
}
« no previous file with comments | « ui/gfx/render_text_harfbuzz.h ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698