APPROVE COMMIT GTK2
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1309387387 -3600
# Node ID 05c30ad6656efb037c798b2d5c3d697b601ad56c
# Parent ac8b11bd1ba03a52c70fffa5b91787d32856eca7
Avoid separate_textual_runs in redisplay-gtk.c, leave character coverage to Pango
2011-06-29 Aidan Kehoe <kehoea(a)parhasard.net>
* redisplay-gtk.c:
* redisplay-gtk.c (XLIKE_text_width):
* redisplay-xlike-inc.c:
* redisplay-xlike-inc.c (XLIKE_output_string):
No need to separate_textual_runs on GTK, it's reasonable and
appropriate to let Pango worry about font coverage once we've
converted the text to Unicode.
diff -r ac8b11bd1ba0 -r 05c30ad6656e lisp/ChangeLog.GTK
--- a/lisp/ChangeLog.GTK Wed Jun 29 23:32:24 2011 +0100
+++ b/lisp/ChangeLog.GTK Wed Jun 29 23:43:07 2011 +0100
@@ -1,3 +1,13 @@
+2011-06-29 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * redisplay-gtk.c:
+ * redisplay-gtk.c (XLIKE_text_width):
+ * redisplay-xlike-inc.c:
+ * redisplay-xlike-inc.c (XLIKE_output_string):
+ No need to separate_textual_runs on GTK, it's reasonable and
+ appropriate to let Pango worry about font coverage once we've
+ converted the text to Unicode.
+
2011-06-29 Aidan Kehoe <kehoea(a)parhasard.net>
* custom.el (custom-declare-variable):
diff -r ac8b11bd1ba0 -r 05c30ad6656e src/redisplay-gtk.c
--- a/src/redisplay-gtk.c Wed Jun 29 23:32:24 2011 +0100
+++ b/src/redisplay-gtk.c Wed Jun 29 23:43:07 2011 +0100
@@ -189,32 +189,54 @@
#endif
-/* We always have to layout text to include combining marks etc. */
+
+/* XLIKE_text_width
+
+ Given a string and a merged face, return the string's length in pixels
+ when displayed in the fonts associated with the face. */
+
static int
-XLIKE_text_width_single_run (struct frame *f,
- struct face_cachel *cachel,
- struct textual_run *run)
+XLIKE_text_width (struct window *w, struct face_cachel *cachel,
+ const Ichar *str, Charcount len)
{
- Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
+ Ibyte *int_storage = alloca_ibytes (MAX_ICHAR_LEN * len);
+ Ibyte *int_storage_ptr = int_storage;
+ Extbyte *alloca_ext_storage;
+ Bytecount extbytes = 0;
+ Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
- GtkWidget *widget = FRAME_GTK_TEXT_WIDGET (f);
+ GtkWidget *widget = FRAME_GTK_TEXT_WIDGET (WINDOW_XFRAME (w));
gint width, height;
PangoContext *context = gtk_widget_get_pango_context (widget);
PangoLayout *layout = pango_layout_new (context);
PangoFontDescription *pfd = FONT_INSTANCE_GTK_FONT_DESC (fi);
- Lisp_Object font = FACE_CACHEL_FONT (cachel, run->charset);
PangoAttrList *attr_list = pango_attr_list_new ();
+ int ii;
+
+ for (ii = 0; ii < len; ii++)
+ {
+ int_storage_ptr += set_itext_ichar (int_storage_ptr, str[ii]);
+ }
+
+ TO_EXTERNAL_FORMAT (DATA, (int_storage, int_storage_ptr - int_storage),
+ ALLOCA, (alloca_ext_storage, extbytes),
+ Qutf_8);
if (cachel->strikethru)
- pango_attr_list_insert (attr_list,
- pango_attr_strikethrough_new (TRUE));
+ {
+ pango_attr_list_insert (attr_list, pango_attr_strikethrough_new (TRUE));
+ }
+
if (cachel->underline)
- pango_attr_list_insert (attr_list,
- pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
+ {
+ pango_attr_list_insert (attr_list,
+ pango_attr_underline_new
+ (PANGO_UNDERLINE_SINGLE));
+ }
pango_layout_set_attributes (layout, attr_list);
pango_layout_set_font_description (layout, pfd);
- pango_layout_set_text (layout, (const char *)run->ptr, run->len);
+ pango_layout_set_text (layout, (const char *) alloca_ext_storage, extbytes);
pango_layout_get_pixel_size (layout, &width, &height);
g_object_unref (layout);
pango_attr_list_unref (attr_list);
diff -r ac8b11bd1ba0 -r 05c30ad6656e src/redisplay-xlike-inc.c
--- a/src/redisplay-xlike-inc.c Wed Jun 29 23:32:24 2011 +0100
+++ b/src/redisplay-xlike-inc.c Wed Jun 29 23:43:07 2011 +0100
@@ -579,14 +579,9 @@
abort();
return 0; /* shut up GCC */
}
-#else
-static int
-XLIKE_text_width_single_run (struct frame * USED_IF_XFT (f),
- struct face_cachel *cachel,
- struct textual_run *run);
-
#endif
+#ifndef THIS_IS_GTK
/*
XLIKE_text_width
@@ -614,6 +609,10 @@
return width_so_far;
}
+#else
+static int XLIKE_text_width (struct window *w, struct face_cachel *cachel,
+ const Ichar *str, Charcount len);
+#endif
/*****************************************************************************
XLIKE_divider_height
@@ -1082,8 +1081,8 @@
int height = XLIKE_DISPLAY_LINE_HEIGHT (dl);
int ypos = XLIKE_DISPLAY_LINE_YPOS (dl);
int len = Dynarr_length (buf);
- unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
- struct textual_run *runs = alloca_array (struct textual_run, len);
+ unsigned char *text_storage;
+ struct textual_run *runs;
int nruns;
int i;
struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
@@ -1174,8 +1173,35 @@
height);
}
+#ifndef THIS_IS_GTK
+ runs = alloca_array (struct textual_run, len);
+ text_storage = (unsigned char *) ALLOCA (2 * len);
nruns = separate_textual_runs (text_storage, runs, Dynarr_begin (buf),
Dynarr_length (buf), cachel);
+#else
+ runs = alloca_new (struct textual_run);
+ nruns = 1;
+ {
+ Elemcount ii, extbytes;
+ Ibyte *int_storage = alloca_ibytes (MAX_ICHAR_LEN * len);
+ Ibyte *int_storage_ptr = int_storage;
+
+ for (ii = 0; ii < len; ii++)
+ {
+ int_storage_ptr += set_itext_ichar (int_storage_ptr,
+ Dynarr_at (buf, ii));
+ }
+
+ TO_EXTERNAL_FORMAT (DATA, (int_storage, int_storage_ptr - int_storage),
+ ALLOCA, (text_storage, extbytes),
+ Qutf_8);
+
+ runs->ptr = text_storage;
+ runs->len = extbytes;
+ runs->dimension = 1;
+ runs->charset = Vcharset_ascii;
+ }
+#endif
#ifdef THIS_IS_GTK
/* XXX Horrible kludge to force display of the only block cursor
@@ -1193,7 +1219,12 @@
if (EQ (font, Vthe_null_font_instance))
continue;
+#ifdef THIS_IS_GTK
+ this_width = width;
+#else
this_width = XLIKE_text_width_single_run (f, cachel, runs + i);
+#endif
+
need_clipping = (dl->clip || clip_start > xpos ||
clip_end < xpos + this_width);
--
‘Iodine deficiency was endemic in parts of the UK until, through what has been
described as “an unplanned and accidental public health triumph”, iodine was
added to cattle feed to improve milk production in the 1930s.’
(EN Pearce, Lancet, June 2011)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches