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.182 by sf-exg, Fri Jul 29 09:41:22 2011 UTC vs.
Revision 1.198 by root, Wed Jun 16 22:51:55 2021 UTC

4 * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de> 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 30
31#if XFT 31#if XFT
32# include <fontconfig/fontconfig.h> 32# include <fontconfig/fontconfig.h>
239 else if (color >= 0) 239 else if (color >= 0)
240 { 240 {
241#if XFT 241#if XFT
242 Picture dst; 242 Picture dst;
243 243
244# ifdef HAVE_BG_PIXMAP 244# ifdef HAVE_IMG
245 if (term->bg_pixmap 245 if (term->bg_img
246 && !term->pix_colors[color].is_opaque () 246 && !term->pix_colors[color].is_opaque ()
247 && ((dst = XftDrawPicture (d)))) 247 && ((dst = XftDrawPicture (d))))
248 { 248 {
249 XClearArea (disp, d, x, y, w, h, false); 249 XClearArea (disp, d, x, y, w, h, false);
250 250
472 switch (t) 472 switch (t)
473 { 473 {
474 case '\t': 474 case '\t':
475 case ZERO_WIDTH_CHAR: 475 case ZERO_WIDTH_CHAR:
476 case NOCHAR: 476 case NOCHAR:
477 break;
478
479 /*
480 * If the base font does not support variation selectors, treat them as ZWC.
481 * a point could be made to do this for all wcwidth == 0 characters, but I
482 * decided against that until more data is available.
483 */
484 case 0xfe00: case 0xfe01: case 0xfe02: case 0xfe03: case 0xfe04: case 0xfe05: case 0xfe06: case 0xfe07:
485 case 0xfe08: case 0xfe09: case 0xfe0a: case 0xfe0b: case 0xfe0c: case 0xfe0d: case 0xfe0e: case 0xfe0f:
477 break; 486 break;
478 487
479 default: 488 default:
480 XDrawRectangle (disp, d, gc, x + 2, y + 2, 489 XDrawRectangle (disp, d, gc, x + 2, y + 2,
481 fwidth - 4, term->fheight - 4); 490 fwidth - 4, term->fheight - 4);
816 XFreeFontNames (list); 825 XFreeFontNames (list);
817 826
818 // this loop only iterates when the guessed font-size is too small 827 // this loop only iterates when the guessed font-size is too small
819 for (;;) 828 for (;;)
820 { 829 {
821 font_weight *best = fonts + count - 1; 830 font_weight *best = fonts;
822 831
823 for (font_weight *w = fonts; w < best; w++) 832 for (font_weight *w = fonts + 1; w < fonts + count; w++)
824 if (w->diff <= best->diff) 833 if (w->diff < best->diff)
825 best = w; 834 best = w;
826 835
827 if (!best->name 836 if (!best->name
828 || !(f = XLoadQueryFont (disp, best->name))) 837 || !(f = XLoadQueryFont (disp, best->name)))
829 break; 838 break;
934 // ignore characters we wouldn't use anyways 943 // ignore characters we wouldn't use anyways
935 bool careful; 944 bool careful;
936 if (!has_char (*t, &prop, careful)) 945 if (!has_char (*t, &prop, careful))
937 continue; 946 continue;
938 947
939 XChar2b ch = { *t >> 8, *t }; 948 // the casts are needed in C++11 (see 8.5.1)
949 XChar2b ch = { (unsigned char)(*t >> 8), (unsigned char)*t };
940 950
941 XCharStruct g; 951 XCharStruct g;
942 int dir_ret, asc_ret, des_ret; 952 int dir_ret, asc_ret, des_ret;
943 XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); 953 XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g);
944 954
1044 dTermDisplay; 1054 dTermDisplay;
1045 dTermGC; 1055 dTermGC;
1046 1056
1047 bool slow = this->slow 1057 bool slow = this->slow
1048 || width != term->fwidth 1058 || width != term->fwidth
1049 || height != term->fheight; 1059 || height != term->fheight
1060 || ascent != f->ascent;
1050 1061
1051 int base = ascent; // sorry, incorrect: term->fbase; 1062 int base = ascent; // sorry, incorrect: term->fbase;
1052 1063
1053 XGCValues v; 1064 XGCValues v;
1054 v.foreground = term->pix_colors[fg]; 1065 v.foreground = term->pix_colors[fg];
1408 { 1419 {
1409 if (ep != enc) 1420 if (ep != enc)
1410 { 1421 {
1411 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1422 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1412 1423
1413#ifdef HAVE_BG_PIXMAP 1424#ifdef HAVE_IMG
1414 Picture dst = 0; // the only assignment is done conditionally in the following if condition 1425 Picture dst = 0; // the only assignment is done conditionally in the following if condition
1415 1426
1416 if (term->bg_pixmap 1427 if (term->bg_img
1417 && (bg == Color_transparent || bg == Color_bg 1428 && (bg == Color_transparent || bg == Color_bg
1418 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) 1429 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2))))))
1419 { 1430 {
1420 int src_x = x, src_y = y; 1431 int src_x = x, src_y = y;
1421 1432
1423 { 1434 {
1424 src_x += term->window_vt_x; 1435 src_x += term->window_vt_x;
1425 src_y += term->window_vt_y; 1436 src_y += term->window_vt_y;
1426 } 1437 }
1427 1438
1428 if (term->bg_pmap_width >= src_x + w 1439 if (term->bg_img->w >= src_x + w
1429 && term->bg_pmap_height >= src_y + h) 1440 && term->bg_img->h >= src_y + h)
1430 { 1441 {
1431 XCopyArea (disp, term->bg_pixmap, d2, gc, 1442 XCopyArea (disp, term->bg_img->pm, d2, gc,
1432 src_x, src_y, w, h, 0, 0); 1443 src_x, src_y, w, h, 0, 0);
1433 } 1444 }
1434 else 1445 else
1435 { 1446 {
1436 XGCValues gcv; 1447 XGCValues gcv;
1437 1448
1438 gcv.fill_style = FillTiled; 1449 gcv.fill_style = FillTiled;
1439 gcv.tile = term->bg_pixmap; 1450 gcv.tile = term->bg_img->pm;
1440 gcv.ts_x_origin = -src_x; 1451 gcv.ts_x_origin = -src_x;
1441 gcv.ts_y_origin = -src_y; 1452 gcv.ts_y_origin = -src_y;
1442 1453
1443 XChangeGC (disp, gc, 1454 XChangeGC (disp, gc,
1444 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1455 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1604 cs = codeset_from_name (spec + sizeof ("codeset=") - 1); 1615 cs = codeset_from_name (spec + sizeof ("codeset=") - 1);
1605 else 1616 else
1606 rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec); 1617 rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec);
1607 1618
1608 desc++; 1619 desc++;
1609 while (*desc <= ' ') desc++; 1620 while (*desc <= ' ' && *desc) desc++;
1610 } 1621 }
1611 1622
1612 end = strchr (desc, ','); 1623 end = strchr (desc, ',');
1613 if (!end) 1624 if (!end)
1614 end = desc + strlen (desc); 1625 end = desc + strlen (desc);
1732 // way to configure this and xft is easier to hack in, 1743 // way to configure this and xft is easier to hack in,
1733 // while x11 has more framework in place already. 1744 // while x11 has more framework in place already.
1734 // TODO: this is a real resource hog, xft takes ages(?) 1745 // TODO: this is a real resource hog, xft takes ages(?)
1735#if XFT && USE_SLOW_LOOKUP 1746#if XFT && USE_SLOW_LOOKUP
1736 // grab the first xft font that seems suitable 1747 // grab the first xft font that seems suitable
1748 // TOOD: should go first for cellchar (spacing 110) then mono, then else
1737 FcPattern *p = FcPatternCreate (); 1749 FcPattern *p = FcPatternCreate ();
1738 1750
1739 FcCharSet *s = FcCharSetCreate (); 1751 FcCharSet *s = FcCharSetCreate ();
1740 FcCharSetAddChar (s, unicode); 1752 FcCharSetAddChar (s, unicode);
1741 FcPatternAddCharSet (p, FC_CHARSET, s); 1753 FcPatternAddCharSet (p, FC_CHARSET, s);
1785 while (hi >= fmap.size ()) 1797 while (hi >= fmap.size ())
1786 fmap.push_back (0); 1798 fmap.push_back (0);
1787 1799
1788 if (!fmap[hi]) 1800 if (!fmap[hi])
1789 { 1801 {
1790 fmap[hi] = (pagemap *)new pagemap; 1802 fmap[hi] = new pagemap;
1791 memset (fmap[hi], 0xff, sizeof (pagemap)); 1803 memset (fmap[hi], 0xff, sizeof (pagemap));
1792 } 1804 }
1793 1805
1794 (*fmap[hi])[unicode & 0xff] = i; 1806 (*fmap[hi])[unicode & 0xff] = i;
1795 } 1807 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines