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 |
… | |
… | |
308 | |
308 | |
309 | if (unicode <= 0x009f) |
309 | if (unicode <= 0x009f) |
310 | return true; |
310 | return true; |
311 | |
311 | |
312 | if (unicode >= 0x2500 && unicode <= 0x259f && |
312 | if (unicode >= 0x2500 && unicode <= 0x259f && |
313 | ! OPTION_R (Opt_skipBuiltinGlyphs)) |
313 | !r->option (Opt_skipBuiltinGlyphs)) |
314 | return true; |
314 | return true; |
315 | |
315 | |
316 | if (IS_COMPOSE (unicode)) |
316 | if (IS_COMPOSE (unicode)) |
317 | return true; |
317 | return true; |
318 | |
318 | |
… | |
… | |
354 | ; |
354 | ; |
355 | |
355 | |
356 | int width = text - tp; |
356 | int width = text - tp; |
357 | int fwidth = r->fwidth * width; |
357 | int fwidth = r->fwidth * width; |
358 | |
358 | |
359 | if (0x2500 <= t && t <= 0x259f && |
359 | if (0x2500 <= t && t <= 0x259f) |
360 | ! OPTION_R (Opt_skipBuiltinGlyphs)) |
|
|
361 | { |
360 | { |
362 | uint16_t offs = linedraw_offs[t - 0x2500]; |
361 | uint16_t offs = linedraw_offs[t - 0x2500]; |
363 | uint32_t *a = linedraw_command + (offs >> 4); |
362 | uint32_t *a = linedraw_command + (offs >> 4); |
364 | uint32_t *b = a + (offs & 15); |
363 | uint32_t *b = a + (offs & 15); |
365 | |
364 | |
… | |
… | |
1270 | void |
1269 | void |
1271 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1270 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1272 | const text_t *text, int len, |
1271 | const text_t *text, int len, |
1273 | int fg, int bg) |
1272 | int fg, int bg) |
1274 | { |
1273 | { |
|
|
1274 | XGlyphInfo extents; |
|
|
1275 | XftGlyphSpec *enc = (XftGlyphSpec *)get_enc_buf (len * sizeof (XftGlyphSpec)); |
|
|
1276 | XftGlyphSpec *ep = enc; |
|
|
1277 | |
1275 | clear_rect (d, x, y, r->fwidth * len, r->fheight, bg); |
1278 | clear_rect (d, x, y, r->fwidth * len, r->fheight, bg); |
1276 | |
1279 | |
1277 | int base = ascent; // should be fbase, but that is incorrect |
1280 | // cut trailing spaces |
1278 | |
1281 | while (len && text [len - 1] == ' ') |
1279 | XGlyphInfo extents; |
1282 | len--; |
1280 | FcChar32 *enc = (FcChar32 *) get_enc_buf (len * sizeof (FcChar32)); |
|
|
1281 | FcChar32 *ep = enc; |
|
|
1282 | int ewidth = 0; |
|
|
1283 | |
1283 | |
1284 | while (len) |
1284 | while (len) |
1285 | { |
1285 | { |
1286 | int cwidth = r->fwidth; |
1286 | int cwidth = r->fwidth; |
1287 | FcChar32 fc = *text++; len--; |
1287 | FcChar32 fc = *text++; len--; |
1288 | |
1288 | |
1289 | while (len && *text == NOCHAR) |
1289 | while (len && *text == NOCHAR) |
1290 | text++, len--, cwidth += r->fwidth; |
1290 | text++, len--, cwidth += r->fwidth; |
1291 | |
1291 | |
1292 | if (fc == ' ' && ep == enc) // skip leading spaces |
1292 | if (fc != ' ') // skip spaces |
1293 | x += cwidth; |
|
|
1294 | else |
|
|
1295 | { |
1293 | { |
1296 | FT_UInt gl = XftCharIndex (d.display->display, f, fc); |
1294 | FT_UInt glyph = XftCharIndex (d.display->display, f, fc); |
1297 | XftGlyphExtents (d.display->display, f, &gl, 1, &extents); |
1295 | XftGlyphExtents (d.display->display, f, &glyph, 1, &extents); |
1298 | |
1296 | |
1299 | if (extents.xOff != cwidth) |
1297 | ep->glyph = glyph; |
1300 | { |
1298 | ep->x = x + (cwidth - extents.xOff >> 1); |
1301 | if (ewidth) |
1299 | ep->y = y + ascent; |
1302 | { |
1300 | ep++; |
1303 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
|
|
1304 | x, y + base, enc, ep - enc); |
|
|
1305 | x += ewidth; |
|
|
1306 | |
|
|
1307 | ep = enc; |
|
|
1308 | ewidth = 0; |
|
|
1309 | } |
|
|
1310 | |
|
|
1311 | if (extents.xOff > cwidth) |
|
|
1312 | extents.xOff = cwidth; |
|
|
1313 | |
|
|
1314 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
|
|
1315 | x + (cwidth - extents.xOff >> 1), |
|
|
1316 | y + base, &gl, 1); |
|
|
1317 | x += cwidth; |
|
|
1318 | } |
1301 | } |
1319 | else |
1302 | |
1320 | { |
1303 | x += cwidth; |
1321 | *ep++ = gl; |
|
|
1322 | ewidth += cwidth; |
|
|
1323 | } |
|
|
1324 | } |
|
|
1325 | } |
1304 | } |
1326 | |
1305 | |
1327 | if (ep != enc) |
1306 | if (ep != enc) |
1328 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
1307 | XftDrawGlyphSpec (d, &r->pix_colors[fg].c, f, enc, ep - enc); |
1329 | x, y + base, enc, ep - enc); |
|
|
1330 | } |
1308 | } |
1331 | #endif |
1309 | #endif |
1332 | |
1310 | |
1333 | ///////////////////////////////////////////////////////////////////////////// |
1311 | ///////////////////////////////////////////////////////////////////////////// |
1334 | |
1312 | |