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

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

Issue 509093004: linux: Make RenderTextPango avoid clipping underlines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | ui/gfx/platform_font_pango.cc » ('j') | ui/gfx/render_text_pango.cc » ('J')
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 #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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 22 matching lines...) Expand all
33 // This function is useful when the system font has changed, for example, when 33 // This function is useful when the system font has changed, for example, when
34 // the locale has changed. 34 // the locale has changed.
35 static void ReloadDefaultFont(); 35 static void ReloadDefaultFont();
36 36
37 #if defined(OS_CHROMEOS) 37 #if defined(OS_CHROMEOS)
38 // Sets the default font. |font_description| is a Pango font description that 38 // Sets the default font. |font_description| is a Pango font description that
39 // will be passed to pango_font_description_from_string(). 39 // will be passed to pango_font_description_from_string().
40 static void SetDefaultFontDescription(const std::string& font_description); 40 static void SetDefaultFontDescription(const std::string& font_description);
41 #endif 41 #endif
42 42
43 // Position as an offset from the height of the drawn text, used to draw
44 // an underline. This is a negative number, so the underline would be
45 // drawn at y + height + underline_position.
46 double underline_position() const;
47 // The thickness to draw the underline.
48 double underline_thickness() const;
49
50 // Overridden from PlatformFont: 43 // Overridden from PlatformFont:
51 virtual Font DeriveFont(int size_delta, int style) const OVERRIDE; 44 virtual Font DeriveFont(int size_delta, int style) const OVERRIDE;
52 virtual int GetHeight() const OVERRIDE; 45 virtual int GetHeight() const OVERRIDE;
53 virtual int GetBaseline() const OVERRIDE; 46 virtual int GetBaseline() const OVERRIDE;
54 virtual int GetCapHeight() const OVERRIDE; 47 virtual int GetCapHeight() const OVERRIDE;
55 virtual int GetExpectedTextWidth(int length) const OVERRIDE; 48 virtual int GetExpectedTextWidth(int length) const OVERRIDE;
56 virtual int GetStyle() const OVERRIDE; 49 virtual int GetStyle() const OVERRIDE;
57 virtual std::string GetFontName() const OVERRIDE; 50 virtual std::string GetFontName() const OVERRIDE;
58 virtual std::string GetActualFontNameForTesting() const OVERRIDE; 51 virtual std::string GetActualFontNameForTesting() const OVERRIDE;
59 virtual int GetFontSize() const OVERRIDE; 52 virtual int GetFontSize() const OVERRIDE;
(...skipping 15 matching lines...) Expand all
75 void InitFromDetails( 68 void InitFromDetails(
76 const skia::RefPtr<SkTypeface>& typeface, 69 const skia::RefPtr<SkTypeface>& typeface,
77 const std::string& font_family, 70 const std::string& font_family,
78 int font_size_pixels, 71 int font_size_pixels,
79 int style, 72 int style,
80 const FontRenderParams& params); 73 const FontRenderParams& params);
81 74
82 // Initializes this object as a copy of another PlatformFontPango. 75 // Initializes this object as a copy of another PlatformFontPango.
83 void InitFromPlatformFont(const PlatformFontPango* other); 76 void InitFromPlatformFont(const PlatformFontPango* other);
84 77
85 // Potentially slow call to get pango metrics (average width, underline info). 78 // Potentially slow call to get pango metrics (average width).
86 void InitPangoMetrics(); 79 void InitPangoMetrics();
87 80
88 // Setup a Skia context to use the current typeface. 81 // Setup a Skia context to use the current typeface.
89 void PaintSetup(SkPaint* paint) const; 82 void PaintSetup(SkPaint* paint) const;
90 83
91 // Make |this| a copy of |other|. 84 // Make |this| a copy of |other|.
92 void CopyFont(const Font& other); 85 void CopyFont(const Font& other);
93 86
94 // The average width of a character, initialized and cached if needed. 87 // The average width of a character, initialized and cached if needed.
95 double GetAverageWidth() const; 88 double GetAverageWidth() const;
(...skipping 11 matching lines...) Expand all
107 100
108 // Cached metrics, generated at construction. 101 // Cached metrics, generated at construction.
109 int ascent_pixels_; 102 int ascent_pixels_;
110 int height_pixels_; 103 int height_pixels_;
111 int cap_height_pixels_; 104 int cap_height_pixels_;
112 105
113 // The pango metrics are much more expensive so we wait until we need them 106 // The pango metrics are much more expensive so we wait until we need them
114 // to compute them. 107 // to compute them.
115 bool pango_metrics_inited_; 108 bool pango_metrics_inited_;
116 double average_width_pixels_; 109 double average_width_pixels_;
117 double underline_position_pixels_;
118 double underline_thickness_pixels_;
119 110
120 // The default font, used for the default constructor. 111 // The default font, used for the default constructor.
121 static Font* default_font_; 112 static Font* default_font_;
122 113
123 #if defined(OS_CHROMEOS) 114 #if defined(OS_CHROMEOS)
124 // A Pango font description. 115 // A Pango font description.
125 static std::string* default_font_description_; 116 static std::string* default_font_description_;
126 #endif 117 #endif
127 118
128 DISALLOW_COPY_AND_ASSIGN(PlatformFontPango); 119 DISALLOW_COPY_AND_ASSIGN(PlatformFontPango);
129 }; 120 };
130 121
131 } // namespace gfx 122 } // namespace gfx
132 123
133 #endif // UI_GFX_PLATFORM_FONT_PANGO_H_ 124 #endif // UI_GFX_PLATFORM_FONT_PANGO_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/platform_font_pango.cc » ('j') | ui/gfx/render_text_pango.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698