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 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2325 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); | 2325 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); |
2326 EXPECT_EQ(kString, render_text->GetLayoutText()); | 2326 EXPECT_EQ(kString, render_text->GetLayoutText()); |
2327 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); | 2327 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); |
2328 EXPECT_EQ(kString, render_text->GetLayoutText()); | 2328 EXPECT_EQ(kString, render_text->GetLayoutText()); |
2329 } | 2329 } |
2330 | 2330 |
2331 // TODO(derat): Figure out why this fails on Windows: http://crbug.com/427184 | 2331 // TODO(derat): Figure out why this fails on Windows: http://crbug.com/427184 |
2332 #if !defined(OS_WIN) | 2332 #if !defined(OS_WIN) |
2333 // Ensure that RenderText examines all of the fonts in its FontList before | 2333 // Ensure that RenderText examines all of the fonts in its FontList before |
2334 // falling back to other fonts. | 2334 // falling back to other fonts. |
2335 TEST_F(RenderTextTest, FontListFallback) { | 2335 TEST_F(RenderTextTest, HarfBuzz_FontListFallback) { |
2336 // Double-check that the requested fonts are present. | 2336 // Double-check that the requested fonts are present. |
2337 FontList font_list("Arial, Symbol, 12px"); | 2337 FontList font_list("Arial, Symbol, 12px"); |
2338 const std::vector<Font>& fonts = font_list.GetFonts(); | 2338 const std::vector<Font>& fonts = font_list.GetFonts(); |
2339 ASSERT_EQ(2u, fonts.size()); | 2339 ASSERT_EQ(2u, fonts.size()); |
2340 ASSERT_EQ("arial", | 2340 ASSERT_EQ("arial", |
2341 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); | 2341 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); |
2342 ASSERT_EQ("symbol", | 2342 ASSERT_EQ("symbol", |
2343 base::StringToLowerASCII(fonts[1].GetActualFontNameForTesting())); | 2343 base::StringToLowerASCII(fonts[1].GetActualFontNameForTesting())); |
2344 | 2344 |
2345 // "⊕" (CIRCLED PLUS) should be rendered with Symbol rather than falling back | 2345 // "⊕" (CIRCLED PLUS) should be rendered with Symbol rather than falling back |
2346 // to some other font that's present on the system. | 2346 // to some other font that's present on the system. |
2347 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 2347 RenderTextHarfBuzz render_text; |
2348 render_text->SetFontList(font_list); | 2348 render_text.SetFontList(font_list); |
2349 render_text->SetText(UTF8ToUTF16("\xE2\x8A\x95")); | 2349 render_text.SetText(UTF8ToUTF16("\xE2\x8A\x95")); |
2350 const std::vector<RenderText::FontSpan> spans = | 2350 const std::vector<RenderText::FontSpan> spans = |
2351 render_text->GetFontSpansForTesting(); | 2351 render_text.GetFontSpansForTesting(); |
2352 ASSERT_EQ(static_cast<size_t>(1), spans.size()); | 2352 ASSERT_EQ(static_cast<size_t>(1), spans.size()); |
2353 EXPECT_EQ("Symbol", spans[0].first.GetFontName()); | 2353 EXPECT_EQ("Symbol", spans[0].first.GetFontName()); |
2354 } | 2354 } |
2355 #endif // !defined(OS_WIN) | 2355 #endif // !defined(OS_WIN) |
2356 | 2356 |
2357 // Ensure that the fallback fonts of the Uniscribe font are tried for shaping. | 2357 // Ensure that the fallback fonts of the Uniscribe font are tried for shaping. |
2358 #if defined(OS_WIN) | 2358 #if defined(OS_WIN) |
2359 TEST_F(RenderTextTest, HarfBuzz_UniscribeFallback) { | 2359 TEST_F(RenderTextTest, HarfBuzz_UniscribeFallback) { |
2360 RenderTextHarfBuzz render_text; | 2360 RenderTextHarfBuzz render_text; |
2361 PlatformFontWin* font_win = new PlatformFontWin("Meiryo", 12); | 2361 PlatformFontWin* font_win = new PlatformFontWin("Meiryo", 12); |
2362 // Japanese name for Meiryo. This name won't be found in the system's linked | 2362 // Japanese name for Meiryo. This name won't be found in the system's linked |
2363 // fonts, forcing RTHB to try the Uniscribe font and its fallbacks. | 2363 // fonts, forcing RTHB to try the Uniscribe font and its fallbacks. |
2364 font_win->font_ref_->font_name_ = WideToUTF8(L"\x30e1\x30a4\x30ea\x30aa"); | 2364 font_win->font_ref_->font_name_ = WideToUTF8(L"\x30e1\x30a4\x30ea\x30aa"); |
2365 FontList font_list((Font(font_win))); | 2365 FontList font_list((Font(font_win))); |
2366 | 2366 |
2367 render_text.SetFontList(font_list); | 2367 render_text.SetFontList(font_list); |
2368 // Korean character "han". | 2368 // Korean character "han". |
2369 render_text.SetText(WideToUTF16(L"\xd55c")); | 2369 render_text.SetText(WideToUTF16(L"\xd55c")); |
2370 render_text.EnsureLayout(); | 2370 render_text.EnsureLayout(); |
2371 ASSERT_EQ(1U, render_text.runs_.size()); | 2371 ASSERT_EQ(1U, render_text.runs_.size()); |
2372 EXPECT_EQ(0U, render_text.runs_[0]->CountMissingGlyphs()); | 2372 EXPECT_EQ(0U, render_text.runs_[0]->CountMissingGlyphs()); |
2373 } | 2373 } |
2374 #endif // defined(OS_WIN) | 2374 #endif // defined(OS_WIN) |
2375 | 2375 |
2376 } // namespace gfx | 2376 } // namespace gfx |
OLD | NEW |