… | |
… | |
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) |
… | |
… | |
513 | rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const |
496 | rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const |
514 | { |
497 | { |
515 | unsigned long value; |
498 | unsigned long value; |
516 | |
499 | |
517 | if (XGetFontProperty (f, property, &value)) |
500 | if (XGetFontProperty (f, property, &value)) |
518 | return XGetAtomName (term->xdisp, value); |
501 | return XGetAtomName (term->dpy, value); |
519 | else |
502 | else |
520 | return rxvt_strdup (repl); |
503 | return rxvt_strdup (repl); |
521 | } |
504 | } |
522 | |
505 | |
523 | rxvt_fontprop |
506 | rxvt_fontprop |
… | |
… | |
546 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
529 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
547 | { |
530 | { |
548 | unsigned long height; |
531 | unsigned long height; |
549 | |
532 | |
550 | #if 0 |
533 | #if 0 |
551 | if (!XGetFontProperty (f, XInternAtom (term->xdisp, "PIXEL_SIZE", 0), &height)) |
534 | if (!XGetFontProperty (f, XInternAtom (term->dpy, "PIXEL_SIZE", 0), &height)) |
552 | return false; |
535 | return false; |
553 | #else |
536 | #else |
554 | height = f->ascent + f->descent; |
537 | height = f->ascent + f->descent; |
555 | #endif |
538 | #endif |
556 | |
539 | |
… | |
… | |
861 | |
844 | |
862 | XCharStruct g; |
845 | XCharStruct g; |
863 | int dir_ret, asc_ret, des_ret; |
846 | int dir_ret, asc_ret, des_ret; |
864 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
847 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
865 | |
848 | |
|
|
849 | int wcw = WCWIDTH (*t); |
866 | int wcw = WCWIDTH (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
850 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
867 | |
851 | |
868 | if (width < g.width) width = g.width; |
852 | if (width < g.width) width = g.width; |
869 | } |
853 | } |
870 | |
854 | |
871 | if (cs == CS_UNKNOWN) |
855 | if (cs == CS_UNKNOWN) |
… | |
… | |
890 | void |
874 | void |
891 | rxvt_font_x11::clear () |
875 | rxvt_font_x11::clear () |
892 | { |
876 | { |
893 | if (f) |
877 | if (f) |
894 | { |
878 | { |
895 | XFreeFont (term->xdisp, f); |
879 | XFreeFont (term->dpy, f); |
896 | f = 0; |
880 | f = 0; |
897 | } |
881 | } |
898 | } |
882 | } |
899 | |
883 | |
900 | bool |
884 | bool |
… | |
… | |
945 | if (!prop || prop->width == rxvt_fontprop::unset) |
929 | if (!prop || prop->width == rxvt_fontprop::unset) |
946 | return true; |
930 | return true; |
947 | |
931 | |
948 | // check wether character overlaps previous/next character |
932 | // check wether character overlaps previous/next character |
949 | int w = xcs->rbearing - xcs->lbearing; |
933 | int w = xcs->rbearing - xcs->lbearing; |
950 | int wcw = WCWIDTH (unicode); |
934 | int wcw = max (WCWIDTH (unicode), 1); |
951 | |
935 | |
952 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
936 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
953 | |
937 | |
954 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
938 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
955 | return false; |
939 | return false; |
… | |
… | |
1072 | void |
1056 | void |
1073 | rxvt_font_xft::clear () |
1057 | rxvt_font_xft::clear () |
1074 | { |
1058 | { |
1075 | if (f) |
1059 | if (f) |
1076 | { |
1060 | { |
1077 | XftFontClose (term->xdisp, f); |
1061 | XftFontClose (term->dpy, f); |
1078 | f = 0; |
1062 | f = 0; |
1079 | } |
1063 | } |
1080 | } |
1064 | } |
1081 | |
1065 | |
1082 | rxvt_fontprop |
1066 | rxvt_fontprop |
… | |
… | |
1249 | bool |
1233 | bool |
1250 | rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
1234 | rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
1251 | { |
1235 | { |
1252 | careful = false; |
1236 | careful = false; |
1253 | |
1237 | |
1254 | if (!XftCharExists (term->xdisp, f, unicode)) |
1238 | if (!XftCharExists (term->dpy, f, unicode)) |
1255 | return false; |
1239 | return false; |
1256 | |
1240 | |
1257 | if (!prop || prop->width == rxvt_fontprop::unset) |
1241 | if (!prop || prop->width == rxvt_fontprop::unset) |
1258 | return true; |
1242 | return true; |
1259 | |
1243 | |
1260 | // check character against base font bounding box |
1244 | // check character against base font bounding box |
1261 | FcChar32 ch = unicode; |
1245 | FcChar32 ch = unicode; |
1262 | XGlyphInfo g; |
1246 | XGlyphInfo g; |
1263 | XftTextExtents32 (term->xdisp, f, &ch, 1, &g); |
1247 | XftTextExtents32 (term->dpy, f, &ch, 1, &g); |
1264 | |
1248 | |
1265 | int w = g.width - g.x; |
1249 | int w = g.width - g.x; |
1266 | int wcw = WCWIDTH (unicode); |
1250 | int wcw = max (WCWIDTH (unicode), 1); |
1267 | |
1251 | |
1268 | careful = g.x > 0 || w > prop->width * wcw; |
1252 | careful = g.x > 0 || w > prop->width * wcw; |
1269 | |
1253 | |
1270 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
1254 | if (careful && !OVERLAP_OK (w, wcw, prop)) |
1271 | return false; |
1255 | return false; |
… | |
… | |
1280 | void |
1264 | void |
1281 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1265 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1282 | const text_t *text, int len, |
1266 | const text_t *text, int len, |
1283 | int fg, int bg) |
1267 | int fg, int bg) |
1284 | { |
1268 | { |
1285 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
|
|
1286 | |
|
|
1287 | XGlyphInfo extents; |
1269 | XGlyphInfo extents; |
1288 | XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); |
1270 | XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); |
1289 | XftGlyphSpec *ep = enc; |
1271 | XftGlyphSpec *ep = enc; |
1290 | |
1272 | |
1291 | dTermDisplay; |
1273 | dTermDisplay; |
1292 | dTermGC; |
1274 | dTermGC; |
1293 | |
1275 | |
|
|
1276 | int w = term->fwidth * len; |
|
|
1277 | int h = term->fheight; |
|
|
1278 | |
|
|
1279 | bool buffered = false; |
|
|
1280 | |
1294 | // cut trailing spaces |
1281 | // cut trailing spaces |
1295 | while (len && text [len - 1] == ' ') |
1282 | while (len && text [len - 1] == ' ') |
1296 | len--; |
1283 | len--; |
|
|
1284 | |
|
|
1285 | int x_ = buffered ? 0 : x; |
|
|
1286 | int y_ = buffered ? 0 : y; |
1297 | |
1287 | |
1298 | while (len) |
1288 | while (len) |
1299 | { |
1289 | { |
1300 | int cwidth = term->fwidth; |
1290 | int cwidth = term->fwidth; |
1301 | FcChar32 fc = *text++; len--; |
1291 | FcChar32 fc = *text++; len--; |
… | |
… | |
1306 | if (fc != ' ') // skip spaces |
1296 | if (fc != ' ') // skip spaces |
1307 | { |
1297 | { |
1308 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1298 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1309 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1299 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1310 | |
1300 | |
1311 | |
|
|
1312 | ep->glyph = glyph; |
1301 | ep->glyph = glyph; |
1313 | ep->x = x + (cwidth - extents.xOff >> 1); |
1302 | ep->x = x_ + (cwidth - extents.xOff >> 1); |
1314 | ep->y = y + ascent; |
1303 | ep->y = y_ + ascent; |
1315 | |
1304 | |
1316 | if (extents.xOff == 0) |
1305 | if (extents.xOff == 0) |
1317 | ep->x = x + cwidth; |
1306 | ep->x = x_ + cwidth; |
1318 | |
1307 | |
1319 | ep++; |
1308 | ep++; |
1320 | } |
1309 | } |
1321 | |
1310 | |
1322 | x += cwidth; |
1311 | x_ += cwidth; |
|
|
1312 | } |
|
|
1313 | |
|
|
1314 | if (buffered) |
1323 | } |
1315 | { |
1324 | |
|
|
1325 | if (ep != enc) |
1316 | if (ep != enc) |
|
|
1317 | { |
|
|
1318 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
|
|
1319 | |
|
|
1320 | XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); |
|
|
1321 | |
|
|
1322 | XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); |
|
|
1323 | XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); |
|
|
1324 | } |
|
|
1325 | else |
|
|
1326 | clear_rect (d, x, y, w, h, bg); |
|
|
1327 | } |
|
|
1328 | else |
|
|
1329 | { |
|
|
1330 | clear_rect (d, x, y, w, h, bg); |
1326 | XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); |
1331 | XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); |
|
|
1332 | } |
1327 | } |
1333 | } |
|
|
1334 | |
1328 | #endif |
1335 | #endif |
1329 | |
1336 | |
1330 | ///////////////////////////////////////////////////////////////////////////// |
1337 | ///////////////////////////////////////////////////////////////////////////// |
1331 | |
1338 | |
1332 | rxvt_fontset::rxvt_fontset (rxvt_term *term) |
1339 | rxvt_fontset::rxvt_fontset (rxvt_term *term) |
… | |
… | |
1575 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1582 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1576 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1583 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1577 | //FcPatternAddBool (p, FC_ANTIALIAS, 1); |
1584 | //FcPatternAddBool (p, FC_ANTIALIAS, 1); |
1578 | |
1585 | |
1579 | XftResult result; |
1586 | XftResult result; |
1580 | FcPattern *match = XftFontMatch (term->xdisp, term->display->screen, p, &result); |
1587 | FcPattern *match = XftFontMatch (term->dpy, term->display->screen, p, &result); |
1581 | |
1588 | |
1582 | FcPatternDestroy (p); |
1589 | FcPatternDestroy (p); |
1583 | |
1590 | |
1584 | if (match) |
1591 | if (match) |
1585 | { |
1592 | { |