2018-11-30 19:52:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 11:12:37 +00: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 06:36:07 +00:00
|
|
|
|
|
|
|
#ifndef GFX_DWRITEFONTLIST_H
|
|
|
|
#define GFX_DWRITEFONTLIST_H
|
|
|
|
|
2018-04-13 19:34:37 +00:00
|
|
|
#include "mozilla/FontPropertyTypes.h"
|
2018-04-16 19:26:08 +00:00
|
|
|
#include "mozilla/MathAlgorithms.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2010-02-26 06:36:07 +00:00
|
|
|
#include "gfxDWriteCommon.h"
|
2018-01-18 17:45:24 +00:00
|
|
|
#include "dwrite_3.h"
|
2010-02-26 06:36:07 +00:00
|
|
|
|
2018-01-18 17:45:25 +00:00
|
|
|
// Currently, we build with WINVER=0x601 (Win7), which means newer
|
|
|
|
// declarations in dwrite_3.h will not be visible. Also, we don't
|
|
|
|
// yet have the Fall Creators Update SDK available on build machines,
|
|
|
|
// so even with updated WINVER, some of the interfaces we need would
|
|
|
|
// not be present.
|
|
|
|
// To work around this, until the build environment is updated,
|
|
|
|
// we #include an extra header that contains copies of the relevant
|
|
|
|
// classes/interfaces we need.
|
2018-01-22 21:01:49 +00:00
|
|
|
#if !defined(__MINGW32__) && WINVER < 0x0A00
|
2018-02-26 21:21:01 +00:00
|
|
|
# include "mozilla/gfx/dw-extra.h"
|
2018-01-18 17:45:25 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
#include "gfxFont.h"
|
|
|
|
#include "gfxUserFontSet.h"
|
|
|
|
#include "cairo-win32.h"
|
|
|
|
|
|
|
|
#include "gfxPlatformFontList.h"
|
2011-06-03 04:31:08 +00:00
|
|
|
#include "gfxPlatform.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
2010-02-26 06:36:07 +00:00
|
|
|
|
2017-04-06 21:41:02 +00:00
|
|
|
#include "mozilla/gfx/UnscaledFontDWrite.h"
|
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
/**
|
|
|
|
* gfxDWriteFontFamily is a class that describes one of the fonts on the
|
|
|
|
* users system. It holds each gfxDWriteFontEntry (maps more directly to
|
|
|
|
* a font face) which holds font type, charset info and character map info.
|
|
|
|
*/
|
|
|
|
class gfxDWriteFontEntry;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Class representing directwrite font family.
|
|
|
|
*/
|
|
|
|
class gfxDWriteFontFamily : public gfxFontFamily {
|
|
|
|
public:
|
2018-04-23 14:52:20 +00:00
|
|
|
typedef mozilla::FontStretch FontStretch;
|
|
|
|
typedef mozilla::FontSlantStyle FontSlantStyle;
|
2018-04-13 19:34:37 +00:00
|
|
|
typedef mozilla::FontWeight FontWeight;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
/**
|
|
|
|
* Constructs a new DWriteFont Family.
|
|
|
|
*
|
|
|
|
* \param aName Name identifying the family
|
|
|
|
* \param aFamily IDWriteFontFamily object representing the directwrite
|
|
|
|
* family object.
|
|
|
|
*/
|
2018-09-12 19:34:57 +00:00
|
|
|
gfxDWriteFontFamily(const nsACString& aName, IDWriteFontFamily* aFamily,
|
2017-11-07 01:20:43 +00:00
|
|
|
bool aIsSystemFontFamily = false)
|
|
|
|
: gfxFontFamily(aName),
|
|
|
|
mDWFamily(aFamily),
|
|
|
|
mIsSystemFontFamily(aIsSystemFontFamily),
|
|
|
|
mForceGDIClassic(false) {}
|
2010-02-26 06:36:07 +00:00
|
|
|
virtual ~gfxDWriteFontFamily();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2018-02-06 06:46:57 +00:00
|
|
|
void FindStyleVariations(FontInfoData* aFontInfoData = nullptr) final;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2018-09-12 19:34:57 +00:00
|
|
|
void LocalizedName(nsACString& aLocalizedName) final;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-08-22 20:38:50 +00:00
|
|
|
void ReadFaceNames(gfxPlatformFontList* aPlatformFontList,
|
|
|
|
bool aNeedFullnamePostscriptNames,
|
2018-02-06 06:46:57 +00:00
|
|
|
FontInfoData* aFontInfoData = nullptr) final;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2011-06-03 04:31:07 +00:00
|
|
|
void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; }
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-08-22 20:38:50 +00:00
|
|
|
void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
2018-02-06 06:46:57 +00:00
|
|
|
FontListSizes* aSizes) const final;
|
2016-08-22 20:38:50 +00:00
|
|
|
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
2018-02-06 06:46:57 +00:00
|
|
|
FontListSizes* aSizes) const final;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2017-10-02 22:05:19 +00:00
|
|
|
bool FilterForFontList(nsAtom* aLangGroup,
|
2018-02-06 06:46:57 +00:00
|
|
|
const nsACString& aGeneric) const final {
|
2017-09-11 18:24:01 +00:00
|
|
|
return !IsSymbolFontFamily();
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
protected:
|
2017-09-11 18:24:01 +00:00
|
|
|
// helper for FilterForFontList
|
|
|
|
bool IsSymbolFontFamily() const;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
/** This font family's directwrite fontfamily object */
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDWriteFontFamily> mDWFamily;
|
2017-11-07 01:20:43 +00:00
|
|
|
bool mIsSystemFontFamily;
|
2011-06-03 04:31:07 +00:00
|
|
|
bool mForceGDIClassic;
|
2010-02-26 06:36:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Class representing DirectWrite FontEntry (a unique font style/family)
|
|
|
|
*/
|
|
|
|
class gfxDWriteFontEntry : public gfxFontEntry {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructs a font entry.
|
|
|
|
*
|
|
|
|
* \param aFaceName The name of the corresponding font face.
|
|
|
|
* \param aFont DirectWrite font object
|
|
|
|
*/
|
2018-09-12 19:34:57 +00:00
|
|
|
gfxDWriteFontEntry(const nsACString& aFaceName, IDWriteFont* aFont,
|
2017-11-07 01:20:43 +00:00
|
|
|
bool aIsSystemFont = false)
|
2012-07-30 14:20:58 +00:00
|
|
|
: gfxFontEntry(aFaceName),
|
|
|
|
mFont(aFont),
|
|
|
|
mFontFile(nullptr),
|
2018-01-18 17:45:24 +00:00
|
|
|
mIsSystemFont(aIsSystemFont),
|
|
|
|
mForceGDIClassic(false),
|
|
|
|
mHasVariations(false),
|
|
|
|
mHasVariationsInitialized(false) {
|
2015-10-19 02:16:43 +00:00
|
|
|
DWRITE_FONT_STYLE dwriteStyle = aFont->GetStyle();
|
2018-04-25 06:18:23 +00:00
|
|
|
FontSlantStyle style = (dwriteStyle == DWRITE_FONT_STYLE_ITALIC
|
|
|
|
? FontSlantStyle::Italic()
|
|
|
|
: (dwriteStyle == DWRITE_FONT_STYLE_OBLIQUE
|
|
|
|
? FontSlantStyle::Oblique()
|
|
|
|
: FontSlantStyle::Normal()));
|
|
|
|
mStyleRange = SlantStyleRange(style);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2018-04-25 06:18:23 +00:00
|
|
|
mStretchRange =
|
|
|
|
StretchRange(FontStretchFromDWriteStretch(aFont->GetStretch()));
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2018-04-25 06:18:23 +00:00
|
|
|
int weight = NS_ROUNDUP(aFont->GetWeight() - 50, 100);
|
2018-04-16 19:26:08 +00:00
|
|
|
weight = mozilla::Clamp(weight, 100, 900);
|
2018-04-25 06:18:23 +00:00
|
|
|
mWeightRange = WeightRange(FontWeight(weight));
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2011-01-25 09:17:18 +00:00
|
|
|
mIsCJK = UNINITIALIZED_VALUE;
|
2010-02-26 06:36:07 +00:00
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
/**
|
|
|
|
* Constructs a font entry using a font. But with custom font values.
|
|
|
|
* This is used for creating correct font entries for @font-face with local
|
|
|
|
* font source.
|
|
|
|
*
|
|
|
|
* \param aFaceName The name of the corresponding font face.
|
|
|
|
* \param aFont DirectWrite font object
|
|
|
|
* \param aWeight Weight of the font
|
|
|
|
* \param aStretch Stretch of the font
|
2015-10-19 02:16:43 +00:00
|
|
|
* \param aStyle italic or oblique of font
|
2010-02-26 06:36:07 +00:00
|
|
|
*/
|
2018-09-12 19:34:57 +00:00
|
|
|
gfxDWriteFontEntry(const nsACString& aFaceName, IDWriteFont* aFont,
|
2018-04-25 06:18:23 +00:00
|
|
|
WeightRange aWeight, StretchRange aStretch,
|
|
|
|
SlantStyleRange aStyle)
|
2012-07-30 14:20:58 +00:00
|
|
|
: gfxFontEntry(aFaceName),
|
|
|
|
mFont(aFont),
|
|
|
|
mFontFile(nullptr),
|
2018-01-18 17:45:24 +00:00
|
|
|
mIsSystemFont(false),
|
|
|
|
mForceGDIClassic(false),
|
|
|
|
mHasVariations(false),
|
|
|
|
mHasVariationsInitialized(false) {
|
2018-04-25 06:18:23 +00:00
|
|
|
mWeightRange = aWeight;
|
|
|
|
mStretchRange = aStretch;
|
|
|
|
mStyleRange = aStyle;
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsLocalUserFont = true;
|
2011-01-25 09:17:18 +00:00
|
|
|
mIsCJK = UNINITIALIZED_VALUE;
|
2010-02-26 06:36:07 +00:00
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
/**
|
|
|
|
* Constructs a font entry using a font file.
|
|
|
|
*
|
|
|
|
* \param aFaceName The name of the corresponding font face.
|
|
|
|
* \param aFontFile DirectWrite fontfile object
|
2016-01-05 10:08:57 +00:00
|
|
|
* \param aFontFileStream DirectWrite fontfile stream object
|
2010-02-26 06:36:07 +00:00
|
|
|
* \param aWeight Weight of the font
|
|
|
|
* \param aStretch Stretch of the font
|
2015-10-19 02:16:43 +00:00
|
|
|
* \param aStyle italic or oblique of font
|
2010-02-26 06:36:07 +00:00
|
|
|
*/
|
2018-09-12 19:34:57 +00:00
|
|
|
gfxDWriteFontEntry(const nsACString& aFaceName, IDWriteFontFile* aFontFile,
|
2016-01-05 10:08:57 +00:00
|
|
|
IDWriteFontFileStream* aFontFileStream,
|
2018-04-25 06:18:23 +00:00
|
|
|
WeightRange aWeight, StretchRange aStretch,
|
|
|
|
SlantStyleRange aStyle)
|
2017-11-07 01:20:43 +00:00
|
|
|
: gfxFontEntry(aFaceName),
|
|
|
|
mFont(nullptr),
|
|
|
|
mFontFile(aFontFile),
|
|
|
|
mFontFileStream(aFontFileStream),
|
2018-01-18 17:45:24 +00:00
|
|
|
mIsSystemFont(false),
|
|
|
|
mForceGDIClassic(false),
|
|
|
|
mHasVariations(false),
|
|
|
|
mHasVariationsInitialized(false) {
|
2018-04-25 06:18:23 +00:00
|
|
|
mWeightRange = aWeight;
|
|
|
|
mStretchRange = aStretch;
|
|
|
|
mStyleRange = aStyle;
|
2014-09-08 07:23:20 +00:00
|
|
|
mIsDataUserFont = true;
|
2011-01-25 09:17:18 +00:00
|
|
|
mIsCJK = UNINITIALIZED_VALUE;
|
2010-02-26 06:36:07 +00:00
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2017-08-01 10:25:35 +00:00
|
|
|
gfxFontEntry* Clone() const override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
virtual ~gfxDWriteFontEntry();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
hb_blob_t* GetFontTable(uint32_t aTableTag) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2014-01-29 07:39:01 +00:00
|
|
|
nsresult ReadCMAP(FontInfoData* aFontInfoData = nullptr);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsCJKFont();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2018-01-18 17:45:27 +00:00
|
|
|
bool HasVariations() override;
|
|
|
|
void GetVariationAxes(nsTArray<gfxFontVariationAxis>& aAxes) override;
|
2018-01-29 13:24:11 +00:00
|
|
|
void GetVariationInstances(
|
|
|
|
nsTArray<gfxFontVariationInstance>& aInstances) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2011-06-03 04:31:07 +00:00
|
|
|
void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; }
|
|
|
|
bool GetForceGDIClassic() { return mForceGDIClassic; }
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-10-15 02:19:47 +00:00
|
|
|
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const;
|
|
|
|
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
protected:
|
|
|
|
friend class gfxDWriteFont;
|
|
|
|
friend class gfxDWriteFontList;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-05-16 16:29:20 +00:00
|
|
|
virtual nsresult CopyFontTable(uint32_t aTableTag,
|
2016-02-02 15:36:30 +00:00
|
|
|
nsTArray<uint8_t>& aBuffer) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
Bug 1449605 - part 1 - Rearrange thebes font code so that the decision whether to apply synthetic-bold is deferred until actually instantiating a font, not made during the font-matching process. r=jwatt
This rearranges how synthetic-bold use is determined in the font selection
& rendering code. Previously, we would decide during the font-selection
algorithm whether we need to apply synthetic-bold to the chosen face, and
then pass that decision through the fontgroup (storing it in the FamilyFace
entries of the mFonts array there) down to the actual rendering code that
instantiates fonts from the faces (font entries) we've selected.
That became a problem for variation fonts because in the case of a user
font, we may not have downloaded the resource yet, so we just have a "user
font container" entry, which carries the descriptors from the @font-face
rule and will fetch the actual resource when needed. But in the case of a
@font-face rule without a weight descriptor, we don't actually know at
font-selection time whether the face will support "true" bold (via a
variation axis) or not, so we can't reliably make the right decision about
applying synthetic bold.
So we now defer that decision until we actually instantiate a platform font
object to shape/measure/draw text. At that point, we have the requested
style and we also have the real font resource, so we can easily determine
whether fake-bold is required.
(This patch should not result in any visible behavior change; that will
come in a second patch now that the architecture supports it.)
2018-05-01 09:30:50 +00:00
|
|
|
virtual gfxFont* CreateFontInstance(const gfxFontStyle* aFontStyle);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
nsresult CreateFontFace(
|
2018-04-25 06:18:23 +00:00
|
|
|
IDWriteFontFace** aFontFace, const gfxFontStyle* aFontStyle = nullptr,
|
2010-02-26 06:36:07 +00:00
|
|
|
DWRITE_FONT_SIMULATIONS aSimulations = DWRITE_FONT_SIMULATIONS_NONE);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool InitLogFont(IDWriteFont* aFont, LOGFONTW* aLogFont);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
/**
|
|
|
|
* A fontentry only needs to have either of these. If it has both only
|
|
|
|
* the IDWriteFont will be used.
|
|
|
|
*/
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDWriteFont> mFont;
|
|
|
|
RefPtr<IDWriteFontFile> mFontFile;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-01-05 10:08:57 +00:00
|
|
|
// For custom fonts, we hold a reference to the IDWriteFontFileStream for
|
|
|
|
// for the IDWriteFontFile, so that the data is available.
|
|
|
|
RefPtr<IDWriteFontFileStream> mFontFileStream;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-05-16 16:29:20 +00:00
|
|
|
// font face corresponding to the mFont/mFontFile *without* any DWrite
|
|
|
|
// style simulations applied
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDWriteFontFace> mFontFace;
|
2018-01-18 17:45:24 +00:00
|
|
|
// Extended fontface interface if supported, else null
|
|
|
|
RefPtr<IDWriteFontFace5> mFontFace5;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
DWRITE_FONT_FACE_TYPE mFaceType;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int8_t mIsCJK;
|
2017-11-07 01:20:43 +00:00
|
|
|
bool mIsSystemFont;
|
2011-06-03 04:31:07 +00:00
|
|
|
bool mForceGDIClassic;
|
2018-01-18 17:45:24 +00:00
|
|
|
bool mHasVariations;
|
|
|
|
bool mHasVariationsInitialized;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2017-10-18 18:22:09 +00:00
|
|
|
mozilla::ThreadSafeWeakPtr<mozilla::gfx::UnscaledFontDWrite> mUnscaledFont;
|
|
|
|
mozilla::ThreadSafeWeakPtr<mozilla::gfx::UnscaledFontDWrite>
|
|
|
|
mUnscaledFontBold;
|
2010-02-26 06:36:07 +00:00
|
|
|
};
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
// custom text renderer used to determine the fallback font for a given char
|
2015-12-18 18:53:25 +00:00
|
|
|
class DWriteFontFallbackRenderer final : public IDWriteTextRenderer {
|
2012-03-09 02:05:55 +00:00
|
|
|
public:
|
2016-12-16 07:54:32 +00:00
|
|
|
explicit DWriteFontFallbackRenderer(IDWriteFactory* aFactory) : mRefCount(0) {
|
2012-03-09 02:05:55 +00:00
|
|
|
HRESULT hr = S_OK;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
hr = aFactory->GetSystemFontCollection(getter_AddRefs(mSystemFonts));
|
|
|
|
NS_ASSERTION(SUCCEEDED(hr), "GetSystemFontCollection failed!");
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2015-12-18 18:53:25 +00:00
|
|
|
~DWriteFontFallbackRenderer() {}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
// IDWriteTextRenderer methods
|
|
|
|
IFACEMETHOD(DrawGlyphRun)
|
2012-04-04 09:12:11 +00:00
|
|
|
(void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY,
|
|
|
|
DWRITE_MEASURING_MODE measuringMode, DWRITE_GLYPH_RUN const* glyphRun,
|
|
|
|
DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
|
|
|
|
IUnknown* clientDrawingEffect);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
IFACEMETHOD(DrawUnderline)
|
2012-04-04 09:12:11 +00:00
|
|
|
(void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY,
|
|
|
|
DWRITE_UNDERLINE const* underline, IUnknown* clientDrawingEffect) {
|
2012-03-09 02:05:55 +00:00
|
|
|
return E_NOTIMPL;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
IFACEMETHOD(DrawStrikethrough)
|
2012-04-04 09:12:11 +00:00
|
|
|
(void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY,
|
|
|
|
DWRITE_STRIKETHROUGH const* strikethrough, IUnknown* clientDrawingEffect) {
|
2012-03-09 02:05:55 +00:00
|
|
|
return E_NOTIMPL;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
IFACEMETHOD(DrawInlineObject)
|
2012-04-04 09:12:11 +00:00
|
|
|
(void* clientDrawingContext, FLOAT originX, FLOAT originY,
|
2012-03-09 02:05:55 +00:00
|
|
|
IDWriteInlineObject* inlineObject, BOOL isSideways, BOOL isRightToLeft,
|
2012-04-04 09:12:11 +00:00
|
|
|
IUnknown* clientDrawingEffect) {
|
2012-03-09 02:05:55 +00:00
|
|
|
return E_NOTIMPL;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
// IDWritePixelSnapping methods
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
IFACEMETHOD(IsPixelSnappingDisabled)
|
2012-04-04 09:12:11 +00:00
|
|
|
(void* clientDrawingContext, BOOL* isDisabled) {
|
2012-03-09 02:05:55 +00:00
|
|
|
*isDisabled = FALSE;
|
|
|
|
return S_OK;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
IFACEMETHOD(GetCurrentTransform)
|
2012-04-04 09:12:11 +00:00
|
|
|
(void* clientDrawingContext, DWRITE_MATRIX* transform) {
|
2012-03-09 02:05:55 +00:00
|
|
|
const DWRITE_MATRIX ident = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
|
|
|
|
*transform = ident;
|
|
|
|
return S_OK;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
IFACEMETHOD(GetPixelsPerDip)
|
2012-04-04 09:12:11 +00:00
|
|
|
(void* clientDrawingContext, FLOAT* pixelsPerDip) {
|
2012-03-09 02:05:55 +00:00
|
|
|
*pixelsPerDip = 1.0f;
|
|
|
|
return S_OK;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
// IUnknown methods
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
IFACEMETHOD_(unsigned long, AddRef)() {
|
|
|
|
return InterlockedIncrement(&mRefCount);
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
IFACEMETHOD_(unsigned long, Release)() {
|
|
|
|
unsigned long newCount = InterlockedDecrement(&mRefCount);
|
|
|
|
if (newCount == 0) {
|
|
|
|
delete this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-18 18:53:25 +00:00
|
|
|
return newCount;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2015-12-18 18:53:25 +00:00
|
|
|
IFACEMETHOD(QueryInterface)(IID const& riid, void** ppvObject) {
|
2012-03-09 02:05:55 +00:00
|
|
|
if (__uuidof(IDWriteTextRenderer) == riid) {
|
|
|
|
*ppvObject = this;
|
|
|
|
} else if (__uuidof(IDWritePixelSnapping) == riid) {
|
2012-04-04 09:12:11 +00:00
|
|
|
*ppvObject = this;
|
|
|
|
} else if (__uuidof(IUnknown) == riid) {
|
2012-03-09 02:05:55 +00:00
|
|
|
*ppvObject = this;
|
|
|
|
} else {
|
2012-04-04 09:12:11 +00:00
|
|
|
*ppvObject = nullptr;
|
2012-03-09 02:05:55 +00:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->AddRef();
|
|
|
|
return S_OK;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2012-03-09 02:05:55 +00:00
|
|
|
|
|
|
|
const nsCString& FallbackFamilyName() { return mFamilyName; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
long mRefCount;
|
|
|
|
RefPtr<IDWriteFontCollection> mSystemFonts;
|
2018-09-12 19:34:57 +00:00
|
|
|
nsCString mFamilyName;
|
2012-03-09 02:05:55 +00:00
|
|
|
};
|
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
class gfxDWriteFontList : public gfxPlatformFontList {
|
|
|
|
public:
|
|
|
|
gfxDWriteFontList();
|
|
|
|
|
|
|
|
static gfxDWriteFontList* PlatformFontList() {
|
|
|
|
return static_cast<gfxDWriteFontList*>(sPlatformFontList);
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-11-08 11:02:27 +00:00
|
|
|
// initialize font lists
|
2019-04-11 12:36:51 +00:00
|
|
|
nsresult InitFontListForPlatform() override;
|
2019-04-27 15:39:25 +00:00
|
|
|
void InitSharedFontListForPlatform() override;
|
2010-02-26 06:36:07 +00:00
|
|
|
|
2016-08-23 00:06:07 +00:00
|
|
|
gfxFontFamily* CreateFontFamily(const nsACString& aName) const override;
|
2010-02-26 06:36:07 +00:00
|
|
|
|
2019-04-27 15:39:25 +00:00
|
|
|
gfxFontEntry* CreateFontEntry(
|
|
|
|
mozilla::fontlist::Face* aFace,
|
|
|
|
const mozilla::fontlist::Family* aFamily) override;
|
2017-08-01 10:25:35 +00:00
|
|
|
|
2019-04-27 15:39:25 +00:00
|
|
|
void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily,
|
|
|
|
bool aNeedFullnamePostscriptNames) override;
|
|
|
|
|
|
|
|
bool ReadFaceNames(mozilla::fontlist::Family* aFamily,
|
|
|
|
mozilla::fontlist::Face* aFace, nsCString& aPSName,
|
|
|
|
nsCString& aFullName) override;
|
|
|
|
|
|
|
|
void GetFacesInitDataForFamily(
|
|
|
|
const mozilla::fontlist::Family* aFamily,
|
|
|
|
nsTArray<mozilla::fontlist::Face::InitData>& aFaces) const override;
|
|
|
|
|
|
|
|
gfxFontEntry* LookupLocalFont(const nsACString& aFontName,
|
|
|
|
WeightRange aWeightForEntry,
|
|
|
|
StretchRange aStretchForEntry,
|
|
|
|
SlantStyleRange aStyleForEntry) override;
|
|
|
|
|
|
|
|
gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
|
|
|
|
WeightRange aWeightForEntry,
|
|
|
|
StretchRange aStretchForEntry,
|
|
|
|
SlantStyleRange aStyleForEntry,
|
|
|
|
const uint8_t* aFontData,
|
|
|
|
uint32_t aLength) override;
|
2014-09-08 07:23:19 +00:00
|
|
|
|
2011-01-21 16:44:32 +00:00
|
|
|
IDWriteGdiInterop* GetGDIInterop() { return mGDIInterop; }
|
2011-09-29 06:19:26 +00:00
|
|
|
bool UseGDIFontTableAccess() { return mGDIFontTableAccess; }
|
2011-01-21 16:44:32 +00:00
|
|
|
|
2019-04-27 15:37:58 +00:00
|
|
|
bool FindAndAddFamilies(mozilla::StyleGenericFontFamily aGeneric,
|
|
|
|
const nsACString& aFamily,
|
2018-05-25 13:07:57 +00:00
|
|
|
nsTArray<FamilyAndGeneric>* aOutput,
|
2017-08-01 10:25:35 +00:00
|
|
|
FindFamiliesFlags aFlags,
|
2016-04-12 06:06:22 +00:00
|
|
|
gfxFontStyle* aStyle = nullptr,
|
|
|
|
gfxFloat aDevToCssSize = 1.0) override;
|
2011-01-21 16:44:33 +00:00
|
|
|
|
2011-06-03 04:31:08 +00:00
|
|
|
gfxFloat GetForceGDIClassicMaxFontSize() {
|
|
|
|
return mForceGDIClassicMaxFontSize;
|
|
|
|
}
|
|
|
|
|
2013-10-15 02:19:47 +00:00
|
|
|
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const;
|
|
|
|
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const;
|
2012-03-27 21:38:39 +00:00
|
|
|
|
2016-08-23 00:06:07 +00:00
|
|
|
protected:
|
2019-04-01 14:33:34 +00:00
|
|
|
FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
2016-08-23 00:06:07 +00:00
|
|
|
|
2017-07-13 08:40:33 +00:00
|
|
|
// attempt to use platform-specific fallback for the given character,
|
|
|
|
// return null if no usable result found
|
2019-04-01 14:33:34 +00:00
|
|
|
gfxFontEntry* PlatformGlobalFontFallback(const uint32_t aCh,
|
|
|
|
Script aRunScript,
|
|
|
|
const gfxFontStyle* aMatchStyle,
|
|
|
|
FontFamily* aMatchedFamily) override;
|
2017-07-13 08:40:33 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
private:
|
|
|
|
friend class gfxDWriteFontFamily;
|
|
|
|
|
2010-03-03 06:57:43 +00:00
|
|
|
nsresult GetFontSubstitutes();
|
|
|
|
|
2011-03-24 20:11:38 +00:00
|
|
|
void GetDirectWriteSubstitutes();
|
|
|
|
|
2012-03-09 02:05:55 +00:00
|
|
|
virtual bool UsesSystemFallback() { return true; }
|
|
|
|
|
2014-05-29 12:01:07 +00:00
|
|
|
void GetFontsFromCollection(IDWriteFontCollection* aCollection);
|
|
|
|
|
2019-04-27 15:39:25 +00:00
|
|
|
void AppendFamiliesFromCollection(
|
|
|
|
IDWriteFontCollection* aCollection,
|
|
|
|
nsTArray<mozilla::fontlist::Family::InitData>& aFamilies,
|
|
|
|
const nsTArray<nsCString>* aForceClassicFams = nullptr);
|
|
|
|
|
2014-05-29 12:01:07 +00:00
|
|
|
#ifdef MOZ_BUNDLED_FONTS
|
|
|
|
already_AddRefed<IDWriteFontCollection> CreateBundledFontsCollection(
|
|
|
|
IDWriteFactory* aFactory);
|
|
|
|
#endif
|
|
|
|
|
2010-03-03 06:57:43 +00:00
|
|
|
/**
|
|
|
|
* Fonts listed in the registry as substitutes but for which no actual
|
|
|
|
* font family is found.
|
|
|
|
*/
|
2018-09-12 19:34:57 +00:00
|
|
|
nsTArray<nsCString> mNonExistingFonts;
|
2010-03-03 06:57:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Table of font substitutes, we grab this from the registry to get
|
|
|
|
* alternative font names.
|
|
|
|
*/
|
2015-07-31 04:15:16 +00:00
|
|
|
FontFamilyTable mFontSubstitutes;
|
2019-04-27 15:39:25 +00:00
|
|
|
nsClassHashtable<nsCStringHashKey, nsCString> mSubstitutions;
|
2011-01-21 16:44:32 +00:00
|
|
|
|
2014-01-29 07:39:01 +00:00
|
|
|
virtual already_AddRefed<FontInfoData> CreateFontInfoData();
|
|
|
|
|
2011-06-03 04:31:08 +00:00
|
|
|
gfxFloat mForceGDIClassicMaxFontSize;
|
|
|
|
|
2011-01-21 16:44:32 +00:00
|
|
|
// whether to use GDI font table access routines
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mGDIFontTableAccess;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDWriteGdiInterop> mGDIInterop;
|
2012-03-09 02:05:55 +00:00
|
|
|
|
2015-12-18 18:53:25 +00:00
|
|
|
RefPtr<DWriteFontFallbackRenderer> mFallbackRenderer;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDWriteTextFormat> mFallbackFormat;
|
2014-05-29 12:01:07 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDWriteFontCollection> mSystemFonts;
|
2014-05-29 12:01:07 +00:00
|
|
|
#ifdef MOZ_BUNDLED_FONTS
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<IDWriteFontCollection> mBundledFonts;
|
2014-05-29 12:01:07 +00:00
|
|
|
#endif
|
2010-02-26 06:36:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_DWRITEFONTLIST_H */
|