diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-08-07 05:05:04 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-08-07 05:05:04 +0000 |
commit | 3bca86ac35fb300e2ec5bd24b411f70733952fea (patch) | |
tree | 2d5f561d2de9070f4b68515f33b0ec273576364f | |
parent | 0e126143b10062055ed87362fa0bf8907a437c3b (diff) | |
parent | 550aafc64bd823748efe88360eab9d95b9f5d4f2 (diff) | |
download | pango-3bca86ac35fb300e2ec5bd24b411f70733952fea.tar.gz |
Merge branch 'ellipsize-height' into 'master'
Pass the right attributes when shaping ellipses
Closes #397
See merge request GNOME/pango!127
-rw-r--r-- | pango/pango-layout.c | 2 | ||||
-rw-r--r-- | tests/layouts/valid-1.expected | 2 | ||||
-rw-r--r-- | tests/meson.build | 1 | ||||
-rw-r--r-- | tests/test-ellipsize.c | 73 |
4 files changed, 76 insertions, 2 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 725ef0e0..67db57bb 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -4275,7 +4275,7 @@ pango_layout_check_lines (PangoLayout *layout) g_assert (delim_len < 4); /* PS is 3 bytes */ g_assert (delim_len >= 0); - state.attrs = attrs; + state.attrs = itemize_attrs; state.items = pango_itemize_with_base_dir (layout->context, base_dir, layout->text, diff --git a/tests/layouts/valid-1.expected b/tests/layouts/valid-1.expected index 6fb890b5..923f244f 100644 --- a/tests/layouts/valid-1.expected +++ b/tests/layouts/valid-1.expected @@ -28,7 +28,7 @@ i=2, index=22, chars=11, level=0, gravity=south, flags=0, font=OMITTED, script=l [22,41]underline=1 [22,41]foreground=#00000000ffff i=3, index=33, chars=15, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'mergency brake!' -[0,2147483647]foreground=#00000000ffff +[0,2147483647]underline=1 [0,2147483647]fallback=0 [22,41]foreground=#00000000ffff i=4, index=48, no run, line end diff --git a/tests/meson.build b/tests/meson.build index 9c5ddf85..449a2110 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -38,6 +38,7 @@ if cairo_dep.found() test_cflags += '-DHAVE_CAIRO' tests += [ [ 'testiter', [ 'testiter.c' ], [ libpangocairo_dep ] ], + [ 'test-ellipsize', [ 'test-ellipsize.c' ], [ libpangocairo_dep ] ], [ 'markup-parse', [ 'markup-parse.c' , 'test-common.c' ], [ libpangocairo_dep ] ], [ 'test-layout', [ 'test-layout.c', 'test-common.c' ], [ libpangocairo_dep ] ], [ 'test-itemize', [ 'test-itemize.c', 'test-common.c' ], [ libpangocairo_dep ] ], diff --git a/tests/test-ellipsize.c b/tests/test-ellipsize.c new file mode 100644 index 00000000..1c262aa1 --- /dev/null +++ b/tests/test-ellipsize.c @@ -0,0 +1,73 @@ +/* Pango + * test-ellipsize.c: Test Pango harfbuzz apis + * + * Copyright (C) 2019 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <pango/pango.h> +#include <pango/pangocairo.h> +#include "test-common.h" + +static PangoContext *context; + +/* Test that ellipsization does not change the + * height of a layout. + */ +static void +test_ellipsize (void) +{ + PangoLayout *layout; + int height1, height2; + PangoFontDescription *desc; + + layout = pango_layout_new (context); + + desc = pango_font_description_from_string ("Fixed 7"); + pango_layout_set_font_description (layout, desc); + pango_font_description_free (desc); + + pango_layout_set_text (layout, "some text that should be ellipsized", -1); + g_assert_cmpint (pango_layout_get_line_count (layout), ==, 1); + pango_layout_get_pixel_size (layout, NULL, &height1); + + pango_layout_set_width (layout, 100 * PANGO_SCALE); + pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); + + g_assert_cmpint (pango_layout_get_line_count (layout), ==, 1); + g_assert_cmpint (pango_layout_is_ellipsized (layout), ==, 1); + pango_layout_get_pixel_size (layout, NULL, &height2); + + g_assert_cmpint (height1, ==, height2); + + g_object_unref (layout); +} + +int +main (int argc, char *argv[]) +{ + PangoFontMap *fontmap; + + fontmap = pango_cairo_font_map_get_default (); + context = pango_font_map_create_context (fontmap); + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/layout/ellipsize", test_ellipsize); + + return g_test_run (); +} |