From 6ef6cb1573a9a587e4912f735ad837f149f50a5a Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 20 Mar 2016 20:04:26 +0000 Subject: [PATCH] Fix goof in Pango bidi suppression. When we're displaying bidirectionally active text (that is, text that the Unicode bidi algorithm will fiddle with), we need to suppress Pango's bidi because we've already done our own. We were doing this by calling is_rtl() on each character, and if it returned true, displaying just that character in a separate Pango call. Except that, ahem, we were only doing this if the _first_ character encountered during a scan of the display buffer was rtl-sensitive. If the first one was fine but a subsequent one was rtl-sensitive, then that one would just get shoved into the buffer we'd already started. Running pterm -fn 'client:Monospace 12' and displaying testdata/utf8.txt now works again. --- unix/gtkfont.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unix/gtkfont.c b/unix/gtkfont.c index a865121e..ed9888bc 100644 --- a/unix/gtkfont.c +++ b/unix/gtkfont.c @@ -1543,7 +1543,8 @@ static void pangofont_draw_internal(unifont_drawctx *ctx, unifont *font, (unsigned char)utfptr[clen] < 0xC0) clen++; n++; - if (pangofont_char_width(layout, pfont, + if (is_rtl(string[n-1]) || + pangofont_char_width(layout, pfont, string[n-1], utfptr + oldclen, clen - oldclen) != desired) { clen = oldclen;