2009-08-16 13:52:12 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
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/. */
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2015-05-19 18:15:34 +00:00
|
|
|
#include "mozilla/Logging.h"
|
2011-01-21 16:44:33 +00:00
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
#include "gfxPlatformFontList.h"
|
2014-09-16 09:58:12 +00:00
|
|
|
#include "gfxTextRun.h"
|
2014-04-17 14:17:22 +00:00
|
|
|
#include "gfxUserFontSet.h"
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2015-09-29 01:51:28 +00:00
|
|
|
#include "nsCRT.h"
|
2015-09-29 01:51:28 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2015-09-29 01:51:28 +00:00
|
|
|
#include "nsILocaleService.h"
|
2015-09-29 01:51:28 +00:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2009-08-16 13:52:12 +00:00
|
|
|
#include "nsUnicharUtils.h"
|
2011-01-21 16:44:33 +00:00
|
|
|
#include "nsUnicodeRange.h"
|
2012-02-24 10:15:46 +00:00
|
|
|
#include "nsUnicodeProperties.h"
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2012-10-26 13:32:10 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/Likely.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2011-06-12 02:30:16 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2011-07-27 06:42:53 +00:00
|
|
|
#include "mozilla/Telemetry.h"
|
2011-11-30 01:55:11 +00:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2013-10-07 23:15:59 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2011-06-12 02:30:16 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
2015-05-21 20:22:04 +00:00
|
|
|
#define LOG_FONTLIST(args) MOZ_LOG(gfxPlatform::GetLog(eGfxLog_fontlist), \
|
2015-06-03 22:25:57 +00:00
|
|
|
LogLevel::Debug, args)
|
2015-06-03 22:22:28 +00:00
|
|
|
#define LOG_FONTLIST_ENABLED() MOZ_LOG_TEST( \
|
2011-01-21 16:44:33 +00:00
|
|
|
gfxPlatform::GetLog(eGfxLog_fontlist), \
|
2015-06-03 22:25:57 +00:00
|
|
|
LogLevel::Debug)
|
2015-05-21 20:22:04 +00:00
|
|
|
#define LOG_FONTINIT(args) MOZ_LOG(gfxPlatform::GetLog(eGfxLog_fontinit), \
|
2015-06-03 22:25:57 +00:00
|
|
|
LogLevel::Debug, args)
|
2015-06-03 22:22:28 +00:00
|
|
|
#define LOG_FONTINIT_ENABLED() MOZ_LOG_TEST( \
|
2013-12-11 00:58:27 +00:00
|
|
|
gfxPlatform::GetLog(eGfxLog_fontinit), \
|
2015-06-03 22:25:57 +00:00
|
|
|
LogLevel::Debug)
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
gfxPlatformFontList *gfxPlatformFontList::sPlatformFontList = nullptr;
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2014-05-05 18:59:55 +00:00
|
|
|
// Character ranges that require complex-script shaping support in the font,
|
|
|
|
// and so should be masked out by ReadCMAP if the necessary layout tables
|
|
|
|
// are not present.
|
|
|
|
// Currently used by the Mac and FT2 implementations only, but probably should
|
|
|
|
// be supported on Windows as well.
|
|
|
|
const gfxFontEntry::ScriptRange gfxPlatformFontList::sComplexScriptRanges[] = {
|
|
|
|
// Actually, now that harfbuzz supports presentation-forms shaping for
|
|
|
|
// Arabic, we can render it without layout tables. So maybe we don't
|
|
|
|
// want to mask the basic Arabic block here?
|
|
|
|
// This affects the arabic-fallback-*.html reftests, which rely on
|
|
|
|
// loading a font that *doesn't* have any GSUB table.
|
|
|
|
{ 0x0600, 0x06FF, { TRUETYPE_TAG('a','r','a','b'), 0, 0 } },
|
|
|
|
{ 0x0700, 0x074F, { TRUETYPE_TAG('s','y','r','c'), 0, 0 } },
|
|
|
|
{ 0x0750, 0x077F, { TRUETYPE_TAG('a','r','a','b'), 0, 0 } },
|
|
|
|
{ 0x08A0, 0x08FF, { TRUETYPE_TAG('a','r','a','b'), 0, 0 } },
|
|
|
|
{ 0x0900, 0x097F, { TRUETYPE_TAG('d','e','v','2'),
|
|
|
|
TRUETYPE_TAG('d','e','v','a'), 0 } },
|
|
|
|
{ 0x0980, 0x09FF, { TRUETYPE_TAG('b','n','g','2'),
|
|
|
|
TRUETYPE_TAG('b','e','n','g'), 0 } },
|
|
|
|
{ 0x0A00, 0x0A7F, { TRUETYPE_TAG('g','u','r','2'),
|
|
|
|
TRUETYPE_TAG('g','u','r','u'), 0 } },
|
|
|
|
{ 0x0A80, 0x0AFF, { TRUETYPE_TAG('g','j','r','2'),
|
|
|
|
TRUETYPE_TAG('g','u','j','r'), 0 } },
|
|
|
|
{ 0x0B00, 0x0B7F, { TRUETYPE_TAG('o','r','y','2'),
|
|
|
|
TRUETYPE_TAG('o','r','y','a'), 0 } },
|
|
|
|
{ 0x0B80, 0x0BFF, { TRUETYPE_TAG('t','m','l','2'),
|
|
|
|
TRUETYPE_TAG('t','a','m','l'), 0 } },
|
|
|
|
{ 0x0C00, 0x0C7F, { TRUETYPE_TAG('t','e','l','2'),
|
|
|
|
TRUETYPE_TAG('t','e','l','u'), 0 } },
|
|
|
|
{ 0x0C80, 0x0CFF, { TRUETYPE_TAG('k','n','d','2'),
|
|
|
|
TRUETYPE_TAG('k','n','d','a'), 0 } },
|
|
|
|
{ 0x0D00, 0x0D7F, { TRUETYPE_TAG('m','l','m','2'),
|
|
|
|
TRUETYPE_TAG('m','l','y','m'), 0 } },
|
|
|
|
{ 0x0D80, 0x0DFF, { TRUETYPE_TAG('s','i','n','h'), 0, 0 } },
|
|
|
|
{ 0x0E80, 0x0EFF, { TRUETYPE_TAG('l','a','o',' '), 0, 0 } },
|
|
|
|
{ 0x0F00, 0x0FFF, { TRUETYPE_TAG('t','i','b','t'), 0, 0 } },
|
|
|
|
{ 0x1000, 0x109f, { TRUETYPE_TAG('m','y','m','r'),
|
|
|
|
TRUETYPE_TAG('m','y','m','2'), 0 } },
|
|
|
|
{ 0x1780, 0x17ff, { TRUETYPE_TAG('k','h','m','r'), 0, 0 } },
|
|
|
|
// Khmer Symbols (19e0..19ff) don't seem to need any special shaping
|
|
|
|
{ 0xaa60, 0xaa7f, { TRUETYPE_TAG('m','y','m','r'),
|
|
|
|
TRUETYPE_TAG('m','y','m','2'), 0 } },
|
|
|
|
// Thai seems to be "renderable" without AAT morphing tables
|
|
|
|
{ 0, 0, { 0, 0, 0 } } // terminator
|
|
|
|
};
|
|
|
|
|
2013-04-26 07:40:44 +00:00
|
|
|
// prefs for the font info loader
|
|
|
|
#define FONT_LOADER_FAMILIES_PER_SLICE_PREF "gfx.font_loader.families_per_slice"
|
|
|
|
#define FONT_LOADER_DELAY_PREF "gfx.font_loader.delay"
|
|
|
|
#define FONT_LOADER_INTERVAL_PREF "gfx.font_loader.interval"
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2011-06-12 02:30:16 +00:00
|
|
|
static const char* kObservedPrefs[] = {
|
|
|
|
"font.",
|
|
|
|
"font.name-list.",
|
|
|
|
"intl.accept_languages", // hmmmm...
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr
|
2011-06-12 02:30:16 +00:00
|
|
|
};
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
// xxx - this can probably be eliminated by reworking pref font handling code
|
|
|
|
static const char *gPrefLangNames[] = {
|
|
|
|
#define FONT_PREF_LANG(enum_id_, str_, atom_id_) str_
|
|
|
|
#include "gfxFontPrefLangList.h"
|
|
|
|
#undef FONT_PREF_LANG
|
|
|
|
};
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
static_assert(MOZ_ARRAY_LENGTH(gPrefLangNames) == uint32_t(eFontPrefLang_Count),
|
|
|
|
"size of pref lang name array doesn't match pref lang enum size");
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class gfxFontListPrefObserver final : public nsIObserver {
|
2014-06-23 18:49:07 +00:00
|
|
|
~gfxFontListPrefObserver() {}
|
2009-08-16 13:52:12 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
};
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
static gfxFontListPrefObserver* gFontListPrefObserver = nullptr;
|
2011-06-12 02:30:16 +00:00
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(gfxFontListPrefObserver, nsIObserver)
|
2009-08-16 13:52:12 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
gfxFontListPrefObserver::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t *aData)
|
2009-08-16 13:52:12 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID), "invalid topic");
|
|
|
|
// XXX this could be made to only clear out the cache for the prefs that were changed
|
|
|
|
// but it probably isn't that big a deal.
|
2015-09-29 01:51:29 +00:00
|
|
|
gfxPlatformFontList::PlatformFontList()->ClearLangGroupPrefFonts();
|
2009-10-07 17:16:52 +00:00
|
|
|
gfxFontCache::GetCache()->AgeAllGenerations();
|
2009-08-16 13:52:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-08 05:38:32 +00:00
|
|
|
MOZ_DEFINE_MALLOC_SIZE_OF(FontListMallocSizeOf)
|
2012-03-27 21:38:39 +00:00
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(gfxPlatformFontList::MemoryReporter, nsIMemoryReporter)
|
2012-03-27 21:38:39 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-05-21 06:06:54 +00:00
|
|
|
gfxPlatformFontList::MemoryReporter::CollectReports(
|
|
|
|
nsIMemoryReporterCallback* aCb, nsISupports* aClosure, bool aAnonymize)
|
2012-03-27 21:38:39 +00:00
|
|
|
{
|
|
|
|
FontListSizes sizes;
|
|
|
|
sizes.mFontListSize = 0;
|
|
|
|
sizes.mFontTableCacheSize = 0;
|
|
|
|
sizes.mCharMapsSize = 0;
|
|
|
|
|
2013-10-15 02:19:47 +00:00
|
|
|
gfxPlatformFontList::PlatformFontList()->AddSizeOfIncludingThis(&FontListMallocSizeOf,
|
|
|
|
&sizes);
|
2012-03-27 21:38:39 +00:00
|
|
|
|
2014-05-21 06:06:54 +00:00
|
|
|
nsresult rv;
|
|
|
|
rv = aCb->Callback(EmptyCString(),
|
|
|
|
NS_LITERAL_CSTRING("explicit/gfx/font-list"),
|
|
|
|
KIND_HEAP, UNITS_BYTES, sizes.mFontListSize,
|
|
|
|
NS_LITERAL_CSTRING("Memory used to manage the list of font families and faces."),
|
|
|
|
aClosure);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = aCb->Callback(EmptyCString(),
|
|
|
|
NS_LITERAL_CSTRING("explicit/gfx/font-charmaps"),
|
|
|
|
KIND_HEAP, UNITS_BYTES, sizes.mCharMapsSize,
|
|
|
|
NS_LITERAL_CSTRING("Memory used to record the character coverage of individual fonts."),
|
|
|
|
aClosure);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-03-27 21:38:39 +00:00
|
|
|
|
|
|
|
if (sizes.mFontTableCacheSize) {
|
|
|
|
aCb->Callback(EmptyCString(),
|
|
|
|
NS_LITERAL_CSTRING("explicit/gfx/font-tables"),
|
2013-12-08 05:39:47 +00:00
|
|
|
KIND_HEAP, UNITS_BYTES, sizes.mFontTableCacheSize,
|
2012-03-27 21:38:39 +00:00
|
|
|
NS_LITERAL_CSTRING("Memory used for cached font metrics and layout tables."),
|
|
|
|
aClosure);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames)
|
2014-08-06 13:31:21 +00:00
|
|
|
: mFontFamilies(64), mOtherFamilyNames(16),
|
2015-09-29 01:51:29 +00:00
|
|
|
mBadUnderlineFamilyNames(8), mSharedCmaps(8),
|
2015-08-05 02:03:41 +00:00
|
|
|
mStartIndex(0), mIncrement(1), mNumFamilies(0), mFontlistInitCount(0)
|
2009-08-16 13:52:12 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
mOtherFamilyNamesInitialized = false;
|
2010-01-29 01:41:25 +00:00
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
if (aNeedFullnamePostscriptNames) {
|
|
|
|
mExtraNames = new ExtraNames();
|
2010-01-29 01:41:25 +00:00
|
|
|
}
|
2014-04-23 05:20:20 +00:00
|
|
|
mFaceNameListsInitialized = false;
|
2010-01-29 01:41:25 +00:00
|
|
|
|
2010-01-28 06:56:16 +00:00
|
|
|
LoadBadUnderlineList();
|
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
// pref changes notification setup
|
2011-06-12 02:30:16 +00:00
|
|
|
NS_ASSERTION(!gFontListPrefObserver,
|
|
|
|
"There has been font list pref observer already");
|
|
|
|
gFontListPrefObserver = new gfxFontListPrefObserver();
|
|
|
|
NS_ADDREF(gFontListPrefObserver);
|
|
|
|
Preferences::AddStrongObservers(gFontListPrefObserver, kObservedPrefs);
|
2012-04-18 23:59:43 +00:00
|
|
|
|
2013-11-07 05:35:30 +00:00
|
|
|
RegisterStrongMemoryReporter(new MemoryReporter());
|
2011-06-12 02:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxPlatformFontList::~gfxPlatformFontList()
|
|
|
|
{
|
2012-04-18 23:59:43 +00:00
|
|
|
mSharedCmaps.Clear();
|
2015-09-29 01:51:29 +00:00
|
|
|
ClearLangGroupPrefFonts();
|
2011-06-12 02:30:16 +00:00
|
|
|
NS_ASSERTION(gFontListPrefObserver, "There is no font list pref observer");
|
|
|
|
Preferences::RemoveObservers(gFontListPrefObserver, kObservedPrefs);
|
|
|
|
NS_RELEASE(gFontListPrefObserver);
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
// number of CSS generic font families
|
|
|
|
const uint32_t kNumGenerics = 5;
|
|
|
|
|
2010-11-08 11:02:27 +00:00
|
|
|
nsresult
|
2010-01-29 01:41:25 +00:00
|
|
|
gfxPlatformFontList::InitFontList()
|
|
|
|
{
|
2015-08-05 02:03:41 +00:00
|
|
|
mFontlistInitCount++;
|
|
|
|
|
2015-07-31 01:10:31 +00:00
|
|
|
if (LOG_FONTINIT_ENABLED()) {
|
|
|
|
LOG_FONTINIT(("(fontinit) system fontlist initialization\n"));
|
|
|
|
}
|
|
|
|
|
2015-01-07 05:30:10 +00:00
|
|
|
// rebuilding fontlist so clear out font/word caches
|
|
|
|
gfxFontCache *fontCache = gfxFontCache::GetCache();
|
|
|
|
if (fontCache) {
|
|
|
|
fontCache->AgeAllGenerations();
|
|
|
|
fontCache->FlushShapedWordCaches();
|
|
|
|
}
|
|
|
|
|
2010-01-29 01:41:25 +00:00
|
|
|
mFontFamilies.Clear();
|
|
|
|
mOtherFamilyNames.Clear();
|
2011-10-17 14:59:28 +00:00
|
|
|
mOtherFamilyNamesInitialized = false;
|
2013-09-02 08:41:57 +00:00
|
|
|
if (mExtraNames) {
|
|
|
|
mExtraNames->mFullnames.Clear();
|
|
|
|
mExtraNames->mPostscriptNames.Clear();
|
2010-01-29 01:41:25 +00:00
|
|
|
}
|
2014-04-23 05:20:20 +00:00
|
|
|
mFaceNameListsInitialized = false;
|
2015-09-29 01:51:29 +00:00
|
|
|
ClearLangGroupPrefFonts();
|
2012-12-19 09:42:25 +00:00
|
|
|
mReplacementCharFallbackFamily = nullptr;
|
2010-01-29 01:41:25 +00:00
|
|
|
CancelLoader();
|
|
|
|
|
|
|
|
// initialize ranges of characters for which system-wide font search should be skipped
|
|
|
|
mCodepointsWithNoFonts.reset();
|
|
|
|
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
|
|
|
|
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
|
2010-11-08 11:02:27 +00:00
|
|
|
|
|
|
|
sPlatformFontList = this;
|
|
|
|
|
|
|
|
return NS_OK;
|
2010-01-29 01:41:25 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::GenerateFontListKey(const nsAString& aKeyName, nsAString& aResult)
|
|
|
|
{
|
|
|
|
aResult = aKeyName;
|
|
|
|
ToLowerCase(aResult);
|
|
|
|
}
|
|
|
|
|
2015-09-24 15:31:30 +00:00
|
|
|
#define OTHERNAMES_TIMEOUT 200
|
2014-04-23 05:20:21 +00:00
|
|
|
|
2015-09-24 15:31:30 +00:00
|
|
|
void
|
2009-08-16 13:52:12 +00:00
|
|
|
gfxPlatformFontList::InitOtherFamilyNames()
|
|
|
|
{
|
2014-04-23 05:20:21 +00:00
|
|
|
if (mOtherFamilyNamesInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-11 00:58:27 +00:00
|
|
|
TimeStamp start = TimeStamp::Now();
|
2015-09-24 15:31:30 +00:00
|
|
|
bool timedOut = false;
|
|
|
|
|
|
|
|
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxFontFamily>& family = iter.Data();
|
2015-09-24 15:31:30 +00:00
|
|
|
family->ReadOtherFamilyNames(this);
|
|
|
|
TimeDuration elapsed = TimeStamp::Now() - start;
|
|
|
|
if (elapsed.ToMilliseconds() > OTHERNAMES_TIMEOUT) {
|
|
|
|
timedOut = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2015-09-24 15:31:30 +00:00
|
|
|
if (!timedOut) {
|
2014-04-23 05:20:21 +00:00
|
|
|
mOtherFamilyNamesInitialized = true;
|
|
|
|
}
|
2013-12-11 00:58:27 +00:00
|
|
|
TimeStamp end = TimeStamp::Now();
|
|
|
|
Telemetry::AccumulateTimeDelta(Telemetry::FONTLIST_INITOTHERFAMILYNAMES,
|
|
|
|
start, end);
|
2014-04-23 05:20:21 +00:00
|
|
|
|
2013-12-11 00:58:27 +00:00
|
|
|
if (LOG_FONTINIT_ENABLED()) {
|
|
|
|
TimeDuration elapsed = end - start;
|
2014-04-23 05:20:21 +00:00
|
|
|
LOG_FONTINIT(("(fontinit) InitOtherFamilyNames took %8.2f ms %s",
|
|
|
|
elapsed.ToMilliseconds(),
|
2015-09-24 15:31:30 +00:00
|
|
|
(timedOut ? "timeout" : "")));
|
2014-04-23 05:20:21 +00:00
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
2014-04-23 05:20:20 +00:00
|
|
|
|
2015-09-24 15:31:30 +00:00
|
|
|
// time limit for loading facename lists (ms)
|
|
|
|
#define NAMELIST_TIMEOUT 200
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2014-04-23 05:20:20 +00:00
|
|
|
gfxFontEntry*
|
|
|
|
gfxPlatformFontList::SearchFamiliesForFaceName(const nsAString& aFaceName)
|
|
|
|
{
|
2013-12-11 00:58:27 +00:00
|
|
|
TimeStamp start = TimeStamp::Now();
|
2015-09-24 15:31:30 +00:00
|
|
|
bool timedOut = false;
|
|
|
|
// if mFirstChar is not 0, only load facenames for families
|
|
|
|
// that start with this character
|
|
|
|
char16_t firstChar = 0;
|
2014-04-23 05:20:20 +00:00
|
|
|
gfxFontEntry *lookup = nullptr;
|
2013-12-11 00:58:27 +00:00
|
|
|
|
2014-04-23 05:20:20 +00:00
|
|
|
// iterate over familes starting with the same letter
|
2015-09-24 15:31:30 +00:00
|
|
|
firstChar = ToLowerCase(aFaceName.CharAt(0));
|
|
|
|
|
|
|
|
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
nsStringHashKey::KeyType key = iter.Key();
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxFontFamily>& family = iter.Data();
|
2015-09-24 15:31:30 +00:00
|
|
|
|
|
|
|
// when filtering, skip names that don't start with the filter character
|
|
|
|
if (firstChar && ToLowerCase(key.CharAt(0)) != firstChar) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
family->ReadFaceNames(this, NeedFullnamePostscriptNames());
|
|
|
|
|
|
|
|
TimeDuration elapsed = TimeStamp::Now() - start;
|
|
|
|
if (elapsed.ToMilliseconds() > NAMELIST_TIMEOUT) {
|
|
|
|
timedOut = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-23 05:20:20 +00:00
|
|
|
lookup = FindFaceName(aFaceName);
|
2013-12-11 00:58:27 +00:00
|
|
|
|
|
|
|
TimeStamp end = TimeStamp::Now();
|
|
|
|
Telemetry::AccumulateTimeDelta(Telemetry::FONTLIST_INITFACENAMELISTS,
|
|
|
|
start, end);
|
|
|
|
if (LOG_FONTINIT_ENABLED()) {
|
|
|
|
TimeDuration elapsed = end - start;
|
2014-04-23 05:20:20 +00:00
|
|
|
LOG_FONTINIT(("(fontinit) SearchFamiliesForFaceName took %8.2f ms %s %s",
|
|
|
|
elapsed.ToMilliseconds(),
|
|
|
|
(lookup ? "found name" : ""),
|
2015-09-24 15:31:30 +00:00
|
|
|
(timedOut ? "timeout" : "")));
|
2013-12-11 00:58:27 +00:00
|
|
|
}
|
2014-04-23 05:20:20 +00:00
|
|
|
|
|
|
|
return lookup;
|
2010-01-29 01:41:25 +00:00
|
|
|
}
|
|
|
|
|
2014-04-23 05:20:20 +00:00
|
|
|
gfxFontEntry*
|
|
|
|
gfxPlatformFontList::FindFaceName(const nsAString& aFaceName)
|
|
|
|
{
|
|
|
|
gfxFontEntry *lookup;
|
|
|
|
|
|
|
|
// lookup in name lookup tables, return null if not found
|
|
|
|
if (mExtraNames &&
|
|
|
|
((lookup = mExtraNames->mPostscriptNames.GetWeak(aFaceName)) ||
|
|
|
|
(lookup = mExtraNames->mFullnames.GetWeak(aFaceName)))) {
|
|
|
|
return lookup;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
|
|
|
gfxPlatformFontList::LookupInFaceNameLists(const nsAString& aFaceName)
|
|
|
|
{
|
|
|
|
gfxFontEntry *lookup = nullptr;
|
|
|
|
|
|
|
|
// initialize facename lookup tables if needed
|
|
|
|
// note: this can terminate early or time out, in which case
|
|
|
|
// mFaceNameListsInitialized remains false
|
|
|
|
if (!mFaceNameListsInitialized) {
|
|
|
|
lookup = SearchFamiliesForFaceName(aFaceName);
|
|
|
|
if (lookup) {
|
|
|
|
return lookup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// lookup in name lookup tables, return null if not found
|
|
|
|
if (!(lookup = FindFaceName(aFaceName))) {
|
|
|
|
// names not completely initialized, so keep track of lookup misses
|
|
|
|
if (!mFaceNameListsInitialized) {
|
|
|
|
if (!mFaceNamesMissed) {
|
2014-08-06 13:31:21 +00:00
|
|
|
mFaceNamesMissed = new nsTHashtable<nsStringHashKey>(2);
|
2014-04-23 05:20:20 +00:00
|
|
|
}
|
|
|
|
mFaceNamesMissed->PutEntry(aFaceName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return lookup;
|
|
|
|
}
|
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::PreloadNamesList()
|
|
|
|
{
|
|
|
|
nsAutoTArray<nsString, 10> preloadFonts;
|
|
|
|
gfxFontUtils::GetPrefsFontList("font.preload-names-list", preloadFonts);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t numFonts = preloadFonts.Length();
|
|
|
|
for (uint32_t i = 0; i < numFonts; i++) {
|
2009-08-16 13:52:12 +00:00
|
|
|
nsAutoString key;
|
|
|
|
GenerateFontListKey(preloadFonts[i], key);
|
2014-08-06 13:31:21 +00:00
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
// only search canonical names!
|
2012-03-27 21:38:39 +00:00
|
|
|
gfxFontFamily *familyEntry = mFontFamilies.GetWeak(key);
|
2009-08-16 13:52:12 +00:00
|
|
|
if (familyEntry) {
|
2010-01-29 01:41:25 +00:00
|
|
|
familyEntry->ReadOtherFamilyNames(this);
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-28 06:56:16 +00:00
|
|
|
gfxPlatformFontList::LoadBadUnderlineList()
|
2009-08-16 13:52:12 +00:00
|
|
|
{
|
|
|
|
nsAutoTArray<nsString, 10> blacklist;
|
|
|
|
gfxFontUtils::GetPrefsFontList("font.blacklist.underline_offset", blacklist);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t numFonts = blacklist.Length();
|
|
|
|
for (uint32_t i = 0; i < numFonts; i++) {
|
2009-08-16 13:52:12 +00:00
|
|
|
nsAutoString key;
|
|
|
|
GenerateFontListKey(blacklist[i], key);
|
2011-11-08 20:22:04 +00:00
|
|
|
mBadUnderlineFamilyNames.PutEntry(key);
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-17 14:17:22 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::UpdateFontList()
|
|
|
|
{
|
|
|
|
InitFontList();
|
2015-07-14 02:08:31 +00:00
|
|
|
RebuildLocalFonts();
|
2014-04-17 14:17:22 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
void
|
2010-02-24 17:57:57 +00:00
|
|
|
gfxPlatformFontList::GetFontList(nsIAtom *aLangGroup,
|
2009-08-16 13:52:12 +00:00
|
|
|
const nsACString& aGenericFamily,
|
|
|
|
nsTArray<nsString>& aListOfFonts)
|
|
|
|
{
|
2015-09-24 15:31:30 +00:00
|
|
|
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxFontFamily>& family = iter.Data();
|
2015-09-24 15:31:30 +00:00
|
|
|
// use the first variation for now. This data should be the same
|
|
|
|
// for all the variations and should probably be moved up to
|
|
|
|
// the Family
|
|
|
|
gfxFontStyle style;
|
|
|
|
style.language = aLangGroup;
|
|
|
|
bool needsBold;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxFontEntry> fontEntry = family->FindFontForStyle(style, needsBold);
|
2015-09-24 15:31:30 +00:00
|
|
|
NS_ASSERTION(fontEntry, "couldn't find any font entry in family");
|
|
|
|
if (!fontEntry) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skip symbol fonts */
|
|
|
|
if (fontEntry->IsSymbolFont()) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2015-09-24 15:31:30 +00:00
|
|
|
if (fontEntry->SupportsLangGroup(aLangGroup) &&
|
|
|
|
fontEntry->MatchesGenericFamily(aGenericFamily)) {
|
|
|
|
nsAutoString localizedFamilyName;
|
|
|
|
family->LocalizedName(localizedFamilyName);
|
|
|
|
aListOfFonts.AppendElement(localizedFamilyName);
|
|
|
|
}
|
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
|
|
|
|
aListOfFonts.Sort();
|
|
|
|
aListOfFonts.Compact();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-10-18 05:24:48 +00:00
|
|
|
gfxPlatformFontList::GetFontFamilyList(nsTArray<RefPtr<gfxFontFamily> >& aFamilyArray)
|
2009-08-16 13:52:12 +00:00
|
|
|
{
|
2015-09-24 15:31:30 +00:00
|
|
|
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxFontFamily>& family = iter.Data();
|
2015-09-24 15:31:30 +00:00
|
|
|
aFamilyArray.AppendElement(family);
|
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:24 +00:00
|
|
|
gfxFontEntry*
|
2014-09-30 06:27:55 +00:00
|
|
|
gfxPlatformFontList::SystemFindFontForChar(uint32_t aCh, uint32_t aNextCh,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aRunScript,
|
2012-03-09 02:05:24 +00:00
|
|
|
const gfxFontStyle* aStyle)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
gfxFontEntry* fontEntry = nullptr;
|
2012-03-09 02:05:24 +00:00
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
// is codepoint with no matching font? return null immediately
|
|
|
|
if (mCodepointsWithNoFonts.test(aCh)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 09:42:25 +00:00
|
|
|
// Try to short-circuit font fallback for U+FFFD, used to represent
|
|
|
|
// encoding errors: just use cached family from last time U+FFFD was seen.
|
|
|
|
// This helps speed up pages with lots of encoding errors, binary-as-text,
|
|
|
|
// etc.
|
|
|
|
if (aCh == 0xFFFD && mReplacementCharFallbackFamily) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool needsBold; // ignored in the system fallback case
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2012-12-19 09:42:25 +00:00
|
|
|
fontEntry =
|
|
|
|
mReplacementCharFallbackFamily->FindFontForStyle(*aStyle,
|
|
|
|
needsBold);
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2012-12-19 09:42:25 +00:00
|
|
|
// this should never fail, as we must have found U+FFFD in order to set
|
|
|
|
// mReplacementCharFallbackFamily at all, but better play it safe
|
2015-01-15 11:07:24 +00:00
|
|
|
if (fontEntry && fontEntry->HasCharacter(aCh)) {
|
2009-08-16 13:52:12 +00:00
|
|
|
return fontEntry;
|
2012-12-19 09:42:25 +00:00
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
2011-11-30 01:55:11 +00:00
|
|
|
TimeStamp start = TimeStamp::Now();
|
|
|
|
|
2012-03-09 02:05:24 +00:00
|
|
|
// search commonly available fonts
|
2013-11-25 02:02:14 +00:00
|
|
|
bool common = true;
|
2012-12-19 09:42:25 +00:00
|
|
|
gfxFontFamily *fallbackFamily = nullptr;
|
2014-09-30 06:27:55 +00:00
|
|
|
fontEntry = CommonFontFallback(aCh, aNextCh, aRunScript, aStyle,
|
|
|
|
&fallbackFamily);
|
2012-03-09 02:05:24 +00:00
|
|
|
|
|
|
|
// if didn't find a font, do system-wide fallback (except for specials)
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t cmapCount = 0;
|
2012-03-09 02:05:24 +00:00
|
|
|
if (!fontEntry) {
|
2013-11-25 02:02:14 +00:00
|
|
|
common = false;
|
2012-12-19 09:42:25 +00:00
|
|
|
fontEntry = GlobalFontFallback(aCh, aRunScript, aStyle, cmapCount,
|
|
|
|
&fallbackFamily);
|
2012-03-09 02:05:24 +00:00
|
|
|
}
|
2011-11-30 01:55:11 +00:00
|
|
|
TimeDuration elapsed = TimeStamp::Now() - start;
|
|
|
|
|
2011-01-21 16:44:33 +00:00
|
|
|
PRLogModuleInfo *log = gfxPlatform::GetLog(eGfxLog_textrun);
|
|
|
|
|
2015-06-03 22:25:57 +00:00
|
|
|
if (MOZ_UNLIKELY(MOZ_LOG_TEST(log, LogLevel::Warning))) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t unicodeRange = FindCharUnicodeRange(aCh);
|
|
|
|
int32_t script = mozilla::unicode::GetScriptCode(aCh);
|
2015-06-03 22:25:57 +00:00
|
|
|
MOZ_LOG(log, LogLevel::Warning,\
|
2012-03-09 02:05:24 +00:00
|
|
|
("(textrun-systemfallback-%s) char: u+%6.6x "
|
2013-06-12 12:08:53 +00:00
|
|
|
"unicode-range: %d script: %d match: [%s]"
|
2012-03-09 02:05:24 +00:00
|
|
|
" time: %dus cmaps: %d\n",
|
2013-11-25 02:02:14 +00:00
|
|
|
(common ? "common" : "global"), aCh,
|
2013-06-12 12:08:53 +00:00
|
|
|
unicodeRange, script,
|
2012-03-09 02:05:24 +00:00
|
|
|
(fontEntry ? NS_ConvertUTF16toUTF8(fontEntry->Name()).get() :
|
|
|
|
"<none>"),
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t(elapsed.ToMicroseconds()),
|
2012-03-09 02:05:24 +00:00
|
|
|
cmapCount));
|
2011-01-21 16:44:33 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
// no match? add to set of non-matching codepoints
|
2012-03-09 02:05:24 +00:00
|
|
|
if (!fontEntry) {
|
2012-12-19 09:42:25 +00:00
|
|
|
mCodepointsWithNoFonts.set(aCh);
|
|
|
|
} else if (aCh == 0xFFFD && fontEntry && fallbackFamily) {
|
|
|
|
mReplacementCharFallbackFamily = fallbackFamily;
|
|
|
|
}
|
2012-03-09 02:05:24 +00:00
|
|
|
|
|
|
|
// track system fallback time
|
|
|
|
static bool first = true;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t intElapsed = int32_t(first ? elapsed.ToMilliseconds() :
|
2011-11-30 01:55:11 +00:00
|
|
|
elapsed.ToMicroseconds());
|
|
|
|
Telemetry::Accumulate((first ? Telemetry::SYSTEM_FONT_FALLBACK_FIRST :
|
|
|
|
Telemetry::SYSTEM_FONT_FALLBACK),
|
|
|
|
intElapsed);
|
|
|
|
first = false;
|
|
|
|
|
2012-03-09 02:06:06 +00:00
|
|
|
// track the script for which fallback occurred (incremented one make it
|
|
|
|
// 1-based)
|
|
|
|
Telemetry::Accumulate(Telemetry::SYSTEM_FONT_FALLBACK_SCRIPT, aRunScript + 1);
|
|
|
|
|
2012-03-09 02:05:24 +00:00
|
|
|
return fontEntry;
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:05:24 +00:00
|
|
|
#define NUM_FALLBACK_FONTS 8
|
|
|
|
|
|
|
|
gfxFontEntry*
|
2014-09-30 06:27:55 +00:00
|
|
|
gfxPlatformFontList::CommonFontFallback(uint32_t aCh, uint32_t aNextCh,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aRunScript,
|
2012-12-19 09:42:25 +00:00
|
|
|
const gfxFontStyle* aMatchStyle,
|
|
|
|
gfxFontFamily** aMatchedFamily)
|
2012-03-09 02:05:24 +00:00
|
|
|
{
|
|
|
|
nsAutoTArray<const char*,NUM_FALLBACK_FONTS> defaultFallbacks;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i, numFallbacks;
|
2012-03-09 02:05:24 +00:00
|
|
|
|
2014-09-30 06:27:55 +00:00
|
|
|
gfxPlatform::GetPlatform()->GetCommonFallbackFonts(aCh, aNextCh,
|
|
|
|
aRunScript,
|
2012-03-09 02:05:24 +00:00
|
|
|
defaultFallbacks);
|
|
|
|
numFallbacks = defaultFallbacks.Length();
|
|
|
|
for (i = 0; i < numFallbacks; i++) {
|
|
|
|
nsAutoString familyName;
|
|
|
|
const char *fallbackFamily = defaultFallbacks[i];
|
|
|
|
|
|
|
|
familyName.AppendASCII(fallbackFamily);
|
2015-05-13 05:11:25 +00:00
|
|
|
gfxFontFamily *fallback = FindFamilyByCanonicalName(familyName);
|
2012-03-09 02:05:24 +00:00
|
|
|
if (!fallback)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gfxFontEntry *fontEntry;
|
|
|
|
bool needsBold; // ignored in the system fallback case
|
|
|
|
|
|
|
|
// use first font in list that supports a given character
|
|
|
|
fontEntry = fallback->FindFontForStyle(*aMatchStyle, needsBold);
|
2015-01-15 11:07:24 +00:00
|
|
|
if (fontEntry && fontEntry->HasCharacter(aCh)) {
|
2012-12-19 09:42:25 +00:00
|
|
|
*aMatchedFamily = fallback;
|
2012-03-09 02:05:24 +00:00
|
|
|
return fontEntry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-03-09 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
2012-08-22 15:56:38 +00:00
|
|
|
gfxPlatformFontList::GlobalFontFallback(const uint32_t aCh,
|
|
|
|
int32_t aRunScript,
|
2012-03-09 02:05:24 +00:00
|
|
|
const gfxFontStyle* aMatchStyle,
|
2012-12-19 09:42:25 +00:00
|
|
|
uint32_t& aCmapCount,
|
|
|
|
gfxFontFamily** aMatchedFamily)
|
2012-03-09 02:05:24 +00:00
|
|
|
{
|
|
|
|
// otherwise, try to find it among local fonts
|
|
|
|
GlobalFontMatch data(aCh, aRunScript, aMatchStyle);
|
|
|
|
|
|
|
|
// iterate over all font families to find a font that support the character
|
2015-09-24 15:31:30 +00:00
|
|
|
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxFontFamily>& family = iter.Data();
|
2015-09-24 15:31:30 +00:00
|
|
|
// evaluate all fonts in this family for a match
|
|
|
|
family->FindFontForChar(&data);
|
|
|
|
}
|
2012-03-09 02:05:24 +00:00
|
|
|
|
|
|
|
aCmapCount = data.mCmapsTested;
|
2012-12-19 09:42:25 +00:00
|
|
|
*aMatchedFamily = data.mMatchedFamily;
|
2012-03-09 02:05:24 +00:00
|
|
|
|
|
|
|
return data.mBestMatch;
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
2011-01-21 16:44:33 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
// crude hack for using when monitoring process
|
|
|
|
static void LogRegistryEvent(const wchar_t *msg)
|
|
|
|
{
|
|
|
|
HKEY dummyKey;
|
|
|
|
HRESULT hr;
|
|
|
|
wchar_t buf[512];
|
|
|
|
|
|
|
|
wsprintfW(buf, L" log %s", msg);
|
|
|
|
hr = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buf, 0, KEY_READ, &dummyKey);
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
RegCloseKey(dummyKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-01-29 07:39:01 +00:00
|
|
|
gfxFontFamily*
|
|
|
|
gfxPlatformFontList::CheckFamily(gfxFontFamily *aFamily)
|
|
|
|
{
|
|
|
|
if (aFamily && !aFamily->HasStyles()) {
|
|
|
|
aFamily->FindStyleVariations();
|
|
|
|
aFamily->CheckForSimpleFamily();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aFamily && aFamily->GetFontList().Length() == 0) {
|
|
|
|
// failed to load any faces for this family, so discard it
|
|
|
|
nsAutoString key;
|
|
|
|
GenerateFontListKey(aFamily->Name(), key);
|
|
|
|
mFontFamilies.Remove(key);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aFamily;
|
|
|
|
}
|
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
gfxFontFamily*
|
2015-10-08 06:04:08 +00:00
|
|
|
gfxPlatformFontList::FindFamily(const nsAString& aFamily, gfxFontStyle* aStyle)
|
2009-08-16 13:52:12 +00:00
|
|
|
{
|
|
|
|
nsAutoString key;
|
|
|
|
gfxFontFamily *familyEntry;
|
|
|
|
GenerateFontListKey(aFamily, key);
|
|
|
|
|
2011-01-28 00:40:06 +00:00
|
|
|
NS_ASSERTION(mFontFamilies.Count() != 0, "system font list was not initialized correctly");
|
|
|
|
|
2009-08-16 13:52:12 +00:00
|
|
|
// lookup in canonical (i.e. English) family name list
|
2012-03-27 21:38:39 +00:00
|
|
|
if ((familyEntry = mFontFamilies.GetWeak(key))) {
|
2014-01-29 07:39:01 +00:00
|
|
|
return CheckFamily(familyEntry);
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// lookup in other family names list (mostly localized names)
|
2012-07-30 14:20:58 +00:00
|
|
|
if ((familyEntry = mOtherFamilyNames.GetWeak(key)) != nullptr) {
|
2014-01-29 07:39:01 +00:00
|
|
|
return CheckFamily(familyEntry);
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// name not found and other family names not yet fully initialized so
|
|
|
|
// initialize the rest of the list and try again. this is done lazily
|
2011-01-07 12:29:49 +00:00
|
|
|
// since reading name table entries is expensive.
|
|
|
|
// although ASCII localized family names are possible they don't occur
|
|
|
|
// in practice so avoid pulling in names at startup
|
|
|
|
if (!mOtherFamilyNamesInitialized && !IsASCII(aFamily)) {
|
2009-08-16 13:52:12 +00:00
|
|
|
InitOtherFamilyNames();
|
2012-07-30 14:20:58 +00:00
|
|
|
if ((familyEntry = mOtherFamilyNames.GetWeak(key)) != nullptr) {
|
2014-01-29 07:39:01 +00:00
|
|
|
return CheckFamily(familyEntry);
|
2014-04-23 05:20:21 +00:00
|
|
|
} else if (!mOtherFamilyNamesInitialized) {
|
|
|
|
// localized family names load timed out, add name to list of
|
|
|
|
// names to check after localized names are loaded
|
|
|
|
if (!mOtherNamesMissed) {
|
2014-08-06 13:31:21 +00:00
|
|
|
mOtherNamesMissed = new nsTHashtable<nsStringHashKey>(2);
|
2014-04-23 05:20:21 +00:00
|
|
|
}
|
|
|
|
mOtherNamesMissed->PutEntry(key);
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
2011-09-29 06:19:26 +00:00
|
|
|
gfxPlatformFontList::FindFontForFamily(const nsAString& aFamily, const gfxFontStyle* aStyle, bool& aNeedsBold)
|
2009-08-16 13:52:12 +00:00
|
|
|
{
|
|
|
|
gfxFontFamily *familyEntry = FindFamily(aFamily);
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
aNeedsBold = false;
|
2009-08-16 13:52:12 +00:00
|
|
|
|
|
|
|
if (familyEntry)
|
|
|
|
return familyEntry->FindFontForStyle(*aStyle, aNeedsBold);
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatformFontList::AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName)
|
|
|
|
{
|
|
|
|
nsAutoString key;
|
|
|
|
GenerateFontListKey(aOtherFamilyName, key);
|
|
|
|
|
2012-03-27 21:38:39 +00:00
|
|
|
if (!mOtherFamilyNames.GetWeak(key)) {
|
2009-08-16 13:52:12 +00:00
|
|
|
mOtherFamilyNames.Put(key, aFamilyEntry);
|
2011-01-21 16:44:33 +00:00
|
|
|
LOG_FONTLIST(("(fontlist-otherfamily) canonical family: %s, "
|
|
|
|
"other family: %s\n",
|
|
|
|
NS_ConvertUTF16toUTF8(aFamilyEntry->Name()).get(),
|
|
|
|
NS_ConvertUTF16toUTF8(aOtherFamilyName).get()));
|
2010-02-11 12:00:07 +00:00
|
|
|
if (mBadUnderlineFamilyNames.Contains(key))
|
2010-01-28 06:56:16 +00:00
|
|
|
aFamilyEntry->SetBadUnderlineFamily();
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-29 01:41:25 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname)
|
|
|
|
{
|
2013-09-02 08:41:57 +00:00
|
|
|
if (!mExtraNames->mFullnames.GetWeak(aFullname)) {
|
|
|
|
mExtraNames->mFullnames.Put(aFullname, aFontEntry);
|
2011-01-21 16:44:33 +00:00
|
|
|
LOG_FONTLIST(("(fontlist-fullname) name: %s, fullname: %s\n",
|
|
|
|
NS_ConvertUTF16toUTF8(aFontEntry->Name()).get(),
|
|
|
|
NS_ConvertUTF16toUTF8(aFullname).get()));
|
2010-01-29 01:41:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatformFontList::AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName)
|
|
|
|
{
|
2013-09-02 08:41:57 +00:00
|
|
|
if (!mExtraNames->mPostscriptNames.GetWeak(aPostscriptName)) {
|
|
|
|
mExtraNames->mPostscriptNames.Put(aPostscriptName, aFontEntry);
|
2011-01-21 16:44:33 +00:00
|
|
|
LOG_FONTLIST(("(fontlist-postscript) name: %s, psname: %s\n",
|
|
|
|
NS_ConvertUTF16toUTF8(aFontEntry->Name()).get(),
|
|
|
|
NS_ConvertUTF16toUTF8(aPostscriptName).get()));
|
2010-01-29 01:41:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxPlatformFontList::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
|
|
|
|
{
|
|
|
|
aFamilyName.Truncate();
|
2014-06-06 06:09:23 +00:00
|
|
|
gfxFontFamily *ff = FindFamily(aFontName);
|
|
|
|
if (!ff) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aFamilyName.Assign(ff->Name());
|
|
|
|
return true;
|
2009-10-07 14:13:40 +00:00
|
|
|
}
|
|
|
|
|
2012-04-18 23:59:43 +00:00
|
|
|
gfxCharacterMap*
|
|
|
|
gfxPlatformFontList::FindCharMap(gfxCharacterMap *aCmap)
|
|
|
|
{
|
|
|
|
aCmap->CalcHash();
|
|
|
|
gfxCharacterMap *cmap = AddCmap(aCmap);
|
|
|
|
cmap->mShared = true;
|
|
|
|
return cmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add a cmap to the shared cmap set
|
|
|
|
gfxCharacterMap*
|
|
|
|
gfxPlatformFontList::AddCmap(const gfxCharacterMap* aCharMap)
|
|
|
|
{
|
|
|
|
CharMapHashKey *found =
|
|
|
|
mSharedCmaps.PutEntry(const_cast<gfxCharacterMap*>(aCharMap));
|
|
|
|
return found->GetKey();
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove the cmap from the shared cmap set
|
|
|
|
void
|
|
|
|
gfxPlatformFontList::RemoveCmap(const gfxCharacterMap* aCharMap)
|
|
|
|
{
|
|
|
|
// skip lookups during teardown
|
|
|
|
if (mSharedCmaps.Count() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// cmap needs to match the entry *and* be the same ptr before removing
|
|
|
|
CharMapHashKey *found =
|
|
|
|
mSharedCmaps.GetEntry(const_cast<gfxCharacterMap*>(aCharMap));
|
|
|
|
if (found && found->GetKey() == aCharMap) {
|
|
|
|
mSharedCmaps.RemoveEntry(const_cast<gfxCharacterMap*>(aCharMap));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 01:51:28 +00:00
|
|
|
void
|
2015-09-29 01:51:29 +00:00
|
|
|
gfxPlatformFontList::ResolveGenericFontNames(
|
|
|
|
FontFamilyType aGenericType,
|
|
|
|
eFontPrefLang aPrefLang,
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies
|
2015-09-29 01:51:29 +00:00
|
|
|
)
|
2015-09-29 01:51:28 +00:00
|
|
|
{
|
2015-09-29 01:51:29 +00:00
|
|
|
const char* langGroupStr = GetPrefLangName(aPrefLang);
|
|
|
|
|
2015-09-29 01:51:28 +00:00
|
|
|
static const char kGeneric_serif[] = "serif";
|
|
|
|
static const char kGeneric_sans_serif[] = "sans-serif";
|
|
|
|
static const char kGeneric_monospace[] = "monospace";
|
|
|
|
static const char kGeneric_cursive[] = "cursive";
|
|
|
|
static const char kGeneric_fantasy[] = "fantasy";
|
|
|
|
|
|
|
|
// type should be standard generic type at this point
|
|
|
|
NS_ASSERTION(aGenericType >= eFamily_serif &&
|
|
|
|
aGenericType <= eFamily_fantasy,
|
|
|
|
"standard generic font family type required");
|
|
|
|
|
|
|
|
// map generic type to string
|
|
|
|
const char *generic = nullptr;
|
|
|
|
switch (aGenericType) {
|
|
|
|
case eFamily_serif:
|
|
|
|
generic = kGeneric_serif;
|
|
|
|
break;
|
|
|
|
case eFamily_sans_serif:
|
|
|
|
generic = kGeneric_sans_serif;
|
|
|
|
break;
|
|
|
|
case eFamily_monospace:
|
|
|
|
generic = kGeneric_monospace;
|
|
|
|
break;
|
|
|
|
case eFamily_cursive:
|
|
|
|
generic = kGeneric_cursive;
|
|
|
|
break;
|
|
|
|
case eFamily_fantasy:
|
|
|
|
generic = kGeneric_fantasy;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!generic) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
nsAutoTArray<nsString,4> genericFamilies;
|
2015-09-29 01:51:28 +00:00
|
|
|
|
|
|
|
// load family for "font.name.generic.lang"
|
|
|
|
nsAutoCString prefFontName("font.name.");
|
|
|
|
prefFontName.Append(generic);
|
|
|
|
prefFontName.Append('.');
|
2015-09-29 01:51:29 +00:00
|
|
|
prefFontName.Append(langGroupStr);
|
|
|
|
gfxFontUtils::AppendPrefsFontList(prefFontName.get(), genericFamilies);
|
|
|
|
|
|
|
|
// load fonts for "font.name-list.generic.lang"
|
|
|
|
nsAutoCString prefFontListName("font.name-list.");
|
|
|
|
prefFontListName.Append(generic);
|
|
|
|
prefFontListName.Append('.');
|
|
|
|
prefFontListName.Append(langGroupStr);
|
|
|
|
gfxFontUtils::AppendPrefsFontList(prefFontListName.get(), genericFamilies);
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
nsIAtom* langGroup = GetLangGroupForPrefLang(aPrefLang);
|
2015-09-29 01:51:29 +00:00
|
|
|
NS_ASSERTION(langGroup, "null lang group for pref lang");
|
|
|
|
|
|
|
|
// lookup and add platform fonts uniquely
|
2015-09-29 01:51:29 +00:00
|
|
|
for (const nsString& genericFamily : genericFamilies) {
|
2015-10-08 06:04:08 +00:00
|
|
|
gfxFontStyle style;
|
|
|
|
style.language = langGroup;
|
|
|
|
style.systemFont = false;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxFontFamily> family =
|
2015-10-08 06:04:08 +00:00
|
|
|
FindFamily(genericFamily, &style);
|
2015-09-29 01:51:29 +00:00
|
|
|
if (family) {
|
|
|
|
bool notFound = true;
|
2015-09-29 01:51:29 +00:00
|
|
|
for (const gfxFontFamily* f : *aGenericFamilies) {
|
|
|
|
if (f == family) {
|
2015-09-29 01:51:29 +00:00
|
|
|
notFound = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (notFound) {
|
|
|
|
aGenericFamilies->AppendElement(family);
|
|
|
|
}
|
|
|
|
}
|
2015-09-29 01:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 // dump out generic mappings
|
|
|
|
printf("%s ===> ", prefFontName.get());
|
2015-09-29 01:51:29 +00:00
|
|
|
for (uint32_t k = 0; k < aGenericFamilies->Length(); k++) {
|
2015-09-29 01:51:28 +00:00
|
|
|
if (k > 0) printf(", ");
|
2015-09-29 01:51:29 +00:00
|
|
|
printf("%s", NS_ConvertUTF16toUTF8(aGenericFamilies[k]->Name()).get());
|
2015-09-29 01:51:28 +00:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<gfxFontFamily>>*
|
2015-09-29 01:51:29 +00:00
|
|
|
gfxPlatformFontList::GetPrefFontsLangGroup(mozilla::FontFamilyType aGenericType,
|
|
|
|
eFontPrefLang aPrefLang)
|
|
|
|
{
|
|
|
|
// treat -moz-fixed as monospace
|
|
|
|
if (aGenericType == eFamily_moz_fixed) {
|
|
|
|
aGenericType = eFamily_monospace;
|
|
|
|
}
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
PrefFontList* prefFonts = mLangGroupPrefFonts[aPrefLang][aGenericType];
|
2015-09-29 01:51:29 +00:00
|
|
|
if (MOZ_UNLIKELY(!prefFonts)) {
|
2015-09-29 01:51:29 +00:00
|
|
|
prefFonts = new PrefFontList;
|
2015-09-29 01:51:29 +00:00
|
|
|
ResolveGenericFontNames(aGenericType, aPrefLang, prefFonts);
|
2015-09-29 01:51:29 +00:00
|
|
|
mLangGroupPrefFonts[aPrefLang][aGenericType] = prefFonts;
|
2015-09-29 01:51:29 +00:00
|
|
|
}
|
|
|
|
return prefFonts;
|
|
|
|
}
|
|
|
|
|
2015-09-29 01:51:28 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::AddGenericFonts(mozilla::FontFamilyType aGenericType,
|
2015-09-29 01:51:29 +00:00
|
|
|
nsIAtom* aLanguage,
|
2015-09-29 01:51:28 +00:00
|
|
|
nsTArray<gfxFontFamily*>& aFamilyList)
|
|
|
|
{
|
2015-09-29 01:51:29 +00:00
|
|
|
// map lang ==> langGroup
|
|
|
|
nsIAtom *langGroup = nullptr;
|
|
|
|
if (aLanguage) {
|
|
|
|
if (!mLangService) {
|
|
|
|
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
|
|
|
}
|
|
|
|
if (mLangService) {
|
|
|
|
nsresult rv;
|
|
|
|
langGroup = mLangService->GetLanguageGroup(aLanguage, &rv);
|
2015-09-29 01:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-29 01:51:29 +00:00
|
|
|
if (!langGroup) {
|
|
|
|
langGroup = nsGkAtoms::Unicode;
|
|
|
|
}
|
2015-09-29 01:51:28 +00:00
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
// langGroup ==> prefLang
|
|
|
|
eFontPrefLang prefLang = GetFontPrefLangFor(langGroup);
|
|
|
|
|
|
|
|
// lookup pref fonts
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<gfxFontFamily>>* prefFonts =
|
2015-09-29 01:51:29 +00:00
|
|
|
GetPrefFontsLangGroup(aGenericType, prefLang);
|
|
|
|
|
|
|
|
if (!prefFonts->IsEmpty()) {
|
|
|
|
aFamilyList.AppendElements(*prefFonts);
|
|
|
|
}
|
|
|
|
}
|
2015-09-29 01:51:28 +00:00
|
|
|
|
|
|
|
static nsIAtom* PrefLangToLangGroups(uint32_t aIndex)
|
|
|
|
{
|
|
|
|
// static array here avoids static constructor
|
|
|
|
static nsIAtom* gPrefLangToLangGroups[] = {
|
|
|
|
#define FONT_PREF_LANG(enum_id_, str_, atom_id_) nsGkAtoms::atom_id_
|
|
|
|
#include "gfxFontPrefLangList.h"
|
|
|
|
#undef FONT_PREF_LANG
|
|
|
|
};
|
|
|
|
|
|
|
|
return aIndex < ArrayLength(gPrefLangToLangGroups)
|
|
|
|
? gPrefLangToLangGroups[aIndex]
|
|
|
|
: nsGkAtoms::Unicode;
|
|
|
|
}
|
|
|
|
|
|
|
|
eFontPrefLang
|
|
|
|
gfxPlatformFontList::GetFontPrefLangFor(const char* aLang)
|
|
|
|
{
|
|
|
|
if (!aLang || !aLang[0]) {
|
|
|
|
return eFontPrefLang_Others;
|
|
|
|
}
|
|
|
|
for (uint32_t i = 0; i < ArrayLength(gPrefLangNames); ++i) {
|
|
|
|
if (!PL_strcasecmp(gPrefLangNames[i], aLang)) {
|
|
|
|
return eFontPrefLang(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return eFontPrefLang_Others;
|
|
|
|
}
|
|
|
|
|
|
|
|
eFontPrefLang
|
|
|
|
gfxPlatformFontList::GetFontPrefLangFor(nsIAtom *aLang)
|
|
|
|
{
|
|
|
|
if (!aLang)
|
|
|
|
return eFontPrefLang_Others;
|
|
|
|
nsAutoCString lang;
|
|
|
|
aLang->ToUTF8String(lang);
|
|
|
|
return GetFontPrefLangFor(lang.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
gfxPlatformFontList::GetLangGroupForPrefLang(eFontPrefLang aLang)
|
|
|
|
{
|
|
|
|
// the special CJK set pref lang should be resolved into separate
|
|
|
|
// calls to individual CJK pref langs before getting here
|
|
|
|
NS_ASSERTION(aLang != eFontPrefLang_CJKSet, "unresolved CJK set pref lang");
|
|
|
|
|
|
|
|
return PrefLangToLangGroups(uint32_t(aLang));
|
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
gfxPlatformFontList::GetPrefLangName(eFontPrefLang aLang)
|
|
|
|
{
|
|
|
|
if (uint32_t(aLang) < ArrayLength(gPrefLangNames)) {
|
|
|
|
return gPrefLangNames[uint32_t(aLang)];
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
eFontPrefLang
|
|
|
|
gfxPlatformFontList::GetFontPrefLangFor(uint8_t aUnicodeRange)
|
|
|
|
{
|
|
|
|
switch (aUnicodeRange) {
|
|
|
|
case kRangeSetLatin: return eFontPrefLang_Western;
|
|
|
|
case kRangeCyrillic: return eFontPrefLang_Cyrillic;
|
|
|
|
case kRangeGreek: return eFontPrefLang_Greek;
|
|
|
|
case kRangeHebrew: return eFontPrefLang_Hebrew;
|
|
|
|
case kRangeArabic: return eFontPrefLang_Arabic;
|
|
|
|
case kRangeThai: return eFontPrefLang_Thai;
|
|
|
|
case kRangeKorean: return eFontPrefLang_Korean;
|
|
|
|
case kRangeJapanese: return eFontPrefLang_Japanese;
|
|
|
|
case kRangeSChinese: return eFontPrefLang_ChineseCN;
|
|
|
|
case kRangeTChinese: return eFontPrefLang_ChineseTW;
|
|
|
|
case kRangeDevanagari: return eFontPrefLang_Devanagari;
|
|
|
|
case kRangeTamil: return eFontPrefLang_Tamil;
|
|
|
|
case kRangeArmenian: return eFontPrefLang_Armenian;
|
|
|
|
case kRangeBengali: return eFontPrefLang_Bengali;
|
|
|
|
case kRangeCanadian: return eFontPrefLang_Canadian;
|
|
|
|
case kRangeEthiopic: return eFontPrefLang_Ethiopic;
|
|
|
|
case kRangeGeorgian: return eFontPrefLang_Georgian;
|
|
|
|
case kRangeGujarati: return eFontPrefLang_Gujarati;
|
|
|
|
case kRangeGurmukhi: return eFontPrefLang_Gurmukhi;
|
|
|
|
case kRangeKhmer: return eFontPrefLang_Khmer;
|
|
|
|
case kRangeMalayalam: return eFontPrefLang_Malayalam;
|
|
|
|
case kRangeOriya: return eFontPrefLang_Oriya;
|
|
|
|
case kRangeTelugu: return eFontPrefLang_Telugu;
|
|
|
|
case kRangeKannada: return eFontPrefLang_Kannada;
|
|
|
|
case kRangeSinhala: return eFontPrefLang_Sinhala;
|
|
|
|
case kRangeTibetan: return eFontPrefLang_Tibetan;
|
|
|
|
case kRangeSetCJK: return eFontPrefLang_CJKSet;
|
|
|
|
default: return eFontPrefLang_Others;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
gfxPlatformFontList::IsLangCJK(eFontPrefLang aLang)
|
|
|
|
{
|
|
|
|
switch (aLang) {
|
|
|
|
case eFontPrefLang_Japanese:
|
|
|
|
case eFontPrefLang_ChineseTW:
|
|
|
|
case eFontPrefLang_ChineseCN:
|
|
|
|
case eFontPrefLang_ChineseHK:
|
|
|
|
case eFontPrefLang_Korean:
|
|
|
|
case eFontPrefLang_CJKSet:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatformFontList::GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
|
|
|
|
{
|
|
|
|
if (IsLangCJK(aCharLang)) {
|
|
|
|
AppendCJKPrefLangs(aPrefLangs, aLen, aCharLang, aPageLang);
|
|
|
|
} else {
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, aCharLang);
|
|
|
|
}
|
|
|
|
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, eFontPrefLang_Others);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatformFontList::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
|
|
|
|
{
|
|
|
|
// prefer the lang specified by the page *if* CJK
|
|
|
|
if (IsLangCJK(aPageLang)) {
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, aPageLang);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if not set up, set up the default CJK order, based on accept lang settings and locale
|
|
|
|
if (mCJKPrefLangs.Length() == 0) {
|
|
|
|
|
|
|
|
// temp array
|
|
|
|
eFontPrefLang tempPrefLangs[kMaxLenPrefLangList];
|
|
|
|
uint32_t tempLen = 0;
|
|
|
|
|
|
|
|
// Add the CJK pref fonts from accept languages, the order should be same order
|
|
|
|
nsAdoptingCString list = Preferences::GetLocalizedCString("intl.accept_languages");
|
|
|
|
if (!list.IsEmpty()) {
|
|
|
|
const char kComma = ',';
|
|
|
|
const char *p, *p_end;
|
|
|
|
list.BeginReading(p);
|
|
|
|
list.EndReading(p_end);
|
|
|
|
while (p < p_end) {
|
|
|
|
while (nsCRT::IsAsciiSpace(*p)) {
|
|
|
|
if (++p == p_end)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p == p_end)
|
|
|
|
break;
|
|
|
|
const char *start = p;
|
|
|
|
while (++p != p_end && *p != kComma)
|
|
|
|
/* nothing */ ;
|
|
|
|
nsAutoCString lang(Substring(start, p));
|
|
|
|
lang.CompressWhitespace(false, true);
|
|
|
|
eFontPrefLang fpl = gfxPlatformFontList::GetFontPrefLangFor(lang.get());
|
|
|
|
switch (fpl) {
|
|
|
|
case eFontPrefLang_Japanese:
|
|
|
|
case eFontPrefLang_Korean:
|
|
|
|
case eFontPrefLang_ChineseCN:
|
|
|
|
case eFontPrefLang_ChineseHK:
|
|
|
|
case eFontPrefLang_ChineseTW:
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, fpl);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
do { // to allow 'break' to abort this block if a call fails
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsILocaleService> ls =
|
|
|
|
do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
|
|
|
nsCOMPtr<nsILocale> appLocale;
|
|
|
|
rv = ls->GetApplicationLocale(getter_AddRefs(appLocale));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
|
|
|
nsString localeStr;
|
|
|
|
rv = appLocale->
|
|
|
|
GetCategory(NS_LITERAL_STRING(NSILOCALE_MESSAGE), localeStr);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
|
|
|
const nsAString& lang = Substring(localeStr, 0, 2);
|
|
|
|
if (lang.EqualsLiteral("ja")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
|
|
|
|
} else if (lang.EqualsLiteral("zh")) {
|
|
|
|
const nsAString& region = Substring(localeStr, 3, 2);
|
|
|
|
if (region.EqualsLiteral("CN")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
|
|
|
|
} else if (region.EqualsLiteral("TW")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
|
|
|
|
} else if (region.EqualsLiteral("HK")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
|
|
|
|
}
|
|
|
|
} else if (lang.EqualsLiteral("ko")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
// last resort... (the order is same as old gfx.)
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
|
|
|
|
|
|
|
|
// copy into the cached array
|
|
|
|
uint32_t j;
|
|
|
|
for (j = 0; j < tempLen; j++) {
|
|
|
|
mCJKPrefLangs.AppendElement(tempPrefLangs[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// append in cached CJK langs
|
|
|
|
uint32_t i, numCJKlangs = mCJKPrefLangs.Length();
|
|
|
|
|
|
|
|
for (i = 0; i < numCJKlangs; i++) {
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, (eFontPrefLang) (mCJKPrefLangs[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatformFontList::AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aAddLang)
|
|
|
|
{
|
|
|
|
if (aLen >= kMaxLenPrefLangList) return;
|
|
|
|
|
|
|
|
// make sure
|
|
|
|
uint32_t i = 0;
|
|
|
|
while (i < aLen && aPrefLangs[i] != aAddLang) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == aLen) {
|
|
|
|
aPrefLangs[aLen] = aAddLang;
|
|
|
|
aLen++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
mozilla::FontFamilyType
|
|
|
|
gfxPlatformFontList::GetDefaultGeneric(eFontPrefLang aLang)
|
|
|
|
{
|
|
|
|
// initialize lang group pref font defaults (i.e. serif/sans-serif)
|
|
|
|
if (MOZ_UNLIKELY(mDefaultGenericsLangGroup.IsEmpty())) {
|
|
|
|
mDefaultGenericsLangGroup.AppendElements(ArrayLength(gPrefLangNames));
|
|
|
|
for (uint32_t i = 0; i < ArrayLength(gPrefLangNames); i++) {
|
|
|
|
nsAutoCString prefDefaultFontType("font.default.");
|
|
|
|
prefDefaultFontType.Append(GetPrefLangName(eFontPrefLang(i)));
|
|
|
|
nsAdoptingCString serifOrSans =
|
|
|
|
Preferences::GetCString(prefDefaultFontType.get());
|
|
|
|
if (serifOrSans.EqualsLiteral("sans-serif")) {
|
|
|
|
mDefaultGenericsLangGroup[i] = eFamily_sans_serif;
|
|
|
|
} else {
|
|
|
|
mDefaultGenericsLangGroup[i] = eFamily_serif;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uint32_t(aLang) < ArrayLength(gPrefLangNames)) {
|
|
|
|
return mDefaultGenericsLangGroup[uint32_t(aLang)];
|
|
|
|
}
|
|
|
|
return eFamily_serif;
|
|
|
|
}
|
|
|
|
|
2014-01-29 07:39:01 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::GetFontFamilyNames(nsTArray<nsString>& aFontFamilyNames)
|
|
|
|
{
|
2015-09-24 15:31:30 +00:00
|
|
|
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxFontFamily>& family = iter.Data();
|
2015-09-24 15:31:30 +00:00
|
|
|
aFontFamilyNames.AppendElement(family->Name());
|
|
|
|
}
|
2014-01-29 07:39:01 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 15:31:30 +00:00
|
|
|
void
|
2009-08-16 13:52:12 +00:00
|
|
|
gfxPlatformFontList::InitLoader()
|
|
|
|
{
|
2014-01-29 07:39:01 +00:00
|
|
|
GetFontFamilyNames(mFontInfo->mFontFamiliesToLoad);
|
2009-08-16 13:52:12 +00:00
|
|
|
mStartIndex = 0;
|
2014-01-29 07:39:01 +00:00
|
|
|
mNumFamilies = mFontInfo->mFontFamiliesToLoad.Length();
|
|
|
|
memset(&(mFontInfo->mLoadStats), 0, sizeof(mFontInfo->mLoadStats));
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
2013-12-06 03:47:46 +00:00
|
|
|
#define FONT_LOADER_MAX_TIMESLICE 100 // max time for one pass through RunLoader = 100ms
|
|
|
|
|
2012-03-09 02:05:40 +00:00
|
|
|
bool
|
2014-01-29 07:39:01 +00:00
|
|
|
gfxPlatformFontList::LoadFontInfo()
|
2009-08-16 13:52:12 +00:00
|
|
|
{
|
2013-12-06 03:47:46 +00:00
|
|
|
TimeStamp start = TimeStamp::Now();
|
2014-01-29 07:39:01 +00:00
|
|
|
uint32_t i, endIndex = mNumFamilies;
|
2012-03-09 02:05:40 +00:00
|
|
|
bool loadCmaps = !UsesSystemFallback() ||
|
|
|
|
gfxPlatform::GetPlatform()->UseCmapsDuringSystemFallback();
|
2009-08-16 13:52:12 +00:00
|
|
|
|
|
|
|
// for each font family, load in various font info
|
|
|
|
for (i = mStartIndex; i < endIndex; i++) {
|
2014-01-29 07:39:01 +00:00
|
|
|
nsAutoString key;
|
|
|
|
gfxFontFamily *familyEntry;
|
|
|
|
GenerateFontListKey(mFontInfo->mFontFamiliesToLoad[i], key);
|
|
|
|
|
|
|
|
// lookup in canonical (i.e. English) family name list
|
|
|
|
if (!(familyEntry = mFontFamilies.GetWeak(key))) {
|
2010-02-11 11:59:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2014-01-29 07:39:01 +00:00
|
|
|
// read in face names
|
|
|
|
familyEntry->ReadFaceNames(this, NeedFullnamePostscriptNames(), mFontInfo);
|
|
|
|
|
2012-03-09 02:05:40 +00:00
|
|
|
// load the cmaps if needed
|
|
|
|
if (loadCmaps) {
|
2014-01-29 07:39:01 +00:00
|
|
|
familyEntry->ReadAllCMAPs(mFontInfo);
|
2012-03-09 02:05:40 +00:00
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
|
2013-12-06 03:47:46 +00:00
|
|
|
// limit the time spent reading fonts in one pass
|
|
|
|
TimeDuration elapsed = TimeStamp::Now() - start;
|
|
|
|
if (elapsed.ToMilliseconds() > FONT_LOADER_MAX_TIMESLICE &&
|
|
|
|
i + 1 != endIndex) {
|
|
|
|
endIndex = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
2010-02-11 11:59:47 +00:00
|
|
|
mStartIndex = endIndex;
|
2014-01-29 07:39:01 +00:00
|
|
|
bool done = mStartIndex >= mNumFamilies;
|
|
|
|
|
|
|
|
if (LOG_FONTINIT_ENABLED()) {
|
|
|
|
TimeDuration elapsed = TimeStamp::Now() - start;
|
|
|
|
LOG_FONTINIT(("(fontinit) fontloader load pass %8.2f ms done %s\n",
|
|
|
|
elapsed.ToMilliseconds(), (done ? "true" : "false")));
|
|
|
|
}
|
2010-02-11 11:59:47 +00:00
|
|
|
|
2014-04-17 14:17:22 +00:00
|
|
|
if (done) {
|
|
|
|
mOtherFamilyNamesInitialized = true;
|
2014-04-23 05:20:20 +00:00
|
|
|
mFaceNameListsInitialized = true;
|
2014-04-17 14:17:22 +00:00
|
|
|
}
|
|
|
|
|
2014-01-29 07:39:01 +00:00
|
|
|
return done;
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 07:39:01 +00:00
|
|
|
gfxPlatformFontList::CleanupLoader()
|
2009-08-16 13:52:12 +00:00
|
|
|
{
|
|
|
|
mFontFamiliesToLoad.Clear();
|
|
|
|
mNumFamilies = 0;
|
2014-04-23 05:20:21 +00:00
|
|
|
bool rebuilt = false, forceReflow = false;
|
2014-04-23 05:20:20 +00:00
|
|
|
|
|
|
|
// if had missed face names that are now available, force reflow all
|
2015-07-14 02:08:31 +00:00
|
|
|
if (mFaceNamesMissed) {
|
|
|
|
for (auto it = mFaceNamesMissed->Iter(); !it.Done(); it.Next()) {
|
|
|
|
if (FindFaceName(it.Get()->GetKey())) {
|
|
|
|
rebuilt = true;
|
|
|
|
RebuildLocalFonts();
|
|
|
|
break;
|
|
|
|
}
|
2014-04-23 05:20:20 +00:00
|
|
|
}
|
|
|
|
mFaceNamesMissed = nullptr;
|
|
|
|
}
|
2014-01-29 07:39:01 +00:00
|
|
|
|
2014-04-23 05:20:21 +00:00
|
|
|
if (mOtherNamesMissed) {
|
2015-07-14 02:08:31 +00:00
|
|
|
for (auto it = mOtherNamesMissed->Iter(); !it.Done(); it.Next()) {
|
|
|
|
if (FindFamily(it.Get()->GetKey())) {
|
|
|
|
forceReflow = true;
|
|
|
|
ForceGlobalReflow();
|
|
|
|
break;
|
|
|
|
}
|
2014-04-23 05:20:21 +00:00
|
|
|
}
|
2015-07-14 02:08:31 +00:00
|
|
|
mOtherNamesMissed = nullptr;
|
2014-04-23 05:20:21 +00:00
|
|
|
}
|
|
|
|
|
2014-01-29 07:39:01 +00:00
|
|
|
if (LOG_FONTINIT_ENABLED() && mFontInfo) {
|
|
|
|
LOG_FONTINIT(("(fontinit) fontloader load thread took %8.2f ms "
|
|
|
|
"%d families %d fonts %d cmaps "
|
2014-04-23 05:20:21 +00:00
|
|
|
"%d facenames %d othernames %s %s",
|
2014-01-29 07:39:01 +00:00
|
|
|
mLoadTime.ToMilliseconds(),
|
|
|
|
mFontInfo->mLoadStats.families,
|
|
|
|
mFontInfo->mLoadStats.fonts,
|
|
|
|
mFontInfo->mLoadStats.cmaps,
|
|
|
|
mFontInfo->mLoadStats.facenames,
|
2014-04-23 05:20:20 +00:00
|
|
|
mFontInfo->mLoadStats.othernames,
|
2014-04-23 05:20:21 +00:00
|
|
|
(rebuilt ? "(userfont sets rebuilt)" : ""),
|
|
|
|
(forceReflow ? "(global reflow)" : "")));
|
2014-01-29 07:39:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontInfoLoader::CleanupLoader();
|
2009-08-16 13:52:12 +00:00
|
|
|
}
|
2012-03-27 21:38:39 +00:00
|
|
|
|
2013-04-26 07:40:44 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::GetPrefsAndStartLoader()
|
|
|
|
{
|
|
|
|
mIncrement =
|
|
|
|
std::max(1u, Preferences::GetUint(FONT_LOADER_FAMILIES_PER_SLICE_PREF));
|
|
|
|
|
|
|
|
uint32_t delay =
|
|
|
|
std::max(1u, Preferences::GetUint(FONT_LOADER_DELAY_PREF));
|
|
|
|
uint32_t interval =
|
|
|
|
std::max(1u, Preferences::GetUint(FONT_LOADER_INTERVAL_PREF));
|
|
|
|
|
|
|
|
StartLoader(delay, interval);
|
|
|
|
}
|
|
|
|
|
2014-04-17 14:17:22 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::ForceGlobalReflow()
|
|
|
|
{
|
|
|
|
// modify a preference that will trigger reflow everywhere
|
|
|
|
static const char kPrefName[] = "font.internaluseonly.changed";
|
|
|
|
bool fontInternalChange = Preferences::GetBool(kPrefName, false);
|
|
|
|
Preferences::SetBool(kPrefName, !fontInternalChange);
|
|
|
|
}
|
|
|
|
|
2015-07-14 02:08:31 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::RebuildLocalFonts()
|
|
|
|
{
|
|
|
|
for (auto it = mUserFontSetList.Iter(); !it.Done(); it.Next()) {
|
|
|
|
it.Get()->GetKey()->RebuildLocalRules();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
void
|
|
|
|
gfxPlatformFontList::ClearLangGroupPrefFonts()
|
|
|
|
{
|
2015-09-29 01:51:29 +00:00
|
|
|
for (uint32_t i = eFontPrefLang_First;
|
|
|
|
i < eFontPrefLang_First + eFontPrefLang_Count; i++) {
|
|
|
|
auto& prefFontsLangGroup = mLangGroupPrefFonts[i];
|
|
|
|
for (uint32_t j = eFamily_generic_first;
|
|
|
|
j < eFamily_generic_first + eFamily_generic_count; j++) {
|
|
|
|
prefFontsLangGroup[j] = nullptr;
|
2015-09-29 01:51:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-27 21:38:39 +00:00
|
|
|
// Support for memory reporting
|
|
|
|
|
2015-07-31 04:19:57 +00:00
|
|
|
// this is also used by subclasses that hold additional font tables
|
2012-03-27 21:38:39 +00:00
|
|
|
/*static*/ size_t
|
2015-07-31 04:19:57 +00:00
|
|
|
gfxPlatformFontList::SizeOfFontFamilyTableExcludingThis(
|
|
|
|
const FontFamilyTable& aTable,
|
|
|
|
MallocSizeOf aMallocSizeOf)
|
2012-03-27 21:38:39 +00:00
|
|
|
{
|
2015-07-31 04:19:57 +00:00
|
|
|
size_t n = aTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
for (auto iter = aTable.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
// We don't count the size of the family here, because this is an
|
|
|
|
// *extra* reference to a family that will have already been counted in
|
|
|
|
// the main list.
|
|
|
|
n += iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
|
|
|
}
|
|
|
|
return n;
|
2012-03-27 21:38:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-05 01:05:19 +00:00
|
|
|
/*static*/ size_t
|
|
|
|
gfxPlatformFontList::SizeOfFontEntryTableExcludingThis(
|
|
|
|
const FontEntryTable& aTable,
|
|
|
|
MallocSizeOf aMallocSizeOf)
|
|
|
|
{
|
|
|
|
size_t n = aTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
for (auto iter = aTable.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
// The font itself is counted by its owning family; here we only care
|
|
|
|
// about the names stored in the hashtable keys.
|
|
|
|
n += iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-03-27 21:38:39 +00:00
|
|
|
void
|
2013-10-15 02:19:47 +00:00
|
|
|
gfxPlatformFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const
|
2012-03-27 21:38:39 +00:00
|
|
|
{
|
|
|
|
aSizes->mFontListSize +=
|
2015-07-31 04:19:57 +00:00
|
|
|
mFontFamilies.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
for (auto iter = mFontFamilies.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
aSizes->mFontListSize +=
|
|
|
|
iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
|
|
|
iter.Data()->AddSizeOfIncludingThis(aMallocSizeOf, aSizes);
|
|
|
|
}
|
2012-03-27 21:38:39 +00:00
|
|
|
|
|
|
|
aSizes->mFontListSize +=
|
2015-07-31 04:19:57 +00:00
|
|
|
SizeOfFontFamilyTableExcludingThis(mOtherFamilyNames, aMallocSizeOf);
|
2012-03-27 21:38:39 +00:00
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
if (mExtraNames) {
|
2012-03-27 21:38:39 +00:00
|
|
|
aSizes->mFontListSize +=
|
2015-08-05 01:05:19 +00:00
|
|
|
SizeOfFontEntryTableExcludingThis(mExtraNames->mFullnames,
|
|
|
|
aMallocSizeOf);
|
2012-03-27 21:38:39 +00:00
|
|
|
aSizes->mFontListSize +=
|
2015-08-05 01:05:19 +00:00
|
|
|
SizeOfFontEntryTableExcludingThis(mExtraNames->mPostscriptNames,
|
|
|
|
aMallocSizeOf);
|
2012-03-27 21:38:39 +00:00
|
|
|
}
|
|
|
|
|
2015-09-29 01:51:29 +00:00
|
|
|
for (uint32_t i = eFontPrefLang_First;
|
|
|
|
i < eFontPrefLang_First + eFontPrefLang_Count; i++) {
|
|
|
|
auto& prefFontsLangGroup = mLangGroupPrefFonts[i];
|
|
|
|
for (uint32_t j = eFamily_generic_first;
|
|
|
|
j < eFamily_generic_first + eFamily_generic_count; j++) {
|
|
|
|
PrefFontList* pf = prefFontsLangGroup[j];
|
|
|
|
if (pf) {
|
|
|
|
aSizes->mFontListSize +=
|
|
|
|
pf->ShallowSizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-27 21:38:39 +00:00
|
|
|
aSizes->mFontListSize +=
|
|
|
|
mCodepointsWithNoFonts.SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
aSizes->mFontListSize +=
|
2015-07-29 06:24:24 +00:00
|
|
|
mFontFamiliesToLoad.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
2012-03-27 21:38:39 +00:00
|
|
|
|
|
|
|
aSizes->mFontListSize +=
|
2014-08-05 20:27:41 +00:00
|
|
|
mBadUnderlineFamilyNames.SizeOfExcludingThis(aMallocSizeOf);
|
2012-04-18 23:59:43 +00:00
|
|
|
|
|
|
|
aSizes->mFontListSize +=
|
2015-07-29 08:50:52 +00:00
|
|
|
mSharedCmaps.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
for (auto iter = mSharedCmaps.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
aSizes->mCharMapsSize +=
|
|
|
|
iter.Get()->GetKey()->SizeOfIncludingThis(aMallocSizeOf);
|
|
|
|
}
|
2012-03-27 21:38:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-10-15 02:19:47 +00:00
|
|
|
gfxPlatformFontList::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const
|
2012-03-27 21:38:39 +00:00
|
|
|
{
|
|
|
|
aSizes->mFontListSize += aMallocSizeOf(this);
|
2013-10-15 02:19:47 +00:00
|
|
|
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
2012-03-27 21:38:39 +00:00
|
|
|
}
|