| 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 63299889200a2d7158006602f20e6aa0b5441584..c5e40dd2ffd0921239dd4d7fc83a36a02fc8c8db 100644
|
| --- a/chrome/browser/android/vr_shell/textures/ui_texture.cc
|
| +++ b/chrome/browser/android/vr_shell/textures/ui_texture.cc
|
| @@ -29,6 +29,8 @@ namespace {
|
|
|
| static constexpr char kDefaultFontFamily[] = "sans-serif";
|
|
|
| +static bool force_font_fallback_failure_for_testing_ = false;
|
| +
|
| std::set<UChar32> CollectDifferentChars(base::string16 text) {
|
| std::set<UChar32> characters;
|
| for (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) {
|
| @@ -162,6 +164,20 @@ gfx::FontList UiTexture::GetDefaultFontList(int size) {
|
| return gfx::FontList(gfx::Font(kDefaultFontFamily, size));
|
| }
|
|
|
| +bool UiTexture::CheckFontList(int size, base::string16 text) {
|
| + if (force_font_fallback_failure_for_testing_)
|
| + return false;
|
| +
|
| + gfx::Font default_font(kDefaultFontFamily, size);
|
| + // TODO(acondor): Query BrowserProcess to obtain the application locale.
|
| + for (UChar32 c : CollectDifferentChars(text)) {
|
| + std::string name;
|
| + if (!GetFallbackFontNameForChar(default_font, c, "", &name))
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| gfx::FontList UiTexture::GetFontList(int size, base::string16 text) {
|
| gfx::Font default_font(kDefaultFontFamily, size);
|
| std::vector<gfx::Font> fonts{default_font};
|
| @@ -169,8 +185,9 @@ gfx::FontList UiTexture::GetFontList(int size, base::string16 text) {
|
| std::set<std::string> names;
|
| // TODO(acondor): Query BrowserProcess to obtain the application locale.
|
| for (UChar32 c : CollectDifferentChars(text)) {
|
| - std::string name = GetFallbackFontNameForChar(default_font, c, "");
|
| - if (!name.empty())
|
| + std::string name;
|
| + bool found_name = GetFallbackFontNameForChar(default_font, c, "", &name);
|
| + if (found_name && !name.empty())
|
| names.insert(name);
|
| }
|
| for (const auto& name : names)
|
| @@ -178,4 +195,8 @@ gfx::FontList UiTexture::GetFontList(int size, base::string16 text) {
|
| return gfx::FontList(fonts);
|
| }
|
|
|
| +void UiTexture::SetForceFontFallbackFailureForTesting(bool force) {
|
| + force_font_fallback_failure_for_testing_ = force;
|
| +}
|
| +
|
| } // namespace vr_shell
|
|
|