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 | #ifdef HAVE_BG_PIXMAP |
243 | # ifdef HAVE_BG_PIXMAP |
243 | if (term->bgPixmap.pixmap && color >= 0 && term->pix_colors[color].c.color.alpha < 0x0ff00) |
244 | if (term->bgPixmap.pixmap |
244 | { |
245 | && !term->pix_colors[color].is_opaque () |
245 | Picture dst = XftDrawPicture (d); |
246 | && ((dst = XftDrawPicture (d)))) |
246 | if (dst != 0) |
|
|
247 | { |
247 | { |
248 | XClearArea (disp, d, x, y, w, h, false); |
248 | XClearArea (disp, d, x, y, w, h, false); |
|
|
249 | |
249 | Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c); |
250 | Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c); |
250 | 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); |
251 | done = true; |
|
|
252 | } |
252 | } |
253 | } |
253 | else |
254 | #endif |
254 | # endif |
255 | if (!done) |
|
|
256 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
255 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
|
|
256 | |
257 | #else |
257 | #else |
258 | XSetForeground (disp, gc, term->pix_colors[color]); |
258 | XSetForeground (disp, gc, term->pix_colors[color]); |
259 | XFillRectangle (disp, d, gc, x, y, w, h); |
259 | XFillRectangle (disp, d, gc, x, y, w, h); |
260 | #endif |
260 | #endif |
261 | } |
261 | } |
… | |
… | |
448 | |
448 | |
449 | text_t chrs[2]; |
449 | text_t chrs[2]; |
450 | chrs [1] = NOCHAR; |
450 | chrs [1] = NOCHAR; |
451 | |
451 | |
452 | *chrs = cc->c1; |
452 | *chrs = cc->c1; |
453 | rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; |
453 | rxvt_font *f1 = fs->get (cc->c1); |
454 | f1->draw (d, x, y, chrs, width, fg, bg); |
454 | f1->draw (d, x, y, chrs, width, fg, bg); |
455 | |
455 | |
456 | if (cc->c2 != NOCHAR) |
456 | if (cc->c2 != NOCHAR) |
457 | { |
457 | { |
458 | bool careful; |
458 | bool careful; |
459 | |
459 | |
460 | // prefer font of first character, for no good reasons |
460 | // prefer font of first character, for no good reasons |
461 | *chrs = cc->c2; |
461 | *chrs = cc->c2; |
462 | rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) |
462 | rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) |
463 | ? f1 |
463 | ? f1 |
464 | : (*fs)[fs->find_font (cc->c2)]; |
464 | : fs->get (cc->c2); |
465 | |
465 | |
466 | f2->draw (d, x, y, chrs, width, fg, Color_none); |
466 | f2->draw (d, x, y, chrs, width, fg, Color_none); |
467 | } |
467 | } |
468 | } |
468 | } |
469 | #endif |
469 | #endif |
… | |
… | |
792 | return false; |
792 | return false; |
793 | |
793 | |
794 | char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); |
794 | char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); |
795 | char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); |
795 | char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); |
796 | |
796 | |
|
|
797 | cs = CS_UNKNOWN; |
|
|
798 | |
797 | if (registry && encoding) |
799 | if (registry && encoding) |
798 | { |
800 | { |
799 | char charset[64]; |
801 | char charset[64]; |
800 | snprintf (charset, 64, "%s-%s", registry, encoding); |
802 | snprintf (charset, 64, "%s-%s", registry, encoding); |
801 | |
803 | |
802 | cs = codeset_from_name (charset); |
804 | cs = codeset_from_name (charset); |
|
|
805 | |
|
|
806 | if (cs == CS_UNKNOWN) |
|
|
807 | rxvt_warn ("%s: cannot deduce encoding from registry/encoding properties \"%s\", ignoring font.\n", name, charset); |
803 | } |
808 | } |
804 | else |
809 | |
|
|
810 | free (registry); |
|
|
811 | free (encoding); |
|
|
812 | |
|
|
813 | if (cs == CS_UNKNOWN) |
805 | { |
814 | { |
806 | const char *charset = get_property (f, XA_FONT, 0); |
815 | const char *charset = get_property (f, XA_FONT, 0); |
807 | |
816 | |
808 | if (!charset) |
817 | if (!charset) |
809 | charset = name; |
818 | charset = name; |
… | |
… | |
812 | while (*charset) |
821 | while (*charset) |
813 | if (*charset++ == '-' && !--count) |
822 | if (*charset++ == '-' && !--count) |
814 | break; |
823 | break; |
815 | |
824 | |
816 | cs = codeset_from_name (charset); |
825 | cs = codeset_from_name (charset); |
|
|
826 | if (cs == CS_UNKNOWN) |
|
|
827 | rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset); |
|
|
828 | } |
|
|
829 | |
|
|
830 | if (cs == CS_UNKNOWN) |
817 | } |
831 | { |
818 | |
832 | clear (); |
819 | free (registry); |
833 | return false; |
820 | free (encoding); |
834 | } |
821 | |
835 | |
822 | if (cs == CS_UNICODE) |
836 | if (cs == CS_UNICODE) |
823 | cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font |
837 | cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font |
824 | |
838 | |
825 | encm = f->min_byte1 != 0 || f->max_byte1 != 0; |
839 | encm = f->min_byte1 != 0 || f->max_byte1 != 0; |
… | |
… | |
870 | |
884 | |
871 | int wcw = WCWIDTH (*t); |
885 | int wcw = WCWIDTH (*t); |
872 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
886 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
873 | |
887 | |
874 | if (width < g.width) width = g.width; |
888 | if (width < g.width) width = g.width; |
875 | } |
|
|
876 | |
|
|
877 | if (cs == CS_UNKNOWN) |
|
|
878 | { |
|
|
879 | fprintf (stderr, "unable to deduce codeset, ignoring font '%s'\n", name); |
|
|
880 | |
|
|
881 | clear (); |
|
|
882 | return false; |
|
|
883 | } |
889 | } |
884 | |
890 | |
885 | #if 0 // do it per-character |
891 | #if 0 // do it per-character |
886 | if (prop && width > prop->width) |
892 | if (prop && width > prop->width) |
887 | { |
893 | { |
… | |
… | |
1133 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1139 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1134 | |
1140 | |
1135 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1141 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1136 | // clip width, we can't do better, or can we? |
1142 | // clip width, we can't do better, or can we? |
1137 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
1143 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
1138 | FcPatternAddInteger (p, FC_CHAR_WIDTH, prop->width); |
1144 | FcPatternAddInteger (p, FC_CHAR_WIDTH, prop.width); |
1139 | #endif |
1145 | #endif |
1140 | |
1146 | |
1141 | if (FcPatternGet (p, FC_MINSPACE, 0, &v) != FcResultMatch) |
1147 | if (FcPatternGet (p, FC_MINSPACE, 0, &v) != FcResultMatch) |
1142 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1148 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1143 | |
1149 | |
… | |
… | |
1287 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1293 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1288 | const text_t *text, int len, |
1294 | const text_t *text, int len, |
1289 | int fg, int bg) |
1295 | int fg, int bg) |
1290 | { |
1296 | { |
1291 | XGlyphInfo extents; |
1297 | XGlyphInfo extents; |
1292 | XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); |
1298 | XftGlyphSpec *enc = rxvt_temp_buf<XftGlyphSpec> (len); |
1293 | XftGlyphSpec *ep = enc; |
1299 | XftGlyphSpec *ep = enc; |
1294 | |
1300 | |
1295 | dTermDisplay; |
1301 | dTermDisplay; |
1296 | dTermGC; |
1302 | dTermGC; |
1297 | |
1303 | |
1298 | int w = term->fwidth * len; |
1304 | int w = term->fwidth * len; |
1299 | int h = term->fheight; |
1305 | int h = term->fheight; |
1300 | |
1306 | |
1301 | /* |
|
|
1302 | * Maybe make buffering into a resource flag? Compile time option doesn't seems like a |
|
|
1303 | * good idea from the perspective of packaging for wide variety of user configs. |
|
|
1304 | */ |
|
|
1305 | bool buffered = bg >= Color_transparent; |
1307 | bool buffered = bg >= Color_transparent |
1306 | #ifdef FORCE_UNBUFFERED_XFT |
1308 | && term->option (Opt_buffered); |
1307 | buffered = false; |
|
|
1308 | #endif |
|
|
1309 | |
1309 | |
1310 | // cut trailing spaces |
1310 | // cut trailing spaces |
1311 | while (len && text [len - 1] == ' ') |
1311 | while (len && text [len - 1] == ' ') |
1312 | len--; |
1312 | len--; |
1313 | |
1313 | |
… | |
… | |
1342 | |
1342 | |
1343 | if (buffered) |
1343 | if (buffered) |
1344 | { |
1344 | { |
1345 | if (ep != enc) |
1345 | if (ep != enc) |
1346 | { |
1346 | { |
1347 | bool back_rendered = false; |
|
|
1348 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1347 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1349 | |
1348 | |
1350 | #ifdef HAVE_BG_PIXMAP |
1349 | #ifdef HAVE_BG_PIXMAP |
|
|
1350 | Picture dst = 0; // the only assignment is done conditionally in the following if condition |
|
|
1351 | |
1351 | if (term->bgPixmap.pixmap) |
1352 | if (term->bgPixmap.pixmap |
|
|
1353 | && (bg == Color_transparent || bg == Color_bg |
|
|
1354 | || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) |
1352 | { |
1355 | { |
1353 | Picture dst = 0; |
1356 | int src_x = x, src_y = y; |
1354 | |
1357 | |
1355 | if (bg >= 0 && term->pix_colors[bg].is_opaque ()) |
1358 | if (term->bgPixmap.is_parentOrigin ()) |
1356 | XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); |
1359 | { |
|
|
1360 | src_x += term->window_vt_x; |
|
|
1361 | src_y += term->window_vt_y; |
|
|
1362 | } |
|
|
1363 | |
|
|
1364 | if (term->bgPixmap.pmap_width >= src_x + w |
|
|
1365 | && term->bgPixmap.pmap_height >= src_y + h) |
|
|
1366 | { |
|
|
1367 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
|
|
1368 | src_x, src_y, w, h, 0, 0); |
|
|
1369 | } |
1357 | else |
1370 | else |
1358 | dst = XftDrawPicture (d2); |
1371 | { |
|
|
1372 | XGCValues gcv; |
|
|
1373 | |
|
|
1374 | gcv.fill_style = FillTiled; |
|
|
1375 | gcv.tile = term->bgPixmap.pixmap; |
|
|
1376 | gcv.ts_x_origin = -src_x; |
|
|
1377 | gcv.ts_y_origin = -src_y; |
|
|
1378 | |
|
|
1379 | XChangeGC (disp, gc, |
|
|
1380 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
|
|
1381 | &gcv); |
|
|
1382 | |
|
|
1383 | XFillRectangle (disp, d2, gc, 0, 0, w, h); |
|
|
1384 | |
|
|
1385 | gcv.fill_style = FillSolid; |
|
|
1386 | XChangeGC (disp, gc, GCFillStyle, &gcv); |
|
|
1387 | } |
1359 | |
1388 | |
1360 | if (dst) |
1389 | if (dst) |
1361 | { |
1390 | { |
1362 | int src_x = x, src_y = y; |
|
|
1363 | |
|
|
1364 | if (term->bgPixmap.is_parentOrigin ()) |
|
|
1365 | { |
|
|
1366 | src_x += term->window_vt_x; |
|
|
1367 | src_y += term->window_vt_y; |
|
|
1368 | } |
|
|
1369 | |
|
|
1370 | if (term->bgPixmap.pmap_width >= src_x+w |
|
|
1371 | && term->bgPixmap.pmap_height >= src_y+h) |
|
|
1372 | { |
|
|
1373 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
|
|
1374 | src_x, src_y, w, h, 0, 0); |
|
|
1375 | } |
|
|
1376 | else |
|
|
1377 | { |
|
|
1378 | XGCValues gcv; |
|
|
1379 | |
|
|
1380 | gcv.fill_style = FillTiled; |
|
|
1381 | gcv.tile = term->bgPixmap.pixmap; |
|
|
1382 | gcv.ts_x_origin = -src_x; |
|
|
1383 | gcv.ts_y_origin = -src_y; |
|
|
1384 | |
|
|
1385 | XChangeGC (disp, gc, |
|
|
1386 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
|
|
1387 | &gcv); |
|
|
1388 | |
|
|
1389 | XFillRectangle (disp, d2, gc, 0, 0, w, h); |
|
|
1390 | |
|
|
1391 | gcv.fill_style = FillSolid; |
|
|
1392 | XChangeGC (disp, gc, GCFillStyle, &gcv); |
|
|
1393 | } |
|
|
1394 | |
|
|
1395 | if (bg >= 0) |
|
|
1396 | { |
|
|
1397 | Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c); |
1391 | Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c); |
|
|
1392 | |
|
|
1393 | // dst can only be set when bg >= 0 |
1398 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
1394 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
1399 | } |
|
|
1400 | |
|
|
1401 | back_rendered = true; |
|
|
1402 | } |
1395 | } |
1403 | } |
1396 | } |
|
|
1397 | else |
1404 | #endif |
1398 | #endif |
1405 | |
|
|
1406 | if (!back_rendered) |
|
|
1407 | XftDrawRect (d2, &term->pix_colors[bg < 0 ? Color_bg : bg].c, 0, 0, w, h); |
1399 | XftDrawRect (d2, &term->pix_colors[bg >= 0 ? bg : Color_bg].c, 0, 0, w, h); |
1408 | |
1400 | |
1409 | XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); |
1401 | XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); |
1410 | XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); |
1402 | XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); |
1411 | } |
1403 | } |
1412 | else |
1404 | else |
… | |
… | |
1594 | |
1586 | |
1595 | return -1; |
1587 | return -1; |
1596 | } |
1588 | } |
1597 | |
1589 | |
1598 | int |
1590 | int |
1599 | rxvt_fontset::find_font (unicode_t unicode) |
1591 | rxvt_fontset::find_font_idx (unicode_t unicode, bool &careful) |
1600 | { |
1592 | { |
1601 | if (unicode >= 1<<20) |
1593 | if (unicode >= 1<<20) |
1602 | return 0; |
1594 | return 0; |
1603 | |
1595 | |
1604 | unicode_t hi = unicode >> 8; |
1596 | unicode_t hi = unicode >> 8; |
1605 | |
1597 | |
1606 | if (hi < fmap.size () |
1598 | if (hi < fmap.size () && fmap[hi]) |
1607 | && fmap[hi] |
1599 | { |
1608 | && (*fmap[hi])[unicode & 0xff] != 0xff) |
1600 | unsigned char m = (*fmap[hi])[unicode & 0xff]; |
1609 | return (*fmap[hi])[unicode & 0xff]; |
1601 | |
|
|
1602 | if (m != 0xff) |
|
|
1603 | { |
|
|
1604 | careful = m & 128; |
|
|
1605 | return m & 127; |
|
|
1606 | } |
|
|
1607 | } |
1610 | |
1608 | |
1611 | unsigned int i; |
1609 | unsigned int i; |
1612 | |
1610 | |
1613 | for (i = 0; i < fonts.size (); i++) |
1611 | for (i = 0; i < fonts.size (); i++) |
1614 | { |
1612 | { |
… | |
… | |
1627 | } |
1625 | } |
1628 | |
1626 | |
1629 | if (f->cs == CS_UNKNOWN) |
1627 | if (f->cs == CS_UNKNOWN) |
1630 | goto next_font; |
1628 | goto next_font; |
1631 | |
1629 | |
1632 | bool careful; |
|
|
1633 | if (f->has_char (unicode, &prop, careful)) |
1630 | if (f->has_char (unicode, &prop, careful)) |
1634 | { |
|
|
1635 | if (careful) |
|
|
1636 | i |= 128; |
|
|
1637 | |
|
|
1638 | goto found; |
1631 | goto found; |
1639 | } |
|
|
1640 | |
1632 | |
1641 | next_font: |
1633 | next_font: |
1642 | if (i == fonts.size () - 1) |
1634 | if (i == fonts.size () - 1) |
1643 | { |
1635 | { |
1644 | if (fallback->name) |
1636 | if (fallback->name) |
… | |
… | |
1683 | FcPatternDestroy (match); |
1675 | FcPatternDestroy (match); |
1684 | |
1676 | |
1685 | if (find_font (font) < 0) |
1677 | if (find_font (font) < 0) |
1686 | { |
1678 | { |
1687 | char fontname[4096]; |
1679 | char fontname[4096]; |
1688 | sprintf (fontname, "xft:%-.4090s", font); |
1680 | snprintf (fontname, sizeof (fontname), "xft:%s", font); |
1689 | |
1681 | |
1690 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1682 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1691 | } |
1683 | } |
1692 | |
1684 | |
1693 | free (font); |
1685 | free (font); |
… | |
… | |
1697 | } |
1689 | } |
1698 | } |
1690 | } |
1699 | |
1691 | |
1700 | /* we must return SOME font */ |
1692 | /* we must return SOME font */ |
1701 | i = 0; |
1693 | i = 0; |
|
|
1694 | careful = false; |
1702 | |
1695 | |
1703 | found: |
1696 | found: |
1704 | // found a font, cache it |
1697 | // found a font, cache it |
1705 | if (i < 255) |
1698 | if (i < 255) |
1706 | { |
1699 | { |
… | |
… | |
1711 | { |
1704 | { |
1712 | fmap[hi] = (pagemap *)new pagemap; |
1705 | fmap[hi] = (pagemap *)new pagemap; |
1713 | memset (fmap[hi], 0xff, sizeof (pagemap)); |
1706 | memset (fmap[hi], 0xff, sizeof (pagemap)); |
1714 | } |
1707 | } |
1715 | |
1708 | |
1716 | (*fmap[hi])[unicode & 0xff] = i; |
1709 | (*fmap[hi])[unicode & 0xff] = i | (careful ? 128 : 0); |
1717 | } |
1710 | } |
1718 | |
1711 | |
1719 | return i; |
1712 | return i; |
1720 | } |
1713 | } |
1721 | |
1714 | |
|
|
1715 | int |
|
|
1716 | rxvt_fontset::find_font (unicode_t unicode) |
|
|
1717 | { |
|
|
1718 | bool careful; |
|
|
1719 | int id = find_font_idx (unicode, careful); |
1722 | |
1720 | |
|
|
1721 | return min<int> (fontCount, id) | (careful ? Careful : 0); |
|
|
1722 | } |
1723 | |
1723 | |