Hello In a few words, here is a patch that makes gvim work better with ligatures in fonts, which can be useful even for programmers. Details follow.
I tried to use a Hasklig[^1], a font with ligatures intended for the Haskell language. It serves the same objective as the Haskell Conceal script[^2], but with the added benefit that even a mouse copy-paste works as intended. [^1]: https://github.com/i-tu/hasklig [^2]: http://www.vim.org/scripts/script.php?script_id=3200 Unfortunately, gvim doesn't support ligatures on ASCII characters. The following assertion fails at run-time: ascii_glyph_table_init: assertion 'gui.ascii_glyphs->num_glyphs == sizeof(ascii_chars)' failed and many characters are displayed with the wrong glyphs. The attached patch limits the function ascii_glyph_table_init() to spaces and alphanumeric chars. It solves the problem here. Yet I wonder if the current hack with ASCII characters is really useful. Is there any performance test to check if a simpler behaviour wouldn't be suitable, at least for modern desktop installations? As the code comment mentions spaces, maybe it should be restricted to blank lines? Regards -- François -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
diff -r 94df797ed6b0 -r e86e08d8e7af src/gui_gtk_x11.c --- a/src/gui_gtk_x11.c Sat Apr 12 13:12:24 2014 +0200 +++ b/src/gui_gtk_x11.c Sun Apr 20 14:50:35 2014 +0200 @@ -4311,7 +4311,7 @@ get_styled_font_variants(void) static PangoEngineShape *default_shape_engine = NULL; /* - * Create a map from ASCII characters in the range [32,126] to glyphs + * Create a map from ASCII characters [ ,0-9,a-z,A-Z] to glyphs * of the current font. This is used by gui_gtk2_draw_string() to skip * the itemize and shaping process for the most common case. */ @@ -4334,8 +4334,13 @@ ascii_glyph_table_init(void) /* For safety, fill in question marks for the control characters. */ for (i = 0; i < 32; ++i) ascii_chars[i] = '?'; - for (; i < 127; ++i) - ascii_chars[i] = i; + for (; i < 127; ++i) { + if (i == 32 || (i >= 48 && i <= 57) || (i >= 65 && i <= 90) || (i >= 97 && i <= 122)) { + ascii_chars[i] = i; + } else { + ascii_chars[i] = '?'; + } + } ascii_chars[i] = '?'; attr_list = pango_attr_list_new(); @@ -4961,8 +4966,9 @@ gui_gtk2_draw_string(int row, int col, c /* * Optimization hack: If possible, skip the itemize and shaping process - * for pure ASCII strings. This optimization is particularly effective - * because Vim draws space characters to clear parts of the screen. + * for pure alphanumeric ASCII strings. + * This optimization is particularly effective because Vim draws space + * characters to clear parts of the screen. */ if (!(flags & DRAW_ITALIC) && !((flags & DRAW_BOLD) && gui.font_can_bold) @@ -4971,7 +4977,7 @@ gui_gtk2_draw_string(int row, int col, c char_u *p; for (p = s; p < s + len; ++p) - if (*p & 0x80) + if (*p != 32 && (*p < 48 || *p > 57) && (*p < 65 || *p > 90) && (*p < 97 || *p > 122)) goto not_ascii; pango_glyph_string_set_size(glyphs, len);