aboutsummaryrefslogtreecommitdiffstats
path: root/include/pango.h
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-21 21:27:36 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-22 18:33:28 +1000
commit10ef118e09435a6fa7815a40829126490d9a7d67 (patch)
tree91a73019ddb8482d90cf79e3f5cdf2c1f1a8c789 /include/pango.h
parentMerge pull request #2678 from RyanDwyer/reconfigure-on-reposition (diff)
downloadsway-10ef118e09435a6fa7815a40829126490d9a7d67.tar.gz
sway-10ef118e09435a6fa7815a40829126490d9a7d67.tar.zst
sway-10ef118e09435a6fa7815a40829126490d9a7d67.zip
Fix pango escaping and refactor escape_markup_text
Fixes #2674. The cause of the issue was in get_pango_layout. When we call pango_parse_markup, `text` is the escaped string, and the unescaped string is then computed and written to `buf`. We were then passing the unescaped string to pango_layout_set_markup, but this function needs the escaped string. `buf` is not needed and has been removed. The other part of this PR refactors escape_markup_text to remove the dest_length argument and removes the -1 return value on error. It now assumes that you've allocated dest to the correct length.
Diffstat (limited to 'include/pango.h')
-rw-r--r--include/pango.h14
1 files changed, 5 insertions, 9 deletions
diff --git a/include/pango.h b/include/pango.h
index 09a535a5..6ab83c16 100644
--- a/include/pango.h
+++ b/include/pango.h
@@ -6,17 +6,13 @@
6#include <cairo/cairo.h> 6#include <cairo/cairo.h>
7#include <pango/pangocairo.h> 7#include <pango/pangocairo.h>
8 8
9/* Utility function which escape characters a & < > ' ". 9/**
10 * Utility function which escape characters a & < > ' ".
10 * 11 *
11 * If the dest parameter is NULL, then the function returns the length of 12 * The function returns the length of the escaped string, optionally writing the
12 * of the escaped src string. The dest_length doesn't matter. 13 * escaped string to dest if provided.
13 *
14 * If the dest parameter is not NULL then the fuction escapes the src string
15 * an puts the escaped string in dest and returns the lenght of the escaped string.
16 * The dest_length parameter is the size of dest array. If the size of dest is not
17 * enough, then the function returns -1.
18 */ 14 */
19int escape_markup_text(const char *src, char *dest, int dest_length); 15size_t escape_markup_text(const char *src, char *dest);
20PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, 16PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
21 const char *text, double scale, bool markup); 17 const char *text, double scale, bool markup);
22void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, 18void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,