2009-08-16 17:52:12 +04: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/. */
|
2009-08-16 17:52:12 +04:00
|
|
|
|
|
|
|
#ifndef GFXPLATFORMFONTLIST_H_
|
|
|
|
#define GFXPLATFORMFONTLIST_H_
|
|
|
|
|
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
2011-11-09 00:22:04 +04:00
|
|
|
#include "nsTHashtable.h"
|
2009-08-16 17:52:12 +04:00
|
|
|
|
|
|
|
#include "gfxFontUtils.h"
|
2014-01-29 11:39:01 +04:00
|
|
|
#include "gfxFontInfoLoader.h"
|
2009-08-16 17:52:12 +04:00
|
|
|
#include "gfxFont.h"
|
2015-09-29 04:51:28 +03:00
|
|
|
#include "gfxFontConstants.h"
|
2009-08-16 17:52:12 +04:00
|
|
|
#include "gfxPlatform.h"
|
2015-09-29 04:51:28 +03:00
|
|
|
#include "gfxFontFamilyList.h"
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2012-03-28 01:38:39 +04:00
|
|
|
#include "nsIMemoryReporter.h"
|
2012-06-13 08:14:28 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2015-09-29 04:51:29 +03:00
|
|
|
#include "mozilla/RangedArray.h"
|
2015-09-29 04:51:28 +03:00
|
|
|
#include "nsILanguageAtomService.h"
|
2010-05-20 03:22:19 +04:00
|
|
|
|
2012-04-19 03:59:43 +04:00
|
|
|
class CharMapHashKey : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef gfxCharacterMap* KeyType;
|
|
|
|
typedef const gfxCharacterMap* KeyTypePointer;
|
|
|
|
|
2014-08-08 05:17:30 +04:00
|
|
|
explicit CharMapHashKey(const gfxCharacterMap *aCharMap) :
|
2012-04-19 03:59:43 +04:00
|
|
|
mCharMap(const_cast<gfxCharacterMap*>(aCharMap))
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CharMapHashKey);
|
|
|
|
}
|
|
|
|
CharMapHashKey(const CharMapHashKey& toCopy) :
|
|
|
|
mCharMap(toCopy.mCharMap)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CharMapHashKey);
|
|
|
|
}
|
|
|
|
~CharMapHashKey()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CharMapHashKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxCharacterMap* GetKey() const { return mCharMap; }
|
|
|
|
|
|
|
|
bool KeyEquals(const gfxCharacterMap *aCharMap) const {
|
|
|
|
NS_ASSERTION(!aCharMap->mBuildOnTheFly && !mCharMap->mBuildOnTheFly,
|
|
|
|
"custom cmap used in shared cmap hashtable");
|
|
|
|
// cmaps built on the fly never match
|
|
|
|
if (aCharMap->mHash != mCharMap->mHash)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return mCharMap->Equals(aCharMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const gfxCharacterMap* KeyToPointer(gfxCharacterMap *aCharMap) {
|
|
|
|
return aCharMap;
|
|
|
|
}
|
|
|
|
static PLDHashNumber HashKey(const gfxCharacterMap *aCharMap) {
|
|
|
|
return aCharMap->mHash;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum { ALLOW_MEMMOVE = true };
|
|
|
|
|
|
|
|
protected:
|
|
|
|
gfxCharacterMap *mCharMap;
|
|
|
|
};
|
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
// gfxPlatformFontList is an abstract class for the global font list on the system;
|
|
|
|
// concrete subclasses for each platform implement the actual interface to the system fonts.
|
|
|
|
// This class exists because we cannot rely on the platform font-finding APIs to behave
|
|
|
|
// in sensible/similar ways, particularly with rich, complex OpenType families,
|
|
|
|
// so we do our own font family/style management here instead.
|
|
|
|
|
|
|
|
// Much of this is based on the old gfxQuartzFontCache, but adapted for use on all platforms.
|
|
|
|
|
2012-03-28 01:38:39 +04:00
|
|
|
struct FontListSizes {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mFontListSize; // size of the font list and dependent objects
|
2012-03-28 01:38:39 +04:00
|
|
|
// (font family and face names, etc), but NOT
|
|
|
|
// including the font table cache and the cmaps
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mFontTableCacheSize; // memory used for the gfxFontEntry table caches
|
|
|
|
uint32_t mCharMapsSize; // memory used for cmap coverage info
|
2012-03-28 01:38:39 +04:00
|
|
|
};
|
|
|
|
|
2014-04-17 18:17:22 +04:00
|
|
|
class gfxUserFontSet;
|
|
|
|
|
2014-01-29 11:39:01 +04:00
|
|
|
class gfxPlatformFontList : public gfxFontInfoLoader
|
2009-08-16 17:52:12 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static gfxPlatformFontList* PlatformFontList() {
|
|
|
|
return sPlatformFontList;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult Init() {
|
|
|
|
NS_ASSERTION(!sPlatformFontList, "What's this doing here?");
|
2010-11-08 14:02:27 +03:00
|
|
|
gfxPlatform::GetPlatform()->CreatePlatformFontList();
|
|
|
|
if (!sPlatformFontList) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2009-08-16 17:52:12 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Shutdown() {
|
|
|
|
delete sPlatformFontList;
|
2012-07-30 18:20:58 +04:00
|
|
|
sPlatformFontList = nullptr;
|
2009-08-16 17:52:12 +04:00
|
|
|
}
|
|
|
|
|
2011-06-12 06:30:16 +04:00
|
|
|
virtual ~gfxPlatformFontList();
|
|
|
|
|
2010-11-08 14:02:27 +03:00
|
|
|
// initialize font lists
|
|
|
|
virtual nsresult InitFontList();
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
virtual void GetFontList(nsIAtom *aLangGroup,
|
|
|
|
const nsACString& aGenericFamily,
|
|
|
|
nsTArray<nsString>& aListOfFonts);
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2014-04-17 18:17:22 +04:00
|
|
|
void UpdateFontList();
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2015-11-16 02:48:40 +03:00
|
|
|
virtual void ClearLangGroupPrefFonts();
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
virtual void GetFontFamilyList(nsTArray<RefPtr<gfxFontFamily> >& aFamilyArray);
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2014-09-30 10:27:55 +04:00
|
|
|
gfxFontEntry*
|
|
|
|
SystemFindFontForChar(uint32_t aCh, uint32_t aNextCh,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aRunScript,
|
2012-03-09 06:05:24 +04:00
|
|
|
const gfxFontStyle* aStyle);
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2016-04-12 09:06:22 +03:00
|
|
|
// Find family(ies) matching aFamily and append to the aOutput array
|
|
|
|
// (there may be multiple results in the case of fontconfig aliases, etc).
|
|
|
|
// Return true if any match was found and appended, false if none.
|
|
|
|
virtual bool
|
|
|
|
FindAndAddFamilies(const nsAString& aFamily,
|
|
|
|
nsTArray<gfxFontFamily*>* aOutput,
|
|
|
|
gfxFontStyle* aStyle = nullptr,
|
|
|
|
gfxFloat aDevToCssSize = 1.0);
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
gfxFontEntry* FindFontForFamily(const nsAString& aFamily, const gfxFontStyle* aStyle, bool& aNeedsBold);
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2010-01-29 04:41:25 +03:00
|
|
|
// name lookup table methods
|
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
void AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName);
|
|
|
|
|
2010-01-29 04:41:25 +03:00
|
|
|
void AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname);
|
|
|
|
|
|
|
|
void AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName);
|
|
|
|
|
2013-09-02 12:41:57 +04:00
|
|
|
bool NeedFullnamePostscriptNames() { return mExtraNames != nullptr; }
|
2010-01-29 04:41:25 +03:00
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
// pure virtual functions, to be provided by concrete subclasses
|
|
|
|
|
2012-12-19 13:42:25 +04:00
|
|
|
// get the system default font family
|
|
|
|
virtual gfxFontFamily* GetDefaultFont(const gfxFontStyle* aStyle) = 0;
|
2009-08-16 17:52:12 +04:00
|
|
|
|
|
|
|
// look up a font by name on the host platform
|
2014-09-08 11:23:19 +04:00
|
|
|
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
|
|
|
|
uint16_t aWeight,
|
|
|
|
int16_t aStretch,
|
2015-10-19 05:16:43 +03:00
|
|
|
uint8_t aStyle) = 0;
|
2009-08-16 17:52:12 +04:00
|
|
|
|
|
|
|
// create a new platform font from downloaded data (@font-face)
|
2015-04-01 08:29:55 +03:00
|
|
|
// this method is responsible to ensure aFontData is free()'d
|
2014-09-08 11:23:19 +04:00
|
|
|
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
|
|
|
uint16_t aWeight,
|
|
|
|
int16_t aStretch,
|
2015-10-19 05:16:43 +03:00
|
|
|
uint8_t aStyle,
|
2014-09-08 11:23:19 +04:00
|
|
|
const uint8_t* aFontData,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aLength) = 0;
|
2009-08-16 17:52:12 +04:00
|
|
|
|
|
|
|
// get the standard family name on the platform for a given font name
|
2009-10-07 18:13:40 +04:00
|
|
|
// (platforms may override, eg Mac)
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2013-10-15 06:19:47 +04:00
|
|
|
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const;
|
|
|
|
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const;
|
2012-03-28 01:38:39 +04:00
|
|
|
|
2012-04-19 03:59:43 +04:00
|
|
|
// search for existing cmap that matches the input
|
|
|
|
// return the input if no match is found
|
|
|
|
gfxCharacterMap* FindCharMap(gfxCharacterMap *aCmap);
|
|
|
|
|
|
|
|
// add a cmap to the shared cmap set
|
|
|
|
gfxCharacterMap* AddCmap(const gfxCharacterMap *aCharMap);
|
|
|
|
|
|
|
|
// remove the cmap from the shared cmap set
|
|
|
|
void RemoveCmap(const gfxCharacterMap *aCharMap);
|
|
|
|
|
2014-04-17 18:17:22 +04:00
|
|
|
// keep track of userfont sets to notify when global fontlist changes occur
|
|
|
|
void AddUserFontSet(gfxUserFontSet *aUserFontSet) {
|
|
|
|
mUserFontSetList.PutEntry(aUserFontSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveUserFontSet(gfxUserFontSet *aUserFontSet) {
|
|
|
|
mUserFontSetList.RemoveEntry(aUserFontSet);
|
|
|
|
}
|
|
|
|
|
2014-05-05 22:59:55 +04:00
|
|
|
static const gfxFontEntry::ScriptRange sComplexScriptRanges[];
|
|
|
|
|
2015-08-05 05:03:41 +03:00
|
|
|
void GetFontlistInitInfo(uint32_t& aNumInits, uint32_t& aLoaderState) {
|
|
|
|
aNumInits = mFontlistInitCount;
|
|
|
|
aLoaderState = (uint32_t) mState;
|
|
|
|
}
|
|
|
|
|
2015-09-29 04:51:28 +03:00
|
|
|
virtual void
|
2015-09-29 04:51:29 +03:00
|
|
|
AddGenericFonts(mozilla::FontFamilyType aGenericType,
|
|
|
|
nsIAtom* aLanguage,
|
2015-09-29 04:51:28 +03:00
|
|
|
nsTArray<gfxFontFamily*>& aFamilyList);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<gfxFontFamily>>*
|
2015-09-29 04:51:29 +03:00
|
|
|
GetPrefFontsLangGroup(mozilla::FontFamilyType aGenericType,
|
|
|
|
eFontPrefLang aPrefLang);
|
|
|
|
|
2015-09-29 04:51:28 +03:00
|
|
|
// in some situations, need to make decisions about ambiguous characters, may need to look at multiple pref langs
|
|
|
|
void GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang);
|
|
|
|
|
|
|
|
// convert a lang group to enum constant (i.e. "zh-TW" ==> eFontPrefLang_ChineseTW)
|
|
|
|
static eFontPrefLang GetFontPrefLangFor(const char* aLang);
|
|
|
|
|
|
|
|
// convert a lang group atom to enum constant
|
|
|
|
static eFontPrefLang GetFontPrefLangFor(nsIAtom *aLang);
|
|
|
|
|
|
|
|
// convert an enum constant to a lang group atom
|
|
|
|
static nsIAtom* GetLangGroupForPrefLang(eFontPrefLang aLang);
|
|
|
|
|
|
|
|
// convert a enum constant to lang group string (i.e. eFontPrefLang_ChineseTW ==> "zh-TW")
|
|
|
|
static const char* GetPrefLangName(eFontPrefLang aLang);
|
|
|
|
|
|
|
|
// map a Unicode range (based on char code) to a font language for Preferences
|
|
|
|
static eFontPrefLang GetFontPrefLangFor(uint8_t aUnicodeRange);
|
|
|
|
|
|
|
|
// returns true if a pref lang is CJK
|
|
|
|
static bool IsLangCJK(eFontPrefLang aLang);
|
|
|
|
|
|
|
|
// helper method to add a pref lang to an array, if not already in array
|
|
|
|
static void AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aAddLang);
|
|
|
|
|
2015-09-29 04:51:29 +03:00
|
|
|
// default serif/sans-serif choice based on font.default.xxx prefs
|
|
|
|
mozilla::FontFamilyType
|
|
|
|
GetDefaultGeneric(eFontPrefLang aLang);
|
|
|
|
|
2016-01-15 10:33:51 +03:00
|
|
|
// map lang group ==> lang string
|
|
|
|
void GetSampleLangForGroup(nsIAtom* aLanguage, nsACString& aLangStr,
|
|
|
|
bool aCheckEnvironment = true);
|
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
protected:
|
2015-03-21 19:28:04 +03:00
|
|
|
class MemoryReporter final : public nsIMemoryReporter
|
2012-03-28 01:38:39 +04:00
|
|
|
{
|
2014-06-23 22:49:07 +04:00
|
|
|
~MemoryReporter() {}
|
2012-03-28 01:38:39 +04:00
|
|
|
public:
|
2013-12-08 09:39:47 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIMEMORYREPORTER
|
2012-03-28 01:38:39 +04:00
|
|
|
};
|
|
|
|
|
2014-08-08 05:17:30 +04:00
|
|
|
explicit gfxPlatformFontList(bool aNeedFullnamePostscriptNames = true);
|
2009-08-16 17:52:12 +04:00
|
|
|
|
|
|
|
static gfxPlatformFontList *sPlatformFontList;
|
|
|
|
|
2016-04-12 09:06:22 +03:00
|
|
|
// Convenience method to return the first matching family (if any) as found
|
|
|
|
// by FindAndAddFamilies().
|
|
|
|
gfxFontFamily*
|
|
|
|
FindFamily(const nsAString& aFamily, gfxFontStyle* aStyle = nullptr,
|
|
|
|
gfxFloat aDevToCssSize = 1.0)
|
|
|
|
{
|
|
|
|
AutoTArray<gfxFontFamily*,1> families;
|
|
|
|
return FindAndAddFamilies(aFamily, &families, aStyle, aDevToCssSize)
|
|
|
|
? families[0] : nullptr;
|
|
|
|
}
|
|
|
|
|
2015-05-13 08:11:25 +03:00
|
|
|
// Lookup family name in global family list without substitutions or
|
|
|
|
// localized family name lookup. Used for common font fallback families.
|
|
|
|
gfxFontFamily* FindFamilyByCanonicalName(const nsAString& aFamily) {
|
|
|
|
nsAutoString key;
|
|
|
|
gfxFontFamily *familyEntry;
|
|
|
|
GenerateFontListKey(aFamily, key);
|
|
|
|
if ((familyEntry = mFontFamilies.GetWeak(key))) {
|
|
|
|
return CheckFamily(familyEntry);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-03-09 06:05:24 +04:00
|
|
|
// returns default font for a given character, null otherwise
|
2014-09-30 10:27:55 +04:00
|
|
|
gfxFontEntry* CommonFontFallback(uint32_t aCh, uint32_t aNextCh,
|
2012-12-19 13:42:25 +04:00
|
|
|
int32_t aRunScript,
|
|
|
|
const gfxFontStyle* aMatchStyle,
|
|
|
|
gfxFontFamily** aMatchedFamily);
|
2012-03-09 06:05:24 +04:00
|
|
|
|
|
|
|
// search fonts system-wide for a given character, null otherwise
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual gfxFontEntry* GlobalFontFallback(const uint32_t aCh,
|
|
|
|
int32_t aRunScript,
|
2012-03-09 06:05:24 +04:00
|
|
|
const gfxFontStyle* aMatchStyle,
|
2012-12-19 13:42:25 +04:00
|
|
|
uint32_t& aCmapCount,
|
|
|
|
gfxFontFamily** aMatchedFamily);
|
2012-03-09 06:05:24 +04:00
|
|
|
|
2012-03-09 06:05:40 +04:00
|
|
|
// whether system-based font fallback is used or not
|
|
|
|
// if system fallback is used, no need to load all cmaps
|
|
|
|
virtual bool UsesSystemFallback() { return false; }
|
|
|
|
|
2015-09-29 04:51:28 +03:00
|
|
|
void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aLen,
|
|
|
|
eFontPrefLang aCharLang, eFontPrefLang aPageLang);
|
|
|
|
|
2014-01-29 11:39:01 +04:00
|
|
|
// verifies that a family contains a non-zero font count
|
|
|
|
gfxFontFamily* CheckFamily(gfxFontFamily *aFamily);
|
|
|
|
|
2014-04-23 09:20:21 +04:00
|
|
|
// initialize localized family names
|
2009-08-16 17:52:12 +04:00
|
|
|
void InitOtherFamilyNames();
|
|
|
|
|
2014-04-23 09:20:20 +04:00
|
|
|
// search through font families, looking for a given name, initializing
|
|
|
|
// facename lists along the way. first checks all families with names
|
|
|
|
// close to face name, then searchs all families if not found.
|
|
|
|
gfxFontEntry* SearchFamiliesForFaceName(const nsAString& aFaceName);
|
|
|
|
|
|
|
|
// helper method for finding fullname/postscript names in facename lists
|
|
|
|
gfxFontEntry* FindFaceName(const nsAString& aFaceName);
|
2010-01-29 04:41:25 +03:00
|
|
|
|
2014-04-23 09:20:20 +04:00
|
|
|
// look up a font by name, for cases where platform font list
|
|
|
|
// maintains explicit mappings of fullname/psname ==> font
|
|
|
|
virtual gfxFontEntry* LookupInFaceNameLists(const nsAString& aFontName);
|
2010-01-29 04:41:25 +03:00
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
// commonly used fonts for which the name table should be loaded at startup
|
|
|
|
virtual void PreloadNamesList();
|
|
|
|
|
2010-01-28 09:56:16 +03:00
|
|
|
// load the bad underline blacklist from pref.
|
|
|
|
void LoadBadUnderlineList();
|
2009-08-16 17:52:12 +04:00
|
|
|
|
|
|
|
void GenerateFontListKey(const nsAString& aKeyName, nsAString& aResult);
|
|
|
|
|
2014-01-29 11:39:01 +04:00
|
|
|
virtual void GetFontFamilyNames(nsTArray<nsString>& aFontFamilyNames);
|
|
|
|
|
2015-11-17 05:39:58 +03:00
|
|
|
nsILanguageAtomService* GetLangService();
|
|
|
|
|
2015-11-16 02:48:40 +03:00
|
|
|
// helper function to map lang to lang group
|
|
|
|
nsIAtom* GetLangGroup(nsIAtom* aLanguage);
|
|
|
|
|
2016-01-15 10:33:51 +03:00
|
|
|
// helper method for finding an appropriate lang string
|
|
|
|
bool TryLangForGroup(const nsACString& aOSLang, nsIAtom* aLangGroup,
|
|
|
|
nsACString& aLang);
|
|
|
|
|
2015-11-16 02:48:40 +03:00
|
|
|
static const char* GetGenericName(mozilla::FontFamilyType aGenericType);
|
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
// gfxFontInfoLoader overrides, used to load in font cmaps
|
|
|
|
virtual void InitLoader();
|
2014-01-29 11:39:01 +04:00
|
|
|
virtual bool LoadFontInfo();
|
|
|
|
virtual void CleanupLoader();
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2013-04-26 11:40:44 +04:00
|
|
|
// read the loader initialization prefs, and start it
|
|
|
|
void GetPrefsAndStartLoader();
|
|
|
|
|
2014-04-17 18:17:22 +04:00
|
|
|
// for font list changes that affect all documents
|
|
|
|
void ForceGlobalReflow();
|
|
|
|
|
2015-07-14 05:08:31 +03:00
|
|
|
void RebuildLocalFonts();
|
|
|
|
|
2015-09-29 04:51:28 +03:00
|
|
|
void
|
|
|
|
ResolveGenericFontNames(mozilla::FontFamilyType aGenericType,
|
2015-09-29 04:51:29 +03:00
|
|
|
eFontPrefLang aPrefLang,
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies);
|
2015-09-29 04:51:29 +03:00
|
|
|
|
2015-07-31 07:15:16 +03:00
|
|
|
typedef nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> FontFamilyTable;
|
2015-08-05 04:05:19 +03:00
|
|
|
typedef nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> FontEntryTable;
|
2015-07-31 07:15:16 +03:00
|
|
|
|
2015-07-31 07:19:57 +03:00
|
|
|
// used by memory reporter to accumulate sizes of family names in the table
|
2012-03-28 01:38:39 +04:00
|
|
|
static size_t
|
2015-07-31 07:19:57 +03:00
|
|
|
SizeOfFontFamilyTableExcludingThis(const FontFamilyTable& aTable,
|
|
|
|
mozilla::MallocSizeOf aMallocSizeOf);
|
2015-08-05 04:05:19 +03:00
|
|
|
static size_t
|
|
|
|
SizeOfFontEntryTableExcludingThis(const FontEntryTable& aTable,
|
|
|
|
mozilla::MallocSizeOf aMallocSizeOf);
|
2012-03-28 01:38:39 +04:00
|
|
|
|
2009-10-07 21:16:52 +04:00
|
|
|
// canonical family name ==> family entry (unique, one name per family entry)
|
2015-07-31 07:15:16 +03:00
|
|
|
FontFamilyTable mFontFamilies;
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2010-01-29 04:41:25 +03:00
|
|
|
// other family name ==> family entry (not unique, can have multiple names per
|
2009-10-07 21:16:52 +04:00
|
|
|
// family entry, only names *other* than the canonical names are stored here)
|
2015-07-31 07:15:16 +03:00
|
|
|
FontFamilyTable mOtherFamilyNames;
|
2010-01-29 04:41:25 +03:00
|
|
|
|
2009-10-07 21:16:52 +04:00
|
|
|
// flag set after InitOtherFamilyNames is called upon first name lookup miss
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mOtherFamilyNamesInitialized;
|
2009-10-07 21:16:52 +04:00
|
|
|
|
2010-01-29 04:41:25 +03:00
|
|
|
// flag set after fullname and Postcript name lists are populated
|
2014-04-23 09:20:20 +04:00
|
|
|
bool mFaceNameListsInitialized;
|
2010-01-29 04:41:25 +03:00
|
|
|
|
2013-09-02 12:41:57 +04:00
|
|
|
struct ExtraNames {
|
2014-08-06 17:31:21 +04:00
|
|
|
ExtraNames() : mFullnames(64), mPostscriptNames(64) {}
|
2015-08-05 04:05:19 +03:00
|
|
|
|
2013-09-02 12:41:57 +04:00
|
|
|
// fullname ==> font entry (unique, one name per font entry)
|
2015-08-05 04:05:19 +03:00
|
|
|
FontEntryTable mFullnames;
|
2013-09-02 12:41:57 +04:00
|
|
|
// Postscript name ==> font entry (unique, one name per font entry)
|
2015-08-05 04:05:19 +03:00
|
|
|
FontEntryTable mPostscriptNames;
|
2013-09-02 12:41:57 +04:00
|
|
|
};
|
|
|
|
nsAutoPtr<ExtraNames> mExtraNames;
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2014-04-23 09:20:20 +04:00
|
|
|
// face names missed when face name loading takes a long time
|
|
|
|
nsAutoPtr<nsTHashtable<nsStringHashKey> > mFaceNamesMissed;
|
|
|
|
|
2014-04-23 09:20:21 +04:00
|
|
|
// localized family names missed when face name loading takes a long time
|
|
|
|
nsAutoPtr<nsTHashtable<nsStringHashKey> > mOtherNamesMissed;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
typedef nsTArray<RefPtr<gfxFontFamily>> PrefFontList;
|
2015-09-29 04:51:29 +03:00
|
|
|
typedef mozilla::RangedArray<nsAutoPtr<PrefFontList>,
|
|
|
|
mozilla::eFamily_generic_first,
|
|
|
|
mozilla::eFamily_generic_count> PrefFontsForLangGroup;
|
|
|
|
mozilla::RangedArray<PrefFontsForLangGroup,
|
|
|
|
eFontPrefLang_First,
|
|
|
|
eFontPrefLang_Count> mLangGroupPrefFonts;
|
2015-09-29 04:51:29 +03:00
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
// when system-wide font lookup fails for a character, cache it to skip future searches
|
|
|
|
gfxSparseBitSet mCodepointsWithNoFonts;
|
|
|
|
|
|
|
|
// the family to use for U+FFFD fallback, to avoid expensive search every time
|
|
|
|
// on pages with lots of problems
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxFontFamily> mReplacementCharFallbackFamily;
|
2009-08-16 17:52:12 +04:00
|
|
|
|
2011-11-09 00:22:04 +04:00
|
|
|
nsTHashtable<nsStringHashKey> mBadUnderlineFamilyNames;
|
2010-01-28 09:56:16 +03:00
|
|
|
|
2012-04-19 03:59:43 +04:00
|
|
|
// character map data shared across families
|
|
|
|
// contains weak ptrs to cmaps shared by font entry objects
|
|
|
|
nsTHashtable<CharMapHashKey> mSharedCmaps;
|
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
// data used as part of the font cmap loading process
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<gfxFontFamily> > mFontFamiliesToLoad;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mStartIndex;
|
|
|
|
uint32_t mIncrement;
|
|
|
|
uint32_t mNumFamilies;
|
2014-04-17 18:17:22 +04:00
|
|
|
|
2015-08-05 05:03:41 +03:00
|
|
|
// xxx - info for diagnosing no default font aborts
|
|
|
|
// see bugs 636957, 1070983, 1189129
|
|
|
|
uint32_t mFontlistInitCount; // num times InitFontList called
|
|
|
|
|
2014-04-17 18:17:22 +04:00
|
|
|
nsTHashtable<nsPtrHashKey<gfxUserFontSet> > mUserFontSetList;
|
2015-09-29 04:51:28 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsILanguageAtomService> mLangService;
|
2015-09-29 04:51:28 +03:00
|
|
|
nsTArray<uint32_t> mCJKPrefLangs;
|
2015-09-29 04:51:29 +03:00
|
|
|
nsTArray<mozilla::FontFamilyType> mDefaultGenericsLangGroup;
|
2009-08-16 17:52:12 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFXPLATFORMFONTLIST_H_ */
|