Chromium Code Reviews| 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) { | |
|
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.
| |
| 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 | |
|
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
| |
| 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 Canvas canvas; | |
| 2347 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.
| |
| 2348 const std::vector<RenderText::FontSpan> spans = | |
| 2349 render_text->GetFontSpansForTesting(); | |
| 2350 ASSERT_EQ(static_cast<size_t>(1), spans.size()); | |
| 2351 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.
| |
| 2352 } | |
| 2353 | |
| 2329 } // namespace gfx | 2354 } // namespace gfx |
| OLD | NEW |