NativeFontResourceMac.h (1487B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_gfx_NativeFontResourceMac_h 8 #define mozilla_gfx_NativeFontResourceMac_h 9 10 #include "2D.h" 11 #include "mozilla/AlreadyAddRefed.h" 12 #include "ScaledFontMac.h" 13 14 namespace mozilla { 15 namespace gfx { 16 17 class NativeFontResourceMac final : public NativeFontResource { 18 public: 19 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(NativeFontResourceMac, override) 20 21 static already_AddRefed<NativeFontResourceMac> Create( 22 const uint8_t* aFontData, uint32_t aDataLength); 23 24 already_AddRefed<UnscaledFont> CreateUnscaledFont( 25 uint32_t aIndex, const uint8_t* aInstanceData, 26 uint32_t aInstanceDataLength) final; 27 28 ~NativeFontResourceMac() { 29 CFRelease(mFontDescRef); 30 CFRelease(mFontRef); 31 } 32 33 static void RegisterMemoryReporter(); 34 35 private: 36 explicit NativeFontResourceMac(CTFontDescriptorRef aFontDescRef, 37 CGFontRef aFontRef, size_t aDataLength) 38 : NativeFontResource(aDataLength), 39 mFontDescRef(aFontDescRef), 40 mFontRef(aFontRef) {} 41 42 CTFontDescriptorRef mFontDescRef; 43 CGFontRef mFontRef; 44 }; 45 46 } // namespace gfx 47 } // namespace mozilla 48 49 #endif // mozilla_gfx_NativeFontResourceMac_h