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.95 by root, Sat Feb 18 14:14:43 2006 UTC vs.
Revision 1.103 by root, Sun Aug 27 10:10:25 2006 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvtfont.C 2 * File: rxvtfont.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> 4 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com>
5 * - original version. 5 * - original version.
6 * 6 *
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) 237 if (color < 0 || color == Color_bg)
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
240 { 240 {
241#if XFT 241#if XFT
242 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); 242 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h);
243#else 243#else
244 XSetForeground (disp, gc, term->pix_colors[color]); 244 XSetForeground (disp, gc, term->pix_colors[color]);
270 p.slant = rxvt_fontprop::roman; 270 p.slant = rxvt_fontprop::roman;
271 271
272 return p; 272 return p;
273 } 273 }
274 274
275 bool load (const rxvt_fontprop &prop) 275 bool load (const rxvt_fontprop &prop, bool force_prop)
276 { 276 {
277 width = 1; height = 1; 277 width = 1; height = 1;
278 ascent = 1; descent = 0; 278 ascent = 1; descent = 0;
279 279
280 set_name (strdup ("built-in support font")); 280 set_name (strdup ("built-in support font"));
471 471
472 void clear (); 472 void clear ();
473 473
474 rxvt_fontprop properties (); 474 rxvt_fontprop properties ();
475 475
476 bool load (const rxvt_fontprop &prop); 476 bool load (const rxvt_fontprop &prop, bool force_prop);
477 477
478 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const; 478 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const;
479 479
480 void draw (rxvt_drawable &d, int x, int y, 480 void draw (rxvt_drawable &d, int x, int y,
481 const text_t *text, int len, 481 const text_t *text, int len,
627 return false; 627 return false;
628 } 628 }
629} 629}
630 630
631bool 631bool
632rxvt_font_x11::load (const rxvt_fontprop &prop) 632rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop)
633{ 633{
634 dTermDisplay; 634 dTermDisplay;
635 635
636 clear (); 636 clear ();
637 637
638 char field_str[64]; // enough for 128 bits 638 char field_str[64]; // enough for 128 bits
639 639
640 // first morph the font if required 640 // first morph the font if required
641 if (prop.weight != rxvt_fontprop::unset 641 if (force_prop)
642 || prop.slant != rxvt_fontprop::unset)
643 { 642 {
644 char fname[1024]; 643 char fname[1024];
645 644
646 if (name[0] != '-') 645 if (name[0] != '-')
647 { 646 {
1039 1038
1040 void clear (); 1039 void clear ();
1041 1040
1042 rxvt_fontprop properties (); 1041 rxvt_fontprop properties ();
1043 1042
1044 bool load (const rxvt_fontprop &prop); 1043 bool load (const rxvt_fontprop &prop, bool force_prop);
1045 1044
1046 void draw (rxvt_drawable &d, int x, int y, 1045 void draw (rxvt_drawable &d, int x, int y,
1047 const text_t *text, int len, 1046 const text_t *text, int len,
1048 int fg, int bg); 1047 int fg, int bg);
1049 1048
1082 1081
1083 return p; 1082 return p;
1084} 1083}
1085 1084
1086bool 1085bool
1087rxvt_font_xft::load (const rxvt_fontprop &prop) 1086rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop)
1088{ 1087{
1089 dTermDisplay; 1088 dTermDisplay;
1090 1089
1091 clear (); 1090 clear ();
1092 1091
1101 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch 1100 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch
1102 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) 1101 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch))
1103 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); 1102 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height);
1104 1103
1105 if (prop.weight != rxvt_fontprop::unset 1104 if (prop.weight != rxvt_fontprop::unset
1106 && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) 1105 && (force_prop || FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch))
1107 FcPatternAddInteger (p, FC_WEIGHT, prop.weight); 1106 FcPatternAddInteger (p, FC_WEIGHT, prop.weight);
1108 1107
1109 if (prop.slant != rxvt_fontprop::unset 1108 if (prop.slant != rxvt_fontprop::unset
1110 && FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) 1109 && (force_prop || FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch))
1111 FcPatternAddInteger (p, FC_SLANT, prop.slant); 1110 FcPatternAddInteger (p, FC_SLANT, prop.slant);
1112 1111
1113#if 0 // clipping unfortunately destroys our precious double-width-characters 1112#if 0 // clipping unfortunately destroys our precious double-width-characters
1114 // clip width, we can't do better, or can we? 1113 // clip width, we can't do better, or can we?
1115 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) 1114 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch)
1274 dTermGC; 1273 dTermGC;
1275 1274
1276 int w = term->fwidth * len; 1275 int w = term->fwidth * len;
1277 int h = term->fheight; 1276 int h = term->fheight;
1278 1277
1279 bool buffered = false; 1278 bool buffered = bg >= 0 // we don't use a transparent bg
1279#ifndef FORCE_UNBUFFERED_XFT
1280# if defined(XPM_BACKGROUND) || defined(TRANSPARENT)
1281 || !term->am_transparent // we aren't transparent
1282 || term->am_pixmap_trans // we have a pixmap
1283# endif
1284#endif
1285 ;
1280 1286
1281 // cut trailing spaces 1287 // cut trailing spaces
1282 while (len && text [len - 1] == ' ') 1288 while (len && text [len - 1] == ' ')
1283 len--; 1289 len--;
1284 1290
1315 { 1321 {
1316 if (ep != enc) 1322 if (ep != enc)
1317 { 1323 {
1318 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1324 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1319 1325
1326 if (0)
1327 ;
1328#ifdef TRANSPARENT
1329 else if (bg < 0 && term->am_pixmap_trans)
1330 XCopyArea (disp, term->pixmap, d2, gc,
1331 x + term->window_vt_x, y + term->window_vt_y,
1332 w, h, 0, 0);
1333#endif
1334#ifdef XPM_BACKGROUND
1335 else if (bg < 0 && term->bgPixmap.pixmap)
1336 {
1337 XGCValues gcv;
1338
1339 gcv.fill_style = FillTiled;
1340 gcv.tile = term->pixmap;
1341 gcv.ts_x_origin = -x;
1342 gcv.ts_y_origin = -y;
1343
1344 GC gc2 = XCreateGC (disp, d2,
1345 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1346 &gcv);
1347
1348 XFillRectangle (disp, d2, gc2, 0, 0, w, h);
1349
1350 XFreeGC (disp, gc2);
1351 }
1352#endif
1353 else
1320 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); 1354 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h);
1321 1355
1322 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); 1356 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
1323 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); 1357 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
1324 } 1358 }
1325 else 1359 else
1350void 1384void
1351rxvt_fontset::clear () 1385rxvt_fontset::clear ()
1352{ 1386{
1353 prop.width = prop.height = prop.ascent = prop.weight = prop.slant 1387 prop.width = prop.height = prop.ascent = prop.weight = prop.slant
1354 = rxvt_fontprop::unset; 1388 = rxvt_fontprop::unset;
1389 force_prop = false;
1355 1390
1356 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) 1391 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
1357 FONT_UNREF (*i); 1392 FONT_UNREF (*i);
1358 1393
1359 for (pagemap **p = fmap.begin (); p != fmap.end (); p++) 1394 for (pagemap **p = fmap.begin (); p != fmap.end (); p++)
1471 if (fonts[i]->loaded) 1506 if (fonts[i]->loaded)
1472 return true; 1507 return true;
1473 1508
1474 fonts[i]->loaded = true; 1509 fonts[i]->loaded = true;
1475 1510
1476 if (!fonts[i]->load (prop)) 1511 if (!fonts[i]->load (prop, force_prop))
1477 { 1512 {
1478 fonts[i]->cs = CS_UNKNOWN; 1513 fonts[i]->cs = CS_UNKNOWN;
1479 return false; 1514 return false;
1480 } 1515 }
1481 1516

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines