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/platform_font_pango.h" | 5 #include "ui/gfx/platform_font_pango.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 #include <fontconfig/fontconfig.h> | 8 #include <fontconfig/fontconfig.h> |
9 #include <glib-object.h> | 9 #include <glib-object.h> |
10 #include <pango/pangocairo.h> | 10 #include <pango/pangocairo.h> |
11 #include <pango/pangofc-fontmap.h> | 11 #include <pango/pangofc-fontmap.h> |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "ui/gfx/pango_util.h" | 17 #include "ui/gfx/pango_util.h" |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 | 20 |
21 // Test that PlatformFontPango is able to cope with PangoFontDescriptions | 21 // Test that PlatformFontPango is able to cope with PangoFontDescriptions |
22 // containing multiple font families. The first family should be preferred. | 22 // containing multiple font families. The first family should be preferred. |
23 TEST(PlatformFontPangoTest, FamilyList) { | 23 TEST(PlatformFontPangoTest, FamilyList) { |
24 // Needed for GLib versions prior to 2.36, but deprecated starting 2.35. | 24 // Needed for GLib versions prior to 2.36, but deprecated starting 2.35. |
25 #if !GLIB_CHECK_VERSION(2, 35, 0) | 25 #if !GLIB_CHECK_VERSION(2, 35, 0) |
26 g_type_init(); | 26 g_type_init(); |
27 #endif | 27 #endif |
28 | 28 |
29 ScopedPangoFontDescription desc( | 29 ScopedPangoFontDescription desc("Arial,Times New Roman, 13px"); |
30 pango_font_description_from_string("Arial,Times New Roman, 13px")); | |
31 scoped_refptr<gfx::PlatformFontPango> font( | 30 scoped_refptr<gfx::PlatformFontPango> font( |
32 new gfx::PlatformFontPango(desc.get())); | 31 new gfx::PlatformFontPango(desc.get())); |
33 EXPECT_EQ("Arial", font->GetFontName()); | 32 EXPECT_EQ("Arial", font->GetFontName()); |
34 EXPECT_EQ(13, font->GetFontSize()); | 33 EXPECT_EQ(13, font->GetFontSize()); |
35 | 34 |
36 ScopedPangoFontDescription desc2( | 35 ScopedPangoFontDescription desc2("Times New Roman,Arial, 15px"); |
37 pango_font_description_from_string("Times New Roman,Arial, 15px")); | |
38 scoped_refptr<gfx::PlatformFontPango> font2( | 36 scoped_refptr<gfx::PlatformFontPango> font2( |
39 new gfx::PlatformFontPango(desc2.get())); | 37 new gfx::PlatformFontPango(desc2.get())); |
40 EXPECT_EQ("Times New Roman", font2->GetFontName()); | 38 EXPECT_EQ("Times New Roman", font2->GetFontName()); |
41 EXPECT_EQ(15, font2->GetFontSize()); | 39 EXPECT_EQ(15, font2->GetFontSize()); |
42 | 40 |
43 // Free memory allocated by FontConfig (http://crbug.com/114750). | 41 // Free memory allocated by FontConfig (http://crbug.com/114750). |
44 pango_fc_font_map_cache_clear( | 42 pango_fc_font_map_cache_clear( |
45 PANGO_FC_FONT_MAP(pango_cairo_font_map_get_default())); | 43 PANGO_FC_FONT_MAP(pango_cairo_font_map_get_default())); |
46 cairo_debug_reset_static_data(); | 44 cairo_debug_reset_static_data(); |
47 FcFini(); | 45 FcFini(); |
48 } | 46 } |
49 | 47 |
50 } // namespace gfx | 48 } // namespace gfx |
OLD | NEW |