|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
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 GFX_CORETEXTSHAPER_H |
|
7 #define GFX_CORETEXTSHAPER_H |
|
8 |
|
9 #include "gfxFont.h" |
|
10 |
|
11 #include <ApplicationServices/ApplicationServices.h> |
|
12 |
|
13 class gfxMacFont; |
|
14 |
|
15 class gfxCoreTextShaper : public gfxFontShaper { |
|
16 public: |
|
17 gfxCoreTextShaper(gfxMacFont *aFont); |
|
18 |
|
19 virtual ~gfxCoreTextShaper(); |
|
20 |
|
21 virtual bool ShapeText(gfxContext *aContext, |
|
22 const char16_t *aText, |
|
23 uint32_t aOffset, |
|
24 uint32_t aLength, |
|
25 int32_t aScript, |
|
26 gfxShapedText *aShapedText); |
|
27 |
|
28 // clean up static objects that may have been cached |
|
29 static void Shutdown(); |
|
30 |
|
31 protected: |
|
32 CTFontRef mCTFont; |
|
33 CFDictionaryRef mAttributesDict; |
|
34 |
|
35 nsresult SetGlyphsFromRun(gfxShapedText *aShapedText, |
|
36 uint32_t aOffset, |
|
37 uint32_t aLength, |
|
38 CTRunRef aCTRun, |
|
39 int32_t aStringOffset); |
|
40 |
|
41 CTFontRef CreateCTFontWithDisabledLigatures(CGFloat aSize); |
|
42 |
|
43 static void CreateDefaultFeaturesDescriptor(); |
|
44 |
|
45 static CTFontDescriptorRef GetDefaultFeaturesDescriptor() { |
|
46 if (sDefaultFeaturesDescriptor == nullptr) { |
|
47 CreateDefaultFeaturesDescriptor(); |
|
48 } |
|
49 return sDefaultFeaturesDescriptor; |
|
50 } |
|
51 |
|
52 // cached font descriptor, created the first time it's needed |
|
53 static CTFontDescriptorRef sDefaultFeaturesDescriptor; |
|
54 |
|
55 // cached descriptor for adding disable-ligatures setting to a font |
|
56 static CTFontDescriptorRef sDisableLigaturesDescriptor; |
|
57 }; |
|
58 |
|
59 #endif /* GFX_CORETEXTSHAPER_H */ |