Clear the cairo text in gtk_window

Clear the cairo text in gtk_window … here is a solution to the problem.

Clear the cairo text in gtk_window

I have questions about the Cairo text.
I wrote some lines in gtk_window:

cr = gdk_cairo_create(window->window);
        cairo_set_source_rgb(cr, 255, 255, 255);
        cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
        cairo_set_font_size(cr, 14.0);

cairo_move_to(cr, 90.0, 85.0);
        cairo_show_text(cr, "Terror");
        cairo_set_font_size(cr, 12.0);
        cairo_set_source_rgb(cr, 30, 254, 145);
        cairo_move_to(cr, 90.0, 105.0);
        cairo_show_text(cr, "Underdogs");
        cairo_move_to(cr, 90.0, 120.0);
        cairo_show_text(cr, "Disziplin");
        cairo_destroy(cr);

The problem is that this text should be dynamic, but if I call the function that writes the text multiple times, the lines overlap.

Is there any way to refresh the previous text?

Thanks!

Solution

You have to overlay the text with a background color 🙂

Related Problems and Solutions