Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: chrome/browser/android/vr_shell/font_fallback.cc

Issue 2914543002: [vr] Bail on unhandled code points. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/font_fallback.cc
diff --git a/chrome/browser/android/vr_shell/font_fallback.cc b/chrome/browser/android/vr_shell/font_fallback.cc
index 9d67ccb35d0675cc1712974aa0611908d17ca8f8..5c0f997507c253d05f0c8d28f071111133c00b5e 100644
--- a/chrome/browser/android/vr_shell/font_fallback.cc
+++ b/chrome/browser/android/vr_shell/font_fallback.cc
@@ -85,13 +85,16 @@ class CachedFontSet {
}
}
- std::string GetFallbackFontNameForChar(UChar32 c) {
+ bool GetFallbackFontNameForChar(UChar32 c, std::string* font_name) {
if (unknown_chars_.find(c) != unknown_chars_.end())
- return "";
+ return false;
+
for (SkFontID font_id : font_ids_) {
std::unique_ptr<CachedFont>& font = g_fonts.Get()[font_id];
- if (font->HasGlyphForCharacter(c))
- return font->GetFontName();
+ if (font->HasGlyphForCharacter(c)) {
+ *font_name = font->GetFontName();
+ return true;
+ }
}
sk_sp<SkFontMgr> font_mgr(SkFontMgr::RefDefault());
const char* bcp47_locales[] = {locale_.c_str()};
@@ -104,10 +107,11 @@ class CachedFontSet {
std::unique_ptr<CachedFont>& cached_font = g_fonts.Get()[font_id];
if (!cached_font)
cached_font = CachedFont::CreateForTypeface(tf);
- return cached_font->GetFontName();
+ *font_name = cached_font->GetFontName();
+ return true;
}
unknown_chars_.insert(c);
- return std::string();
+ return false;
}
private:
@@ -133,14 +137,17 @@ bool FontSupportsChar(const gfx::Font& font, UChar32 c) {
} // namespace
-std::string GetFallbackFontNameForChar(const gfx::Font& default_font,
- UChar32 c,
- const std::string& locale) {
- if (FontSupportsChar(default_font, c))
- return std::string();
+bool GetFallbackFontNameForChar(const gfx::Font& default_font,
+ UChar32 c,
+ const std::string& locale,
+ std::string* font_name) {
+ if (FontSupportsChar(default_font, c)) {
+ *font_name = std::string();
+ return true;
+ }
CachedFontSet& cached_font_set = g_cached_font_set.Get();
cached_font_set.SetLocale(locale);
- return cached_font_set.GetFallbackFontNameForChar(c);
+ return cached_font_set.GetFallbackFontNameForChar(c, font_name);
}
} // namespace vr_shell
« no previous file with comments | « chrome/browser/android/vr_shell/font_fallback.h ('k') | chrome/browser/android/vr_shell/textures/exit_warning_texture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698