OLD | NEW |
---|---|
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 Loading... | |
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 // Skip the first fallback font, which is |uniscribe_font|. | |
1128 fallback_families.insert(fallback_families.end(), | |
1129 uniscribe_fallbacks.begin() + 1, uniscribe_fallbacks.end()); | |
Daniel Erat
2014/10/28 18:00:36
can the returned vector ever be empty? if so, you
msw
2014/10/28 18:17:56
It looks like all impls should return at least one
ckocagil
2014/10/29 01:07:20
We now add all fonts and skip if it's primary_font
| |
1130 } | |
1114 #endif | 1131 #endif |
1115 | 1132 |
1116 // Skip the first fallback font, which is |primary_font|. | 1133 // Skip the first fallback font, which is |primary_font|. |
msw
2014/10/28 18:17:56
I'm trying to determine if this is true for font_f
Daniel Erat
2014/10/28 18:20:53
yeah, you're right -- this seems wrong. i don't th
ckocagil
2014/10/29 01:07:20
Done.
| |
1117 std::vector<std::string> fallback_families = | |
1118 GetFallbackFontFamilies(primary_font.GetFontName()); | |
1119 for (size_t i = 1; i < fallback_families.size(); ++i) { | 1134 for (size_t i = 1; i < fallback_families.size(); ++i) { |
1120 FontRenderParamsQuery query(false); | 1135 FontRenderParamsQuery query(false); |
1121 query.families.push_back(fallback_families[i]); | 1136 query.families.push_back(fallback_families[i]); |
1122 query.pixel_size = run->font_size; | 1137 query.pixel_size = run->font_size; |
1123 query.style = run->font_style; | 1138 query.style = run->font_style; |
1124 FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL); | 1139 FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL); |
1125 if (CompareFamily(run, fallback_families[i], fallback_render_params, | 1140 if (CompareFamily(run, fallback_families[i], fallback_render_params, |
1126 &best_family, &best_render_params, &best_missing_glyphs)) | 1141 &best_family, &best_render_params, &best_missing_glyphs)) |
1127 return; | 1142 return; |
1128 } | 1143 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1190 run->width = std::floor(run->width + 0.5f); | 1205 run->width = std::floor(run->width + 0.5f); |
1191 #endif | 1206 #endif |
1192 } | 1207 } |
1193 | 1208 |
1194 hb_buffer_destroy(buffer); | 1209 hb_buffer_destroy(buffer); |
1195 hb_font_destroy(harfbuzz_font); | 1210 hb_font_destroy(harfbuzz_font); |
1196 return true; | 1211 return true; |
1197 } | 1212 } |
1198 | 1213 |
1199 } // namespace gfx | 1214 } // namespace gfx |
OLD | NEW |