From 4bb3e2b16ec0eba141a4e43cd8beed431623da9d Mon Sep 17 00:00:00 2001 From: ilevy Date: Mon, 13 Dec 2021 21:22:14 +0200 Subject: [PATCH] Check text base direction --- src/bubblegen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bubblegen.c b/src/bubblegen.c index 0145fab..eea62ea 100644 --- a/src/bubblegen.c +++ b/src/bubblegen.c @@ -371,6 +371,7 @@ GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height, PangoFontDescription *font = pango_font_description_from_string(get_string_option("font")); PangoAttrList *pango_attrs = NULL; + PangoDirection text_direction = PANGO_DIRECTION_NEUTRAL; // Adjust max width to account for bubble edges max_width -= LEFT_BUF; @@ -394,6 +395,9 @@ GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height, pango_layout_set_attributes(layout, pango_attrs); } + text_direction = pango_find_base_dir(text, strlen(text)); + pango_context_set_base_dir(pango_context, text_direction); + pango_layout_set_font_description(layout, font); pango_layout_set_text(layout, stripped, -1); pango_layout_get_pixel_size(layout, &text_width, &text_height); -- 2.39.2