UnscaledFontDWrite.h (2077B)
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_UNSCALEDFONTDWRITE_H_ 8 #define MOZILLA_GFX_UNSCALEDFONTDWRITE_H_ 9 10 #include <dwrite.h> 11 12 #include <vector> 13 14 #include "2D.h" 15 16 namespace mozilla { 17 namespace gfx { 18 19 class ScaledFontDWrite; 20 21 class UnscaledFontDWrite final : public UnscaledFont { 22 public: 23 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(UnscaledFontDWrite, override) 24 UnscaledFontDWrite(const RefPtr<IDWriteFontFace>& aFontFace, 25 const RefPtr<IDWriteFont>& aFont) 26 : mFontFace(aFontFace), mFont(aFont) {} 27 28 FontType GetType() const override { return FontType::DWRITE; } 29 30 const RefPtr<IDWriteFontFace>& GetFontFace() const { return mFontFace; } 31 const RefPtr<IDWriteFont>& GetFont() const { return mFont; } 32 33 bool GetFontFileData(FontFileDataOutput aDataCallback, void* aBaton) override; 34 35 already_AddRefed<ScaledFont> CreateScaledFont( 36 Float aGlyphSize, const uint8_t* aInstanceData, 37 uint32_t aInstanceDataLength, const FontVariation* aVariations, 38 uint32_t aNumVariations) override; 39 40 already_AddRefed<ScaledFont> CreateScaledFontFromWRFont( 41 Float aGlyphSize, const wr::FontInstanceOptions* aOptions, 42 const wr::FontInstancePlatformOptions* aPlatformOptions, 43 const FontVariation* aVariations, uint32_t aNumVariations) override; 44 45 bool GetFontDescriptor(FontDescriptorOutput aCb, void* aBaton) override; 46 47 static already_AddRefed<UnscaledFont> CreateFromFontDescriptor( 48 const uint8_t* aData, uint32_t aDataLength, uint32_t aIndex); 49 50 private: 51 bool InitBold(); 52 53 RefPtr<IDWriteFontFace> mFontFace; 54 RefPtr<IDWriteFontFace> mFontFaceBold; 55 RefPtr<IDWriteFont> mFont; 56 std::vector<WCHAR> mFontFileName; 57 }; 58 59 } // namespace gfx 60 } // namespace mozilla 61 62 #endif /* MOZILLA_GFX_UNSCALEDFONTDWRITE_H_ */