2010-02-26 09:36:07 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
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-02-26 09:36:07 +03:00
|
|
|
|
|
|
|
#ifndef GFX_WINDOWSDWRITEFONTS_H
|
|
|
|
#define GFX_WINDOWSDWRITEFONTS_H
|
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2016-04-15 22:45:37 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2017-05-20 00:25:28 +03:00
|
|
|
#include <dwrite_1.h>
|
2010-02-26 09:36:07 +03:00
|
|
|
|
|
|
|
#include "gfxFont.h"
|
|
|
|
#include "gfxUserFontSet.h"
|
|
|
|
#include "cairo-win32.h"
|
|
|
|
|
2010-06-11 23:14:38 +04:00
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
|
2017-04-07 00:41:02 +03:00
|
|
|
#include "mozilla/gfx/UnscaledFontDWrite.h"
|
|
|
|
|
2010-02-26 09:36:07 +03:00
|
|
|
/**
|
|
|
|
* \brief Class representing a font face for a font entry.
|
|
|
|
*/
|
|
|
|
class gfxDWriteFont : public gfxFont
|
|
|
|
{
|
|
|
|
public:
|
2017-04-07 00:41:02 +03:00
|
|
|
gfxDWriteFont(const RefPtr<mozilla::gfx::UnscaledFontDWrite>& aUnscaledFont,
|
|
|
|
gfxFontEntry *aFontEntry,
|
2010-03-12 07:25:35 +03:00
|
|
|
const gfxFontStyle *aFontStyle,
|
2010-06-10 22:19:51 +04:00
|
|
|
AntialiasOption = kAntialiasDefault);
|
2010-02-26 09:36:07 +03:00
|
|
|
~gfxDWriteFont();
|
|
|
|
|
2016-12-22 14:06:15 +03:00
|
|
|
static void UpdateClearTypeUsage();
|
|
|
|
|
2017-01-09 20:41:35 +03:00
|
|
|
mozilla::UniquePtr<gfxFont>
|
2015-03-21 19:28:04 +03:00
|
|
|
CopyWithAntialiasOption(AntialiasOption anAAOption) override;
|
2010-06-10 22:19:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint32_t GetSpaceGlyph() override;
|
2010-02-26 09:36:07 +03:00
|
|
|
|
2015-12-16 00:56:40 +03:00
|
|
|
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
|
2010-02-26 09:36:07 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool AllowSubpixelAA() override
|
2014-11-17 12:59:50 +03:00
|
|
|
{ return mAllowManualShowGlyphs; }
|
2012-05-24 19:43:55 +04:00
|
|
|
|
2014-11-17 12:59:50 +03:00
|
|
|
bool IsValid() const;
|
2010-03-12 14:57:49 +03:00
|
|
|
|
2011-01-21 19:44:32 +03:00
|
|
|
IDWriteFontFace *GetFontFace();
|
2010-02-26 09:36:07 +03:00
|
|
|
|
2011-07-01 10:38:17 +04:00
|
|
|
/* override Measure to add padding for antialiasing */
|
2016-06-27 19:41:55 +03:00
|
|
|
virtual RunMetrics Measure(const gfxTextRun *aTextRun,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aStart, uint32_t aEnd,
|
2011-07-01 10:38:17 +04:00
|
|
|
BoundingBoxType aBoundingBoxType,
|
2015-12-16 00:56:41 +03:00
|
|
|
DrawTarget *aDrawTargetForTightBoundingBox,
|
2014-10-16 12:40:19 +04:00
|
|
|
Spacing *aSpacing,
|
2017-05-05 00:27:05 +03:00
|
|
|
mozilla::gfx::ShapedTextFlags aOrientation) override;
|
2011-07-01 10:38:17 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool ProvidesGlyphWidths() const override;
|
2011-01-04 19:58:31 +03:00
|
|
|
|
2014-11-17 12:59:50 +03:00
|
|
|
virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint16_t aGID) override;
|
2011-01-04 19:58:31 +03:00
|
|
|
|
2013-10-15 06:19:47 +04:00
|
|
|
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
2015-12-16 18:41:21 +03:00
|
|
|
FontCacheSizes* aSizes) const override;
|
2013-10-15 06:19:47 +04:00
|
|
|
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
2015-12-16 18:41:21 +03:00
|
|
|
FontCacheSizes* aSizes) const override;
|
2012-03-23 16:14:16 +04:00
|
|
|
|
2015-12-16 18:41:21 +03:00
|
|
|
virtual FontType GetType() const override { return FONT_TYPE_DWRITE; }
|
2012-04-11 18:55:31 +04:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
2015-03-21 19:28:04 +03:00
|
|
|
GetScaledFont(mozilla::gfx::DrawTarget *aTarget) override;
|
2012-09-24 19:02:49 +04:00
|
|
|
|
2010-04-07 00:19:39 +04:00
|
|
|
protected:
|
2017-08-07 23:20:48 +03:00
|
|
|
cairo_scaled_font_t *InitCairoScaledFont();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual const Metrics& GetHorizontalMetrics() override;
|
2014-09-30 10:37:40 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics);
|
2011-03-24 06:01:14 +03:00
|
|
|
|
2011-06-03 08:31:08 +04:00
|
|
|
void ComputeMetrics(AntialiasOption anAAOption);
|
2010-02-26 09:36:07 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
bool HasBitmapStrikeForSize(uint32_t aSize);
|
2011-01-21 13:36:28 +03:00
|
|
|
|
2010-02-26 09:36:07 +03:00
|
|
|
cairo_font_face_t *CairoFontFace();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
gfxFloat MeasureGlyphWidth(uint16_t aGlyph);
|
2011-04-21 10:29:50 +04:00
|
|
|
|
2011-06-03 08:31:07 +04:00
|
|
|
DWRITE_MEASURING_MODE GetMeasuringMode();
|
2011-06-03 08:31:08 +04:00
|
|
|
bool GetForceGDIClassic();
|
2011-06-03 08:31:07 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDWriteFontFace> mFontFace;
|
2017-05-20 00:25:28 +03:00
|
|
|
RefPtr<IDWriteFontFace1> mFontFace1; // may be unavailable on older DWrite
|
|
|
|
|
2010-02-26 09:36:07 +03:00
|
|
|
cairo_font_face_t *mCairoFontFace;
|
|
|
|
|
2014-09-30 10:37:40 +04:00
|
|
|
Metrics *mMetrics;
|
2011-01-04 19:58:31 +03:00
|
|
|
|
|
|
|
// cache of glyph widths in 16.16 fixed-point pixels
|
2016-04-15 22:45:37 +03:00
|
|
|
mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey,int32_t>> mGlyphWidths;
|
2011-01-04 19:58:31 +03:00
|
|
|
|
2014-11-18 13:19:54 +03:00
|
|
|
uint32_t mSpaceGlyph;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUseSubpixelPositions;
|
|
|
|
bool mAllowManualShowGlyphs;
|
2017-09-14 19:26:53 +03:00
|
|
|
|
2018-03-20 16:46:40 +03:00
|
|
|
// Used to record the sUseClearType setting at the time mAzureScaledFont
|
|
|
|
// was set up, so we can tell if it's stale and needs to be re-created.
|
|
|
|
bool mAzureScaledFontUsedClearType;
|
|
|
|
|
2017-09-14 19:26:53 +03:00
|
|
|
static bool sUseClearType;
|
2010-02-26 09:36:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|