gfx/thebes/gfxGDIFont.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:effaa1760176
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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 GFX_GDIFONT_H
7 #define GFX_GDIFONT_H
8
9 #include "mozilla/MemoryReporting.h"
10 #include "gfxFont.h"
11 #include "gfxGDIFontList.h"
12
13 #include "nsDataHashtable.h"
14 #include "nsHashKeys.h"
15
16 #include "cairo.h"
17
18 class gfxGDIFont : public gfxFont
19 {
20 public:
21 gfxGDIFont(GDIFontEntry *aFontEntry,
22 const gfxFontStyle *aFontStyle,
23 bool aNeedsBold,
24 AntialiasOption anAAOption = kAntialiasDefault);
25
26 virtual ~gfxGDIFont();
27
28 HFONT GetHFONT() { if (!mMetrics) Initialize(); return mFont; }
29
30 gfxFloat GetAdjustedSize() { if (!mMetrics) Initialize(); return mAdjustedSize; }
31
32 cairo_font_face_t *CairoFontFace() { return mFontFace; }
33 cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; }
34
35 /* overrides for the pure virtual methods in gfxFont */
36 virtual const gfxFont::Metrics& GetMetrics();
37
38 virtual uint32_t GetSpaceGlyph();
39
40 virtual bool SetupCairoFont(gfxContext *aContext);
41
42 /* override Measure to add padding for antialiasing */
43 virtual RunMetrics Measure(gfxTextRun *aTextRun,
44 uint32_t aStart, uint32_t aEnd,
45 BoundingBoxType aBoundingBoxType,
46 gfxContext *aContextForTightBoundingBox,
47 Spacing *aSpacing);
48
49 /* required for MathML to suppress effects of ClearType "padding" */
50 virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
51
52 virtual bool ProvidesGlyphWidths() { return true; }
53
54 // get hinted glyph width in pixels as 16.16 fixed-point value
55 virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
56
57 virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
58 FontCacheSizes* aSizes) const;
59 virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
60 FontCacheSizes* aSizes) const;
61
62 virtual FontType GetType() const { return FONT_TYPE_GDI; }
63
64 protected:
65 virtual void CreatePlatformShaper();
66
67 /* override to check for uniscribe failure and fall back to GDI */
68 virtual bool ShapeText(gfxContext *aContext,
69 const char16_t *aText,
70 uint32_t aOffset,
71 uint32_t aLength,
72 int32_t aScript,
73 gfxShapedText *aShapedText,
74 bool aPreferPlatformShaping);
75
76 void Initialize(); // creates metrics and Cairo fonts
77
78 // Fill the given LOGFONT record according to our style, but don't adjust
79 // the lfItalic field if we're going to use a cairo transform for fake
80 // italics.
81 void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize, bool aUseGDIFakeItalic);
82
83 // mPlatformShaper is used for the GDI shaper, mUniscribeShaper
84 // for the Uniscribe version if needed
85 nsAutoPtr<gfxFontShaper> mUniscribeShaper;
86
87 HFONT mFont;
88 cairo_font_face_t *mFontFace;
89
90 Metrics *mMetrics;
91 uint32_t mSpaceGlyph;
92
93 bool mNeedsBold;
94
95 // cache of glyph widths in 16.16 fixed-point pixels
96 nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;
97 };
98
99 #endif /* GFX_GDIFONT_H */

mercurial