コード例 #1
0
void populateFontDatabase()
{
    static bool initialized;
    if (initialized)
        return;
    initialized = true;

    if (wkCanCreateCGFontWithLOGFONT())
        return;

    RetainPtr<CFPropertyListRef> propertyList = readFontPlist();
    RetainPtr<CFArrayRef> lastFilenamesFromRegistry;
    if (propertyList && CFGetTypeID(propertyList.get()) == CFDictionaryGetTypeID()) {
        CFDictionaryRef dictionary = static_cast<CFDictionaryRef>(propertyList.get());
        CFArrayRef array = static_cast<CFArrayRef>(CFDictionaryGetValue(dictionary, fontFilenamesFromRegistryKey()));
        if (array && CFGetTypeID(array) == CFArrayGetTypeID())
            lastFilenamesFromRegistry = array;
    }
    RetainPtr<CFArrayRef> currentFilenamesFromRegistry = fontFilenamesFromRegistry();
    bool registryChanged = !lastFilenamesFromRegistry || !CFEqual(lastFilenamesFromRegistry.get(), currentFilenamesFromRegistry.get());

    if (!registryChanged && !systemHasFontsNewerThanFontsPlist()) {
        if (populateFontDatabaseFromPlist(propertyList.get()))
            return;
    }

    if (populateFontDatabaseFromFileSystem()) {
        wkAddFontsFromRegistry();
        RetainPtr<CFPropertyListRef> cgFontDBPropertyList(AdoptCF, wkCreateFontsPlist());
        writeFontDatabaseToPlist(cgFontDBPropertyList.get(), currentFilenamesFromRegistry.get());
    }
}
コード例 #2
0
ファイル: FontDatabase.cpp プロジェクト: Czerrr/ISeeBrowser
void populateFontDatabase()
{
    static bool initialized;
    if (initialized)
        return;
    initialized = true;

    if (!systemHasFontsNewerThanFontsPlist())
        if (populateFontDatabaseFromPlist())
            return;

    if (populateFontDatabaseFromFileSystem())
        writeFontDatabaseToPlist();
}