1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: defaultfont.C |
2 | * File: rxvtfont.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
4 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
5 | * - original version. |
5 | * - original version. |
6 | * |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
7 | * This program is free software; you can redistribute it and/or modify |
… | |
… | |
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 "rxvtutil.h" |
24 | #include "rxvtutil.h" |
… | |
… | |
130 | { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, |
130 | { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, |
131 | { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, |
131 | { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, |
132 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, |
132 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, |
133 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
133 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
134 | #if XFT |
134 | #if XFT |
135 | { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true"}, |
135 | { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true" }, |
136 | { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" }, |
136 | { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" }, |
137 | { CS_UNICODE, "xft:Andale Mono:antialias=false" }, |
137 | { CS_UNICODE, "xft:Andale Mono:antialias=false:autohint=false" }, |
138 | { CS_UNICODE, "xft:Arial Unicode MS:antialias=false" }, |
138 | { CS_UNICODE, "xft:Arial Unicode MS:antialias=false:autohint=false" }, |
139 | |
139 | |
140 | // FreeMono is usually uglier than x fonts, so try last only. |
140 | // FreeMono is usually uglier than x fonts, so try last only. |
141 | { CS_UNICODE, "xft:FreeMono:autohint=true" }, |
141 | { CS_UNICODE, "xft:FreeMono:autohint=true" }, |
142 | #endif |
142 | #endif |
143 | |
143 | |
… | |
… | |
331 | void |
331 | void |
332 | rxvt_font_default::draw (rxvt_drawable &d, int x, int y, |
332 | rxvt_font_default::draw (rxvt_drawable &d, int x, int y, |
333 | const text_t *text, int len, |
333 | const text_t *text, int len, |
334 | int fg, int bg) |
334 | int fg, int bg) |
335 | { |
335 | { |
|
|
336 | Display *disp = d.display->display; |
|
|
337 | |
336 | clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
338 | clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
337 | |
339 | |
338 | XSetForeground (d.display->display, TGC, r->pix_colors[fg]); |
340 | XSetForeground (disp, TGC, r->pix_colors[fg]); |
339 | |
341 | |
340 | while (len) |
342 | while (len) |
341 | { |
343 | { |
342 | #if ENABLE_COMBINING |
344 | #if ENABLE_COMBINING |
343 | compose_char *cc; |
345 | compose_char *cc; |
… | |
… | |
374 | |
376 | |
375 | XGCValues gcv; |
377 | XGCValues gcv; |
376 | |
378 | |
377 | gcv.cap_style = CapButt; |
379 | gcv.cap_style = CapButt; |
378 | gcv.line_width = 0; |
380 | gcv.line_width = 0; |
379 | XChangeGC (d.display->display, TGC, GCLineWidth | GCCapStyle, &gcv); |
381 | XChangeGC (disp, TGC, GCLineWidth | GCCapStyle, &gcv); |
380 | |
382 | |
381 | while (a < b) |
383 | while (a < b) |
382 | { |
384 | { |
383 | uint32_t command = *a++; |
385 | uint32_t command = *a++; |
384 | |
386 | |
… | |
… | |
391 | int y2 = y_[(command >> 0) & 15]; |
393 | int y2 = y_[(command >> 0) & 15]; |
392 | |
394 | |
393 | switch (op) |
395 | switch (op) |
394 | { |
396 | { |
395 | case 0: // line |
397 | case 0: // line |
396 | XDrawLine (d.display->display, d, TGC, x1, y1, x2, y2); |
398 | XDrawLine (disp, d, TGC, x1, y1, x2, y2); |
397 | break; |
399 | break; |
398 | |
400 | |
399 | case 1: // rectangle, possibly stippled |
401 | case 1: // rectangle, possibly stippled |
400 | if (a) |
402 | if (a) |
401 | { |
403 | { |
402 | static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; |
404 | static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; |
403 | |
405 | |
404 | gcv.fill_style = FillStippled; |
406 | gcv.fill_style = FillStippled; |
405 | gcv.stipple = XCreateBitmapFromData (d.display->display, d, bm + a * 2, 2, 2); |
407 | gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2); |
406 | gcv.ts_x_origin = x; |
408 | gcv.ts_x_origin = x; |
407 | gcv.ts_y_origin = y; |
409 | gcv.ts_y_origin = y; |
408 | |
410 | |
409 | XChangeGC (d.display->display, TGC, |
411 | XChangeGC (disp, TGC, |
410 | GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin, |
412 | GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin, |
411 | &gcv); |
413 | &gcv); |
412 | } |
414 | } |
413 | |
415 | |
414 | XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1 + 1, y2 - y1 + 1); |
416 | XFillRectangle (disp, d, TGC, x1, y1, x2 - x1 + 1, y2 - y1 + 1); |
415 | |
417 | |
416 | if (a) |
418 | if (a) |
417 | { |
419 | { |
418 | XFreePixmap (d.display->display, gcv.stipple); |
420 | XFreePixmap (disp, gcv.stipple); |
419 | gcv.stipple = 0; |
421 | gcv.stipple = 0; |
420 | gcv.fill_style = FillSolid; |
422 | gcv.fill_style = FillSolid; |
421 | XChangeGC (d.display->display, TGC, GCFillStyle, &gcv); |
423 | XChangeGC (disp, TGC, GCFillStyle, &gcv); |
422 | } |
424 | } |
423 | break; |
425 | break; |
424 | case 2: // arc |
426 | case 2: // arc |
425 | XDrawArc (d.display->display, d, TGC, |
427 | XDrawArc (disp, d, TGC, |
426 | x1 - W/2, y1 - H/2, W-1, H-1, |
428 | x1 - W/2, y1 - H/2, W-1, H-1, |
427 | (a - 1) * 90*64, (b - 1) * 90*64); |
429 | (a - 1) * 90*64, (b - 1) * 90*64); |
428 | break; |
430 | break; |
429 | } |
431 | } |
430 | } |
432 | } |
… | |
… | |
461 | case ZERO_WIDTH_CHAR: |
463 | case ZERO_WIDTH_CHAR: |
462 | case NOCHAR: |
464 | case NOCHAR: |
463 | break; |
465 | break; |
464 | |
466 | |
465 | default: |
467 | default: |
466 | XDrawRectangle (d.display->display, d, TGC, x + 2, y + 2, |
468 | XDrawRectangle (disp, d, TGC, x + 2, y + 2, |
467 | fwidth - 4, r->TermWin.fheight - 4); |
469 | fwidth - 4, r->TermWin.fheight - 4); |
468 | } |
470 | } |
469 | |
471 | |
470 | x += fwidth; |
472 | x += fwidth; |
471 | } |
473 | } |
… | |
… | |
630 | } |
632 | } |
631 | |
633 | |
632 | bool |
634 | bool |
633 | rxvt_font_x11::load (const rxvt_fontprop &prop) |
635 | rxvt_font_x11::load (const rxvt_fontprop &prop) |
634 | { |
636 | { |
|
|
637 | Display *disp = DISPLAY; |
|
|
638 | |
635 | clear (); |
639 | clear (); |
636 | |
640 | |
637 | char field_str[64]; // enough for 128 bits |
641 | char field_str[64]; // enough for 128 bits |
638 | |
642 | |
639 | // first morph the font if required |
643 | // first morph the font if required |
… | |
… | |
642 | { |
646 | { |
643 | char fname[1024]; |
647 | char fname[1024]; |
644 | |
648 | |
645 | if (name[0] != '-') |
649 | if (name[0] != '-') |
646 | { |
650 | { |
647 | f = XLoadQueryFont (DISPLAY, name); |
651 | f = XLoadQueryFont (disp, name); |
648 | |
652 | |
649 | if (!f) |
653 | if (!f) |
650 | return false; |
654 | return false; |
651 | |
655 | |
652 | char *new_name = get_property (f, "FONT", name); |
656 | char *new_name = get_property (f, "FONT", name); |
… | |
… | |
654 | if (new_name) |
658 | if (new_name) |
655 | set_name (new_name); |
659 | set_name (new_name); |
656 | else |
660 | else |
657 | rxvt_warn ("font '%s' has no FONT property, continuing without.", name); |
661 | rxvt_warn ("font '%s' has no FONT property, continuing without.", name); |
658 | |
662 | |
659 | XFreeFont (DISPLAY, f); |
663 | XFreeFont (disp, f); |
660 | f = 0; |
664 | f = 0; |
661 | } |
665 | } |
662 | |
666 | |
663 | if (prop.weight != rxvt_fontprop::unset) |
667 | if (prop.weight != rxvt_fontprop::unset) |
664 | { |
668 | { |
… | |
… | |
694 | ~font_weight () { free (name); } |
698 | ~font_weight () { free (name); } |
695 | }; |
699 | }; |
696 | |
700 | |
697 | char **list; |
701 | char **list; |
698 | int count; |
702 | int count; |
699 | list = XListFonts (DISPLAY, name, 4000, &count); |
703 | list = XListFonts (disp, name, 4000, &count); |
700 | |
704 | |
701 | set_name (0); |
705 | set_name (0); |
702 | |
706 | |
703 | if (!list) |
707 | if (!list) |
704 | return false; |
708 | return false; |
… | |
… | |
712 | |
716 | |
713 | int diff = 0; |
717 | int diff = 0; |
714 | |
718 | |
715 | if (replace_field (fname, list[i], 6, '0', field_str)) |
719 | if (replace_field (fname, list[i], 6, '0', field_str)) |
716 | diff += 10; // slightly penalize scalable fonts |
720 | diff += 10; // slightly penalize scalable fonts |
|
|
721 | else if (replace_field (fname, list[i], 11, '0', "0")) |
|
|
722 | diff += 300; // more heavily penalize what looks like scaled bitmap fotns |
717 | |
723 | |
718 | if (!set_properties (p, fname)) |
724 | if (!set_properties (p, fname)) |
719 | continue; |
725 | continue; |
720 | |
726 | |
721 | if (prop.height != rxvt_fontprop::unset |
727 | if (prop.height != rxvt_fontprop::unset |
… | |
… | |
737 | for (;;) |
743 | for (;;) |
738 | { |
744 | { |
739 | font_weight *best = fonts + count - 1; |
745 | font_weight *best = fonts + count - 1; |
740 | |
746 | |
741 | for (font_weight *w = best; w-- > fonts; ) |
747 | for (font_weight *w = best; w-- > fonts; ) |
742 | if (w->diff < best->diff) |
748 | if (w->diff <= best->diff) |
743 | best = w; |
749 | best = w; |
744 | |
750 | |
745 | if (!best->name |
751 | if (!best->name |
746 | || !(f = XLoadQueryFont (DISPLAY, best->name))) |
752 | || !(f = XLoadQueryFont (disp, best->name))) |
747 | break; |
753 | break; |
748 | |
754 | |
749 | set_name (best->name); |
755 | set_name (best->name); |
750 | best->clear (); |
756 | best->clear (); |
751 | |
757 | |
… | |
… | |
845 | |
851 | |
846 | XCharStruct g; |
852 | XCharStruct g; |
847 | int dir_ret, asc_ret, des_ret; |
853 | int dir_ret, asc_ret, des_ret; |
848 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
854 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
849 | |
855 | |
850 | int wcw = wcwidth (*t); if (wcw > 0) g.width = g.width / wcw; |
856 | int wcw = wcwidth (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
851 | |
857 | |
852 | if (width < g.width) width = g.width; |
858 | if (width < g.width) width = g.width; |
853 | } |
859 | } |
854 | |
860 | |
855 | if (cs == CS_UNKNOWN) |
861 | if (cs == CS_UNKNOWN) |
… | |
… | |
930 | return true; |
936 | return true; |
931 | |
937 | |
932 | // check character against base font bounding box |
938 | // check character against base font bounding box |
933 | int w = xcs->width; |
939 | int w = xcs->width; |
934 | int wcw = wcwidth (unicode); |
940 | int wcw = wcwidth (unicode); |
935 | if (wcw > 0) w /= wcw; |
941 | if (wcw > 0) w = (w + wcw - 1) / wcw; |
936 | |
942 | |
937 | careful = w > prop->width; |
943 | careful = w > prop->width; |
938 | if (careful && w > prop->width * MAX_OVERLAP >> 2) |
944 | if (careful && w > prop->width * MAX_OVERLAP >> 2) |
939 | return false; |
945 | return false; |
940 | |
946 | |
… | |
… | |
1080 | } |
1086 | } |
1081 | |
1087 | |
1082 | bool |
1088 | bool |
1083 | rxvt_font_xft::load (const rxvt_fontprop &prop) |
1089 | rxvt_font_xft::load (const rxvt_fontprop &prop) |
1084 | { |
1090 | { |
|
|
1091 | Display *disp = DISPLAY; |
|
|
1092 | |
1085 | clear (); |
1093 | clear (); |
1086 | |
1094 | |
1087 | FcPattern *p = FcNameParse ((FcChar8 *) name); |
1095 | FcPattern *p = FcNameParse ((FcChar8 *) name); |
1088 | |
1096 | |
1089 | if (!p) |
1097 | if (!p) |
1090 | return false; |
1098 | return false; |
1091 | |
1099 | |
1092 | FcValue v; |
1100 | FcValue v; |
1093 | |
1101 | |
1094 | if (prop.height != rxvt_fontprop::unset |
1102 | if (prop.height != rxvt_fontprop::unset |
1095 | || (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch |
1103 | && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch |
1096 | && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) |
1104 | && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) |
1097 | FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); |
1105 | FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); |
1098 | |
1106 | |
1099 | if (prop.weight != rxvt_fontprop::unset |
1107 | if (prop.weight != rxvt_fontprop::unset |
1100 | && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) |
1108 | && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) |
… | |
… | |
1115 | |
1123 | |
1116 | // store generated name so iso14755 view gives better results |
1124 | // store generated name so iso14755 view gives better results |
1117 | set_name ((char *)FcNameUnparse (p)); |
1125 | set_name ((char *)FcNameUnparse (p)); |
1118 | |
1126 | |
1119 | XftResult result; |
1127 | XftResult result; |
1120 | FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result); |
1128 | FcPattern *match = XftFontMatch (disp, r->display->screen, p, &result); |
1121 | |
1129 | |
1122 | FcPatternDestroy (p); |
1130 | FcPatternDestroy (p); |
1123 | |
1131 | |
1124 | if (!match) |
1132 | if (!match) |
1125 | return false; |
1133 | return false; |
… | |
… | |
1127 | int ftheight = 0; |
1135 | int ftheight = 0; |
1128 | bool success = true; |
1136 | bool success = true; |
1129 | |
1137 | |
1130 | for (;;) |
1138 | for (;;) |
1131 | { |
1139 | { |
1132 | f = XftFontOpenPattern (DISPLAY, FcPatternDuplicate (match)); |
1140 | f = XftFontOpenPattern (disp, FcPatternDuplicate (match)); |
1133 | |
1141 | |
1134 | if (!f) |
1142 | if (!f) |
1135 | { |
1143 | { |
1136 | success = false; |
1144 | success = false; |
1137 | break; |
1145 | break; |
… | |
… | |
1146 | |
1154 | |
1147 | bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE; |
1155 | bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE; |
1148 | |
1156 | |
1149 | XftUnlockFace (f); |
1157 | XftUnlockFace (f); |
1150 | |
1158 | |
|
|
1159 | int glheight = height; |
|
|
1160 | |
1151 | for (uint16_t *t = extent_test_chars + NUM_EXTENT_TEST_CHARS; t-- > extent_test_chars; ) |
1161 | for (uint16_t *t = extent_test_chars + NUM_EXTENT_TEST_CHARS; t-- > extent_test_chars; ) |
1152 | { |
1162 | { |
1153 | FcChar16 ch = *t; |
1163 | FcChar16 ch = *t; |
1154 | |
1164 | |
1155 | if (cs != CS_UNICODE |
1165 | if (cs != CS_UNICODE |
… | |
… | |
1161 | bool careful; |
1171 | bool careful; |
1162 | if (!has_char (*t, &prop, careful)) |
1172 | if (!has_char (*t, &prop, careful)) |
1163 | continue; |
1173 | continue; |
1164 | |
1174 | |
1165 | XGlyphInfo g; |
1175 | XGlyphInfo g; |
1166 | XftTextExtents16 (DISPLAY, f, &ch, 1, &g); |
1176 | XftTextExtents16 (disp, f, &ch, 1, &g); |
|
|
1177 | |
|
|
1178 | g.width -= g.x; |
1167 | |
1179 | |
1168 | int wcw = wcwidth (ch); |
1180 | int wcw = wcwidth (ch); |
1169 | if (wcw > 0) g.width = g.width / wcw; |
1181 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
1170 | |
1182 | |
1171 | if (width < g.width) width = g.width; |
1183 | if (width < g.width ) width = g.width; |
1172 | if (height < g.height) height = g.height; |
1184 | if (height < g.height ) height = g.height; |
|
|
1185 | if (glheight < g.height - g.y) glheight = g.height - g.y; |
1173 | } |
1186 | } |
1174 | |
1187 | |
1175 | if (prop.height == rxvt_fontprop::unset |
1188 | if (prop.height == rxvt_fontprop::unset |
1176 | || height <= prop.height |
1189 | || (height <= prop.height && glheight <= prop.height) |
1177 | || height <= 2 |
1190 | || height <= 2 |
1178 | || !scalable) |
1191 | || !scalable) |
1179 | break; |
1192 | break; |
1180 | |
1193 | |
1181 | if (ftheight) |
1194 | if (ftheight) |
… | |
… | |
1188 | ftheight -= height - prop.height; |
1201 | ftheight -= height - prop.height; |
1189 | } |
1202 | } |
1190 | else |
1203 | else |
1191 | ftheight = prop.height - 1; |
1204 | ftheight = prop.height - 1; |
1192 | |
1205 | |
1193 | XftFontClose (DISPLAY, f); |
1206 | XftFontClose (disp, f); |
1194 | FcPatternDel (match, FC_PIXEL_SIZE); |
1207 | FcPatternDel (match, FC_PIXEL_SIZE); |
1195 | FcPatternAddInteger (match, FC_PIXEL_SIZE, ftheight); |
1208 | FcPatternAddInteger (match, FC_PIXEL_SIZE, ftheight); |
1196 | } |
1209 | } |
1197 | |
1210 | |
1198 | FcPatternDestroy (match); |
1211 | FcPatternDestroy (match); |
… | |
… | |
1222 | // check character against base font bounding box |
1235 | // check character against base font bounding box |
1223 | FcChar32 ch = unicode; |
1236 | FcChar32 ch = unicode; |
1224 | XGlyphInfo g; |
1237 | XGlyphInfo g; |
1225 | XftTextExtents32 (DISPLAY, f, &ch, 1, &g); |
1238 | XftTextExtents32 (DISPLAY, f, &ch, 1, &g); |
1226 | |
1239 | |
1227 | int w = g.width; |
1240 | int w = g.width - g.x; |
1228 | int wcw = wcwidth (unicode); |
1241 | int wcw = wcwidth (unicode); |
1229 | if (wcw > 0) w /= wcw; |
1242 | if (wcw > 0) w = (w + wcw - 1) / wcw; |
1230 | |
1243 | |
1231 | careful = w > prop->width; |
1244 | careful = w > prop->width; |
1232 | if (careful && w > prop->width * MAX_OVERLAP >> 2) |
1245 | if (careful && w > prop->width * MAX_OVERLAP >> 2) |
1233 | return false; |
1246 | return false; |
1234 | |
1247 | |
… | |
… | |
1246 | |
1259 | |
1247 | XGlyphInfo extents; |
1260 | XGlyphInfo extents; |
1248 | FcChar32 *enc = (FcChar32 *) get_enc_buf (len * sizeof (FcChar32)); |
1261 | FcChar32 *enc = (FcChar32 *) get_enc_buf (len * sizeof (FcChar32)); |
1249 | FcChar32 *ep = enc; |
1262 | FcChar32 *ep = enc; |
1250 | int ewidth = 0; |
1263 | int ewidth = 0; |
1251 | int xoff = 0; |
|
|
1252 | |
1264 | |
1253 | while (len) |
1265 | while (len) |
1254 | { |
1266 | { |
1255 | int cwidth = r->TermWin.fwidth; |
1267 | int cwidth = r->TermWin.fwidth; |
1256 | FcChar32 fc = *text++; len--; |
1268 | FcChar32 fc = *text++; len--; |
1257 | FT_UInt gl; |
|
|
1258 | |
1269 | |
1259 | while (len && *text == NOCHAR) |
1270 | while (len && *text == NOCHAR) |
1260 | text++, len--, cwidth += r->TermWin.fwidth; |
1271 | text++, len--, cwidth += r->TermWin.fwidth; |
1261 | |
1272 | |
1262 | gl = XftCharIndex (d.display->display, f, fc); |
|
|
1263 | XftGlyphExtents (d.display->display, f, &gl, 1, &extents); |
|
|
1264 | |
|
|
1265 | if (extents.xOff != cwidth && ep != enc) |
|
|
1266 | { |
|
|
1267 | if (xoff > ewidth) xoff = ewidth; |
|
|
1268 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
|
|
1269 | x + (ewidth - xoff >> 1), |
|
|
1270 | y + base, enc, ep - enc); |
|
|
1271 | x += ewidth; |
|
|
1272 | |
|
|
1273 | ep = enc; |
|
|
1274 | ewidth = 0; |
|
|
1275 | xoff = 0; |
|
|
1276 | } |
|
|
1277 | |
|
|
1278 | if (fc == ' ' && ep == enc) // skip leading spaces |
1273 | if (fc == ' ' && ep == enc) // skip leading spaces |
1279 | { |
|
|
1280 | x += cwidth; |
1274 | x += cwidth; |
1281 | continue; |
|
|
1282 | } |
|
|
1283 | |
|
|
1284 | else |
1275 | else |
1285 | { |
1276 | { |
|
|
1277 | FT_UInt gl = XftCharIndex (d.display->display, f, fc); |
|
|
1278 | XftGlyphExtents (d.display->display, f, &gl, 1, &extents); |
|
|
1279 | |
|
|
1280 | if (extents.xOff != cwidth) |
|
|
1281 | { |
|
|
1282 | if (ewidth) |
|
|
1283 | { |
|
|
1284 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
|
|
1285 | x, y + base, enc, ep - enc); |
|
|
1286 | x += ewidth; |
|
|
1287 | |
|
|
1288 | ep = enc; |
|
|
1289 | ewidth = 0; |
|
|
1290 | } |
|
|
1291 | |
|
|
1292 | if (extents.xOff > cwidth) |
|
|
1293 | extents.xOff = cwidth; |
|
|
1294 | |
|
|
1295 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
|
|
1296 | x + (cwidth - extents.xOff >> 1), |
|
|
1297 | y + base, &gl, 1); |
|
|
1298 | x += cwidth; |
|
|
1299 | } |
|
|
1300 | else |
|
|
1301 | { |
1286 | *ep++ = gl; |
1302 | *ep++ = gl; |
1287 | ewidth += cwidth; |
1303 | ewidth += cwidth; |
1288 | xoff += extents.xOff; |
1304 | } |
1289 | } |
1305 | } |
1290 | } |
1306 | } |
1291 | |
1307 | |
1292 | if (ep != enc) |
1308 | if (ep != enc) |
1293 | { |
|
|
1294 | if (xoff > ewidth) xoff = ewidth; |
|
|
1295 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
1309 | XftDrawGlyphs (d, &r->pix_colors[fg].c, f, |
1296 | x + (ewidth - xoff >> 1), |
|
|
1297 | y + base, enc, ep - enc); |
1310 | x, y + base, enc, ep - enc); |
1298 | } |
|
|
1299 | } |
1311 | } |
1300 | #endif |
1312 | #endif |
1301 | |
1313 | |
1302 | ///////////////////////////////////////////////////////////////////////////// |
1314 | ///////////////////////////////////////////////////////////////////////////// |
1303 | |
1315 | |
1304 | rxvt_fontset::rxvt_fontset (rxvt_t r) |
1316 | rxvt_fontset::rxvt_fontset (rxvt_t r) |
1305 | : r (r), fontdesc (0) |
1317 | : fontdesc (0), r (r) |
1306 | { |
1318 | { |
1307 | clear (); |
1319 | clear (); |
1308 | } |
1320 | } |
1309 | |
1321 | |
1310 | rxvt_fontset::~rxvt_fontset () |
1322 | rxvt_fontset::~rxvt_fontset () |
… | |
… | |
1375 | char buf[512]; |
1387 | char buf[512]; |
1376 | const char *end; |
1388 | const char *end; |
1377 | |
1389 | |
1378 | do |
1390 | do |
1379 | { |
1391 | { |
1380 | while (*desc <= ' ') desc++; |
1392 | while (*desc && *desc <= ' ') |
|
|
1393 | desc++; |
1381 | |
1394 | |
1382 | codeset cs = CS_UNICODE; |
1395 | codeset cs = CS_UNICODE; |
1383 | |
1396 | |
1384 | if (*desc == '[') |
1397 | if (*desc == '[') |
1385 | { |
1398 | { |
… | |
… | |
1543 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1556 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1544 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1557 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1545 | //FcPatternAddBool (p, FC_ANTIALIAS, 1); |
1558 | //FcPatternAddBool (p, FC_ANTIALIAS, 1); |
1546 | |
1559 | |
1547 | XftResult result; |
1560 | XftResult result; |
1548 | FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result); |
1561 | FcPattern *match = XftFontMatch (DISPLAY, r->display->screen, p, &result); |
1549 | |
1562 | |
1550 | FcPatternDestroy (p); |
1563 | FcPatternDestroy (p); |
1551 | |
1564 | |
1552 | if (match) |
1565 | if (match) |
1553 | { |
1566 | { |