Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: ui/gfx/render_text_unittest.cc

Issue 674233003: RenderTextHarfBuzz: Try fallback fonts of the Uniscribe font while shaping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix include Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/render_text_harfbuzz.h" 19 #include "ui/gfx/render_text_harfbuzz.h"
20 20
21 #if defined(OS_WIN) 21 #if defined(OS_WIN)
22 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
23 #include "ui/gfx/platform_font_win.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 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 2347 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
2346 render_text->SetFontList(font_list); 2348 render_text->SetFontList(font_list);
2347 render_text->SetText(UTF8ToUTF16("\xE2\x8A\x95")); 2349 render_text->SetText(UTF8ToUTF16("\xE2\x8A\x95"));
2348 const std::vector<RenderText::FontSpan> spans = 2350 const std::vector<RenderText::FontSpan> spans =
2349 render_text->GetFontSpansForTesting(); 2351 render_text->GetFontSpansForTesting();
2350 ASSERT_EQ(static_cast<size_t>(1), spans.size()); 2352 ASSERT_EQ(static_cast<size_t>(1), spans.size());
2351 EXPECT_EQ("Symbol", spans[0].first.GetFontName()); 2353 EXPECT_EQ("Symbol", spans[0].first.GetFontName());
2352 } 2354 }
2353 #endif // !defined(OS_WIN) 2355 #endif // !defined(OS_WIN)
2354 2356
2357 // Ensure that the fallback fonts of the Uniscribe font are tried for shaping.
2358 #if defined(OS_WIN)
2359 TEST_F(RenderTextTest, HarfBuzz_UniscribeFallback) {
2360 RenderTextHarfBuzz render_text;
2361 PlatformFontWin* font_win = new PlatformFontWin("Meiryo", 12);
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.
2364 font_win->font_ref_->font_name_ = WideToUTF8(L"\x30e1\x30a4\x30ea\x30aa");
2365 FontList font_list((Font(font_win)));
2366
2367 render_text.SetFontList(font_list);
2368 // Korean character "han".
2369 render_text.SetText(WideToUTF16(L"\xd55c"));
2370 render_text.EnsureLayout();
2371 ASSERT_EQ(1U, render_text.runs_.size());
2372 EXPECT_EQ(0U, render_text.runs_[0]->CountMissingGlyphs());
2373 }
2374 #endif // defined(OS_WIN)
2375
2355 } // namespace gfx 2376 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698