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

Side by Side 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, 1 month 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text_harfbuzz.h" 5 #include "ui/gfx/render_text_harfbuzz.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <map> 8 #include <map>
9 9
10 #include "base/i18n/bidi_line_iterator.h" 10 #include "base/i18n/bidi_line_iterator.h"
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 FontRenderParams best_render_params; 1097 FontRenderParams best_render_params;
1098 size_t best_missing_glyphs = std::numeric_limits<size_t>::max(); 1098 size_t best_missing_glyphs = std::numeric_limits<size_t>::max();
1099 1099
1100 if (CompareFamily(run, primary_font.GetFontName(), 1100 if (CompareFamily(run, primary_font.GetFontName(),
1101 primary_font.GetFontRenderParams(), 1101 primary_font.GetFontRenderParams(),
1102 &best_family, &best_render_params, &best_missing_glyphs)) 1102 &best_family, &best_render_params, &best_missing_glyphs))
1103 return; 1103 return;
1104 1104
1105 #if defined(OS_WIN) 1105 #if defined(OS_WIN)
1106 Font uniscribe_font; 1106 Font uniscribe_font;
1107 bool got_uniscribe_font = false;
1107 const base::char16* run_text = &(GetLayoutText()[run->range.start()]); 1108 const base::char16* run_text = &(GetLayoutText()[run->range.start()]);
1108 if (GetUniscribeFallbackFont(primary_font, run_text, run->range.length(), 1109 if (GetUniscribeFallbackFont(primary_font, run_text, run->range.length(),
1109 &uniscribe_font) && 1110 &uniscribe_font)) {
1110 CompareFamily(run, uniscribe_font.GetFontName(), 1111 got_uniscribe_font = true;
1111 uniscribe_font.GetFontRenderParams(), 1112 if (CompareFamily(run, uniscribe_font.GetFontName(),
1112 &best_family, &best_render_params, &best_missing_glyphs)) 1113 uniscribe_font.GetFontRenderParams(),
1113 return; 1114 &best_family, &best_render_params, &best_missing_glyphs))
1115 return;
1116 }
1117 #endif
1118
1119 std::vector<std::string> fallback_families =
1120 GetFallbackFontFamilies(primary_font.GetFontName());
1121
1122 #if defined(OS_WIN)
1123 // Append fonts in the fallback list of the Uniscribe font.
1124 if (got_uniscribe_font) {
1125 std::vector<std::string> uniscribe_fallbacks =
1126 GetFallbackFontFamilies(uniscribe_font.GetFontName());
1127 fallback_families.insert(fallback_families.end(),
1128 uniscribe_fallbacks.begin(), uniscribe_fallbacks.end());
Daniel Erat 2014/10/28 14:32:59 patch set 2 skipped the first uniscribe fallback f
ckocagil 2014/10/28 17:39:04 Yes, fixed.
1129 }
1114 #endif 1130 #endif
1115 1131
1116 // Skip the first fallback font, which is |primary_font|. 1132 // Skip the first fallback font, which is |primary_font|.
1117 std::vector<std::string> fallback_families =
1118 GetFallbackFontFamilies(primary_font.GetFontName());
1119 for (size_t i = 1; i < fallback_families.size(); ++i) { 1133 for (size_t i = 1; i < fallback_families.size(); ++i) {
1120 FontRenderParamsQuery query(false); 1134 FontRenderParamsQuery query(false);
1121 query.families.push_back(fallback_families[i]); 1135 query.families.push_back(fallback_families[i]);
1122 query.pixel_size = run->font_size; 1136 query.pixel_size = run->font_size;
1123 query.style = run->font_style; 1137 query.style = run->font_style;
1124 FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL); 1138 FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL);
1125 if (CompareFamily(run, fallback_families[i], fallback_render_params, 1139 if (CompareFamily(run, fallback_families[i], fallback_render_params,
1126 &best_family, &best_render_params, &best_missing_glyphs)) 1140 &best_family, &best_render_params, &best_missing_glyphs))
1127 return; 1141 return;
1128 } 1142 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 run->width = std::floor(run->width + 0.5f); 1204 run->width = std::floor(run->width + 0.5f);
1191 #endif 1205 #endif
1192 } 1206 }
1193 1207
1194 hb_buffer_destroy(buffer); 1208 hb_buffer_destroy(buffer);
1195 hb_font_destroy(harfbuzz_font); 1209 hb_font_destroy(harfbuzz_font);
1196 return true; 1210 return true;
1197 } 1211 }
1198 1212
1199 } // namespace gfx 1213 } // namespace gfx
OLDNEW
« 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