1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxGDIFont.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,99 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_GDIFONT_H 1.10 +#define GFX_GDIFONT_H 1.11 + 1.12 +#include "mozilla/MemoryReporting.h" 1.13 +#include "gfxFont.h" 1.14 +#include "gfxGDIFontList.h" 1.15 + 1.16 +#include "nsDataHashtable.h" 1.17 +#include "nsHashKeys.h" 1.18 + 1.19 +#include "cairo.h" 1.20 + 1.21 +class gfxGDIFont : public gfxFont 1.22 +{ 1.23 +public: 1.24 + gfxGDIFont(GDIFontEntry *aFontEntry, 1.25 + const gfxFontStyle *aFontStyle, 1.26 + bool aNeedsBold, 1.27 + AntialiasOption anAAOption = kAntialiasDefault); 1.28 + 1.29 + virtual ~gfxGDIFont(); 1.30 + 1.31 + HFONT GetHFONT() { if (!mMetrics) Initialize(); return mFont; } 1.32 + 1.33 + gfxFloat GetAdjustedSize() { if (!mMetrics) Initialize(); return mAdjustedSize; } 1.34 + 1.35 + cairo_font_face_t *CairoFontFace() { return mFontFace; } 1.36 + cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; } 1.37 + 1.38 + /* overrides for the pure virtual methods in gfxFont */ 1.39 + virtual const gfxFont::Metrics& GetMetrics(); 1.40 + 1.41 + virtual uint32_t GetSpaceGlyph(); 1.42 + 1.43 + virtual bool SetupCairoFont(gfxContext *aContext); 1.44 + 1.45 + /* override Measure to add padding for antialiasing */ 1.46 + virtual RunMetrics Measure(gfxTextRun *aTextRun, 1.47 + uint32_t aStart, uint32_t aEnd, 1.48 + BoundingBoxType aBoundingBoxType, 1.49 + gfxContext *aContextForTightBoundingBox, 1.50 + Spacing *aSpacing); 1.51 + 1.52 + /* required for MathML to suppress effects of ClearType "padding" */ 1.53 + virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption); 1.54 + 1.55 + virtual bool ProvidesGlyphWidths() { return true; } 1.56 + 1.57 + // get hinted glyph width in pixels as 16.16 fixed-point value 1.58 + virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID); 1.59 + 1.60 + virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, 1.61 + FontCacheSizes* aSizes) const; 1.62 + virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, 1.63 + FontCacheSizes* aSizes) const; 1.64 + 1.65 + virtual FontType GetType() const { return FONT_TYPE_GDI; } 1.66 + 1.67 +protected: 1.68 + virtual void CreatePlatformShaper(); 1.69 + 1.70 + /* override to check for uniscribe failure and fall back to GDI */ 1.71 + virtual bool ShapeText(gfxContext *aContext, 1.72 + const char16_t *aText, 1.73 + uint32_t aOffset, 1.74 + uint32_t aLength, 1.75 + int32_t aScript, 1.76 + gfxShapedText *aShapedText, 1.77 + bool aPreferPlatformShaping); 1.78 + 1.79 + void Initialize(); // creates metrics and Cairo fonts 1.80 + 1.81 + // Fill the given LOGFONT record according to our style, but don't adjust 1.82 + // the lfItalic field if we're going to use a cairo transform for fake 1.83 + // italics. 1.84 + void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize, bool aUseGDIFakeItalic); 1.85 + 1.86 + // mPlatformShaper is used for the GDI shaper, mUniscribeShaper 1.87 + // for the Uniscribe version if needed 1.88 + nsAutoPtr<gfxFontShaper> mUniscribeShaper; 1.89 + 1.90 + HFONT mFont; 1.91 + cairo_font_face_t *mFontFace; 1.92 + 1.93 + Metrics *mMetrics; 1.94 + uint32_t mSpaceGlyph; 1.95 + 1.96 + bool mNeedsBold; 1.97 + 1.98 + // cache of glyph widths in 16.16 fixed-point pixels 1.99 + nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths; 1.100 +}; 1.101 + 1.102 +#endif /* GFX_GDIFONT_H */