Index: ui/gfx/render_text_unittest.cc |
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc |
index 1c6f902d936fb435827912df67561e1d1af51c51..c67f9e973070cdf5b590a9fb014c7e181a3f5b66 100644 |
--- a/ui/gfx/render_text_unittest.cc |
+++ b/ui/gfx/render_text_unittest.cc |
@@ -2326,4 +2326,29 @@ TEST_F(RenderTextTest, StringFitsOwnWidth) { |
EXPECT_EQ(kString, render_text->GetLayoutText()); |
} |
+// Ensure that RenderText examines all of the fonts in its FontList before |
+// falling back to other fonts. |
+TEST_F(RenderTextTest, FontListFallback) { |
Daniel Erat
2014/10/24 15:43:23
not sure yet whether this will work on all platfor
msw
2014/10/24 16:09:11
Acknowledged.
|
+ // Double-check that the requested fonts are present. |
+ FontList font_list("Arial, Symbol, 12px"); |
+ const std::vector<Font>& fonts = font_list.GetFonts(); |
+ ASSERT_EQ(2u, fonts.size()); |
+ ASSERT_EQ("arial", |
+ base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); |
+ ASSERT_EQ("symbol", |
+ base::StringToLowerASCII(fonts[1].GetActualFontNameForTesting())); |
+ |
+ // "⊕" (CIRCLED PLUS) should be rendered with Symbol rather than falling back |
msw
2014/10/24 16:09:11
Can you actually include this unicode char in this
Daniel Erat
2014/10/24 16:25:47
the web is inconclusive here, but i think it's fin
msw
2014/10/24 16:48:29
Hmm, the style guide might suggest only UTF-8 and
|
+ // to some other font that's present on the system. |
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
+ render_text->SetFontList(font_list); |
+ render_text->SetText(UTF8ToUTF16("\xE2\x8A\x95")); |
+ Canvas canvas; |
+ render_text->Draw(&canvas); |
msw
2014/10/24 16:09:11
You shouldn't need to Draw, GetFontSpansForTesting
Daniel Erat
2014/10/24 16:25:47
cool, thanks. done.
|
+ const std::vector<RenderText::FontSpan> spans = |
+ render_text->GetFontSpansForTesting(); |
+ ASSERT_EQ(static_cast<size_t>(1), spans.size()); |
+ EXPECT_EQ("Symbol", spans[0].first.GetFontName()); |
msw
2014/10/24 16:09:11
Does this actually fail without your change?
Daniel Erat
2014/10/24 16:25:47
yep, wrote the test first. :-P at least on my gtru
msw
2014/10/24 16:48:29
Acknowledged.
|
+} |
+ |
} // namespace gfx |