From: Michael D. Lowis Date: Mon, 1 May 2017 14:21:01 +0000 (-0400) Subject: Moved font cache size config option to edit.h with the other tunable items X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=ce3c2190235da4259b6e2dddd86c75478b486f45;p=projs%2Ftide.git Moved font cache size config option to edit.h with the other tunable items --- diff --git a/TODO.md b/TODO.md index a8a93d3..320bc0e 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,7 @@ Up Next: * refactor x11.c and win.c * Add keyboard shortcut to highlight the thing under the cursor -* Make Fn keys execute nth command in the tags buffer +* Make Fn keys execute nth command in the tags buffers * Run commands in the background and don't block the main thread. * check for file changes on save * check for file changes when window regains focus diff --git a/inc/edit.h b/inc/edit.h index 2a12642..5d0e952 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -205,11 +205,12 @@ enum ColorId { /* Configuration *****************************************************************************/ enum { - Width = 640, /* default window width */ - Height = 480, /* default window height */ - TabWidth = 4, /* maximum number of spaces used to represent a tab */ - ScrollLines = 4, /* number of lines to scroll by for mouse wheel scrolling */ - BufSize = 8192, /* default buffer size */ + Width = 640, /* default window width */ + Height = 480, /* default window height */ + TabWidth = 4, /* maximum number of spaces used to represent a tab */ + ScrollLines = 4, /* number of lines to scroll by for mouse wheel scrolling */ + BufSize = 8192, /* default buffer size */ + FontCacheSize = 16, /* Maximum number of fonts allowed in the font cache */ }; /* choose the font to use for xft */ diff --git a/lib/x11.c b/lib/x11.c index a4bc436..c56ea63 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -31,7 +31,7 @@ struct XFont { struct { XftFont* font; uint32_t unicodep; - } cache[MAXFONTS]; + } cache[FontCacheSize]; int ncached; }; @@ -435,8 +435,8 @@ void x11_font_getglyph(XFont fnt, XGlyphSpec* spec, uint32_t rune) { FcDefaultSubstitute(fcpattern); FcPattern* fontmatch = FcFontSetMatch(0, fcsets, 1, fcpattern, &fcres); /* add the font to the cache and use it */ - if (font->ncached >= MAXFONTS) { - font->ncached = MAXFONTS - 1; + if (font->ncached >= FontCacheSize) { + font->ncached = FontCacheSize - 1; XftFontClose(X.display, font->cache[font->ncached].font); } font->cache[font->ncached].font = XftFontOpenPattern(X.display, fontmatch);