mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1056479 p6 - handle font updates. r=jfkthame
This commit is contained in:
parent
27c91674de
commit
bc2095e1d1
@ -920,8 +920,35 @@ gfxFontConfigFont::GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams)
|
||||
}
|
||||
#endif
|
||||
|
||||
gfxFcPlatformFontList::gfxFcPlatformFontList()
|
||||
: mLocalNames(64), mGenericMappings(32), mLastConfig(nullptr)
|
||||
{
|
||||
// if the rescan interval is set, start the timer
|
||||
int rescanInterval = FcConfigGetRescanInterval(nullptr);
|
||||
if (rescanInterval) {
|
||||
mLastConfig = FcConfigGetCurrent();
|
||||
mCheckFontUpdatesTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
if (mCheckFontUpdatesTimer) {
|
||||
mCheckFontUpdatesTimer->
|
||||
InitWithFuncCallback(CheckFontUpdates, this,
|
||||
(rescanInterval + 1) * 1000,
|
||||
nsITimer::TYPE_REPEATING_SLACK);
|
||||
} else {
|
||||
NS_WARNING("Failure to create font updates timer");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
mBundledFontsInitialized = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
gfxFcPlatformFontList::~gfxFcPlatformFontList()
|
||||
{
|
||||
if (mCheckFontUpdatesTimer) {
|
||||
mCheckFontUpdatesTimer->Cancel();
|
||||
mCheckFontUpdatesTimer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -1008,6 +1035,8 @@ gfxFcPlatformFontList::AddFontSetFamilies(FcFontSet* aFontSet)
|
||||
nsresult
|
||||
gfxFcPlatformFontList::InitFontList()
|
||||
{
|
||||
mLastConfig = FcConfigGetCurrent();
|
||||
|
||||
// reset font lists
|
||||
gfxPlatformFontList::InitFontList();
|
||||
|
||||
@ -1394,6 +1423,21 @@ gfxFcPlatformFontList::FindGenericFamily(const nsAString& aGeneric,
|
||||
return genericFamily;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
gfxFcPlatformFontList::CheckFontUpdates(nsITimer *aTimer, void *aThis)
|
||||
{
|
||||
// check for font updates
|
||||
FcInitBringUptoDate();
|
||||
|
||||
// update fontlist if current config changed
|
||||
gfxFcPlatformFontList *pfl = static_cast<gfxFcPlatformFontList*>(aThis);
|
||||
FcConfig* current = FcConfigGetCurrent();
|
||||
if (current != pfl->GetLastConfig()) {
|
||||
pfl->UpdateFontList();
|
||||
pfl->ForceGlobalReflow();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
void
|
||||
gfxFcPlatformFontList::ActivateBundledFonts()
|
||||
|
@ -28,6 +28,13 @@ public:
|
||||
static void Release(FcObjectSet *ptr) { FcObjectSetDestroy(ptr); }
|
||||
};
|
||||
|
||||
template <>
|
||||
class nsAutoRefTraits<FcConfig> : public nsPointerRefTraits<FcConfig>
|
||||
{
|
||||
public:
|
||||
static void Release(FcConfig *ptr) { FcConfigDestroy(ptr); }
|
||||
static void AddRef(FcConfig *ptr) { FcConfigReference(ptr); }
|
||||
};
|
||||
|
||||
// Helper classes used for clearning out user font data when cairo font
|
||||
// face is destroyed. Since multiple faces may use the same data, be
|
||||
@ -187,13 +194,7 @@ protected:
|
||||
|
||||
class gfxFcPlatformFontList : public gfxPlatformFontList {
|
||||
public:
|
||||
gfxFcPlatformFontList()
|
||||
: mLocalNames(64), mGenericMappings(32)
|
||||
{
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
mBundledFontsInitialized = false;
|
||||
#endif
|
||||
}
|
||||
gfxFcPlatformFontList();
|
||||
|
||||
// initialize font lists
|
||||
nsresult InitFontList() override;
|
||||
@ -223,6 +224,8 @@ public:
|
||||
bool GetStandardFamilyName(const nsAString& aFontName,
|
||||
nsAString& aFamilyName) override;
|
||||
|
||||
FcConfig* GetLastConfig() const { return mLastConfig; }
|
||||
|
||||
static FT_Library GetFTLibrary();
|
||||
|
||||
protected:
|
||||
@ -236,6 +239,8 @@ protected:
|
||||
gfxFontFamily* FindGenericFamily(const nsAString& aGeneric,
|
||||
nsIAtom* aLanguage);
|
||||
|
||||
static void CheckFontUpdates(nsITimer *aTimer, void *aThis);
|
||||
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
void ActivateBundledFonts();
|
||||
nsCString mBundledFontsPath;
|
||||
@ -249,6 +254,9 @@ protected:
|
||||
// caching generic/lang ==> font family
|
||||
nsRefPtrHashtable<nsCStringHashKey, gfxFontFamily> mGenericMappings;
|
||||
|
||||
nsCOMPtr<nsITimer> mCheckFontUpdatesTimer;
|
||||
nsCountedRef<FcConfig> mLastConfig;
|
||||
|
||||
static FT_Library sCairoFTLibrary;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user