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 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2570 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); | 2570 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); |
2571 EXPECT_EQ(Range(0, 0), | 2571 EXPECT_EQ(Range(0, 0), |
2572 internal::RoundRangeF(run.GetGraphemeBounds(iter.get(), 4))); | 2572 internal::RoundRangeF(run.GetGraphemeBounds(iter.get(), 4))); |
2573 Range chars; | 2573 Range chars; |
2574 Range glyphs; | 2574 Range glyphs; |
2575 run.GetClusterAt(4, &chars, &glyphs); | 2575 run.GetClusterAt(4, &chars, &glyphs); |
2576 EXPECT_EQ(Range(3, 8), chars); | 2576 EXPECT_EQ(Range(3, 8), chars); |
2577 EXPECT_EQ(Range(0, 0), glyphs); | 2577 EXPECT_EQ(Range(0, 0), glyphs); |
2578 } | 2578 } |
2579 | 2579 |
2580 // Ensure the line breaker doesn't compute the word's width bigger than the | |
2581 // actual size. See http://crbug.com/470073 | |
2582 TEST_F(RenderTextTest, HarfBuzz_WordWidthWithDiacritics) { | |
2583 RenderTextHarfBuzz render_text; | |
2584 const base::string16 kWord = WideToUTF16(L"\u0906\u092A\u0915\u0947 "); | |
2585 render_text.SetText(kWord); | |
2586 gfx::SizeF text_size = render_text.GetStringSizeF(); | |
msw
2015/03/25 20:25:16
nit: const
Jun Mukai
2015/03/25 21:50:05
Done.
| |
2587 | |
2588 render_text.SetText(kWord + kWord); | |
msw
2015/03/25 20:25:16
nit: after this, but before SetDisplayRect, can yo
Jun Mukai
2015/03/25 21:50:05
Done.
| |
2589 render_text.SetMultiline(true); | |
2590 render_text.SetDisplayRect(gfx::Rect(0, 0, text_size.width(), 0)); | |
msw
2015/03/25 20:25:16
nit: instead of setting the display rect, can you
Jun Mukai
2015/03/25 21:50:05
'\n' doesn't work well in this case, since RTHB sp
msw
2015/03/25 22:51:44
Acknowledged.
| |
2591 EXPECT_EQ(text_size.width(), render_text.GetStringSizeF().width()); | |
2592 EXPECT_EQ(text_size.height() * 2, render_text.GetStringSizeF().height()); | |
2593 } | |
2594 | |
2580 // Ensure a string fits in a display rect with a width equal to the string's. | 2595 // Ensure a string fits in a display rect with a width equal to the string's. |
2581 TEST_F(RenderTextTest, StringFitsOwnWidth) { | 2596 TEST_F(RenderTextTest, StringFitsOwnWidth) { |
2582 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 2597 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
2583 const base::string16 kString = ASCIIToUTF16("www.example.com"); | 2598 const base::string16 kString = ASCIIToUTF16("www.example.com"); |
2584 | 2599 |
2585 render_text->SetText(kString); | 2600 render_text->SetText(kString); |
2586 render_text->ApplyStyle(BOLD, true, Range(0, 3)); | 2601 render_text->ApplyStyle(BOLD, true, Range(0, 3)); |
2587 render_text->SetElideBehavior(ELIDE_TAIL); | 2602 render_text->SetElideBehavior(ELIDE_TAIL); |
2588 | 2603 |
2589 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); | 2604 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2822 string_size.set_width(string_size.width() / 2); | 2837 string_size.set_width(string_size.width() / 2); |
2823 render_text.SetDisplayRect(gfx::Rect(string_size)); | 2838 render_text.SetDisplayRect(gfx::Rect(string_size)); |
2824 render_text.EnsureLayout(); | 2839 render_text.EnsureLayout(); |
2825 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); | 2840 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); |
2826 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); | 2841 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); |
2827 EXPECT_NE(0, glyph_count); | 2842 EXPECT_NE(0, glyph_count); |
2828 } | 2843 } |
2829 #endif | 2844 #endif |
2830 | 2845 |
2831 } // namespace gfx | 2846 } // namespace gfx |
OLD | NEW |