I am trying to follow your example to render another font variant: I need font with 2 colors and 1pixel shift in x,y between each color
that would create a shadow.
cairo_t *cr = gdk_cairo_create(widget->window);
PangoLayout *layout = gtk_label_get_layout(GTK_LABEL(widget));
int width=-1, height=-1;
pango_layout_get_size(layout, &width, &height);
/* add 1 pixel to x and y and draw white shadow */
cairo_move_to(cr, widget->allocation.x +
(widget->allocation.width - width / PANGO_SCALE) / 2 +1,
height / PANGO_SCALE / 2 +1);
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_set_line_width(cr, 1.0);
pango_cairo_show_layout(cr, layout);
pango_cairo_layout_path(cr, layout);
cairo_stroke(cr);
/* draw black font */
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, widget->allocation.x +
(widget->allocation.width - width / PANGO_SCALE) / 2,
height / PANGO_SCALE / 2);
cairo_set_line_join(cr, CAIRO_LINE_JOIN_BEVEL);
pango_cairo_layout_path(cr, layout);
cairo_stroke(cr);
the problem is that I get blurred fonts.
when I draw only one of the colors - the font looks blurred at the edges, I need all the pixels to be in the same color but what I get is
black in the middle and gray edges
when I draw the 2 colors one over the other - I get smudged font, looks line the white background emerges through the black foreground
I tried calling cairo_set_line_join with all options but I am probably missing something with the font definition
Thanks for your help,
Jonathan