[cairo] Overlay problem for two texts
Eric Feillant
eric.feillant at live-media.fr
Wed Jan 5 13:51:17 UTC 2022
I thank Martin (martinfischer8 at t-online.de) for responding me and fixed
the problem in my first question.
I have another problem for some days still with Cairo when overlaying
texts, i probably forgeth something or do not understand some others
tricks in CAIRO.
In my program i've to display several text strings on a png image.
The first one for player1 (Scoreboard image)
The second one for player 2 wich is the same code.
It is as if the second text was creating a new full image and deleting
the first text.
Cairo code start like this :
// START CAIRO HEAD
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 600,
400);
cr = cairo_create(surface);
cairo_set_source_rgb(cr, 0.7, 0.3, 0.2);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(cr);
cairo_select_font_face(cr, "Sans",
CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 20.0);
cairo_set_source_rgb(cr, 1.0, 1.0, 0.1);
// END CAIRO HEAD
For some reasons i ignore, displaying datas for player2 is ok,
But the first pass in the program for player 1 never works, Even if a
"printf" is right displayed on my screen.
See this :
if(joueur->num == 1)
{
char * joueur1 = joueur[joueur->num-1].nom;
printf("%s\t", joueur1); // joueur1 name is displayed
on screen
cairo_move_to(cr, 10, 50);
cairo_show_text(cr, joueur1); // *this is never on the
PNG image Cairo writes*
}
later in the program i have for player2 the same code :
if(joueur->num == 2)
{
char * joueur2 = joueur->nom;
printf("%s\t", joueur2);
cairo_move_to(cr, 10, 120);
cairo_show_text(cr, joueur2); // *No problem, text is
in the PNG image*
}
// END CAIRO CODE
cairo_surface_write_to_png(surface, "image.png");
cairo_destroy(cr);
cairo_surface_destroy(surface);
Thanks in advance for your help.
signature
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20220105/4f56bbee/attachment.htm>
More information about the cairo
mailing list