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 explicit gfxCoreTextShaper(gfxMacFont *aFont); 18 19 virtual ~gfxCoreTextShaper(); 20 21 bool ShapeText(DrawTarget *aDrawTarget, const char16_t *aText, 22 uint32_t aOffset, uint32_t aLength, Script aScript, 23 bool aVertical, RoundingFlags aRounding, 24 gfxShapedText *aShapedText) override; 25 26 // clean up static objects that may have been cached 27 static void Shutdown(); 28 29 protected: 30 CTFontRef mCTFont; 31 32 // attributes for shaping text with LTR or RTL directionality 33 CFDictionaryRef mAttributesDictLTR; 34 CFDictionaryRef mAttributesDictRTL; 35 36 nsresult SetGlyphsFromRun(gfxShapedText *aShapedText, uint32_t aOffset, 37 uint32_t aLength, CTRunRef aCTRun); 38 39 CTFontRef CreateCTFontWithFeatures(CGFloat aSize, 40 CTFontDescriptorRef aDescriptor); 41 42 CFDictionaryRef CreateAttrDict(bool aRightToLeft); 43 CFDictionaryRef CreateAttrDictWithoutDirection(); 44 45 static CTFontDescriptorRef CreateFontFeaturesDescriptor( 46 const std::pair<SInt16, SInt16> aFeatures[], size_t aCount); 47 48 static CTFontDescriptorRef GetDefaultFeaturesDescriptor(); 49 static CTFontDescriptorRef GetSmallCapsDescriptor(); 50 static CTFontDescriptorRef GetDisableLigaturesDescriptor(); 51 static CTFontDescriptorRef GetSmallCapDisableLigDescriptor(); 52 static CTFontDescriptorRef GetIndicFeaturesDescriptor(); 53 static CTFontDescriptorRef GetIndicDisableLigaturesDescriptor(); 54 55 // cached font descriptor, created the first time it's needed 56 static CTFontDescriptorRef sDefaultFeaturesDescriptor; 57 static CTFontDescriptorRef sSmallCapsDescriptor; 58 59 // cached descriptor for adding disable-ligatures setting to a font 60 static CTFontDescriptorRef sDisableLigaturesDescriptor; 61 static CTFontDescriptorRef sSmallCapDisableLigDescriptor; 62 63 // feature descriptors for buggy Indic AAT font workaround 64 static CTFontDescriptorRef sIndicFeaturesDescriptor; 65 static CTFontDescriptorRef sIndicDisableLigaturesDescriptor; 66 }; 67 68 #endif /* GFX_CORETEXTSHAPER_H */ 69