2021-11-13 21:56:53 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2023-05-13 16:10:33 +03:00
|
|
|
#ifndef LABWC_FONT_H
|
|
|
|
|
#define LABWC_FONT_H
|
2025-05-29 12:34:03 -04:00
|
|
|
|
|
|
|
|
#include <cairo.h>
|
2025-04-23 20:01:26 +01:00
|
|
|
#include <pango/pango-font.h>
|
2020-08-05 20:14:17 +01:00
|
|
|
|
2022-02-17 01:46:32 +01:00
|
|
|
struct lab_data_buffer;
|
2021-08-07 08:35:46 +01:00
|
|
|
|
2021-08-20 20:20:49 +01:00
|
|
|
struct font {
|
|
|
|
|
char *name;
|
|
|
|
|
int size;
|
2025-04-23 20:03:14 +01:00
|
|
|
PangoStyle slant;
|
2025-04-23 20:01:26 +01:00
|
|
|
PangoWeight weight;
|
2021-08-20 20:20:49 +01:00
|
|
|
};
|
|
|
|
|
|
2022-09-15 10:53:49 -04:00
|
|
|
struct _PangoFontDescription *font_to_pango_desc(struct font *font);
|
|
|
|
|
|
2020-08-07 20:21:14 +01:00
|
|
|
/**
|
2020-08-05 20:14:17 +01:00
|
|
|
* font_height - get font vertical extents
|
2021-08-20 20:20:49 +01:00
|
|
|
* @font: description of font including family name and size
|
2020-08-05 20:14:17 +01:00
|
|
|
*/
|
2021-08-20 20:20:49 +01:00
|
|
|
int font_height(struct font *font);
|
2020-08-05 20:14:17 +01:00
|
|
|
|
2022-06-15 01:16:32 +02:00
|
|
|
/**
|
|
|
|
|
* font_width - get font horizontal extents
|
|
|
|
|
* @font: description of font including family name and size
|
|
|
|
|
*/
|
|
|
|
|
int font_width(struct font *font, const char *string);
|
|
|
|
|
|
2024-12-03 16:18:52 +09:00
|
|
|
/**
|
|
|
|
|
* font_get_buffer_size - dry-run font_buffer_create() to get buffer size
|
|
|
|
|
*/
|
|
|
|
|
void font_get_buffer_size(int max_width, const char *text, struct font *font,
|
|
|
|
|
int *width, int *height);
|
|
|
|
|
|
2021-08-07 08:35:46 +01:00
|
|
|
/**
|
2022-02-17 01:46:32 +01:00
|
|
|
* font_buffer_create - Create ARGB8888 lab_data_buffer using pango
|
|
|
|
|
* @buffer: buffer pointer
|
2021-08-07 08:35:46 +01:00
|
|
|
* @max_width: max allowable width; will be ellipsized if longer
|
2025-05-29 12:34:03 -04:00
|
|
|
* @height: buffer height or -1 to compute from font
|
2021-08-07 08:35:46 +01:00
|
|
|
* @text: text to be generated as texture
|
|
|
|
|
* @font: font description
|
|
|
|
|
* @color: foreground color in rgba format
|
2025-05-29 12:34:03 -04:00
|
|
|
* @bg_pattern: background pattern
|
2021-08-07 08:35:46 +01:00
|
|
|
*/
|
2022-02-17 01:46:32 +01:00
|
|
|
void font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
2025-05-29 12:34:03 -04:00
|
|
|
int height, const char *text, struct font *font, const float *color,
|
|
|
|
|
cairo_pattern_t *bg_pattern, double scale);
|
2022-02-17 01:46:32 +01:00
|
|
|
|
2020-10-31 15:41:06 +00:00
|
|
|
/**
|
|
|
|
|
* font_finish - free some font related resources
|
|
|
|
|
* Note: use on exit
|
|
|
|
|
*/
|
|
|
|
|
void font_finish(void);
|
|
|
|
|
|
2023-05-13 16:10:33 +03:00
|
|
|
#endif /* LABWC_FONT_H */
|