From 9bdd02dbc6d6725a71baa68c13968ba0d3d6d264 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 14 Apr 2020 17:31:06 +0100 Subject: Fix annotation In arguments are nullable; out arguments are optional. --- pango/fonts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pango/fonts.c b/pango/fonts.c index f4244911..e83abbbe 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -2319,7 +2319,7 @@ pango_font_family_real_get_face (PangoFontFamily *family, /** * pango_font_family_get_face: * @family: a #PangoFontFamily - * @name: (optional): the name of a face. If the name is %NULL, + * @name: (nullable): the name of a face. If the name is %NULL, * the family's default face (fontconfig calls it "Regular") * will be returned. * -- cgit v1.2.1 From 5bd63ea4ebb2bb8d9fd0fd03211b33ecc573764c Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 14 Apr 2020 17:42:12 +0100 Subject: build: Generate the correct introspection symbols The prefix for the Pango sub-libraries is still Pango, so we need to ensure that the symbols and identifiers are correctly matched. This partially reverts !175, as Pango does not have separate pkg-config files for pango-ot and pango-fc. --- pango/meson.build | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pango/meson.build b/pango/meson.build index b2496373..808a8509 100644 --- a/pango/meson.build +++ b/pango/meson.build @@ -240,9 +240,9 @@ if build_pangoft2 dependencies: [ libpango_dep, pango_gir_dep ], namespace: 'PangoFc', nsversion: pango_api_version, - identifier_prefix: 'PangoFc', - symbol_prefix: 'pango_fc', - export_packages: 'pangofc', + identifier_prefix: 'Pango', + symbol_prefix: 'pango', + export_packages: 'pangoft2', includes: [ pango_gir[0], 'fontconfig-2.0', ], header: 'pango/pangofc-fontmap.h', install: true, @@ -258,9 +258,9 @@ if build_pangoft2 dependencies: [ libpango_dep, pango_gir_dep, pangofc_gir_dep ], namespace: 'PangoOT', nsversion: pango_api_version, - identifier_prefix: 'PangoOT', - symbol_prefix: 'pango_ot', - export_packages: 'pangoot', + identifier_prefix: 'Pango', + symbol_prefix: 'pango', + export_packages: 'pangoft2', includes: [ pangofc_gir[0], 'freetype2-2.0', ], header: 'pango/pango-ot.h', install: true, @@ -275,8 +275,8 @@ if build_pangoft2 dependencies: [ libpango_dep, pango_gir_dep, pangofc_gir_dep, pangoot_gir_dep ], namespace: 'PangoFT2', nsversion: pango_api_version, - identifier_prefix: 'PangoFT2', - symbol_prefix: 'pango_ft2', + identifier_prefix: 'Pango', + symbol_prefix: 'pango', export_packages: 'pangoft2', includes: [ pangofc_gir[0], 'freetype2-2.0', ], header: 'pango/pangoft2.h', @@ -349,8 +349,8 @@ if xft_dep.found() and fontconfig_dep.found() dependencies: [ libpango_dep, libpangoft2_dep, pango_gir_dep, pangoot_gir_dep, pangoft2_gir_dep ], namespace: 'PangoXft', nsversion: pango_api_version, - identifier_prefix: 'PangoXft', - symbol_prefix: 'pango_xft', + identifier_prefix: 'Pango', + symbol_prefix: 'pango', export_packages: 'pangoxft', includes: [ pango_gir[0], pangoot_gir[0], pangoft2_gir[0], 'GObject-2.0', 'xft-2.0', 'xlib-2.0' ], header: 'pango/pangoxft.h', @@ -518,8 +518,8 @@ if cairo_dep.found() dependencies: [ pangocairo_deps, pango_gir_dep ], namespace: 'PangoCairo', nsversion: pango_api_version, - identifier_prefix: 'PangoCairo', - symbol_prefix: 'pango_cairo', + identifier_prefix: 'Pango', + symbol_prefix: 'pango', export_packages: 'pangocairo', includes: [ pango_gir[0], 'GObject-2.0', 'cairo-1.0' ], header: 'pango/pangocairo.h', -- cgit v1.2.1 From 6d90ae0ce23b4ebf25f63d6b1a4f209b49753f22 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 14 Apr 2020 18:15:03 +0100 Subject: Add missing GType for PangoOT deprecated types This way consumers of the deprecated API can get appropriate memory management for a couple of boxed types. --- pango/pango-ot-buffer.c | 14 ++++++++++++++ pango/pango-ot-ruleset.c | 4 ++++ pango/pango-ot.h | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/pango/pango-ot-buffer.c b/pango/pango-ot-buffer.c index 334df746..bec4365a 100644 --- a/pango/pango-ot-buffer.c +++ b/pango/pango-ot-buffer.c @@ -23,6 +23,20 @@ #include "pango-ot-private.h" +static PangoOTBuffer * +pango_ot_buffer_copy (PangoOTBuffer *src) +{ + PangoOTBuffer *dst = g_slice_new (PangoOTBuffer); + + dst->buffer = hb_buffer_reference (src->buffer); + + return dst; +} + +G_DEFINE_BOXED_TYPE (PangoOTBuffer, pango_ot_buffer, + pango_ot_buffer_copy, + pango_ot_buffer_destroy) + /** * pango_ot_buffer_new * @font: a #PangoFcFont diff --git a/pango/pango-ot-ruleset.c b/pango/pango-ot-ruleset.c index 36bf65a2..9df8faef 100644 --- a/pango/pango-ot-ruleset.c +++ b/pango/pango-ot-ruleset.c @@ -364,6 +364,10 @@ pango_ot_ruleset_description_equal (const PangoOTRulesetDescription *desc1, return TRUE; } +G_DEFINE_BOXED_TYPE (PangoOTRulesetDescription, pango_ot_ruleset_description, + pango_ot_ruleset_description_copy, + pango_ot_ruleset_description_free) + /** * pango_ot_ruleset_description_copy: * @desc: ruleset description to copy diff --git a/pango/pango-ot.h b/pango/pango-ot.h index 501ca8b6..2c9f42d5 100644 --- a/pango/pango-ot.h +++ b/pango/pango-ot.h @@ -300,6 +300,11 @@ PangoOTTag *pango_ot_info_list_features (PangoOTInfo *info, guint script_index, guint language_index); +#define PANGO_TYPE_OT_BUFFER (pango_ot_buffer_get_type()) + +PANGO_DEPRECATED +GType pango_ot_buffer_get_type (void) G_GNUC_CONST; + PANGO_DEPRECATED PangoOTBuffer *pango_ot_buffer_new (PangoFcFont *font); PANGO_DEPRECATED @@ -378,6 +383,11 @@ PangoLanguage *pango_ot_tag_to_language (PangoOTTag language_tag) G_GNUC_ PANGO_DEPRECATED PangoOTTag pango_ot_tag_from_language (PangoLanguage *language) G_GNUC_CONST; +#define PANGO_TYPE_OT_RULESET_DESCRIPTION (pango_ot_ruleset_description_get_type()) + +PANGO_DEPRECATED +GType pango_ot_ruleset_description_get_type (void) G_GNUC_CONST; + PANGO_DEPRECATED guint pango_ot_ruleset_description_hash (const PangoOTRulesetDescription *desc) G_GNUC_PURE; -- cgit v1.2.1 From 8a22bba574379d0c6bd8129cd61390fcb36dd67e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 14 Apr 2020 18:22:41 +0100 Subject: Skip introspection on low level API We don't have introspection for fontconfig and freetype2 data types. While we do have introspection for Harfbuzz, it doesn't really work. --- pango/pangofc-font.c | 6 +++--- pango/pangofc-fontmap.c | 25 +++++++++++++++++++------ pango/pangoft2.c | 13 ++++++------- pango/pangoxft-font.c | 26 +++++++++++++------------- 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c index 72b9931d..4b6a34f7 100644 --- a/pango/pangofc-font.c +++ b/pango/pangofc-font.c @@ -533,14 +533,14 @@ pango_fc_font_real_get_glyph (PangoFcFont *font, } /** - * pango_fc_font_lock_face: + * pango_fc_font_lock_face: (skip) * @font: a #PangoFcFont. * - * Gets the FreeType FT_Face associated with a font, + * Gets the FreeType `FT_Face` associated with a font, * This face will be kept around until you call * pango_fc_font_unlock_face(). * - * Return value: the FreeType FT_Face associated with @font. + * Return value: the FreeType `FT_Face` associated with @font. * * Since: 1.4 * Deprecated: 1.44: Use pango_font_get_hb_font() instead diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 9ecea09b..b0c8365d 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -2021,9 +2021,9 @@ pango_fc_font_map_config_changed (PangoFcFontMap *fcfontmap) } /** - * pango_fc_font_map_set_config: + * pango_fc_font_map_set_config: (skip) * @fcfontmap: a #PangoFcFontMap - * @fcconfig: (nullable): a #FcConfig, or %NULL + * @fcconfig: (nullable): a `FcConfig`, or %NULL * * Set the FcConfig for this font map to use. The default value * is %NULL, which causes Fontconfig to use its global "current config". @@ -2065,12 +2065,14 @@ pango_fc_font_map_set_config (PangoFcFontMap *fcfontmap, } /** - * pango_fc_font_map_get_config: + * pango_fc_font_map_get_config: (skip) * @fcfontmap: a #PangoFcFontMap * - * Fetches FcConfig attached to a font map. See pango_fc_font_map_set_config(). + * Fetches the `FcConfig` attached to a font map. * - * Returns: (nullable): the #FcConfig object attached to @fcfontmap, which + * See also: pango_fc_font_map_set_config() + * + * Returns: (nullable): the `FcConfig` object attached to @fcfontmap, which * might be %NULL. * * Since: 1.38 @@ -2247,7 +2249,7 @@ _pango_fc_font_map_fc_to_coverage (FcCharSet *charset) * needed for correct operation on the #PangoContext after calling * this function. * - * Return value: a new #PangoContext + * Return value: (transfer full): a new #PangoContext * * Since: 1.4 * @@ -2940,6 +2942,17 @@ pango_fc_family_init (PangoFcFamily *fcfamily) fcfamily->n_faces = -1; } +/** + * pango_fc_font_map_get_hb_face: (skip) + * @fcfontmap: a #PangoFcFontMap + * @fcfont: a #PangoFcFont + * + * Retrieves the `hb_face_t` for the given #PangoFcFont. + * + * Returns: (transfer none) (nullable): the `hb_face_t` for the given Pango font + * + * Since: 1.44 + */ hb_face_t * pango_fc_font_map_get_hb_face (PangoFcFontMap *fcfontmap, PangoFcFont *fcfont) diff --git a/pango/pangoft2.c b/pango/pangoft2.c index b6467981..2fe49171 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -159,19 +159,18 @@ set_transform (PangoFT2Font *ft2font) } /** - * pango_ft2_font_get_face: + * pango_ft2_font_get_face: (skip) * @font: a #PangoFont * - * Returns the native FreeType2 FT_Face structure used for this #PangoFont. + * Returns the native FreeType2 `FT_Face` structure used for this #PangoFont. * This may be useful if you want to use FreeType2 functions directly. * * Use pango_fc_font_lock_face() instead; when you are done with a * face from pango_fc_font_lock_face() you must call * pango_fc_font_unlock_face(). * - * Return value: (nullable): a pointer to a FT_Face - * structure, with the size set correctly, or %NULL if - * @font is %NULL. + * Return value: (nullable): a pointer to a `FT_Face` structure, with the + * size set correctly, or %NULL if @font is %NULL. **/ FT_Face pango_ft2_font_get_face (PangoFont *font) @@ -476,10 +475,10 @@ pango_ft2_font_finalize (GObject *object) /** * pango_ft2_font_get_coverage: - * @font: a PangoFT2Font. + * @font: a Pango FT2 font * @language: a language tag. * - * Gets the #PangoCoverage for a PangoFT2Font. Use + * Gets the #PangoCoverage for a `PangoFT2Font`. Use * pango_font_get_coverage() instead. * * Return value: (transfer full): a #PangoCoverage. diff --git a/pango/pangoxft-font.c b/pango/pangoxft-font.c index 2526b13d..45418c15 100644 --- a/pango/pangoxft-font.c +++ b/pango/pangoxft-font.c @@ -499,13 +499,13 @@ pango_xft_font_real_shutdown (PangoFcFont *fcfont) } /** - * pango_xft_font_get_font: + * pango_xft_font_get_font: (skip) * @font: (nullable): a #PangoFont. * - * Returns the XftFont of a font. + * Returns the `XftFont` of a font. * - * Return value: (nullable): the XftFont associated to @font, or %NULL - * if @font is %NULL. + * Return value: (nullable): the `XftFont` associated to @font, + * or %NULL if @font is %NULL. **/ XftFont * pango_xft_font_get_font (PangoFont *font) @@ -517,12 +517,12 @@ pango_xft_font_get_font (PangoFont *font) } /** - * pango_xft_font_get_display: + * pango_xft_font_get_display: (skip) * @font: a #PangoFont. * - * Returns the X display of the XftFont of a font. + * Returns the X display of the `XftFont` of a font. * - * Return value: the X display of the XftFont associated to @font. + * Return value: (transfer none): the X display of the XftFont associated to @font. **/ Display * pango_xft_font_get_display (PangoFont *font) @@ -560,16 +560,16 @@ pango_xft_font_get_unknown_glyph (PangoFont *font, } /** - * pango_xft_font_lock_face: + * pango_xft_font_lock_face: (skip) * @font: a #PangoFont. * - * Gets the FreeType FT_Face associated with a font, - * This face will be kept around until you call - * pango_xft_font_unlock_face(). + * Gets the FreeType `FT_Face` associated with a font. + * + * This face will be kept around until you call pango_xft_font_unlock_face(). * * Use pango_fc_font_lock_face() instead. * - * Return value: the FreeType FT_Face associated with @font. + * Return value: the FreeType `FT_Face` associated with @font. * * Since: 1.2 **/ @@ -582,7 +582,7 @@ pango_xft_font_lock_face (PangoFont *font) } /** - * pango_xft_font_unlock_face: + * pango_xft_font_unlock_face: (skip) * @font: a #PangoFont. * * Releases a font previously obtained with -- cgit v1.2.1 From 598c3a28e5eb14a047d767055f4d8c7833dda0fb Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 14 Apr 2020 18:58:07 +0100 Subject: build: Remove unnecessary arguments The pkgconfig.generate() function has default values for the version and installation path argument, and we're already using them. --- pango/meson.build | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pango/meson.build b/pango/meson.build index 808a8509..a86617b4 100644 --- a/pango/meson.build +++ b/pango/meson.build @@ -160,11 +160,9 @@ endif pkgconfig.generate(libpango, name: 'Pango', description: 'Internationalized text handling', - version: meson.project_version(), requires: pango_pkg_requires, filebase: 'pango', subdirs: pango_api_name, - install_dir: join_paths(pango_libdir, 'pkgconfig'), ) # FreeType @@ -370,11 +368,9 @@ if xft_dep.found() and fontconfig_dep.found() pkgconfig.generate(libpangoxft, name: 'Pango Xft', description: 'Xft font support for Pango', - version: meson.project_version(), filebase: 'pangoxft', subdirs: pango_api_name, requires: [ 'pangoft2', 'xft' ], - install_dir: join_paths(pango_libdir, 'pkgconfig'), ) else # For usage as a subproject @@ -431,11 +427,9 @@ if host_system == 'windows' pkgconfig.generate(libpangowin32, name: 'Pango Win32', description: 'Win32 GDI font support for Pango', - version: meson.project_version(), filebase: 'pangowin32', subdirs: pango_api_name, requires: 'pango', - install_dir: join_paths(pango_libdir, 'pkgconfig'), ) else # For usage as a subproject @@ -547,11 +541,9 @@ if cairo_dep.found() pkgconfig.generate(libpangocairo, name: 'Pango Cairo', description: 'Cairo rendering support for Pango', - version: meson.project_version(), filebase: 'pangocairo', subdirs: pango_api_name, requires: pango_cairo_requires, - install_dir: join_paths(pango_libdir, 'pkgconfig'), ) else # For usage as a subproject -- cgit v1.2.1 From 5dfa88dc880079fb314f24525f940cdd9b2d08b5 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 14 Apr 2020 18:59:26 +0100 Subject: build: Generate pkg-config files for PangoOT and PangoFc Since we have them as separate namespaces, we need separate pkg-config file in order to let Vala consume them. --- pango/meson.build | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pango/meson.build b/pango/meson.build index a86617b4..ad7fb798 100644 --- a/pango/meson.build +++ b/pango/meson.build @@ -240,7 +240,7 @@ if build_pangoft2 nsversion: pango_api_version, identifier_prefix: 'Pango', symbol_prefix: 'pango', - export_packages: 'pangoft2', + export_packages: 'pangofc', includes: [ pango_gir[0], 'fontconfig-2.0', ], header: 'pango/pangofc-fontmap.h', install: true, @@ -258,7 +258,7 @@ if build_pangoft2 nsversion: pango_api_version, identifier_prefix: 'Pango', symbol_prefix: 'pango', - export_packages: 'pangoft2', + export_packages: 'pangoot', includes: [ pangofc_gir[0], 'freetype2-2.0', ], header: 'pango/pango-ot.h', install: true, @@ -295,11 +295,27 @@ if build_pangoft2 pkgconfig.generate(libpangoft2, name: 'Pango FT2 and Pango Fc', description: 'Freetype 2.0 and fontconfig font support for Pango', - version: meson.project_version(), filebase: 'pangoft2', subdirs: pango_api_name, requires: [ 'pango', freetype2_pc, fontconfig_pc ], - install_dir: join_paths(pango_libdir, 'pkgconfig'), + ) + + # Since we split the introspection data, we also need a split pkg-config + # file for Vala + pkgconfig.generate( + name: 'Pango OT', + description: 'OpenType font support for Pango (deprecated)', + filebase: 'pangoot', + subdirs: pango_api_name, + requires: [ 'pangoft2' ], + ) + + pkgconfig.generate( + name: 'Pango FC', + description: 'Fontconfig support for Pango', + filebase: 'pangofc', + subdirs: pango_api_name, + requires: [ 'pangoft2' ], ) else # For usage as a subproject -- cgit v1.2.1 From fb8664764b6d2432a8f91f309439b00a60f07106 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 8 Jun 2020 17:08:08 +0100 Subject: Skip layout tests if the en_US locale is not available There's no point in running a tests if we know the locale isn't there. The reason gets logged, so the developer can decide to install it. --- tests/test-layout.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test-layout.c b/tests/test-layout.c index 2fc78240..9661457b 100644 --- a/tests/test-layout.c +++ b/tests/test-layout.c @@ -304,6 +304,16 @@ test_layout (gconstpointer d) GString *dump; gchar *diff; + const char *old_locale = setlocale (LC_ALL, NULL); + setlocale (LC_ALL, "en_US.UTF-8"); + if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL) + { + char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping layout %s", filename); + g_test_skip (msg); + g_free (msg); + return; + } + expected_file = get_expected_filename (filename); dump = g_string_sized_new (0); @@ -323,6 +333,8 @@ test_layout (gconstpointer d) g_string_free (dump, TRUE); g_free (expected_file); + + setlocale (LC_ALL, old_locale); } int @@ -333,9 +345,6 @@ main (int argc, char *argv[]) const gchar *name; gchar *path; - g_setenv ("LC_ALL", "en_US.UTF-8", TRUE); - setlocale (LC_ALL, ""); - g_test_init (&argc, &argv, NULL); context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); -- cgit v1.2.1 From 6944e96edf3e12ce5ee35043e638462ab43d2e26 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 14 Apr 2020 20:37:42 +0200 Subject: Fix some annotations --- pango/pangocairo-context.c | 2 +- pango/pangocairo-font.c | 2 +- pango/pangocairo.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pango/pangocairo-context.c b/pango/pangocairo-context.c index 5949c448..d2e66c4b 100644 --- a/pango/pangocairo-context.c +++ b/pango/pangocairo-context.c @@ -374,7 +374,7 @@ pango_cairo_context_set_shape_renderer (PangoContext *context, * attributes of type %PANGO_ATTR_SHAPE as set by * pango_cairo_context_set_shape_renderer(), if any. * - * Return value: (nullable): the shape rendering callback previously + * Return value: (transfer none) (nullable): the shape rendering callback previously * set on the context, or %NULL if no shape rendering callback have * been set. * diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c index a49d14d4..1cadd005 100644 --- a/pango/pangocairo-font.c +++ b/pango/pangocairo-font.c @@ -143,7 +143,7 @@ done: * The scaled font can be referenced and kept using * cairo_scaled_font_reference(). * - * Return value: (nullable): the #cairo_scaled_font_t used by @font, + * Return value: (transfer none) (nullable): the #cairo_scaled_font_t used by @font, * or %NULL if @font is %NULL. * * Since: 1.18 diff --git a/pango/pangocairo.h b/pango/pangocairo.h index d15d879b..cd368f8f 100644 --- a/pango/pangocairo.h +++ b/pango/pangocairo.h @@ -64,7 +64,7 @@ typedef struct _PangoCairoFontMap PangoCairoFontMap; * path of @cr and no filling/stroking done. This will be set * to %TRUE when called from pango_cairo_layout_path() and * pango_cairo_layout_line_path() rendering functions. - * @data: user data passed to pango_cairo_context_set_shape_renderer() + * @data: (closure): user data passed to pango_cairo_context_set_shape_renderer() * * Function type for rendering attributes of type %PANGO_ATTR_SHAPE * with Pango's Cairo renderer. -- cgit v1.2.1 From ce2258484f22e43c83ffb6825cfa0e5af2c40925 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 14 Apr 2020 20:45:14 +0200 Subject: meson: Fix help2man options command line --- utils/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/meson.build b/utils/meson.build index 510d1b7e..b71cfe2a 100644 --- a/utils/meson.build +++ b/utils/meson.build @@ -47,7 +47,7 @@ if help2man.found() and not meson.is_cross_build() '--no-info', '--section=1', '--help-option=--help-all', - '--name=Pango text viewer', + '--name="Pango text viewer"', ] custom_target('pango-view.1', -- cgit v1.2.1 From 85167fff28951658fa89b3bcfe13a78176d2a8d7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 8 Jun 2020 17:29:28 +0100 Subject: Skip test-itemize when the en_US locale is missing Just like test-layout. --- tests/test-itemize.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/test-itemize.c b/tests/test-itemize.c index 167e4e80..51f2bb9c 100644 --- a/tests/test-itemize.c +++ b/tests/test-itemize.c @@ -110,7 +110,7 @@ test_file (const gchar *filename, GString *string) gchar *contents; gsize length; GError *error = NULL; - GString *s1, *s2, *s3, *s4, *s5, *s6; + GString *s1, *s2, *s3, *s4, *s5, *s6; char *test; char *text; PangoAttrList *attrs; @@ -237,6 +237,16 @@ test_itemize (gconstpointer d) GString *dump; gchar *diff; + const char *old_locale = setlocale (LC_ALL, NULL); + setlocale (LC_ALL, "en_US.UTF-8"); + if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL) + { + char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping itemization %s", filename); + g_test_skip (msg); + g_free (msg); + return; + } + expected_file = get_expected_filename (filename); dump = g_string_sized_new (0); @@ -256,6 +266,8 @@ test_itemize (gconstpointer d) g_string_free (dump, TRUE); g_free (expected_file); + + setlocale (LC_ALL, old_locale); } int @@ -266,9 +278,6 @@ main (int argc, char *argv[]) const gchar *name; gchar *path; - g_setenv ("LC_ALL", "en_US.UTF-8", TRUE); - setlocale (LC_ALL, ""); - g_test_init (&argc, &argv, NULL); context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); -- cgit v1.2.1 From 984ed4597d51a1f81f6bb9006dc503901cc6401a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 8 Jun 2020 17:30:12 +0100 Subject: Skip test-break when the en_US locale is missing Just like test-layout and test-itemize. --- tests/test-break.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test-break.c b/tests/test-break.c index f4faaab3..e92cbe8e 100644 --- a/tests/test-break.c +++ b/tests/test-break.c @@ -241,6 +241,16 @@ test_break (gconstpointer d) GString *dump; gchar *diff; + const char *old_locale = setlocale (LC_ALL, NULL); + setlocale (LC_ALL, "en_US.UTF-8"); + if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL) + { + char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping break %s", filename); + g_test_skip (msg); + g_free (msg); + return; + } + expected_file = get_expected_filename (filename); dump = g_string_sized_new (0); @@ -260,6 +270,8 @@ test_break (gconstpointer d) g_string_free (dump, TRUE); g_free (expected_file); + + setlocale (LC_ALL, old_locale); } int @@ -270,9 +282,6 @@ main (int argc, char *argv[]) const gchar *name; gchar *path; - g_setenv ("LC_ALL", "en_US.UTF-8", TRUE); - setlocale (LC_ALL, ""); - g_test_init (&argc, &argv, NULL); context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); -- cgit v1.2.1 From c3de8bca2d084e90a77d50db40447f145520e4f5 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 8 Jun 2020 17:52:56 +0100 Subject: tests: Ensure we respect the TAP output format When dumping the diff between the computed and expected results, we need to respect the TAP format and place "#" in front of each line. --- tests/test-break.c | 15 ++++++++++++--- tests/test-itemize.c | 15 ++++++++++++--- tests/test-layout.c | 14 +++++++++++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/tests/test-break.c b/tests/test-break.c index e92cbe8e..cdb7e6c0 100644 --- a/tests/test-break.c +++ b/tests/test-break.c @@ -260,18 +260,27 @@ test_break (gconstpointer d) diff = diff_with_file (expected_file, dump->str, dump->len, &error); g_assert_no_error (error); + setlocale (LC_ALL, old_locale); + if (diff && diff[0]) { + char **lines = g_strsplit (diff, "\n", -1); + const char *line; + int i = 0; + g_test_message ("Contents don't match expected contents"); - g_test_message ("%s", diff); + + for (line = lines[0]; line != NULL; line = lines[++i]) + g_test_message ("%s", line); + g_test_fail (); + + g_strfreev (lines); g_free (diff); } g_string_free (dump, TRUE); g_free (expected_file); - - setlocale (LC_ALL, old_locale); } int diff --git a/tests/test-itemize.c b/tests/test-itemize.c index 51f2bb9c..1709b834 100644 --- a/tests/test-itemize.c +++ b/tests/test-itemize.c @@ -256,18 +256,27 @@ test_itemize (gconstpointer d) diff = diff_with_file (expected_file, dump->str, dump->len, &error); g_assert_no_error (error); + setlocale (LC_ALL, old_locale); + if (diff && diff[0]) { + char **lines = g_strsplit (diff, "\n", -1); + const char *line; + int i = 0; + g_test_message ("Contents don't match expected contents"); - g_test_message ("%s", diff); + + for (line = lines[0]; line != NULL; line = lines[++i]) + g_test_message ("%s", line); + g_test_fail (); + + g_strfreev (lines); g_free (diff); } g_string_free (dump, TRUE); g_free (expected_file); - - setlocale (LC_ALL, old_locale); } int diff --git a/tests/test-layout.c b/tests/test-layout.c index 9661457b..623b7a70 100644 --- a/tests/test-layout.c +++ b/tests/test-layout.c @@ -323,18 +323,26 @@ test_layout (gconstpointer d) diff = diff_with_file (expected_file, dump->str, dump->len, &error); g_assert_no_error (error); + setlocale (LC_ALL, old_locale); + if (diff && diff[0]) { + char **lines = g_strsplit (diff, "\n", -1); + const char *line; + int i = 0; + g_test_message ("Contents don't match expected contents"); - g_test_message ("%s", diff); + + for (line = lines[0]; line != NULL; line = lines[++i]) + g_test_message ("%s", line); + g_test_fail (); + g_strfreev (lines); g_free (diff); } g_string_free (dump, TRUE); g_free (expected_file); - - setlocale (LC_ALL, old_locale); } int -- cgit v1.2.1 From f6032b754fd76ebbf0ae6ec4f3c8b2616add0e91 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 8 Jun 2020 18:03:22 +0100 Subject: tests: Update the locale use Create the PangoContext for the test after resetting the locale, and use the en_US.utf8 name, as it seems to be the name used by Fedora. --- tests/test-break.c | 7 ++++--- tests/test-itemize.c | 6 +++--- tests/test-layout.c | 7 ++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/test-break.c b/tests/test-break.c index cdb7e6c0..49eaa653 100644 --- a/tests/test-break.c +++ b/tests/test-break.c @@ -242,7 +242,7 @@ test_break (gconstpointer d) gchar *diff; const char *old_locale = setlocale (LC_ALL, NULL); - setlocale (LC_ALL, "en_US.UTF-8"); + setlocale (LC_ALL, "en_US.utf8"); if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL) { char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping break %s", filename); @@ -251,6 +251,9 @@ test_break (gconstpointer d) return; } + if (context == NULL) + context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); + expected_file = get_expected_filename (filename); dump = g_string_sized_new (0); @@ -293,8 +296,6 @@ main (int argc, char *argv[]) g_test_init (&argc, &argv, NULL); - context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); - /* allow to easily generate expected output for new test cases */ if (argc > 1) { diff --git a/tests/test-itemize.c b/tests/test-itemize.c index 1709b834..3c58e18f 100644 --- a/tests/test-itemize.c +++ b/tests/test-itemize.c @@ -238,7 +238,7 @@ test_itemize (gconstpointer d) gchar *diff; const char *old_locale = setlocale (LC_ALL, NULL); - setlocale (LC_ALL, "en_US.UTF-8"); + setlocale (LC_ALL, "en_US.utf8"); if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL) { char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping itemization %s", filename); @@ -247,6 +247,8 @@ test_itemize (gconstpointer d) return; } + context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); + expected_file = get_expected_filename (filename); dump = g_string_sized_new (0); @@ -289,8 +291,6 @@ main (int argc, char *argv[]) g_test_init (&argc, &argv, NULL); - context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); - /* allow to easily generate expected output for new test cases */ if (argc > 1) { diff --git a/tests/test-layout.c b/tests/test-layout.c index 623b7a70..52617ce6 100644 --- a/tests/test-layout.c +++ b/tests/test-layout.c @@ -305,7 +305,7 @@ test_layout (gconstpointer d) gchar *diff; const char *old_locale = setlocale (LC_ALL, NULL); - setlocale (LC_ALL, "en_US.UTF-8"); + setlocale (LC_ALL, "en_US.utf8"); if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL) { char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping layout %s", filename); @@ -314,6 +314,9 @@ test_layout (gconstpointer d) return; } + if (context == NULL) + context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); + expected_file = get_expected_filename (filename); dump = g_string_sized_new (0); @@ -355,8 +358,6 @@ main (int argc, char *argv[]) g_test_init (&argc, &argv, NULL); - context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); - /* allow to easily generate expected output for new test cases */ if (argc > 1) { -- cgit v1.2.1