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_GDIFONT_H michael@0: #define GFX_GDIFONT_H michael@0: michael@0: #include "mozilla/MemoryReporting.h" michael@0: #include "gfxFont.h" michael@0: #include "gfxGDIFontList.h" michael@0: michael@0: #include "nsDataHashtable.h" michael@0: #include "nsHashKeys.h" michael@0: michael@0: #include "cairo.h" michael@0: michael@0: class gfxGDIFont : public gfxFont michael@0: { michael@0: public: michael@0: gfxGDIFont(GDIFontEntry *aFontEntry, michael@0: const gfxFontStyle *aFontStyle, michael@0: bool aNeedsBold, michael@0: AntialiasOption anAAOption = kAntialiasDefault); michael@0: michael@0: virtual ~gfxGDIFont(); michael@0: michael@0: HFONT GetHFONT() { if (!mMetrics) Initialize(); return mFont; } michael@0: michael@0: gfxFloat GetAdjustedSize() { if (!mMetrics) Initialize(); return mAdjustedSize; } michael@0: michael@0: cairo_font_face_t *CairoFontFace() { return mFontFace; } michael@0: cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; } michael@0: michael@0: /* overrides for the pure virtual methods in gfxFont */ 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: /* 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: /* required for MathML to suppress effects of ClearType "padding" */ michael@0: virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption); michael@0: michael@0: virtual bool ProvidesGlyphWidths() { return true; } michael@0: michael@0: // get hinted glyph width in pixels as 16.16 fixed-point value michael@0: virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID); 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_GDI; } michael@0: michael@0: protected: michael@0: virtual void CreatePlatformShaper(); michael@0: michael@0: /* override to check for uniscribe failure and fall back to GDI */ michael@0: virtual bool ShapeText(gfxContext *aContext, michael@0: const char16_t *aText, michael@0: uint32_t aOffset, michael@0: uint32_t aLength, michael@0: int32_t aScript, michael@0: gfxShapedText *aShapedText, michael@0: bool aPreferPlatformShaping); michael@0: michael@0: void Initialize(); // creates metrics and Cairo fonts michael@0: michael@0: // Fill the given LOGFONT record according to our style, but don't adjust michael@0: // the lfItalic field if we're going to use a cairo transform for fake michael@0: // italics. michael@0: void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize, bool aUseGDIFakeItalic); michael@0: michael@0: // mPlatformShaper is used for the GDI shaper, mUniscribeShaper michael@0: // for the Uniscribe version if needed michael@0: nsAutoPtr mUniscribeShaper; michael@0: michael@0: HFONT mFont; michael@0: cairo_font_face_t *mFontFace; michael@0: michael@0: Metrics *mMetrics; michael@0: uint32_t mSpaceGlyph; michael@0: michael@0: bool mNeedsBold; michael@0: michael@0: // cache of glyph widths in 16.16 fixed-point pixels michael@0: nsAutoPtr > mGlyphWidths; michael@0: }; michael@0: michael@0: #endif /* GFX_GDIFONT_H */