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

Side by Side Diff: ui/gfx/render_text_harfbuzz.cc

Issue 677803002: Do not commit: debug Windows RenderText test failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 ubidi_reorderLogical(&levels[0], num_runs, &logical_to_visual_[0]); 1070 ubidi_reorderLogical(&levels[0], num_runs, &logical_to_visual_[0]);
1071 } 1071 }
1072 1072
1073 bool RenderTextHarfBuzz::CompareFamily( 1073 bool RenderTextHarfBuzz::CompareFamily(
1074 internal::TextRunHarfBuzz* run, 1074 internal::TextRunHarfBuzz* run,
1075 const std::string& family, 1075 const std::string& family,
1076 const gfx::FontRenderParams& render_params, 1076 const gfx::FontRenderParams& render_params,
1077 std::string* best_family, 1077 std::string* best_family,
1078 gfx::FontRenderParams* best_render_params, 1078 gfx::FontRenderParams* best_render_params,
1079 size_t* best_missing_glyphs) { 1079 size_t* best_missing_glyphs) {
1080 LOG(ERROR) << "XXX evaluating " << family;
1080 if (!ShapeRunWithFont(run, family, render_params)) 1081 if (!ShapeRunWithFont(run, family, render_params))
1081 return false; 1082 return false;
1082 1083
1083 const size_t missing_glyphs = run->CountMissingGlyphs(); 1084 const size_t missing_glyphs = run->CountMissingGlyphs();
1085 LOG(ERROR) << "XXX " << missing_glyphs << " missing glyph(s)";
1084 if (missing_glyphs < *best_missing_glyphs) { 1086 if (missing_glyphs < *best_missing_glyphs) {
1085 *best_family = family; 1087 *best_family = family;
1086 *best_render_params = render_params; 1088 *best_render_params = render_params;
1087 *best_missing_glyphs = missing_glyphs; 1089 *best_missing_glyphs = missing_glyphs;
1088 } 1090 }
1089 return missing_glyphs == 0; 1091 return missing_glyphs == 0;
1090 } 1092 }
1091 1093
1092 void RenderTextHarfBuzz::ShapeRun(internal::TextRunHarfBuzz* run) { 1094 void RenderTextHarfBuzz::ShapeRun(internal::TextRunHarfBuzz* run) {
1093 const Font& primary_font = font_list().GetPrimaryFont(); 1095 const Font& primary_font = font_list().GetPrimaryFont();
1094 run->font_size = primary_font.GetFontSize(); 1096 run->font_size = primary_font.GetFontSize();
1095 1097
1096 std::string best_family; 1098 std::string best_family;
1097 FontRenderParams best_render_params; 1099 FontRenderParams best_render_params;
1098 size_t best_missing_glyphs = std::numeric_limits<size_t>::max(); 1100 size_t best_missing_glyphs = std::numeric_limits<size_t>::max();
1099 1101
1100 if (CompareFamily(run, primary_font.GetFontName(), 1102 for (const Font& font : font_list().GetFonts()) {
1101 primary_font.GetFontRenderParams(), 1103 if (CompareFamily(run, font.GetFontName(), font.GetFontRenderParams(),
1102 &best_family, &best_render_params, &best_missing_glyphs)) 1104 &best_family, &best_render_params, &best_missing_glyphs))
1103 return; 1105 return;
1106 }
1104 1107
1105 #if defined(OS_WIN) 1108 #if defined(OS_WIN)
1106 Font uniscribe_font; 1109 Font uniscribe_font;
1107 const base::char16* run_text = &(GetLayoutText()[run->range.start()]); 1110 const base::char16* run_text = &(GetLayoutText()[run->range.start()]);
1108 if (GetUniscribeFallbackFont(primary_font, run_text, run->range.length(), 1111 if (GetUniscribeFallbackFont(primary_font, run_text, run->range.length(),
1109 &uniscribe_font) && 1112 &uniscribe_font) &&
1110 CompareFamily(run, uniscribe_font.GetFontName(), 1113 CompareFamily(run, uniscribe_font.GetFontName(),
1111 uniscribe_font.GetFontRenderParams(), 1114 uniscribe_font.GetFontRenderParams(),
1112 &best_family, &best_render_params, &best_missing_glyphs)) 1115 &best_family, &best_render_params, &best_missing_glyphs))
1113 return; 1116 return;
1114 #endif 1117 #endif
1115 1118
1116 // Skip the first fallback font, which is |primary_font|. 1119 // Skip the first fallback font, which is |primary_font|.
1117 std::vector<std::string> fallback_families = 1120 std::vector<std::string> fallback_families =
1118 GetFallbackFontFamilies(primary_font.GetFontName()); 1121 GetFallbackFontFamilies(primary_font.GetFontName());
1119 for (size_t i = 1; i < fallback_families.size(); ++i) { 1122 for (size_t i = 1; i < fallback_families.size(); ++i) {
1120 FontRenderParamsQuery query(false); 1123 FontRenderParamsQuery query(false);
1121 query.families.push_back(fallback_families[i]); 1124 query.families.push_back(fallback_families[i]);
1122 query.pixel_size = run->font_size; 1125 query.pixel_size = run->font_size;
1123 query.style = run->font_style; 1126 query.style = run->font_style;
1124 FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL); 1127 FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL);
1125 if (CompareFamily(run, fallback_families[i], fallback_render_params, 1128 if (CompareFamily(run, fallback_families[i], fallback_render_params,
1126 &best_family, &best_render_params, &best_missing_glyphs)) 1129 &best_family, &best_render_params, &best_missing_glyphs))
1127 return; 1130 return;
1128 } 1131 }
1129 1132
1133 LOG(ERROR) << "XXX best was " << best_family;
1130 if (!best_family.empty() && 1134 if (!best_family.empty() &&
1131 (best_family == run->family || 1135 (best_family == run->family ||
1132 ShapeRunWithFont(run, best_family, best_render_params))) 1136 ShapeRunWithFont(run, best_family, best_render_params)))
1133 return; 1137 return;
1134 1138
1135 run->glyph_count = 0; 1139 run->glyph_count = 0;
1136 run->width = 0.0f; 1140 run->width = 0.0f;
1137 } 1141 }
1138 1142
1139 bool RenderTextHarfBuzz::ShapeRunWithFont(internal::TextRunHarfBuzz* run, 1143 bool RenderTextHarfBuzz::ShapeRunWithFont(internal::TextRunHarfBuzz* run,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 run->width = std::floor(run->width + 0.5f); 1194 run->width = std::floor(run->width + 0.5f);
1191 #endif 1195 #endif
1192 } 1196 }
1193 1197
1194 hb_buffer_destroy(buffer); 1198 hb_buffer_destroy(buffer);
1195 hb_font_destroy(harfbuzz_font); 1199 hb_font_destroy(harfbuzz_font);
1196 return true; 1200 return true;
1197 } 1201 }
1198 1202
1199 } // namespace gfx 1203 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698