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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "ui/gfx/break_list.h" | 16 #include "ui/gfx/break_list.h" |
17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/font.h" | 18 #include "ui/gfx/font.h" |
19 #include "ui/gfx/platform_font_win.h" | |
19 #include "ui/gfx/render_text_harfbuzz.h" | 20 #include "ui/gfx/render_text_harfbuzz.h" |
20 | 21 |
21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
22 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
23 #include "ui/gfx/render_text_win.h" | 24 #include "ui/gfx/render_text_win.h" |
24 #endif | 25 #endif |
25 | 26 |
26 #if defined(OS_LINUX) && !defined(USE_OZONE) | 27 #if defined(OS_LINUX) && !defined(USE_OZONE) |
27 #include "ui/gfx/render_text_pango.h" | 28 #include "ui/gfx/render_text_pango.h" |
28 #endif | 29 #endif |
29 | 30 |
30 using base::ASCIIToUTF16; | 31 using base::ASCIIToUTF16; |
31 using base::UTF8ToUTF16; | 32 using base::UTF8ToUTF16; |
32 using base::WideToUTF16; | 33 using base::WideToUTF16; |
34 using base::WideToUTF8; | |
33 | 35 |
34 namespace gfx { | 36 namespace gfx { |
35 | 37 |
36 namespace { | 38 namespace { |
37 | 39 |
38 // Various weak, LTR, RTL, and Bidi string cases with three characters each. | 40 // Various weak, LTR, RTL, and Bidi string cases with three characters each. |
39 const wchar_t kWeak[] = L" . "; | 41 const wchar_t kWeak[] = L" . "; |
40 const wchar_t kLtr[] = L"abc"; | 42 const wchar_t kLtr[] = L"abc"; |
41 const wchar_t kRtl[] = L"\x5d0\x5d1\x5d2"; | 43 const wchar_t kRtl[] = L"\x5d0\x5d1\x5d2"; |
42 #if !defined(OS_MACOSX) | 44 #if !defined(OS_MACOSX) |
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2319 render_text->SetText(kString); | 2321 render_text->SetText(kString); |
2320 render_text->ApplyStyle(BOLD, true, Range(0, 3)); | 2322 render_text->ApplyStyle(BOLD, true, Range(0, 3)); |
2321 render_text->SetElideBehavior(ELIDE_TAIL); | 2323 render_text->SetElideBehavior(ELIDE_TAIL); |
2322 | 2324 |
2323 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); | 2325 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); |
2324 EXPECT_EQ(kString, render_text->GetLayoutText()); | 2326 EXPECT_EQ(kString, render_text->GetLayoutText()); |
2325 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); | 2327 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); |
2326 EXPECT_EQ(kString, render_text->GetLayoutText()); | 2328 EXPECT_EQ(kString, render_text->GetLayoutText()); |
2327 } | 2329 } |
2328 | 2330 |
2331 // Ensure that the fallback fonts of the Uniscribe font are tried for shaping. | |
2332 #if defined(OS_WIN) | |
2333 TEST_F(RenderTextTest, HarfBuzz_UniscribeFallback) { | |
2334 RenderTextHarfBuzz render_text; | |
2335 PlatformFontWin* font_win = new PlatformFontWin("Meiryo", 12); | |
2336 // Japanese name for Meiryo. This name won't be found in the system's linked | |
2337 // fonts, forcing RTHB to try the Uniscribe font and its fallbacks. | |
msw
2014/10/28 18:17:56
I'm not sure this really tests that the Uniscribe
ckocagil
2014/10/29 01:07:20
Yes, it fails without this fix.
| |
2338 font_win->font_ref_->font_name_ = WideToUTF8(L"\x30e1\x30a4\x30ea\x30aa"); | |
2339 Font font(font_win); | |
msw
2014/10/28 18:17:56
nit: inline this in the line below?
ckocagil
2014/10/29 01:07:20
"FontList font_list(Font(font_win));" gives a synt
Daniel Erat
2014/10/29 01:18:10
you can just work around this with an extra set of
ckocagil
2014/10/29 02:05:16
Oh, that works! Thanks!
| |
2340 FontList font_list(font); | |
2341 | |
2342 render_text.SetFontList(font_list); | |
2343 // Korean character "han". | |
2344 render_text.SetText(WideToUTF16(L"\xd55c")); | |
2345 render_text.EnsureLayout(); | |
2346 ASSERT_EQ(1U, render_text.runs_.size()); | |
2347 EXPECT_EQ(0U, render_text.runs_[0]->CountMissingGlyphs()); | |
2348 } | |
2349 #endif // defined(OS_WIN) | |
2350 | |
2329 } // namespace gfx | 2351 } // namespace gfx |
OLD | NEW |