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