Chromium Code Reviews| Index: chrome/browser/android/vr_shell/textures/ui_texture.cc |
| diff --git a/chrome/browser/android/vr_shell/textures/ui_texture.cc b/chrome/browser/android/vr_shell/textures/ui_texture.cc |
| index b5edf11cafcede42e9f3c72f548c09787a5aa0e8..19aef97e5f94b5ea0cbc4731693b50abdedbac90 100644 |
| --- a/chrome/browser/android/vr_shell/textures/ui_texture.cc |
| +++ b/chrome/browser/android/vr_shell/textures/ui_texture.cc |
| @@ -13,9 +13,10 @@ |
| #include "base/memory/ptr_util.h" |
| #include "base/strings/string_util.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "third_party/icu/source/common/unicode/uscript.h" |
| #include "third_party/skia/include/core/SkCanvas.h" |
| -#include "third_party/skia/include/ports/SkFontMgr.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/gfx/font_fallback_android.h" |
| #include "ui/gfx/font_list.h" |
| #include "ui/gl/gl_bindings.h" |
| @@ -23,6 +24,15 @@ namespace vr_shell { |
| namespace { |
|
Alexei Svitkine (slow)
2017/05/09 14:52:16
Nit: Add an empty line after this now that the blo
acondor_
2017/05/09 16:21:51
Done.
|
| constexpr char kDefaultFontFamily[] = "sans-serif"; |
| + |
| +std::set<UChar32> CollectDifferentChars(base::string16 text) { |
| + std::set<UChar32> characters; |
| + for (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) { |
| + characters.insert(it.get()); |
| + } |
| + return characters; |
| +} |
| + |
| } // namespace |
| UiTexture::UiTexture() = default; |
| @@ -32,6 +42,7 @@ UiTexture::~UiTexture() = default; |
| void UiTexture::DrawAndLayout(SkCanvas* canvas, const gfx::Size& texture_size) { |
| cc::SkiaPaintCanvas paint_canvas(canvas); |
| gfx::Canvas gfx_canvas(&paint_canvas, 1.0f); |
| + |
|
Alexei Svitkine (slow)
2017/05/09 14:52:16
Nit: Remove extra unnecessary change
acondor_
2017/05/09 16:21:51
Done.
|
| gfx_canvas.DrawColor(SK_ColorTRANSPARENT); |
| Draw(&gfx_canvas, texture_size); |
| } |
| @@ -44,28 +55,11 @@ gfx::FontList UiTexture::GetFontList(int size, base::string16 text) { |
| gfx::Font default_font(kDefaultFontFamily, size); |
| std::vector<gfx::Font> fonts{default_font}; |
| - std::set<wchar_t> characters; |
| - for (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) { |
| - characters.insert(it.get()); |
| - } |
| - // TODO(acondor): Obtain fallback fonts with gfx::GetFallbackFonts |
| - // (which is not implemented for android yet) in order to avoid |
| - // querying per character. |
| - |
| - sk_sp<SkFontMgr> font_mgr(SkFontMgr::RefDefault()); |
| std::set<std::string> names; |
| // TODO(acondor): Query BrowserProcess to obtain the application locale. |
| - for (wchar_t character : characters) { |
| - sk_sp<SkTypeface> tf(font_mgr->matchFamilyStyleCharacter( |
| - kDefaultFontFamily, SkFontStyle(), nullptr, 0, character)); |
| - |
| - // TODO(acondor): How should we handle no matching font? |
| - if (!tf) |
| - continue; |
| - SkString sk_name; |
| - tf->getFamilyName(&sk_name); |
| - std::string name(sk_name.c_str()); |
| - if (name != kDefaultFontFamily) |
| + for (UChar32 c : CollectDifferentChars(text)) { |
| + std::string name = gfx::GetFallbackFontNameForChar(default_font, c, ""); |
| + if (!name.empty()) |
| names.insert(name); |
| } |
| for (const auto& name : names) |