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_NativeFontResourceDWrite_h 8 #define mozilla_gfx_NativeFontResourceDWrite_h 9 10 #include <dwrite.h> 11 12 #include "2D.h" 13 #include "mozilla/AlreadyAddRefed.h" 14 15 namespace mozilla { 16 namespace gfx { 17 18 class NativeFontResourceDWrite final : public NativeFontResource { 19 public: 20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(NativeFontResourceDWrite, override) 21 22 /** 23 * Creates a NativeFontResourceDWrite if data is valid. Note aFontData will be 24 * copied if required and so can be released after calling. 25 * 26 * @param aFontData the SFNT data. 27 * @param aDataLength length of data. 28 * @return Referenced NativeFontResourceDWrite or nullptr if invalid. 29 */ 30 static already_AddRefed<NativeFontResourceDWrite> Create( 31 uint8_t* aFontData, uint32_t aDataLength); 32 33 already_AddRefed<UnscaledFont> CreateUnscaledFont( 34 uint32_t aIndex, const uint8_t* aInstanceData, 35 uint32_t aInstanceDataLength) final; 36 37 private: NativeFontResourceDWrite(IDWriteFactory * aFactory,already_AddRefed<IDWriteFontFile> aFontFile,already_AddRefed<IDWriteFontFileStream> aFontFileStream,DWRITE_FONT_FACE_TYPE aFaceType,uint32_t aNumberOfFaces,size_t aDataLength)38 NativeFontResourceDWrite( 39 IDWriteFactory* aFactory, already_AddRefed<IDWriteFontFile> aFontFile, 40 already_AddRefed<IDWriteFontFileStream> aFontFileStream, 41 DWRITE_FONT_FACE_TYPE aFaceType, uint32_t aNumberOfFaces, 42 size_t aDataLength) 43 : NativeFontResource(aDataLength), 44 mFactory(aFactory), 45 mFontFile(aFontFile), 46 mFontFileStream(aFontFileStream), 47 mFaceType(aFaceType), 48 mNumberOfFaces(aNumberOfFaces) {} 49 50 IDWriteFactory* mFactory; 51 RefPtr<IDWriteFontFile> mFontFile; 52 RefPtr<IDWriteFontFileStream> mFontFileStream; 53 DWRITE_FONT_FACE_TYPE mFaceType; 54 uint32_t mNumberOfFaces; 55 }; 56 57 } // namespace gfx 58 } // namespace mozilla 59 60 #endif // mozilla_gfx_NativeFontResourceDWrite_h 61