From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- gfx/thebes/gfxPlatformFontList.cpp | 44 +++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'gfx/thebes/gfxPlatformFontList.cpp') diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index 709a0f3c27..bc0e123f85 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -378,6 +378,40 @@ gfxPlatformFontList::~gfxPlatformFontList() { NS_RELEASE(gFontListPrefObserver); } +void gfxPlatformFontList::GetMissingFonts(nsCString& aMissingFonts) { + AutoLock lock(mLock); + + auto fontLists = GetFilteredPlatformFontLists(); + + if (!fontLists.Length()) { + aMissingFonts.Append("No font list available for this device."); + } + + for (unsigned int i = 0; i < fontLists.Length(); i++) { + for (unsigned int j = 0; j < fontLists[i].second; j++) { + nsCString key(fontLists[i].first[j]); + GenerateFontListKey(key); + + if (SharedFontList()) { + fontlist::Family* family = SharedFontList()->FindFamily(key); + if (!family) { + aMissingFonts.Append(fontLists[i].first[j]); + aMissingFonts.Append("|"); + } + } else { + gfxFontFamily* familyEntry = mFontFamilies.GetWeak(key); + if (!familyEntry) { + familyEntry = mOtherFamilyNames.GetWeak(key); + } + if (!familyEntry) { + aMissingFonts.Append(fontLists[i].first[j]); + aMissingFonts.Append("|"); + } + } + } + } +} + /* static */ void gfxPlatformFontList::FontWhitelistPrefChanged(const char* aPref, void* aClosure) { @@ -700,6 +734,10 @@ void gfxPlatformFontList::GenerateFontListKey(const nsACString& aKeyName, ToLowerCase(aResult); } +void gfxPlatformFontList::GenerateFontListKey(nsACString& aKeyName) { + ToLowerCase(aKeyName); +} + // Used if a stylo thread wants to trigger InitOtherFamilyNames in the main // process: we can't do IPC from the stylo thread so we post this to the main // thread instead. @@ -755,7 +793,7 @@ bool gfxPlatformFontList::InitOtherFamilyNames( // (This is used so we can reliably run reftests that depend on localized // font-family names being available.) if (aDeferOtherFamilyNamesLoading && - StaticPrefs::gfx_font_loader_delay_AtStartup() > 0) { + StaticPrefs::gfx_font_loader_delay() > 0) { if (!mPendingOtherFamilyNameTask) { RefPtr task = new InitOtherFamilyNamesRunnable(); @@ -2648,7 +2686,7 @@ bool gfxPlatformFontList::LoadFontInfo() { // Limit the time spent reading fonts in one pass, unless the font-loader // delay was set to zero, in which case we run to completion even if it // causes some jank. - if (StaticPrefs::gfx_font_loader_delay_AtStartup() > 0) { + if (StaticPrefs::gfx_font_loader_delay() > 0) { TimeDuration elapsed = TimeStamp::Now() - start; if (elapsed.ToMilliseconds() > FONT_LOADER_MAX_TIMESLICE && i + 1 != endIndex) { @@ -2751,7 +2789,7 @@ void gfxPlatformFontList::GetPrefsAndStartLoader() { if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) { return; } - uint32_t delay = std::max(1u, StaticPrefs::gfx_font_loader_delay_AtStartup()); + uint32_t delay = std::max(1u, StaticPrefs::gfx_font_loader_delay()); if (NS_IsMainThread()) { StartLoader(delay); } else { -- cgit v1.2.3