69 static char buf[1024];
70 static PangoFontMap *fontmap;
71 static PangoContext *context;
72 static PangoFontDescription *desc;
73 static char *fontname;
74 static double fontsize;
76 char *fnt, *psfnt =
NULL;
78 PangoRectangle logical_rect;
81#ifdef ENABLE_PANGO_MARKUP
87 double textlayout_scale;
91 fontmap = pango_cairo_font_map_new();
93 context = pango_font_map_create_context (fontmap);
94 options=cairo_font_options_create();
95 cairo_font_options_set_antialias(
options,CAIRO_ANTIALIAS_GRAY);
96 cairo_font_options_set_hint_style(
options,CAIRO_HINT_STYLE_FULL);
97 cairo_font_options_set_hint_metrics(
options,CAIRO_HINT_METRICS_ON);
98 cairo_font_options_set_subpixel_order(
options,CAIRO_SUBPIXEL_ORDER_BGR);
99 pango_cairo_context_set_font_options(context,
options);
100 pango_cairo_context_set_resolution(context,
FONT_DPI);
101 cairo_font_options_destroy(
options);
102 g_object_unref(fontmap);
105 if (!fontname || strcmp(fontname, span->
font->
name) != 0 || fontsize != span->
font->
size) {
108 if ((
double)(G_MAXINT / PANGO_SCALE) < span->
font->
size) {
115 pango_font_description_free (desc);
126 desc = pango_font_description_from_string(fnt);
128 pango_font_description_set_size (desc, (gint)(fontsize * PANGO_SCALE));
130 if (fontpath && (
font = pango_font_map_load_font(fontmap, context, desc))) {
131 const char *fontclass;
133 fontclass = G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(
font));
137 strcat(buf,
"(ps:pango ");
142 strcat(buf, fontclass);
144#ifdef HAVE_PANGO_FC_FONT_LOCK_FACE
145 if (strcmp(fontclass,
"PangoCairoFcFont") == 0) {
149 FT_StreamDesc streamdesc;
150 fcfont = PANGO_FC_FONT(
font);
151 face = pango_fc_font_lock_face(fcfont);
154 strcat(buf, face->family_name);
156 strcat(buf, face->style_name);
159 stream = face->stream;
161 streamdesc = stream->pathname;
162 if (streamdesc.pointer)
163 strcat(buf, (
char*)streamdesc.pointer);
165 strcat(buf,
"*no pathname available*");
168 strcat(buf,
"*no stream available*");
170 pango_fc_font_unlock_face(fcfont);
175 PangoFontDescription *tdesc;
178 tdesc = pango_font_describe(
font);
179 tfont = pango_font_description_to_string(tdesc);
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 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 pango_layout_get_extents (
layout,
NULL, &logical_rect);
248 if (logical_rect.width == 0)
249 logical_rect.height = 0;
252 span->
size.
x = logical_rect.width * textlayout_scale;
253 span->
size.
y = logical_rect.height * textlayout_scale;
261 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)