Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef GFX_CORETEXTSHAPER_H |
michael@0 | 7 | #define GFX_CORETEXTSHAPER_H |
michael@0 | 8 | |
michael@0 | 9 | #include "gfxFont.h" |
michael@0 | 10 | |
michael@0 | 11 | #include <ApplicationServices/ApplicationServices.h> |
michael@0 | 12 | |
michael@0 | 13 | class gfxMacFont; |
michael@0 | 14 | |
michael@0 | 15 | class gfxCoreTextShaper : public gfxFontShaper { |
michael@0 | 16 | public: |
michael@0 | 17 | gfxCoreTextShaper(gfxMacFont *aFont); |
michael@0 | 18 | |
michael@0 | 19 | virtual ~gfxCoreTextShaper(); |
michael@0 | 20 | |
michael@0 | 21 | virtual bool ShapeText(gfxContext *aContext, |
michael@0 | 22 | const char16_t *aText, |
michael@0 | 23 | uint32_t aOffset, |
michael@0 | 24 | uint32_t aLength, |
michael@0 | 25 | int32_t aScript, |
michael@0 | 26 | gfxShapedText *aShapedText); |
michael@0 | 27 | |
michael@0 | 28 | // clean up static objects that may have been cached |
michael@0 | 29 | static void Shutdown(); |
michael@0 | 30 | |
michael@0 | 31 | protected: |
michael@0 | 32 | CTFontRef mCTFont; |
michael@0 | 33 | CFDictionaryRef mAttributesDict; |
michael@0 | 34 | |
michael@0 | 35 | nsresult SetGlyphsFromRun(gfxShapedText *aShapedText, |
michael@0 | 36 | uint32_t aOffset, |
michael@0 | 37 | uint32_t aLength, |
michael@0 | 38 | CTRunRef aCTRun, |
michael@0 | 39 | int32_t aStringOffset); |
michael@0 | 40 | |
michael@0 | 41 | CTFontRef CreateCTFontWithDisabledLigatures(CGFloat aSize); |
michael@0 | 42 | |
michael@0 | 43 | static void CreateDefaultFeaturesDescriptor(); |
michael@0 | 44 | |
michael@0 | 45 | static CTFontDescriptorRef GetDefaultFeaturesDescriptor() { |
michael@0 | 46 | if (sDefaultFeaturesDescriptor == nullptr) { |
michael@0 | 47 | CreateDefaultFeaturesDescriptor(); |
michael@0 | 48 | } |
michael@0 | 49 | return sDefaultFeaturesDescriptor; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | // cached font descriptor, created the first time it's needed |
michael@0 | 53 | static CTFontDescriptorRef sDefaultFeaturesDescriptor; |
michael@0 | 54 | |
michael@0 | 55 | // cached descriptor for adding disable-ligatures setting to a font |
michael@0 | 56 | static CTFontDescriptorRef sDisableLigaturesDescriptor; |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | #endif /* GFX_CORETEXTSHAPER_H */ |