michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_CORETEXTSHAPER_H michael@0: #define GFX_CORETEXTSHAPER_H michael@0: michael@0: #include "gfxFont.h" michael@0: michael@0: #include michael@0: michael@0: class gfxMacFont; michael@0: michael@0: class gfxCoreTextShaper : public gfxFontShaper { michael@0: public: michael@0: gfxCoreTextShaper(gfxMacFont *aFont); michael@0: michael@0: virtual ~gfxCoreTextShaper(); michael@0: michael@0: virtual bool ShapeText(gfxContext *aContext, michael@0: const char16_t *aText, michael@0: uint32_t aOffset, michael@0: uint32_t aLength, michael@0: int32_t aScript, michael@0: gfxShapedText *aShapedText); michael@0: michael@0: // clean up static objects that may have been cached michael@0: static void Shutdown(); michael@0: michael@0: protected: michael@0: CTFontRef mCTFont; michael@0: CFDictionaryRef mAttributesDict; michael@0: michael@0: nsresult SetGlyphsFromRun(gfxShapedText *aShapedText, michael@0: uint32_t aOffset, michael@0: uint32_t aLength, michael@0: CTRunRef aCTRun, michael@0: int32_t aStringOffset); michael@0: michael@0: CTFontRef CreateCTFontWithDisabledLigatures(CGFloat aSize); michael@0: michael@0: static void CreateDefaultFeaturesDescriptor(); michael@0: michael@0: static CTFontDescriptorRef GetDefaultFeaturesDescriptor() { michael@0: if (sDefaultFeaturesDescriptor == nullptr) { michael@0: CreateDefaultFeaturesDescriptor(); michael@0: } michael@0: return sDefaultFeaturesDescriptor; michael@0: } michael@0: michael@0: // cached font descriptor, created the first time it's needed michael@0: static CTFontDescriptorRef sDefaultFeaturesDescriptor; michael@0: michael@0: // cached descriptor for adding disable-ligatures setting to a font michael@0: static CTFontDescriptorRef sDisableLigaturesDescriptor; michael@0: }; michael@0: michael@0: #endif /* GFX_CORETEXTSHAPER_H */