|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef MOZILLA_GFX_SCALEDFONTMAC_H_ |
|
7 #define MOZILLA_GFX_SCALEDFONTMAC_H_ |
|
8 |
|
9 #import <ApplicationServices/ApplicationServices.h> |
|
10 #include "2D.h" |
|
11 |
|
12 #include "ScaledFontBase.h" |
|
13 |
|
14 namespace mozilla { |
|
15 namespace gfx { |
|
16 |
|
17 class ScaledFontMac : public ScaledFontBase |
|
18 { |
|
19 public: |
|
20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontMac) |
|
21 ScaledFontMac(CGFontRef aFont, Float aSize); |
|
22 virtual ~ScaledFontMac(); |
|
23 |
|
24 virtual FontType GetType() const { return FontType::MAC; } |
|
25 #ifdef USE_SKIA |
|
26 virtual SkTypeface* GetSkTypeface(); |
|
27 #endif |
|
28 virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget); |
|
29 virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint); |
|
30 virtual bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton); |
|
31 |
|
32 private: |
|
33 friend class DrawTargetCG; |
|
34 CGFontRef mFont; |
|
35 CTFontRef mCTFont; // only created if CTFontDrawGlyphs is available, otherwise null |
|
36 |
|
37 typedef void (CTFontDrawGlyphsFuncT)(CTFontRef, |
|
38 const CGGlyph[], const CGPoint[], |
|
39 size_t, CGContextRef); |
|
40 |
|
41 static bool sSymbolLookupDone; |
|
42 |
|
43 public: |
|
44 // function pointer for CTFontDrawGlyphs, if available; |
|
45 // initialized the first time a ScaledFontMac is created, |
|
46 // so it will be valid by the time DrawTargetCG wants to use it |
|
47 static CTFontDrawGlyphsFuncT* CTFontDrawGlyphsPtr; |
|
48 }; |
|
49 |
|
50 } |
|
51 } |
|
52 |
|
53 #endif /* MOZILLA_GFX_SCALEDFONTMAC_H_ */ |