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.91 by root, Mon Jan 30 04:27:17 2006 UTC vs.
Revision 1.120 by ayin, Mon Oct 22 07:36:51 2007 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 *
129 { CS_KSC5601_1987_0, "xft:Baekmuk Gulim:antialias=false" }, 129 { CS_KSC5601_1987_0, "xft:Baekmuk Gulim:antialias=false" },
130 { CS_KSC5601_1987_0, "xft::lang=ko:antialias=false" }, 130 { CS_KSC5601_1987_0, "xft::lang=ko:antialias=false" },
131# endif 131# endif
132#endif 132#endif
133 133
134 // generic font fallback
135 { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, 134 { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" },
136 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, 135 //{ CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, // this gem of a font has actual dotted circles within the combining character glyphs.
137 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" },
138 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
139#if XFT 136#if XFT
140 { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true" }, 137 { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true" },
141 { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" }, 138 { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" },
142 { CS_UNICODE, "xft:Andale Mono:antialias=false:autohint=false" }, 139 { CS_UNICODE, "xft:Andale Mono:antialias=false:autohint=false" },
143 { CS_UNICODE, "xft:Arial Unicode MS:antialias=false:autohint=false" }, 140 { CS_UNICODE, "xft:Arial Unicode MS:antialias=false:autohint=false" },
144 141
145 // FreeMono is usually uglier than x fonts, so try last only. 142 // FreeMono is usually uglier than x fonts, so try after the others
146 { CS_UNICODE, "xft:FreeMono:autohint=true" }, 143 { CS_UNICODE, "xft:FreeMono:autohint=true" },
147#endif 144#endif
148 145
146 // generic font fallback, put this last, as many iso10646 fonts have extents
147 // specified for all glyphs in the range they cover, but most are simply empty
148 //{ CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" },
149 //{ CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
149 { CS_UNKNOWN, 0 } 150 { CS_UNKNOWN, 0 }
150}; 151};
151 152
152// these characters are used to guess the font height and width 153// these characters are used to guess the font height and width
153// pango uses a similar algorithm and doesn't trust the font either. 154// pango uses a similar algorithm and doesn't trust the font either.
157 0x304c, 0x672c, // が本 158 0x304c, 0x672c, // が本
158}; 159};
159 160
160#define NUM_EXTENT_TEST_CHARS (sizeof (extent_test_chars) / sizeof (extent_test_chars[0])) 161#define NUM_EXTENT_TEST_CHARS (sizeof (extent_test_chars) / sizeof (extent_test_chars[0]))
161 162
162#define dTermDisplay Display *disp = term->xdisp 163#define dTermDisplay Display *disp = term->dpy
163#define dTermGC GC gc = term->gc 164#define dTermGC GC gc = term->gc
164
165/////////////////////////////////////////////////////////////////////////////
166
167#if XFT
168rxvt_drawable::~rxvt_drawable ()
169{
170 if (xftdrawable)
171 XftDrawDestroy (xftdrawable);
172}
173
174rxvt_drawable::operator XftDraw *()
175{
176 if (!xftdrawable)
177 xftdrawable = XftDrawCreate (screen->xdisp, drawable, screen->visual, screen->cmap);
178
179 return xftdrawable;
180}
181#endif
182 165
183///////////////////////////////////////////////////////////////////////////// 166/////////////////////////////////////////////////////////////////////////////
184 167
185static const char * 168static const char *
186enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) 169enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero)
249rxvt_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
250{ 233{
251 dTermDisplay; 234 dTermDisplay;
252 dTermGC; 235 dTermGC;
253 236
254 if (color == Color_bg) 237 if (color == Color_bg || color == Color_transparent)
255 XClearArea (disp, d, x, y, w, h, false); 238 XClearArea (disp, d, x, y, w, h, false);
256 else if (color >= 0) 239 else if (color >= 0)
257 { 240 {
258#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)
259 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); 257 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h);
260#else 258#else
261 XSetForeground (disp, gc, term->pix_colors[color]); 259 XSetForeground (disp, gc, term->pix_colors[color]);
262 XFillRectangle (disp, d, gc, x, y, w, h); 260 XFillRectangle (disp, d, gc, x, y, w, h);
263#endif 261#endif
264 } 262 }
287 p.slant = rxvt_fontprop::roman; 285 p.slant = rxvt_fontprop::roman;
288 286
289 return p; 287 return p;
290 } 288 }
291 289
292 bool load (const rxvt_fontprop &prop) 290 bool load (const rxvt_fontprop &prop, bool force_prop)
293 { 291 {
294 width = 1; height = 1; 292 width = 1; height = 1;
295 ascent = 1; descent = 0; 293 ascent = 1; descent = 0;
296 294
297 set_name (strdup ("built-in support font")); 295 set_name (strdup ("built-in support font"));
458 *chrs = cc->c2; 456 *chrs = cc->c2;
459 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) 457 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful)
460 ? f1 458 ? f1
461 : (*fs)[fs->find_font (cc->c2)]; 459 : (*fs)[fs->find_font (cc->c2)];
462 460
463 f2->draw (d, x, y, chrs, width, fg, -1); 461 f2->draw (d, x, y, chrs, width, fg, Color_none);
464 } 462 }
465 } 463 }
466#endif 464#endif
467 else 465 else
468 switch (t) 466 switch (t)
488 486
489 void clear (); 487 void clear ();
490 488
491 rxvt_fontprop properties (); 489 rxvt_fontprop properties ();
492 490
493 bool load (const rxvt_fontprop &prop); 491 bool load (const rxvt_fontprop &prop, bool force_prop);
494 492
495 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const; 493 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const;
496 494
497 void draw (rxvt_drawable &d, int x, int y, 495 void draw (rxvt_drawable &d, int x, int y,
498 const text_t *text, int len, 496 const text_t *text, int len,
499 int fg, int bg); 497 int fg, int bg);
500 498
501 bool slow; // wether this is a proportional font or has other funny characteristics 499 bool slow; // wether this is a proportional font or has other funny characteristics
502 XFontStruct *f; 500 XFontStruct *f;
503 codeset cs;
504 bool enc2b, encm; 501 bool enc2b, encm;
505 502
506 char *get_property (XFontStruct *f, Atom property, const char *repl) const; 503 char *get_property (XFontStruct *f, Atom property, const char *repl) const;
507 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); 504 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth);
508 bool set_properties (rxvt_fontprop &p, XFontStruct *f); 505 bool set_properties (rxvt_fontprop &p, XFontStruct *f);
513rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const 510rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const
514{ 511{
515 unsigned long value; 512 unsigned long value;
516 513
517 if (XGetFontProperty (f, property, &value)) 514 if (XGetFontProperty (f, property, &value))
518 return XGetAtomName (term->xdisp, value); 515 return XGetAtomName (term->dpy, value);
519 else 516 else
520 return rxvt_strdup (repl); 517 return rxvt_strdup (repl);
521} 518}
522 519
523rxvt_fontprop 520rxvt_fontprop
546rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) 543rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f)
547{ 544{
548 unsigned long height; 545 unsigned long height;
549 546
550#if 0 547#if 0
551 if (!XGetFontProperty (f, XInternAtom (term->xdisp, "PIXEL_SIZE", 0), &height)) 548 if (!XGetFontProperty (f, XInternAtom (term->dpy, "PIXEL_SIZE", 0), &height))
552 return false; 549 return false;
553#else 550#else
554 height = f->ascent + f->descent; 551 height = f->ascent + f->descent;
555#endif 552#endif
556 553
644 return false; 641 return false;
645 } 642 }
646} 643}
647 644
648bool 645bool
649rxvt_font_x11::load (const rxvt_fontprop &prop) 646rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop)
650{ 647{
651 dTermDisplay; 648 dTermDisplay;
652 649
653 clear (); 650 clear ();
654 651
655 char field_str[64]; // enough for 128 bits 652 char field_str[64]; // enough for 128 bits
656 653
657 // first morph the font if required 654 // first morph the font if required
658 if (prop.weight != rxvt_fontprop::unset 655 if (force_prop)
659 || prop.slant != rxvt_fontprop::unset)
660 { 656 {
661 char fname[1024]; 657 char fname[1024];
662 658
663 if (name[0] != '-') 659 if (name[0] != '-')
664 { 660 {
861 857
862 XCharStruct g; 858 XCharStruct g;
863 int dir_ret, asc_ret, des_ret; 859 int dir_ret, asc_ret, des_ret;
864 XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); 860 XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g);
865 861
862 int wcw = WCWIDTH (*t);
866 int wcw = WCWIDTH (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; 863 if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;
867 864
868 if (width < g.width) width = g.width; 865 if (width < g.width) width = g.width;
869 } 866 }
870 867
871 if (cs == CS_UNKNOWN) 868 if (cs == CS_UNKNOWN)
890void 887void
891rxvt_font_x11::clear () 888rxvt_font_x11::clear ()
892{ 889{
893 if (f) 890 if (f)
894 { 891 {
895 XFreeFont (term->xdisp, f); 892 XFreeFont (term->dpy, f);
896 f = 0; 893 f = 0;
897 } 894 }
898} 895}
899 896
900bool 897bool
945 if (!prop || prop->width == rxvt_fontprop::unset) 942 if (!prop || prop->width == rxvt_fontprop::unset)
946 return true; 943 return true;
947 944
948 // check wether character overlaps previous/next character 945 // check wether character overlaps previous/next character
949 int w = xcs->rbearing - xcs->lbearing; 946 int w = xcs->rbearing - xcs->lbearing;
950 int wcw = WCWIDTH (unicode); 947 int wcw = max (WCWIDTH (unicode), 1);
951 948
952 careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; 949 careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw;
953 950
954 if (careful && !OVERLAP_OK (w, wcw, prop)) 951 if (careful && !OVERLAP_OK (w, wcw, prop))
955 return false; 952 return false;
1055 1052
1056 void clear (); 1053 void clear ();
1057 1054
1058 rxvt_fontprop properties (); 1055 rxvt_fontprop properties ();
1059 1056
1060 bool load (const rxvt_fontprop &prop); 1057 bool load (const rxvt_fontprop &prop, bool force_prop);
1061 1058
1062 void draw (rxvt_drawable &d, int x, int y, 1059 void draw (rxvt_drawable &d, int x, int y,
1063 const text_t *text, int len, 1060 const text_t *text, int len,
1064 int fg, int bg); 1061 int fg, int bg);
1065 1062
1066 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &carefull) const; 1063 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const;
1067 1064
1068protected: 1065protected:
1069 XftFont *f; 1066 XftFont *f;
1070}; 1067};
1071 1068
1072void 1069void
1073rxvt_font_xft::clear () 1070rxvt_font_xft::clear ()
1074{ 1071{
1075 if (f) 1072 if (f)
1076 { 1073 {
1077 XftFontClose (term->xdisp, f); 1074 XftFontClose (term->dpy, f);
1078 f = 0; 1075 f = 0;
1079 } 1076 }
1080} 1077}
1081 1078
1082rxvt_fontprop 1079rxvt_fontprop
1098 1095
1099 return p; 1096 return p;
1100} 1097}
1101 1098
1102bool 1099bool
1103rxvt_font_xft::load (const rxvt_fontprop &prop) 1100rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop)
1104{ 1101{
1105 dTermDisplay; 1102 dTermDisplay;
1106 1103
1107 clear (); 1104 clear ();
1108 1105
1117 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch 1114 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch
1118 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) 1115 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch))
1119 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); 1116 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height);
1120 1117
1121 if (prop.weight != rxvt_fontprop::unset 1118 if (prop.weight != rxvt_fontprop::unset
1122 && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) 1119 && (force_prop || FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch))
1123 FcPatternAddInteger (p, FC_WEIGHT, prop.weight); 1120 FcPatternAddInteger (p, FC_WEIGHT, prop.weight);
1124 1121
1125 if (prop.slant != rxvt_fontprop::unset 1122 if (prop.slant != rxvt_fontprop::unset
1126 && FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) 1123 && (force_prop || FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch))
1127 FcPatternAddInteger (p, FC_SLANT, prop.slant); 1124 FcPatternAddInteger (p, FC_SLANT, prop.slant);
1128 1125
1129#if 0 // clipping unfortunately destroys our precious double-width-characters 1126#if 0 // clipping unfortunately destroys our precious double-width-characters
1130 // clip width, we can't do better, or can we? 1127 // clip width, we can't do better, or can we?
1131 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) 1128 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch)
1249bool 1246bool
1250rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const 1247rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const
1251{ 1248{
1252 careful = false; 1249 careful = false;
1253 1250
1254 if (!XftCharExists (term->xdisp, f, unicode)) 1251 if (!XftCharExists (term->dpy, f, unicode))
1255 return false; 1252 return false;
1256 1253
1257 if (!prop || prop->width == rxvt_fontprop::unset) 1254 if (!prop || prop->width == rxvt_fontprop::unset)
1258 return true; 1255 return true;
1259 1256
1260 // check character against base font bounding box 1257 // check character against base font bounding box
1261 FcChar32 ch = unicode; 1258 FcChar32 ch = unicode;
1262 XGlyphInfo g; 1259 XGlyphInfo g;
1263 XftTextExtents32 (term->xdisp, f, &ch, 1, &g); 1260 XftTextExtents32 (term->dpy, f, &ch, 1, &g);
1264 1261
1265 int w = g.width - g.x; 1262 int w = g.width - g.x;
1266 int wcw = WCWIDTH (unicode); 1263 int wcw = max (WCWIDTH (unicode), 1);
1267 1264
1268 careful = g.x > 0 || w > prop->width * wcw; 1265 careful = g.x > 0 || w > prop->width * wcw;
1269 1266
1270 if (careful && !OVERLAP_OK (w, wcw, prop)) 1267 if (careful && !OVERLAP_OK (w, wcw, prop))
1271 return false; 1268 return false;
1280void 1277void
1281rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, 1278rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
1282 const text_t *text, int len, 1279 const text_t *text, int len,
1283 int fg, int bg) 1280 int fg, int bg)
1284{ 1281{
1285 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
1286
1287 XGlyphInfo extents; 1282 XGlyphInfo extents;
1288 XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); 1283 XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec));
1289 XftGlyphSpec *ep = enc; 1284 XftGlyphSpec *ep = enc;
1290 1285
1291 dTermDisplay; 1286 dTermDisplay;
1292 dTermGC; 1287 dTermGC;
1293 1288
1289 int w = term->fwidth * len;
1290 int h = term->fheight;
1291
1292 /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency.
1293 * Maybe make buffering into a resource flag? Compile time option doesn't seems like a
1294 * good idea from the perspective of packaging for wide variety of user configs.
1295 */
1296 bool buffered = true
1297#ifdef FORCE_UNBUFFERED_XFT
1298 && bg >= 0
1299#endif
1300 ;
1294 // cut trailing spaces 1301 // cut trailing spaces
1295 while (len && text [len - 1] == ' ') 1302 while (len && text [len - 1] == ' ')
1296 len--; 1303 len--;
1304
1305 int x_ = buffered ? 0 : x;
1306 int y_ = buffered ? 0 : y;
1297 1307
1298 while (len) 1308 while (len)
1299 { 1309 {
1300 int cwidth = term->fwidth; 1310 int cwidth = term->fwidth;
1301 FcChar32 fc = *text++; len--; 1311 FcChar32 fc = *text++; len--;
1306 if (fc != ' ') // skip spaces 1316 if (fc != ' ') // skip spaces
1307 { 1317 {
1308 FT_UInt glyph = XftCharIndex (disp, f, fc); 1318 FT_UInt glyph = XftCharIndex (disp, f, fc);
1309 XftGlyphExtents (disp, f, &glyph, 1, &extents); 1319 XftGlyphExtents (disp, f, &glyph, 1, &extents);
1310 1320
1311
1312 ep->glyph = glyph; 1321 ep->glyph = glyph;
1313 ep->x = x + (cwidth - extents.xOff >> 1); 1322 ep->x = x_ + (cwidth - extents.xOff >> 1);
1314 ep->y = y + ascent; 1323 ep->y = y_ + ascent;
1315 1324
1316 if (extents.xOff == 0) 1325 if (extents.xOff == 0)
1317 ep->x = x + cwidth; 1326 ep->x = x_ + cwidth;
1318 1327
1319 ep++; 1328 ep++;
1320 } 1329 }
1321 1330
1322 x += cwidth; 1331 x_ += cwidth;
1332 }
1333
1334 if (buffered)
1323 } 1335 {
1324 1336 bool back_rendered = false;
1325 if (ep != enc) 1337 if (ep != enc)
1338 {
1339 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1340
1341#ifdef HAVE_BG_PIXMAP
1342 if (term->bgPixmap.pixmap)
1343 {
1344 Picture dst = 0;
1345
1346 if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00)
1347 dst = XftDrawPicture (d2);
1348
1349 if (bg < 0 || dst != 0)
1350 {
1351 int src_x = x, src_y = y ;
1352
1353 if (term->bgPixmap.is_parentOrigin ())
1354 {
1355 src_x += term->window_vt_x;
1356 src_y += term->window_vt_y;
1357 }
1358
1359 if (term->bgPixmap.pmap_width >= src_x+w
1360 && term->bgPixmap.pmap_height >= src_y+h)
1361 {
1362 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc,
1363 src_x, src_y, w, h, 0, 0);
1364 }
1365 else
1366 {
1367 XGCValues gcv;
1368
1369 gcv.fill_style = FillTiled;
1370 gcv.tile = term->bgPixmap.pixmap;
1371 gcv.ts_x_origin = -src_x;
1372 gcv.ts_y_origin = -src_y;
1373
1374 XChangeGC (disp, gc,
1375 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1376 &gcv);
1377
1378 XFillRectangle (disp, d2, gc, 0, 0, w, h);
1379
1380 gcv.fill_style = FillSolid;
1381 XChangeGC (disp, gc, GCFillStyle, &gcv);
1382 }
1383
1384 if (bg >= 0)
1385 {
1386 Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c);
1387 XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h);
1388 }
1389
1390 back_rendered = true;
1391 }
1392 }
1393#endif
1394
1395 if (bg >= 0 && !back_rendered)
1396 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h);
1397
1398 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
1399 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
1400 }
1401 else
1402 clear_rect (d, x, y, w, h, bg);
1403 }
1404 else
1405 {
1406 clear_rect (d, x, y, w, h, bg);
1326 XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); 1407 XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc);
1408 }
1327} 1409}
1410
1328#endif 1411#endif
1329 1412
1330///////////////////////////////////////////////////////////////////////////// 1413/////////////////////////////////////////////////////////////////////////////
1331 1414
1332rxvt_fontset::rxvt_fontset (rxvt_term *term) 1415rxvt_fontset::rxvt_fontset (rxvt_term *term)
1343void 1426void
1344rxvt_fontset::clear () 1427rxvt_fontset::clear ()
1345{ 1428{
1346 prop.width = prop.height = prop.ascent = prop.weight = prop.slant 1429 prop.width = prop.height = prop.ascent = prop.weight = prop.slant
1347 = rxvt_fontprop::unset; 1430 = rxvt_fontprop::unset;
1431 force_prop = false;
1348 1432
1349 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) 1433 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
1350 FONT_UNREF (*i); 1434 FONT_UNREF (*i);
1351 1435
1352 for (pagemap **p = fmap.begin (); p != fmap.end (); p++) 1436 for (pagemap **p = fmap.begin (); p != fmap.end (); p++)
1464 if (fonts[i]->loaded) 1548 if (fonts[i]->loaded)
1465 return true; 1549 return true;
1466 1550
1467 fonts[i]->loaded = true; 1551 fonts[i]->loaded = true;
1468 1552
1469 if (!fonts[i]->load (prop)) 1553 if (!fonts[i]->load (prop, force_prop))
1470 { 1554 {
1471 fonts[i]->cs = CS_UNKNOWN; 1555 fonts[i]->cs = CS_UNKNOWN;
1472 return false; 1556 return false;
1473 } 1557 }
1474 1558
1575 FcPatternAddInteger (p, FC_SLANT, prop.slant); 1659 FcPatternAddInteger (p, FC_SLANT, prop.slant);
1576 FcPatternAddBool (p, FC_MINSPACE, 1); 1660 FcPatternAddBool (p, FC_MINSPACE, 1);
1577 //FcPatternAddBool (p, FC_ANTIALIAS, 1); 1661 //FcPatternAddBool (p, FC_ANTIALIAS, 1);
1578 1662
1579 XftResult result; 1663 XftResult result;
1580 FcPattern *match = XftFontMatch (term->xdisp, term->display->screen, p, &result); 1664 FcPattern *match = XftFontMatch (term->dpy, term->display->screen, p, &result);
1581 1665
1582 FcPatternDestroy (p); 1666 FcPatternDestroy (p);
1583 1667
1584 if (match) 1668 if (match)
1585 { 1669 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines