Chromium Code Reviews| 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")) { |
|
msw
2015/03/24 17:38:52
nit: maybe check |uniscribe_family| too?
ananta
2015/03/24 20:10:12
Done.
| |
| 1300 GetFallbackFontFamilies("Segoe UI"); | 1301 std::vector<std::string> default_fallback_families = |
| 1301 fallback_families.insert(fallback_families.end(), | 1302 GetFallbackFontFamilies("Segoe UI"); |
| 1302 default_fallback_families.begin(), default_fallback_families.end()); | 1303 fallback_families.insert(fallback_families.end(), |
| 1304 default_fallback_families.begin(), default_fallback_families.end()); | |
| 1305 } | |
| 1303 #endif | 1306 #endif |
| 1304 | 1307 |
| 1305 // Get rid of duplicate fonts in the fallback list. We use the std::unique | 1308 // 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 | 1309 // 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. | 1310 // the font list as the unique algorithm relies on duplicates being adjacent. |
| 1308 // TODO(ananta) | 1311 // TODO(ananta) |
| 1309 // Sorting the list changes the order in which fonts are evaluated. This may | 1312 // 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 | 1313 // 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 | 1314 // font fallback on the same lines as blink or skia which do this based on |
| 1312 // character glyph mapping. | 1315 // character glyph mapping. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1515 DCHECK(!update_layout_run_list_); | 1518 DCHECK(!update_layout_run_list_); |
| 1516 DCHECK(!update_display_run_list_); | 1519 DCHECK(!update_display_run_list_); |
| 1517 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1520 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
| 1518 } | 1521 } |
| 1519 | 1522 |
| 1520 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1523 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
| 1521 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1524 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
| 1522 } | 1525 } |
| 1523 | 1526 |
| 1524 } // namespace gfx | 1527 } // namespace gfx |
| OLD | NEW |