|
|
@ -437,7 +437,7 @@ typedef struct { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
static Fontcache frc[256]; |
|
|
|
static Fontcache frc[256]; |
|
|
|
static int frccur = 0, frclen = 0; |
|
|
|
static int frccur = -1, frclen = 0; |
|
|
|
|
|
|
|
|
|
|
|
ssize_t |
|
|
|
ssize_t |
|
|
|
xwrite(int fd, char *s, size_t len) { |
|
|
|
xwrite(int fd, char *s, size_t len) { |
|
|
@ -2410,7 +2410,7 @@ xunloadfonts(void) |
|
|
|
ip = LEN(frc) - 1; |
|
|
|
ip = LEN(frc) - 1; |
|
|
|
XftFontClose(xw.dpy, frc[ip].font); |
|
|
|
XftFontClose(xw.dpy, frc[ip].font); |
|
|
|
} |
|
|
|
} |
|
|
|
frccur = 0; |
|
|
|
frccur = -1; |
|
|
|
frclen = 0; |
|
|
|
frclen = 0; |
|
|
|
|
|
|
|
|
|
|
|
XftFontClose(xw.dpy, dc.font.match); |
|
|
|
XftFontClose(xw.dpy, dc.font.match); |
|
|
@ -2532,11 +2532,12 @@ xinit(void) { |
|
|
|
void |
|
|
|
void |
|
|
|
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { |
|
|
|
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { |
|
|
|
int winx = borderpx + x * xw.cw, winy = borderpx + y * xw.ch, |
|
|
|
int winx = borderpx + x * xw.cw, winy = borderpx + y * xw.ch, |
|
|
|
width = charlen * xw.cw, u8clen, xp, i, frp, frcflags; |
|
|
|
width = charlen * xw.cw, xp, i; |
|
|
|
|
|
|
|
int frp, frcflags; |
|
|
|
|
|
|
|
int u8fl, u8fblen, u8cblen, doesexist; |
|
|
|
|
|
|
|
char *u8c, *u8fs; |
|
|
|
long u8char; |
|
|
|
long u8char; |
|
|
|
char *u8c; |
|
|
|
|
|
|
|
Font *font = &dc.font; |
|
|
|
Font *font = &dc.font; |
|
|
|
XftFont *sfont; |
|
|
|
|
|
|
|
FcResult fcres; |
|
|
|
FcResult fcres; |
|
|
|
FcPattern *fcpattern, *fontpattern; |
|
|
|
FcPattern *fcpattern, *fontpattern; |
|
|
|
FcFontSet *fcsets[] = { NULL }; |
|
|
|
FcFontSet *fcsets[] = { NULL }; |
|
|
@ -2608,11 +2609,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { |
|
|
|
bg = temp; |
|
|
|
bg = temp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Width of the whole string that should be printed. */ |
|
|
|
|
|
|
|
XftTextExtentsUtf8(xw.dpy, font->match, (FcChar8 *)s, bytelen, |
|
|
|
|
|
|
|
&extents); |
|
|
|
|
|
|
|
width = extents.xOff; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Intelligent cleaning up of the borders. */ |
|
|
|
/* Intelligent cleaning up of the borders. */ |
|
|
|
if(x == 0) { |
|
|
|
if(x == 0) { |
|
|
|
xclear(0, (y == 0)? 0 : winy, borderpx, |
|
|
|
xclear(0, (y == 0)? 0 : winy, borderpx, |
|
|
@ -2630,24 +2626,49 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { |
|
|
|
/* Clean up the region we want to draw to. */ |
|
|
|
/* Clean up the region we want to draw to. */ |
|
|
|
XftDrawRect(xw.draw, bg, winx, winy, width, xw.ch); |
|
|
|
XftDrawRect(xw.draw, bg, winx, winy, width, xw.ch); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fcsets[0] = font->set; |
|
|
|
|
|
|
|
for (xp = winx; bytelen > 0;) { |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Step through all UTF-8 characters one by one and search in the font |
|
|
|
* Search for the range in the to be printed string of glyphs |
|
|
|
* cache ring buffer, whether there was some font found to display the |
|
|
|
* that are in the main font. Then print that range. If |
|
|
|
* unicode value of that UTF-8 character. |
|
|
|
* some glyph is found that is not in the font, do the |
|
|
|
|
|
|
|
* fallback dance. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fcsets[0] = font->set; |
|
|
|
u8fs = s; |
|
|
|
for (xp = winx; bytelen > 0; ) { |
|
|
|
u8fblen = 0; |
|
|
|
|
|
|
|
u8fl = 0; |
|
|
|
|
|
|
|
for (;;) { |
|
|
|
u8c = s; |
|
|
|
u8c = s; |
|
|
|
u8clen = utf8decode(s, &u8char); |
|
|
|
u8cblen = utf8decode(s, &u8char); |
|
|
|
s += u8clen; |
|
|
|
s += u8cblen; |
|
|
|
bytelen -= u8clen; |
|
|
|
bytelen -= u8cblen; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doesexist = XftCharIndex(xw.dpy, font->match, u8char); |
|
|
|
|
|
|
|
if (!doesexist || bytelen <= 0) { |
|
|
|
|
|
|
|
if (bytelen <= 0) { |
|
|
|
|
|
|
|
if (doesexist) { |
|
|
|
|
|
|
|
u8fl++; |
|
|
|
|
|
|
|
u8fblen += u8cblen; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (u8fl > 0) { |
|
|
|
|
|
|
|
XftDrawStringUtf8(xw.draw, fg, |
|
|
|
|
|
|
|
font->match, xp, |
|
|
|
|
|
|
|
winy + font->ascent, |
|
|
|
|
|
|
|
(FcChar8 *)u8fs, |
|
|
|
|
|
|
|
u8fblen); |
|
|
|
|
|
|
|
xp += font->width * u8fl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u8fl++; |
|
|
|
|
|
|
|
u8fblen += u8cblen; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (doesexist) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
sfont = font->match; |
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Only check the font cache or load new fonts, if the |
|
|
|
|
|
|
|
* characters is not represented in main font. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (!XftCharExists(xw.dpy, font->match, u8char)) { |
|
|
|
|
|
|
|
frp = frccur; |
|
|
|
frp = frccur; |
|
|
|
/* Search the font cache. */ |
|
|
|
/* Search the font cache. */ |
|
|
|
for (i = 0; i < frclen; i++, frp--) { |
|
|
|
for (i = 0; i < frclen; i++, frp--) { |
|
|
@ -2659,6 +2680,8 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Nothing was found. */ |
|
|
|
if (i >= frclen) { |
|
|
|
if (i >= frclen) { |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Nothing was found in the cache. Now use |
|
|
|
* Nothing was found in the cache. Now use |
|
|
@ -2681,19 +2704,19 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { |
|
|
|
fontpattern = FcFontSetMatch(0, fcsets, |
|
|
|
fontpattern = FcFontSetMatch(0, fcsets, |
|
|
|
FcTrue, fcpattern, &fcres); |
|
|
|
FcTrue, fcpattern, &fcres); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Overwrite or create the new cache entry |
|
|
|
|
|
|
|
* entry. |
|
|
|
|
|
|
|
*/ |
|
|
|
frccur++; |
|
|
|
frccur++; |
|
|
|
frclen++; |
|
|
|
frclen++; |
|
|
|
if (frccur >= LEN(frc)) |
|
|
|
if (frccur >= LEN(frc)) |
|
|
|
frccur = 0; |
|
|
|
frccur = 0; |
|
|
|
if (frclen >= LEN(frc)) { |
|
|
|
if (frclen > LEN(frc)) { |
|
|
|
frclen = LEN(frc); |
|
|
|
frclen = LEN(frc); |
|
|
|
XftFontClose(xw.dpy, frc[frccur].font); |
|
|
|
XftFontClose(xw.dpy, frc[frccur].font); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Overwrite or create the new cache entry |
|
|
|
|
|
|
|
* entry. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
frc[frccur].font = XftFontOpenPattern(xw.dpy, |
|
|
|
frc[frccur].font = XftFontOpenPattern(xw.dpy, |
|
|
|
fontpattern); |
|
|
|
fontpattern); |
|
|
|
frc[frccur].c = u8char; |
|
|
|
frc[frccur].c = u8char; |
|
|
@ -2704,11 +2727,10 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { |
|
|
|
|
|
|
|
|
|
|
|
frp = frccur; |
|
|
|
frp = frccur; |
|
|
|
} |
|
|
|
} |
|
|
|
sfont = frc[frp].font; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XftDrawStringUtf8(xw.draw, fg, sfont, xp, winy + sfont->ascent, |
|
|
|
XftDrawStringUtf8(xw.draw, fg, frc[frp].font, |
|
|
|
(FcChar8 *)u8c, u8clen); |
|
|
|
xp, winy + frc[frp].font->ascent, |
|
|
|
|
|
|
|
(FcChar8 *)u8c, u8cblen); |
|
|
|
|
|
|
|
|
|
|
|
xp += font->width; |
|
|
|
xp += font->width; |
|
|
|
} |
|
|
|
} |
|
|
|