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 |
|
|
168 | rxvt_drawable::~rxvt_drawable () |
|
|
169 | { |
|
|
170 | if (xftdrawable) |
|
|
171 | XftDrawDestroy (xftdrawable); |
|
|
172 | } |
|
|
173 | |
|
|
174 | rxvt_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 | |
185 | static const char * |
168 | static const char * |
186 | enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) |
169 | enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) |
… | |
… | |
249 | rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const |
232 | rxvt_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 |
259 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
242 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
… | |
… | |
287 | p.slant = rxvt_fontprop::roman; |
270 | p.slant = rxvt_fontprop::roman; |
288 | |
271 | |
289 | return p; |
272 | return p; |
290 | } |
273 | } |
291 | |
274 | |
292 | bool load (const rxvt_fontprop &prop) |
275 | bool load (const rxvt_fontprop &prop, bool force_prop) |
293 | { |
276 | { |
294 | width = 1; height = 1; |
277 | width = 1; height = 1; |
295 | ascent = 1; descent = 0; |
278 | ascent = 1; descent = 0; |
296 | |
279 | |
297 | set_name (strdup ("built-in support font")); |
280 | set_name (strdup ("built-in support font")); |
… | |
… | |
458 | *chrs = cc->c2; |
441 | *chrs = cc->c2; |
459 | rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) |
442 | rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) |
460 | ? f1 |
443 | ? f1 |
461 | : (*fs)[fs->find_font (cc->c2)]; |
444 | : (*fs)[fs->find_font (cc->c2)]; |
462 | |
445 | |
463 | f2->draw (d, x, y, chrs, width, fg, -1); |
446 | f2->draw (d, x, y, chrs, width, fg, Color_none); |
464 | } |
447 | } |
465 | } |
448 | } |
466 | #endif |
449 | #endif |
467 | else |
450 | else |
468 | switch (t) |
451 | switch (t) |
… | |
… | |
488 | |
471 | |
489 | void clear (); |
472 | void clear (); |
490 | |
473 | |
491 | rxvt_fontprop properties (); |
474 | rxvt_fontprop properties (); |
492 | |
475 | |
493 | bool load (const rxvt_fontprop &prop); |
476 | bool load (const rxvt_fontprop &prop, bool force_prop); |
494 | |
477 | |
495 | 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; |
496 | |
479 | |
497 | void draw (rxvt_drawable &d, int x, int y, |
480 | void draw (rxvt_drawable &d, int x, int y, |
498 | const text_t *text, int len, |
481 | const text_t *text, int len, |
499 | int fg, int bg); |
482 | int fg, int bg); |
500 | |
483 | |
501 | 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 |
502 | XFontStruct *f; |
485 | XFontStruct *f; |
503 | codeset cs; |
|
|
504 | bool enc2b, encm; |
486 | bool enc2b, encm; |
505 | |
487 | |
506 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
488 | 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); |
489 | 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); |
490 | bool set_properties (rxvt_fontprop &p, XFontStruct *f); |
… | |
… | |
513 | rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const |
495 | rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const |
514 | { |
496 | { |
515 | unsigned long value; |
497 | unsigned long value; |
516 | |
498 | |
517 | if (XGetFontProperty (f, property, &value)) |
499 | if (XGetFontProperty (f, property, &value)) |
518 | return XGetAtomName (term->xdisp, value); |
500 | return XGetAtomName (term->dpy, value); |
519 | else |
501 | else |
520 | return rxvt_strdup (repl); |
502 | return rxvt_strdup (repl); |
521 | } |
503 | } |
522 | |
504 | |
523 | rxvt_fontprop |
505 | rxvt_fontprop |
… | |
… | |
546 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
528 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
547 | { |
529 | { |
548 | unsigned long height; |
530 | unsigned long height; |
549 | |
531 | |
550 | #if 0 |
532 | #if 0 |
551 | if (!XGetFontProperty (f, XInternAtom (term->xdisp, "PIXEL_SIZE", 0), &height)) |
533 | if (!XGetFontProperty (f, XInternAtom (term->dpy, "PIXEL_SIZE", 0), &height)) |
552 | return false; |
534 | return false; |
553 | #else |
535 | #else |
554 | height = f->ascent + f->descent; |
536 | height = f->ascent + f->descent; |
555 | #endif |
537 | #endif |
556 | |
538 | |
… | |
… | |
644 | return false; |
626 | return false; |
645 | } |
627 | } |
646 | } |
628 | } |
647 | |
629 | |
648 | bool |
630 | bool |
649 | rxvt_font_x11::load (const rxvt_fontprop &prop) |
631 | rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop) |
650 | { |
632 | { |
651 | dTermDisplay; |
633 | dTermDisplay; |
652 | |
634 | |
653 | clear (); |
635 | clear (); |
654 | |
636 | |
655 | char field_str[64]; // enough for 128 bits |
637 | char field_str[64]; // enough for 128 bits |
656 | |
638 | |
657 | // first morph the font if required |
639 | // first morph the font if required |
658 | if (prop.weight != rxvt_fontprop::unset |
640 | if (force_prop) |
659 | || prop.slant != rxvt_fontprop::unset) |
|
|
660 | { |
641 | { |
661 | char fname[1024]; |
642 | char fname[1024]; |
662 | |
643 | |
663 | if (name[0] != '-') |
644 | if (name[0] != '-') |
664 | { |
645 | { |
… | |
… | |
861 | |
842 | |
862 | XCharStruct g; |
843 | XCharStruct g; |
863 | int dir_ret, asc_ret, des_ret; |
844 | int dir_ret, asc_ret, des_ret; |
864 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
845 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
865 | |
846 | |
|
|
847 | int wcw = WCWIDTH (*t); |
866 | int wcw = WCWIDTH (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
848 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
867 | |
849 | |
868 | if (width < g.width) width = g.width; |
850 | if (width < g.width) width = g.width; |
869 | } |
851 | } |
870 | |
852 | |
871 | if (cs == CS_UNKNOWN) |
853 | if (cs == CS_UNKNOWN) |
… | |
… | |
890 | void |
872 | void |
891 | rxvt_font_x11::clear () |
873 | rxvt_font_x11::clear () |
892 | { |
874 | { |
893 | if (f) |
875 | if (f) |
894 | { |
876 | { |
895 | XFreeFont (term->xdisp, f); |
877 | XFreeFont (term->dpy, f); |
896 | f = 0; |
878 | f = 0; |
897 | } |
879 | } |
898 | } |
880 | } |
899 | |
881 | |
900 | bool |
882 | bool |
… | |
… | |
945 | if (!prop || prop->width == rxvt_fontprop::unset) |
927 | if (!prop || prop->width == rxvt_fontprop::unset) |
946 | return true; |
928 | return true; |
947 | |
929 | |
948 | // check wether character overlaps previous/next character |
930 | // check wether character overlaps previous/next character |
949 | int w = xcs->rbearing - xcs->lbearing; |
931 | int w = xcs->rbearing - xcs->lbearing; |
950 | int wcw = WCWIDTH (unicode); |
932 | int wcw = max (WCWIDTH (unicode), 1); |
951 | |
933 | |
952 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
934 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
953 | |
935 | |
954 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
936 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
955 | return false; |
937 | return false; |
… | |
… | |
1055 | |
1037 | |
1056 | void clear (); |
1038 | void clear (); |
1057 | |
1039 | |
1058 | rxvt_fontprop properties (); |
1040 | rxvt_fontprop properties (); |
1059 | |
1041 | |
1060 | bool load (const rxvt_fontprop &prop); |
1042 | bool load (const rxvt_fontprop &prop, bool force_prop); |
1061 | |
1043 | |
1062 | void draw (rxvt_drawable &d, int x, int y, |
1044 | void draw (rxvt_drawable &d, int x, int y, |
1063 | const text_t *text, int len, |
1045 | const text_t *text, int len, |
1064 | int fg, int bg); |
1046 | int fg, int bg); |
1065 | |
1047 | |
… | |
… | |
1072 | void |
1054 | void |
1073 | rxvt_font_xft::clear () |
1055 | rxvt_font_xft::clear () |
1074 | { |
1056 | { |
1075 | if (f) |
1057 | if (f) |
1076 | { |
1058 | { |
1077 | XftFontClose (term->xdisp, f); |
1059 | XftFontClose (term->dpy, f); |
1078 | f = 0; |
1060 | f = 0; |
1079 | } |
1061 | } |
1080 | } |
1062 | } |
1081 | |
1063 | |
1082 | rxvt_fontprop |
1064 | rxvt_fontprop |
… | |
… | |
1098 | |
1080 | |
1099 | return p; |
1081 | return p; |
1100 | } |
1082 | } |
1101 | |
1083 | |
1102 | bool |
1084 | bool |
1103 | rxvt_font_xft::load (const rxvt_fontprop &prop) |
1085 | rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop) |
1104 | { |
1086 | { |
1105 | dTermDisplay; |
1087 | dTermDisplay; |
1106 | |
1088 | |
1107 | clear (); |
1089 | clear (); |
1108 | |
1090 | |
… | |
… | |
1117 | && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch |
1099 | && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch |
1118 | && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) |
1100 | && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) |
1119 | FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); |
1101 | FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); |
1120 | |
1102 | |
1121 | if (prop.weight != rxvt_fontprop::unset |
1103 | if (prop.weight != rxvt_fontprop::unset |
1122 | && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) |
1104 | && (force_prop || FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch)) |
1123 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
1105 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
1124 | |
1106 | |
1125 | if (prop.slant != rxvt_fontprop::unset |
1107 | if (prop.slant != rxvt_fontprop::unset |
1126 | && FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) |
1108 | && (force_prop || FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch)) |
1127 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1109 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1128 | |
1110 | |
1129 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1111 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1130 | // clip width, we can't do better, or can we? |
1112 | // clip width, we can't do better, or can we? |
1131 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
1113 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
… | |
… | |
1249 | bool |
1231 | bool |
1250 | rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
1232 | rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
1251 | { |
1233 | { |
1252 | careful = false; |
1234 | careful = false; |
1253 | |
1235 | |
1254 | if (!XftCharExists (term->xdisp, f, unicode)) |
1236 | if (!XftCharExists (term->dpy, f, unicode)) |
1255 | return false; |
1237 | return false; |
1256 | |
1238 | |
1257 | if (!prop || prop->width == rxvt_fontprop::unset) |
1239 | if (!prop || prop->width == rxvt_fontprop::unset) |
1258 | return true; |
1240 | return true; |
1259 | |
1241 | |
1260 | // check character against base font bounding box |
1242 | // check character against base font bounding box |
1261 | FcChar32 ch = unicode; |
1243 | FcChar32 ch = unicode; |
1262 | XGlyphInfo g; |
1244 | XGlyphInfo g; |
1263 | XftTextExtents32 (term->xdisp, f, &ch, 1, &g); |
1245 | XftTextExtents32 (term->dpy, f, &ch, 1, &g); |
1264 | |
1246 | |
1265 | int w = g.width - g.x; |
1247 | int w = g.width - g.x; |
1266 | int wcw = WCWIDTH (unicode); |
1248 | int wcw = max (WCWIDTH (unicode), 1); |
1267 | |
1249 | |
1268 | careful = g.x > 0 || w > prop->width * wcw; |
1250 | careful = g.x > 0 || w > prop->width * wcw; |
1269 | |
1251 | |
1270 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
1252 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
1271 | return false; |
1253 | return false; |
… | |
… | |
1280 | void |
1262 | void |
1281 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1263 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1282 | const text_t *text, int len, |
1264 | const text_t *text, int len, |
1283 | int fg, int bg) |
1265 | int fg, int bg) |
1284 | { |
1266 | { |
1285 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
|
|
1286 | |
|
|
1287 | XGlyphInfo extents; |
1267 | XGlyphInfo extents; |
1288 | XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); |
1268 | XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); |
1289 | XftGlyphSpec *ep = enc; |
1269 | XftGlyphSpec *ep = enc; |
1290 | |
1270 | |
1291 | dTermDisplay; |
1271 | dTermDisplay; |
1292 | dTermGC; |
1272 | dTermGC; |
1293 | |
1273 | |
|
|
1274 | int w = term->fwidth * len; |
|
|
1275 | int h = term->fheight; |
|
|
1276 | |
|
|
1277 | /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency. |
|
|
1278 | * Maybe make buffering into a resource flag? Compile time option doesn't seems like a |
|
|
1279 | * good idea from the perspective of packaging for wide variety of user configs. |
|
|
1280 | */ |
|
|
1281 | bool buffered = true |
|
|
1282 | #ifdef FORCE_UNBUFFERED_XFT |
|
|
1283 | && bg >= 0 |
|
|
1284 | #endif |
|
|
1285 | ; |
1294 | // cut trailing spaces |
1286 | // cut trailing spaces |
1295 | while (len && text [len - 1] == ' ') |
1287 | while (len && text [len - 1] == ' ') |
1296 | len--; |
1288 | len--; |
|
|
1289 | |
|
|
1290 | int x_ = buffered ? 0 : x; |
|
|
1291 | int y_ = buffered ? 0 : y; |
1297 | |
1292 | |
1298 | while (len) |
1293 | while (len) |
1299 | { |
1294 | { |
1300 | int cwidth = term->fwidth; |
1295 | int cwidth = term->fwidth; |
1301 | FcChar32 fc = *text++; len--; |
1296 | FcChar32 fc = *text++; len--; |
… | |
… | |
1306 | if (fc != ' ') // skip spaces |
1301 | if (fc != ' ') // skip spaces |
1307 | { |
1302 | { |
1308 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1303 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1309 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1304 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1310 | |
1305 | |
1311 | |
|
|
1312 | ep->glyph = glyph; |
1306 | ep->glyph = glyph; |
1313 | ep->x = x + (cwidth - extents.xOff >> 1); |
1307 | ep->x = x_ + (cwidth - extents.xOff >> 1); |
1314 | ep->y = y + ascent; |
1308 | ep->y = y_ + ascent; |
1315 | |
1309 | |
1316 | if (extents.xOff == 0) |
1310 | if (extents.xOff == 0) |
1317 | ep->x = x + cwidth; |
1311 | ep->x = x_ + cwidth; |
1318 | |
1312 | |
1319 | ep++; |
1313 | ep++; |
1320 | } |
1314 | } |
1321 | |
1315 | |
1322 | x += cwidth; |
1316 | x_ += cwidth; |
|
|
1317 | } |
|
|
1318 | |
|
|
1319 | if (buffered) |
1323 | } |
1320 | { |
1324 | |
|
|
1325 | if (ep != enc) |
1321 | if (ep != enc) |
|
|
1322 | { |
|
|
1323 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
|
|
1324 | bool back_rendered = false; |
|
|
1325 | |
|
|
1326 | #ifdef HAVE_BG_PIXMAP |
|
|
1327 | if (term->bgPixmap.pixmap) |
|
|
1328 | { |
|
|
1329 | Picture dst = 0; |
|
|
1330 | if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00) |
|
|
1331 | dst = XftDrawPicture(d2); |
|
|
1332 | |
|
|
1333 | if (bg < 0 || dst != 0) |
|
|
1334 | { |
|
|
1335 | if (term->bgPixmap.pmap_width >= x + term->window_vt_x+w |
|
|
1336 | && term->bgPixmap.pmap_height >= y + term->window_vt_y+h) |
|
|
1337 | { |
|
|
1338 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
|
|
1339 | x + term->window_vt_x, y + term->window_vt_y, |
|
|
1340 | w, h, 0, 0); |
|
|
1341 | } |
|
|
1342 | else |
|
|
1343 | { |
|
|
1344 | XGCValues gcv; |
|
|
1345 | |
|
|
1346 | gcv.fill_style = FillTiled; |
|
|
1347 | gcv.tile = term->bgPixmap.pixmap; |
|
|
1348 | gcv.ts_x_origin = -x; |
|
|
1349 | gcv.ts_y_origin = -y; |
|
|
1350 | |
|
|
1351 | XChangeGC (disp, gc, |
|
|
1352 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
|
|
1353 | &gcv); |
|
|
1354 | |
|
|
1355 | XFillRectangle (disp, d2, gc, 0, 0, w, h); |
|
|
1356 | |
|
|
1357 | gcv.fill_style = FillSolid; |
|
|
1358 | XChangeGC (disp, gc, GCFillStyle, &gcv); |
|
|
1359 | } |
|
|
1360 | |
|
|
1361 | if (bg >= 0) |
|
|
1362 | { |
|
|
1363 | Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c); |
|
|
1364 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
|
|
1365 | } |
|
|
1366 | |
|
|
1367 | back_rendered = true; |
|
|
1368 | } |
|
|
1369 | } |
|
|
1370 | #endif |
|
|
1371 | |
|
|
1372 | if(bg >= 0 && !back_rendered) |
|
|
1373 | XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); |
|
|
1374 | |
|
|
1375 | XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); |
|
|
1376 | XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); |
|
|
1377 | } |
|
|
1378 | else |
|
|
1379 | clear_rect (d, x, y, w, h, bg); |
|
|
1380 | } |
|
|
1381 | else |
|
|
1382 | { |
|
|
1383 | clear_rect (d, x, y, w, h, bg); |
1326 | XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); |
1384 | XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); |
|
|
1385 | } |
1327 | } |
1386 | } |
|
|
1387 | |
1328 | #endif |
1388 | #endif |
1329 | |
1389 | |
1330 | ///////////////////////////////////////////////////////////////////////////// |
1390 | ///////////////////////////////////////////////////////////////////////////// |
1331 | |
1391 | |
1332 | rxvt_fontset::rxvt_fontset (rxvt_term *term) |
1392 | rxvt_fontset::rxvt_fontset (rxvt_term *term) |
… | |
… | |
1343 | void |
1403 | void |
1344 | rxvt_fontset::clear () |
1404 | rxvt_fontset::clear () |
1345 | { |
1405 | { |
1346 | prop.width = prop.height = prop.ascent = prop.weight = prop.slant |
1406 | prop.width = prop.height = prop.ascent = prop.weight = prop.slant |
1347 | = rxvt_fontprop::unset; |
1407 | = rxvt_fontprop::unset; |
|
|
1408 | force_prop = false; |
1348 | |
1409 | |
1349 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1410 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1350 | FONT_UNREF (*i); |
1411 | FONT_UNREF (*i); |
1351 | |
1412 | |
1352 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
1413 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
… | |
… | |
1464 | if (fonts[i]->loaded) |
1525 | if (fonts[i]->loaded) |
1465 | return true; |
1526 | return true; |
1466 | |
1527 | |
1467 | fonts[i]->loaded = true; |
1528 | fonts[i]->loaded = true; |
1468 | |
1529 | |
1469 | if (!fonts[i]->load (prop)) |
1530 | if (!fonts[i]->load (prop, force_prop)) |
1470 | { |
1531 | { |
1471 | fonts[i]->cs = CS_UNKNOWN; |
1532 | fonts[i]->cs = CS_UNKNOWN; |
1472 | return false; |
1533 | return false; |
1473 | } |
1534 | } |
1474 | |
1535 | |
… | |
… | |
1575 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1636 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1576 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1637 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1577 | //FcPatternAddBool (p, FC_ANTIALIAS, 1); |
1638 | //FcPatternAddBool (p, FC_ANTIALIAS, 1); |
1578 | |
1639 | |
1579 | XftResult result; |
1640 | XftResult result; |
1580 | FcPattern *match = XftFontMatch (term->xdisp, term->display->screen, p, &result); |
1641 | FcPattern *match = XftFontMatch (term->dpy, term->display->screen, p, &result); |
1581 | |
1642 | |
1582 | FcPatternDestroy (p); |
1643 | FcPatternDestroy (p); |
1583 | |
1644 | |
1584 | if (match) |
1645 | if (match) |
1585 | { |
1646 | { |