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

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

Issue 8392017: Change string16 to std::string in the gfx::Font() interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add 'UTF-8' everywhere in the comments Created 9 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
« no previous file with comments | « ui/gfx/platform_font_mac.mm ('k') | ui/gfx/platform_font_pango.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef UI_GFX_PLATFORM_FONT_PANGO_H_ 5 #ifndef UI_GFX_PLATFORM_FONT_PANGO_H_
6 #define UI_GFX_PLATFORM_FONT_PANGO_H_ 6 #define UI_GFX_PLATFORM_FONT_PANGO_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "third_party/skia/include/core/SkRefCnt.h" 10 #include "third_party/skia/include/core/SkRefCnt.h"
11 #include "ui/gfx/platform_font.h" 11 #include "ui/gfx/platform_font.h"
12 12
13 class SkTypeface; 13 class SkTypeface;
14 class SkPaint; 14 class SkPaint;
15 15
16 namespace gfx { 16 namespace gfx {
17 17
18 class UI_EXPORT PlatformFontPango : public PlatformFont { 18 class UI_EXPORT PlatformFontPango : public PlatformFont {
19 public: 19 public:
20 PlatformFontPango(); 20 PlatformFontPango();
21 explicit PlatformFontPango(const Font& other); 21 explicit PlatformFontPango(const Font& other);
22 explicit PlatformFontPango(NativeFont native_font); 22 explicit PlatformFontPango(NativeFont native_font);
23 PlatformFontPango(const string16& font_name, int font_size); 23 PlatformFontPango(const std::string& font_name, int font_size);
24 24
25 // Converts |gfx_font| to a new pango font. Free the returned font with 25 // Converts |gfx_font| to a new pango font. Free the returned font with
26 // pango_font_description_free(). 26 // pango_font_description_free().
27 static PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font); 27 static PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font);
28 28
29 // Resets and reloads the cached system font used by the default constructor. 29 // Resets and reloads the cached system font used by the default constructor.
30 // This function is useful when the system font has changed, for example, when 30 // This function is useful when the system font has changed, for example, when
31 // the locale has changed. 31 // the locale has changed.
32 static void ReloadDefaultFont(); 32 static void ReloadDefaultFont();
33 33
34 // Position as an offset from the height of the drawn text, used to draw 34 // Position as an offset from the height of the drawn text, used to draw
35 // an underline. This is a negative number, so the underline would be 35 // an underline. This is a negative number, so the underline would be
36 // drawn at y + height + underline_position; 36 // drawn at y + height + underline_position;
37 double underline_position() const; 37 double underline_position() const;
38 // The thickness to draw the underline. 38 // The thickness to draw the underline.
39 double underline_thickness() const; 39 double underline_thickness() const;
40 40
41 // Overridden from PlatformFont: 41 // Overridden from PlatformFont:
42 virtual Font DeriveFont(int size_delta, int style) const; 42 virtual Font DeriveFont(int size_delta, int style) const;
43 virtual int GetHeight() const; 43 virtual int GetHeight() const;
44 virtual int GetBaseline() const; 44 virtual int GetBaseline() const;
45 virtual int GetAverageCharacterWidth() const; 45 virtual int GetAverageCharacterWidth() const;
46 virtual int GetStringWidth(const string16& text) const; 46 virtual int GetStringWidth(const string16& text) const;
47 virtual int GetExpectedTextWidth(int length) const; 47 virtual int GetExpectedTextWidth(int length) const;
48 virtual int GetStyle() const; 48 virtual int GetStyle() const;
49 virtual string16 GetFontName() const; 49 virtual std::string GetFontName() const;
50 virtual int GetFontSize() const; 50 virtual int GetFontSize() const;
51 virtual NativeFont GetNativeFont() const; 51 virtual NativeFont GetNativeFont() const;
52 52
53 private: 53 private:
54 // Create a new instance of this object with the specified properties. Called 54 // Create a new instance of this object with the specified properties. Called
55 // from DeriveFont. 55 // from DeriveFont.
56 PlatformFontPango(SkTypeface* typeface, 56 PlatformFontPango(SkTypeface* typeface,
57 const string16& name, 57 const std::string& name,
58 int size, 58 int size,
59 int style); 59 int style);
60 virtual ~PlatformFontPango(); 60 virtual ~PlatformFontPango();
61 61
62 // Initialize this object. 62 // Initialize this object.
63 void InitWithNameAndSize(const string16& font_name, int font_size); 63 void InitWithNameAndSize(const std::string& font_name, int font_size);
64 void InitWithTypefaceNameSizeAndStyle(SkTypeface* typeface, 64 void InitWithTypefaceNameSizeAndStyle(SkTypeface* typeface,
65 const string16& name, 65 const std::string& name,
66 int size, 66 int size,
67 int style); 67 int style);
68 void InitFromPlatformFont(const PlatformFontPango* other); 68 void InitFromPlatformFont(const PlatformFontPango* other);
69 69
70 // Potentially slow call to get pango metrics (average width, underline info). 70 // Potentially slow call to get pango metrics (average width, underline info).
71 void InitPangoMetrics(); 71 void InitPangoMetrics();
72 72
73 // Setup a Skia context to use the current typeface 73 // Setup a Skia context to use the current typeface
74 void PaintSetup(SkPaint* paint) const; 74 void PaintSetup(SkPaint* paint) const;
75 75
76 // Make |this| a copy of |other|. 76 // Make |this| a copy of |other|.
77 void CopyFont(const Font& other); 77 void CopyFont(const Font& other);
78 78
79 // The average width of a character, initialized and cached if needed. 79 // The average width of a character, initialized and cached if needed.
80 double GetAverageWidth() const; 80 double GetAverageWidth() const;
81 81
82 // These two both point to the same SkTypeface. We use the SkAutoUnref to 82 // These two both point to the same SkTypeface. We use the SkAutoUnref to
83 // handle the reference counting, but without @typeface_ we would have to 83 // handle the reference counting, but without @typeface_ we would have to
84 // cast the SkRefCnt from @typeface_helper_ every time. 84 // cast the SkRefCnt from @typeface_helper_ every time.
85 scoped_ptr<SkAutoUnref> typeface_helper_; 85 scoped_ptr<SkAutoUnref> typeface_helper_;
86 SkTypeface* typeface_; 86 SkTypeface* typeface_;
87 87
88 // Additional information about the face 88 // Additional information about the face
89 // Skia actually expects a family name and not a font name. 89 // Skia actually expects a family name and not a font name.
90 string16 font_family_; 90 std::string font_family_;
91 int font_size_pixels_; 91 int font_size_pixels_;
92 int style_; 92 int style_;
93 93
94 // Cached metrics, generated at construction 94 // Cached metrics, generated at construction
95 int height_pixels_; 95 int height_pixels_;
96 int ascent_pixels_; 96 int ascent_pixels_;
97 97
98 // The pango metrics are much more expensive so we wait until we need them 98 // The pango metrics are much more expensive so we wait until we need them
99 // to compute them. 99 // to compute them.
100 bool pango_metrics_inited_; 100 bool pango_metrics_inited_;
101 double average_width_pixels_; 101 double average_width_pixels_;
102 double underline_position_pixels_; 102 double underline_position_pixels_;
103 double underline_thickness_pixels_; 103 double underline_thickness_pixels_;
104 104
105 // The default font, used for the default constructor. 105 // The default font, used for the default constructor.
106 static Font* default_font_; 106 static Font* default_font_;
107 }; 107 };
108 108
109 } // namespace gfx 109 } // namespace gfx
110 110
111 #endif // UI_GFX_PLATFORM_FONT_PANGO_H_ 111 #endif // UI_GFX_PLATFORM_FONT_PANGO_H_
OLDNEW
« no previous file with comments | « ui/gfx/platform_font_mac.mm ('k') | ui/gfx/platform_font_pango.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698