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 | |
… | |
… | |
1272 | clear_rect (d, x, y, r->fwidth * len, r->fheight, bg); |
1274 | clear_rect (d, x, y, r->fwidth * len, r->fheight, bg); |
1273 | |
1275 | |
1274 | int base = ascent; // should be fbase, but that is incorrect |
1276 | int base = ascent; // should be fbase, but that is incorrect |
1275 | |
1277 | |
1276 | XGlyphInfo extents; |
1278 | XGlyphInfo extents; |
1277 | FcChar32 *enc = (FcChar32 *) get_enc_buf (len * sizeof (FcChar32)); |
1279 | XftGlyphSpec *enc = (XftGlyphSpec *) get_enc_buf (len * sizeof (XftGlyphSpec)); |
1278 | FcChar32 *ep = enc; |
1280 | XftGlyphSpec *ep = enc; |
1279 | int ewidth = 0; |
1281 | |
|
|
1282 | // skip trailing spaces |
|
|
1283 | while (len && text [len - 1] == ' ') |
|
|
1284 | len--; |
1280 | |
1285 | |
1281 | while (len) |
1286 | while (len) |
1282 | { |
1287 | { |
1283 | int cwidth = r->fwidth; |
1288 | int cwidth = r->fwidth; |
1284 | FcChar32 fc = *text++; len--; |
1289 | FcChar32 fc = *text++; len--; |
1285 | |
1290 | |
1286 | while (len && *text == NOCHAR) |
1291 | while (len && *text == NOCHAR) |
1287 | text++, len--, cwidth += r->fwidth; |
1292 | text++, len--, cwidth += r->fwidth; |
1288 | |
1293 | |
1289 | if (fc == ' ' && ep == enc) // skip leading spaces |
1294 | if (fc != ' ') // skip spaces |
1290 | x += cwidth; |
|
|
1291 | else |
|
|
1292 | { |
1295 | { |
1293 | FT_UInt gl = XftCharIndex (d.display->display, f, fc); |
1296 | FT_UInt gl = XftCharIndex (d.display->display, f, fc); |
1294 | XftGlyphExtents (d.display->display, f, &gl, 1, &extents); |
1297 | XftGlyphExtents (d.display->display, f, &gl, 1, &extents); |
1295 | |
1298 | |
1296 | if (extents.xOff != cwidth) |
1299 | ep->glyph = gl; |
1297 | { |
1300 | ep->x = x + (cwidth - extents.xOff >> 1); |
1298 | if (ewidth) |
1301 | ep->y = y + base; |
1299 | { |
1302 | 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 | } |
1303 | } |
1316 | else |
1304 | |
1317 | { |
1305 | x += cwidth; |
1318 | *ep++ = gl; |
|
|
1319 | ewidth += cwidth; |
|
|
1320 | } |
|
|
1321 | } |
|
|
1322 | } |
1306 | } |
1323 | |
1307 | |
1324 | if (ep != enc) |
1308 | if (ep != enc) |
1325 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
1309 | XftDrawGlyphSpec (d, &r->pix_colors[fg].c, f, enc, ep - enc); |
1326 | x, y + base, enc, ep - enc); |
|
|
1327 | } |
1310 | } |
1328 | #endif |
1311 | #endif |
1329 | |
1312 | |
1330 | ///////////////////////////////////////////////////////////////////////////// |
1313 | ///////////////////////////////////////////////////////////////////////////// |
1331 | |
1314 | |