1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef MOZILLA_GFX_SCALEDFONTDWRITE_H_ 7 #define MOZILLA_GFX_SCALEDFONTDWRITE_H_ 8 9 #include <dwrite.h> 10 #include "ScaledFontBase.h" 11 12 struct ID2D1GeometrySink; 13 struct gfxFontStyle; 14 15 namespace mozilla { 16 namespace gfx { 17 18 class ScaledFontDWrite final : public ScaledFontBase 19 { 20 public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontDwrite)21 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontDwrite) 22 ScaledFontDWrite(IDWriteFontFace *aFont, Float aSize) 23 : ScaledFontBase(aSize) 24 , mFontFace(aFont) 25 , mUseEmbeddedBitmap(false) 26 , mForceGDIMode(false) 27 {} 28 29 ScaledFontDWrite(IDWriteFontFace *aFontFace, Float aSize, bool aUseEmbeddedBitmap, 30 bool aForceGDIMode, const gfxFontStyle* aStyle); 31 GetType()32 virtual FontType GetType() const { return FontType::DWRITE; } 33 34 virtual already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget); 35 virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, const Matrix *aTransformHint); 36 37 void CopyGlyphsToSink(const GlyphBuffer &aBuffer, ID2D1GeometrySink *aSink); 38 39 virtual void GetGlyphDesignMetrics(const uint16_t* aGlyphIndices, uint32_t aNumGlyphs, GlyphMetrics* aGlyphMetrics); 40 41 virtual bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton); 42 43 virtual AntialiasMode GetDefaultAAMode() override; 44 UseEmbeddedBitmaps()45 bool UseEmbeddedBitmaps() { return mUseEmbeddedBitmap; } ForceGDIMode()46 bool ForceGDIMode() { return mForceGDIMode; } 47 48 #ifdef USE_SKIA 49 virtual SkTypeface* GetSkTypeface(); 50 SkFontStyle mStyle; 51 #endif 52 53 RefPtr<IDWriteFontFace> mFontFace; 54 bool mUseEmbeddedBitmap; 55 bool mForceGDIMode; 56 57 protected: 58 #ifdef USE_CAIRO_SCALED_FONT 59 cairo_font_face_t* GetCairoFontFace() override; 60 #endif 61 }; 62 63 class GlyphRenderingOptionsDWrite : public GlyphRenderingOptions 64 { 65 public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptionsDWrite)66 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptionsDWrite) 67 GlyphRenderingOptionsDWrite(IDWriteRenderingParams *aParams) 68 : mParams(aParams) 69 { 70 } 71 GetType()72 virtual FontType GetType() const { return FontType::DWRITE; } 73 74 private: 75 friend class DrawTargetD2D; 76 friend class DrawTargetD2D1; 77 78 RefPtr<IDWriteRenderingParams> mParams; 79 }; 80 81 } 82 } 83 84 #endif /* MOZILLA_GFX_SCALEDFONTDWRITE_H_ */ 85