dtext.h 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* See LICENSE file for copyright and license details. */
  2. typedef int32_t dt_error;
  3. typedef struct {
  4. FT_Library ft_lib;
  5. XRenderPictFormat *win_format;
  6. XRenderPictFormat *argb32_format;
  7. Display *dpy;
  8. Picture pic;
  9. Picture fill;
  10. } dt_context;
  11. typedef struct {
  12. FT_Face face;
  13. GlyphSet gs;
  14. uint8_t loaded[256];
  15. } dt_font;
  16. typedef struct {
  17. int32_t x; // Bottom-left of box, relative to point of origin of text
  18. int32_t y;
  19. uint32_t w;
  20. uint32_t h;
  21. } dt_bbox;
  22. typedef struct {
  23. uint8_t red;
  24. uint8_t green;
  25. uint8_t blue;
  26. uint8_t alpha; // 0 means opaque
  27. } dt_style;
  28. dt_error dt_init(dt_context **ctx, Display *dpy, Window win);
  29. dt_error dt_quit(dt_context *ctx);
  30. dt_error dt_load(dt_context *ctx, dt_font **fnt,
  31. uint8_t size, char const *name);
  32. dt_error dt_free(dt_context *ctx, dt_font *fnt);
  33. dt_error dt_box(dt_font *fnt, dt_bbox *bbox, char const *txt);
  34. dt_error dt_draw(dt_context *ctx, dt_font *fnt, dt_style const *style,
  35. uint32_t x, uint32_t y, char const *txt);