summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pango/pango-attributes.c3
-rw-r--r--pango/pango-context.c2
-rw-r--r--tests/testmisc.c26
-rw-r--r--utils/meson.build27
-rw-r--r--utils/pango-list.c14
-rw-r--r--utils/pango-segmentation.c14
6 files changed, 72 insertions, 14 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index d33e0eec..8b4b2f7a 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1777,7 +1777,8 @@ pango_attr_list_update (PangoAttrList *list,
}
else if (attr->end_index >= pos + remove)
{
- if (G_MAXUINT - attr->end_index < add - remove)
+ if (add > remove &&
+ G_MAXUINT - attr->end_index < add - remove)
attr->end_index = G_MAXUINT;
else
attr->end_index += add - remove;
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 561f55bf..7fa0d7b1 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -38,7 +38,7 @@
* A `PangoContext` stores global information used to control the
* itemization process.
*
- * The information stored by `PangoContext includes the fontmap used
+ * The information stored by `PangoContext` includes the fontmap used
* to look up fonts, and default values such as the default language,
* default gravity, or default font.
*
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 06b39a7a..0767eb7a 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -121,6 +121,31 @@ test_line_height (void)
g_object_unref (context);
}
+static void
+test_attr_list_update (void)
+{
+ PangoAttribute *weight_attr;
+ PangoAttrList *list;
+
+ weight_attr = pango_attr_weight_new (700);
+ weight_attr->start_index = 4;
+ weight_attr->end_index = 6;
+
+ list = pango_attr_list_new();
+ pango_attr_list_insert (list, weight_attr);
+
+ g_assert_cmpuint (weight_attr->start_index, ==, 4);
+ g_assert_cmpuint (weight_attr->end_index, ==, 6);
+
+ // Delete 1 byte at position 2
+ pango_attr_list_update (list, 2, 1, 0);
+
+ g_assert_cmpuint (weight_attr->start_index, ==, 3);
+ g_assert_cmpuint (weight_attr->end_index, ==, 5);
+
+ pango_attr_list_unref (list);
+}
+
int
main (int argc, char *argv[])
{
@@ -132,6 +157,7 @@ main (int argc, char *argv[])
g_test_add_func ("/layout/short-string-crash", test_short_string_crash);
g_test_add_func ("/language/emoji-crash", test_language_emoji_crash);
g_test_add_func ("/layout/line-height", test_line_height);
+ g_test_add_func ("/attr-list/update", test_attr_list_update);
return g_test_run ();
}
diff --git a/utils/meson.build b/utils/meson.build
index 12968ef7..6d06dbec 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -79,11 +79,24 @@ if cairo_dep.found()
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
])
-endif
+ pango_segmentation_sources = [
+ 'pango-segmentation.c',
+ ]
-pango_segmentation = executable('pango-segmentation',
- 'pango-segmentation.c',
- dependencies: [ libpango_dep, libpangocairo_dep ],
- include_directories: [ root_inc ],
- install: false,
- )
+ pango_segmentation_deps = [
+ pango_deps,
+ libpango_dep,
+ libpangocairo_dep
+ ]
+
+ pango_segmentation = executable('pango-segmentation',
+ pango_segmentation_sources,
+ dependencies: pango_segmentation_deps,
+ include_directories: [ root_inc ],
+ install: true,
+ c_args: [
+ '-DPACKAGE_NAME="@0@"'.format(meson.project_name()),
+ '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
+ ])
+
+endif
diff --git a/utils/pango-list.c b/utils/pango-list.c
index 6e81fd6e..82a5647c 100644
--- a/utils/pango-list.c
+++ b/utils/pango-list.c
@@ -46,10 +46,12 @@ main (int argc,
gboolean opt_verbose = FALSE;
gboolean opt_metrics = FALSE;
gboolean opt_variations = FALSE;
+ gboolean opt_version = FALSE;
GOptionEntry entries[] = {
- {"verbose", 0, 0, G_OPTION_ARG_NONE, &opt_verbose, "Print verbose information", NULL },
- {"metrics", 0, 0, G_OPTION_ARG_NONE, &opt_metrics, "Print font metrics", NULL },
- {"variations", 0, 0, G_OPTION_ARG_NONE, &opt_variations, "Print font variations", NULL },
+ { "verbose", 0, 0, G_OPTION_ARG_NONE, &opt_verbose, "Print verbose information", NULL },
+ { "metrics", 0, 0, G_OPTION_ARG_NONE, &opt_metrics, "Print font metrics", NULL },
+ { "variations", 0, 0, G_OPTION_ARG_NONE, &opt_variations, "Print font variations", NULL },
+ { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Show version" },
{ NULL, }
};
GOptionContext *context;
@@ -77,6 +79,12 @@ main (int argc,
g_option_context_free (context);
+ if (opt_version)
+ {
+ g_print ("%s (%s) %s\n", g_get_prgname (), PACKAGE_NAME, PACKAGE_VERSION);
+ exit (0);
+ }
+
/* Use PangoCairo to get default fontmap so it works on every platform. */
fontmap = pango_cairo_font_map_get_default ();
ctx = pango_font_map_create_context (fontmap);
diff --git a/utils/pango-segmentation.c b/utils/pango-segmentation.c
index 3e774167..6931d180 100644
--- a/utils/pango-segmentation.c
+++ b/utils/pango-segmentation.c
@@ -151,15 +151,19 @@ show_segmentation (const char *input,
int
main (int argc, char *argv[])
{
- setlocale (LC_ALL, "");
char *opt_kind = "grapheme";
+ gboolean opt_version = FALSE;
GOptionEntry entries[] = {
{ "kind", 0, 0, G_OPTION_ARG_STRING, &opt_kind, "Kind of boundary (grapheme/word/line/sentence)", "KIND" },
+ { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Show version" },
{ NULL, },
};
GOptionContext *context;
GError *error = NULL;
+ g_set_prgname ("pango-segmentation");
+ setlocale (LC_ALL, "");
+
context = g_option_context_new ("TEXT");
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_set_description (context,
@@ -170,9 +174,15 @@ main (int argc, char *argv[])
exit (1);
}
+ if (opt_version)
+ {
+ g_print ("%s (%s) %s\n", g_get_prgname (), PACKAGE_NAME, PACKAGE_VERSION);
+ exit (0);
+ }
+
if (argc < 2)
{
- g_printerr ("Usage: pango-segmentation [OPTIONS…] TEXT");
+ g_printerr ("Usage: pango-segmentation [OPTIONS…] TEXT\n");
exit (1);
}