Skip to content

Instantly share code, notes, and snippets.

@Yabes
Created November 16, 2016 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yabes/942922a058f828a4596fb96f57f0aa7d to your computer and use it in GitHub Desktop.
Save Yabes/942922a058f828a4596fb96f57f0aa7d to your computer and use it in GitHub Desktop.
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -5232,7 +5232,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.
*/
@@ -5256,7 +5256,7 @@ ascii_glyph_table_init(void)
* Put a space between characters to avoid shaping. */
for (i = 0; i < 128; ++i)
{
- if (i >= 32 && i < 127)
+ if (i == 32 || (i >= 48 && i <= 57) || (i >= 65 && i <= 90) || (i >= 97 && i <= 122))
ascii_chars[2 * i] = i;
else
ascii_chars[2 * i] = '?';
@@ -5933,8 +5933,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)
@@ -5943,7 +5944,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);
@Yabes
Copy link
Author

Yabes commented Nov 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment