2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-15 12:34:25 +03:00
|
|
|
|
|
|
|
#ifndef GFX_GDIFONT_H
|
|
|
|
#define GFX_GDIFONT_H
|
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2010-03-15 12:34:25 +03:00
|
|
|
#include "gfxFont.h"
|
|
|
|
#include "gfxGDIFontList.h"
|
|
|
|
|
2021-03-10 13:47:47 +03:00
|
|
|
#include "nsTHashMap.h"
|
2009-10-07 21:16:52 +04:00
|
|
|
#include "nsHashKeys.h"
|
|
|
|
|
2014-06-09 19:43:16 +04:00
|
|
|
#include "usp10.h"
|
2010-03-15 12:34:25 +03:00
|
|
|
|
|
|
|
class gfxGDIFont : public gfxFont {
|
|
|
|
public:
|
|
|
|
gfxGDIFont(GDIFontEntry* aFontEntry, const gfxFontStyle* aFontStyle,
|
|
|
|
AntialiasOption anAAOption = kAntialiasDefault);
|
|
|
|
|
|
|
|
virtual ~gfxGDIFont();
|
|
|
|
|
2022-03-24 21:58:00 +03:00
|
|
|
HFONT GetHFONT() const { return mFont; }
|
2010-03-15 12:34:25 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(
|
2021-12-10 01:16:17 +03:00
|
|
|
const TextRunDrawParams& aRunParams) override;
|
2017-08-07 23:20:44 +03:00
|
|
|
|
2011-06-22 12:49:53 +04:00
|
|
|
/* override Measure to add padding for antialiasing */
|
2019-04-11 15:36:51 +03:00
|
|
|
RunMetrics Measure(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
|
|
|
|
BoundingBoxType aBoundingBoxType,
|
|
|
|
DrawTarget* aDrawTargetForTightBoundingBox,
|
|
|
|
Spacing* aSpacing,
|
|
|
|
mozilla::gfx::ShapedTextFlags aOrientation) override;
|
2011-06-22 12:49:53 +04:00
|
|
|
|
2010-03-15 12:34:25 +03:00
|
|
|
/* required for MathML to suppress effects of ClearType "padding" */
|
2022-03-24 21:58:00 +03:00
|
|
|
gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption) const override;
|
2010-03-15 12:34:25 +03:00
|
|
|
|
2014-06-09 18:47:31 +04:00
|
|
|
// If the font has a cmap table, we handle it purely with harfbuzz;
|
|
|
|
// but if not (e.g. .fon fonts), we'll use a GDI callback to get glyphs.
|
2019-04-11 15:36:51 +03:00
|
|
|
bool ProvidesGetGlyph() const override { return !mFontEntry->HasCmapTable(); }
|
2014-06-09 18:47:31 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
uint32_t GetGlyph(uint32_t aUnicode, uint32_t aVarSelector) override;
|
2014-06-09 18:47:31 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool ProvidesGlyphWidths() const override { return true; }
|
2011-01-07 15:38:28 +03:00
|
|
|
|
|
|
|
// get hinted glyph width in pixels as 16.16 fixed-point value
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t GetGlyphWidth(uint16_t aGID) override;
|
2011-01-07 15:38:28 +03:00
|
|
|
|
2022-03-24 21:58:00 +03:00
|
|
|
bool GetGlyphBounds(uint16_t aGID, gfxRect* aBounds,
|
|
|
|
bool aTight) const override;
|
2019-09-20 19:30:21 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
2012-03-23 16:14:16 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
FontType GetType() const override { return FONT_TYPE_GDI; }
|
2012-04-11 18:55:31 +04:00
|
|
|
|
2011-01-07 15:38:28 +03:00
|
|
|
protected:
|
2022-03-24 21:58:00 +03:00
|
|
|
const Metrics& GetHorizontalMetrics() const override { return *mMetrics; }
|
2014-09-30 10:37:40 +04:00
|
|
|
|
2017-04-03 19:49:17 +03:00
|
|
|
bool ShapeText(DrawTarget* aDrawTarget, const char16_t* aText,
|
|
|
|
uint32_t aOffset, uint32_t aLength, Script aScript,
|
2020-11-13 16:15:39 +03:00
|
|
|
nsAtom* aLanguage, bool aVertical, RoundingFlags aRounding,
|
2017-04-03 19:49:17 +03:00
|
|
|
gfxShapedText* aShapedText) override;
|
2009-10-07 21:16:52 +04:00
|
|
|
|
2010-05-05 14:10:36 +04:00
|
|
|
void Initialize(); // creates metrics and Cairo fonts
|
2010-03-15 12:34:25 +03:00
|
|
|
|
2017-11-23 22:38:17 +03:00
|
|
|
// Fill the given LOGFONT record according to our size.
|
|
|
|
// (Synthetic italic is *not* handled here, because GDI may not reliably
|
|
|
|
// use the face we expect if we tweak the lfItalic field, and because we
|
|
|
|
// have generic support for this in gfxFont::Draw instead.)
|
|
|
|
void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize);
|
2010-03-15 12:34:25 +03:00
|
|
|
|
|
|
|
HFONT mFont;
|
|
|
|
|
2010-05-05 14:10:36 +04:00
|
|
|
Metrics* mMetrics;
|
2019-09-20 19:30:21 +03:00
|
|
|
bool mIsBitmap;
|
2010-05-05 14:10:36 +04:00
|
|
|
|
2018-04-26 14:46:18 +03:00
|
|
|
bool mNeedsSyntheticBold;
|
2009-10-07 21:16:52 +04:00
|
|
|
|
2014-06-09 18:47:31 +04:00
|
|
|
// cache of glyph IDs (used for non-sfnt fonts only)
|
2021-03-10 13:47:47 +03:00
|
|
|
mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, uint32_t> > mGlyphIDs;
|
2014-06-09 19:43:16 +04:00
|
|
|
SCRIPT_CACHE mScriptCache;
|
2014-06-09 18:47:31 +04:00
|
|
|
|
2009-10-07 21:16:52 +04:00
|
|
|
// cache of glyph widths in 16.16 fixed-point pixels
|
2021-03-10 13:47:47 +03:00
|
|
|
mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, int32_t> > mGlyphWidths;
|
2010-03-15 12:34:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_GDIFONT_H */
|