Bug 1799258 - Fix constexpr issue on base toolchain builds. r=gfx-reviewers,lsalzman
[gecko.git] / gfx / thebes / gfxCoreTextShaper.h
blob1385bd00bb1273a3d84a7bf79e707f4a82832777
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
9 #include "gfxFont.h"
11 #include <ApplicationServices/ApplicationServices.h>
13 class gfxMacFont;
15 class gfxCoreTextShaper : public gfxFontShaper {
16 public:
17 explicit gfxCoreTextShaper(gfxMacFont* aFont);
19 virtual ~gfxCoreTextShaper();
21 bool ShapeText(DrawTarget* aDrawTarget, const char16_t* aText, uint32_t aOffset, uint32_t aLength,
22 Script aScript, nsAtom* aLanguage, bool aVertical, RoundingFlags aRounding,
23 gfxShapedText* aShapedText) override;
25 // clean up static objects that may have been cached
26 static void Shutdown();
28 // Flags used to track what AAT features should be enabled on the Core Text
29 // font instance. (Internal; only public so that we can use the
30 // MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS macro below.)
31 enum FeatureFlags : uint8_t {
32 kDefaultFeatures = 0x00,
33 // bit flags for non-default feature settings we might need
34 // to use, which will require separate font instances
35 kDisableLigatures = 0x01,
36 kAddSmallCaps = 0x02,
37 kIndicFeatures = 0x04,
39 // number of font instances, indexed by OR-ing the flags above
40 kMaxFontInstances = 8
43 protected:
44 CTFontRef mCTFont[kMaxFontInstances];
46 // attributes for shaping text with LTR or RTL directionality
47 CFDictionaryRef mAttributesDictLTR;
48 CFDictionaryRef mAttributesDictRTL;
50 nsresult SetGlyphsFromRun(gfxShapedText* aShapedText, uint32_t aOffset, uint32_t aLength,
51 CTRunRef aCTRun);
53 CTFontRef CreateCTFontWithFeatures(CGFloat aSize, CTFontDescriptorRef aDescriptor);
55 CFDictionaryRef CreateAttrDict(bool aRightToLeft);
56 CFDictionaryRef CreateAttrDictWithoutDirection();
58 static CTFontDescriptorRef CreateFontFeaturesDescriptor(
59 const std::pair<SInt16, SInt16>* aFeatures, size_t aCount);
61 static CTFontDescriptorRef GetFeaturesDescriptor(FeatureFlags aFeatureFlags);
63 // cached font descriptors, created the first time they're needed
64 static CTFontDescriptorRef sFeaturesDescriptor[kMaxFontInstances];
67 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(gfxCoreTextShaper::FeatureFlags)
69 #endif /* GFX_CORETEXTSHAPER_H */