summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--.gitlab-ci/fedora.Dockerfile1
-rwxr-xr-x.gitlab-ci/run-tests.sh3
-rw-r--r--meson.build2
-rw-r--r--pango/pango-layout.c17
-rw-r--r--pango/pango-utils.c16
-rw-r--r--pango/pangofc-fontmap.c10
-rw-r--r--pango/pangowin32-fontmap.c5
-rw-r--r--pango/pangowin32-private.h4
-rw-r--r--pango/pangowin32.c59
-rw-r--r--tests/test-common.c55
-rw-r--r--tests/test-common.h3
-rw-r--r--tests/testattributes.c143
-rw-r--r--tests/testmisc.c11
-rw-r--r--utils/pango-segmentation.c25
15 files changed, 236 insertions, 120 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ed21f97e..bfe5f790 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,7 +8,7 @@ stages:
variables:
COMMON_MESON_FLAGS: "--fatal-meson-warnings --werror"
MESON_TEST_TIMEOUT_MULTIPLIER: 2
- FEDORA_IMAGE: registry.gitlab.gnome.org/gnome/pango/fedora:v5
+ FEDORA_IMAGE: registry.gitlab.gnome.org/gnome/pango/fedora:v6
.only-default:
only:
diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile
index c047b6f2..ebb1e6b5 100644
--- a/.gitlab-ci/fedora.Dockerfile
+++ b/.gitlab-ci/fedora.Dockerfile
@@ -31,6 +31,7 @@ RUN dnf -y install \
libthai-devel \
libubsan \
libXft-devel \
+ llvm \
ninja-build \
python3 \
python3-jinja2 \
diff --git a/.gitlab-ci/run-tests.sh b/.gitlab-ci/run-tests.sh
index d82f1d08..683c031b 100755
--- a/.gitlab-ci/run-tests.sh
+++ b/.gitlab-ci/run-tests.sh
@@ -7,7 +7,8 @@ srcdir=$( pwd )
builddir=$1
# Ignore memory leaks lower in dependencies
-export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0
+export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:symbolize=1
+export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer
# Check leaks of slices
export G_SLICE=always-malloc
diff --git a/meson.build b/meson.build
index f5425746..a1add61d 100644
--- a/meson.build
+++ b/meson.build
@@ -193,7 +193,7 @@ pango_deps = []
glib_req_version = '>= 2.62'
fribidi_req_version = '>= 0.19.7'
libthai_req_version = '>= 0.1.9'
-harfbuzz_req_version = '>= 2.0.0'
+harfbuzz_req_version = '>= 2.2.0'
fontconfig_req_version = '>= 2.11.91'
xft_req_version = '>= 2.0.0'
cairo_req_version = '>= 1.12.10'
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 87d2a2a9..a56e5329 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -457,6 +457,8 @@ pango_layout_get_height (PangoLayout *layout)
* The wrap mode only has effect if a width is set on the layout
* with [method@Pango.Layout.set_width]. To turn off wrapping,
* set the width to -1.
+ *
+ * The default value is %PANGO_WRAP_WORD.
*/
void
pango_layout_set_wrap (PangoLayout *layout,
@@ -531,6 +533,8 @@ pango_layout_is_wrapped (PangoLayout *layout)
*
* The indent setting is ignored if layout alignment is set to
* %PANGO_ALIGN_CENTER.
+ *
+ * The default value is 0.
*/
void
pango_layout_set_indent (PangoLayout *layout,
@@ -574,11 +578,12 @@ pango_layout_get_indent (PangoLayout *layout)
*
* line2.top = line1.bottom + spacing
*
- * Note: Since 1.44, Pango defaults to using the line height
- * (as determined by the font) for placing lines. The @spacing
- * set with this function is only taken into account when the
- * line height factor is set to zero with
- * [method@Pango.Layout.set_line_spacing].
+ * The default value is 0.
+ *
+ * Note: Since 1.44, Pango is using the line height (as determined
+ * by the font) for placing lines when the line height factor is set
+ * to a non-zero value with [method@Pango.Layout.set_line_spacing].
+ * In that case, the @spacing set with this function is ignored.
*/
void
pango_layout_set_spacing (PangoLayout *layout,
@@ -625,7 +630,7 @@ pango_layout_get_spacing (PangoLayout *layout)
* (as determined by the font(s)). In this case, the spacing
* set with [method@Pango.Layout.set_spacing] is ignored.
*
- * If @factor is zero, spacing is applied as before.
+ * If @factor is zero (the default), spacing is applied as before.
*
* Since: 1.44
*/
diff --git a/pango/pango-utils.c b/pango/pango-utils.c
index c90b4c86..894935e7 100644
--- a/pango/pango-utils.c
+++ b/pango/pango-utils.c
@@ -920,23 +920,29 @@ pango_is_zero_width (gunichar ch)
*
* 2028 LINE SEPARATOR
*
+ * 2060 WORD JOINER
+ * 2061 FUNCTION APPLICATION
+ * 2062 INVISIBLE TIMES
+ * 2063 INVISIBLE SEPARATOR
+ *
+ * 2066 LEFT-TO-RIGHT ISOLATE
+ * 2067 RIGHT-TO-LEFT ISOLATE
+ * 2068 FIRST STRONG ISOLATE
+ * 2069 POP DIRECTIONAL ISOLATE
+ *
* 202A LEFT-TO-RIGHT EMBEDDING
* 202B RIGHT-TO-LEFT EMBEDDING
* 202C POP DIRECTIONAL FORMATTING
* 202D LEFT-TO-RIGHT OVERRIDE
* 202E RIGHT-TO-LEFT OVERRIDE
*
- * 2060 WORD JOINER
- * 2061 FUNCTION APPLICATION
- * 2062 INVISIBLE TIMES
- * 2063 INVISIBLE SEPARATOR
- *
* FEFF ZERO WIDTH NO-BREAK SPACE
*/
return ((ch & ~(gunichar)0x007F) == 0x2000 && (
(ch >= 0x200B && ch <= 0x200F) ||
(ch >= 0x202A && ch <= 0x202E) ||
(ch >= 0x2060 && ch <= 0x2063) ||
+ (ch >= 0x2066 && ch <= 0x2069) ||
(ch == 0x2028)
)) || G_UNLIKELY (ch == 0x00AD
|| ch == 0x034F
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 7ea5dc52..aada1909 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -962,12 +962,20 @@ pango_fc_is_supported_font_format (FcPattern* pattern)
{
FcResult res;
const char *fontformat;
+ const char *file;
+
+ /* Harfbuzz loads woff fonts, but we don't get any glyphs */
+ res = FcPatternGetString (pattern, FC_FILE, 0, (FcChar8 **)(void*)&file);
+ if (res == FcResultMatch &&
+ (g_str_has_suffix (file, ".woff") ||
+ g_str_has_suffix (file, ".woff2")))
+ return FALSE;
res = FcPatternGetString (pattern, FC_FONTFORMAT, 0, (FcChar8 **)(void*)&fontformat);
if (res != FcResultMatch)
return FALSE;
- /* harfbuzz supports only SFNT fonts. */
+ /* Harfbuzz supports only SFNT fonts. */
/* FIXME: "CFF" is used for both CFF in OpenType and bare CFF files, but
* HarfBuzz does not support the later and FontConfig does not seem
* to have a way to tell them apart.
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 4cf2df3a..b6341f52 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -619,7 +619,6 @@ lookup_aliases (GHashTable *aliases_ht,
{
struct PangoAlias alias_key;
struct PangoAlias *alias;
- static gsize aliases_inited = 0;
alias_key.alias = g_ascii_strdown (fontname, -1);
alias = g_hash_table_lookup (aliases_ht, &alias_key);
@@ -678,7 +677,7 @@ create_standard_family (PangoWin32FontMap *win32fontmap,
new_face->has_cmap = old_face->has_cmap;
new_face->cmap_format = old_face->cmap_format;
- new_face->cmap = old_face->cmap;
+ new_face->cmap = _pango_win32_copy_cmap (old_face->cmap, old_face->cmap_format);
new_face->cached_fonts = NULL;
@@ -1761,7 +1760,7 @@ pango_win32_face_finalize (GObject *object)
g_free (win32face->face_name);
- //g_free (win32face->cmap); // Err, cmap does not have lifecycle management currently :(
+ g_free (win32face->cmap);
g_slist_free (win32face->cached_fonts);
// g_slist_free_full (win32face->cached_fonts, g_object_unref); // This doesn't work.
diff --git a/pango/pangowin32-private.h b/pango/pangowin32-private.h
index 1c9c1c09..3884c776 100644
--- a/pango/pangowin32-private.h
+++ b/pango/pangowin32-private.h
@@ -275,6 +275,10 @@ HFONT _pango_win32_font_get_hfont (PangoFont *font);
_PANGO_EXTERN
HDC _pango_win32_get_display_dc (void);
+_PANGO_EXTERN
+gpointer _pango_win32_copy_cmap (gpointer cmap,
+ guint16 cmap_format);
+
extern gboolean _pango_win32_debug;
#endif /* __PANGOWIN32_PRIVATE_H__ */
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index c8a5b46c..2d22e1d1 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -1275,3 +1275,62 @@ pango_win32_font_create_hb_font (PangoFont *font)
return hb_font;
}
+
+gpointer
+_pango_win32_copy_cmap (gpointer cmap, guint16 cmap_format)
+{
+ if (!cmap)
+ return NULL;
+
+ if (cmap_format == 12)
+ {
+ struct format_12_cmap *new_table;
+ struct format_12_cmap *old_table;
+ guint32 *tbl, *tbl_end;
+
+ old_table = (struct format_12_cmap *) cmap;
+
+ new_table = g_malloc (old_table->length);
+ memcpy (old_table, new_table, sizeof (struct format_12_cmap));
+
+ tbl_end = (guint32 *) ((char *) new_table + new_table->length);
+ tbl = new_table->groups;
+
+ while (tbl < tbl_end)
+ {
+ *tbl = GUINT32_FROM_BE (*tbl);
+ tbl++;
+ }
+
+ return new_table;
+ }
+ else if (cmap_format == 4)
+ {
+ struct format_4_cmap *new_table;
+ struct format_4_cmap *old_table;
+ guint16 *tbl, *tbl_end;
+
+ old_table = (struct format_4_cmap *) cmap;
+
+ new_table = g_malloc (old_table->length);
+ memcpy (old_table, new_table, sizeof (struct format_4_cmap));
+
+ tbl_end = (guint16 *)((char *) new_table + new_table->length);
+ tbl = &new_table->reserved;
+
+ while (tbl < tbl_end)
+ {
+ *tbl = GUINT16_FROM_BE (*tbl);
+ tbl++;
+ }
+
+ return new_table;
+ }
+ else
+ {
+ /* got non-null cmap but unknown format, it shouldn't happen */
+ g_assert_not_reached ();
+ }
+
+ return NULL;
+}
diff --git a/tests/test-common.c b/tests/test-common.c
index 3b8880e3..14e9941a 100644
--- a/tests/test-common.c
+++ b/tests/test-common.c
@@ -220,7 +220,9 @@ print_attributes (GSList *attrs, GString *string)
}
}
-static PangoAttribute *
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+PangoAttribute *
attribute_from_string (const char *string)
{
char *s, *p;
@@ -229,6 +231,7 @@ attribute_from_string (const char *string)
GEnumClass *class;
int i;
PangoColor color;
+ int val;
s = string;
g_assert (*s == '[');
@@ -278,16 +281,32 @@ attribute_from_string (const char *string)
attr = pango_attr_font_features_new (s);
break;
case PANGO_ATTR_STYLE:
- attr = pango_attr_style_new (strtol (s, &p, 10));
+ {
+ if (!pango_parse_enum (PANGO_TYPE_STYLE, s, &val, FALSE, NULL))
+ val = strtol (s, &p, 10);
+ attr = pango_attr_style_new (val);
+ }
break;
case PANGO_ATTR_WEIGHT:
- attr = pango_attr_weight_new (strtol (s, &p, 10));
+ {
+ if (!pango_parse_enum (PANGO_TYPE_WEIGHT, s, &val, FALSE, NULL))
+ val = strtol (s, &p, 10);
+ attr = pango_attr_weight_new (val);
+ }
break;
case PANGO_ATTR_VARIANT:
- attr = pango_attr_variant_new (strtol (s, &p, 10));
+ {
+ if (!pango_parse_enum (PANGO_TYPE_VARIANT, s, &val, FALSE, NULL))
+ val = strtol (s, &p, 10);
+ attr = pango_attr_variant_new (val);
+ }
break;
case PANGO_ATTR_STRETCH:
- attr = pango_attr_stretch_new (strtol (s, &p, 10));
+ {
+ if (!pango_parse_enum (PANGO_TYPE_STRETCH, s, &val, FALSE, NULL))
+ val = strtol (s, &p, 10);
+ attr = pango_attr_stretch_new (val);
+ }
break;
case PANGO_ATTR_SIZE:
attr = pango_attr_size_new (strtol (s, &p, 10));
@@ -296,10 +315,18 @@ attribute_from_string (const char *string)
attr = pango_attr_size_new_absolute (strtol (s, &p, 10));
break;
case PANGO_ATTR_UNDERLINE:
- attr = pango_attr_underline_new (strtol (s, &p, 10));
+ {
+ if (!pango_parse_enum (PANGO_TYPE_UNDERLINE, s, &val, FALSE, NULL))
+ val = strtol (s, &p, 10);
+ attr = pango_attr_underline_new (val);
+ }
break;
case PANGO_ATTR_OVERLINE:
- attr = pango_attr_overline_new (strtol (s, &p, 10));
+ {
+ if (!pango_parse_enum (PANGO_TYPE_OVERLINE, s, &val, FALSE, NULL))
+ val = strtol (s, &p, 10);
+ attr = pango_attr_overline_new (val);
+ }
break;
case PANGO_ATTR_STRIKETHROUGH:
attr = pango_attr_strikethrough_new (strtol (s, &p, 10));
@@ -314,10 +341,18 @@ attribute_from_string (const char *string)
attr = pango_attr_letter_spacing_new (strtol (s, &p, 10));
break;
case PANGO_ATTR_GRAVITY:
- attr = pango_attr_gravity_new (strtol (s, &p, 10));
+ {
+ if (!pango_parse_enum (PANGO_TYPE_GRAVITY, s, &val, FALSE, NULL))
+ val = strtol (s, &p, 10);
+ attr = pango_attr_gravity_new (val);
+ }
break;
case PANGO_ATTR_GRAVITY_HINT:
- attr = pango_attr_gravity_hint_new (strtol (s, &p, 10));
+ {
+ if (!pango_parse_enum (PANGO_TYPE_GRAVITY_HINT, s, &val, FALSE, NULL))
+ val = strtol (s, &p, 10);
+ attr = pango_attr_gravity_hint_new (val);
+ }
break;
case PANGO_ATTR_FOREGROUND_ALPHA:
attr = pango_attr_foreground_alpha_new (strtol (s, &p, 10));
@@ -393,6 +428,8 @@ attribute_from_string (const char *string)
return attr;
}
+G_GNUC_END_IGNORE_DEPRECATIONS
+
PangoAttrList *
attributes_from_string (const char *string)
{
diff --git a/tests/test-common.h b/tests/test-common.h
index 22953f2d..e3f46afe 100644
--- a/tests/test-common.h
+++ b/tests/test-common.h
@@ -19,6 +19,9 @@ void print_attributes (GSList *attrs,
void print_attr_list (PangoAttrList *attrs,
GString *string);
+PangoAttribute *
+attribute_from_string (const char *string);
+
PangoAttrList *
attributes_from_string (const char *string);
diff --git a/tests/testattributes.c b/tests/testattributes.c
index 26277b56..787303d9 100644
--- a/tests/testattributes.c
+++ b/tests/testattributes.c
@@ -178,17 +178,13 @@ test_list (void)
list = pango_attr_list_new ();
/* test that insertion respects start_index */
- attr = pango_attr_size_new (10);
+ attr = attribute_from_string ("[0,-1]size=10");
pango_attr_list_insert (list, attr);
- attr = pango_attr_size_new (20);
- attr->start_index = 10;
- attr->end_index = 20;
+ attr = attribute_from_string ("[10,20]size=20");
pango_attr_list_insert (list, attr);
- attr = pango_attr_size_new (30);
+ attr = attribute_from_string ("[0,-1]size=30");
pango_attr_list_insert (list, attr);
- attr = pango_attr_size_new (40);
- attr->start_index = 10;
- attr->end_index = 40;
+ attr = attribute_from_string ("[10,40]size=40");
pango_attr_list_insert_before (list, attr);
assert_attr_list (list, "[0,-1]size=10\n"
@@ -209,9 +205,7 @@ test_list_change (void)
"[20,30]size=20\n");
/* no-op */
- attr = pango_attr_variant_new (PANGO_VARIANT_SMALL_CAPS);
- attr->start_index = 10;
- attr->end_index = 10;
+ attr = attribute_from_string ("[10,10]variant=small-caps");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,10]size=10\n"
@@ -219,9 +213,7 @@ test_list_change (void)
"[20,30]size=20\n");
/* simple insertion with pango_attr_list_change */
- attr = pango_attr_variant_new (PANGO_VARIANT_SMALL_CAPS);
- attr->start_index = 10;
- attr->end_index = 20;
+ attr = attribute_from_string ("[10,20]variant=small-caps");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,10]size=10\n"
@@ -230,9 +222,7 @@ test_list_change (void)
"[20,30]size=20\n");
/* insertion with splitting */
- attr = pango_attr_weight_new (PANGO_WEIGHT_LIGHT);
- attr->start_index = 15;
- attr->end_index = 20;
+ attr = attribute_from_string ("[15,20]weight=light");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,10]size=10\n"
@@ -243,9 +233,7 @@ test_list_change (void)
"[20,30]weight=700\n");
/* insertion with joining */
- attr = pango_attr_size_new (20);
- attr->start_index = 5;
- attr->end_index = 20;
+ attr = attribute_from_string ("[5,20]size=20");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,5]size=10\n"
@@ -258,6 +246,25 @@ test_list_change (void)
pango_attr_list_unref (list);
}
+/* See https://gitlab.gnome.org/GNOME/pango/-/issues/564 */
+static void
+test_list_change2 (void)
+{
+ PangoAttrList *list;
+ PangoAttribute *attr;
+
+ list = attributes_from_string ("[6,11]weight=700\n"
+ "[18,23]weight=700\n");
+
+ /* insertion with joining */
+ attr = attribute_from_string ("[0,29]weight=700");
+ pango_attr_list_change (list, attr);
+
+ assert_attr_list (list, "[0,29]weight=700\n");
+
+ pango_attr_list_unref (list);
+}
+
static void
test_list_splice (void)
{
@@ -317,9 +324,7 @@ test_list_splice2 (void)
g_assert_null (pango_attr_list_get_attributes (list));
- attr = pango_attr_size_new (10);
- attr->start_index = 0;
- attr->end_index = -1;
+ attr = attribute_from_string ("[0,-1]size=10");
pango_attr_list_insert (other, attr);
pango_attr_list_splice (list, other, 11, 5);
@@ -414,14 +419,11 @@ test_iter (void)
pango_attr_list_unref (list);
list = pango_attr_list_new ();
- attr = pango_attr_size_new (10);
+ attr = attribute_from_string ("[0,-1]size=10");
pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 10;
- attr->end_index = 30;
+ attr = attribute_from_string ("[10,30]stretch=condensed");
pango_attr_list_insert (list, attr);
- attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- attr->start_index = 20;
+ attr = attribute_from_string ("[20,-1]weight=bold");
pango_attr_list_insert (list, attr);
iter = pango_attr_list_get_iterator (list);
@@ -467,12 +469,9 @@ test_iter_get (void)
list = pango_attr_list_new ();
attr = pango_attr_size_new (10);
pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 10;
- attr->end_index = 30;
+ attr = attribute_from_string ("[10,30]stretch=condensed");
pango_attr_list_insert (list, attr);
- attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- attr->start_index = 20;
+ attr = attribute_from_string ("[20,-1]weight=bold");
pango_attr_list_insert (list, attr);
iter = pango_attr_list_get_iterator (list);
@@ -508,25 +507,17 @@ test_iter_get_font (void)
list = pango_attr_list_new ();
attr = pango_attr_size_new (10 * PANGO_SCALE);
pango_attr_list_insert (list, attr);
- attr = pango_attr_family_new ("Times");
+ attr = attribute_from_string ("[0,-1]family=Times");
pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 10;
- attr->end_index = 30;
+ attr = attribute_from_string ("[10,30]stretch=condensed");
pango_attr_list_insert (list, attr);
- attr = pango_attr_size_new_absolute (10 * PANGO_SCALE);
- attr->start_index = 10;
- attr->end_index = 20;
+ attr = attribute_from_string ("[10,20]absolute-size=10240");
pango_attr_list_insert (list, attr);
- attr = pango_attr_language_new (pango_language_from_string ("ja-JP"));
- attr->start_index = 10;
- attr->end_index = 20;
+ attr = attribute_from_string ("[10,20]language=ja-JP");
pango_attr_list_insert (list, attr);
- attr = pango_attr_rise_new (100);
- attr->start_index = 20;
+ attr = attribute_from_string ("[20,-1]rise=100");
pango_attr_list_insert (list, attr);
- attr = pango_attr_fallback_new (FALSE);
- attr->start_index = 20;
+ attr = attribute_from_string ("[20,-1]fallback=0");
pango_attr_list_insert (list, attr);
iter = pango_attr_list_get_iterator (list);
@@ -577,21 +568,15 @@ test_iter_get_attrs (void)
list = pango_attr_list_new ();
attr = pango_attr_size_new (10 * PANGO_SCALE);
pango_attr_list_insert (list, attr);
- attr = pango_attr_family_new ("Times");
+ attr = attribute_from_string ("[0,-1]family=Times");
pango_attr_list_insert (list, attr);
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 10;
- attr->end_index = 30;
+ attr = attribute_from_string ("[10,30]stretch=condensed");
pango_attr_list_insert (list, attr);
- attr = pango_attr_language_new (pango_language_from_string ("ja-JP"));
- attr->start_index = 10;
- attr->end_index = 20;
+ attr = attribute_from_string ("[10,20]language=ja-JP");
pango_attr_list_insert (list, attr);
- attr = pango_attr_rise_new (100);
- attr->start_index = 20;
+ attr = attribute_from_string ("[20,-1]rise=100");
pango_attr_list_insert (list, attr);
- attr = pango_attr_fallback_new (FALSE);
- attr->start_index = 20;
+ attr = attribute_from_string ("[20,-1]fallback=0");
pango_attr_list_insert (list, attr);
iter = pango_attr_list_get_iterator (list);
@@ -688,18 +673,14 @@ test_list_equal (void)
g_assert_true (pango_attr_list_equal (list1, list1));
g_assert_true (pango_attr_list_equal (list1, list2));
- attr = pango_attr_size_new (10 * PANGO_SCALE);
- attr->start_index = 0;
- attr->end_index = 7;
+ attr = attribute_from_string ("[0,7]size=10240");
pango_attr_list_insert (list1, pango_attribute_copy (attr));
pango_attr_list_insert (list2, pango_attribute_copy (attr));
pango_attribute_destroy (attr);
g_assert_true (pango_attr_list_equal (list1, list2));
- attr = pango_attr_stretch_new (PANGO_STRETCH_CONDENSED);
- attr->start_index = 0;
- attr->end_index = 1;
+ attr = attribute_from_string ("[0,1]stretch=condensed");
pango_attr_list_insert (list1, pango_attribute_copy (attr));
g_assert_true (!pango_attr_list_equal (list1, list2));
@@ -707,10 +688,8 @@ test_list_equal (void)
g_assert_true (pango_attr_list_equal (list1, list2));
pango_attribute_destroy (attr);
- attr = pango_attr_size_new (30 * PANGO_SCALE);
/* Same range as the first attribute */
- attr->start_index = 0;
- attr->end_index = 7;
+ attr = attribute_from_string ("[0,7]size=30720");
pango_attr_list_insert (list2, pango_attribute_copy (attr));
g_assert_true (!pango_attr_list_equal (list1, list2));
pango_attr_list_insert (list1, pango_attribute_copy (attr));
@@ -761,9 +740,7 @@ test_insert (void)
"[11,100]fallback=0\n"
"[30,60]stretch=2\n");
- attr = pango_attr_family_new ("Times");
- attr->start_index = 10;
- attr->end_index = 25;
+ attr = attribute_from_string ("[10,25]family=Times");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,200]rise=100\n"
@@ -772,9 +749,7 @@ test_insert (void)
"[11,100]fallback=0\n"
"[30,60]stretch=2\n");
- attr = pango_attr_family_new ("Futura");
- attr->start_index = 11;
- attr->end_index = 25;
+ attr = attribute_from_string ("[11,25]family=Futura");
pango_attr_list_insert (list, attr);
assert_attr_list (list, "[0,200]rise=100\n"
@@ -801,9 +776,7 @@ test_insert2 (void)
"[30,40]family=Futura\n"
"[30,60]stretch=2\n");
- attr = pango_attr_family_new ("Times");
- attr->start_index = 10;
- attr->end_index = 35;
+ attr = attribute_from_string ("[10,35]family=Times");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,200]rise=100\n"
@@ -867,10 +840,7 @@ test_merge2 (void)
list = attributes_from_string ("[0,10]underline=1\n"
"[0,10]foreground=#00000000ffff\n");
- attr = pango_attr_foreground_new (0xffff, 0, 0);
- attr->start_index = 2;
- attr->end_index = 3;
-
+ attr = attribute_from_string ("[2,3]foreground=#ffff00000000");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,10]underline=1\n"
@@ -878,10 +848,7 @@ test_merge2 (void)
"[2,3]foreground=#ffff00000000\n"
"[3,10]foreground=#00000000ffff\n");
- attr = pango_attr_foreground_new (0, 0xffff, 0);
- attr->start_index = 3;
- attr->end_index = 4;
-
+ attr = attribute_from_string ("[3,4]foreground=#0000ffff0000");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,10]underline=1\n"
@@ -890,10 +857,7 @@ test_merge2 (void)
"[3,4]foreground=#0000ffff0000\n"
"[4,10]foreground=#00000000ffff\n");
- attr = pango_attr_foreground_new (0, 0, 0xffff);
- attr->start_index = 4;
- attr->end_index = 5;
-
+ attr = attribute_from_string ("[4,5]foreground=#00000000ffff");
pango_attr_list_change (list, attr);
assert_attr_list (list, "[0,10]underline=1\n"
@@ -1003,6 +967,7 @@ main (int argc, char *argv[])
g_test_add_func ("/attributes/register", test_attributes_register);
g_test_add_func ("/attributes/list/basic", test_list);
g_test_add_func ("/attributes/list/change", test_list_change);
+ g_test_add_func ("/attributes/list/change2", test_list_change2);
g_test_add_func ("/attributes/list/splice", test_list_splice);
g_test_add_func ("/attributes/list/splice2", test_list_splice2);
g_test_add_func ("/attributes/list/splice3", test_list_splice3);
diff --git a/tests/testmisc.c b/tests/testmisc.c
index c0f8c426..fe2e9075 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -178,6 +178,17 @@ test_is_zero_width (void)
g_assert_true (pango_is_zero_width (0x034f));
g_assert_false (pango_is_zero_width ('a'));
g_assert_false (pango_is_zero_width ('c'));
+
+ g_assert_true (pango_is_zero_width (0x2066));
+ g_assert_true (pango_is_zero_width (0x2067));
+ g_assert_true (pango_is_zero_width (0x2068));
+ g_assert_true (pango_is_zero_width (0x2069));
+
+ g_assert_true (pango_is_zero_width (0x202a));
+ g_assert_true (pango_is_zero_width (0x202b));
+ g_assert_true (pango_is_zero_width (0x202c));
+ g_assert_true (pango_is_zero_width (0x202d));
+ g_assert_true (pango_is_zero_width (0x202e));
}
static void
diff --git a/utils/pango-segmentation.c b/utils/pango-segmentation.c
index 0d5b5a49..31cefdbd 100644
--- a/utils/pango-segmentation.c
+++ b/utils/pango-segmentation.c
@@ -22,6 +22,7 @@
#include <glib.h>
#include <pango/pangocairo.h>
#include <string.h>
+#include <stdlib.h>
#include <locale.h>
#ifndef G_OS_WIN32
@@ -141,19 +142,23 @@ int
main (int argc, char *argv[])
{
char *opt_kind = "grapheme";
+ char *opt_text = NULL;
gboolean opt_version = FALSE;
GOptionEntry entries[] = {
{ "kind", 0, 0, G_OPTION_ARG_STRING, &opt_kind, "Kind of boundary (grapheme/word/line/sentence)", "KIND" },
+ { "text", 0, 0, G_OPTION_ARG_STRING, &opt_text, "Text to display", "STRING" },
{ "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Show version" },
{ NULL, },
};
GOptionContext *context;
GError *error = NULL;
+ char *text;
+ gsize len;
g_set_prgname ("pango-segmentation");
setlocale (LC_ALL, "");
- context = g_option_context_new ("TEXT");
+ context = g_option_context_new ("[FILE]");
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_set_description (context,
"Show text segmentation as determined by Pango.");
@@ -169,13 +174,25 @@ main (int argc, char *argv[])
exit (0);
}
- if (argc < 2)
+ if (opt_text)
+ {
+ text = opt_text;
+ }
+ else if (argc > 1)
+ {
+ if (!g_file_get_contents (argv[1], &text, &len, &error))
+ {
+ g_printerr ("%s\n", error->message);
+ exit (1);
+ }
+ }
+ else
{
- g_printerr ("Usage: pango-segmentation [OPTIONS…] TEXT\n");
+ g_printerr ("Usage: pango-segmentation [OPTIONS…] FILE\n");
exit (1);
}
- show_segmentation (argv[1], kind_from_string (opt_kind));
+ show_segmentation (text, kind_from_string (opt_kind));
return 0;
}