Bug 1567650 [wpt PR 17950] - [ElementTiming] Replace responseEnd with loadTime, a...
[gecko.git] / gfx / thebes / gfxGDIFont.h
blob318784778ee49a06e1c4263ef89b115792e2d7a5
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/. */
6 #ifndef GFX_GDIFONT_H
7 #define GFX_GDIFONT_H
9 #include "mozilla/MemoryReporting.h"
10 #include "gfxFont.h"
11 #include "gfxGDIFontList.h"
13 #include "nsDataHashtable.h"
14 #include "nsHashKeys.h"
16 #include "cairo.h"
17 #include "usp10.h"
19 class gfxGDIFont : public gfxFont {
20 public:
21 gfxGDIFont(GDIFontEntry* aFontEntry, const gfxFontStyle* aFontStyle,
22 AntialiasOption anAAOption = kAntialiasDefault);
24 virtual ~gfxGDIFont();
26 HFONT GetHFONT() { return mFont; }
28 cairo_font_face_t* CairoFontFace() { return mFontFace; }
30 /* overrides for the pure virtual methods in gfxFont */
31 uint32_t GetSpaceGlyph() override;
33 bool SetupCairoFont(DrawTarget* aDrawTarget) override;
35 already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(
36 DrawTarget* aTarget) override;
38 /* override Measure to add padding for antialiasing */
39 RunMetrics Measure(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
40 BoundingBoxType aBoundingBoxType,
41 DrawTarget* aDrawTargetForTightBoundingBox,
42 Spacing* aSpacing,
43 mozilla::gfx::ShapedTextFlags aOrientation) override;
45 /* required for MathML to suppress effects of ClearType "padding" */
46 mozilla::UniquePtr<gfxFont> CopyWithAntialiasOption(
47 AntialiasOption anAAOption) override;
49 // If the font has a cmap table, we handle it purely with harfbuzz;
50 // but if not (e.g. .fon fonts), we'll use a GDI callback to get glyphs.
51 bool ProvidesGetGlyph() const override { return !mFontEntry->HasCmapTable(); }
53 uint32_t GetGlyph(uint32_t aUnicode, uint32_t aVarSelector) override;
55 bool ProvidesGlyphWidths() const override { return true; }
57 // get hinted glyph width in pixels as 16.16 fixed-point value
58 int32_t GetGlyphWidth(uint16_t aGID) override;
60 void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
61 FontCacheSizes* aSizes) const;
62 void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
63 FontCacheSizes* aSizes) const;
65 FontType GetType() const override { return FONT_TYPE_GDI; }
67 protected:
68 const Metrics& GetHorizontalMetrics() override;
70 /* override to ensure the cairo font is set up properly */
71 bool ShapeText(DrawTarget* aDrawTarget, const char16_t* aText,
72 uint32_t aOffset, uint32_t aLength, Script aScript,
73 bool aVertical, RoundingFlags aRounding,
74 gfxShapedText* aShapedText) override;
76 void Initialize(); // creates metrics and Cairo fonts
78 // Fill the given LOGFONT record according to our size.
79 // (Synthetic italic is *not* handled here, because GDI may not reliably
80 // use the face we expect if we tweak the lfItalic field, and because we
81 // have generic support for this in gfxFont::Draw instead.)
82 void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize);
84 HFONT mFont;
85 cairo_font_face_t* mFontFace;
87 Metrics* mMetrics;
88 uint32_t mSpaceGlyph;
90 bool mNeedsSyntheticBold;
92 // cache of glyph IDs (used for non-sfnt fonts only)
93 mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey, uint32_t> > mGlyphIDs;
94 SCRIPT_CACHE mScriptCache;
96 // cache of glyph widths in 16.16 fixed-point pixels
97 mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey, int32_t> > mGlyphWidths;
100 #endif /* GFX_GDIFONT_H */