68 static PangoFontMap *fontmap;
69 static PangoContext *context;
70 static PangoFontDescription *desc;
71 static char *fontname;
72 static double fontsize;
74 char *fnt, *psfnt =
NULL;
76#ifdef ENABLE_PANGO_MARKUP
81 bool text_needs_free =
false;
85 fontmap = pango_cairo_font_map_new();
87 context = pango_font_map_create_context (fontmap);
88 cairo_font_options_t*
options = cairo_font_options_create();
89 cairo_font_options_set_antialias(
options,CAIRO_ANTIALIAS_GRAY);
90 cairo_font_options_set_hint_style(
options,CAIRO_HINT_STYLE_FULL);
91 cairo_font_options_set_hint_metrics(
options,CAIRO_HINT_METRICS_ON);
92 cairo_font_options_set_subpixel_order(
options,CAIRO_SUBPIXEL_ORDER_BGR);
93 pango_cairo_context_set_font_options(context,
options);
94 pango_cairo_context_set_resolution(context,
FONT_DPI);
95 cairo_font_options_destroy(
options);
96 g_object_unref(fontmap);
99 if (!fontname || strcmp(fontname, span->
font->
name) != 0 ||
103 if (INT_MAX / PANGO_SCALE < span->
font->size) {
110 pango_font_description_free (desc);
113 bool psfnt_needs_free =
false;
118 psfnt_needs_free =
true;
124 desc = pango_font_description_from_string(fnt);
126 pango_font_description_set_size (desc, (
int)(fontsize * PANGO_SCALE));
128 if (fontpath && (
font = pango_font_map_load_font(fontmap, context, desc))) {
129 const char *fontclass = G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(
font));
133 agxbprint(&buf,
"(ps:pango %s) ", psfnt);
136#ifdef HAVE_PANGO_FC_FONT_LOCK_FACE
137 if (strcmp(fontclass,
"PangoCairoFcFont") == 0) {
138 PangoFcFont *fcfont = PANGO_FC_FONT(
font);
146#pragma GCC diagnostic push
147#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
149 FT_Face face = pango_fc_font_lock_face(fcfont);
151#pragma GCC diagnostic pop
154 agxbprint(&buf,
"\"%s, %s\" ", face->family_name, face->style_name);
156 FT_Stream stream = face->stream;
158 FT_StreamDesc streamdesc = stream->pathname;
159 if (streamdesc.pointer)
160 agxbput(&buf, streamdesc.pointer);
162 agxbput(&buf,
"*no pathname available*");
165 agxbput(&buf,
"*no stream available*");
168#pragma GCC diagnostic push
169#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
171 pango_fc_font_unlock_face(fcfont);
173#pragma GCC diagnostic pop
179 PangoFontDescription *tdesc = pango_font_describe(
font);
180 char *tfont = pango_font_description_to_string(tdesc);
186 if (psfnt_needs_free) {
191#ifdef ENABLE_PANGO_MARKUP
198 agxbput(&xb,
" weight=\"bold\"");
200 agxbput(&xb,
" style=\"italic\"");
202 agxbput(&xb,
" underline=\"single\"");
204 agxbput(&xb,
" strikethrough=\"true\"");
221 if (!pango_parse_markup (
agxbuse(&xb), -1, 0, &attrs, &text,
NULL, &
error)) {
222 fprintf (stderr,
"Error - pango_parse_markup: %s\n",
error->message);
226 text_needs_free =
true;
238 PangoLayout *
layout = pango_layout_new (context);
242 pango_layout_set_text (
layout, text, -1);
243 pango_layout_set_font_description (
layout, desc);
244#ifdef ENABLE_PANGO_MARKUP
246 pango_layout_set_attributes (
layout, attrs);
249 PangoRectangle logical_rect;
250 pango_layout_get_extents (
layout,
NULL, &logical_rect);
253 if (logical_rect.width == 0)
254 logical_rect.height = 0;
257 span->
size.
x = logical_rect.width * textlayout_scale;
258 span->
size.
y = logical_rect.height * textlayout_scale;
266 const bool rc = logical_rect.width != 0 || strcmp(text,
"") == 0;
267 if (text_needs_free) {
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)