NativeFontResourceGDI.h (1592B)
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_NativeFontResourceGDI_h 8 #define mozilla_gfx_NativeFontResourceGDI_h 9 10 #include <windows.h> 11 12 #include "2D.h" 13 #include "mozilla/AlreadyAddRefed.h" 14 15 namespace mozilla { 16 namespace gfx { 17 18 class NativeFontResourceGDI final : public NativeFontResource { 19 public: 20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(NativeFontResourceGDI, override) 21 22 /** 23 * Creates a NativeFontResourceGDI 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 NativeFontResourceGDI or nullptr if invalid. 29 */ 30 static already_AddRefed<NativeFontResourceGDI> Create( 31 const uint8_t* aFontData, uint32_t aDataLength); 32 33 virtual ~NativeFontResourceGDI(); 34 35 already_AddRefed<UnscaledFont> CreateUnscaledFont( 36 uint32_t aIndex, const uint8_t* aInstanceData, 37 uint32_t aInstanceDataLength) final; 38 39 private: 40 explicit NativeFontResourceGDI(HANDLE aFontResourceHandle, size_t aDataLength) 41 : NativeFontResource(aDataLength), 42 mFontResourceHandle(aFontResourceHandle) {} 43 44 HANDLE mFontResourceHandle; 45 }; 46 47 } // namespace gfx 48 } // namespace mozilla 49 50 #endif // mozilla_gfx_NativeFontResourceGDI_h