text: Fix loading XCFs with XLFD fonts
This commit is contained in:
parent
5f38c37b98
commit
4a174206af
6 changed files with 44 additions and 10 deletions
|
|
@ -524,6 +524,13 @@ gimp_font_match_by_lookup_name (GimpFont *font,
|
|||
return !g_strcmp0 (font->lookup_name, name);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_font_match_by_description (GimpFont *font,
|
||||
const gchar *desc)
|
||||
{
|
||||
return !g_strcmp0 (font->desc, desc);
|
||||
}
|
||||
|
||||
const gchar*
|
||||
gimp_font_get_lookup_name (GimpFont *font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ void gimp_font_set_lookup_name (GimpFont *font,
|
|||
gchar *name);
|
||||
gboolean gimp_font_match_by_lookup_name (GimpFont *font,
|
||||
const gchar *name);
|
||||
gboolean gimp_font_match_by_description (GimpFont *font,
|
||||
const gchar *desc);
|
||||
void gimp_font_set_font_info (GimpFont *font,
|
||||
gpointer font_info[]);
|
||||
void gimp_font_class_set_font_factory (GimpFontFactory *factory);
|
||||
|
|
|
|||
|
|
@ -221,7 +221,8 @@ enum
|
|||
};
|
||||
|
||||
GimpText *
|
||||
gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
||||
gimp_text_from_gdyntext_parasite (Gimp *gimp,
|
||||
const GimpParasite *parasite)
|
||||
{
|
||||
GimpText *retval = NULL;
|
||||
GimpTextJustification justify;
|
||||
|
|
@ -281,6 +282,7 @@ gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
|||
color / 255.0f, 1.0);
|
||||
|
||||
retval = g_object_new (GIMP_TYPE_TEXT,
|
||||
"gimp", gimp,
|
||||
"text", text,
|
||||
"antialias", antialias,
|
||||
"justify", justify,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ GimpText * gimp_text_from_parasite (const GimpParasite *parasite,
|
|||
GError **error);
|
||||
|
||||
const gchar * gimp_text_gdyntext_parasite_name (void) G_GNUC_CONST;
|
||||
GimpText * gimp_text_from_gdyntext_parasite (const GimpParasite *parasite);
|
||||
GimpText * gimp_text_from_gdyntext_parasite (Gimp *gimp,
|
||||
const GimpParasite *parasite);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_PARASITE_H__ */
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <pango/pango.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -31,6 +32,11 @@
|
|||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "core/core-types.h"
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpdatafactory.h"
|
||||
|
||||
#include "text-types.h"
|
||||
|
||||
#include "gimpfont.h"
|
||||
|
|
@ -192,11 +198,27 @@ gimp_text_set_font_from_xlfd (GimpText *text,
|
|||
font_name = gimp_text_font_name_from_xlfd (xlfd);
|
||||
if (font_name != NULL)
|
||||
{
|
||||
font = g_object_new (GIMP_TYPE_FONT,
|
||||
"name", font_name,
|
||||
NULL);
|
||||
gimp_font_set_lookup_name (font, font_name);
|
||||
PangoFontDescription *pfd = pango_font_description_from_string (font_name);
|
||||
gchar *desc = pango_font_description_to_string (pfd);
|
||||
GimpContainer *fonts_container;
|
||||
|
||||
fonts_container = gimp_data_factory_get_container (text->gimp->font_factory);
|
||||
|
||||
font = GIMP_FONT (gimp_container_search (fonts_container,
|
||||
(GimpContainerSearchFunc) gimp_font_match_by_description,
|
||||
(gpointer) desc));
|
||||
if (font == NULL)
|
||||
font = GIMP_FONT (gimp_font_get_standard ());
|
||||
|
||||
pango_font_description_free (pfd);
|
||||
g_free (desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
font = GIMP_FONT (gimp_font_get_standard ());
|
||||
}
|
||||
|
||||
g_object_ref (font);
|
||||
|
||||
#if GIMP_TEXT_DEBUG
|
||||
g_printerr ("XLFD: %s font: %s\n", xlfd, font ? font : "(null)");
|
||||
|
|
@ -207,10 +229,10 @@ gimp_text_set_font_from_xlfd (GimpText *text,
|
|||
g_object_set (text,
|
||||
"font-size", size,
|
||||
"font-size-unit", size_unit,
|
||||
font_name ? "font" : NULL, font,
|
||||
"font", font,
|
||||
NULL);
|
||||
}
|
||||
else if (font)
|
||||
else
|
||||
{
|
||||
g_object_set (text,
|
||||
"font", font,
|
||||
|
|
@ -218,7 +240,6 @@ gimp_text_set_font_from_xlfd (GimpText *text,
|
|||
}
|
||||
|
||||
g_free (font_name);
|
||||
g_object_unref (font);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ gimp_text_layer_xcf_load_hack (GimpLayer **layer)
|
|||
|
||||
if (parasite)
|
||||
{
|
||||
text = gimp_text_from_gdyntext_parasite (parasite);
|
||||
text = gimp_text_from_gdyntext_parasite (gimp_item_get_image (GIMP_ITEM (*layer))->gimp,
|
||||
parasite);
|
||||
before_xcf_v19 = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue