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

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

Issue 400193004: Unify desktop Linux and Chrome OS font rendering params. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update some comments Created 6 years, 5 months 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 | Annotate | Revision Log
« ui/gfx/linux_font_delegate.h ('K') | « ui/gfx/platform_font_pango.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 30 matching lines...) Expand all
41 #if defined(OS_CHROMEOS) 41 #if defined(OS_CHROMEOS)
42 // static 42 // static
43 std::string* PlatformFontPango::default_font_description_ = NULL; 43 std::string* PlatformFontPango::default_font_description_ = NULL;
44 #endif 44 #endif
45 45
46 //////////////////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////////////////
47 // PlatformFontPango, public: 47 // PlatformFontPango, public:
48 48
49 PlatformFontPango::PlatformFontPango() { 49 PlatformFontPango::PlatformFontPango() {
50 if (!default_font_) { 50 if (!default_font_) {
51 std::string desc_string; 51 scoped_ptr<ScopedPangoFontDescription> desc;
msw 2014/07/18 19:14:44 nit: |description| shouldn't cause any extra wrapp
Daniel Erat 2014/07/18 19:39:09 Done.
52 const gfx::LinuxFontDelegate* delegate = gfx::LinuxFontDelegate::instance();
53 if (delegate)
54 desc = delegate->GetDefaultPangoFontDescription();
55
56 if (!desc.get()) {
57 std::string desc_string;
52 #if defined(OS_CHROMEOS) 58 #if defined(OS_CHROMEOS)
53 // Font name must have been provided by way of SetDefaultFontDescription(). 59 CHECK(default_font_description_);
msw 2014/07/18 19:14:44 ChromeOS uses InitDefaultFontList() to set a speci
Daniel Erat 2014/07/18 19:39:09 chrome os doesn't use a LinuxFontDelegate (althoug
msw 2014/07/18 19:59:46 Hmm, I think the latest patch set is a bit safer f
54 CHECK(default_font_description_); 60 desc_string = *default_font_description_;
55 desc_string = *default_font_description_;
56 #else 61 #else
57 const gfx::LinuxFontDelegate* delegate = gfx::LinuxFontDelegate::instance(); 62 desc_string = "sans 10";
58 desc_string = delegate ? delegate->GetDefaultFontDescription() : "sans 10";
59 #endif 63 #endif
64 desc.reset(new ScopedPangoFontDescription(
65 pango_font_description_from_string(desc_string.c_str())));
66 }
60 67
61 ScopedPangoFontDescription desc( 68 default_font_ = new Font(desc->get());
62 pango_font_description_from_string(desc_string.c_str()));
63 default_font_ = new Font(desc.get());
64 } 69 }
65 70
66 InitFromPlatformFont( 71 InitFromPlatformFont(
67 static_cast<PlatformFontPango*>(default_font_->platform_font())); 72 static_cast<PlatformFontPango*>(default_font_->platform_font()));
68 } 73 }
69 74
70 PlatformFontPango::PlatformFontPango(NativeFont native_font) { 75 PlatformFontPango::PlatformFontPango(NativeFont native_font) {
71 const int pango_size = 76 const int pango_size =
72 pango_font_description_get_size(native_font) / PANGO_SCALE; 77 pango_font_description_get_size(native_font) / PANGO_SCALE;
73 const bool pango_using_pixels = 78 const bool pango_using_pixels =
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return new PlatformFontPango(native_font); 371 return new PlatformFontPango(native_font);
367 } 372 }
368 373
369 // static 374 // static
370 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 375 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
371 int font_size) { 376 int font_size) {
372 return new PlatformFontPango(font_name, font_size); 377 return new PlatformFontPango(font_name, font_size);
373 } 378 }
374 379
375 } // namespace gfx 380 } // namespace gfx
OLDNEW
« ui/gfx/linux_font_delegate.h ('K') | « ui/gfx/platform_font_pango.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698