sway/include/pango.h
Hugo Osvaldo Barrera 75605491a5 Reject font values that are invalid for pango
Use pango to parse font configuration early, and reject the command as
invalid if the value is invalid for pango. Since we're already parsing
the font into a `PangoFontDescription`, keep that instance around and
avoid re-parsing the font each time we render text.

Fixes: https://github.com/swaywm/sway/issues/6805
2022-07-01 13:05:58 +02:00

25 lines
852 B
C

#ifndef _SWAY_PANGO_H
#define _SWAY_PANGO_H
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <cairo.h>
#include <pango/pangocairo.h>
/**
* Utility function which escape characters a & < > ' ".
*
* The function returns the length of the escaped string, optionally writing the
* escaped string to dest if provided.
*/
size_t escape_markup_text(const char *src, char *dest);
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
const char *text, double scale, bool markup);
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
int *baseline, double scale, bool markup, const char *fmt, ...);
void get_text_metrics(const PangoFontDescription *font, int *height, int *baseline);
void render_text(cairo_t *cairo, const char *font,
double scale, bool markup, const char *fmt, ...);
#endif