ASPiK SDK
cfontmac.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __cfontmac__
6 #define __cfontmac__
7 
8 #include "../iplatformfont.h"
9 
10 #if MAC
11 #include "../../ccolor.h"
12 
13 #if TARGET_OS_IPHONE
14  #include <CoreText/CoreText.h>
15 #else
16  #include <ApplicationServices/ApplicationServices.h>
17 #endif
18 
19 namespace VSTGUI {
20 class MacString;
21 
22 //-----------------------------------------------------------------------------
23 class CoreTextFont : public IPlatformFont, public IFontPainter
24 {
25 public:
26  CoreTextFont (const UTF8String& name, const CCoord& size, const int32_t& style);
27 
28  double getAscent () const override;
29  double getDescent () const override;
30  double getLeading () const override;
31  double getCapHeight () const override;
32 
33  const IFontPainter* getPainter () const override { return this; }
34 
35  CTFontRef getFontRef () const { return fontRef; }
36  CGFloat getSize () const { return CTFontGetSize (fontRef); }
37 
38 //------------------------------------------------------------------------------------
39 protected:
40  ~CoreTextFont () noexcept override;
41 
42  void drawString (CDrawContext* context, IPlatformString* string, const CPoint& p, bool antialias = true) const override;
43  CCoord getStringWidth (CDrawContext* context, IPlatformString* string, bool antialias = true) const override;
44  CFDictionaryRef getStringAttributes (const CGColorRef color = nullptr) const;
45 
46  CTLineRef createCTLine (CDrawContext* context, MacString* macString) const;
47 
48  CTFontRef fontRef;
49  int32_t style;
50  bool underlineStyle;
51  mutable CColor lastColor;
52  mutable CFMutableDictionaryRef stringAttributes;
53  double ascent;
54  double descent;
55  double leading;
56  double capHeight;
57 };
58 
59 } // namespace
60 
61 #endif // MAC
62 
63 #endif
Definition: customcontrols.cpp:8