ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtfont.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtfont.C (file contents):
Revision 1.94 by root, Thu Feb 2 18:04:46 2006 UTC vs.
Revision 1.95 by root, Sat Feb 18 14:14:43 2006 UTC

163#define dTermDisplay Display *disp = term->dpy 163#define dTermDisplay Display *disp = term->dpy
164#define dTermGC GC gc = term->gc 164#define dTermGC GC gc = term->gc
165 165
166///////////////////////////////////////////////////////////////////////////// 166/////////////////////////////////////////////////////////////////////////////
167 167
168#if XFT
169rxvt_drawable::~rxvt_drawable ()
170{
171 if (xftdrawable)
172 XftDrawDestroy (xftdrawable);
173}
174
175rxvt_drawable::operator XftDraw *()
176{
177 if (!xftdrawable)
178 xftdrawable = XftDrawCreate (screen->dpy, drawable, screen->visual, screen->cmap);
179
180 return xftdrawable;
181}
182#endif
183
184/////////////////////////////////////////////////////////////////////////////
185
186static const char * 168static const char *
187enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) 169enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero)
188{ 170{
189 uint8_t *buf = rxvt_temp_buf<uint8_t> (len); 171 uint8_t *buf = rxvt_temp_buf<uint8_t> (len);
190 uint8_t *res = buf; 172 uint8_t *res = buf;
1282void 1264void
1283rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, 1265rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
1284 const text_t *text, int len, 1266 const text_t *text, int len,
1285 int fg, int bg) 1267 int fg, int bg)
1286{ 1268{
1287 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
1288
1289 XGlyphInfo extents; 1269 XGlyphInfo extents;
1290 XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); 1270 XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec));
1291 XftGlyphSpec *ep = enc; 1271 XftGlyphSpec *ep = enc;
1292 1272
1293 dTermDisplay; 1273 dTermDisplay;
1294 dTermGC; 1274 dTermGC;
1295 1275
1276 int w = term->fwidth * len;
1277 int h = term->fheight;
1278
1279 bool buffered = false;
1280
1296 // cut trailing spaces 1281 // cut trailing spaces
1297 while (len && text [len - 1] == ' ') 1282 while (len && text [len - 1] == ' ')
1298 len--; 1283 len--;
1284
1285 int x_ = buffered ? 0 : x;
1286 int y_ = buffered ? 0 : y;
1299 1287
1300 while (len) 1288 while (len)
1301 { 1289 {
1302 int cwidth = term->fwidth; 1290 int cwidth = term->fwidth;
1303 FcChar32 fc = *text++; len--; 1291 FcChar32 fc = *text++; len--;
1309 { 1297 {
1310 FT_UInt glyph = XftCharIndex (disp, f, fc); 1298 FT_UInt glyph = XftCharIndex (disp, f, fc);
1311 XftGlyphExtents (disp, f, &glyph, 1, &extents); 1299 XftGlyphExtents (disp, f, &glyph, 1, &extents);
1312 1300
1313 ep->glyph = glyph; 1301 ep->glyph = glyph;
1314 ep->x = x + (cwidth - extents.xOff >> 1); 1302 ep->x = x_ + (cwidth - extents.xOff >> 1);
1315 ep->y = y + ascent; 1303 ep->y = y_ + ascent;
1316 1304
1317 if (extents.xOff == 0) 1305 if (extents.xOff == 0)
1318 ep->x = x + cwidth; 1306 ep->x = x_ + cwidth;
1319 1307
1320 ep++; 1308 ep++;
1321 } 1309 }
1322 1310
1323 x += cwidth; 1311 x_ += cwidth;
1312 }
1313
1314 if (buffered)
1324 } 1315 {
1325
1326 if (ep != enc) 1316 if (ep != enc)
1317 {
1318 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1319
1320 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h);
1321
1322 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
1323 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
1324 }
1325 else
1326 clear_rect (d, x, y, w, h, bg);
1327 }
1328 else
1329 {
1330 clear_rect (d, x, y, w, h, bg);
1327 XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); 1331 XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc);
1332 }
1328} 1333}
1334
1329#endif 1335#endif
1330 1336
1331///////////////////////////////////////////////////////////////////////////// 1337/////////////////////////////////////////////////////////////////////////////
1332 1338
1333rxvt_fontset::rxvt_fontset (rxvt_term *term) 1339rxvt_fontset::rxvt_fontset (rxvt_term *term)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines