| 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 c93ca29e39126d88f285412d152d386b04552ae5..7cac42d2d92dc001543e0081e4afe4aa18733ab4 100644
|
| --- a/chrome/browser/android/vr_shell/textures/ui_texture.cc
|
| +++ b/chrome/browser/android/vr_shell/textures/ui_texture.cc
|
| @@ -4,17 +4,27 @@
|
|
|
| #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
|
|
|
| +#include <set>
|
| #include <string>
|
| #include <vector>
|
|
|
| +#include "base/i18n/char_iterator.h"
|
| +#include "base/i18n/rtl.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/strings/string_util.h"
|
| +#include "chrome/browser/browser_process.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_list.h"
|
| #include "ui/gl/gl_bindings.h"
|
|
|
| namespace vr_shell {
|
|
|
| +namespace {
|
| +constexpr char kDefaultFontFamily[] = "sans-serif";
|
| +} // namespace
|
| +
|
| // TODO(acondor): Create non-square textures to reduce memory usage.
|
| UITexture::UITexture(int texture_handle, int texture_size)
|
| : texture_handle_(texture_handle),
|
| @@ -46,4 +56,34 @@ void UITexture::Flush() {
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| }
|
|
|
| +bool UITexture::IsRTL() {
|
| + return base::i18n::IsRTL();
|
| +}
|
| +
|
| +gfx::FontList UITexture::GetFontList(int size, base::string16 text) {
|
| + gfx::Font default_font(kDefaultFontFamily, size);
|
| + std::vector<gfx::Font> fonts{default_font};
|
| +
|
| + // 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 (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) {
|
| + sk_sp<SkTypeface> tf(font_mgr->matchFamilyStyleCharacter(
|
| + default_font.GetFontName().c_str(), SkFontStyle(), nullptr, 0,
|
| + it.get()));
|
| + SkString sk_name;
|
| + tf->getFamilyName(&sk_name);
|
| + std::string name(sk_name.c_str());
|
| + if (name != kDefaultFontFamily)
|
| + names.insert(name);
|
| + }
|
| + for (const auto& name : names)
|
| + fonts.push_back(gfx::Font(name, size));
|
| + return gfx::FontList(fonts);
|
| +}
|
| +
|
| } // namespace vr_shell
|
|
|