}
}
-static int x11_font_has_glyph(XFontStruct *xfs, int byte1, int byte2)
+static const XCharStruct *x11_char_struct(XFontStruct *xfs,
+ int byte1, int byte2)
{
int index;
/*
- * Not to be confused with x11font_has_glyph, which is a method of
- * the x11font 'class' and hence takes a unifont as argument. This
- * is the low-level function which grubs about in an actual
- * XFontStruct to see if a given glyph exists.
- *
- * We must do this ourselves rather than letting Xlib's
- * XTextExtents16 do the job, because XTextExtents will helpfully
- * substitute the font's default_char for any missing glyph and
- * not tell us it did so, which precisely won't help us find out
- * which glyphs _are_ missing.
- *
* The man page for XQueryFont is rather confusing about how the
* per_char array in the XFontStruct is laid out, because it gives
* formulae for determining the two-byte X character code _from_
}
if (!xfs->per_char) /* per_char NULL => everything in range exists */
- return TRUE;
+ return &xfs->max_bounds;
+
+ return &xfs->per_char[index];
+}
- return (xfs->per_char[index].ascent + xfs->per_char[index].descent > 0 ||
- xfs->per_char[index].width > 0);
+static int x11_font_has_glyph(XFontStruct *xfs, int byte1, int byte2)
+{
+ /*
+ * Not to be confused with x11font_has_glyph, which is a method of
+ * the x11font 'class' and hence takes a unifont as argument. This
+ * is the low-level function which grubs about in an actual
+ * XFontStruct to see if a given glyph exists.
+ *
+ * We must do this ourselves rather than letting Xlib's
+ * XTextExtents16 do the job, because XTextExtents will helpfully
+ * substitute the font's default_char for any missing glyph and
+ * not tell us it did so, which precisely won't help us find out
+ * which glyphs _are_ missing.
+ */
+ const XCharStruct *xcs = x11_char_struct(xfs, byte1, byte2);
+ return xcs && (xcs->ascent + xcs->descent > 0 || xcs->width > 0);
}
static unifont *x11font_create(GtkWidget *widget, const char *name,
int x, y;
unsigned char *bitmap;
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
+ const XCharStruct *xcs = x11_char_struct(xfi->xfs, glyphindex >> 8,
+ glyphindex & 0xFF);
bitmap = snewn(xfi->allsize, unsigned char);
memset(bitmap, 0, xfi->allsize);
image = XGetImage(disp, xfi->pixmap, 0, 0,
xfi->pixwidth, xfi->pixheight, AllPlanes, XYPixmap);
- for (y = 0; y < xfi->pixheight; y++) {
- for (x = 0; x < xfi->pixwidth; x++) {
+ for (y = xfi->pixoriginy - xcs->ascent;
+ y < xfi->pixoriginy + xcs->descent; y++) {
+ for (x = xfi->pixoriginx + xcs->lbearing;
+ x < xfi->pixoriginx + xcs->rbearing; x++) {
unsigned long pixel = XGetPixel(image, x, y);
if (pixel) {
int byteindex = y * xfi->rowsize + x/8;
(unsigned char)utfptr[clen] < 0xC0)
clen++;
n++;
- if (pangofont_char_width(layout, pfont,
+ if (is_rtl(string[n-1]) ||
+ pangofont_char_width(layout, pfont,
string[n-1], utfptr + oldclen,
clen - oldclen) != desired) {
clen = oldclen;
gtk_list_store_append(fs->style_model, &iter);
gtk_list_store_set(fs->style_model, &iter,
0, currstyle, 1, minpos, 2, maxpos+1,
- 3, TRUE, -1);
+ 3, TRUE, 4, PANGO_WEIGHT_NORMAL, -1);
listindex++;
}
if (info) {
gtk_list_store_append(fs->style_model, &iter);
gtk_list_store_set(fs->style_model, &iter,
0, info->charset, 1, -1, 2, -1,
- 3, FALSE, -1);
+ 3, FALSE, 4, PANGO_WEIGHT_BOLD, -1);
listindex++;
}
currcs = info->charset;
#endif
/*
- * The Style list box can contain insensitive elements
- * (character set headings for server-side fonts), so we add
- * an extra column to the list store to hold that information.
+ * The Style list box can contain insensitive elements (character
+ * set headings for server-side fonts), so we add an extra column
+ * to the list store to hold that information. Also, since GTK3 at
+ * least doesn't seem to display insensitive elements differently
+ * by default, we add a further column to change their style.
*/
- model = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT,
- G_TYPE_BOOLEAN);
+ model = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT,
+ G_TYPE_BOOLEAN, G_TYPE_INT);
w = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(w), FALSE);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), w);
gtk_widget_show(w);
column = gtk_tree_view_column_new_with_attributes
("Style", gtk_cell_renderer_text_new(),
- "text", 0, "sensitive", 3, (char *)NULL);
+ "text", 0, "sensitive", 3, "weight", 4, (char *)NULL);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(w))),