mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
app, devel-docs, libgimp: updating gimp_text_layer_[gs]et_font() and new…
… function gimp_font_get_pango_font_description(). Also updating file-pdf-save which is the only plug-in using these right now. Note that I am not fully happy with the new function gimp_font_get_pango_font_description() because I experienced some weird behavior in file-pdf-save which is that some fonts were wrong if this is called after pango_cairo_font_map_set_resolution(). But let's say this is a first step looking for improvements.
This commit is contained in:
parent
faae47a9a8
commit
ea55b7a11a
15 changed files with 114 additions and 58 deletions
|
@ -255,26 +255,26 @@ text_layer_get_font_invoker (GimpProcedure *procedure,
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
GimpTextLayer *layer;
|
GimpTextLayer *layer;
|
||||||
gchar *font = NULL;
|
GimpFont *font = NULL;
|
||||||
|
|
||||||
layer = g_value_get_object (gimp_value_array_index (args, 0));
|
layer = g_value_get_object (gimp_value_array_index (args, 0));
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
GimpFont *font_obj;
|
|
||||||
|
|
||||||
g_object_get (gimp_text_layer_get_text (layer),
|
g_object_get (gimp_text_layer_get_text (layer),
|
||||||
"font", &font_obj,
|
"font", &font,
|
||||||
NULL);
|
NULL);
|
||||||
font = g_strdup (gimp_font_get_lookup_name (font_obj));
|
/* The GimpText keeps a reference. Therefore unref before returning the
|
||||||
g_object_unref (font_obj);
|
* pointer so that we don't leak a reference.
|
||||||
|
*/
|
||||||
|
g_object_unref (font);
|
||||||
}
|
}
|
||||||
|
|
||||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||||
error ? *error : NULL);
|
error ? *error : NULL);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
g_value_take_string (gimp_value_array_index (return_vals, 1), font);
|
g_value_set_object (gimp_value_array_index (return_vals, 1), font);
|
||||||
|
|
||||||
return return_vals;
|
return return_vals;
|
||||||
}
|
}
|
||||||
|
@ -289,10 +289,10 @@ text_layer_set_font_invoker (GimpProcedure *procedure,
|
||||||
{
|
{
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
GimpTextLayer *layer;
|
GimpTextLayer *layer;
|
||||||
const gchar *font;
|
GimpFont *font;
|
||||||
|
|
||||||
layer = g_value_get_object (gimp_value_array_index (args, 0));
|
layer = g_value_get_object (gimp_value_array_index (args, 0));
|
||||||
font = g_value_get_string (gimp_value_array_index (args, 1));
|
font = g_value_get_object (gimp_value_array_index (args, 1));
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
@ -1182,7 +1182,7 @@ register_text_layer_procs (GimpPDB *pdb)
|
||||||
"gimp-text-layer-get-font");
|
"gimp-text-layer-get-font");
|
||||||
gimp_procedure_set_static_help (procedure,
|
gimp_procedure_set_static_help (procedure,
|
||||||
"Get the font from a text layer as string.",
|
"Get the font from a text layer as string.",
|
||||||
"This procedure returns the name of the font from a text layer.",
|
"This procedure returns the font from a text layer.",
|
||||||
NULL);
|
NULL);
|
||||||
gimp_procedure_set_static_attribution (procedure,
|
gimp_procedure_set_static_attribution (procedure,
|
||||||
"Marcus Heese <heese@cip.ifi.lmu.de>",
|
"Marcus Heese <heese@cip.ifi.lmu.de>",
|
||||||
|
@ -1195,12 +1195,11 @@ register_text_layer_procs (GimpPDB *pdb)
|
||||||
FALSE,
|
FALSE,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
gimp_procedure_add_return_value (procedure,
|
gimp_procedure_add_return_value (procedure,
|
||||||
gimp_param_spec_string ("font",
|
gimp_param_spec_font ("font",
|
||||||
"font",
|
"font",
|
||||||
"The font which is used in the specified text layer.",
|
"The font which is used in the specified text layer.",
|
||||||
FALSE, FALSE, FALSE,
|
FALSE,
|
||||||
NULL,
|
GIMP_PARAM_READWRITE));
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
g_object_unref (procedure);
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
@ -1225,12 +1224,11 @@ register_text_layer_procs (GimpPDB *pdb)
|
||||||
FALSE,
|
FALSE,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
gimp_procedure_add_argument (procedure,
|
gimp_procedure_add_argument (procedure,
|
||||||
gimp_param_spec_string ("font",
|
gimp_param_spec_font ("font",
|
||||||
"font",
|
"font",
|
||||||
"The new font to use",
|
"The new font to use",
|
||||||
FALSE, FALSE, FALSE,
|
FALSE,
|
||||||
NULL,
|
GIMP_PARAM_READWRITE));
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
g_object_unref (procedure);
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,11 @@ search_index = true
|
||||||
description = "A 2D graphics library with support for multiple output devices"
|
description = "A 2D graphics library with support for multiple output devices"
|
||||||
docs_url = "https://www.cairographics.org/manual/"
|
docs_url = "https://www.cairographics.org/manual/"
|
||||||
|
|
||||||
|
[dependencies."Pango-1.0"]
|
||||||
|
name = "Pango"
|
||||||
|
description = "Internationalized text layout and rendering"
|
||||||
|
docs_url = "https://docs.gtk.org/Pango/"
|
||||||
|
|
||||||
[theme]
|
[theme]
|
||||||
name = "basic"
|
name = "basic"
|
||||||
show_index_summary = true
|
show_index_summary = true
|
||||||
|
|
|
@ -8,4 +8,5 @@ baseURLs = [
|
||||||
[ 'GdkPixbuf', 'https://docs.gtk.org/gdk-pixbuf/' ],
|
[ 'GdkPixbuf', 'https://docs.gtk.org/gdk-pixbuf/' ],
|
||||||
[ 'Gio', 'https://docs.gtk.org/gio/' ],
|
[ 'Gio', 'https://docs.gtk.org/gio/' ],
|
||||||
[ 'Gtk', 'https://docs.gtk.org/gtk3/' ],
|
[ 'Gtk', 'https://docs.gtk.org/gtk3/' ],
|
||||||
|
[ 'Pango', 'https://docs.gtk.org/Pango/' ],
|
||||||
]
|
]
|
||||||
|
|
|
@ -294,6 +294,7 @@ EXPORTS
|
||||||
gimp_floating_sel_remove
|
gimp_floating_sel_remove
|
||||||
gimp_floating_sel_to_layer
|
gimp_floating_sel_to_layer
|
||||||
gimp_font_get_by_name
|
gimp_font_get_by_name
|
||||||
|
gimp_font_get_pango_font_description
|
||||||
gimp_font_get_type
|
gimp_font_get_type
|
||||||
gimp_fonts_close_popup
|
gimp_fonts_close_popup
|
||||||
gimp_fonts_get_list
|
gimp_fonts_get_list
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <gegl.h>
|
#include <gegl.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
#include <pango/pango.h>
|
||||||
|
|
||||||
#include <libgimpbase/gimpbase.h>
|
#include <libgimpbase/gimpbase.h>
|
||||||
#include <libgimpcolor/gimpcolor.h>
|
#include <libgimpcolor/gimpcolor.h>
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <pango/pangofc-fontmap.h>
|
||||||
|
|
||||||
#include "gimp.h"
|
#include "gimp.h"
|
||||||
|
|
||||||
#include "gimpfont.h"
|
#include "gimpfont.h"
|
||||||
|
@ -40,3 +42,45 @@ static void gimp_font_class_init (GimpFontClass *klass)
|
||||||
static void gimp_font_init (GimpFont *font)
|
static void gimp_font_init (GimpFont *font)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_font_get_pango_font_description:
|
||||||
|
* @font: (transfer none): the [class@Gimp.Font]
|
||||||
|
*
|
||||||
|
* Returns a [class@Pango.Font.Description] representing @font.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a %PangoFontDescription representing @font.
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
**/
|
||||||
|
PangoFontDescription *
|
||||||
|
gimp_font_get_pango_font_description (GimpFont *font)
|
||||||
|
{
|
||||||
|
PangoFontDescription *desc = NULL;
|
||||||
|
gchar *name = NULL;
|
||||||
|
gchar *collection_id = NULL;
|
||||||
|
gboolean is_internal;
|
||||||
|
|
||||||
|
is_internal = _gimp_resource_get_identifiers (GIMP_RESOURCE (font),
|
||||||
|
&name, &collection_id);
|
||||||
|
/* TODO: we can't create fonts from internal fonts right now, but it should
|
||||||
|
* actually be possible because these are in fact alias to non-internal fonts.
|
||||||
|
* See #9985.
|
||||||
|
*/
|
||||||
|
if (! is_internal)
|
||||||
|
{
|
||||||
|
gchar *expanded_path;
|
||||||
|
|
||||||
|
expanded_path = gimp_config_path_expand (collection_id, FALSE, NULL);
|
||||||
|
if (expanded_path != NULL &&
|
||||||
|
FcConfigAppFontAddFile (FcConfigGetCurrent (), (const FcChar8 *) expanded_path))
|
||||||
|
desc = pango_font_description_from_string (name);
|
||||||
|
|
||||||
|
g_free (expanded_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (name);
|
||||||
|
g_free (collection_id);
|
||||||
|
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ G_BEGIN_DECLS
|
||||||
G_DECLARE_FINAL_TYPE (GimpFont, gimp_font, GIMP, FONT, GimpResource)
|
G_DECLARE_FINAL_TYPE (GimpFont, gimp_font, GIMP, FONT, GimpResource)
|
||||||
|
|
||||||
|
|
||||||
|
PangoFontDescription * gimp_font_get_pango_font_description (GimpFont *font);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GIMP_FONT_H__ */
|
#endif /* __GIMP_FONT_H__ */
|
||||||
|
|
|
@ -121,6 +121,7 @@ static GimpLayer *
|
||||||
gimp_text_layer_copy (GimpLayer *layer)
|
gimp_text_layer_copy (GimpLayer *layer)
|
||||||
{
|
{
|
||||||
GimpTextLayer *new_layer;
|
GimpTextLayer *new_layer;
|
||||||
|
GimpFont *font;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
gchar *fontname;
|
gchar *fontname;
|
||||||
gdouble size;
|
gdouble size;
|
||||||
|
@ -129,7 +130,8 @@ gimp_text_layer_copy (GimpLayer *layer)
|
||||||
g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL);
|
g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL);
|
||||||
|
|
||||||
text = gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer));
|
text = gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer));
|
||||||
fontname = gimp_text_layer_get_font (GIMP_TEXT_LAYER (layer));
|
font = gimp_text_layer_get_font (GIMP_TEXT_LAYER (layer));
|
||||||
|
fontname = gimp_resource_get_name (GIMP_RESOURCE (font));
|
||||||
size = gimp_text_layer_get_font_size (GIMP_TEXT_LAYER (layer), &unit);
|
size = gimp_text_layer_get_font_size (GIMP_TEXT_LAYER (layer), &unit);
|
||||||
new_layer = gimp_text_layer_new (gimp_item_get_image (GIMP_ITEM (layer)),
|
new_layer = gimp_text_layer_new (gimp_item_get_image (GIMP_ITEM (layer)),
|
||||||
text, fontname, size, unit);
|
text, fontname, size, unit);
|
||||||
|
|
|
@ -254,20 +254,19 @@ gimp_text_layer_set_markup (GimpTextLayer *layer,
|
||||||
*
|
*
|
||||||
* Get the font from a text layer as string.
|
* Get the font from a text layer as string.
|
||||||
*
|
*
|
||||||
* This procedure returns the name of the font from a text layer.
|
* This procedure returns the font from a text layer.
|
||||||
*
|
*
|
||||||
* Returns: (transfer full):
|
* Returns: (transfer none):
|
||||||
* The font which is used in the specified text layer.
|
* The font which is used in the specified text layer.
|
||||||
* The returned value must be freed with g_free().
|
|
||||||
*
|
*
|
||||||
* Since: 2.6
|
* Since: 2.6
|
||||||
**/
|
**/
|
||||||
gchar *
|
GimpFont *
|
||||||
gimp_text_layer_get_font (GimpTextLayer *layer)
|
gimp_text_layer_get_font (GimpTextLayer *layer)
|
||||||
{
|
{
|
||||||
GimpValueArray *args;
|
GimpValueArray *args;
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
gchar *font = NULL;
|
GimpFont *font = NULL;
|
||||||
|
|
||||||
args = gimp_value_array_new_from_types (NULL,
|
args = gimp_value_array_new_from_types (NULL,
|
||||||
GIMP_TYPE_TEXT_LAYER, layer,
|
GIMP_TYPE_TEXT_LAYER, layer,
|
||||||
|
@ -279,7 +278,7 @@ gimp_text_layer_get_font (GimpTextLayer *layer)
|
||||||
gimp_value_array_unref (args);
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||||
font = GIMP_VALUES_DUP_STRING (return_vals, 1);
|
font = GIMP_VALUES_GET_FONT (return_vals, 1);
|
||||||
|
|
||||||
gimp_value_array_unref (return_vals);
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
|
@ -301,7 +300,7 @@ gimp_text_layer_get_font (GimpTextLayer *layer)
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
gimp_text_layer_set_font (GimpTextLayer *layer,
|
gimp_text_layer_set_font (GimpTextLayer *layer,
|
||||||
const gchar *font)
|
GimpFont *font)
|
||||||
{
|
{
|
||||||
GimpValueArray *args;
|
GimpValueArray *args;
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
|
@ -309,7 +308,7 @@ gimp_text_layer_set_font (GimpTextLayer *layer,
|
||||||
|
|
||||||
args = gimp_value_array_new_from_types (NULL,
|
args = gimp_value_array_new_from_types (NULL,
|
||||||
GIMP_TYPE_TEXT_LAYER, layer,
|
GIMP_TYPE_TEXT_LAYER, layer,
|
||||||
G_TYPE_STRING, font,
|
GIMP_TYPE_FONT, font,
|
||||||
G_TYPE_NONE);
|
G_TYPE_NONE);
|
||||||
|
|
||||||
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||||
|
|
|
@ -43,9 +43,9 @@ gboolean gimp_text_layer_set_text (GimpTextLayer
|
||||||
gchar* gimp_text_layer_get_markup (GimpTextLayer *layer);
|
gchar* gimp_text_layer_get_markup (GimpTextLayer *layer);
|
||||||
gboolean gimp_text_layer_set_markup (GimpTextLayer *layer,
|
gboolean gimp_text_layer_set_markup (GimpTextLayer *layer,
|
||||||
const gchar *markup);
|
const gchar *markup);
|
||||||
gchar* gimp_text_layer_get_font (GimpTextLayer *layer);
|
GimpFont* gimp_text_layer_get_font (GimpTextLayer *layer);
|
||||||
gboolean gimp_text_layer_set_font (GimpTextLayer *layer,
|
gboolean gimp_text_layer_set_font (GimpTextLayer *layer,
|
||||||
const gchar *font);
|
GimpFont *font);
|
||||||
gdouble gimp_text_layer_get_font_size (GimpTextLayer *layer,
|
gdouble gimp_text_layer_get_font_size (GimpTextLayer *layer,
|
||||||
GimpUnit *unit);
|
GimpUnit *unit);
|
||||||
gboolean gimp_text_layer_set_font_size (GimpTextLayer *layer,
|
gboolean gimp_text_layer_set_font_size (GimpTextLayer *layer,
|
||||||
|
|
|
@ -344,6 +344,8 @@ libgimp = library('gimp-'+ gimp_api_version,
|
||||||
gegl,
|
gegl,
|
||||||
gexiv2,
|
gexiv2,
|
||||||
drmingw,
|
drmingw,
|
||||||
|
pango,
|
||||||
|
pangoft2,
|
||||||
],
|
],
|
||||||
sources: [
|
sources: [
|
||||||
pdbgen
|
pdbgen
|
||||||
|
@ -465,6 +467,7 @@ else
|
||||||
'Gio-2.0',
|
'Gio-2.0',
|
||||||
'GLib-2.0',
|
'GLib-2.0',
|
||||||
'GObject-2.0',
|
'GObject-2.0',
|
||||||
|
'Pango-1.0',
|
||||||
]
|
]
|
||||||
|
|
||||||
gir_args = [
|
gir_args = [
|
||||||
|
|
|
@ -413,7 +413,7 @@ endif
|
||||||
conf.set_quoted('MYPAINT_BRUSHES_DIR', mypaint_brushes_dir)
|
conf.set_quoted('MYPAINT_BRUSHES_DIR', mypaint_brushes_dir)
|
||||||
|
|
||||||
pango_minver = '1.50.0'
|
pango_minver = '1.50.0'
|
||||||
pangocairo = dependency('pango', version: '>='+pango_minver)
|
pango = dependency('pango', version: '>='+pango_minver)
|
||||||
pangocairo = dependency('pangocairo', version: '>='+pango_minver)
|
pangocairo = dependency('pangocairo', version: '>='+pango_minver)
|
||||||
pangoft2 = dependency('pangoft2', version: '>='+pango_minver)
|
pangoft2 = dependency('pangoft2', version: '>='+pango_minver)
|
||||||
rsvg_minver = '2.40.6'
|
rsvg_minver = '2.40.6'
|
||||||
|
|
|
@ -231,7 +231,7 @@ sub text_layer_get_font {
|
||||||
$blurb = 'Get the font from a text layer as string.';
|
$blurb = 'Get the font from a text layer as string.';
|
||||||
|
|
||||||
$help = <<'HELP';
|
$help = <<'HELP';
|
||||||
This procedure returns the name of the font from a text layer.
|
This procedure returns the font from a text layer.
|
||||||
HELP
|
HELP
|
||||||
|
|
||||||
&marcus_pdb_misc('2008', '2.6');
|
&marcus_pdb_misc('2008', '2.6');
|
||||||
|
@ -242,20 +242,20 @@ HELP
|
||||||
);
|
);
|
||||||
|
|
||||||
@outargs = (
|
@outargs = (
|
||||||
{ name => 'font', type => 'string',
|
{ name => 'font', type => 'font',
|
||||||
desc => 'The font which is used in the specified text layer.' }
|
desc => 'The font which is used in the specified text layer.' }
|
||||||
);
|
);
|
||||||
|
|
||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<'CODE'
|
code => <<'CODE'
|
||||||
{
|
{
|
||||||
GimpFont *font_obj;
|
|
||||||
|
|
||||||
g_object_get (gimp_text_layer_get_text (layer),
|
g_object_get (gimp_text_layer_get_text (layer),
|
||||||
"font", &font_obj,
|
"font", &font,
|
||||||
NULL);
|
NULL);
|
||||||
font = g_strdup (gimp_font_get_lookup_name (font_obj));
|
/* The GimpText keeps a reference. Therefore unref before returning the
|
||||||
g_object_unref (font_obj);
|
* pointer so that we don't leak a reference.
|
||||||
|
*/
|
||||||
|
g_object_unref (font);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
);
|
);
|
||||||
|
@ -273,7 +273,7 @@ HELP
|
||||||
@inargs = (
|
@inargs = (
|
||||||
{ name => 'layer', type => 'text_layer',
|
{ name => 'layer', type => 'text_layer',
|
||||||
desc => 'The text layer' },
|
desc => 'The text layer' },
|
||||||
{ name => 'font', type => 'string',
|
{ name => 'font', type => 'font',
|
||||||
desc => 'The new font to use' }
|
desc => 'The new font to use' }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -641,7 +641,7 @@ get_missing_fonts (GList *layers)
|
||||||
}
|
}
|
||||||
else if (gimp_item_is_text_layer (GIMP_ITEM (layer)))
|
else if (gimp_item_is_text_layer (GIMP_ITEM (layer)))
|
||||||
{
|
{
|
||||||
gchar *font_family;
|
GimpFont *gimp_font;
|
||||||
PangoFontDescription *font_description;
|
PangoFontDescription *font_description;
|
||||||
PangoFontDescription *font_description2;
|
PangoFontDescription *font_description2;
|
||||||
PangoFontMap *fontmap;
|
PangoFontMap *fontmap;
|
||||||
|
@ -651,8 +651,8 @@ get_missing_fonts (GList *layers)
|
||||||
fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
|
fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
|
||||||
context = pango_font_map_create_context (fontmap);
|
context = pango_font_map_create_context (fontmap);
|
||||||
|
|
||||||
font_family = gimp_text_layer_get_font (GIMP_TEXT_LAYER (layer));
|
gimp_font = gimp_text_layer_get_font (GIMP_TEXT_LAYER (layer));
|
||||||
font_description = pango_font_description_from_string (font_family);
|
font_description = gimp_font_get_pango_font_description (gimp_font);
|
||||||
|
|
||||||
font = pango_font_map_load_font (fontmap, context, font_description);
|
font = pango_font_map_load_font (fontmap, context, font_description);
|
||||||
font_description2 = pango_font_describe (font);
|
font_description2 = pango_font_describe (font);
|
||||||
|
@ -669,7 +669,6 @@ get_missing_fonts (GList *layers)
|
||||||
g_object_unref (font);
|
g_object_unref (font);
|
||||||
pango_font_description_free (font_description);
|
pango_font_description_free (font_description);
|
||||||
pango_font_description_free (font_description2);
|
pango_font_description_free (font_description2);
|
||||||
g_free (font_family);
|
|
||||||
g_object_unref (context);
|
g_object_unref (context);
|
||||||
g_object_unref (fontmap);
|
g_object_unref (fontmap);
|
||||||
}
|
}
|
||||||
|
@ -1599,7 +1598,6 @@ drawText (GimpLayer *layer,
|
||||||
GimpImageType type = gimp_drawable_type (GIMP_DRAWABLE (layer));
|
GimpImageType type = gimp_drawable_type (GIMP_DRAWABLE (layer));
|
||||||
gchar *text = gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer));
|
gchar *text = gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer));
|
||||||
gchar *markup = gimp_text_layer_get_markup (GIMP_TEXT_LAYER (layer));
|
gchar *markup = gimp_text_layer_get_markup (GIMP_TEXT_LAYER (layer));
|
||||||
gchar *font_family;
|
|
||||||
gchar *language;
|
gchar *language;
|
||||||
cairo_font_options_t *options;
|
cairo_font_options_t *options;
|
||||||
gint x;
|
gint x;
|
||||||
|
@ -1614,6 +1612,7 @@ drawText (GimpLayer *layer,
|
||||||
GimpTextDirection dir;
|
GimpTextDirection dir;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoContext *context;
|
PangoContext *context;
|
||||||
|
GimpFont *font;
|
||||||
PangoFontDescription *font_description;
|
PangoFontDescription *font_description;
|
||||||
gdouble indent;
|
gdouble indent;
|
||||||
gdouble line_spacing;
|
gdouble line_spacing;
|
||||||
|
@ -1676,6 +1675,15 @@ drawText (GimpLayer *layer,
|
||||||
*/
|
*/
|
||||||
fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
|
fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
|
||||||
|
|
||||||
|
/* Font */
|
||||||
|
font = gimp_text_layer_get_font (GIMP_TEXT_LAYER (layer));
|
||||||
|
font_description = gimp_font_get_pango_font_description (font);
|
||||||
|
|
||||||
|
/* This function breaks rendering with some fonts if it's called before
|
||||||
|
* gimp_font_get_pango_font_description(). I'm still unsure why yet it
|
||||||
|
* probably means there is a bug somewhere we must fix. Until then, let's make
|
||||||
|
* sure we keep this order. XXX
|
||||||
|
*/
|
||||||
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), y_res);
|
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), y_res);
|
||||||
|
|
||||||
context = pango_font_map_create_context (fontmap);
|
context = pango_font_map_create_context (fontmap);
|
||||||
|
@ -1687,7 +1695,7 @@ drawText (GimpLayer *layer,
|
||||||
language = gimp_text_layer_get_language (GIMP_TEXT_LAYER (layer));
|
language = gimp_text_layer_get_language (GIMP_TEXT_LAYER (layer));
|
||||||
if (language)
|
if (language)
|
||||||
pango_context_set_language (context,
|
pango_context_set_language (context,
|
||||||
pango_language_from_string(language));
|
pango_language_from_string (language));
|
||||||
|
|
||||||
/* Text Direction */
|
/* Text Direction */
|
||||||
dir = gimp_text_layer_get_base_direction (GIMP_TEXT_LAYER (layer));
|
dir = gimp_text_layer_get_base_direction (GIMP_TEXT_LAYER (layer));
|
||||||
|
@ -1737,14 +1745,6 @@ drawText (GimpLayer *layer,
|
||||||
layout = pango_layout_new (context);
|
layout = pango_layout_new (context);
|
||||||
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
|
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
|
||||||
|
|
||||||
/* Font */
|
|
||||||
font_family = gimp_text_layer_get_font (GIMP_TEXT_LAYER (layer));
|
|
||||||
|
|
||||||
/* We need to find a way to convert GIMP's returned font name to a
|
|
||||||
* normal Pango name... Hopefully GIMP 2.8 with Pango will fix it.
|
|
||||||
*/
|
|
||||||
font_description = pango_font_description_from_string (font_family);
|
|
||||||
|
|
||||||
/* Font Size */
|
/* Font Size */
|
||||||
size = gimp_text_layer_get_font_size (GIMP_TEXT_LAYER (layer), &unit);
|
size = gimp_text_layer_get_font_size (GIMP_TEXT_LAYER (layer), &unit);
|
||||||
size = gimp_units_to_pixels (size, unit, y_res);
|
size = gimp_units_to_pixels (size, unit, y_res);
|
||||||
|
@ -1825,7 +1825,6 @@ drawText (GimpLayer *layer,
|
||||||
pango_cairo_show_layout (cr, layout);
|
pango_cairo_show_layout (cr, layout);
|
||||||
|
|
||||||
g_free (text);
|
g_free (text);
|
||||||
g_free (font_family);
|
|
||||||
g_free (language);
|
g_free (language);
|
||||||
|
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
|
|
|
@ -21,7 +21,7 @@ common_plugins_list = [
|
||||||
{ 'name': 'destripe', },
|
{ 'name': 'destripe', },
|
||||||
{ 'name': 'file-cel', },
|
{ 'name': 'file-cel', },
|
||||||
{ 'name': 'file-compressor',
|
{ 'name': 'file-compressor',
|
||||||
'deps': [ gegl, gdk_pixbuf, cairo, gio, liblzma, bz2, zlib, ],
|
'deps': [ gegl, gdk_pixbuf, cairo, gio, liblzma, pango, bz2, zlib, ],
|
||||||
},
|
},
|
||||||
{ 'name': 'file-csource', },
|
{ 'name': 'file-csource', },
|
||||||
{ 'name': 'file-desktop-link',
|
{ 'name': 'file-desktop-link',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue