void gimp_fonts_load (Gimp *gimp) { FcConfig *config; GFile *fonts_conf; GList *path; g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts)); gimp_set_busy (gimp); if (gimp->be_verbose) g_print ("Loading fonts\n"); gimp_container_freeze (GIMP_CONTAINER (gimp->fonts)); gimp_container_clear (GIMP_CONTAINER (gimp->fonts)); config = FcInitLoadConfig (); if (! config) goto cleanup; fonts_conf = gimp_directory_file (CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; fonts_conf = gimp_sysconf_directory_file (CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; path = gimp_config_path_expand_to_files (gimp->config->font_path, FALSE); gimp_fonts_add_directories (config, path); g_list_free_full (path, (GDestroyNotify) g_object_unref); if (! FcConfigBuildFonts (config)) { FcConfigDestroy (config); goto cleanup; } FcConfigSetCurrent (config); gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts)); cleanup: gimp_container_thaw (GIMP_CONTAINER (gimp->fonts)); gimp_unset_busy (gimp); }
void gimp_fonts_load (Gimp *gimp) { FcConfig *config; gchar *fonts_conf; gchar *path; g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts)); gimp_set_busy (gimp); if (gimp->be_verbose) g_print ("Loading fonts\n"); gimp_container_freeze (GIMP_CONTAINER (gimp->fonts)); gimp_container_clear (GIMP_CONTAINER (gimp->fonts)); config = FcInitLoadConfig (); if (! config) goto cleanup; fonts_conf = gimp_personal_rc_file (CONF_FNAME); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; fonts_conf = g_build_filename (gimp_sysconf_directory (), CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; path = gimp_config_path_expand (gimp->config->font_path, TRUE, NULL); gimp_fonts_add_directories (config, path); g_free (path); if (! FcConfigBuildFonts (config)) { FcConfigDestroy (config); goto cleanup; } FcConfigSetCurrent (config); gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts)); cleanup: gimp_container_thaw (GIMP_CONTAINER (gimp->fonts)); gimp_unset_busy (gimp); }
void gimp_fonts_load (Gimp *gimp, GimpInitStatusFunc status_callback) { FcConfig *config; GFile *fonts_conf; GList *path; g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts)); gimp_set_busy (gimp); if (gimp->be_verbose) g_print ("Loading fonts\n"); gimp_container_freeze (GIMP_CONTAINER (gimp->fonts)); gimp_container_clear (GIMP_CONTAINER (gimp->fonts)); config = FcInitLoadConfig (); if (! config) goto cleanup; fonts_conf = gimp_directory_file (CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; fonts_conf = gimp_sysconf_directory_file (CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; path = gimp_config_path_expand_to_files (gimp->config->font_path, FALSE); gimp_fonts_add_directories (config, path); g_list_free_full (path, (GDestroyNotify) g_object_unref); if (status_callback) { gint64 end_time; GThread *cache_thread; GimpFontsLoadFuncData data; /* We perform font cache initialization in a separate thread, so * in the case a cache rebuild is to be done it will not block * the UI. */ data.config = config; g_mutex_init (&data.mutex); g_cond_init (&data.cond); data.caching_complete = FALSE; cache_thread = g_thread_new ("font-cacher", (GThreadFunc) gimp_fonts_load_thread, &data); g_mutex_lock (&data.mutex); end_time = g_get_monotonic_time () + 0.1 * G_TIME_SPAN_SECOND; while (! data.caching_complete) if (! g_cond_wait_until (&data.cond, &data.mutex, end_time)) { status_callback (NULL, NULL, 0.6); end_time += 0.1 * G_TIME_SPAN_SECOND; continue; } g_mutex_unlock (&data.mutex); g_thread_join (cache_thread); g_mutex_clear (&data.mutex); g_cond_clear (&data.cond); } else { gimp_fonts_load_func (config); } gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts)); cleanup: gimp_container_thaw (GIMP_CONTAINER (gimp->fonts)); gimp_unset_busy (gimp); }