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

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

Issue 2959913002: PlatformFontMac: Use a default NSFont when an invalid font is passed. (Closed)
Patch Set: Use a default font Created 3 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
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_MAC_H_ 5 #ifndef UI_GFX_PLATFORM_FONT_MAC_H_
6 #define UI_GFX_PLATFORM_FONT_MAC_H_ 6 #define UI_GFX_PLATFORM_FONT_MAC_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 int font_style, 48 int font_style,
49 Font::Weight font_weight); 49 Font::Weight font_weight);
50 50
51 ~PlatformFontMac() override; 51 ~PlatformFontMac() override;
52 52
53 // Calculates and caches the font metrics and inits |render_params_|. 53 // Calculates and caches the font metrics and inits |render_params_|.
54 void CalculateMetricsAndInitRenderParams(); 54 void CalculateMetricsAndInitRenderParams();
55 55
56 // The NSFont instance for this object. If this object was constructed from an 56 // The NSFont instance for this object. If this object was constructed from an
57 // NSFont instance, this holds that NSFont instance. Otherwise this NSFont 57 // NSFont instance, this holds that NSFont instance. Otherwise this NSFont
58 // instance is constructed from the name, size, and style, and if there is no 58 // instance is constructed from the name, size, and style. If there is no
59 // active font that matched those criteria, this object may be nil. 59 // active font that matched those criteria a default font is used.
60 base::scoped_nsobject<NSFont> native_font_; 60 base::scoped_nsobject<NSFont> native_font_;
61 61
62 // The name/size/style trio that specify the font. Initialized in the 62 // The name/size/style trio that specify the font. Initialized in the
63 // constructors. 63 // constructors.
64 const std::string font_name_; // Corresponds to -[NSFont fontFamily]. 64 const std::string font_name_; // Corresponds to -[NSFont fontFamily].
65 const int font_size_; 65 const int font_size_;
66 const int font_style_; 66 const int font_style_;
67 const Font::Weight font_weight_; 67 const Font::Weight font_weight_;
68 68
69 // Cached metrics, generated in CalculateMetrics(). 69 // Cached metrics, generated in CalculateMetrics().
70 int height_; 70 int height_;
71 int ascent_; 71 int ascent_;
72 int cap_height_; 72 int cap_height_;
73 73
74 // Cached average width, generated in GetExpectedTextWidth(). 74 // Cached average width, generated in GetExpectedTextWidth().
75 float average_width_ = 0.0; 75 float average_width_ = 0.0;
76 76
77 // Details about how the font should be rendered. 77 // Details about how the font should be rendered.
78 FontRenderParams render_params_; 78 FontRenderParams render_params_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(PlatformFontMac); 80 DISALLOW_COPY_AND_ASSIGN(PlatformFontMac);
81 }; 81 };
82 82
83 } // namespace gfx 83 } // namespace gfx
84 84
85 #endif // UI_GFX_PLATFORM_FONT_MAC_H_ 85 #endif // UI_GFX_PLATFORM_FONT_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698