From 6b4992d80ff3277b2f39948948eb2c31229e1706 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 7 Aug 2007 18:40:05 +0000 Subject: =?UTF-8?q?Bug=20464183=20=E2=80=93=20Minimum=20tab=20width=20enfo?= =?UTF-8?q?rcement=20in=20pango-layout=20breaks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2007-08-07 Behdad Esfahbod Bug 464183 – Minimum tab width enforcement in pango-layout breaks TabArray positions Patch by David Trowbridge * pango/pango-layout.c (get_tab_pos), (shape_tab): Don't enforce any minimum space between tabs if tab-array is set on the layout. svn path=/trunk/; revision=2390 --- pango/pango-layout.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'pango') diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 5ed398a6..843e4fde 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -2818,11 +2818,14 @@ ensure_tab_width (PangoLayout *layout) * all tabs are left-aligned. */ static int -get_tab_pos (PangoLayout *layout, int index) +get_tab_pos (PangoLayout *layout, int index, gboolean *is_default) { gint n_tabs; gboolean in_pixels; + if (is_default) + *is_default = FALSE; + if (layout->tabs) { n_tabs = pango_tab_array_get_size (layout->tabs); @@ -2883,6 +2886,9 @@ get_tab_pos (PangoLayout *layout, int index) { /* No tab array set, so use default tab width */ + if (is_default) + *is_default = FALSE; + return layout->tab_width * index; } } @@ -2930,8 +2936,15 @@ shape_tab (PangoLayoutLine *line, for (i=0;;i++) { - int tab_pos = get_tab_pos (line->layout, i); - if (tab_pos >= current_width + space_width) + gboolean is_default; + int tab_pos = get_tab_pos (line->layout, i, &is_default); + /* Make sure there is at least a space-width of space between + * tab-aligned text and the text before it. However, only do + * this if no tab array is set on the layout, ie. using default + * tab positions. If use has set tab positions, respect it to + * the pixel. + */ + if (tab_pos >= current_width + (is_default ? space_width : 0)) { glyphs->glyphs[0].geometry.width = tab_pos - current_width; break; -- cgit v1.2.1