[cairo] please help

Mohit Sindhwani ml3p at onghu.com
Wed Jan 5 15:23:32 UTC 2022


Hi Eric,

Someone else might be able to help you more but just to get you started.

On 2022-1-5 7:48 pm, Eric Feillant wrote:
> My problem here is that in the "for" loop, cairo display only one 
> colum and not the entire string, ex: 3 2 1
> my small code:
>                 char  sets2 [100] ;
>                 for (size_t i=0; i < match->nb_set; i++)
>                 {
>                 char  chaine  = joueur->sets[i] ;
>                 sprintf(sets2 , "%d", chaine);
>                 printf("%s ", sets2);  // This print 3 2 1
>                 cairo_move_to(cr, 250, 120);
>                 cairo_show_text(cr, sets2); // this display in the 
> image one colum the overlayed number
>                 }

As I see it, you move to the exact same position on the surface 
(250,120) and then you draw the text, one character at a time - this 
means that you will end up with all the characters drawn at the same 
position on top of each other.

There are text samples here: https://www.cairographics.org/samples/text/
You will see that, in general, you want to output the whole string once 
you move to the position rather than just a single character.

Hope this helps.

Best Regards,
Mohit.
2022-1-5 | 11:23 pm.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20220105/dd510080/attachment.htm>


More information about the cairo mailing list