67 static PangoFontMap *fontmap;
68 static PangoContext *context;
69 static PangoFontDescription *desc;
70 static char *fontname;
71 static double fontsize;
73 char *fnt, *psfnt =
NULL;
75#ifdef ENABLE_PANGO_MARKUP
83 fontmap = pango_cairo_font_map_new();
85 context = pango_font_map_create_context (fontmap);
86 cairo_font_options_t*
options = cairo_font_options_create();
87 cairo_font_options_set_antialias(
options,CAIRO_ANTIALIAS_GRAY);
88 cairo_font_options_set_hint_style(
options,CAIRO_HINT_STYLE_FULL);
89 cairo_font_options_set_hint_metrics(
options,CAIRO_HINT_METRICS_ON);
90 cairo_font_options_set_subpixel_order(
options,CAIRO_SUBPIXEL_ORDER_BGR);
91 pango_cairo_context_set_font_options(context,
options);
92 pango_cairo_context_set_resolution(context,
FONT_DPI);
93 cairo_font_options_destroy(
options);
94 g_object_unref(fontmap);
97 if (!fontname || strcmp(fontname, span->
font->
name) != 0 ||
101 if (INT_MAX / PANGO_SCALE < span->
font->size) {
108 pango_font_description_free (desc);
111 bool psfnt_needs_free =
false;
116 psfnt_needs_free =
true;
122 desc = pango_font_description_from_string(fnt);
124 pango_font_description_set_size (desc, (
int)(fontsize * PANGO_SCALE));
126 if (fontpath && (
font = pango_font_map_load_font(fontmap, context, desc))) {
127 const char *fontclass = G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(
font));
131 agxbprint(&buf,
"(ps:pango %s) ", psfnt);
134#ifdef HAVE_PANGO_FC_FONT_LOCK_FACE
135 if (strcmp(fontclass,
"PangoCairoFcFont") == 0) {
136 PangoFcFont *fcfont = PANGO_FC_FONT(
font);
144#pragma GCC diagnostic push
145#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
147 FT_Face face = pango_fc_font_lock_face(fcfont);
149#pragma GCC diagnostic pop
152 agxbprint(&buf,
"\"%s, %s\" ", face->family_name, face->style_name);
154 FT_Stream stream = face->stream;
156 FT_StreamDesc streamdesc = stream->pathname;
157 if (streamdesc.pointer)
158 agxbput(&buf, streamdesc.pointer);
160 agxbput(&buf,
"*no pathname available*");
163 agxbput(&buf,
"*no stream available*");
166#pragma GCC diagnostic push
167#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
169 pango_fc_font_unlock_face(fcfont);
171#pragma GCC diagnostic pop
177 PangoFontDescription *tdesc = pango_font_describe(
font);
178 char *tfont = pango_font_description_to_string(tdesc);
184 if (psfnt_needs_free) {
189#ifdef ENABLE_PANGO_MARKUP
196 agxbput(&xb,
" weight=\"bold\"");
198 agxbput(&xb,
" style=\"italic\"");
200 agxbput(&xb,
" underline=\"single\"");
202 agxbput(&xb,
" strikethrough=\"true\"");
219 if (!pango_parse_markup (
agxbuse(&xb), -1, 0, &attrs, &text,
NULL, &
error)) {
220 fprintf (stderr,
"Error - pango_parse_markup: %s\n",
error->message);
234 PangoLayout *
layout = pango_layout_new (context);
238 pango_layout_set_text (
layout, text, -1);
239 pango_layout_set_font_description (
layout, desc);
240#ifdef ENABLE_PANGO_MARKUP
242 pango_layout_set_attributes (
layout, attrs);
245 PangoRectangle logical_rect;
246 pango_layout_get_extents (
layout,
NULL, &logical_rect);
249 if (logical_rect.width == 0)
250 logical_rect.height = 0;
253 span->
size.
x = logical_rect.width * textlayout_scale;
254 span->
size.
y = logical_rect.height * textlayout_scale;
262 return logical_rect.width != 0 || strcmp(text,
"") == 0;
static gvtextlayout_engine_t pango_textlayout_engine
static int agxbput_int(void *buffer, const char *s)
gvplugin_installed_t gvtextlayout_pango_types[]
static char * pango_psfontResolve(PostscriptAlias *pa)
static bool pango_textlayout(textspan_t *span, char **fontpath)
static void pango_free_layout(void *layout)
PostscriptAlias * postscript_alias
double yoffset_centerline
void(* free_layout)(void *layout)