aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2013-05-11 08:54:26 +0200
committerChristoph Lohmann <20h@r-36.net>2013-05-11 08:54:26 +0200
commit62502a88e94dd908fdd4418899afdd09a4de3bea (patch)
tree1720ca7a66bbfa0788c230ceecace91083a61a7b /st.c
parent678eff6e1882a888deda5e4e429df42c39b604fe (diff)
downloadst-62502a88e94dd908fdd4418899afdd09a4de3bea.tar.gz
st-62502a88e94dd908fdd4418899afdd09a4de3bea.zip
Lazy fontset loading.
Thanks Johannes Hofmann <Johannes.Hofmann@gmx.de>!
Diffstat (limited to 'st.c')
-rw-r--r--st.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/st.c b/st.c
index 50090a4..56955a3 100644
--- a/st.c
+++ b/st.c
@@ -363,6 +363,7 @@ static void xloadcols(void);
363static int xsetcolorname(int, const char *); 363static int xsetcolorname(int, const char *);
364static int xloadfont(Font *, FcPattern *); 364static int xloadfont(Font *, FcPattern *);
365static void xloadfonts(char *, int); 365static void xloadfonts(char *, int);
366static int xloadfontset(Font *);
366static void xsettitle(char *); 367static void xsettitle(char *);
367static void xresettitle(void); 368static void xresettitle(void);
368static void xseturgency(int); 369static void xseturgency(int);
@@ -2643,16 +2644,12 @@ xloadfont(Font *f, FcPattern *pattern) {
2643 if(!match) 2644 if(!match)
2644 return 1; 2645 return 1;
2645 2646
2646 if(!(f->set = FcFontSort(0, match, FcTrue, 0, &result))) {
2647 FcPatternDestroy(match);
2648 return 1;
2649 }
2650
2651 if(!(f->match = XftFontOpenPattern(xw.dpy, match))) { 2647 if(!(f->match = XftFontOpenPattern(xw.dpy, match))) {
2652 FcPatternDestroy(match); 2648 FcPatternDestroy(match);
2653 return 1; 2649 return 1;
2654 } 2650 }
2655 2651
2652 f->set = NULL;
2656 f->pattern = FcPatternDuplicate(pattern); 2653 f->pattern = FcPatternDuplicate(pattern);
2657 2654
2658 f->ascent = f->match->ascent; 2655 f->ascent = f->match->ascent;
@@ -2727,6 +2724,15 @@ xloadfonts(char *fontstr, int fontsize) {
2727 FcPatternDestroy(pattern); 2724 FcPatternDestroy(pattern);
2728} 2725}
2729 2726
2727int
2728xloadfontset(Font *f) {
2729 FcResult result;
2730
2731 if(!(f->set = FcFontSort(0, f->pattern, FcTrue, 0, &result)))
2732 return 1;
2733 return 0;
2734}
2735
2730void 2736void
2731xunloadfonts(void) { 2737xunloadfonts(void) {
2732 int i, ip; 2738 int i, ip;
@@ -2987,7 +2993,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
2987 r.width = width; 2993 r.width = width;
2988 XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1); 2994 XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1);
2989 2995
2990 fcsets[0] = font->set;
2991 for(xp = winx; bytelen > 0;) { 2996 for(xp = winx; bytelen > 0;) {
2992 /* 2997 /*
2993 * Search for the range in the to be printed string of glyphs 2998 * Search for the range in the to be printed string of glyphs
@@ -3045,6 +3050,10 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
3045 3050
3046 /* Nothing was found. */ 3051 /* Nothing was found. */
3047 if(i >= frclen) { 3052 if(i >= frclen) {
3053 if(!font->set)
3054 xloadfontset(font);
3055 fcsets[0] = font->set;
3056
3048 /* 3057 /*
3049 * Nothing was found in the cache. Now use 3058 * Nothing was found in the cache. Now use
3050 * some dozen of Fontconfig calls to get the 3059 * some dozen of Fontconfig calls to get the