ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtfont.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtfont.C (file contents):
Revision 1.129 by root, Wed Jan 23 05:18:43 2008 UTC vs.
Revision 1.162 by root, Wed Mar 31 22:46:40 2010 UTC

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
220void 220void
221rxvt_font::set_name (char *name) 221rxvt_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
230void 230void
231rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const 231rxvt_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 }
482 482
483 x += fwidth; 483 x += fwidth;
484 } 484 }
485} 485}
486 486
487struct rxvt_font_overflow : rxvt_font {
488 struct rxvt_fontset *fs;
489
490 rxvt_font_overflow (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 rendition overflow 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
487///////////////////////////////////////////////////////////////////////////// 537/////////////////////////////////////////////////////////////////////////////
488 538
489struct rxvt_font_x11 : rxvt_font { 539struct rxvt_font_x11 : rxvt_font {
490 rxvt_font_x11 () { f = 0; } 540 rxvt_font_x11 () { f = 0; }
491 541
499 549
500 void draw (rxvt_drawable &d, int x, int y, 550 void draw (rxvt_drawable &d, int x, int y,
501 const text_t *text, int len, 551 const text_t *text, int len,
502 int fg, int bg); 552 int fg, int bg);
503 553
504 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
505 XFontStruct *f; 555 XFontStruct *f;
506 bool enc2b, encm; 556 bool enc2b, encm;
507 557
508 char *get_property (XFontStruct *f, Atom property, const char *repl) const; 558 char *get_property (XFontStruct *f, Atom property, const char *repl) const;
509 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);
792 return false; 842 return false;
793 843
794 char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); 844 char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0);
795 char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); 845 char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0);
796 846
847 cs = CS_UNKNOWN;
848
797 if (registry && encoding) 849 if (registry && encoding)
798 { 850 {
799 char charset[64]; 851 char charset[64];
800 snprintf (charset, 64, "%s-%s", registry, encoding); 852 snprintf (charset, 64, "%s-%s", registry, encoding);
801 853
802 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);
803 } 858 }
804 else 859
860 free (registry);
861 free (encoding);
862
863 if (cs == CS_UNKNOWN)
805 { 864 {
806 const char *charset = get_property (f, XA_FONT, 0); 865 const char *charset = get_property (f, XA_FONT, 0);
807 866
808 if (!charset) 867 if (!charset)
809 charset = name; 868 charset = name;
812 while (*charset) 871 while (*charset)
813 if (*charset++ == '-' && !--count) 872 if (*charset++ == '-' && !--count)
814 break; 873 break;
815 874
816 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)
817 } 881 {
818 882 clear ();
819 free (registry); 883 return false;
820 free (encoding); 884 }
821 885
822 if (cs == CS_UNICODE) 886 if (cs == CS_UNICODE)
823 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
824 888
825 encm = f->min_byte1 != 0 || f->max_byte1 != 0; 889 encm = f->min_byte1 != 0 || f->max_byte1 != 0;
872 if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; 936 if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;
873 937
874 if (width < g.width) width = g.width; 938 if (width < g.width) width = g.width;
875 } 939 }
876 940
877 if (cs == CS_UNKNOWN) 941#if 0 // do it per-character
942 if (prop && width > prop->width)
878 { 943 {
879 fprintf (stderr, "unable to deduce codeset, ignoring font '%s'\n", name);
880
881 clear (); 944 clear ();
882 return false; 945 return false;
883 } 946 }
884
885#if 0 // do it per-character
886 if (prop && width > prop->width)
887 {
888 clear ();
889 return false;
890 }
891#endif 947#endif
892 948
893 return true; 949 return true;
894} 950}
895 951
909 uint32_t ch = FROM_UNICODE (cs, unicode); 965 uint32_t ch = FROM_UNICODE (cs, unicode);
910 966
911 if (ch == NOCHAR) 967 if (ch == NOCHAR)
912 return false; 968 return false;
913 969
914 /* check wether the character exists in _this_ font. horrible. */ 970 /* check whether the character exists in _this_ font. horrible. */
915 XCharStruct *xcs; 971 XCharStruct *xcs;
916 972
917 if (encm) 973 if (encm)
918 { 974 {
919 unsigned char byte1 = ch >> 8; 975 unsigned char byte1 = ch >> 8;
949 return false; 1005 return false;
950 1006
951 if (!prop || prop->width == rxvt_fontprop::unset) 1007 if (!prop || prop->width == rxvt_fontprop::unset)
952 return true; 1008 return true;
953 1009
954 // check wether character overlaps previous/next character 1010 // check whether character overlaps previous/next character
955 int w = xcs->rbearing - xcs->lbearing; 1011 int w = xcs->rbearing - xcs->lbearing;
956 int wcw = max (WCWIDTH (unicode), 1); 1012 int wcw = max (WCWIDTH (unicode), 1);
957 1013
958 careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; 1014 careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw;
959 1015
1133 FcPatternAddInteger (p, FC_SLANT, prop.slant); 1189 FcPatternAddInteger (p, FC_SLANT, prop.slant);
1134 1190
1135#if 0 // clipping unfortunately destroys our precious double-width-characters 1191#if 0 // clipping unfortunately destroys our precious double-width-characters
1136 // clip width, we can't do better, or can we? 1192 // clip width, we can't do better, or can we?
1137 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) 1193 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch)
1138 FcPatternAddInteger (p, FC_CHAR_WIDTH, prop->width); 1194 FcPatternAddInteger (p, FC_CHAR_WIDTH, prop.width);
1139#endif 1195#endif
1140 1196
1141 if (FcPatternGet (p, FC_MINSPACE, 0, &v) != FcResultMatch) 1197 if (FcPatternGet (p, FC_MINSPACE, 0, &v) != FcResultMatch)
1142 FcPatternAddBool (p, FC_MINSPACE, 1); 1198 FcPatternAddBool (p, FC_MINSPACE, 1);
1143 1199
1287rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, 1343rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
1288 const text_t *text, int len, 1344 const text_t *text, int len,
1289 int fg, int bg) 1345 int fg, int bg)
1290{ 1346{
1291 XGlyphInfo extents; 1347 XGlyphInfo extents;
1292 XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); 1348 XftGlyphSpec *enc = rxvt_temp_buf<XftGlyphSpec> (len);
1293 XftGlyphSpec *ep = enc; 1349 XftGlyphSpec *ep = enc;
1294 1350
1295 dTermDisplay; 1351 dTermDisplay;
1296 dTermGC; 1352 dTermGC;
1297 1353
1298 int w = term->fwidth * len; 1354 int w = term->fwidth * len;
1299 int h = term->fheight; 1355 int h = term->fheight;
1300 1356
1301 /* 1357 bool buffered = bg >= Color_transparent
1302 * Maybe make buffering into a resource flag? Compile time option doesn't seems like a 1358 && term->option (Opt_buffered);
1303 * good idea from the perspective of packaging for wide variety of user configs.
1304 */
1305 bool buffered = bg >= 0;
1306#ifdef FORCE_UNBUFFERED_XFT
1307 buffered = false;
1308#endif
1309 1359
1310 // cut trailing spaces 1360 // cut trailing spaces
1311 while (len && text [len - 1] == ' ') 1361 while (len && text [len - 1] == ' ')
1312 len--; 1362 len--;
1313 1363
1342 1392
1343 if (buffered) 1393 if (buffered)
1344 { 1394 {
1345 if (ep != enc) 1395 if (ep != enc)
1346 { 1396 {
1347 bool back_rendered = false;
1348 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1397 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1349 1398
1350#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
1351 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))))))
1352 { 1405 {
1353 Picture dst = 0; 1406 int src_x = x, src_y = y;
1354 1407
1355 if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0xff00) 1408 if (term->bgPixmap.is_parentOrigin ())
1356 dst = XftDrawPicture (d2);
1357
1358 if (bg < 0 || dst != 0)
1359 { 1409 {
1360 int src_x = x, src_y = y ;
1361
1362 if (term->bgPixmap.is_parentOrigin ())
1363 {
1364 src_x += term->window_vt_x; 1410 src_x += term->window_vt_x;
1365 src_y += term->window_vt_y; 1411 src_y += term->window_vt_y;
1366 } 1412 }
1367 1413
1368 if (term->bgPixmap.pmap_width >= src_x+w 1414 if (term->bgPixmap.pmap_width >= src_x + w
1369 && term->bgPixmap.pmap_height >= src_y+h) 1415 && term->bgPixmap.pmap_height >= src_y + h)
1370 { 1416 {
1371 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, 1417 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc,
1372 src_x, src_y, w, h, 0, 0); 1418 src_x, src_y, w, h, 0, 0);
1373 } 1419 }
1374 else 1420 else
1375 { 1421 {
1376 XGCValues gcv; 1422 XGCValues gcv;
1377 1423
1378 gcv.fill_style = FillTiled; 1424 gcv.fill_style = FillTiled;
1379 gcv.tile = term->bgPixmap.pixmap; 1425 gcv.tile = term->bgPixmap.pixmap;
1380 gcv.ts_x_origin = -src_x; 1426 gcv.ts_x_origin = -src_x;
1381 gcv.ts_y_origin = -src_y; 1427 gcv.ts_y_origin = -src_y;
1382 1428
1383 XChangeGC (disp, gc, 1429 XChangeGC (disp, gc,
1384 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1430 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1385 &gcv); 1431 &gcv);
1386 1432
1387 XFillRectangle (disp, d2, gc, 0, 0, w, h); 1433 XFillRectangle (disp, d2, gc, 0, 0, w, h);
1388 1434
1389 gcv.fill_style = FillSolid; 1435 gcv.fill_style = FillSolid;
1390 XChangeGC (disp, gc, GCFillStyle, &gcv); 1436 XChangeGC (disp, gc, GCFillStyle, &gcv);
1391 } 1437 }
1392 1438
1439 if (dst)
1440 {
1393 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
1394 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);
1395
1396 back_rendered = true;
1397 } 1445 }
1398 } 1446 }
1447 else
1399#endif 1448#endif
1400
1401 if (!back_rendered)
1402 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); 1449 XftDrawRect (d2, &term->pix_colors[bg >= 0 ? bg : Color_bg].c, 0, 0, w, h);
1403 1450
1404 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); 1451 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
1405 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); 1452 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
1406 } 1453 }
1407 else 1454 else
1447 fonts.clear (); 1494 fonts.clear ();
1448 1495
1449 fallback = fallback_fonts; 1496 fallback = fallback_fonts;
1450} 1497}
1451 1498
1499void
1500rxvt_fontset::prepare_font (rxvt_font *font, codeset cs)
1501{
1502 font->set_term (term);
1503
1504 font->cs = cs;
1505 font->loaded = false;
1506}
1507
1452rxvt_font * 1508rxvt_font *
1453rxvt_fontset::new_font (const char *name, codeset cs) 1509rxvt_fontset::new_font (const char *name, codeset cs)
1454{ 1510{
1455 rxvt_font *f; 1511 rxvt_font *f;
1456 1512
1472 f = new rxvt_font_x11; 1528 f = new rxvt_font_x11;
1473 } 1529 }
1474 else 1530 else
1475 f = new rxvt_font_x11; 1531 f = new rxvt_font_x11;
1476 1532
1477 f->set_term (term);
1478 f->set_name (strdup (name)); 1533 f->set_name (strdup (name));
1479 1534 prepare_font (f, cs);
1480 f->cs = cs;
1481 f->loaded = false;
1482 1535
1483 return f; 1536 return f;
1484} 1537}
1485 1538
1486///////////////////////////////////////////////////////////////////////////// 1539/////////////////////////////////////////////////////////////////////////////
1540
1541void
1542rxvt_fontset::push_font (rxvt_font *font)
1543{
1544 if (fonts.size () == fontCount)
1545 {
1546 rxvt_font *f = new rxvt_font_overflow (this);
1547
1548 prepare_font (f, CS_UNICODE);
1549 fonts.push_back (f);
1550 }
1551
1552 fonts.push_back (font);
1553}
1487 1554
1488void 1555void
1489rxvt_fontset::add_fonts (const char *desc) 1556rxvt_fontset::add_fonts (const char *desc)
1490{ 1557{
1491 if (desc) 1558 if (desc)
1532 if (end - desc < 511) 1599 if (end - desc < 511)
1533 { 1600 {
1534 memcpy (buf, desc, end - desc); 1601 memcpy (buf, desc, end - desc);
1535 buf[end - desc] = 0; 1602 buf[end - desc] = 0;
1536 1603
1537 fonts.push_back (new_font (buf, cs)); 1604 push_font (new_font (buf, cs));
1538 } 1605 }
1539 else 1606 else
1540 rxvt_warn ("fontset element too long (>511 bytes), ignored."); 1607 rxvt_warn ("fontset element too long (>511 bytes), ignored.");
1541 1608
1542 desc = end + 1; 1609 desc = end + 1;
1570{ 1637{
1571 clear (); 1638 clear ();
1572 1639
1573 fontdesc = strdup (desc); 1640 fontdesc = strdup (desc);
1574 1641
1575 fonts.push_back (new_font (0, CS_UNICODE)); 1642 push_font (new_font (0, CS_UNICODE));
1576 realize_font (0); 1643 realize_font (0);
1577 1644
1578 add_fonts (desc); 1645 add_fonts (desc);
1579 1646
1580 return true; 1647 return true;
1589 1656
1590 return -1; 1657 return -1;
1591} 1658}
1592 1659
1593int 1660int
1594rxvt_fontset::find_font (unicode_t unicode) 1661rxvt_fontset::find_font_idx (unicode_t unicode)
1595{ 1662{
1596 if (unicode >= 1<<20) 1663 if (unicode >= 1<<20)
1597 return 0; 1664 return 0;
1598 1665
1599 unicode_t hi = unicode >> 8; 1666 unicode_t hi = unicode >> 8;
1625 goto next_font; 1692 goto next_font;
1626 1693
1627 bool careful; 1694 bool careful;
1628 if (f->has_char (unicode, &prop, careful)) 1695 if (f->has_char (unicode, &prop, careful))
1629 { 1696 {
1630 if (careful) 1697 i = (i << 1) | careful;
1631 i |= 128;
1632 1698
1633 goto found; 1699 goto found;
1634 } 1700 }
1635 1701
1636 next_font: 1702 next_font:
1637 if (i == fonts.size () - 1) 1703 if (i == fonts.size () - 1)
1638 { 1704 {
1639 if (fallback->name) 1705 if (fallback->name)
1640 { 1706 {
1641 // search through the fallback list 1707 // search through the fallback list
1642 fonts.push_back (new_font (fallback->name, fallback->cs)); 1708 push_font (new_font (fallback->name, fallback->cs));
1643 fallback++; 1709 fallback++;
1644 } 1710 }
1645 else 1711 else
1646 { 1712 {
1647 // try to find a new font. 1713 // try to find a new font.
1678 FcPatternDestroy (match); 1744 FcPatternDestroy (match);
1679 1745
1680 if (find_font (font) < 0) 1746 if (find_font (font) < 0)
1681 { 1747 {
1682 char fontname[4096]; 1748 char fontname[4096];
1683 sprintf (fontname, "xft:%-.4090s", font); 1749 snprintf (fontname, sizeof (fontname), "xft:%s", font);
1684 1750
1685 fonts.push_back (new_font (fontname, CS_UNICODE)); 1751 push_font (new_font (fontname, CS_UNICODE));
1686 } 1752 }
1687 1753
1688 free (font); 1754 free (font);
1689 } 1755 }
1690#endif 1756#endif
1712 } 1778 }
1713 1779
1714 return i; 1780 return i;
1715} 1781}
1716 1782
1717
1718

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines