OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 render_text->SetText(kString); | 2319 render_text->SetText(kString); |
2320 render_text->ApplyStyle(BOLD, true, Range(0, 3)); | 2320 render_text->ApplyStyle(BOLD, true, Range(0, 3)); |
2321 render_text->SetElideBehavior(ELIDE_TAIL); | 2321 render_text->SetElideBehavior(ELIDE_TAIL); |
2322 | 2322 |
2323 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); | 2323 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); |
2324 EXPECT_EQ(kString, render_text->GetLayoutText()); | 2324 EXPECT_EQ(kString, render_text->GetLayoutText()); |
2325 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); | 2325 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); |
2326 EXPECT_EQ(kString, render_text->GetLayoutText()); | 2326 EXPECT_EQ(kString, render_text->GetLayoutText()); |
2327 } | 2327 } |
2328 | 2328 |
| 2329 // Ensure that RenderText examines all of the fonts in its FontList before |
| 2330 // falling back to other fonts. |
| 2331 TEST_F(RenderTextTest, FontListFallback) { |
| 2332 // Double-check that the requested fonts are present. |
| 2333 FontList font_list("Arial, Symbol, 12px"); |
| 2334 const std::vector<Font>& fonts = font_list.GetFonts(); |
| 2335 ASSERT_EQ(2u, fonts.size()); |
| 2336 ASSERT_EQ("arial", |
| 2337 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); |
| 2338 ASSERT_EQ("symbol", |
| 2339 base::StringToLowerASCII(fonts[1].GetActualFontNameForTesting())); |
| 2340 |
| 2341 // "⊕" (CIRCLED PLUS) should be rendered with Symbol rather than falling back |
| 2342 // to some other font that's present on the system. |
| 2343 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
| 2344 render_text->SetFontList(font_list); |
| 2345 render_text->SetText(UTF8ToUTF16("\xE2\x8A\x95")); |
| 2346 const std::vector<RenderText::FontSpan> spans = |
| 2347 render_text->GetFontSpansForTesting(); |
| 2348 ASSERT_EQ(static_cast<size_t>(1), spans.size()); |
| 2349 EXPECT_EQ("Symbol", spans[0].first.GetFontName()); |
| 2350 } |
| 2351 |
2329 } // namespace gfx | 2352 } // namespace gfx |
OLD | NEW |