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.76 by root, Tue Jan 3 23:40:58 2006 UTC vs.
Revision 1.83 by root, Mon Jan 9 07:35:23 2006 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: rxvtfont.C 2 * File: rxvtfont.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 4 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com>
5 * - original version. 5 * - original version.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *---------------------------------------------------------------------*/ 20 *---------------------------------------------------------------------*/
21 21
22#include "../config.h" 22#include "../config.h"
23#include "rxvt.h" 23#include "rxvt.h"
24#include "rxvtlib.h"
24#include "rxvtutil.h" 25#include "rxvtutil.h"
25#include "rxvtfont.h" 26#include "rxvtfont.h"
26 27
27#include <cstdlib> 28#include <cstdlib>
28#include <wchar.h> 29#include <wchar.h>
306 return false; 307 return false;
307 308
308 if (unicode <= 0x009f) 309 if (unicode <= 0x009f)
309 return true; 310 return true;
310 311
311 if (unicode >= 0x2500 && unicode <= 0x259f) 312 if (unicode >= 0x2500 && unicode <= 0x259f &&
313 !r->option (Opt_skipBuiltinGlyphs))
312 return true; 314 return true;
313 315
314 if (IS_COMPOSE (unicode)) 316 if (IS_COMPOSE (unicode))
315 return true; 317 return true;
316 318
1267void 1269void
1268rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, 1270rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
1269 const text_t *text, int len, 1271 const text_t *text, int len,
1270 int fg, int bg) 1272 int fg, int bg)
1271{ 1273{
1274 XGlyphInfo extents;
1275 XftGlyphSpec *enc = (XftGlyphSpec *)get_enc_buf (len * sizeof (XftGlyphSpec));
1276 XftGlyphSpec *ep = enc;
1277
1272 clear_rect (d, x, y, r->fwidth * len, r->fheight, bg); 1278 clear_rect (d, x, y, r->fwidth * len, r->fheight, bg);
1273 1279
1274 int base = ascent; // should be fbase, but that is incorrect 1280 // cut trailing spaces
1275 1281 while (len && text [len - 1] == ' ')
1276 XGlyphInfo extents; 1282 len--;
1277 FcChar32 *enc = (FcChar32 *) get_enc_buf (len * sizeof (FcChar32));
1278 FcChar32 *ep = enc;
1279 int ewidth = 0;
1280 1283
1281 while (len) 1284 while (len)
1282 { 1285 {
1283 int cwidth = r->fwidth; 1286 int cwidth = r->fwidth;
1284 FcChar32 fc = *text++; len--; 1287 FcChar32 fc = *text++; len--;
1285 1288
1286 while (len && *text == NOCHAR) 1289 while (len && *text == NOCHAR)
1287 text++, len--, cwidth += r->fwidth; 1290 text++, len--, cwidth += r->fwidth;
1288 1291
1289 if (fc == ' ' && ep == enc) // skip leading spaces 1292 if (fc != ' ') // skip spaces
1290 x += cwidth;
1291 else
1292 { 1293 {
1293 FT_UInt gl = XftCharIndex (d.display->display, f, fc); 1294 FT_UInt glyph = XftCharIndex (d.display->display, f, fc);
1294 XftGlyphExtents (d.display->display, f, &gl, 1, &extents); 1295 XftGlyphExtents (d.display->display, f, &glyph, 1, &extents);
1295 1296
1296 if (extents.xOff != cwidth) 1297 ep->glyph = glyph;
1297 { 1298 ep->x = x + (cwidth - extents.xOff >> 1);
1298 if (ewidth) 1299 ep->y = y + ascent;
1299 { 1300 ep++;
1300 XftDrawGlyphs (d, &r->pix_colors[fg].c, f,
1301 x, y + base, enc, ep - enc);
1302 x += ewidth;
1303
1304 ep = enc;
1305 ewidth = 0;
1306 }
1307
1308 if (extents.xOff > cwidth)
1309 extents.xOff = cwidth;
1310
1311 XftDrawGlyphs (d, &r->pix_colors[fg].c, f,
1312 x + (cwidth - extents.xOff >> 1),
1313 y + base, &gl, 1);
1314 x += cwidth;
1315 } 1301 }
1316 else 1302
1317 { 1303 x += cwidth;
1318 *ep++ = gl;
1319 ewidth += cwidth;
1320 }
1321 }
1322 } 1304 }
1323 1305
1324 if (ep != enc) 1306 if (ep != enc)
1325 XftDrawGlyphs (d, &r->pix_colors[fg].c, f, 1307 XftDrawGlyphSpec (d, &r->pix_colors[fg].c, f, enc, ep - enc);
1326 x, y + base, enc, ep - enc);
1327} 1308}
1328#endif 1309#endif
1329 1310
1330///////////////////////////////////////////////////////////////////////////// 1311/////////////////////////////////////////////////////////////////////////////
1331 1312

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines