1 | /*----------------------------------------------------------------------* |
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-2008 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 |
8 | * it under the terms of the GNU General Public License as published by |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
9 | * the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
79 | |
79 | |
80 | // japanese |
80 | // japanese |
81 | #if ENCODING_JP || ENCODING_JP_EXT |
81 | #if ENCODING_JP || ENCODING_JP_EXT |
82 | # if XFT |
82 | # if XFT |
83 | // prefer xft for complex scripts |
83 | // prefer xft for complex scripts |
|
|
84 | { CS_JIS0208_1990_0, "xft:Sazanami Mincho:antialias=false" }, |
84 | { CS_JIS0208_1990_0, "xft:Kochi Gothic:antialias=false" }, |
85 | { CS_JIS0208_1990_0, "xft:Kochi Gothic:antialias=false" }, |
85 | { CS_JIS0208_1990_0, "xft:Sazanami Mincho:antialias=false" }, |
|
|
86 | { CS_JIS0208_1990_0, "xft:Mincho:antialias=false" }, |
86 | { CS_JIS0208_1990_0, "xft:Mincho:antialias=false" }, |
87 | { CS_JIS0208_1990_0, "xft::lang=ja:antialias=false" }, |
87 | { CS_JIS0208_1990_0, "xft::lang=ja:antialias=false" }, |
88 | # endif |
88 | # endif |
89 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
89 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
90 | { CS_JIS0208_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
90 | { CS_JIS0208_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
… | |
… | |
216 | : name(0), width(rxvt_fontprop::unset), height(rxvt_fontprop::unset) |
216 | : name(0), width(rxvt_fontprop::unset), height(rxvt_fontprop::unset) |
217 | { |
217 | { |
218 | } |
218 | } |
219 | |
219 | |
220 | void |
220 | void |
221 | rxvt_font::set_name (char *name) |
221 | rxvt_font::set_name (char *name_) |
222 | { |
222 | { |
223 | if (this->name == name) |
223 | if (name == name_) |
224 | return; |
224 | return; |
225 | |
225 | |
226 | if (this->name) free (this->name); // let the compiler optimize |
226 | if (name) free (name); // let the compiler optimize |
227 | this->name = name; |
227 | name = name_; |
228 | } |
228 | } |
229 | |
229 | |
230 | void |
230 | void |
231 | rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const |
231 | rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const |
232 | { |
232 | { |
… | |
… | |
236 | if (color == Color_bg || color == Color_transparent) |
236 | if (color == Color_bg || color == Color_transparent) |
237 | XClearArea (disp, d, x, y, w, h, false); |
237 | XClearArea (disp, d, x, y, w, h, false); |
238 | else if (color >= 0) |
238 | else if (color >= 0) |
239 | { |
239 | { |
240 | #if XFT |
240 | #if XFT |
241 | bool done = false; |
241 | Picture dst; |
242 | |
242 | |
243 | # ifdef HAVE_BG_PIXMAP |
243 | # ifdef HAVE_BG_PIXMAP |
244 | if (term->bgPixmap.pixmap && color >= 0 && !term->pix_colors[color].is_opaque ()) |
244 | if (term->bgPixmap.pixmap |
245 | { |
245 | && !term->pix_colors[color].is_opaque () |
246 | Picture dst = XftDrawPicture (d); |
246 | && ((dst = XftDrawPicture (d)))) |
247 | |
|
|
248 | if (dst != 0) |
|
|
249 | { |
247 | { |
250 | XClearArea (disp, d, x, y, w, h, false); |
248 | XClearArea (disp, d, x, y, w, h, false); |
|
|
249 | |
251 | Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c); |
250 | Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c); |
252 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, x, y, w, h); |
251 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, x, y, w, h); |
253 | done = true; |
|
|
254 | } |
252 | } |
255 | } |
253 | else |
256 | # endif |
254 | # endif |
257 | if (!done) |
|
|
258 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
255 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
259 | |
256 | |
260 | #else |
257 | #else |
261 | XSetForeground (disp, gc, term->pix_colors[color]); |
258 | XSetForeground (disp, gc, term->pix_colors[color]); |
262 | XFillRectangle (disp, d, gc, x, y, w, h); |
259 | XFillRectangle (disp, d, gc, x, y, w, h); |
… | |
… | |
485 | |
482 | |
486 | x += fwidth; |
483 | x += fwidth; |
487 | } |
484 | } |
488 | } |
485 | } |
489 | |
486 | |
|
|
487 | struct rxvt_font_meta : rxvt_font { |
|
|
488 | struct rxvt_fontset *fs; |
|
|
489 | |
|
|
490 | rxvt_font_meta (rxvt_fontset *fs) |
|
|
491 | : rxvt_font () |
|
|
492 | { |
|
|
493 | this->fs = fs; |
|
|
494 | } |
|
|
495 | |
|
|
496 | rxvt_fontprop properties () |
|
|
497 | { |
|
|
498 | rxvt_fontprop p; |
|
|
499 | |
|
|
500 | p.width = p.height = 1; |
|
|
501 | p.ascent = rxvt_fontprop::unset; |
|
|
502 | p.weight = rxvt_fontprop::medium; |
|
|
503 | p.slant = rxvt_fontprop::roman; |
|
|
504 | |
|
|
505 | return p; |
|
|
506 | } |
|
|
507 | |
|
|
508 | bool load (const rxvt_fontprop &prop, bool force_prop) |
|
|
509 | { |
|
|
510 | width = 1; height = 1; |
|
|
511 | ascent = 1; descent = 0; |
|
|
512 | |
|
|
513 | set_name (strdup ("built-in meta font")); |
|
|
514 | |
|
|
515 | return true; |
|
|
516 | } |
|
|
517 | |
|
|
518 | bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
|
|
519 | { |
|
|
520 | return false; |
|
|
521 | } |
|
|
522 | |
|
|
523 | void draw (rxvt_drawable &d, int x, int y, |
|
|
524 | const text_t *text, int len, |
|
|
525 | int fg, int bg) |
|
|
526 | { |
|
|
527 | while (len--) |
|
|
528 | { |
|
|
529 | int fid = fs->find_font_idx (*text); |
|
|
530 | (*fs)[fid]->draw (d, x, y, text, 1, fg, bg); |
|
|
531 | ++text; |
|
|
532 | x += term->fwidth; |
|
|
533 | } |
|
|
534 | } |
|
|
535 | }; |
|
|
536 | |
490 | ///////////////////////////////////////////////////////////////////////////// |
537 | ///////////////////////////////////////////////////////////////////////////// |
491 | |
538 | |
492 | struct rxvt_font_x11 : rxvt_font { |
539 | struct rxvt_font_x11 : rxvt_font { |
493 | rxvt_font_x11 () { f = 0; } |
540 | rxvt_font_x11 () { f = 0; } |
494 | |
541 | |
… | |
… | |
502 | |
549 | |
503 | void draw (rxvt_drawable &d, int x, int y, |
550 | void draw (rxvt_drawable &d, int x, int y, |
504 | const text_t *text, int len, |
551 | const text_t *text, int len, |
505 | int fg, int bg); |
552 | int fg, int bg); |
506 | |
553 | |
507 | bool slow; // wether this is a proportional font or has other funny characteristics |
554 | bool slow; // whether this is a proportional font or has other funny characteristics |
508 | XFontStruct *f; |
555 | XFontStruct *f; |
509 | bool enc2b, encm; |
556 | bool enc2b, encm; |
510 | |
557 | |
511 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
558 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
512 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
559 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
… | |
… | |
795 | return false; |
842 | return false; |
796 | |
843 | |
797 | char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); |
844 | char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); |
798 | char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); |
845 | char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); |
799 | |
846 | |
|
|
847 | cs = CS_UNKNOWN; |
|
|
848 | |
800 | if (registry && encoding) |
849 | if (registry && encoding) |
801 | { |
850 | { |
802 | char charset[64]; |
851 | char charset[64]; |
803 | snprintf (charset, 64, "%s-%s", registry, encoding); |
852 | snprintf (charset, 64, "%s-%s", registry, encoding); |
804 | |
853 | |
805 | cs = codeset_from_name (charset); |
854 | cs = codeset_from_name (charset); |
|
|
855 | |
|
|
856 | if (cs == CS_UNKNOWN) |
|
|
857 | rxvt_warn ("%s: cannot deduce encoding from registry/encoding properties \"%s\", ignoring font.\n", name, charset); |
806 | } |
858 | } |
807 | else |
859 | |
|
|
860 | free (registry); |
|
|
861 | free (encoding); |
|
|
862 | |
|
|
863 | if (cs == CS_UNKNOWN) |
808 | { |
864 | { |
809 | const char *charset = get_property (f, XA_FONT, 0); |
865 | const char *charset = get_property (f, XA_FONT, 0); |
810 | |
866 | |
811 | if (!charset) |
867 | if (!charset) |
812 | charset = name; |
868 | charset = name; |
… | |
… | |
815 | while (*charset) |
871 | while (*charset) |
816 | if (*charset++ == '-' && !--count) |
872 | if (*charset++ == '-' && !--count) |
817 | break; |
873 | break; |
818 | |
874 | |
819 | cs = codeset_from_name (charset); |
875 | cs = codeset_from_name (charset); |
|
|
876 | if (cs == CS_UNKNOWN) |
|
|
877 | rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset); |
|
|
878 | } |
|
|
879 | |
|
|
880 | if (cs == CS_UNKNOWN) |
820 | } |
881 | { |
821 | |
882 | clear (); |
822 | free (registry); |
883 | return false; |
823 | free (encoding); |
884 | } |
824 | |
885 | |
825 | if (cs == CS_UNICODE) |
886 | if (cs == CS_UNICODE) |
826 | cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font |
887 | cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font |
827 | |
888 | |
828 | encm = f->min_byte1 != 0 || f->max_byte1 != 0; |
889 | encm = f->min_byte1 != 0 || f->max_byte1 != 0; |
… | |
… | |
875 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
936 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
876 | |
937 | |
877 | if (width < g.width) width = g.width; |
938 | if (width < g.width) width = g.width; |
878 | } |
939 | } |
879 | |
940 | |
880 | if (cs == CS_UNKNOWN) |
941 | #if 0 // do it per-character |
|
|
942 | if (prop && width > prop->width) |
881 | { |
943 | { |
882 | fprintf (stderr, "unable to deduce codeset, ignoring font '%s'\n", name); |
|
|
883 | |
|
|
884 | clear (); |
944 | clear (); |
885 | return false; |
945 | return false; |
886 | } |
946 | } |
887 | |
|
|
888 | #if 0 // do it per-character |
|
|
889 | if (prop && width > prop->width) |
|
|
890 | { |
|
|
891 | clear (); |
|
|
892 | return false; |
|
|
893 | } |
|
|
894 | #endif |
947 | #endif |
895 | |
948 | |
896 | return true; |
949 | return true; |
897 | } |
950 | } |
898 | |
951 | |
… | |
… | |
912 | uint32_t ch = FROM_UNICODE (cs, unicode); |
965 | uint32_t ch = FROM_UNICODE (cs, unicode); |
913 | |
966 | |
914 | if (ch == NOCHAR) |
967 | if (ch == NOCHAR) |
915 | return false; |
968 | return false; |
916 | |
969 | |
917 | /* check wether the character exists in _this_ font. horrible. */ |
970 | /* check whether the character exists in _this_ font. horrible. */ |
918 | XCharStruct *xcs; |
971 | XCharStruct *xcs; |
919 | |
972 | |
920 | if (encm) |
973 | if (encm) |
921 | { |
974 | { |
922 | unsigned char byte1 = ch >> 8; |
975 | unsigned char byte1 = ch >> 8; |
… | |
… | |
952 | return false; |
1005 | return false; |
953 | |
1006 | |
954 | if (!prop || prop->width == rxvt_fontprop::unset) |
1007 | if (!prop || prop->width == rxvt_fontprop::unset) |
955 | return true; |
1008 | return true; |
956 | |
1009 | |
957 | // check wether character overlaps previous/next character |
1010 | // check whether character overlaps previous/next character |
958 | int w = xcs->rbearing - xcs->lbearing; |
1011 | int w = xcs->rbearing - xcs->lbearing; |
959 | int wcw = max (WCWIDTH (unicode), 1); |
1012 | int wcw = max (WCWIDTH (unicode), 1); |
960 | |
1013 | |
961 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
1014 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
962 | |
1015 | |
… | |
… | |
1136 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1189 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1137 | |
1190 | |
1138 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1191 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1139 | // clip width, we can't do better, or can we? |
1192 | // clip width, we can't do better, or can we? |
1140 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
1193 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
1141 | FcPatternAddInteger (p, FC_CHAR_WIDTH, prop->width); |
1194 | FcPatternAddInteger (p, FC_CHAR_WIDTH, prop.width); |
1142 | #endif |
1195 | #endif |
1143 | |
1196 | |
1144 | if (FcPatternGet (p, FC_MINSPACE, 0, &v) != FcResultMatch) |
1197 | if (FcPatternGet (p, FC_MINSPACE, 0, &v) != FcResultMatch) |
1145 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1198 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1146 | |
1199 | |
… | |
… | |
1290 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1343 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1291 | const text_t *text, int len, |
1344 | const text_t *text, int len, |
1292 | int fg, int bg) |
1345 | int fg, int bg) |
1293 | { |
1346 | { |
1294 | XGlyphInfo extents; |
1347 | XGlyphInfo extents; |
1295 | XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); |
1348 | XftGlyphSpec *enc = rxvt_temp_buf<XftGlyphSpec> (len); |
1296 | XftGlyphSpec *ep = enc; |
1349 | XftGlyphSpec *ep = enc; |
1297 | |
1350 | |
1298 | dTermDisplay; |
1351 | dTermDisplay; |
1299 | dTermGC; |
1352 | dTermGC; |
1300 | |
1353 | |
1301 | int w = term->fwidth * len; |
1354 | int w = term->fwidth * len; |
1302 | int h = term->fheight; |
1355 | int h = term->fheight; |
1303 | |
1356 | |
1304 | /* |
|
|
1305 | * Maybe make buffering into a resource flag? Compile time option doesn't seems like a |
|
|
1306 | * good idea from the perspective of packaging for wide variety of user configs. |
|
|
1307 | */ |
|
|
1308 | bool buffered = bg >= Color_transparent; |
1357 | bool buffered = bg >= Color_transparent |
1309 | #ifdef FORCE_UNBUFFERED_XFT |
1358 | && term->option (Opt_buffered); |
1310 | buffered = false; |
|
|
1311 | #endif |
|
|
1312 | |
1359 | |
1313 | // cut trailing spaces |
1360 | // cut trailing spaces |
1314 | while (len && text [len - 1] == ' ') |
1361 | while (len && text [len - 1] == ' ') |
1315 | len--; |
1362 | len--; |
1316 | |
1363 | |
… | |
… | |
1345 | |
1392 | |
1346 | if (buffered) |
1393 | if (buffered) |
1347 | { |
1394 | { |
1348 | if (ep != enc) |
1395 | if (ep != enc) |
1349 | { |
1396 | { |
1350 | bool back_rendered = false; |
|
|
1351 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1397 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1352 | |
1398 | |
1353 | #ifdef HAVE_BG_PIXMAP |
1399 | #ifdef HAVE_BG_PIXMAP |
|
|
1400 | Picture dst = 0; // the only assignment is done conditionally in the following if condition |
|
|
1401 | |
1354 | if (term->bgPixmap.pixmap) |
1402 | if (term->bgPixmap.pixmap |
|
|
1403 | && (bg == Color_transparent || bg == Color_bg |
|
|
1404 | || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) |
1355 | { |
1405 | { |
1356 | Picture dst = 0; |
1406 | int src_x = x, src_y = y; |
1357 | |
1407 | |
1358 | if (bg >= 0 && term->pix_colors[bg].is_opaque ()) |
1408 | if (term->bgPixmap.is_parentOrigin ()) |
1359 | XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); |
1409 | { |
|
|
1410 | src_x += term->window_vt_x; |
|
|
1411 | src_y += term->window_vt_y; |
|
|
1412 | } |
|
|
1413 | |
|
|
1414 | if (term->bgPixmap.pmap_width >= src_x + w |
|
|
1415 | && term->bgPixmap.pmap_height >= src_y + h) |
|
|
1416 | { |
|
|
1417 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
|
|
1418 | src_x, src_y, w, h, 0, 0); |
|
|
1419 | } |
1360 | else |
1420 | else |
1361 | dst = XftDrawPicture (d2); |
1421 | { |
|
|
1422 | XGCValues gcv; |
|
|
1423 | |
|
|
1424 | gcv.fill_style = FillTiled; |
|
|
1425 | gcv.tile = term->bgPixmap.pixmap; |
|
|
1426 | gcv.ts_x_origin = -src_x; |
|
|
1427 | gcv.ts_y_origin = -src_y; |
|
|
1428 | |
|
|
1429 | XChangeGC (disp, gc, |
|
|
1430 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
|
|
1431 | &gcv); |
|
|
1432 | |
|
|
1433 | XFillRectangle (disp, d2, gc, 0, 0, w, h); |
|
|
1434 | |
|
|
1435 | gcv.fill_style = FillSolid; |
|
|
1436 | XChangeGC (disp, gc, GCFillStyle, &gcv); |
|
|
1437 | } |
1362 | |
1438 | |
1363 | if (dst) |
1439 | if (dst) |
1364 | { |
1440 | { |
1365 | int src_x = x, src_y = y; |
|
|
1366 | |
|
|
1367 | if (term->bgPixmap.is_parentOrigin ()) |
|
|
1368 | { |
|
|
1369 | src_x += term->window_vt_x; |
|
|
1370 | src_y += term->window_vt_y; |
|
|
1371 | } |
|
|
1372 | |
|
|
1373 | if (term->bgPixmap.pmap_width >= src_x+w |
|
|
1374 | && term->bgPixmap.pmap_height >= src_y+h) |
|
|
1375 | { |
|
|
1376 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
|
|
1377 | src_x, src_y, w, h, 0, 0); |
|
|
1378 | } |
|
|
1379 | else |
|
|
1380 | { |
|
|
1381 | XGCValues gcv; |
|
|
1382 | |
|
|
1383 | gcv.fill_style = FillTiled; |
|
|
1384 | gcv.tile = term->bgPixmap.pixmap; |
|
|
1385 | gcv.ts_x_origin = -src_x; |
|
|
1386 | gcv.ts_y_origin = -src_y; |
|
|
1387 | |
|
|
1388 | XChangeGC (disp, gc, |
|
|
1389 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
|
|
1390 | &gcv); |
|
|
1391 | |
|
|
1392 | XFillRectangle (disp, d2, gc, 0, 0, w, h); |
|
|
1393 | |
|
|
1394 | gcv.fill_style = FillSolid; |
|
|
1395 | XChangeGC (disp, gc, GCFillStyle, &gcv); |
|
|
1396 | } |
|
|
1397 | |
|
|
1398 | if (bg >= 0) |
|
|
1399 | { |
|
|
1400 | Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c); |
1441 | Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c); |
|
|
1442 | |
|
|
1443 | // dst can only be set when bg >= 0 |
1401 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
1444 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
1402 | } |
|
|
1403 | |
|
|
1404 | back_rendered = true; |
|
|
1405 | } |
1445 | } |
1406 | } |
1446 | } |
|
|
1447 | else |
1407 | #endif |
1448 | #endif |
1408 | |
|
|
1409 | if (!back_rendered) |
|
|
1410 | XftDrawRect (d2, &term->pix_colors[bg < 0 ? Color_bg : bg].c, 0, 0, w, h); |
1449 | XftDrawRect (d2, &term->pix_colors[bg >= 0 ? bg : Color_bg].c, 0, 0, w, h); |
1411 | |
1450 | |
1412 | XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); |
1451 | XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); |
1413 | XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); |
1452 | XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); |
1414 | } |
1453 | } |
1415 | else |
1454 | else |
… | |
… | |
1597 | |
1636 | |
1598 | return -1; |
1637 | return -1; |
1599 | } |
1638 | } |
1600 | |
1639 | |
1601 | int |
1640 | int |
1602 | rxvt_fontset::find_font (unicode_t unicode) |
1641 | rxvt_fontset::find_font_idx (unicode_t unicode) |
1603 | { |
1642 | { |
1604 | if (unicode >= 1<<20) |
1643 | if (unicode >= 1<<20) |
1605 | return 0; |
1644 | return 0; |
1606 | |
1645 | |
1607 | unicode_t hi = unicode >> 8; |
1646 | unicode_t hi = unicode >> 8; |
… | |
… | |
1633 | goto next_font; |
1672 | goto next_font; |
1634 | |
1673 | |
1635 | bool careful; |
1674 | bool careful; |
1636 | if (f->has_char (unicode, &prop, careful)) |
1675 | if (f->has_char (unicode, &prop, careful)) |
1637 | { |
1676 | { |
1638 | if (careful) |
1677 | i = (i << 1) | careful; |
1639 | i |= 128; |
|
|
1640 | |
1678 | |
1641 | goto found; |
1679 | goto found; |
1642 | } |
1680 | } |
1643 | |
1681 | |
1644 | next_font: |
1682 | next_font: |
… | |
… | |
1686 | FcPatternDestroy (match); |
1724 | FcPatternDestroy (match); |
1687 | |
1725 | |
1688 | if (find_font (font) < 0) |
1726 | if (find_font (font) < 0) |
1689 | { |
1727 | { |
1690 | char fontname[4096]; |
1728 | char fontname[4096]; |
1691 | sprintf (fontname, "xft:%-.4090s", font); |
1729 | snprintf (fontname, sizeof (fontname), "xft:%s", font); |
1692 | |
1730 | |
1693 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1731 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1694 | } |
1732 | } |
1695 | |
1733 | |
1696 | free (font); |
1734 | free (font); |
… | |
… | |
1720 | } |
1758 | } |
1721 | |
1759 | |
1722 | return i; |
1760 | return i; |
1723 | } |
1761 | } |
1724 | |
1762 | |
|
|
1763 | int |
|
|
1764 | rxvt_fontset::find_font (unicode_t unicode) |
|
|
1765 | { |
|
|
1766 | return min<int> ((fontCount << 1) | 1, find_font_idx (unicode)); |
|
|
1767 | } |
1725 | |
1768 | |
1726 | |
|
|