Make font_texture_create() more generic

Move font_texture_create() to font.c so it can be used for purposes other
than rendering the menu, for example server side decoration.

Refactor menu.c and menu.h to use this more generic font_texture_create()
This commit is contained in:
Johan Malm 2021-08-07 08:35:46 +01:00
parent 8fc6f795db
commit 5ecf0e1e7e
5 changed files with 104 additions and 72 deletions

View file

@ -1,12 +1,28 @@
#ifndef __LABWC_FONT_H
#define __LABWC_FONT_H
struct server;
struct wlr_texture;
struct wlr_box;
/**
* font_height - get font vertical extents
* @font_description: string describing font, for example 'sans 10'
*/
int font_height(const char *font_description);
/**
* texture_create - Create ARGB8888 texture using pango
* @server: context (for wlr_renderer)
* @texture: texture pointer; existing pointer will be freed
* @max_width: max allowable width; will be ellipsized if longer
* @text: text to be generated as texture
* @font: font description
* @color: foreground color in rgba format
*/
void font_texture_create(struct server *server, struct wlr_texture **texture,
int max_width, const char *text, const char *font, float *color);
/**
* font_finish - free some font related resources
* Note: use on exit