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.66 by root, Fri Feb 11 05:51:14 2005 UTC vs.
Revision 1.77 by root, Wed Jan 4 20:43:38 2006 UTC

14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *---------------------------------------------------------------------*/ 20 *---------------------------------------------------------------------*/
21 21
22#include "../config.h" 22#include "../config.h"
23#include "rxvt.h" 23#include "rxvt.h"
24#include "rxvtlib.h"
24#include "rxvtutil.h" 25#include "rxvtutil.h"
25#include "rxvtfont.h" 26#include "rxvtfont.h"
26 27
27#include <cstdlib> 28#include <cstdlib>
28#include <wchar.h> 29#include <wchar.h>
29#include <inttypes.h> 30#include <inttypes.h>
30 31
31#define DISPLAY r->display->display 32#define DISPLAY r->display->display
32#define TGC r->TermWin.gc 33#define TGC r->gc
33 34
34#define MAX_OVERLAP (4 + 1) // max. character width in 4ths of the base width 35#define MAX_OVERLAP (4 + 1) // max. character width in 4ths of the base width
35 36
36const struct rxvt_fallback_font { 37const struct rxvt_fallback_font {
37 codeset cs; 38 codeset cs;
130 { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, 131 { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" },
131 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, 132 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" },
132 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, 133 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" },
133 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, 134 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
134#if XFT 135#if XFT
135 { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true"}, 136 { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true" },
136 { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" }, 137 { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" },
137 { CS_UNICODE, "xft:Andale Mono:antialias=false" }, 138 { CS_UNICODE, "xft:Andale Mono:antialias=false:autohint=false" },
138 { CS_UNICODE, "xft:Arial Unicode MS:antialias=false" }, 139 { CS_UNICODE, "xft:Arial Unicode MS:antialias=false:autohint=false" },
139 140
140 // FreeMono is usually uglier than x fonts, so try last only. 141 // FreeMono is usually uglier than x fonts, so try last only.
141 { CS_UNICODE, "xft:FreeMono:autohint=true" }, 142 { CS_UNICODE, "xft:FreeMono:autohint=true" },
142#endif 143#endif
143 144
276 rxvt_fontprop properties () 277 rxvt_fontprop properties ()
277 { 278 {
278 rxvt_fontprop p; 279 rxvt_fontprop p;
279 280
280 p.width = p.height = 1; 281 p.width = p.height = 1;
282 p.ascent = rxvt_fontprop::unset;
281 p.weight = rxvt_fontprop::medium; 283 p.weight = rxvt_fontprop::medium;
282 p.slant = rxvt_fontprop::roman; 284 p.slant = rxvt_fontprop::roman;
283 285
284 return p; 286 return p;
285 } 287 }
305 return false; 307 return false;
306 308
307 if (unicode <= 0x009f) 309 if (unicode <= 0x009f)
308 return true; 310 return true;
309 311
310 if (unicode >= 0x2500 && unicode <= 0x259f) 312 if (unicode >= 0x2500 && unicode <= 0x259f &&
313 ! OPTION_R (Opt_skipBuiltinGlyphs))
311 return true; 314 return true;
312 315
313 if (IS_COMPOSE (unicode)) 316 if (IS_COMPOSE (unicode))
314 return true; 317 return true;
315 318
333 const text_t *text, int len, 336 const text_t *text, int len,
334 int fg, int bg) 337 int fg, int bg)
335{ 338{
336 Display *disp = d.display->display; 339 Display *disp = d.display->display;
337 340
338 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 341 clear_rect (d, x, y, r->fwidth * len, r->fheight, bg);
339 342
340 XSetForeground (disp, TGC, r->pix_colors[fg]); 343 XSetForeground (disp, TGC, r->pix_colors[fg]);
341 344
342 while (len) 345 while (len)
343 { 346 {
349 352
350 while (++text, --len && *text == NOCHAR) 353 while (++text, --len && *text == NOCHAR)
351 ; 354 ;
352 355
353 int width = text - tp; 356 int width = text - tp;
354 int fwidth = r->TermWin.fwidth * width; 357 int fwidth = r->fwidth * width;
355 358
356 if (0x2500 <= t && t <= 0x259f) 359 if (0x2500 <= t && t <= 0x259f &&
360 ! OPTION_R (Opt_skipBuiltinGlyphs))
357 { 361 {
358 uint16_t offs = linedraw_offs[t - 0x2500]; 362 uint16_t offs = linedraw_offs[t - 0x2500];
359 uint32_t *a = linedraw_command + (offs >> 4); 363 uint32_t *a = linedraw_command + (offs >> 4);
360 uint32_t *b = a + (offs & 15); 364 uint32_t *b = a + (offs & 15);
361 365
362 int W = fwidth; 366 int W = fwidth;
363 int H = r->TermWin.fheight; 367 int H = r->fheight;
364 368
365 int x_[16]; 369 int x_[16];
366 int y_[16]; 370 int y_[16];
367 371
368 for (int i = 0; i <= 8; i++) 372 for (int i = 0; i <= 8; i++)
464 case NOCHAR: 468 case NOCHAR:
465 break; 469 break;
466 470
467 default: 471 default:
468 XDrawRectangle (disp, d, TGC, x + 2, y + 2, 472 XDrawRectangle (disp, d, TGC, x + 2, y + 2,
469 fwidth - 4, r->TermWin.fheight - 4); 473 fwidth - 4, r->fheight - 4);
470 } 474 }
471 475
472 x += fwidth; 476 x += fwidth;
473 } 477 }
474} 478}
523bool 527bool
524rxvt_font_x11::set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth) 528rxvt_font_x11::set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth)
525{ 529{
526 p.width = avgwidth ? (avgwidth + 1) / 10 : (height + 1) / 2; 530 p.width = avgwidth ? (avgwidth + 1) / 10 : (height + 1) / 2;
527 p.height = height; 531 p.height = height;
532 p.ascent = rxvt_fontprop::unset;
528 p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium; 533 p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium;
529 p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic; 534 p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic;
530 535
531 return true; 536 return true;
532} 537}
552 557
553 set_properties (p, height, weight, slant, avgwidth); 558 set_properties (p, height, weight, slant, avgwidth);
554 559
555 free (weight); 560 free (weight);
556 free (slant); 561 free (slant);
562
563 p.ascent = f->ascent;
557 564
558 return true; 565 return true;
559} 566}
560 567
561bool 568bool
716 723
717 int diff = 0; 724 int diff = 0;
718 725
719 if (replace_field (fname, list[i], 6, '0', field_str)) 726 if (replace_field (fname, list[i], 6, '0', field_str))
720 diff += 10; // slightly penalize scalable fonts 727 diff += 10; // slightly penalize scalable fonts
728 else if (replace_field (fname, list[i], 11, '0', "0"))
729 diff += 300; // more heavily penalize what looks like scaled bitmap fotns
721 730
722 if (!set_properties (p, fname)) 731 if (!set_properties (p, fname))
723 continue; 732 continue;
724 733
725 if (prop.height != rxvt_fontprop::unset 734 if (prop.height != rxvt_fontprop::unset
741 for (;;) 750 for (;;)
742 { 751 {
743 font_weight *best = fonts + count - 1; 752 font_weight *best = fonts + count - 1;
744 753
745 for (font_weight *w = best; w-- > fonts; ) 754 for (font_weight *w = best; w-- > fonts; )
746 if (w->diff < best->diff) 755 if (w->diff <= best->diff)
747 best = w; 756 best = w;
748 757
749 if (!best->name 758 if (!best->name
750 || !(f = XLoadQueryFont (disp, best->name))) 759 || !(f = XLoadQueryFont (disp, best->name)))
751 break; 760 break;
849 858
850 XCharStruct g; 859 XCharStruct g;
851 int dir_ret, asc_ret, des_ret; 860 int dir_ret, asc_ret, des_ret;
852 XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); 861 XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g);
853 862
854 int wcw = wcwidth (*t); if (wcw > 0) g.width = g.width / wcw; 863 int wcw = wcwidth (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;
855 864
856 if (width < g.width) width = g.width; 865 if (width < g.width) width = g.width;
857 } 866 }
858 867
859 if (cs == CS_UNKNOWN) 868 if (cs == CS_UNKNOWN)
934 return true; 943 return true;
935 944
936 // check character against base font bounding box 945 // check character against base font bounding box
937 int w = xcs->width; 946 int w = xcs->width;
938 int wcw = wcwidth (unicode); 947 int wcw = wcwidth (unicode);
939 if (wcw > 0) w /= wcw; 948 if (wcw > 0) w = (w + wcw - 1) / wcw;
940 949
941 careful = w > prop->width; 950 careful = w > prop->width;
942 if (careful && w > prop->width * MAX_OVERLAP >> 2) 951 if (careful && w > prop->width * MAX_OVERLAP >> 2)
943 return false; 952 return false;
944 953
954 // and it is a mess /. 963 // and it is a mess /.
955 // yet we are trying to be perfect /. 964 // yet we are trying to be perfect /.
956 // but the result still isn't perfect /. 965 // but the result still isn't perfect /.
957 966
958 bool slow = this->slow 967 bool slow = this->slow
959 || width != r->TermWin.fwidth 968 || width != r->fwidth
960 || height != r->TermWin.fheight; 969 || height != r->fheight;
961 970
962 int base = ascent; // sorry, incorrect: r->TermWin.fbase; 971 int base = ascent; // sorry, incorrect: r->fbase;
963 972
964 XGCValues v; 973 XGCValues v;
965 v.foreground = r->pix_colors[fg]; 974 v.foreground = r->pix_colors[fg];
966 v.font = f->fid; 975 v.font = f->fid;
967 976
975 XChangeGC (d.display->display, TGC, GCForeground | GCBackground | GCFont, &v); 984 XChangeGC (d.display->display, TGC, GCForeground | GCBackground | GCFont, &v);
976 XDrawImageString16 (d.display->display, d, TGC, x, y + base, xc, len); 985 XDrawImageString16 (d.display->display, d, TGC, x, y + base, xc, len);
977 } 986 }
978 else 987 else
979 { 988 {
980 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 989 clear_rect (d, x, y, r->fwidth * len, r->fheight, bg);
981 990
982 XChangeGC (d.display->display, TGC, GCForeground | GCFont, &v); 991 XChangeGC (d.display->display, TGC, GCForeground | GCFont, &v);
983 992
984 if (slow) 993 if (slow)
985 { 994 {
986 do 995 do
987 { 996 {
988 if (xc->byte1 || xc->byte2) 997 if (xc->byte1 || xc->byte2)
989 XDrawString16 (d.display->display, d, TGC, x, y + base, xc, 1); 998 XDrawString16 (d.display->display, d, TGC, x, y + base, xc, 1);
990 999
991 x += r->TermWin.fwidth; 1000 x += r->fwidth;
992 xc++; len--; 1001 xc++; len--;
993 } 1002 }
994 while (len); 1003 while (len);
995 } 1004 }
996 else 1005 else
1007 XChangeGC (d.display->display, TGC, GCForeground | GCBackground | GCFont, &v); 1016 XChangeGC (d.display->display, TGC, GCForeground | GCBackground | GCFont, &v);
1008 XDrawImageString (d.display->display, d, TGC, x, y + base, xc, len); 1017 XDrawImageString (d.display->display, d, TGC, x, y + base, xc, len);
1009 } 1018 }
1010 else 1019 else
1011 { 1020 {
1012 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 1021 clear_rect (d, x, y, r->fwidth * len, r->fheight, bg);
1013 1022
1014 XChangeGC (d.display->display, TGC, GCForeground | GCFont, &v); 1023 XChangeGC (d.display->display, TGC, GCForeground | GCFont, &v);
1015 1024
1016 if (slow) 1025 if (slow)
1017 { 1026 {
1018 do 1027 do
1019 { 1028 {
1020 if (*xc) 1029 if (*xc)
1021 XDrawString (d.display->display, d, TGC, x, y + base, xc, 1); 1030 XDrawString (d.display->display, d, TGC, x, y + base, xc, 1);
1022 1031
1023 x += r->TermWin.fwidth; 1032 x += r->fwidth;
1024 xc++; len--; 1033 xc++; len--;
1025 } 1034 }
1026 while (len); 1035 while (len);
1027 } 1036 }
1028 else 1037 else
1071 1080
1072 FT_Face face = XftLockFace (f); 1081 FT_Face face = XftLockFace (f);
1073 1082
1074 p.width = width; 1083 p.width = width;
1075 p.height = height; 1084 p.height = height;
1085 p.ascent = ascent;
1076 p.weight = face->style_flags & FT_STYLE_FLAG_BOLD 1086 p.weight = face->style_flags & FT_STYLE_FLAG_BOLD
1077 ? rxvt_fontprop::bold : rxvt_fontprop::medium; 1087 ? rxvt_fontprop::bold : rxvt_fontprop::medium;
1078 p.slant = face->style_flags & FT_STYLE_FLAG_ITALIC 1088 p.slant = face->style_flags & FT_STYLE_FLAG_ITALIC
1079 ? rxvt_fontprop::italic : rxvt_fontprop::roman; 1089 ? rxvt_fontprop::italic : rxvt_fontprop::roman;
1080 1090
1096 return false; 1106 return false;
1097 1107
1098 FcValue v; 1108 FcValue v;
1099 1109
1100 if (prop.height != rxvt_fontprop::unset 1110 if (prop.height != rxvt_fontprop::unset
1101 || (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch 1111 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch
1102 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) 1112 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch))
1103 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); 1113 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height);
1104 1114
1105 if (prop.weight != rxvt_fontprop::unset 1115 if (prop.weight != rxvt_fontprop::unset
1106 && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) 1116 && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch)
1152 1162
1153 bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE; 1163 bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE;
1154 1164
1155 XftUnlockFace (f); 1165 XftUnlockFace (f);
1156 1166
1167 int glheight = height;
1168
1157 for (uint16_t *t = extent_test_chars + NUM_EXTENT_TEST_CHARS; t-- > extent_test_chars; ) 1169 for (uint16_t *t = extent_test_chars + NUM_EXTENT_TEST_CHARS; t-- > extent_test_chars; )
1158 { 1170 {
1159 FcChar16 ch = *t; 1171 FcChar16 ch = *t;
1160 1172
1161 if (cs != CS_UNICODE 1173 if (cs != CS_UNICODE
1169 continue; 1181 continue;
1170 1182
1171 XGlyphInfo g; 1183 XGlyphInfo g;
1172 XftTextExtents16 (disp, f, &ch, 1, &g); 1184 XftTextExtents16 (disp, f, &ch, 1, &g);
1173 1185
1186 g.width -= g.x;
1187
1174 int wcw = wcwidth (ch); 1188 int wcw = wcwidth (ch);
1175 if (wcw > 0) g.width = g.width / wcw; 1189 if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;
1176 1190
1177 if (width < g.width) width = g.width; 1191 if (width < g.width ) width = g.width;
1178 if (height < g.height) height = g.height; 1192 if (height < g.height ) height = g.height;
1193 if (glheight < g.height - g.y) glheight = g.height - g.y;
1194 }
1195
1196 if (!width)
1197 {
1198 rxvt_warn ("unable to calculate font width for '%s', ignoring.\n", name);
1199
1200 XftFontClose (disp, f);
1201 f = 0;
1202
1203 success = false;
1204 break;
1179 } 1205 }
1180 1206
1181 if (prop.height == rxvt_fontprop::unset 1207 if (prop.height == rxvt_fontprop::unset
1182 || height <= prop.height 1208 || (height <= prop.height && glheight <= prop.height)
1183 || height <= 2 1209 || height <= 2
1184 || !scalable) 1210 || !scalable)
1185 break; 1211 break;
1186 1212
1187 if (ftheight) 1213 if (ftheight)
1194 ftheight -= height - prop.height; 1220 ftheight -= height - prop.height;
1195 } 1221 }
1196 else 1222 else
1197 ftheight = prop.height - 1; 1223 ftheight = prop.height - 1;
1198 1224
1199 XftFontClose (disp, f); 1225 XftFontClose (disp, f);
1200 FcPatternDel (match, FC_PIXEL_SIZE); 1226 FcPatternDel (match, FC_PIXEL_SIZE);
1201 FcPatternAddInteger (match, FC_PIXEL_SIZE, ftheight); 1227 FcPatternAddInteger (match, FC_PIXEL_SIZE, ftheight);
1202 } 1228 }
1203 1229
1204 FcPatternDestroy (match); 1230 FcPatternDestroy (match);
1205 1231
1206#if 0 // do it per-character 1232#if 0 // do it per-character
1228 // check character against base font bounding box 1254 // check character against base font bounding box
1229 FcChar32 ch = unicode; 1255 FcChar32 ch = unicode;
1230 XGlyphInfo g; 1256 XGlyphInfo g;
1231 XftTextExtents32 (DISPLAY, f, &ch, 1, &g); 1257 XftTextExtents32 (DISPLAY, f, &ch, 1, &g);
1232 1258
1233 int w = g.width; 1259 int w = g.width - g.x;
1234 int wcw = wcwidth (unicode); 1260 int wcw = wcwidth (unicode);
1235 if (wcw > 0) w /= wcw; 1261 if (wcw > 0) w = (w + wcw - 1) / wcw;
1236 1262
1237 careful = w > prop->width; 1263 careful = w > prop->width;
1238 if (careful && w > prop->width * MAX_OVERLAP >> 2) 1264 if (careful && w > prop->width * MAX_OVERLAP >> 2)
1239 return false; 1265 return false;
1240 1266
1244void 1270void
1245rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, 1271rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
1246 const text_t *text, int len, 1272 const text_t *text, int len,
1247 int fg, int bg) 1273 int fg, int bg)
1248{ 1274{
1249 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 1275 clear_rect (d, x, y, r->fwidth * len, r->fheight, bg);
1250 1276
1251 int base = ascent; // should be fbase, but that is incorrect 1277 int base = ascent; // should be fbase, but that is incorrect
1252 1278
1253 XGlyphInfo extents; 1279 XGlyphInfo extents;
1254 FcChar32 *enc = (FcChar32 *) get_enc_buf (len * sizeof (FcChar32)); 1280 FcChar32 *enc = (FcChar32 *) get_enc_buf (len * sizeof (FcChar32));
1255 FcChar32 *ep = enc; 1281 FcChar32 *ep = enc;
1256 int ewidth = 0; 1282 int ewidth = 0;
1257 int xoff = 0;
1258 1283
1259 while (len) 1284 while (len)
1260 { 1285 {
1261 int cwidth = r->TermWin.fwidth; 1286 int cwidth = r->fwidth;
1262 FcChar32 fc = *text++; len--; 1287 FcChar32 fc = *text++; len--;
1263 FT_UInt gl;
1264 1288
1265 while (len && *text == NOCHAR) 1289 while (len && *text == NOCHAR)
1266 text++, len--, cwidth += r->TermWin.fwidth; 1290 text++, len--, cwidth += r->fwidth;
1267 1291
1268 gl = XftCharIndex (d.display->display, f, fc);
1269 XftGlyphExtents (d.display->display, f, &gl, 1, &extents);
1270
1271 if (extents.xOff != cwidth && ep != enc)
1272 {
1273 if (xoff > ewidth) xoff = ewidth;
1274 XftDrawGlyphs (d, &r->pix_colors[fg].c, f,
1275 x + (ewidth - xoff >> 1),
1276 y + base, enc, ep - enc);
1277 x += ewidth;
1278
1279 ep = enc;
1280 ewidth = 0;
1281 xoff = 0;
1282 }
1283
1284 if (fc == ' ' && ep == enc) // skip leading spaces 1292 if (fc == ' ' && ep == enc) // skip leading spaces
1285 {
1286 x += cwidth; 1293 x += cwidth;
1287 continue;
1288 }
1289
1290 else 1294 else
1291 { 1295 {
1296 FT_UInt gl = XftCharIndex (d.display->display, f, fc);
1297 XftGlyphExtents (d.display->display, f, &gl, 1, &extents);
1298
1299 if (extents.xOff != cwidth)
1300 {
1301 if (ewidth)
1302 {
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 }
1319 else
1320 {
1292 *ep++ = gl; 1321 *ep++ = gl;
1293 ewidth += cwidth; 1322 ewidth += cwidth;
1294 xoff += extents.xOff; 1323 }
1295 } 1324 }
1296 } 1325 }
1297 1326
1298 if (ep != enc) 1327 if (ep != enc)
1299 {
1300 if (xoff > ewidth) xoff = ewidth;
1301 XftDrawGlyphs (d, &r->pix_colors[fg].c, f, 1328 XftDrawGlyphs (d, &r->pix_colors[fg].c, f,
1302 x + (ewidth - xoff >> 1),
1303 y + base, enc, ep - enc); 1329 x, y + base, enc, ep - enc);
1304 }
1305} 1330}
1306#endif 1331#endif
1307 1332
1308///////////////////////////////////////////////////////////////////////////// 1333/////////////////////////////////////////////////////////////////////////////
1309 1334
1310rxvt_fontset::rxvt_fontset (rxvt_t r) 1335rxvt_fontset::rxvt_fontset (rxvt_t r)
1311: r (r), fontdesc (0) 1336: fontdesc (0), r (r)
1312{ 1337{
1313 clear (); 1338 clear ();
1314} 1339}
1315 1340
1316rxvt_fontset::~rxvt_fontset () 1341rxvt_fontset::~rxvt_fontset ()
1319} 1344}
1320 1345
1321void 1346void
1322rxvt_fontset::clear () 1347rxvt_fontset::clear ()
1323{ 1348{
1324 prop.width = prop.height = prop.weight = prop.slant 1349 prop.width = prop.height = prop.ascent = prop.weight = prop.slant
1325 = rxvt_fontprop::unset; 1350 = rxvt_fontprop::unset;
1326 1351
1327 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) 1352 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
1328 FONT_UNREF (*i); 1353 FONT_UNREF (*i);
1329 1354
1381 char buf[512]; 1406 char buf[512];
1382 const char *end; 1407 const char *end;
1383 1408
1384 do 1409 do
1385 { 1410 {
1386 while (*desc <= ' ') desc++; 1411 while (*desc && *desc <= ' ')
1412 desc++;
1387 1413
1388 codeset cs = CS_UNICODE; 1414 codeset cs = CS_UNICODE;
1389 1415
1390 if (*desc == '[') 1416 if (*desc == '[')
1391 { 1417 {
1501 if (FROM_UNICODE (f->cs, unicode) == NOCHAR) 1527 if (FROM_UNICODE (f->cs, unicode) == NOCHAR)
1502 goto next_font; 1528 goto next_font;
1503 1529
1504 if (!realize_font (i)) 1530 if (!realize_font (i))
1505 goto next_font; 1531 goto next_font;
1532
1533 if (prop.ascent != rxvt_fontprop::unset)
1534 max_it (f->ascent, prop.ascent);
1506 } 1535 }
1507 1536
1508 if (f->cs == CS_UNKNOWN) 1537 if (f->cs == CS_UNKNOWN)
1509 goto next_font; 1538 goto next_font;
1510 1539

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines