void gimp_font_list_restore (GimpFontList *list) { PangoFontMap *fontmap; PangoContext *context; g_return_if_fail (GIMP_IS_FONT_LIST (list)); fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); if (! fontmap) g_error ("You are using a Pango that has been built against a cairo " "that lacks the Freetype font backend"); pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), list->yresolution); context = pango_font_map_create_context (fontmap); g_object_unref (fontmap); gimp_container_freeze (GIMP_CONTAINER (list)); gimp_font_list_load_names (list, PANGO_FONT_MAP (fontmap), context); g_object_unref (context); gimp_list_sort_by_name (GIMP_LIST (list)); gimp_container_thaw (GIMP_CONTAINER (list)); }
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_font_list_restore (GimpFontList *list) { PangoFontMap *fontmap; PangoContext *context; g_return_if_fail (GIMP_IS_FONT_LIST (list)); if (font_desc_to_string == NULL) { PangoFontDescription *desc; gchar *name; gchar last_char; desc = pango_font_description_new (); pango_font_description_set_family (desc, "Wilber 12"); name = pango_font_description_to_string (desc); last_char = name[strlen (name) - 1]; g_free (name); pango_font_description_free (desc); if (last_char != ',') font_desc_to_string = &gimp_font_util_pango_font_description_to_string; else font_desc_to_string = &pango_font_description_to_string; } fontmap = pango_ft2_font_map_new (); pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), list->xresolution, list->yresolution); context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap)); g_object_unref (fontmap); gimp_container_freeze (GIMP_CONTAINER (list)); gimp_font_list_load_names (list, fontmap, context); g_object_unref (context); gimp_list_sort_by_name (GIMP_LIST (list)); gimp_container_thaw (GIMP_CONTAINER (list)); }
static void gimp_text_style_editor_constructed (GObject *object) { GimpTextStyleEditor *editor = GIMP_TEXT_STYLE_EDITOR (object); if (G_OBJECT_CLASS (parent_class)->constructed) G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (GIMP_IS_GIMP (editor->gimp)); g_assert (GIMP_IS_FONT_LIST (editor->fonts)); g_assert (GIMP_IS_TEXT (editor->text)); g_assert (GIMP_IS_TEXT_BUFFER (editor->buffer)); editor->context = gimp_context_new (editor->gimp, "text style editor", NULL); g_signal_connect (editor->context, "font-changed", G_CALLBACK (gimp_text_style_editor_font_changed), editor); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_entry), 0, editor->resolution_y, TRUE); /* use the global user context so we get the global FG/BG colors */ gimp_color_panel_set_context (GIMP_COLOR_PANEL (editor->color_button), gimp_get_user_context (editor->gimp)); gimp_container_view_set_container (GIMP_CONTAINER_VIEW (editor->font_entry), editor->fonts); gimp_container_view_set_context (GIMP_CONTAINER_VIEW (editor->font_entry), editor->context); gimp_text_style_editor_create_toggle (editor, editor->buffer->bold_tag, GTK_STOCK_BOLD, _("Bold")); gimp_text_style_editor_create_toggle (editor, editor->buffer->italic_tag, GTK_STOCK_ITALIC, _("Italic")); gimp_text_style_editor_create_toggle (editor, editor->buffer->underline_tag, GTK_STOCK_UNDERLINE, _("Underline")); gimp_text_style_editor_create_toggle (editor, editor->buffer->strikethrough_tag, GTK_STOCK_STRIKETHROUGH, _("Strikethrough")); g_signal_connect_swapped (editor->text, "notify::font", G_CALLBACK (gimp_text_style_editor_update), editor); g_signal_connect_swapped (editor->text, "notify::font-size", G_CALLBACK (gimp_text_style_editor_update), editor); g_signal_connect_swapped (editor->text, "notify::font-size-unit", G_CALLBACK (gimp_text_style_editor_update), editor); g_signal_connect_swapped (editor->text, "notify::color", G_CALLBACK (gimp_text_style_editor_update), editor); g_signal_connect_data (editor->buffer, "changed", G_CALLBACK (gimp_text_style_editor_update), editor, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); g_signal_connect_data (editor->buffer, "apply-tag", G_CALLBACK (gimp_text_style_editor_update), editor, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); g_signal_connect_data (editor->buffer, "remove-tag", G_CALLBACK (gimp_text_style_editor_update), editor, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); g_signal_connect_data (editor->buffer, "mark-set", G_CALLBACK (gimp_text_style_editor_update), editor, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); }
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); }