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

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

Issue 637953010: RenderText: Try fallback fonts of the Uniscribe font while shaping (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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_win.h" 5 #include "ui/gfx/render_text_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/i18n/char_iterator.h" 10 #include "base/i18n/char_iterator.h"
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 if (missing_count == 0) 1025 if (missing_count == 0)
1026 return; 1026 return;
1027 if (missing_count < best_partial_font_missing_char_count) { 1027 if (missing_count < best_partial_font_missing_char_count) {
1028 best_partial_font_missing_char_count = missing_count; 1028 best_partial_font_missing_char_count = missing_count;
1029 best_partial_font = current_font; 1029 best_partial_font = current_font;
1030 } 1030 }
1031 } 1031 }
1032 1032
1033 // Try finding a fallback font using a meta file. 1033 // Try finding a fallback font using a meta file.
1034 // TODO(msw|asvitkine): Support RenderText's font_list()? 1034 // TODO(msw|asvitkine): Support RenderText's font_list()?
1035 Font uniscribe_font;
1035 if (GetUniscribeFallbackFont(original_font, run_text, run_length, 1036 if (GetUniscribeFallbackFont(original_font, run_text, run_length,
1036 &current_font)) { 1037 &uniscribe_font)) {
1038 current_font = uniscribe_font;
1037 missing_count = CountCharsWithMissingGlyphs(run, 1039 missing_count = CountCharsWithMissingGlyphs(run,
1038 ShapeTextRunWithFont(run, current_font)); 1040 ShapeTextRunWithFont(run, current_font));
1039 if (missing_count == 0) { 1041 if (missing_count == 0) {
1040 successful_substitute_fonts_[original_font.GetFontName()] = current_font; 1042 successful_substitute_fonts_[original_font.GetFontName()] = current_font;
1041 return; 1043 return;
1042 } 1044 }
1043 if (missing_count < best_partial_font_missing_char_count) { 1045 if (missing_count < best_partial_font_missing_char_count) {
1044 best_partial_font_missing_char_count = missing_count; 1046 best_partial_font_missing_char_count = missing_count;
1045 best_partial_font = current_font; 1047 best_partial_font = current_font;
1046 } 1048 }
1047 } 1049 }
1048 1050
1049 // Try fonts in the fallback list except the first, which is |original_font|. 1051 // Try fonts in the fallback list except the first, which is |original_font|.
1050 std::vector<std::string> fonts = 1052 std::vector<std::string> fonts =
1051 GetFallbackFontFamilies(original_font.GetFontName()); 1053 GetFallbackFontFamilies(original_font.GetFontName());
1052 for (size_t i = 1; i < fonts.size(); ++i) { 1054 for (size_t i = 1; i < fonts.size(); ++i) {
1055 current_font = Font(fonts[i], original_font.GetFontSize());
msw 2014/10/20 20:12:03 The entire defect may just be that |current_font|
Alexei Svitkine (slow) 2014/10/20 20:21:20 From my recollection of the original motivation fo
Alexei Svitkine (slow) 2014/10/20 20:25:06 Although yeah, it looks like the code without the
1053 missing_count = CountCharsWithMissingGlyphs(run, 1056 missing_count = CountCharsWithMissingGlyphs(run,
1054 ShapeTextRunWithFont(run, Font(fonts[i], original_font.GetFontSize()))); 1057 ShapeTextRunWithFont(run, current_font));
1055 if (missing_count == 0) { 1058 if (missing_count == 0) {
1056 successful_substitute_fonts_[original_font.GetFontName()] = current_font; 1059 successful_substitute_fonts_[original_font.GetFontName()] = current_font;
1057 return; 1060 return;
1061 }
1062 if (missing_count < best_partial_font_missing_char_count) {
1063 best_partial_font_missing_char_count = missing_count;
1064 best_partial_font = current_font;
1065 }
1066 }
1067
1068 // Try fonts in the fallback list of the Uniscribe font.
1069 fonts = GetFallbackFontFamilies(uniscribe_font.GetFontName());
1070 for (size_t i = 1; i < fonts.size(); ++i) {
1071 current_font = Font(fonts[i], original_font.GetFontSize());
1072 missing_count = CountCharsWithMissingGlyphs(run,
1073 ShapeTextRunWithFont(run, current_font));
Alexei Svitkine (slow) 2014/10/20 20:14:04 Nit: Indent 2 more.
1074 if (missing_count == 0) {
1075 successful_substitute_fonts_[original_font.GetFontName()] = current_font;
1076 return;
1058 } 1077 }
1059 if (missing_count < best_partial_font_missing_char_count) { 1078 if (missing_count < best_partial_font_missing_char_count) {
1060 best_partial_font_missing_char_count = missing_count; 1079 best_partial_font_missing_char_count = missing_count;
1061 best_partial_font = current_font; 1080 best_partial_font = current_font;
1062 } 1081 }
1063 } 1082 }
1064 1083
1065 // If a font was able to partially display the run, use that now. 1084 // If a font was able to partially display the run, use that now.
1066 if (best_partial_font_missing_char_count < static_cast<int>(run_length)) { 1085 if (best_partial_font_missing_char_count < static_cast<int>(run_length)) {
1067 // Re-shape the run only if |best_partial_font| differs from the last font. 1086 // Re-shape the run only if |best_partial_font| differs from the last font.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 size_t position = LayoutIndexToTextIndex(run->range.end()); 1243 size_t position = LayoutIndexToTextIndex(run->range.end());
1225 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); 1244 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD);
1226 return SelectionModel(position, CURSOR_FORWARD); 1245 return SelectionModel(position, CURSOR_FORWARD);
1227 } 1246 }
1228 1247
1229 RenderText* RenderText::CreateNativeInstance() { 1248 RenderText* RenderText::CreateNativeInstance() {
1230 return new RenderTextWin; 1249 return new RenderTextWin;
1231 } 1250 }
1232 1251
1233 } // namespace gfx 1252 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698