[dev] st slow startup

From: Johannes Hofmann <Johannes.Hofmann_AT_gmx.de>
Date: Thu, 9 May 2013 23:42:50 +0200

Hi,

as others also have noticed, Xft based st starts slow on some
systems. For me it helps if FcFontSort() is done lazily as shown
below.

Regards,
Johannes


diff --git a/st.c b/st.c
index 50090a4..425f669 100644
--- a/st.c
+++ b/st.c
_AT_@ -2643,10 +2643,7 @@ xloadfont(Font *f, FcPattern *pattern) {
         if(!match)
                 return 1;
 
- if(!(f->set = FcFontSort(0, match, FcTrue, 0, &result))) {
- FcPatternDestroy(match);
- return 1;
- }
+ f->set = NULL;
 
         if(!(f->match = XftFontOpenPattern(xw.dpy, match))) {
                 FcPatternDestroy(match);
_AT_@ -2666,6 +2663,16 @@ xloadfont(Font *f, FcPattern *pattern) {
         return 0;
 }
 
+int
+xloadfontset(Font *f) {
+ FcResult result;
+
+ if(!(f->set = FcFontSort(0, f->pattern, FcTrue, 0, &result))) {
+ return 1;
+ }
+ return 0;
+}
+
 void
 xloadfonts(char *fontstr, int fontsize) {
         FcPattern *pattern;
_AT_@ -2987,7 +2994,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
         r.width = width;
         XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1);
 
- fcsets[0] = font->set;
         for(xp = winx; bytelen > 0;) {
                 /*
                  * Search for the range in the to be printed string of glyphs
_AT_@ -3045,6 +3051,10 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 
                 /* Nothing was found. */
                 if(i >= frclen) {
+ if (!font->set)
+ xloadfontset(font);
+ fcsets[0] = font->set;
+
                         /*
                          * Nothing was found in the cache. Now use
                          * some dozen of Fontconfig calls to get the
Received on Thu May 09 2013 - 23:42:50 CEST

This archive was generated by hypermail 2.3.0 : Thu May 09 2013 - 23:48:05 CEST