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

Side by Side Diff: app/gfx/font.h

Issue 199105: Continue with the FreeBSD port - this version builds and links, though... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « app/gfx/canvas.h ('k') | app/gfx/path.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 APP_GFX_FONT_H_ 5 #ifndef APP_GFX_FONT_H_
6 #define APP_GFX_FONT_H_ 6 #define APP_GFX_FONT_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include <string> 10 #include <string>
11 11
12 #if defined(OS_WIN) 12 #if defined(OS_WIN)
13 typedef struct HFONT__* HFONT; 13 typedef struct HFONT__* HFONT;
14 #elif defined(OS_LINUX) 14 #elif defined(USE_X11)
15 #include "third_party/skia/include/core/SkRefCnt.h" 15 #include "third_party/skia/include/core/SkRefCnt.h"
16 class SkPaint; 16 class SkPaint;
17 class SkTypeface; 17 class SkTypeface;
18 #endif 18 #endif
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 typedef struct HFONT__* NativeFont; 21 typedef struct HFONT__* NativeFont;
22 #elif defined(OS_MACOSX) 22 #elif defined(OS_MACOSX)
23 #ifdef __OBJC__ 23 #ifdef __OBJC__
24 @class NSFont; 24 @class NSFont;
25 #else 25 #else
26 class NSFont; 26 class NSFont;
27 #endif 27 #endif
28 typedef NSFont* NativeFont; 28 typedef NSFont* NativeFont;
29 #elif defined(OS_LINUX) 29 #elif defined(USE_X11)
30 typedef struct _PangoFontDescription PangoFontDescription; 30 typedef struct _PangoFontDescription PangoFontDescription;
31 class SkTypeface; 31 class SkTypeface;
32 typedef SkTypeface* NativeFont; 32 typedef SkTypeface* NativeFont;
33 #else // null port. 33 #else // null port.
34 #error No known OS defined 34 #error No known OS defined
35 #endif 35 #endif
36 36
37 #include "base/basictypes.h" 37 #include "base/basictypes.h"
38 #include "base/ref_counted.h" 38 #include "base/ref_counted.h"
39 #include "base/scoped_ptr.h" 39 #include "base/scoped_ptr.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 HFONT hfont() const { return font_ref_->hfont(); } 117 HFONT hfont() const { return font_ref_->hfont(); }
118 118
119 // Dialog units to pixels conversion. 119 // Dialog units to pixels conversion.
120 // See http://support.microsoft.com/kb/145994 for details. 120 // See http://support.microsoft.com/kb/145994 for details.
121 int horizontal_dlus_to_pixels(int dlus) { 121 int horizontal_dlus_to_pixels(int dlus) {
122 return dlus * font_ref_->dlu_base_x() / 4; 122 return dlus * font_ref_->dlu_base_x() / 4;
123 } 123 }
124 int vertical_dlus_to_pixels(int dlus) { 124 int vertical_dlus_to_pixels(int dlus) {
125 return dlus * font_ref_->height() / 8; 125 return dlus * font_ref_->height() / 8;
126 } 126 }
127 #elif defined(OS_LINUX) 127 #elif defined(USE_X11)
128 static Font CreateFont(PangoFontDescription* desc); 128 static Font CreateFont(PangoFontDescription* desc);
129 // We need a copy constructor and assignment operator to deal with 129 // We need a copy constructor and assignment operator to deal with
130 // the Skia reference counting. 130 // the Skia reference counting.
131 Font(const Font& other); 131 Font(const Font& other);
132 Font& operator=(const Font& other); 132 Font& operator=(const Font& other);
133 // Setup a Skia context to use the current typeface 133 // Setup a Skia context to use the current typeface
134 void PaintSetup(SkPaint* paint) const; 134 void PaintSetup(SkPaint* paint) const;
135 135
136 // Converts |gfx_font| to a new pango font. Free the returned font with 136 // Converts |gfx_font| to a new pango font. Free the returned font with
137 // pango_font_description_free(). 137 // pango_font_description_free().
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Creates and returns a new HFONTRef from the specified HFONT. 188 // Creates and returns a new HFONTRef from the specified HFONT.
189 static HFontRef* CreateHFontRef(HFONT font); 189 static HFontRef* CreateHFontRef(HFONT font);
190 190
191 explicit Font(HFontRef* font_ref) : font_ref_(font_ref) { } 191 explicit Font(HFontRef* font_ref) : font_ref_(font_ref) { }
192 192
193 // Reference to the base font all fonts are derived from. 193 // Reference to the base font all fonts are derived from.
194 static HFontRef* base_font_ref_; 194 static HFontRef* base_font_ref_;
195 195
196 // Indirect reference to the HFontRef, which references the underlying HFONT. 196 // Indirect reference to the HFontRef, which references the underlying HFONT.
197 scoped_refptr<HFontRef> font_ref_; 197 scoped_refptr<HFontRef> font_ref_;
198 #elif defined(OS_LINUX) 198 #elif defined(USE_X11)
199 explicit Font(SkTypeface* typeface, const std::wstring& name, 199 explicit Font(SkTypeface* typeface, const std::wstring& name,
200 int size, int style); 200 int size, int style);
201 // Calculate and cache the font metrics. 201 // Calculate and cache the font metrics.
202 void calculateMetrics(); 202 void calculateMetrics();
203 // Make |this| a copy of |other|. 203 // Make |this| a copy of |other|.
204 void CopyFont(const Font& other); 204 void CopyFont(const Font& other);
205 205
206 // The default font, used for the default constructor. 206 // The default font, used for the default constructor.
207 static Font* default_font_; 207 static Font* default_font_;
208 208
(...skipping 27 matching lines...) Expand all
236 int height_; 236 int height_;
237 int ascent_; 237 int ascent_;
238 int avg_width_; 238 int avg_width_;
239 #endif 239 #endif
240 240
241 }; 241 };
242 242
243 } // namespace gfx 243 } // namespace gfx
244 244
245 #endif // APP_GFX_FONT_H_ 245 #endif // APP_GFX_FONT_H_
OLDNEW
« no previous file with comments | « app/gfx/canvas.h ('k') | app/gfx/path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698