mojo: Fix map of booleans for python bindings.
[chromium-blink-merge.git] / ui / gfx / platform_font_mac.h
blob05c124901ab7ecab356614f0a246eba08a0b3099
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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_PLATFORM_FONT_MAC_H_
6 #define UI_GFX_PLATFORM_FONT_MAC_H_
8 #include "base/compiler_specific.h"
9 #include "base/mac/scoped_nsobject.h"
10 #include "ui/gfx/platform_font.h"
12 namespace gfx {
14 class PlatformFontMac : public PlatformFont {
15 public:
16 PlatformFontMac();
17 explicit PlatformFontMac(NativeFont native_font);
18 PlatformFontMac(const std::string& font_name,
19 int font_size);
21 // Overridden from PlatformFont:
22 virtual Font DeriveFont(int size_delta, int style) const override;
23 virtual int GetHeight() const override;
24 virtual int GetBaseline() const override;
25 virtual int GetCapHeight() const override;
26 virtual int GetExpectedTextWidth(int length) const override;
27 virtual int GetStyle() const override;
28 virtual std::string GetFontName() const override;
29 virtual std::string GetActualFontNameForTesting() const override;
30 virtual int GetFontSize() const override;
31 virtual const FontRenderParams& GetFontRenderParams() const override;
32 virtual NativeFont GetNativeFont() const override;
34 private:
35 PlatformFontMac(const std::string& font_name, int font_size, int font_style);
36 virtual ~PlatformFontMac();
38 // Calculates and caches the font metrics.
39 void CalculateMetrics();
41 // The NSFont instance for this object. If this object was constructed from an
42 // NSFont instance, this holds that NSFont instance. Otherwise this NSFont
43 // instance is constructed from the name, size, and style, and if there is no
44 // active font that matched those criteria, this object may be nil.
45 base::scoped_nsobject<NSFont> native_font_;
47 // The name/size/style trio that specify the font. Initialized in the
48 // constructors.
49 std::string font_name_; // Corresponds to -[NSFont fontFamily].
50 int font_size_;
51 int font_style_;
53 // Cached metrics, generated in CalculateMetrics().
54 int height_;
55 int ascent_;
56 int cap_height_;
57 int average_width_;
59 DISALLOW_COPY_AND_ASSIGN(PlatformFontMac);
62 } // namespace gfx
64 #endif // UI_GFX_PLATFORM_FONT_MAC_H_