mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23: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
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <pango/pangofc-fontmap.h>
|
||||
|
||||
#include "gimp.h"
|
||||
|
||||
#include "gimpfont.h"
|
||||
|
@ -40,3 +42,45 @@ static void gimp_font_class_init (GimpFontClass *klass)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue