2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2015-05-13 08:11:25 +03: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/. */
|
|
|
|
|
|
|
|
#ifndef GFXFCPLATFORMFONTLIST_H_
|
|
|
|
#define GFXFCPLATFORMFONTLIST_H_
|
|
|
|
|
|
|
|
#include "gfxFT2FontBase.h"
|
|
|
|
#include "gfxPlatformFontList.h"
|
2018-04-13 22:34:37 +03:00
|
|
|
#include "mozilla/FontPropertyTypes.h"
|
2015-05-13 08:11:25 +03:00
|
|
|
#include "mozilla/mozalloc.h"
|
2017-08-07 23:20:37 +03:00
|
|
|
#include "nsAutoRef.h"
|
2016-04-15 22:45:37 +03:00
|
|
|
#include "nsClassHashtable.h"
|
2015-05-13 08:11:25 +03:00
|
|
|
|
|
|
|
#include <fontconfig/fontconfig.h>
|
|
|
|
#include "ft2build.h"
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
#include FT_TRUETYPE_TABLES_H
|
2018-01-29 16:24:11 +03:00
|
|
|
#include FT_MULTIPLE_MASTERS_H
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2019-03-19 01:31:59 +03:00
|
|
|
#if defined(MOZ_SANDBOX) && defined(XP_LINUX)
|
2017-11-09 19:54:30 +03:00
|
|
|
# include "mozilla/SandboxBroker.h"
|
|
|
|
#endif
|
|
|
|
|
2017-11-02 23:29:33 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class SystemFontListEntry;
|
|
|
|
};
|
|
|
|
}; // namespace mozilla
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
template <>
|
2017-08-07 23:20:37 +03:00
|
|
|
class nsAutoRefTraits<FcPattern> : public nsPointerRefTraits<FcPattern> {
|
2015-05-13 08:11:25 +03:00
|
|
|
public:
|
2017-08-07 23:20:37 +03:00
|
|
|
static void Release(FcPattern* ptr) { FcPatternDestroy(ptr); }
|
|
|
|
static void AddRef(FcPattern* ptr) { FcPatternReference(ptr); }
|
2015-05-13 08:11:25 +03:00
|
|
|
};
|
|
|
|
|
2015-05-13 08:11:26 +03:00
|
|
|
template <>
|
|
|
|
class nsAutoRefTraits<FcConfig> : public nsPointerRefTraits<FcConfig> {
|
|
|
|
public:
|
|
|
|
static void Release(FcConfig* ptr) { FcConfigDestroy(ptr); }
|
|
|
|
static void AddRef(FcConfig* ptr) { FcConfigReference(ptr); }
|
|
|
|
};
|
2015-05-13 08:11:25 +03:00
|
|
|
|
|
|
|
// The names for the font entry and font classes should really
|
|
|
|
// the common 'Fc' abbreviation but the gfxPangoFontGroup code already
|
|
|
|
// defines versions of these, so use the verbose name for now.
|
|
|
|
|
2020-03-10 18:00:56 +03:00
|
|
|
class gfxFontconfigFontEntry final : public gfxFT2FontEntryBase {
|
2020-07-06 17:29:23 +03:00
|
|
|
friend class gfxFcPlatformFontList;
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
public:
|
|
|
|
// used for system fonts with explicit patterns
|
2018-09-12 22:34:57 +03:00
|
|
|
explicit gfxFontconfigFontEntry(const nsACString& aFaceName,
|
2016-06-15 16:35:05 +03:00
|
|
|
FcPattern* aFontPattern,
|
|
|
|
bool aIgnoreFcCharmap);
|
2015-05-13 08:11:25 +03:00
|
|
|
|
|
|
|
// used for data fonts where the fontentry takes ownership
|
|
|
|
// of the font data and the FT_Face
|
2018-09-12 22:34:57 +03:00
|
|
|
explicit gfxFontconfigFontEntry(const nsACString& aFaceName,
|
2018-04-25 09:18:23 +03:00
|
|
|
WeightRange aWeight, StretchRange aStretch,
|
2019-09-16 20:07:59 +03:00
|
|
|
SlantStyleRange aStyle,
|
|
|
|
RefPtr<mozilla::gfx::SharedFTFace>&& aFace);
|
2015-05-13 08:11:25 +03:00
|
|
|
|
|
|
|
// used for @font-face local system fonts with explicit patterns
|
2018-09-12 22:34:57 +03:00
|
|
|
explicit gfxFontconfigFontEntry(const nsACString& aFaceName,
|
2015-05-13 08:11:25 +03:00
|
|
|
FcPattern* aFontPattern, WeightRange aWeight,
|
2018-04-25 09:18:23 +03:00
|
|
|
StretchRange aStretch,
|
|
|
|
SlantStyleRange aStyle);
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2017-08-01 13:25:35 +03:00
|
|
|
gfxFontEntry* Clone() const override;
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
FcPattern* GetPattern() { return mFontPattern; }
|
|
|
|
|
|
|
|
nsresult ReadCMAP(FontInfoData* aFontInfoData = nullptr) override;
|
|
|
|
bool TestCharacterMap(uint32_t aCh) override;
|
|
|
|
|
2019-09-16 20:07:59 +03:00
|
|
|
const RefPtr<mozilla::gfx::SharedFTFace>& GetFTFace();
|
|
|
|
FTUserFontData* GetUserFontData();
|
2017-12-07 16:22:49 +03:00
|
|
|
|
2018-08-02 00:39:05 +03:00
|
|
|
FT_MM_Var* GetMMVar() override;
|
2018-01-29 16:24:11 +03:00
|
|
|
|
2018-01-18 22:27:41 +03:00
|
|
|
bool HasVariations() override;
|
|
|
|
void GetVariationAxes(nsTArray<gfxFontVariationAxis>& aAxes) override;
|
2018-01-29 16:24:11 +03:00
|
|
|
void GetVariationInstances(
|
|
|
|
nsTArray<gfxFontVariationInstance>& aInstances) override;
|
2018-01-18 22:27:41 +03:00
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
hb_blob_t* GetFontTable(uint32_t aTableTag) override;
|
|
|
|
|
2017-03-29 20:47:46 +03:00
|
|
|
double GetAspect();
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
protected:
|
2015-05-13 08:11:26 +03:00
|
|
|
virtual ~gfxFontconfigFontEntry();
|
2015-05-13 08:11:25 +03: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 12:30:50 +03:00
|
|
|
gfxFont* CreateFontInstance(const gfxFontStyle* aFontStyle) override;
|
2015-05-13 08:11:25 +03:00
|
|
|
|
|
|
|
// override to pull data from FTFace
|
|
|
|
virtual nsresult CopyFontTable(uint32_t aTableTag,
|
2016-02-02 18:36:30 +03:00
|
|
|
nsTArray<uint8_t>& aBuffer) override;
|
2015-05-13 08:11:25 +03:00
|
|
|
|
|
|
|
// pattern for a single face of a family
|
|
|
|
nsCountedRef<FcPattern> mFontPattern;
|
|
|
|
|
|
|
|
// FTFace - initialized when needed
|
2019-09-16 20:07:59 +03:00
|
|
|
RefPtr<mozilla::gfx::SharedFTFace> mFTFace;
|
2015-05-13 08:11:25 +03:00
|
|
|
bool mFTFaceInitialized;
|
2016-06-15 16:35:05 +03:00
|
|
|
|
|
|
|
// Whether TestCharacterMap should check the actual cmap rather than asking
|
|
|
|
// fontconfig about character coverage.
|
|
|
|
// We do this for app-bundled (rather than system) fonts, as they may
|
|
|
|
// include color glyphs that fontconfig would overlook, and for fonts
|
|
|
|
// loaded via @font-face.
|
|
|
|
bool mIgnoreFcCharmap;
|
|
|
|
|
2018-04-25 09:18:23 +03:00
|
|
|
// Whether the face supports variations. For system-installed fonts, we
|
|
|
|
// query fontconfig for this (so they will only work if fontconfig is
|
|
|
|
// recent enough to include support); for downloaded user-fonts we query
|
|
|
|
// the FreeType face.
|
|
|
|
bool mHasVariations;
|
|
|
|
bool mHasVariationsInitialized;
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
double mAspect;
|
|
|
|
|
2017-04-07 00:41:02 +03:00
|
|
|
class UnscaledFontCache {
|
|
|
|
public:
|
|
|
|
already_AddRefed<mozilla::gfx::UnscaledFontFontconfig> Lookup(
|
2019-09-16 20:07:59 +03:00
|
|
|
const std::string& aFile, uint32_t aIndex);
|
2017-04-07 00:41:02 +03:00
|
|
|
|
|
|
|
void Add(
|
|
|
|
const RefPtr<mozilla::gfx::UnscaledFontFontconfig>& aUnscaledFont) {
|
|
|
|
mUnscaledFonts[kNumEntries - 1] = aUnscaledFont;
|
|
|
|
MoveToFront(kNumEntries - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void MoveToFront(size_t aIndex);
|
|
|
|
|
|
|
|
static const size_t kNumEntries = 3;
|
2017-10-18 21:22:09 +03:00
|
|
|
mozilla::ThreadSafeWeakPtr<mozilla::gfx::UnscaledFontFontconfig>
|
|
|
|
mUnscaledFonts[kNumEntries];
|
2017-04-07 00:41:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
UnscaledFontCache mUnscaledFontCache;
|
2018-01-29 16:24:11 +03:00
|
|
|
|
|
|
|
// Because of FreeType bug 52955, we keep the FT_MM_Var struct when it is
|
|
|
|
// first loaded, rather than releasing it and re-fetching it as needed.
|
|
|
|
FT_MM_Var* mMMVar = nullptr;
|
|
|
|
bool mMMVarInitialized = false;
|
2015-05-13 08:11:25 +03:00
|
|
|
};
|
|
|
|
|
2020-03-10 18:00:56 +03:00
|
|
|
class gfxFontconfigFontFamily final : public gfxFontFamily {
|
2015-05-13 08:11:25 +03:00
|
|
|
public:
|
2020-04-02 15:36:24 +03:00
|
|
|
gfxFontconfigFontFamily(const nsACString& aName, FontVisibility aVisibility)
|
|
|
|
: gfxFontFamily(aName, aVisibility),
|
2017-03-29 20:47:46 +03:00
|
|
|
mContainsAppFonts(false),
|
2017-05-05 22:46:10 +03:00
|
|
|
mHasNonScalableFaces(false),
|
|
|
|
mForceScalable(false) {}
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2017-11-02 23:29:33 +03:00
|
|
|
template <typename Func>
|
|
|
|
void AddFacesToFontList(Func aAddPatternFunc);
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
void FindStyleVariations(FontInfoData* aFontInfoData = nullptr) override;
|
|
|
|
|
|
|
|
// Families are constructed initially with just references to patterns.
|
|
|
|
// When necessary, these are enumerated within FindStyleVariations.
|
|
|
|
void AddFontPattern(FcPattern* aFontPattern);
|
|
|
|
|
2016-06-15 16:35:05 +03:00
|
|
|
void SetFamilyContainsAppFonts(bool aContainsAppFonts) {
|
|
|
|
mContainsAppFonts = aContainsAppFonts;
|
|
|
|
}
|
|
|
|
|
2017-03-29 20:47:46 +03:00
|
|
|
void FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
|
|
|
|
nsTArray<gfxFontEntry*>& aFontEntryList,
|
2017-08-07 19:27:33 +03:00
|
|
|
bool aIgnoreSizeTolerance) override;
|
2017-03-29 20:47:46 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
bool FilterForFontList(nsAtom* aLangGroup,
|
2018-02-06 09:46:57 +03:00
|
|
|
const nsACString& aGeneric) const final {
|
2017-09-11 21:24:01 +03:00
|
|
|
return SupportsLangGroup(aLangGroup);
|
|
|
|
}
|
2017-09-11 21:22:15 +03:00
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
protected:
|
2017-04-08 01:49:44 +03:00
|
|
|
virtual ~gfxFontconfigFontFamily();
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2017-09-11 21:24:01 +03:00
|
|
|
// helper for FilterForFontList
|
2017-10-03 01:05:19 +03:00
|
|
|
bool SupportsLangGroup(nsAtom* aLangGroup) const;
|
2017-09-11 21:24:01 +03:00
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
nsTArray<nsCountedRef<FcPattern>> mFontPatterns;
|
2016-06-15 16:35:05 +03:00
|
|
|
|
|
|
|
bool mContainsAppFonts;
|
2017-03-29 20:47:46 +03:00
|
|
|
bool mHasNonScalableFaces;
|
2017-05-05 22:46:10 +03:00
|
|
|
bool mForceScalable;
|
2015-05-13 08:11:25 +03:00
|
|
|
};
|
|
|
|
|
2020-03-10 18:00:56 +03:00
|
|
|
class gfxFontconfigFont final : public gfxFT2FontBase {
|
2015-05-13 08:11:25 +03:00
|
|
|
public:
|
2017-04-07 00:41:02 +03:00
|
|
|
gfxFontconfigFont(
|
|
|
|
const RefPtr<mozilla::gfx::UnscaledFontFontconfig>& aUnscaledFont,
|
2019-09-16 20:07:59 +03:00
|
|
|
RefPtr<mozilla::gfx::SharedFTFace>&& aFTFace, FcPattern* aPattern,
|
2017-01-13 01:37:07 +03:00
|
|
|
gfxFloat aAdjustedSize, gfxFontEntry* aFontEntry,
|
2019-09-16 20:15:10 +03:00
|
|
|
const gfxFontStyle* aFontStyle, int aLoadFlags, bool aEmbolden);
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
FontType GetType() const override { return FONT_TYPE_FONTCONFIG; }
|
2019-10-02 00:56:30 +03:00
|
|
|
FcPattern* GetPattern() const { return mPattern; }
|
2017-08-07 23:20:37 +03:00
|
|
|
|
2019-10-02 00:56:30 +03:00
|
|
|
already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(
|
2017-08-07 23:20:44 +03:00
|
|
|
DrawTarget* aTarget) override;
|
|
|
|
|
2019-09-16 20:15:10 +03:00
|
|
|
bool ShouldHintMetrics() const override;
|
|
|
|
|
2017-08-07 23:20:37 +03:00
|
|
|
private:
|
2015-05-13 08:11:26 +03:00
|
|
|
virtual ~gfxFontconfigFont();
|
2017-08-07 23:20:37 +03:00
|
|
|
|
|
|
|
nsCountedRef<FcPattern> mPattern;
|
2015-05-13 08:11:25 +03:00
|
|
|
};
|
|
|
|
|
2020-03-10 18:00:56 +03:00
|
|
|
class gfxFcPlatformFontList final : public gfxPlatformFontList {
|
2020-03-09 15:27:45 +03:00
|
|
|
using FontPatternListEntry = mozilla::dom::SystemFontListEntry;
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
public:
|
2015-05-13 08:11:26 +03:00
|
|
|
gfxFcPlatformFontList();
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2015-11-17 05:39:58 +03:00
|
|
|
static gfxFcPlatformFontList* PlatformFontList() {
|
|
|
|
return static_cast<gfxFcPlatformFontList*>(sPlatformFontList);
|
|
|
|
}
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
// initialize font lists
|
2019-04-11 15:36:51 +03:00
|
|
|
nsresult InitFontListForPlatform() override;
|
2019-04-27 18:38:28 +03:00
|
|
|
void InitSharedFontListForPlatform() override;
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
void GetFontList(nsAtom* aLangGroup, const nsACString& aGenericFamily,
|
2015-05-13 08:11:25 +03:00
|
|
|
nsTArray<nsString>& aListOfFonts) override;
|
|
|
|
|
2020-03-09 15:27:45 +03:00
|
|
|
void ReadSystemFontList(nsTArray<FontPatternListEntry>* retValue);
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2019-04-27 18:38:28 +03:00
|
|
|
gfxFontEntry* CreateFontEntry(
|
|
|
|
mozilla::fontlist::Face* aFace,
|
|
|
|
const mozilla::fontlist::Family* aFamily) override;
|
|
|
|
|
2018-09-12 22:34:57 +03:00
|
|
|
gfxFontEntry* LookupLocalFont(const nsACString& aFontName,
|
2018-04-25 09:18:23 +03:00
|
|
|
WeightRange aWeightForEntry,
|
|
|
|
StretchRange aStretchForEntry,
|
|
|
|
SlantStyleRange aStyleForEntry) override;
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2018-09-12 22:34:57 +03:00
|
|
|
gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
|
2018-04-25 09:18:23 +03:00
|
|
|
WeightRange aWeightForEntry,
|
|
|
|
StretchRange aStretchForEntry,
|
|
|
|
SlantStyleRange aStyleForEntry,
|
2015-05-13 08:11:25 +03:00
|
|
|
const uint8_t* aFontData,
|
|
|
|
uint32_t aLength) override;
|
|
|
|
|
2019-04-27 18:37:58 +03:00
|
|
|
bool FindAndAddFamilies(mozilla::StyleGenericFontFamily aGeneric,
|
|
|
|
const nsACString& aFamily,
|
2018-05-25 16:07:57 +03:00
|
|
|
nsTArray<FamilyAndGeneric>* aOutput,
|
2017-08-01 13:25:35 +03:00
|
|
|
FindFamiliesFlags aFlags,
|
2016-04-12 09:06:22 +03:00
|
|
|
gfxFontStyle* aStyle = nullptr,
|
|
|
|
gfxFloat aDevToCssSize = 1.0) override;
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2018-09-12 22:34:57 +03:00
|
|
|
bool GetStandardFamilyName(const nsCString& aFontName,
|
|
|
|
nsACString& aFamilyName) override;
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2015-05-13 08:11:26 +03:00
|
|
|
FcConfig* GetLastConfig() const { return mLastConfig; }
|
|
|
|
|
2015-11-16 02:48:40 +03:00
|
|
|
// override to use fontconfig lookup for generics
|
2019-04-02 00:47:59 +03:00
|
|
|
void AddGenericFonts(mozilla::StyleGenericFontFamily, nsAtom* aLanguage,
|
2018-05-25 16:07:57 +03:00
|
|
|
nsTArray<FamilyAndGeneric>& aFamilyList) override;
|
2015-11-16 02:48:40 +03:00
|
|
|
|
|
|
|
void ClearLangGroupPrefFonts() override;
|
|
|
|
|
2015-11-20 07:35:15 +03:00
|
|
|
// clear out cached generic-lang ==> family-list mappings
|
|
|
|
void ClearGenericMappings() { mGenericMappings.Clear(); }
|
|
|
|
|
2018-05-25 23:18:54 +03:00
|
|
|
// map lang group ==> lang string
|
2018-05-28 12:09:28 +03:00
|
|
|
// When aForFontEnumerationThread is true, this method will avoid using
|
|
|
|
// LanguageService::LookupLanguage, because it is not safe for off-main-
|
|
|
|
// thread use (except by stylo traversal, which does the necessary locking)
|
|
|
|
void GetSampleLangForGroup(nsAtom* aLanguage, nsACString& aLangStr,
|
|
|
|
bool aForFontEnumerationThread = false);
|
2018-05-25 23:18:54 +03:00
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
protected:
|
|
|
|
virtual ~gfxFcPlatformFontList();
|
|
|
|
|
2019-03-19 01:31:59 +03:00
|
|
|
#if defined(MOZ_SANDBOX) && defined(XP_LINUX)
|
2017-11-09 19:54:30 +03:00
|
|
|
typedef mozilla::SandboxBroker::Policy SandboxPolicy;
|
|
|
|
#else
|
|
|
|
// Dummy type just so we can still have a SandboxPolicy* parameter.
|
|
|
|
struct SandboxPolicy {};
|
|
|
|
#endif
|
|
|
|
|
2016-06-15 16:35:05 +03:00
|
|
|
// Add all the font families found in a font set.
|
|
|
|
// aAppFonts indicates whether this is the system or application fontset.
|
2017-11-09 19:54:30 +03:00
|
|
|
void AddFontSetFamilies(FcFontSet* aFontSet, const SandboxPolicy* aPolicy,
|
|
|
|
bool aAppFonts);
|
2017-11-02 23:29:33 +03:00
|
|
|
|
2017-11-02 23:29:33 +03:00
|
|
|
// Helper for above, to add a single font pattern.
|
|
|
|
void AddPatternToFontList(FcPattern* aFont, FcChar8*& aLastFamilyName,
|
2018-09-12 22:34:57 +03:00
|
|
|
nsACString& aFamilyName,
|
2017-11-02 23:29:33 +03:00
|
|
|
RefPtr<gfxFontconfigFontFamily>& aFontFamily,
|
|
|
|
bool aAppFonts);
|
|
|
|
|
2015-11-16 02:48:40 +03:00
|
|
|
// figure out which families fontconfig maps a generic to
|
2015-05-13 08:11:25 +03:00
|
|
|
// (aGeneric assumed already lowercase)
|
2018-09-18 11:34:21 +03:00
|
|
|
PrefFontList* FindGenericFamilies(const nsCString& aGeneric,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aLanguage);
|
2015-11-16 02:48:40 +03:00
|
|
|
|
|
|
|
// are all pref font settings set to use fontconfig generics?
|
|
|
|
bool PrefFontListsUseOnlyGenerics();
|
2015-05-13 08:11:25 +03:00
|
|
|
|
2015-05-13 08:11:26 +03:00
|
|
|
static void CheckFontUpdates(nsITimer* aTimer, void* aThis);
|
|
|
|
|
2019-04-01 17:33:34 +03:00
|
|
|
FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
2016-08-23 03:06:07 +03:00
|
|
|
|
2020-04-03 02:12:56 +03:00
|
|
|
enum class DistroID : int8_t {
|
|
|
|
Unknown = 0,
|
|
|
|
Ubuntu = 1,
|
|
|
|
Fedora = 2,
|
|
|
|
// To be extended with any distros that ship a useful base set of fonts
|
|
|
|
// that we want to explicitly support.
|
|
|
|
};
|
|
|
|
DistroID GetDistroID() const; // -> DistroID::Unknown if we can't tell
|
|
|
|
|
|
|
|
FontVisibility GetVisibilityForFamily(const nsACString& aName) const;
|
|
|
|
|
2020-04-02 15:36:24 +03:00
|
|
|
gfxFontFamily* CreateFontFamily(const nsACString& aName,
|
|
|
|
FontVisibility aVisibility) const override;
|
2017-08-01 13:25:35 +03:00
|
|
|
|
2018-05-25 23:18:54 +03:00
|
|
|
// helper method for finding an appropriate lang string
|
|
|
|
bool TryLangForGroup(const nsACString& aOSLang, nsAtom* aLangGroup,
|
2018-05-28 12:09:28 +03:00
|
|
|
nsACString& aLang, bool aForFontEnumerationThread);
|
2018-05-25 23:18:54 +03:00
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
#ifdef MOZ_BUNDLED_FONTS
|
|
|
|
void ActivateBundledFonts();
|
|
|
|
nsCString mBundledFontsPath;
|
|
|
|
bool mBundledFontsInitialized;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// to avoid enumerating all fonts, maintain a mapping of local font
|
|
|
|
// names to family
|
2018-09-12 22:34:57 +03:00
|
|
|
nsBaseHashtable<nsCStringHashKey, nsCountedRef<FcPattern>, FcPattern*>
|
2015-05-27 10:19:19 +03:00
|
|
|
mLocalNames;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-16 02:48:40 +03:00
|
|
|
// caching generic/lang ==> font family list
|
2016-04-15 22:45:37 +03:00
|
|
|
nsClassHashtable<nsCStringHashKey, PrefFontList> mGenericMappings;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-04-09 13:09:08 +03:00
|
|
|
// Caching family lookups as found by FindAndAddFamilies after resolving
|
|
|
|
// substitutions. The gfxFontFamily objects cached here are owned by the
|
|
|
|
// gfxFcPlatformFontList via its mFamilies table; note that if the main
|
|
|
|
// font list is rebuilt (e.g. due to a fontconfig configuration change),
|
|
|
|
// these pointers will be invalidated. InitFontList() flushes the cache
|
|
|
|
// in this case.
|
2020-05-05 13:56:14 +03:00
|
|
|
nsDataHashtable<nsCStringHashKey, CopyableTArray<FamilyAndGeneric>>
|
2018-05-25 16:07:57 +03:00
|
|
|
mFcSubstituteCache;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-05-13 08:11:26 +03:00
|
|
|
nsCOMPtr<nsITimer> mCheckFontUpdatesTimer;
|
|
|
|
nsCountedRef<FcConfig> mLastConfig;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-16 02:48:40 +03:00
|
|
|
// By default, font prefs under Linux are set to simply lookup
|
|
|
|
// via fontconfig the appropriate font for serif/sans-serif/monospace.
|
|
|
|
// Rather than check each time a font pref is used, check them all at startup
|
|
|
|
// and set a boolean to flag the case that non-default user font prefs exist
|
|
|
|
// Note: langGroup == x-math is handled separately
|
|
|
|
bool mAlwaysUseFontconfigGenerics;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-09-16 20:12:38 +03:00
|
|
|
static FT_Library sFTLibrary;
|
2015-05-13 08:11:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFXPLATFORMFONTLIST_H_ */
|