Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 20 additions & 38 deletions draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,21 +395,20 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
XpmColorSymbol xpms;
#endif

/* icon cache */
int ip;

#ifdef DZEN_XFT
XftDraw *xftd=NULL;
XftColor xftc;
char *xftcs;
int xftcs_f=0;
char *xftcs_bg;
int xftcs_bgf=0;

xftcs = (char *)dzen.fg;
xftcs_bg = (char *)dzen.bg;
/* set default fg/bg for XFT */
xftcs = estrdup(dzen.fg);
xftcs_bg = estrdup(dzen.bg);
#endif

/* icon cache */
int ip;

/* parse line and return the text without control commands */
if(nodraw) {
rbuf = emalloc(MAX_LINE_LEN);
Expand Down Expand Up @@ -446,8 +445,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
xpms.pixel = dzen.norm[ColBG];
#endif
#ifdef DZEN_XFT
xftcs_bg = (char *)dzen.bg;
xftcs_bgf = 0;
xftcs_bg = estrdup(dzen.bg);
#endif
}
else {
Expand Down Expand Up @@ -679,35 +677,24 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
case bg:
lastbg = tval[0] ? (unsigned)getcolor(tval) : dzen.norm[ColBG];
#ifdef DZEN_XFT
if(xftcs_bgf) free(xftcs_bg);
if(tval[0]) {
xftcs_bg = estrdup(tval);
xftcs_bgf = 1;
} else {
xftcs_bg = (char *)dzen.bg;
xftcs_bgf = 0;
}
#endif
if(xftcs_bg) free(xftcs_bg);
xftcs_bg = estrdup(tval[0] ? tval : dzen.bg);
#endif

break;

case fg:
lastfg = tval[0] ? (unsigned)getcolor(tval) : dzen.norm[ColFG];
XSetForeground(dzen.dpy, dzen.tgc, lastfg);
#ifdef DZEN_XFT
if(tval[0]) {
xftcs = estrdup(tval);
xftcs_f = 1;
} else {
xftcs = (char *)dzen.fg;
xftcs_f = 0;
}
#endif
if (xftcs) free(xftcs);
xftcs = estrdup(tval[0] ? tval : dzen.fg);
#endif
break;

case fn:
if(tval[0]) {
#ifndef DZEN_XFT
#ifndef DZEN_XFT
if(!strncmp(tval, "dfnt", 4)) {
cur_fnt = &(dzen.fnpl[atoi(tval+4)]);

Expand Down Expand Up @@ -816,18 +803,8 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
DefaultColormap(dzen.dpy, dzen.screen), xftcs, &xftc);
}

XftDrawStringUtf8(xftd, &xftc,
XftDrawStringUtf8(xftd, &xftc,
cur_fnt->xftfont, px, py + dzen.font.xftfont->ascent, (const FcChar8 *)lbuf, strlen(lbuf));

if(xftcs_f) {
free(xftcs);
xftcs_f = 0;
}
if(xftcs_bgf) {
free(xftcs_bg);
xftcs_bgf = 0;
}

#endif

max_y = MAX(max_y, py+dzen.font.height);
Expand Down Expand Up @@ -920,6 +897,11 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
#endif
}

#ifdef DZEN_XFT
if(xftcs) free(xftcs);
if(xftcs_bg) free(xftcs_bg);
#endif

return nodraw ? rbuf : NULL;
}

Expand Down