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

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: comments addressed 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
Index: ui/gfx/render_text_harfbuzz.cc
diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc
index 3ee533290ca729bb9871427740e29c597c6d1489..2af847d3e794677df7af1fb3b202cc98f58b84ce 100644
--- a/ui/gfx/render_text_harfbuzz.cc
+++ b/ui/gfx/render_text_harfbuzz.cc
@@ -1091,39 +1091,60 @@ 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;
FontRenderParams best_render_params;
size_t best_missing_glyphs = std::numeric_limits<size_t>::max();
- if (CompareFamily(run, primary_font.GetFontName(),
- primary_font.GetFontRenderParams(),
+ if (CompareFamily(run, primary_family, primary_font.GetFontRenderParams(),
&best_family, &best_render_params, &best_missing_glyphs))
return;
#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 (size_t i = 0; i < fallback_families.size(); ++i) {
Daniel Erat 2014/10/29 01:18:10 nit: for (auto family : fallback_families) {
ckocagil 2014/10/29 02:05:16 Done. (yay c++11)
+ const std::string& current_family = fallback_families[i];
+ if (current_family == primary_family)
+ continue;
+#if defined(OS_WIN)
+ if (current_family == uniscribe_family)
+ continue;
+#endif
FontRenderParamsQuery query(false);
- query.families.push_back(fallback_families[i]);
+ query.families.push_back(current_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, current_family, fallback_render_params, &best_family,
+ &best_render_params, &best_missing_glyphs))
return;
}

Powered by Google App Engine
This is Rietveld 408576698