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.162 by root, Wed Mar 31 22:46:40 2010 UTC vs.
Revision 1.199 by root, Thu Jun 17 00:08:35 2021 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvtfont.C 2 * File: rxvtfont.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * Copyright (c) 2003-2008 Marc Lehmann <pcg@goof.com> 4 * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de>
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 3 of the License, or
10 * (at your option) any later version. 10 * (at your option) any later version.
11 * 11 *
12 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22#include "../config.h" 22#include "../config.h"
23#include "rxvt.h" 23#include "rxvt.h"
24#include "rxvtutil.h" 24#include "rxvtutil.h"
25#include "rxvtfont.h" 25#include "rxvtfont.h"
26 26
27#include <cstdlib> 27#include <stdlib.h>
28 28
29#include <inttypes.h> 29#include <inttypes.h>
30
31#if XFT
32# include <fontconfig/fontconfig.h>
33#endif
30 34
31#define MAX_OVERLAP_ROMAN (8 + 2) // max. character width in 8ths of the base width 35#define MAX_OVERLAP_ROMAN (8 + 2) // max. character width in 8ths of the base width
32#define MAX_OVERLAP_ITALIC (8 + 3) // max. overlap for italic fonts 36#define MAX_OVERLAP_ITALIC (8 + 3) // max. overlap for italic fonts
33 37
34#define OVERLAP_OK(w,wcw,prop) ((w) <= ( \ 38#define OVERLAP_OK(w,wcw,prop) ((w) <= ( \
35 (prop)->slant >= rxvt_fontprop::italic \ 39 (prop)->slant >= rxvt_fontprop::italic \
36 ? ((prop)->width * (wcw) * MAX_OVERLAP_ITALIC + 7) >> 3 \ 40 ? ((prop)->width * (wcw) * MAX_OVERLAP_ITALIC + 7) >> 3 \
37 : ((prop)->width * (wcw) * MAX_OVERLAP_ROMAN + 7) >> 3 \ 41 : ((prop)->width * (wcw) * MAX_OVERLAP_ROMAN + 7) >> 3 \
38 )) 42 ))
39 43
40const struct rxvt_fallback_font { 44static const struct rxvt_fallback_font {
41 codeset cs; 45 codeset cs;
42 const char *name; 46 const char *name;
43} fallback_fonts[] = { 47} fallback_fonts[] = {
44 { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" }, 48 { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" },
45 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" }, 49 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" },
128 { CS_KSC5601_1987_0, "xft:Baekmuk Gulim:antialias=false" }, 132 { CS_KSC5601_1987_0, "xft:Baekmuk Gulim:antialias=false" },
129 { CS_KSC5601_1987_0, "xft::lang=ko:antialias=false" }, 133 { CS_KSC5601_1987_0, "xft::lang=ko:antialias=false" },
130# endif 134# endif
131#endif 135#endif
132 136
133 { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" },
134 //{ CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, // this gem of a font has actual dotted circles within the combining character glyphs. 137 //{ CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, // this gem of a font has actual dotted circles within the combining character glyphs.
135#if XFT 138#if XFT
136 { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true" }, 139 { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true" },
137 { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" }, 140 { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" },
138 { CS_UNICODE, "xft:Andale Mono:antialias=false:autohint=false" }, 141 { CS_UNICODE, "xft:Andale Mono:antialias=false:autohint=false" },
155 '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_', 158 '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_',
156 0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ 159 0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ
157 0x304c, 0x672c, // が本 160 0x304c, 0x672c, // が本
158}; 161};
159 162
160#define NUM_EXTENT_TEST_CHARS (sizeof (extent_test_chars) / sizeof (extent_test_chars[0]))
161
162#define dTermDisplay Display *disp = term->dpy 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
238 else if (color >= 0) 239 else if (color >= 0)
239 { 240 {
240#if XFT 241#if XFT
241 Picture dst; 242 Picture dst;
242 243
243# ifdef HAVE_BG_PIXMAP 244# ifdef HAVE_IMG
244 if (term->bgPixmap.pixmap 245 if (term->bg_img
245 && !term->pix_colors[color].is_opaque () 246 && !term->pix_colors[color].is_opaque ()
246 && ((dst = XftDrawPicture (d)))) 247 && ((dst = XftDrawPicture (d))))
247 { 248 {
248 XClearArea (disp, d, x, y, w, h, false); 249 XClearArea (disp, d, x, y, w, h, false);
249 250
261 } 262 }
262} 263}
263 264
264///////////////////////////////////////////////////////////////////////////// 265/////////////////////////////////////////////////////////////////////////////
265 266
266struct rxvt_font_default : rxvt_font { 267struct rxvt_font_default : rxvt_font
268{
267 struct rxvt_fontset *fs; 269 struct rxvt_fontset *fs;
268 270
269 rxvt_font_default (rxvt_fontset *fs) 271 rxvt_font_default (rxvt_fontset *fs)
270 : rxvt_font () 272 : rxvt_font ()
271 { 273 {
448 450
449 text_t chrs[2]; 451 text_t chrs[2];
450 chrs [1] = NOCHAR; 452 chrs [1] = NOCHAR;
451 453
452 *chrs = cc->c1; 454 *chrs = cc->c1;
453 rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; 455 rxvt_font *f1 = (*fs)[fs->find_font_idx (cc->c1)];
454 f1->draw (d, x, y, chrs, width, fg, bg); 456 f1->draw (d, x, y, chrs, width, fg, bg);
455 457
456 if (cc->c2 != NOCHAR) 458 if (cc->c2 != NOCHAR)
457 { 459 {
458 bool careful; 460 bool careful;
459 461
460 // prefer font of first character, for no good reasons 462 // prefer font of first character, for no good reasons
461 *chrs = cc->c2; 463 *chrs = cc->c2;
462 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) 464 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful)
463 ? f1 465 ? f1
464 : (*fs)[fs->find_font (cc->c2)]; 466 : (*fs)[fs->find_font_idx (cc->c2)];
465 467
466 f2->draw (d, x, y, chrs, width, fg, Color_none); 468 f2->draw (d, x, y, chrs, width, fg, Color_none);
467 } 469 }
468 } 470 }
469#endif 471#endif
473 case '\t': 475 case '\t':
474 case ZERO_WIDTH_CHAR: 476 case ZERO_WIDTH_CHAR:
475 case NOCHAR: 477 case NOCHAR:
476 break; 478 break;
477 479
480 /*
481 * If the base font does not support variation selectors, treat them as ZWC.
482 * a point could be made to do this for all wcwidth == 0 characters, but I
483 * decided against that until more data is available.
484 */
485 case 0xfe00: case 0xfe01: case 0xfe02: case 0xfe03: case 0xfe04: case 0xfe05: case 0xfe06: case 0xfe07:
486 case 0xfe08: case 0xfe09: case 0xfe0a: case 0xfe0b: case 0xfe0c: case 0xfe0d: case 0xfe0e: case 0xfe0f:
487 break;
488
478 default: 489 default:
479 XDrawRectangle (disp, d, gc, x + 2, y + 2, 490 XDrawRectangle (disp, d, gc, x + 2, y + 2,
480 fwidth - 4, term->fheight - 4); 491 fwidth - 4, term->fheight - 4);
481 } 492 }
482 493
483 x += fwidth; 494 x += fwidth;
484 } 495 }
485} 496}
486 497
487struct rxvt_font_overflow : rxvt_font { 498struct rxvt_font_overflow : rxvt_font
499{
488 struct rxvt_fontset *fs; 500 struct rxvt_fontset *fs;
489 501
490 rxvt_font_overflow (rxvt_fontset *fs) 502 rxvt_font_overflow (rxvt_fontset *fs)
491 : rxvt_font () 503 : rxvt_font ()
492 { 504 {
522 534
523 void draw (rxvt_drawable &d, int x, int y, 535 void draw (rxvt_drawable &d, int x, int y,
524 const text_t *text, int len, 536 const text_t *text, int len,
525 int fg, int bg) 537 int fg, int bg)
526 { 538 {
527 while (len--) 539 while (len)
528 { 540 {
529 int fid = fs->find_font_idx (*text); 541 int fid = fs->find_font_idx (*text);
542 int w = 1;
543 while (w < len && text[w] == NOCHAR)
544 w++;
530 (*fs)[fid]->draw (d, x, y, text, 1, fg, bg); 545 (*fs)[fid]->draw (d, x, y, text, w, fg, bg);
531 ++text; 546 text += w;
547 len -= w;
532 x += term->fwidth; 548 x += term->fwidth * w;
533 } 549 }
534 } 550 }
535}; 551};
536 552
537///////////////////////////////////////////////////////////////////////////// 553/////////////////////////////////////////////////////////////////////////////
538 554
539struct rxvt_font_x11 : rxvt_font { 555struct rxvt_font_x11 : rxvt_font
556{
540 rxvt_font_x11 () { f = 0; } 557 rxvt_font_x11 () { f = 0; }
541 558
542 void clear (); 559 void clear ();
543 560
544 rxvt_fontprop properties (); 561 rxvt_fontprop properties ();
716 f = XLoadQueryFont (disp, name); 733 f = XLoadQueryFont (disp, name);
717 734
718 if (!f) 735 if (!f)
719 return false; 736 return false;
720 737
721 char *new_name = get_property (f, XA_FONT, name); 738 char *new_name = get_property (f, XA_FONT, 0);
722 739
723 if (new_name) 740 if (new_name)
724 set_name (new_name); 741 set_name (new_name);
725 else 742 else
726 rxvt_warn ("font '%s' has no FONT property, continuing without.", name); 743 rxvt_warn ("font '%s' has no FONT property, continuing without.\n", name);
727 744
728 XFreeFont (disp, f); 745 XFreeFont (disp, f);
729 f = 0; 746 f = 0;
730 } 747 }
731 748
788 free (fname); 805 free (fname);
789 if (replace_field (&fname, list[i], 11, '0', "0")) 806 if (replace_field (&fname, list[i], 11, '0', "0"))
790 diff += 300; // more heavily penalize what looks like scaled bitmap fonts 807 diff += 300; // more heavily penalize what looks like scaled bitmap fonts
791 } 808 }
792 809
793 if (!set_properties (p, fname)) 810 if (!set_properties (p, fname)
811 // also weed out too large fonts
812 || (prop.height != rxvt_fontprop::unset
813 && p.height > prop.height))
814 {
815 free (fname);
794 continue; 816 continue;
795 817 }
796 if (prop.height != rxvt_fontprop::unset
797 && p.height > prop.height) // weed out too large fonts
798 continue;
799 818
800 if (prop.height != rxvt_fontprop::unset) diff += (prop.height - p.height) * 128; 819 if (prop.height != rxvt_fontprop::unset) diff += (prop.height - p.height) * 128;
801 if (prop.weight != rxvt_fontprop::unset) diff += abs (prop.weight - p.weight); 820 if (prop.weight != rxvt_fontprop::unset) diff += abs (prop.weight - p.weight);
802 if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant); 821 if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant);
803 //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width); 822 //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width);
809 XFreeFontNames (list); 828 XFreeFontNames (list);
810 829
811 // this loop only iterates when the guessed font-size is too small 830 // this loop only iterates when the guessed font-size is too small
812 for (;;) 831 for (;;)
813 { 832 {
814 font_weight *best = fonts + count - 1; 833 font_weight *best = fonts;
815 834
816 for (font_weight *w = best; w-- > fonts; ) 835 for (font_weight *w = fonts + 1; w < fonts + count; w++)
817 if (w->diff <= best->diff) 836 if (w->diff < best->diff)
818 best = w; 837 best = w;
819 838
820 if (!best->name 839 if (!best->name
821 || !(f = XLoadQueryFont (disp, best->name))) 840 || !(f = XLoadQueryFont (disp, best->name)))
822 break; 841 break;
860 free (registry); 879 free (registry);
861 free (encoding); 880 free (encoding);
862 881
863 if (cs == CS_UNKNOWN) 882 if (cs == CS_UNKNOWN)
864 { 883 {
865 const char *charset = get_property (f, XA_FONT, 0); 884 char *value = get_property (f, XA_FONT, 0);
885 const char *charset = value;
866 886
867 if (!charset) 887 if (!charset)
868 charset = name; 888 charset = name;
869 889
870 int count = 13; 890 int count = 13;
873 break; 893 break;
874 894
875 cs = codeset_from_name (charset); 895 cs = codeset_from_name (charset);
876 if (cs == CS_UNKNOWN) 896 if (cs == CS_UNKNOWN)
877 rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset); 897 rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset);
898
899 free (value);
878 } 900 }
879 901
880 if (cs == CS_UNKNOWN) 902 if (cs == CS_UNKNOWN)
881 { 903 {
882 clear (); 904 clear ();
914 } 936 }
915#endif 937#endif
916 938
917 width = 1; 939 width = 1;
918 940
919 for (uint16_t *t = extent_test_chars + NUM_EXTENT_TEST_CHARS; t-- > extent_test_chars; ) 941 for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++)
920 { 942 {
921 if (FROM_UNICODE (cs, *t) == NOCHAR) 943 if (FROM_UNICODE (cs, *t) == NOCHAR)
922 continue; 944 continue;
923 945
924 // ignore characters we wouldn't use anyways 946 // ignore characters we wouldn't use anyways
925 bool careful; 947 bool careful;
926 if (!has_char (*t, &prop, careful)) 948 if (!has_char (*t, &prop, careful))
927 continue; 949 continue;
928 950
929 XChar2b ch = { *t >> 8, *t }; 951 // the casts are needed in C++11 (see 8.5.1)
952 XChar2b ch = { (unsigned char)(*t >> 8), (unsigned char)*t };
930 953
931 XCharStruct g; 954 XCharStruct g;
932 int dir_ret, asc_ret, des_ret; 955 int dir_ret, asc_ret, des_ret;
933 XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); 956 XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g);
934 957
960} 983}
961 984
962bool 985bool
963rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const 986rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const
964{ 987{
988 careful = false;
989
965 uint32_t ch = FROM_UNICODE (cs, unicode); 990 uint32_t ch = FROM_UNICODE (cs, unicode);
966 991
967 if (ch == NOCHAR) 992 if (ch == NOCHAR)
968 return false; 993 return false;
969 994
1032 dTermDisplay; 1057 dTermDisplay;
1033 dTermGC; 1058 dTermGC;
1034 1059
1035 bool slow = this->slow 1060 bool slow = this->slow
1036 || width != term->fwidth 1061 || width != term->fwidth
1037 || height != term->fheight; 1062 || height != term->fheight
1063 || ascent != f->ascent;
1038 1064
1039 int base = ascent; // sorry, incorrect: term->fbase; 1065 int base = ascent; // sorry, incorrect: term->fbase;
1040 1066
1041 XGCValues v; 1067 XGCValues v;
1042 v.foreground = term->pix_colors[fg]; 1068 v.foreground = term->pix_colors[fg];
1110 1136
1111///////////////////////////////////////////////////////////////////////////// 1137/////////////////////////////////////////////////////////////////////////////
1112 1138
1113#if XFT 1139#if XFT
1114 1140
1115struct rxvt_font_xft : rxvt_font { 1141struct rxvt_font_xft : rxvt_font
1142{
1116 rxvt_font_xft () { f = 0; } 1143 rxvt_font_xft ()
1144 {
1145 f = 0;
1146 }
1117 1147
1118 void clear (); 1148 void clear ();
1119 1149
1120 rxvt_fontprop properties (); 1150 rxvt_fontprop properties ();
1121 1151
1211 int ftheight = 0; 1241 int ftheight = 0;
1212 bool success = true; 1242 bool success = true;
1213 1243
1214 for (;;) 1244 for (;;)
1215 { 1245 {
1246 p = FcPatternDuplicate (match);
1216 f = XftFontOpenPattern (disp, FcPatternDuplicate (match)); 1247 f = XftFontOpenPattern (disp, p);
1217 1248
1218 if (!f) 1249 if (!f)
1219 { 1250 {
1251 FcPatternDestroy (p);
1220 success = false; 1252 success = false;
1221 break; 1253 break;
1222 } 1254 }
1223 1255
1224 FT_Face face = XftLockFace (f); 1256 FT_Face face = XftLockFace (f);
1232 1264
1233 XftUnlockFace (f); 1265 XftUnlockFace (f);
1234 1266
1235 int glheight = height; 1267 int glheight = height;
1236 1268
1237 for (uint16_t *t = extent_test_chars + NUM_EXTENT_TEST_CHARS; t-- > extent_test_chars; ) 1269 for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++)
1238 { 1270 {
1239 FcChar16 ch = *t; 1271 FcChar16 ch = *t;
1240 1272
1241 if (cs != CS_UNICODE 1273 if (cs != CS_UNICODE
1242 && ch > 0x100 1274 && ch > 0x100
1394 { 1426 {
1395 if (ep != enc) 1427 if (ep != enc)
1396 { 1428 {
1397 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1429 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1398 1430
1399#ifdef HAVE_BG_PIXMAP 1431#ifdef HAVE_IMG
1400 Picture dst = 0; // the only assignment is done conditionally in the following if condition 1432 Picture dst = 0; // the only assignment is done conditionally in the following if condition
1401 1433
1402 if (term->bgPixmap.pixmap 1434 if (term->bg_img
1403 && (bg == Color_transparent || bg == Color_bg 1435 && (bg == Color_transparent || bg == Color_bg
1404 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) 1436 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2))))))
1405 { 1437 {
1406 int src_x = x, src_y = y; 1438 int src_x = x, src_y = y;
1407 1439
1408 if (term->bgPixmap.is_parentOrigin ()) 1440 if (term->bg_flags & rxvt_term::BG_IS_TRANSPARENT)
1409 { 1441 {
1410 src_x += term->window_vt_x; 1442 src_x += term->window_vt_x;
1411 src_y += term->window_vt_y; 1443 src_y += term->window_vt_y;
1412 } 1444 }
1413 1445
1414 if (term->bgPixmap.pmap_width >= src_x + w 1446 if (term->bg_img->w >= src_x + w
1415 && term->bgPixmap.pmap_height >= src_y + h) 1447 && term->bg_img->h >= src_y + h)
1416 { 1448 {
1417 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, 1449 XCopyArea (disp, term->bg_img->pm, d2, gc,
1418 src_x, src_y, w, h, 0, 0); 1450 src_x, src_y, w, h, 0, 0);
1419 } 1451 }
1420 else 1452 else
1421 { 1453 {
1422 XGCValues gcv; 1454 XGCValues gcv;
1423 1455
1424 gcv.fill_style = FillTiled; 1456 gcv.fill_style = FillTiled;
1425 gcv.tile = term->bgPixmap.pixmap; 1457 gcv.tile = term->bg_img->pm;
1426 gcv.ts_x_origin = -src_x; 1458 gcv.ts_x_origin = -src_x;
1427 gcv.ts_y_origin = -src_y; 1459 gcv.ts_y_origin = -src_y;
1428 1460
1429 XChangeGC (disp, gc, 1461 XChangeGC (disp, gc,
1430 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1462 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1482 prop.width = prop.height = prop.ascent = prop.weight = prop.slant 1514 prop.width = prop.height = prop.ascent = prop.weight = prop.slant
1483 = rxvt_fontprop::unset; 1515 = rxvt_fontprop::unset;
1484 force_prop = false; 1516 force_prop = false;
1485 1517
1486 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) 1518 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
1487 FONT_UNREF (*i); 1519 (*i)->unref ();
1488 1520
1489 for (pagemap **p = fmap.begin (); p != fmap.end (); p++) 1521 for (pagemap **p = fmap.begin (); p != fmap.end (); p++)
1490 delete *p; 1522 delete *p;
1491 1523
1492 free (fontdesc); fontdesc = 0; 1524 free (fontdesc); fontdesc = 0;
1539///////////////////////////////////////////////////////////////////////////// 1571/////////////////////////////////////////////////////////////////////////////
1540 1572
1541void 1573void
1542rxvt_fontset::push_font (rxvt_font *font) 1574rxvt_fontset::push_font (rxvt_font *font)
1543{ 1575{
1576 // the fontCount index is reserved for the overflow font, it is only
1577 // necessary when we get fontCount or more fonts, as they cannot be
1578 // represented in the rendition.
1544 if (fonts.size () == fontCount) 1579 if (fonts.size () == fontCount)
1545 { 1580 {
1546 rxvt_font *f = new rxvt_font_overflow (this); 1581 rxvt_font *f = new rxvt_font_overflow (this);
1547 1582
1548 prepare_font (f, CS_UNICODE); 1583 prepare_font (f, CS_UNICODE);
1587 cs = codeset_from_name (spec + sizeof ("codeset=") - 1); 1622 cs = codeset_from_name (spec + sizeof ("codeset=") - 1);
1588 else 1623 else
1589 rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec); 1624 rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec);
1590 1625
1591 desc++; 1626 desc++;
1592 while (*desc <= ' ') desc++; 1627 while (*desc <= ' ' && *desc) desc++;
1593 } 1628 }
1594 1629
1595 end = strchr (desc, ','); 1630 end = strchr (desc, ',');
1596 if (!end) 1631 if (!end)
1597 end = desc + strlen (desc); 1632 end = desc + strlen (desc);
1602 buf[end - desc] = 0; 1637 buf[end - desc] = 0;
1603 1638
1604 push_font (new_font (buf, cs)); 1639 push_font (new_font (buf, cs));
1605 } 1640 }
1606 else 1641 else
1607 rxvt_warn ("fontset element too long (>511 bytes), ignored."); 1642 rxvt_warn ("fontset element too long (>511 bytes), ignored.\n");
1608 1643
1609 desc = end + 1; 1644 desc = end + 1;
1610 } 1645 }
1611 while (*end); 1646 while (*end);
1612 } 1647 }
1715 // way to configure this and xft is easier to hack in, 1750 // way to configure this and xft is easier to hack in,
1716 // while x11 has more framework in place already. 1751 // while x11 has more framework in place already.
1717 // TODO: this is a real resource hog, xft takes ages(?) 1752 // TODO: this is a real resource hog, xft takes ages(?)
1718#if XFT && USE_SLOW_LOOKUP 1753#if XFT && USE_SLOW_LOOKUP
1719 // grab the first xft font that seems suitable 1754 // grab the first xft font that seems suitable
1755 // TOOD: should go first for cellchar (spacing 110) then mono, then else
1720 FcPattern *p = FcPatternCreate (); 1756 FcPattern *p = FcPatternCreate ();
1721 1757
1722 FcCharSet *s = FcCharSetCreate (); 1758 FcCharSet *s = FcCharSetCreate ();
1723 FcCharSetAddChar (s, unicode); 1759 FcCharSetAddChar (s, unicode);
1724 FcPatternAddCharSet (p, FC_CHARSET, s); 1760 FcPatternAddCharSet (p, FC_CHARSET, s);
1768 while (hi >= fmap.size ()) 1804 while (hi >= fmap.size ())
1769 fmap.push_back (0); 1805 fmap.push_back (0);
1770 1806
1771 if (!fmap[hi]) 1807 if (!fmap[hi])
1772 { 1808 {
1773 fmap[hi] = (pagemap *)new pagemap; 1809 fmap[hi] = new pagemap;
1774 memset (fmap[hi], 0xff, sizeof (pagemap)); 1810 memset (fmap[hi], 0xff, sizeof (pagemap));
1775 } 1811 }
1776 1812
1777 (*fmap[hi])[unicode & 0xff] = i; 1813 (*fmap[hi])[unicode & 0xff] = i;
1778 } 1814 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines