Ejemplo n.º 1
0
int XSetFontPath(Display* display, char** directories, int ndirs) {
    SET_X_SERVER_REQUEST(display, X_SetFontPath);
    char* path;
    size_t i;
    while (fontSearchPaths->length > 0) {
        // Clear the array and free the data
        free(removeArray(fontSearchPaths, 0, False));
    }
    if (directories == NULL || ndirs == 0) {
        // Reset the search path to the default for the compiled platform
        ndirs = ARRAY_LENGTH(DEFAULT_FONT_SEARCH_PATHS);
        directories = (char **) DEFAULT_FONT_SEARCH_PATHS;
    }
    for (i = 0; i < ndirs; i++) {
        if (checkFontPath(directories[i])) {
            path = strdup(directories[i]);
            if (path == NULL) {
                handleOutOfMemory(0, display, 0, 0);
            } else {
                insertArray(fontSearchPaths, path);
            }
        }
    }
    return updateFontCache() ? 1 : 0;
}
Ejemplo n.º 2
0
void FontEngine::readSettings()
{
		m_default_size[FM_Standard] = m_settings->getU16("font_size");
		m_default_size[FM_Fallback] = m_settings->getU16("fallback_font_size");
		m_default_size[FM_Mono]     = m_settings->getU16("mono_font_size");

		if (is_yes(_("needs_fallback_font"))) {
			m_currentMode = FM_Fallback;
		}
		else {
			m_currentMode = FM_Standard;
		}
	m_default_size[FM_Simple]       = m_settings->getU16("font_size");
	m_default_size[FM_SimpleMono]   = m_settings->getU16("mono_font_size");

	cleanCache();
	updateFontCache();
	updateSkin();
}
Ejemplo n.º 3
0
void FontEngine::readSettings()
{
#if USE_FREETYPE
	if (g_settings->getBool("freetype")) {
		m_default_size[FM_Standard] = m_settings->getU16("font_size");
		m_default_size[FM_Fallback] = m_settings->getU16("fallback_font_size");
		m_default_size[FM_Mono]     = m_settings->getU16("mono_font_size");

		if (is_yes(gettext("needs_fallback_font"))) {
			m_currentMode = FM_Fallback;
		}
		else {
			m_currentMode = FM_Standard;
		}
	}
#endif
	m_default_size[FM_Simple]       = m_settings->getU16("font_size");
	m_default_size[FM_SimpleMono]   = m_settings->getU16("mono_font_size");

	cleanCache();
	updateFontCache();
	updateSkin();
}
Ejemplo n.º 4
0
Bool initFontStorage() {
    size_t fontCount = 0;
    DIR* fontDirectory;
    struct dirent* entry;
    fontSearchPaths = malloc(sizeof(Array));
    if (fontSearchPaths == NULL) {
        return False;
    }
    if (!initArray(fontSearchPaths, ARRAY_LENGTH(DEFAULT_FONT_SEARCH_PATHS))) {
        return False;
    }
    for (size_t i = 0; i < ARRAY_LENGTH(DEFAULT_FONT_SEARCH_PATHS); i++) {
        const char *path = DEFAULT_FONT_SEARCH_PATHS[i];
        if (checkFontPath(path)) {
            fontDirectory = opendir(path);
            if (fontDirectory == NULL) continue;
            path = strdup(path);
            if (path == NULL) return False;
            insertArray(fontSearchPaths, (char*) path);
            // Count the font files in the directory
            while ((entry = readdir(fontDirectory)) != NULL) {
                if (strncmp(&entry->d_name[strlen(entry->d_name) - 4], ".ttf", 4) == 0) {
                    fontCount++;
                }
            }
            closedir(fontDirectory);
        }
    }
    fontCache = malloc(sizeof(Array));
    if (fontCache == NULL) {
        return False;
    }
    if (!initArray(fontCache, fontCount)) {
        return False;
    }
    return updateFontCache();
}