… | |
… | |
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 | |
165 | ///////////////////////////////////////////////////////////////////////////// |
166 | ///////////////////////////////////////////////////////////////////////////// |
166 | |
167 | |
167 | #if XFT |
168 | #if XFT |
… | |
… | |
172 | } |
173 | } |
173 | |
174 | |
174 | rxvt_drawable::operator XftDraw *() |
175 | rxvt_drawable::operator XftDraw *() |
175 | { |
176 | { |
176 | if (!xftdrawable) |
177 | if (!xftdrawable) |
177 | xftdrawable = XftDrawCreate (screen->xdisp, drawable, screen->visual, screen->cmap); |
178 | xftdrawable = XftDrawCreate (screen->dpy, drawable, screen->visual, screen->cmap); |
178 | |
179 | |
179 | return xftdrawable; |
180 | return xftdrawable; |
180 | } |
181 | } |
181 | #endif |
182 | #endif |
182 | |
183 | |
… | |
… | |
513 | rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const |
514 | rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const |
514 | { |
515 | { |
515 | unsigned long value; |
516 | unsigned long value; |
516 | |
517 | |
517 | if (XGetFontProperty (f, property, &value)) |
518 | if (XGetFontProperty (f, property, &value)) |
518 | return XGetAtomName (term->xdisp, value); |
519 | return XGetAtomName (term->dpy, value); |
519 | else |
520 | else |
520 | return rxvt_strdup (repl); |
521 | return rxvt_strdup (repl); |
521 | } |
522 | } |
522 | |
523 | |
523 | rxvt_fontprop |
524 | rxvt_fontprop |
… | |
… | |
546 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
547 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
547 | { |
548 | { |
548 | unsigned long height; |
549 | unsigned long height; |
549 | |
550 | |
550 | #if 0 |
551 | #if 0 |
551 | if (!XGetFontProperty (f, XInternAtom (term->xdisp, "PIXEL_SIZE", 0), &height)) |
552 | if (!XGetFontProperty (f, XInternAtom (term->dpy, "PIXEL_SIZE", 0), &height)) |
552 | return false; |
553 | return false; |
553 | #else |
554 | #else |
554 | height = f->ascent + f->descent; |
555 | height = f->ascent + f->descent; |
555 | #endif |
556 | #endif |
556 | |
557 | |
… | |
… | |
861 | |
862 | |
862 | XCharStruct g; |
863 | XCharStruct g; |
863 | int dir_ret, asc_ret, des_ret; |
864 | int dir_ret, asc_ret, des_ret; |
864 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
865 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
865 | |
866 | |
|
|
867 | int wcw = WCWIDTH (*t); |
866 | int wcw = WCWIDTH (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
868 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
867 | |
869 | |
868 | if (width < g.width) width = g.width; |
870 | if (width < g.width) width = g.width; |
869 | } |
871 | } |
870 | |
872 | |
871 | if (cs == CS_UNKNOWN) |
873 | if (cs == CS_UNKNOWN) |
… | |
… | |
890 | void |
892 | void |
891 | rxvt_font_x11::clear () |
893 | rxvt_font_x11::clear () |
892 | { |
894 | { |
893 | if (f) |
895 | if (f) |
894 | { |
896 | { |
895 | XFreeFont (term->xdisp, f); |
897 | XFreeFont (term->dpy, f); |
896 | f = 0; |
898 | f = 0; |
897 | } |
899 | } |
898 | } |
900 | } |
899 | |
901 | |
900 | bool |
902 | bool |
… | |
… | |
945 | if (!prop || prop->width == rxvt_fontprop::unset) |
947 | if (!prop || prop->width == rxvt_fontprop::unset) |
946 | return true; |
948 | return true; |
947 | |
949 | |
948 | // check wether character overlaps previous/next character |
950 | // check wether character overlaps previous/next character |
949 | int w = xcs->rbearing - xcs->lbearing; |
951 | int w = xcs->rbearing - xcs->lbearing; |
950 | int wcw = WCWIDTH (unicode); |
952 | int wcw = max (WCWIDTH (unicode), 1); |
951 | |
953 | |
952 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
954 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
953 | |
955 | |
954 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
956 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
955 | return false; |
957 | return false; |
… | |
… | |
1072 | void |
1074 | void |
1073 | rxvt_font_xft::clear () |
1075 | rxvt_font_xft::clear () |
1074 | { |
1076 | { |
1075 | if (f) |
1077 | if (f) |
1076 | { |
1078 | { |
1077 | XftFontClose (term->xdisp, f); |
1079 | XftFontClose (term->dpy, f); |
1078 | f = 0; |
1080 | f = 0; |
1079 | } |
1081 | } |
1080 | } |
1082 | } |
1081 | |
1083 | |
1082 | rxvt_fontprop |
1084 | rxvt_fontprop |
… | |
… | |
1249 | bool |
1251 | bool |
1250 | rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
1252 | rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
1251 | { |
1253 | { |
1252 | careful = false; |
1254 | careful = false; |
1253 | |
1255 | |
1254 | if (!XftCharExists (term->xdisp, f, unicode)) |
1256 | if (!XftCharExists (term->dpy, f, unicode)) |
1255 | return false; |
1257 | return false; |
1256 | |
1258 | |
1257 | if (!prop || prop->width == rxvt_fontprop::unset) |
1259 | if (!prop || prop->width == rxvt_fontprop::unset) |
1258 | return true; |
1260 | return true; |
1259 | |
1261 | |
1260 | // check character against base font bounding box |
1262 | // check character against base font bounding box |
1261 | FcChar32 ch = unicode; |
1263 | FcChar32 ch = unicode; |
1262 | XGlyphInfo g; |
1264 | XGlyphInfo g; |
1263 | XftTextExtents32 (term->xdisp, f, &ch, 1, &g); |
1265 | XftTextExtents32 (term->dpy, f, &ch, 1, &g); |
1264 | |
1266 | |
1265 | int w = g.width - g.x; |
1267 | int w = g.width - g.x; |
1266 | int wcw = WCWIDTH (unicode); |
1268 | int wcw = max (WCWIDTH (unicode), 1); |
1267 | |
1269 | |
1268 | careful = g.x > 0 || w > prop->width * wcw; |
1270 | careful = g.x > 0 || w > prop->width * wcw; |
1269 | |
1271 | |
1270 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
1272 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
1271 | return false; |
1273 | return false; |
… | |
… | |
1305 | |
1307 | |
1306 | if (fc != ' ') // skip spaces |
1308 | if (fc != ' ') // skip spaces |
1307 | { |
1309 | { |
1308 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1310 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1309 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1311 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1310 | |
|
|
1311 | |
1312 | |
1312 | ep->glyph = glyph; |
1313 | ep->glyph = glyph; |
1313 | ep->x = x + (cwidth - extents.xOff >> 1); |
1314 | ep->x = x + (cwidth - extents.xOff >> 1); |
1314 | ep->y = y + ascent; |
1315 | ep->y = y + ascent; |
1315 | |
1316 | |
… | |
… | |
1575 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1576 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1576 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1577 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1577 | //FcPatternAddBool (p, FC_ANTIALIAS, 1); |
1578 | //FcPatternAddBool (p, FC_ANTIALIAS, 1); |
1578 | |
1579 | |
1579 | XftResult result; |
1580 | XftResult result; |
1580 | FcPattern *match = XftFontMatch (term->xdisp, term->display->screen, p, &result); |
1581 | FcPattern *match = XftFontMatch (term->dpy, term->display->screen, p, &result); |
1581 | |
1582 | |
1582 | FcPatternDestroy (p); |
1583 | FcPatternDestroy (p); |
1583 | |
1584 | |
1584 | if (match) |
1585 | if (match) |
1585 | { |
1586 | { |