Bug 1919083 - [ci] Enable os-integration variant for more suites, r=jmaher
[gecko.git] / gfx / thebes / gfxGDIFont.h
blob505f731a79bbde9e4f1facb7edfa2fe862d7ac24
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 "nsTHashMap.h"
14 #include "nsHashKeys.h"
16 #include "usp10.h"
18 class gfxGDIFont final : public gfxFont {
19 public:
20 gfxGDIFont(GDIFontEntry* aFontEntry, const gfxFontStyle* aFontStyle,
21 AntialiasOption anAAOption = kAntialiasDefault);
23 HFONT GetHFONT() const { return mFont; }
25 already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(
26 const TextRunDrawParams& aRunParams) override;
28 /* override Measure to add padding for antialiasing */
29 RunMetrics Measure(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
30 BoundingBoxType aBoundingBoxType,
31 DrawTarget* aDrawTargetForTightBoundingBox,
32 Spacing* aSpacing,
33 mozilla::gfx::ShapedTextFlags aOrientation) override;
35 /* required for MathML to suppress effects of ClearType "padding" */
36 gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption) const override;
38 // If the font has a cmap table, we handle it purely with harfbuzz;
39 // but if not (e.g. .fon fonts), we'll use a GDI callback to get glyphs.
40 bool ProvidesGetGlyph() const override { return !mFontEntry->HasCmapTable(); }
42 uint32_t GetGlyph(uint32_t aUnicode, uint32_t aVarSelector) override;
44 bool ProvidesGlyphWidths() const override { return true; }
46 // get hinted glyph width in pixels as 16.16 fixed-point value
47 int32_t GetGlyphWidth(uint16_t aGID) override;
49 bool GetGlyphBounds(uint16_t aGID, gfxRect* aBounds, bool aTight) override;
51 void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
52 FontCacheSizes* aSizes) const;
53 void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
54 FontCacheSizes* aSizes) const;
56 FontType GetType() const override { return FONT_TYPE_GDI; }
58 protected:
59 ~gfxGDIFont() override;
61 const Metrics& GetHorizontalMetrics() const override { return *mMetrics; }
63 bool ShapeText(DrawTarget* aDrawTarget, const char16_t* aText,
64 uint32_t aOffset, uint32_t aLength, Script aScript,
65 nsAtom* aLanguage, bool aVertical, RoundingFlags aRounding,
66 gfxShapedText* aShapedText) override;
68 void Initialize(); // creates metrics and Cairo fonts
70 // Fill the given LOGFONT record according to our size.
71 // (Synthetic italic is *not* handled here, because GDI may not reliably
72 // use the face we expect if we tweak the lfItalic field, and because we
73 // have generic support for this in gfxFont::Draw instead.)
74 void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize);
76 HFONT mFont;
78 Metrics* mMetrics;
79 bool mIsBitmap;
81 bool mNeedsSyntheticBold;
83 // cache of glyph IDs (used for non-sfnt fonts only)
84 mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, uint32_t> > mGlyphIDs;
85 SCRIPT_CACHE mScriptCache;
87 // cache of glyph widths in 16.16 fixed-point pixels
88 mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, int32_t> > mGlyphWidths;
91 #endif /* GFX_GDIFONT_H */