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 <fontconfig/fontconfig.h> | 7 #include <fontconfig/fontconfig.h> |
8 #include <pango/pango.h> | 8 #include <pango/pango.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 #if defined(OS_CHROMEOS) | 67 #if defined(OS_CHROMEOS) |
68 // static | 68 // static |
69 std::string* PlatformFontPango::default_font_description_ = NULL; | 69 std::string* PlatformFontPango::default_font_description_ = NULL; |
70 #endif | 70 #endif |
71 | 71 |
72 //////////////////////////////////////////////////////////////////////////////// | 72 //////////////////////////////////////////////////////////////////////////////// |
73 // PlatformFontPango, public: | 73 // PlatformFontPango, public: |
74 | 74 |
75 PlatformFontPango::PlatformFontPango() { | 75 PlatformFontPango::PlatformFontPango() { |
76 if (!default_font_) { | 76 if (!default_font_) { |
77 std::string desc_string; | 77 scoped_ptr<ScopedPangoFontDescription> description; |
78 #if defined(OS_CHROMEOS) | 78 #if defined(OS_CHROMEOS) |
79 // Font name must have been provided by way of SetDefaultFontDescription(). | |
80 CHECK(default_font_description_); | 79 CHECK(default_font_description_); |
81 desc_string = *default_font_description_; | 80 description.reset(new ScopedPangoFontDescription( |
81 pango_font_description_from_string( | |
82 default_font_description_->c_str()))); | |
82 #else | 83 #else |
83 const gfx::LinuxFontDelegate* delegate = gfx::LinuxFontDelegate::instance(); | 84 const gfx::LinuxFontDelegate* delegate = gfx::LinuxFontDelegate::instance(); |
84 desc_string = delegate ? delegate->GetDefaultFontDescription() : "sans 10"; | 85 if (delegate) { |
86 description = delegate->GetDefaultPangoFontDescription(); | |
87 } else { | |
msw
2014/07/18 19:59:46
Should this be a separate check like "if (!descrip
Daniel Erat
2014/07/18 20:26:52
sure. i'd prefer to have the delegate only return
| |
88 description.reset(new ScopedPangoFontDescription( | |
89 pango_font_description_from_string("sans 10"))); | |
90 } | |
85 #endif | 91 #endif |
86 | 92 default_font_ = new Font(description->get()); |
87 ScopedPangoFontDescription desc( | |
88 pango_font_description_from_string(desc_string.c_str())); | |
89 default_font_ = new Font(desc.get()); | |
90 } | 93 } |
91 | 94 |
92 InitFromPlatformFont( | 95 InitFromPlatformFont( |
93 static_cast<PlatformFontPango*>(default_font_->platform_font())); | 96 static_cast<PlatformFontPango*>(default_font_->platform_font())); |
94 } | 97 } |
95 | 98 |
96 PlatformFontPango::PlatformFontPango(NativeFont native_font) { | 99 PlatformFontPango::PlatformFontPango(NativeFont native_font) { |
97 const int pango_size = | 100 const int pango_size = |
98 pango_font_description_get_size(native_font) / PANGO_SCALE; | 101 pango_font_description_get_size(native_font) / PANGO_SCALE; |
99 const bool pango_using_pixels = | 102 const bool pango_using_pixels = |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 return new PlatformFontPango(native_font); | 375 return new PlatformFontPango(native_font); |
373 } | 376 } |
374 | 377 |
375 // static | 378 // static |
376 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 379 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
377 int font_size) { | 380 int font_size) { |
378 return new PlatformFontPango(font_name, font_size); | 381 return new PlatformFontPango(font_name, font_size); |
379 } | 382 } |
380 | 383 |
381 } // namespace gfx | 384 } // namespace gfx |
OLD | NEW |