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.101 by root, Sat Mar 11 00:33:23 2006 UTC vs.
Revision 1.109 by sasha, Fri Aug 3 05:33:04 2007 UTC

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 < 0 || color == Color_bg) 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 239 else if (color >= 0)
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"));
441 *chrs = cc->c2; 441 *chrs = cc->c2;
442 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) 442 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful)
443 ? f1 443 ? f1
444 : (*fs)[fs->find_font (cc->c2)]; 444 : (*fs)[fs->find_font (cc->c2)];
445 445
446 f2->draw (d, x, y, chrs, width, fg, -1); 446 f2->draw (d, x, y, chrs, width, fg, Color_none);
447 } 447 }
448 } 448 }
449#endif 449#endif
450 else 450 else
451 switch (t) 451 switch (t)
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,
482 int fg, int bg); 482 int fg, int bg);
483 483
484 bool slow; // wether this is a proportional font or has other funny characteristics 484 bool slow; // wether this is a proportional font or has other funny characteristics
485 XFontStruct *f; 485 XFontStruct *f;
486 codeset cs;
487 bool enc2b, encm; 486 bool enc2b, encm;
488 487
489 char *get_property (XFontStruct *f, Atom property, const char *repl) const; 488 char *get_property (XFontStruct *f, Atom property, const char *repl) const;
490 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); 489 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth);
491 bool set_properties (rxvt_fontprop &p, XFontStruct *f); 490 bool set_properties (rxvt_fontprop &p, XFontStruct *f);
627 return false; 626 return false;
628 } 627 }
629} 628}
630 629
631bool 630bool
632rxvt_font_x11::load (const rxvt_fontprop &prop) 631rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop)
633{ 632{
634 dTermDisplay; 633 dTermDisplay;
635 634
636 clear (); 635 clear ();
637 636
638 char field_str[64]; // enough for 128 bits 637 char field_str[64]; // enough for 128 bits
639 638
640 // first morph the font if required 639 // first morph the font if required
641 if (prop.weight != rxvt_fontprop::unset 640 if (force_prop)
642 || prop.slant != rxvt_fontprop::unset)
643 { 641 {
644 char fname[1024]; 642 char fname[1024];
645 643
646 if (name[0] != '-') 644 if (name[0] != '-')
647 { 645 {
1039 1037
1040 void clear (); 1038 void clear ();
1041 1039
1042 rxvt_fontprop properties (); 1040 rxvt_fontprop properties ();
1043 1041
1044 bool load (const rxvt_fontprop &prop); 1042 bool load (const rxvt_fontprop &prop, bool force_prop);
1045 1043
1046 void draw (rxvt_drawable &d, int x, int y, 1044 void draw (rxvt_drawable &d, int x, int y,
1047 const text_t *text, int len, 1045 const text_t *text, int len,
1048 int fg, int bg); 1046 int fg, int bg);
1049 1047
1082 1080
1083 return p; 1081 return p;
1084} 1082}
1085 1083
1086bool 1084bool
1087rxvt_font_xft::load (const rxvt_fontprop &prop) 1085rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop)
1088{ 1086{
1089 dTermDisplay; 1087 dTermDisplay;
1090 1088
1091 clear (); 1089 clear ();
1092 1090
1101 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch 1099 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch
1102 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) 1100 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch))
1103 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); 1101 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height);
1104 1102
1105 if (prop.weight != rxvt_fontprop::unset 1103 if (prop.weight != rxvt_fontprop::unset
1106 && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) 1104 && (force_prop || FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch))
1107 FcPatternAddInteger (p, FC_WEIGHT, prop.weight); 1105 FcPatternAddInteger (p, FC_WEIGHT, prop.weight);
1108 1106
1109 if (prop.slant != rxvt_fontprop::unset 1107 if (prop.slant != rxvt_fontprop::unset
1110 && FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) 1108 && (force_prop || FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch))
1111 FcPatternAddInteger (p, FC_SLANT, prop.slant); 1109 FcPatternAddInteger (p, FC_SLANT, prop.slant);
1112 1110
1113#if 0 // clipping unfortunately destroys our precious double-width-characters 1111#if 0 // clipping unfortunately destroys our precious double-width-characters
1114 // clip width, we can't do better, or can we? 1112 // clip width, we can't do better, or can we?
1115 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) 1113 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch)
1276 int w = term->fwidth * len; 1274 int w = term->fwidth * len;
1277 int h = term->fheight; 1275 int h = term->fheight;
1278 1276
1279 bool buffered = bg >= 0 // we don't use a transparent bg 1277 bool buffered = bg >= 0 // we don't use a transparent bg
1280#ifndef FORCE_UNBUFFERED_XFT 1278#ifndef FORCE_UNBUFFERED_XFT
1281# if defined(XPM_BACKGROUND) || defined(TRANSPARENT) 1279# ifdef ENABLE_TRANSPARENCY
1282 || !term->am_transparent // we aren't transparent 1280 || !term->am_transparent // we aren't transparent
1283 || term->am_pixmap_trans // we have a pixmap
1284# endif 1281# endif
1285#endif 1282#endif
1286 ; 1283 ;
1287 1284
1288 // cut trailing spaces 1285 // cut trailing spaces
1322 { 1319 {
1323 if (ep != enc) 1320 if (ep != enc)
1324 { 1321 {
1325 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1322 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1326 1323
1327#if defined(XPM_BACKGROUND) || defined(TRANSPARENT) 1324 if (0)
1328 if (bg < 0 && term->am_pixmap_trans) 1325 ;
1329 XCopyArea (disp, term->pixmap, d2, gc, 1326#if defined(ENABLE_TRANSPARENCY) || defined(XPM_BACKGROUND)
1330 x + term->window_vt_x, y + term->window_vt_y,
1331 w, h, 0, 0);
1332 else if (bg < 0 && term->bgPixmap.pixmap) 1327 else if (bg < 0 && term->bgPixmap.pixmap)
1333 { 1328 {
1329 if (term->bgPixmap.pmap_width >= x + term->window_vt_x+w
1330 && term->bgPixmap.pmap_height >= y + term->window_vt_y+h)
1331 {
1332 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc,
1333 x + term->window_vt_x, y + term->window_vt_y,
1334 w, h, 0, 0);
1335 }
1336 else
1337 {
1334 XGCValues gcv; 1338 XGCValues gcv;
1335 1339
1336 gcv.fill_style = FillTiled; 1340 gcv.fill_style = FillTiled;
1337 gcv.tile = term->pixmap; 1341 gcv.tile = term->bgPixmap.pixmap;
1338 gcv.ts_x_origin = -x; 1342 gcv.ts_x_origin = -x;
1339 gcv.ts_y_origin = -y; 1343 gcv.ts_y_origin = -y;
1340 1344
1345#if 0
1341 GC gc2 = XCreateGC (disp, d2, 1346 GC gc2 = XCreateGC (disp, d2,
1342 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1347 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1343 &gcv); 1348 &gcv);
1349#endif
1350 XChangeGC (disp, gc,
1351 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1352 &gcv);
1344 1353
1345 XFillRectangle (disp, d2, gc2, 0, 0, w, h); 1354 XFillRectangle (disp, d2, gc/*gc2*/, 0, 0, w, h);
1346 1355
1356 gcv.fill_style = FillSolid;
1357 XChangeGC (disp, gc, GCFillStyle, &gcv);
1347 XFreeGC (disp, gc2); 1358 /* XFreeGC (disp, gc2); */
1359
1360 }
1348 } 1361 }
1362#endif
1349 else 1363 else
1350#endif
1351 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); 1364 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h);
1352 1365
1353 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); 1366 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
1354 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); 1367 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
1355 } 1368 }
1381void 1394void
1382rxvt_fontset::clear () 1395rxvt_fontset::clear ()
1383{ 1396{
1384 prop.width = prop.height = prop.ascent = prop.weight = prop.slant 1397 prop.width = prop.height = prop.ascent = prop.weight = prop.slant
1385 = rxvt_fontprop::unset; 1398 = rxvt_fontprop::unset;
1399 force_prop = false;
1386 1400
1387 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) 1401 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
1388 FONT_UNREF (*i); 1402 FONT_UNREF (*i);
1389 1403
1390 for (pagemap **p = fmap.begin (); p != fmap.end (); p++) 1404 for (pagemap **p = fmap.begin (); p != fmap.end (); p++)
1502 if (fonts[i]->loaded) 1516 if (fonts[i]->loaded)
1503 return true; 1517 return true;
1504 1518
1505 fonts[i]->loaded = true; 1519 fonts[i]->loaded = true;
1506 1520
1507 if (!fonts[i]->load (prop)) 1521 if (!fonts[i]->load (prop, force_prop))
1508 { 1522 {
1509 fonts[i]->cs = CS_UNKNOWN; 1523 fonts[i]->cs = CS_UNKNOWN;
1510 return false; 1524 return false;
1511 } 1525 }
1512 1526

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines