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/. */
6 #ifndef GFX_CORETEXTSHAPER_H
7 #define GFX_CORETEXTSHAPER_H
11 #include <CoreText/CoreText.h>
15 class gfxCoreTextShaper
: public gfxFontShaper
{
17 explicit gfxCoreTextShaper(gfxMacFont
* aFont
);
19 virtual ~gfxCoreTextShaper();
21 bool ShapeText(DrawTarget
* aDrawTarget
, const char16_t
* aText
,
22 uint32_t aOffset
, uint32_t aLength
, Script aScript
,
23 nsAtom
* aLanguage
, bool aVertical
, RoundingFlags aRounding
,
24 gfxShapedText
* aShapedText
) override
;
26 // clean up static objects that may have been cached
27 static void Shutdown();
29 // Flags used to track what AAT features should be enabled on the Core Text
30 // font instance. (Internal; only public so that we can use the
31 // MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS macro below.)
32 enum FeatureFlags
: uint8_t {
33 kDefaultFeatures
= 0x00,
34 // bit flags for non-default feature settings we might need
35 // to use, which will require separate font instances
36 kDisableLigatures
= 0x01,
38 kIndicFeatures
= 0x04,
40 // number of font instances, indexed by OR-ing the flags above
45 CTFontRef mCTFont
[kMaxFontInstances
];
47 // attributes for shaping text with LTR or RTL directionality
48 CFDictionaryRef mAttributesDictLTR
;
49 CFDictionaryRef mAttributesDictRTL
;
51 nsresult
SetGlyphsFromRun(gfxShapedText
* aShapedText
, uint32_t aOffset
,
52 uint32_t aLength
, CTRunRef aCTRun
);
54 CTFontRef
CreateCTFontWithFeatures(CGFloat aSize
,
55 CTFontDescriptorRef aDescriptor
);
57 CFDictionaryRef
CreateAttrDict(bool aRightToLeft
);
58 CFDictionaryRef
CreateAttrDictWithoutDirection();
60 static CTFontDescriptorRef
CreateFontFeaturesDescriptor(
61 const std::pair
<SInt16
, SInt16
>* aFeatures
, size_t aCount
);
63 static CTFontDescriptorRef
GetFeaturesDescriptor(FeatureFlags aFeatureFlags
);
65 // cached font descriptors, created the first time they're needed
66 static CTFontDescriptorRef sFeaturesDescriptor
[kMaxFontInstances
];
69 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(gfxCoreTextShaper::FeatureFlags
)
71 #endif /* GFX_CORETEXTSHAPER_H */