mirror of https://github.com/GNOME/gimp.git
app, pdb: wait for fonts to load before dependent operations
Use gimp_fonts_wait(), added in the previous commit, to wait for fonts to finish loading before operations that depend on font availability. In particular, this includes font- and text-related PDB functions, and text-layer rendering.
This commit is contained in:
parent
0a5a4fed03
commit
f2134180de
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 "
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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, "
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue