[Xcb] xcb_image_text_8 Transparent Background

Cinolt cinolt.yk at gmail.com
Sat Jan 1 19:35:30 PST 2011


Hello, the xcb_image_text_8 function seems to fill the area of the text with
the background color, and in my case it is black if not specified. Is there
any way to prevent it from filling in a background color, and only draw the
text? Here is a minimal example illustrating my problem, as this only
displays a black box when I want to draw black text. Setting XCB_GC_FUNCTION
to XCB_GX_CLEAR seems to have no effect.

#include <xcb/xcb.h>

int main(int argc, char** argv)
{
  xcb_connection_t* c = xcb_connect(0, 0);
  xcb_screen_t* s = xcb_setup_roots_iterator(xcb_get_setup(c)).data;

  xcb_window_t w = xcb_generate_id(c);

  uint32_t cw_v[2] = {(*s).white_pixel, XCB_EVENT_MASK_EXPOSURE};

  xcb_create_window(c, 0, w, (*s).root, 0, 0, 256, 256, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, (*s).root_visual, XCB_CW_BACK_PIXEL |
XCB_CW_EVENT_MASK, cw_v);
  xcb_map_window(c, w);

  xcb_font_t font = xcb_generate_id(c);
  xcb_void_cookie_t f_co = xcb_open_font(c, font, 4, "8x16");

  xcb_gcontext_t gc = xcb_generate_id(c);
  uint32_t gc_v[3] = {XCB_GX_CLEAR, (*s).black_pixel, font};

  xcb_create_gc(c, gc, w, XCB_GC_FUNCTION | XCB_GC_FOREGROUND | XCB_GC_FONT,
gc_v);

  xcb_flush(c);

  xcb_generic_event_t* e;
  while(e = xcb_wait_for_event(c))
  {
    switch((*e).response_type)
    {
      case XCB_EXPOSE:
        xcb_image_text_8(c, 4, w, gc, 16, 16, "Test");
        xcb_flush(c);
        break;
    }
  }

  return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20110101/bc705934/attachment.html>


More information about the Xcb mailing list