--- rxvt-unicode/src/rxvtfont.C 2010/12/30 01:13:24 1.170 +++ rxvt-unicode/src/rxvtfont.C 2012/01/26 13:08:51 1.188 @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------* * File: rxvtfont.C *----------------------------------------------------------------------* - * Copyright (c) 2003-2008 Marc Lehmann + * Copyright (c) 2003-2008 Marc Lehmann * - original version. * * This program is free software; you can redistribute it and/or modify @@ -24,7 +24,7 @@ #include "rxvtutil.h" #include "rxvtfont.h" -#include +#include #include @@ -134,7 +134,6 @@ # endif #endif - { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, //{ CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, // this gem of a font has actual dotted circles within the combining character glyphs. #if XFT { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true" }, @@ -243,7 +242,7 @@ Picture dst; # ifdef HAVE_BG_PIXMAP - if (term->bgPixmap.pixmap + if (term->bg_pixmap && !term->pix_colors[color].is_opaque () && ((dst = XftDrawPicture (d)))) { @@ -526,12 +525,16 @@ const text_t *text, int len, int fg, int bg) { - while (len--) + while (len) { int fid = fs->find_font_idx (*text); - (*fs)[fid]->draw (d, x, y, text, 1, fg, bg); - ++text; - x += term->fwidth; + int w = 1; + while (w < len && text[w] == NOCHAR) + w++; + (*fs)[fid]->draw (d, x, y, text, w, fg, bg); + text += w; + len -= w; + x += term->fwidth * w; } } }; @@ -720,12 +723,12 @@ if (!f) return false; - char *new_name = get_property (f, XA_FONT, name); + char *new_name = get_property (f, XA_FONT, 0); if (new_name) set_name (new_name); else - rxvt_warn ("font '%s' has no FONT property, continuing without.", name); + rxvt_warn ("font '%s' has no FONT property, continuing without.\n", name); XFreeFont (disp, f); f = 0; @@ -815,10 +818,10 @@ // this loop only iterates when the guessed font-size is too small for (;;) { - font_weight *best = fonts + count - 1; + font_weight *best = fonts; - for (font_weight *w = best; w-- > fonts; ) - if (w->diff <= best->diff) + for (font_weight *w = fonts + 1; w < fonts + count; w++) + if (w->diff < best->diff) best = w; if (!best->name @@ -866,7 +869,8 @@ if (cs == CS_UNKNOWN) { - const char *charset = get_property (f, XA_FONT, 0); + char *value = get_property (f, XA_FONT, 0); + const char *charset = value; if (!charset) charset = name; @@ -879,6 +883,8 @@ cs = codeset_from_name (charset); if (cs == CS_UNKNOWN) rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset); + + free (value); } if (cs == CS_UNKNOWN) @@ -920,7 +926,7 @@ width = 1; - for (uint16_t *t = extent_test_chars + ARRAY_LENGTH(extent_test_chars); t-- > extent_test_chars; ) + for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++) { if (FROM_UNICODE (cs, *t) == NOCHAR) continue; @@ -966,6 +972,8 @@ bool rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const { + careful = false; + uint32_t ch = FROM_UNICODE (cs, unicode); if (ch == NOCHAR) @@ -1217,10 +1225,12 @@ for (;;) { - f = XftFontOpenPattern (disp, FcPatternDuplicate (match)); + p = FcPatternDuplicate (match); + f = XftFontOpenPattern (disp, p); if (!f) { + FcPatternDestroy (p); success = false; break; } @@ -1238,7 +1248,7 @@ int glheight = height; - for (uint16_t *t = extent_test_chars + ARRAY_LENGTH(extent_test_chars); t-- > extent_test_chars; ) + for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++) { FcChar16 ch = *t; @@ -1403,22 +1413,22 @@ #ifdef HAVE_BG_PIXMAP Picture dst = 0; // the only assignment is done conditionally in the following if condition - if (term->bgPixmap.pixmap + if (term->bg_pixmap && (bg == Color_transparent || bg == Color_bg || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) { int src_x = x, src_y = y; - if (term->bgPixmap.flags & bgPixmap_t::isTransparent) + if (term->bg_flags & rxvt_term::BG_IS_TRANSPARENT) { src_x += term->window_vt_x; src_y += term->window_vt_y; } - if (term->bgPixmap.pmap_width >= src_x + w - && term->bgPixmap.pmap_height >= src_y + h) + if (term->bg_pmap_width >= src_x + w + && term->bg_pmap_height >= src_y + h) { - XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, + XCopyArea (disp, term->bg_pixmap, d2, gc, src_x, src_y, w, h, 0, 0); } else @@ -1426,7 +1436,7 @@ XGCValues gcv; gcv.fill_style = FillTiled; - gcv.tile = term->bgPixmap.pixmap; + gcv.tile = term->bg_pixmap; gcv.ts_x_origin = -src_x; gcv.ts_y_origin = -src_y; @@ -1491,7 +1501,7 @@ (*i)->unref (); for (pagemap **p = fmap.begin (); p != fmap.end (); p++) - delete *p; + delete [] *p; free (fontdesc); fontdesc = 0; @@ -1611,7 +1621,7 @@ push_font (new_font (buf, cs)); } else - rxvt_warn ("fontset element too long (>511 bytes), ignored."); + rxvt_warn ("fontset element too long (>511 bytes), ignored.\n"); desc = end + 1; } @@ -1777,7 +1787,14 @@ if (!fmap[hi]) { - fmap[hi] = (pagemap *)new pagemap; + // we use [1] here because C++ has no separate new and new [] forms, + // and pagemap is char[256], so new incorrectly assumes we want to + // allocate an array of chars instead of a single pagemap. + // we can either cast the resulting pointer to (pagemap *) or + // allocate an array of pagemaps, returning a pointer to the first member + // this is no extra overhead, as new even allocates an array for + // "new pagemap" + fmap[hi] = new pagemap[1]; memset (fmap[hi], 0xff, sizeof (pagemap)); }