We shouldn't fork off a utmp helper subprocess when we aren't setuid,
[u/mdw/putty] / unix / gtkfont.c
index e80d7ac..5db582a 100644 (file)
@@ -280,6 +280,9 @@ static int x11_font_has_glyph(XFontStruct *xfs, int byte1, int byte2)
                   (xfs->max_char_or_byte2 - xfs->min_char_or_byte2 + 1)));
     }
 
+    if (!xfs->per_char)   /* per_char NULL => everything in range exists */
+        return TRUE;
+
     return (xfs->per_char[index].ascent + xfs->per_char[index].descent > 0 ||
             xfs->per_char[index].width > 0);
 }
@@ -425,7 +428,8 @@ static int x11font_has_glyph(unifont *font, wchar_t glyph)
         if (!sbstring[0])
             return FALSE;              /* not even in the charset */
 
-        return x11_font_has_glyph(xfont->fonts[0], 0, sbstring[0]);
+        return x11_font_has_glyph(xfont->fonts[0], 0,
+                                  (unsigned char)sbstring[0]);
     }
 }
 
@@ -1114,34 +1118,42 @@ static void pangofont_draw_text(GdkDrawable *target, GdkGC *gc, unifont *font,
            clen++;
        n = 1;
 
-       /*
-        * See if that character has the width we expect.
-        */
-       pango_layout_set_text(layout, utfptr, clen);
-       pango_layout_get_pixel_extents(layout, NULL, &rect);
+        /*
+         * If it's a right-to-left character, we must display it on
+         * its own, to stop Pango helpfully re-reversing our already
+         * reversed text.
+         */
+        if (!is_rtl(string[0])) {
 
-       if (rect.width == cellwidth) {
-           /*
-            * Try extracting more characters, for as long as they
-            * stay well-behaved.
-            */
-           while (clen < utflen) {
-               int oldclen = clen;
-               clen++;                /* skip UTF-8 introducer byte */
-               while (clen < utflen &&
-                      (unsigned char)utfptr[clen] >= 0x80 &&
-                      (unsigned char)utfptr[clen] < 0xC0)
-                   clen++;
-               n++;
-               pango_layout_set_text(layout, utfptr, clen);
-               pango_layout_get_pixel_extents(layout, NULL, &rect);
-               if (rect.width != n * cellwidth) {
-                   clen = oldclen;
-                   n--;
-                   break;
-               }
-           }
-       }
+            /*
+             * See if that character has the width we expect.
+             */
+            pango_layout_set_text(layout, utfptr, clen);
+            pango_layout_get_pixel_extents(layout, NULL, &rect);
+
+            if (rect.width == cellwidth) {
+                /*
+                 * Try extracting more characters, for as long as they
+                 * stay well-behaved.
+                 */
+                while (clen < utflen) {
+                    int oldclen = clen;
+                    clen++;                   /* skip UTF-8 introducer byte */
+                    while (clen < utflen &&
+                           (unsigned char)utfptr[clen] >= 0x80 &&
+                           (unsigned char)utfptr[clen] < 0xC0)
+                        clen++;
+                    n++;
+                    pango_layout_set_text(layout, utfptr, clen);
+                    pango_layout_get_pixel_extents(layout, NULL, &rect);
+                    if (rect.width != n * cellwidth) {
+                        clen = oldclen;
+                        n--;
+                        break;
+                    }
+                }
+            }
+        }
 
        pango_layout_set_text(layout, utfptr, clen);
        pango_layout_get_pixel_extents(layout, NULL, &rect);
@@ -1153,6 +1165,7 @@ static void pangofont_draw_text(GdkDrawable *target, GdkGC *gc, unifont *font,
 
        utflen -= clen;
        utfptr += clen;
+        string += n;
        x += n * cellwidth;
     }
 
@@ -1554,6 +1567,7 @@ unifont *multifont_create(GtkWidget *widget, const char *name,
     if (!font)
         return NULL;
 
+    fallback = NULL;
     if (font->want_fallback) {
        for (i = 0; i < lenof(unifont_types); i++) {
             if (unifont_types[i]->create_fallback) {