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 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 render_text.SetFontList(font_list); | 2562 render_text.SetFontList(font_list); |
2563 // Korean character "han". | 2563 // Korean character "han". |
2564 render_text.SetText(WideToUTF16(L"\xd55c")); | 2564 render_text.SetText(WideToUTF16(L"\xd55c")); |
2565 render_text.EnsureLayout(); | 2565 render_text.EnsureLayout(); |
2566 internal::TextRunList* run_list = render_text.GetRunList(); | 2566 internal::TextRunList* run_list = render_text.GetRunList(); |
2567 ASSERT_EQ(1U, run_list->size()); | 2567 ASSERT_EQ(1U, run_list->size()); |
2568 EXPECT_EQ(0U, run_list->runs()[0]->CountMissingGlyphs()); | 2568 EXPECT_EQ(0U, run_list->runs()[0]->CountMissingGlyphs()); |
2569 } | 2569 } |
2570 #endif // defined(OS_WIN) | 2570 #endif // defined(OS_WIN) |
2571 | 2571 |
| 2572 // Ensure that the fallback fonts offered by gfx::GetFallbackFontFamilies() are |
| 2573 // tried. Note this test assumes the font "Arial" doesn't provide a unicode |
| 2574 // glyph for a particular character, and that there exists a system fallback |
| 2575 // font which does. |
| 2576 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 2577 TEST_F(RenderTextTest, HarfBuzz_UnicodeFallback) { |
| 2578 RenderTextHarfBuzz render_text; |
| 2579 render_text.SetFontList(FontList("Arial, 12px")); |
| 2580 |
| 2581 // Korean character "han". |
| 2582 render_text.SetText(WideToUTF16(L"\xd55c")); |
| 2583 render_text.EnsureLayout(); |
| 2584 internal::TextRunList* run_list = render_text.GetRunList(); |
| 2585 ASSERT_EQ(1U, run_list->size()); |
| 2586 EXPECT_EQ(0U, run_list->runs()[0]->CountMissingGlyphs()); |
| 2587 } |
| 2588 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 2589 |
2572 // Ensure that the width reported by RenderText is sufficient for drawing. Draws | 2590 // Ensure that the width reported by RenderText is sufficient for drawing. Draws |
2573 // to a canvas and checks whether any pixel beyond the width is colored. | 2591 // to a canvas and checks whether any pixel beyond the width is colored. |
2574 TEST_F(RenderTextTest, TextDoesntClip) { | 2592 TEST_F(RenderTextTest, TextDoesntClip) { |
2575 const wchar_t* kTestStrings[] = { L"Save", L"Remove", L"TEST", L"W", L"WWW" }; | 2593 const wchar_t* kTestStrings[] = { L"Save", L"Remove", L"TEST", L"W", L"WWW" }; |
2576 const Size kCanvasSize(300, 50); | 2594 const Size kCanvasSize(300, 50); |
2577 const int kTestWidth = 10; | 2595 const int kTestWidth = 10; |
2578 | 2596 |
2579 skia::RefPtr<SkSurface> surface = skia::AdoptRef( | 2597 skia::RefPtr<SkSurface> surface = skia::AdoptRef( |
2580 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height())); | 2598 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height())); |
2581 scoped_ptr<Canvas> canvas( | 2599 scoped_ptr<Canvas> canvas( |
(...skipping 20 matching lines...) Expand all Loading... |
2602 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; | 2620 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; |
2603 for (int x = 1; x < kTestWidth; ++x) { | 2621 for (int x = 1; x < kTestWidth; ++x) { |
2604 color = buffer[width + x + y * kCanvasSize.width()]; | 2622 color = buffer[width + x + y * kCanvasSize.width()]; |
2605 EXPECT_EQ(SK_ColorWHITE, color) << string; | 2623 EXPECT_EQ(SK_ColorWHITE, color) << string; |
2606 } | 2624 } |
2607 } | 2625 } |
2608 } | 2626 } |
2609 } | 2627 } |
2610 | 2628 |
2611 } // namespace gfx | 2629 } // namespace gfx |
OLD | NEW |