michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_WINDOWSDWRITEFONTS_H michael@0: #define GFX_WINDOWSDWRITEFONTS_H michael@0: michael@0: #include "mozilla/MemoryReporting.h" michael@0: #include michael@0: michael@0: #include "gfxFont.h" michael@0: #include "gfxUserFontSet.h" michael@0: #include "cairo-win32.h" michael@0: michael@0: #include "nsDataHashtable.h" michael@0: #include "nsHashKeys.h" michael@0: michael@0: /** michael@0: * \brief Class representing a font face for a font entry. michael@0: */ michael@0: class gfxDWriteFont : public gfxFont michael@0: { michael@0: public: michael@0: gfxDWriteFont(gfxFontEntry *aFontEntry, michael@0: const gfxFontStyle *aFontStyle, michael@0: bool aNeedsBold = false, michael@0: AntialiasOption = kAntialiasDefault); michael@0: ~gfxDWriteFont(); michael@0: michael@0: virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption); michael@0: michael@0: virtual const gfxFont::Metrics& GetMetrics(); michael@0: michael@0: virtual uint32_t GetSpaceGlyph(); michael@0: michael@0: virtual bool SetupCairoFont(gfxContext *aContext); michael@0: michael@0: virtual bool AllowSubpixelAA() { return mAllowManualShowGlyphs; } michael@0: michael@0: virtual bool IsValid(); michael@0: michael@0: gfxFloat GetAdjustedSize() { michael@0: return mAdjustedSize; michael@0: } michael@0: michael@0: IDWriteFontFace *GetFontFace(); michael@0: michael@0: /* override Measure to add padding for antialiasing */ michael@0: virtual RunMetrics Measure(gfxTextRun *aTextRun, michael@0: uint32_t aStart, uint32_t aEnd, michael@0: BoundingBoxType aBoundingBoxType, michael@0: gfxContext *aContextForTightBoundingBox, michael@0: Spacing *aSpacing); michael@0: michael@0: virtual bool ProvidesGlyphWidths(); michael@0: michael@0: virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID); michael@0: michael@0: virtual mozilla::TemporaryRef GetGlyphRenderingOptions(); michael@0: michael@0: virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, michael@0: FontCacheSizes* aSizes) const; michael@0: virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, michael@0: FontCacheSizes* aSizes) const; michael@0: michael@0: virtual FontType GetType() const { return FONT_TYPE_DWRITE; } michael@0: michael@0: virtual mozilla::TemporaryRef GetScaledFont(mozilla::gfx::DrawTarget *aTarget); michael@0: michael@0: virtual cairo_scaled_font_t *GetCairoScaledFont(); michael@0: michael@0: protected: michael@0: friend class gfxDWriteShaper; michael@0: michael@0: virtual void CreatePlatformShaper(); michael@0: michael@0: bool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics); michael@0: michael@0: void ComputeMetrics(AntialiasOption anAAOption); michael@0: michael@0: bool HasBitmapStrikeForSize(uint32_t aSize); michael@0: michael@0: cairo_font_face_t *CairoFontFace(); michael@0: michael@0: gfxFloat MeasureGlyphWidth(uint16_t aGlyph); michael@0: michael@0: DWRITE_MEASURING_MODE GetMeasuringMode(); michael@0: bool GetForceGDIClassic(); michael@0: michael@0: nsRefPtr mFontFace; michael@0: cairo_font_face_t *mCairoFontFace; michael@0: michael@0: gfxFont::Metrics *mMetrics; michael@0: michael@0: // cache of glyph widths in 16.16 fixed-point pixels michael@0: nsAutoPtr > mGlyphWidths; michael@0: michael@0: bool mNeedsOblique; michael@0: bool mNeedsBold; michael@0: bool mUseSubpixelPositions; michael@0: bool mAllowManualShowGlyphs; michael@0: bool mAzureScaledFontIsCairo; michael@0: }; michael@0: michael@0: #endif