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 | 8 |
9 #include "base/i18n/bidi_line_iterator.h" | 9 #include "base/i18n/bidi_line_iterator.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
11 #include "base/i18n/char_iterator.h" | 11 #include "base/i18n/char_iterator.h" |
12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 13 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
15 #include "third_party/harfbuzz-ng/src/hb.h" | 16 #include "third_party/harfbuzz-ng/src/hb.h" |
16 #include "third_party/icu/source/common/unicode/ubidi.h" | 17 #include "third_party/icu/source/common/unicode/ubidi.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
18 #include "third_party/skia/include/core/SkTypeface.h" | 19 #include "third_party/skia/include/core/SkTypeface.h" |
19 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
20 #include "ui/gfx/font_fallback.h" | 21 #include "ui/gfx/font_fallback.h" |
21 #include "ui/gfx/font_render_params.h" | 22 #include "ui/gfx/font_render_params.h" |
22 #include "ui/gfx/geometry/safe_integer_conversions.h" | 23 #include "ui/gfx/geometry/safe_integer_conversions.h" |
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 GetFallbackFontFamilies(uniscribe_family); | 1290 GetFallbackFontFamilies(uniscribe_family); |
1290 fallback_families.insert(fallback_families.end(), | 1291 fallback_families.insert(fallback_families.end(), |
1291 uniscribe_fallbacks.begin(), uniscribe_fallbacks.end()); | 1292 uniscribe_fallbacks.begin(), uniscribe_fallbacks.end()); |
1292 } | 1293 } |
1293 | 1294 |
1294 // Add Segoe UI and its associated linked fonts to the fallback font list to | 1295 // Add Segoe UI and its associated linked fonts to the fallback font list to |
1295 // ensure that the fallback list covers the basic cases. | 1296 // ensure that the fallback list covers the basic cases. |
1296 // http://crbug.com/467459. On some Windows configurations the default font | 1297 // http://crbug.com/467459. On some Windows configurations the default font |
1297 // could be a raster font like System, which would not give us a reasonable | 1298 // could be a raster font like System, which would not give us a reasonable |
1298 // fallback font list. | 1299 // fallback font list. |
1299 std::vector<std::string> default_fallback_families = | 1300 if (!LowerCaseEqualsASCII(primary_family, "segoe ui") && |
1300 GetFallbackFontFamilies("Segoe UI"); | 1301 !LowerCaseEqualsASCII(uniscribe_family, "segoe ui")) { |
1301 fallback_families.insert(fallback_families.end(), | 1302 std::vector<std::string> default_fallback_families = |
1302 default_fallback_families.begin(), default_fallback_families.end()); | 1303 GetFallbackFontFamilies("Segoe UI"); |
| 1304 fallback_families.insert(fallback_families.end(), |
| 1305 default_fallback_families.begin(), default_fallback_families.end()); |
| 1306 } |
1303 #endif | 1307 #endif |
1304 | 1308 |
1305 // Get rid of duplicate fonts in the fallback list. We use the std::unique | 1309 // Get rid of duplicate fonts in the fallback list. We use the std::unique |
1306 // algorithm for this. However for this function to work we need to sort | 1310 // algorithm for this. However for this function to work we need to sort |
1307 // the font list as the unique algorithm relies on duplicates being adjacent. | 1311 // the font list as the unique algorithm relies on duplicates being adjacent. |
1308 // TODO(ananta) | 1312 // TODO(ananta) |
1309 // Sorting the list changes the order in which fonts are evaluated. This may | 1313 // Sorting the list changes the order in which fonts are evaluated. This may |
1310 // cause problems in the way some characters appear. It may be best to do | 1314 // cause problems in the way some characters appear. It may be best to do |
1311 // font fallback on the same lines as blink or skia which do this based on | 1315 // font fallback on the same lines as blink or skia which do this based on |
1312 // character glyph mapping. | 1316 // character glyph mapping. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 DCHECK(!update_layout_run_list_); | 1519 DCHECK(!update_layout_run_list_); |
1516 DCHECK(!update_display_run_list_); | 1520 DCHECK(!update_display_run_list_); |
1517 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1521 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
1518 } | 1522 } |
1519 | 1523 |
1520 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1524 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
1521 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1525 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
1522 } | 1526 } |
1523 | 1527 |
1524 } // namespace gfx | 1528 } // namespace gfx |
OLD | NEW |