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.116 by root, Tue Aug 28 17:33:46 2007 UTC vs.
Revision 1.123 by ayin, Sat Nov 24 10:32:33 2007 UTC

43 const char *name; 43 const char *name;
44} fallback_fonts[] = { 44} fallback_fonts[] = {
45 { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" }, 45 { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" },
46 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" }, 46 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" },
47 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-fcd8859-15" }, 47 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-fcd8859-15" },
48 48
49#if ENCODING_EU 49#if ENCODING_EU
50 // cyrillic 50 // cyrillic
51 { CS_KOI8_R, "-*-*-*-r-*--*-*-*-*-c-*-koi8-r" }, 51 { CS_KOI8_R, "-*-*-*-r-*--*-*-*-*-c-*-koi8-r" },
52 { CS_KOI8_U, "-*-*-*-r-*--*-*-*-*-c-*-koi8-u" }, 52 { CS_KOI8_U, "-*-*-*-r-*--*-*-*-*-c-*-koi8-u" },
53 53
54 { CS_ISO8859_2, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-2" }, 54 { CS_ISO8859_2, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-2" },
55 { CS_ISO8859_3, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-3" }, 55 { CS_ISO8859_3, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-3" },
56 { CS_ISO8859_4, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-4" }, 56 { CS_ISO8859_4, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-4" },
57 { CS_ISO8859_5, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-5" }, 57 { CS_ISO8859_5, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-5" },
58 { CS_ISO8859_6, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-6" }, 58 { CS_ISO8859_6, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-6" },
65 { CS_ISO8859_14, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-14" }, 65 { CS_ISO8859_14, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-14" },
66 { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" }, 66 { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" },
67 67
68# if XFT 68# if XFT
69 { CS_KOI8_U, "xft::lang=ru" }, 69 { CS_KOI8_U, "xft::lang=ru" },
70 70
71 { CS_ISO8859_5, "xft::lang=ru" }, 71 { CS_ISO8859_5, "xft::lang=ru" },
72 { CS_ISO8859_6, "xft::lang=ar" }, 72 { CS_ISO8859_6, "xft::lang=ar" },
73 { CS_ISO8859_7, "xft::lang=el" }, 73 { CS_ISO8859_7, "xft::lang=el" },
74 { CS_ISO8859_8, "xft::lang=he" }, 74 { CS_ISO8859_8, "xft::lang=he" },
75 { CS_ISO8859_9, "xft::lang=tr" }, 75 { CS_ISO8859_9, "xft::lang=tr" },
231void 231void
232rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const 232rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const
233{ 233{
234 dTermDisplay; 234 dTermDisplay;
235 dTermGC; 235 dTermGC;
236 236
237 if (color == Color_bg || color == Color_transparent) 237 if (color == Color_bg || color == Color_transparent)
238 XClearArea (disp, d, x, y, w, h, false); 238 XClearArea (disp, d, x, y, w, h, false);
239 else if (color >= 0) 239 else if (color >= 0)
240 { 240 {
241#if XFT 241#if XFT
242 bool done = false;
243#ifdef HAVE_BG_PIXMAP
244 if (term->bgPixmap.pixmap && color >= 0 && term->pix_colors[color].c.color.alpha < 0x0ff00)
245 {
246 Picture dst = XftDrawPicture (d);
247 if (dst != 0)
248 {
249 XClearArea (disp, d, x, y, w, h, false);
250 Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c);
251 XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, x, y, w, h);
252 done = true;
253 }
254 }
255#endif
256 if (!done)
242 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); 257 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h);
243#else 258#else
244 XSetForeground (disp, gc, term->pix_colors[color]); 259 XSetForeground (disp, gc, term->pix_colors[color]);
245 XFillRectangle (disp, d, gc, x, y, w, h); 260 XFillRectangle (disp, d, gc, x, y, w, h);
246#endif 261#endif
247 } 262 }
248} 263}
249 264
250///////////////////////////////////////////////////////////////////////////// 265/////////////////////////////////////////////////////////////////////////////
251
252#include "table/linedraw.h"
253 266
254struct rxvt_font_default : rxvt_font { 267struct rxvt_font_default : rxvt_font {
255 struct rxvt_fontset *fs; 268 struct rxvt_fontset *fs;
256 269
257 rxvt_font_default (rxvt_fontset *fs) 270 rxvt_font_default (rxvt_fontset *fs)
341 ; 354 ;
342 355
343 int width = text - tp; 356 int width = text - tp;
344 int fwidth = term->fwidth * width; 357 int fwidth = term->fwidth * width;
345 358
359#ifdef BUILTIN_GLYPHS
346 if (0x2500 <= t && t <= 0x259f) 360 if (0x2500 <= t && t <= 0x259f)
347 { 361 {
362# include "table/linedraw.h"
348 uint16_t offs = linedraw_offs[t - 0x2500]; 363 uint16_t offs = linedraw_offs[t - 0x2500];
349 uint32_t *a = linedraw_command + (offs >> 4); 364 uint32_t *a = linedraw_command + (offs >> 4);
350 uint32_t *b = a + (offs & 15); 365 uint32_t *b = a + (offs & 15);
351 366
352 int W = fwidth; 367 int W = fwidth;
390 405
391 case 1: // rectangle, possibly stippled 406 case 1: // rectangle, possibly stippled
392 if (a) 407 if (a)
393 { 408 {
394 static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; 409 static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 };
395 410
396 gcv.fill_style = FillStippled; 411 gcv.fill_style = FillStippled;
397 gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2); 412 gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2);
398 gcv.ts_x_origin = x; 413 gcv.ts_x_origin = x;
399 gcv.ts_y_origin = y; 414 gcv.ts_y_origin = y;
400 415
419 (a - 1) * 90*64, (b - 1) * 90*64); 434 (a - 1) * 90*64, (b - 1) * 90*64);
420 break; 435 break;
421 } 436 }
422 } 437 }
423 } 438 }
439#else
440 if (0)
441 ;
442#endif
424#if ENABLE_COMBINING 443#if ENABLE_COMBINING
425 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) 444 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t]))
426 { 445 {
427 min_it (width, 2); // we only support wcwidth up to 2 446 min_it (width, 2); // we only support wcwidth up to 2
428 447
497 unsigned long value; 516 unsigned long value;
498 517
499 if (XGetFontProperty (f, property, &value)) 518 if (XGetFontProperty (f, property, &value))
500 return XGetAtomName (term->dpy, value); 519 return XGetAtomName (term->dpy, value);
501 else 520 else
502 return rxvt_strdup (repl); 521 return repl ? strdup (repl) : 0;
503} 522}
504 523
505rxvt_fontprop 524rxvt_fontprop
506rxvt_font_x11::properties () 525rxvt_font_x11::properties ()
507{ 526{
659 f = 0; 678 f = 0;
660 } 679 }
661 680
662 if (prop.weight != rxvt_fontprop::unset) 681 if (prop.weight != rxvt_fontprop::unset)
663 { 682 {
664 replace_field (fname, name, 2, 0, 683 replace_field (fname, name, 2, 0,
665 prop.weight < rxvt_fontprop::bold 684 prop.weight < rxvt_fontprop::bold
666 ? "medium" : "bold"); 685 ? "medium" : "bold");
667 set_name (strdup (fname)); 686 set_name (strdup (fname));
668 } 687 }
669 688
813 int N = f->max_char_or_byte2 - f->min_char_or_byte2; 832 int N = f->max_char_or_byte2 - f->min_char_or_byte2;
814 833
815 if (encm) 834 if (encm)
816 N += (f->max_byte1 - f->min_byte1) 835 N += (f->max_byte1 - f->min_byte1)
817 * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1); 836 * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1);
818 837
819 while (N) 838 while (N)
820 { 839 {
821 if (f->per_char[N].width > width) 840 if (f->per_char[N].width > width)
822 width = f->per_char[N].width; 841 width = f->per_char[N].width;
823 842
975 else 994 else
976 { 995 {
977 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); 996 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
978 997
979 XChangeGC (disp, gc, GCForeground | GCFont, &v); 998 XChangeGC (disp, gc, GCForeground | GCFont, &v);
980 999
981 if (slow) 1000 if (slow)
982 { 1001 {
983 do 1002 do
984 { 1003 {
985 if (xc->byte1 || xc->byte2) 1004 if (xc->byte1 || xc->byte2)
1007 else 1026 else
1008 { 1027 {
1009 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); 1028 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
1010 1029
1011 XChangeGC (disp, gc, GCForeground | GCFont, &v); 1030 XChangeGC (disp, gc, GCForeground | GCFont, &v);
1012 1031
1013 if (slow) 1032 if (slow)
1014 { 1033 {
1015 do 1034 do
1016 { 1035 {
1017 if (*xc) 1036 if (*xc)
1043 1062
1044 void draw (rxvt_drawable &d, int x, int y, 1063 void draw (rxvt_drawable &d, int x, int y,
1045 const text_t *text, int len, 1064 const text_t *text, int len,
1046 int fg, int bg); 1065 int fg, int bg);
1047 1066
1048 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &carefull) const; 1067 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const;
1049 1068
1050protected: 1069protected:
1051 XftFont *f; 1070 XftFont *f;
1052}; 1071};
1053 1072
1273 1292
1274 int w = term->fwidth * len; 1293 int w = term->fwidth * len;
1275 int h = term->fheight; 1294 int h = term->fheight;
1276 1295
1277 /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency. 1296 /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency.
1278 * Maybe make buffering into a resource flag? Compile time option doesn't seems like a 1297 * Maybe make buffering into a resource flag? Compile time option doesn't seems like a
1279 * good idea from the perspective of packaging for wide variety of user configs. 1298 * good idea from the perspective of packaging for wide variety of user configs.
1280 */ 1299 */
1281 bool buffered = true 1300 bool buffered = true
1282#ifdef FORCE_UNBUFFERED_XFT 1301#ifdef FORCE_UNBUFFERED_XFT
1283 && bg >= 0 1302 && bg >= 0
1295 int cwidth = term->fwidth; 1314 int cwidth = term->fwidth;
1296 FcChar32 fc = *text++; len--; 1315 FcChar32 fc = *text++; len--;
1297 1316
1298 while (len && *text == NOCHAR) 1317 while (len && *text == NOCHAR)
1299 text++, len--, cwidth += term->fwidth; 1318 text++, len--, cwidth += term->fwidth;
1300 1319
1301 if (fc != ' ') // skip spaces 1320 if (fc != ' ') // skip spaces
1302 { 1321 {
1303 FT_UInt glyph = XftCharIndex (disp, f, fc); 1322 FT_UInt glyph = XftCharIndex (disp, f, fc);
1304 XftGlyphExtents (disp, f, &glyph, 1, &extents); 1323 XftGlyphExtents (disp, f, &glyph, 1, &extents);
1305 1324
1316 x_ += cwidth; 1335 x_ += cwidth;
1317 } 1336 }
1318 1337
1319 if (buffered) 1338 if (buffered)
1320 { 1339 {
1340 bool back_rendered = false;
1321 if (ep != enc) 1341 if (ep != enc)
1322 { 1342 {
1323 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1343 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1324 bool back_rendered = false;
1325 1344
1326#ifdef HAVE_BG_PIXMAP 1345#ifdef HAVE_BG_PIXMAP
1327 if (term->bgPixmap.pixmap) 1346 if (term->bgPixmap.pixmap)
1328 { 1347 {
1329 Picture dst = 0; 1348 Picture dst = 0;
1349
1330 if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00) 1350 if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00)
1331 dst = XftDrawPicture (d2); 1351 dst = XftDrawPicture (d2);
1332 1352
1333 if (bg < 0 || dst != 0) 1353 if (bg < 0 || dst != 0)
1334 { 1354 {
1355 int src_x = x, src_y = y ;
1356
1357 if (term->bgPixmap.is_parentOrigin ())
1358 {
1359 src_x += term->window_vt_x;
1360 src_y += term->window_vt_y;
1361 }
1362
1335 if (term->bgPixmap.pmap_width >= x + term->window_vt_x+w 1363 if (term->bgPixmap.pmap_width >= src_x+w
1336 && term->bgPixmap.pmap_height >= y + term->window_vt_y+h) 1364 && term->bgPixmap.pmap_height >= src_y+h)
1337 { 1365 {
1338 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, 1366 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc,
1339 x + term->window_vt_x, y + term->window_vt_y,
1340 w, h, 0, 0); 1367 src_x, src_y, w, h, 0, 0);
1341 } 1368 }
1342 else 1369 else
1343 { 1370 {
1344 XGCValues gcv; 1371 XGCValues gcv;
1345 1372
1346 gcv.fill_style = FillTiled; 1373 gcv.fill_style = FillTiled;
1347 gcv.tile = term->bgPixmap.pixmap; 1374 gcv.tile = term->bgPixmap.pixmap;
1348 gcv.ts_x_origin = -x; 1375 gcv.ts_x_origin = -src_x;
1349 gcv.ts_y_origin = -y; 1376 gcv.ts_y_origin = -src_y;
1350 1377
1351 XChangeGC (disp, gc, 1378 XChangeGC (disp, gc,
1352 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1379 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1353 &gcv); 1380 &gcv);
1354 1381
1422 1449
1423rxvt_font * 1450rxvt_font *
1424rxvt_fontset::new_font (const char *name, codeset cs) 1451rxvt_fontset::new_font (const char *name, codeset cs)
1425{ 1452{
1426 rxvt_font *f; 1453 rxvt_font *f;
1427 1454
1428 if (!name || !*name) 1455 if (!name || !*name)
1429 { 1456 {
1430 name = ""; 1457 name = "";
1431 f = new rxvt_font_default (this); 1458 f = new rxvt_font_default (this);
1432 } 1459 }
1651 if (find_font (font) < 0) 1678 if (find_font (font) < 0)
1652 { 1679 {
1653 char fontname[4096]; 1680 char fontname[4096];
1654 sprintf (fontname, "xft:%-.4090s", font); 1681 sprintf (fontname, "xft:%-.4090s", font);
1655 1682
1656 fonts.push_back (new_font (fontname, CS_UNICODE)); 1683 fonts.push_back (new_font (fontname, CS_UNICODE));
1657 } 1684 }
1658 1685
1659 free (font); 1686 free (font);
1660 } 1687 }
1661#endif 1688#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines