diff --git a/app/pdb/font-select-cmds.c b/app/pdb/font-select-cmds.c index 949f9baa2c..32b6a600d4 100644 --- a/app/pdb/font-select-cmds.c +++ b/app/pdb/font-select-cmds.c @@ -29,6 +29,7 @@ #include "core/gimp.h" #include "core/gimpparamspecs.h" +#include "text/gimp-fonts.h" #include "gimppdb.h" #include "gimpprocedure.h" @@ -56,6 +57,7 @@ fonts_popup_invoker (GimpProcedure *procedure, { if (gimp->no_interface || ! gimp_pdb_lookup_procedure (gimp->pdb, font_callback) || + ! gimp_fonts_wait (gimp, error) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp->fonts, popup_title, font_callback, initial_font, NULL)) @@ -110,6 +112,7 @@ fonts_set_popup_invoker (GimpProcedure *procedure, { if (gimp->no_interface || ! gimp_pdb_lookup_procedure (gimp->pdb, font_callback) || + ! gimp_fonts_wait (gimp, error) || ! gimp_pdb_dialog_set (gimp, gimp->fonts, font_callback, font_name, NULL)) success = FALSE; diff --git a/app/pdb/fonts-cmds.c b/app/pdb/fonts-cmds.c index c170d9ec8d..18ca3ce777 100644 --- a/app/pdb/fonts-cmds.c +++ b/app/pdb/fonts-cmds.c @@ -47,6 +47,7 @@ fonts_refresh_invoker (GimpProcedure *procedure, GError **error) { gimp_fonts_load (gimp, error); + gimp_fonts_wait (gimp, NULL); return gimp_procedure_get_return_values (procedure, TRUE, NULL); } @@ -69,8 +70,14 @@ fonts_get_list_invoker (GimpProcedure *procedure, if (success) { - font_list = gimp_container_get_filtered_name_array (gimp->fonts, - filter, &num_fonts); + if (! gimp_fonts_wait (gimp, error)) + success = FALSE; + + if (success) + { + font_list = gimp_container_get_filtered_name_array (gimp->fonts, + filter, &num_fonts); + } } return_vals = gimp_procedure_get_return_values (procedure, success, diff --git a/app/pdb/text-tool-cmds.c b/app/pdb/text-tool-cmds.c index 0052998036..bdb3a47e8c 100644 --- a/app/pdb/text-tool-cmds.c +++ b/app/pdb/text-tool-cmds.c @@ -127,7 +127,8 @@ text_get_extents_fontname_invoker (GimpProcedure *procedure, { gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size); - success = text_get_extents (real_fontname, text, + success = text_get_extents (gimp, + real_fontname, text, &width, &height, &ascent, &descent); diff --git a/app/text/gimptext-compat.c b/app/text/gimptext-compat.c index 9eb602692e..49b248086d 100644 --- a/app/text/gimptext-compat.c +++ b/app/text/gimptext-compat.c @@ -37,6 +37,7 @@ #include "core/gimpimage-undo.h" #include "core/gimplayer-floating-selection.h" +#include "gimp-fonts.h" #include "gimptext.h" #include "gimptext-compat.h" #include "gimptextlayer.h" @@ -70,6 +71,9 @@ text_render (GimpImage *image, g_return_val_if_fail (fontname != NULL, NULL); g_return_val_if_fail (text != NULL, NULL); + if (! gimp_fonts_wait (image->gimp, NULL)) + return NULL; + if (border < 0) border = 0; @@ -133,7 +137,8 @@ text_render (GimpImage *image, } gboolean -text_get_extents (const gchar *fontname, +text_get_extents (Gimp *gimp, + const gchar *fontname, const gchar *text, gint *width, gint *height, @@ -146,9 +151,13 @@ text_get_extents (const gchar *fontname, PangoFontMap *fontmap; PangoRectangle rect; + g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); g_return_val_if_fail (fontname != NULL, FALSE); g_return_val_if_fail (text != NULL, FALSE); + if (! gimp_fonts_wait (gimp, NULL)) + return FALSE; + 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 " diff --git a/app/text/gimptext-compat.h b/app/text/gimptext-compat.h index 6f36fdc687..2ca6d5ab41 100644 --- a/app/text/gimptext-compat.h +++ b/app/text/gimptext-compat.h @@ -33,7 +33,8 @@ GimpLayer * text_render (GimpImage *image, const gchar *text, gint border, gboolean antialias); -gboolean text_get_extents (const gchar *fontname, +gboolean text_get_extents (Gimp *gimp, + const gchar *fontname, const gchar *text, gint *width, gint *height, diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c index e68c2c2384..d321e8b6e5 100644 --- a/app/text/gimptextlayer.c +++ b/app/text/gimptextlayer.c @@ -39,7 +39,6 @@ #include "core/gimp.h" #include "core/gimp-utils.h" -#include "core/gimpasyncset.h" #include "core/gimpcontext.h" #include "core/gimpcontainer.h" #include "core/gimpimage.h" @@ -49,6 +48,7 @@ #include "core/gimpitemtree.h" #include "core/gimpparasitelist.h" +#include "gimp-fonts.h" #include "gimptext.h" #include "gimptextlayer.h" #include "gimptextlayer-transform.h" @@ -629,14 +629,9 @@ gimp_text_layer_render (GimpTextLayer *layer) item = GIMP_ITEM (layer); image = gimp_item_get_image (item); - if (! gimp_async_set_is_empty (image->gimp->fonts_async_set)) - { - gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_ERROR, - _("Fonts are still loading (this may take a while), " - "text functionality is not available yet.")); - return FALSE; - } - else if (gimp_container_is_empty (image->gimp->fonts)) + gimp_fonts_wait (image->gimp, NULL); + + if (gimp_container_is_empty (image->gimp->fonts)) { gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_ERROR, _("Due to lack of any fonts, " diff --git a/pdb/groups/font_select.pdb b/pdb/groups/font_select.pdb index 5ec44fa32a..3fc233a9d3 100644 --- a/pdb/groups/font_select.pdb +++ b/pdb/groups/font_select.pdb @@ -36,6 +36,7 @@ sub fonts_popup { { if (gimp->no_interface || ! gimp_pdb_lookup_procedure (gimp->pdb, font_callback) || + ! gimp_fonts_wait (gimp, error) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp->fonts, popup_title, font_callback, initial_font, NULL)) @@ -86,6 +87,7 @@ sub fonts_set_popup { { if (gimp->no_interface || ! gimp_pdb_lookup_procedure (gimp->pdb, font_callback) || + ! gimp_fonts_wait (gimp, error) || ! gimp_pdb_dialog_set (gimp, gimp->fonts, font_callback, font_name, NULL)) success = FALSE; @@ -95,7 +97,8 @@ CODE } -@headers = qw("core/gimp.h"); +@headers = qw("core/gimp.h" + "text/gimp-fonts.h"); @procs = qw(fonts_popup fonts_close_popup diff --git a/pdb/groups/fonts.pdb b/pdb/groups/fonts.pdb index a5fb6187c2..c9c73f571b 100644 --- a/pdb/groups/fonts.pdb +++ b/pdb/groups/fonts.pdb @@ -31,6 +31,7 @@ HELP code => <<'CODE' { gimp_fonts_load (gimp, error); + gimp_fonts_wait (gimp, NULL); } CODE ); @@ -61,8 +62,14 @@ HELP headers => [ qw("core/gimpcontainer-filter.h") ], code => <<'CODE' { - font_list = gimp_container_get_filtered_name_array (gimp->fonts, - filter, &num_fonts); + if (! gimp_fonts_wait (gimp, error)) + success = FALSE; + + if (success) + { + font_list = gimp_container_get_filtered_name_array (gimp->fonts, + filter, &num_fonts); + } } CODE ); diff --git a/pdb/groups/text_tool.pdb b/pdb/groups/text_tool.pdb index 3b0c78cb00..15ec9f24ca 100644 --- a/pdb/groups/text_tool.pdb +++ b/pdb/groups/text_tool.pdb @@ -136,7 +136,8 @@ HELP { gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size); - success = text_get_extents (real_fontname, text, + success = text_get_extents (gimp, + real_fontname, text, &width, &height, &ascent, &descent);