[pango/pango2: 1/10] context: Reshuffle convenience api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 1/10] context: Reshuffle convenience api
- Date: Thu, 16 Jun 2022 10:58:32 +0000 (UTC)
commit 59e049d522b04fa39a39e175409c9e9f35c6b5b0
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jun 15 07:30:20 2022 -0400
context: Reshuffle convenience api
Replace pango_context_new_with_font_map with
pango_context_new_with_font_map, and make
pango_context_new explicitly use the default
fontmap.
Update all callers.
examples/columns.c | 2 +-
examples/parshape.c | 2 +-
examples/userfont.c | 2 +-
pango/pango-context.c | 37 ++++++++++++++++++++++++++++---------
pango/pango-context.h | 3 +++
pango/pango-fontmap.c | 31 -------------------------------
pango/pango-fontmap.h | 2 --
pango/pango-hbfont.c | 2 +-
pango/pangocairo-context.c | 4 +---
pango/pangocairo-font.c | 2 +-
tests/meson.build | 2 +-
tests/test-bidi.c | 5 +----
tests/test-break.c | 4 ++--
tests/test-ellipsize.c | 5 +----
tests/test-font.c | 19 ++++++-------------
tests/test-fontsets.c | 2 +-
tests/test-itemize.c | 2 +-
tests/test-layout.c | 4 ++--
tests/testhbfont.c | 6 +++---
tests/testiter.c | 8 ++------
tests/testmisc.c | 36 ++++++++++++++++++------------------
tests/testrandom.c | 4 ++--
tests/testserialize.c | 10 +++++-----
utils/pango-list.c | 2 +-
utils/pango-segmentation.c | 2 +-
utils/viewer-pangocairo.c | 2 +-
26 files changed, 85 insertions(+), 115 deletions(-)
---
diff --git a/examples/columns.c b/examples/columns.c
index 7f76335c..4884c0dc 100644
--- a/examples/columns.c
+++ b/examples/columns.c
@@ -33,7 +33,7 @@ main (int argc, char *argv[])
filename = argv[2];
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 600, 600);
cr = cairo_create (surface);
diff --git a/examples/parshape.c b/examples/parshape.c
index 2fe8cbe9..3774834d 100644
--- a/examples/parshape.c
+++ b/examples/parshape.c
@@ -10,7 +10,7 @@ format_text (const char *text)
int x, y, width;
int inc, m, w, w2;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
breaker = pango_line_breaker_new (context);
pango_line_breaker_add_text (breaker, text, -1, NULL);
diff --git a/examples/userfont.c b/examples/userfont.c
index 92ca101b..7c35cd5e 100644
--- a/examples/userfont.c
+++ b/examples/userfont.c
@@ -82,7 +82,7 @@ get_layout (void)
PangoFontDescription *desc;
/* Create a PangoLayout, set the font and text */
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new_with_font_map (fontmap);
layout = pango_layout_new (context);
g_object_unref (context);
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 17c7483c..6503e857 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -45,7 +45,7 @@
* to look up fonts, and default values such as the default language,
* default gravity, or default font.
*
- * To obtain a `PangoContext`, use [method@Pango.FontMap.create_context]
+ * To obtain a `PangoContext`, use [ctor Pango Context new]
* or [func@Pango.cairo_create_context].
*/
@@ -351,10 +351,9 @@ pango_context_finalize (GObject *object)
*
* Creates a new `PangoContext` initialized to default values.
*
- * This function is not particularly useful as it should always
- * be followed by a [method@Pango.Context.set_font_map] call, and the
- * function [method@Pango.FontMap.create_context] does these two steps
- * together and hence users are recommended to use that.
+ * If you want to use a specific [class@Pango.FontMap] other than
+ * the default one, you should use [ctor@Pango.Context.new_with_font_map]
+ * instead.
*
* If you are using Pango as part of a higher-level system,
* that system may have it's own way of create a `PangoContext`.
@@ -367,11 +366,31 @@ pango_context_finalize (GObject *object)
PangoContext *
pango_context_new (void)
{
- PangoContext *context;
-
- context = g_object_new (PANGO_TYPE_CONTEXT, NULL);
+ return g_object_new (PANGO_TYPE_CONTEXT,
+ "font-map", pango_font_map_get_default (),
+ NULL);
+}
- return context;
+/**
+ * pango_context_new_with_font_map:
+ * @font_map: the `PangoFontMap` to use
+ *
+ * Creates a new `PangoContext` with the given font map.
+ *
+ * If you are using Pango as part of a higher-level system,
+ * that system may have it's own way of create a `PangoContext`.
+ * Pango's own cairo support for instance, has [func@Pango.cairo_create_context],
+ * and the GTK toolkit has, among others, gtk_widget_get_pango_context().
+ * Use those instead.
+ *
+ * Return value: the newly allocated `PangoContext`
+ */
+PangoContext *
+pango_context_new_with_font_map (PangoFontMap *font_map)
+{
+ return g_object_new (PANGO_TYPE_CONTEXT,
+ "font-map", font_map,
+ NULL);
}
static void
diff --git a/pango/pango-context.h b/pango/pango-context.h
index 2830b3fe..99400fef 100644
--- a/pango/pango-context.h
+++ b/pango/pango-context.h
@@ -34,6 +34,9 @@ G_DECLARE_FINAL_TYPE (PangoContext, pango_context, PANGO, CONTEXT, GObject);
PANGO_AVAILABLE_IN_ALL
PangoContext * pango_context_new (void);
+PANGO_AVAILABLE_IN_ALL
+PangoContext * pango_context_new_with_font_map (PangoFontMap *font_map);
+
PANGO_AVAILABLE_IN_ALL
void pango_context_changed (PangoContext *context);
PANGO_AVAILABLE_IN_ALL
diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c
index 7b8a3add..99fbae64 100644
--- a/pango/pango-fontmap.c
+++ b/pango/pango-fontmap.c
@@ -745,37 +745,6 @@ pango_font_map_changed (PangoFontMap *self)
/* }}} */
/* {{{ Public API */
-/**
- * pango_font_map_create_context:
- * @self: a `PangoFontMap`
- *
- * Creates a `PangoContext` connected to @fontmap.
- *
- * This is equivalent to [ctor Pango Context new] followed by
- * [method@Pango.Context.set_font_map].
- *
- * If you are using Pango as part of a higher-level system,
- * that system may have it's own way of create a `PangoContext`.
- * Pango's own cairo support for instance, has [func@Pango.cairo_create_context],
- * and the GTK toolkit has, among others, gtk_widget_get_pango_context().
- * Use those instead.
- *
- * Return value: (transfer full): the newly created `PangoContext`
- */
-PangoContext *
-pango_font_map_create_context (PangoFontMap *self)
-{
- PangoContext *context;
-
- g_return_val_if_fail (PANGO_IS_FONT_MAP (self), NULL);
-
- context = pango_context_new ();
- pango_context_set_font_map (context, self);
-
- return context;
-}
-
-
/**
* pango_font_map_load_font:
* @self: a `PangoFontMap`
diff --git a/pango/pango-fontmap.h b/pango/pango-fontmap.h
index ac106b08..14ff5c30 100644
--- a/pango/pango-fontmap.h
+++ b/pango/pango-fontmap.h
@@ -30,8 +30,6 @@ G_BEGIN_DECLS
PANGO_AVAILABLE_IN_ALL
PANGO_DECLARE_INTERNAL_TYPE (PangoFontMap, pango_font_map, PANGO, FONT_MAP, GObject)
-PANGO_AVAILABLE_IN_ALL
-PangoContext * pango_font_map_create_context (PangoFontMap *self);
PANGO_AVAILABLE_IN_ALL
PangoFont * pango_font_map_load_font (PangoFontMap *self,
PangoContext *context,
diff --git a/pango/pango-hbfont.c b/pango/pango-hbfont.c
index 373f3bb9..8f720893 100644
--- a/pango/pango-hbfont.c
+++ b/pango/pango-hbfont.c
@@ -382,7 +382,7 @@ create_hex_box_info (PangoHbFont *self)
pango_font_description_set_size (desc, mini_size);
/* Load mini_font */
- context = pango_font_map_create_context (map);
+ context = pango_context_new_with_font_map (map);
pango_context_set_matrix (context, &font->ctm);
pango_context_set_language (context, pango_script_get_sample_language (G_UNICODE_SCRIPT_LATIN));
diff --git a/pango/pangocairo-context.c b/pango/pangocairo-context.c
index 9a968643..81b4ea17 100644
--- a/pango/pangocairo-context.c
+++ b/pango/pangocairo-context.c
@@ -211,13 +211,11 @@ pango_cairo_context_get_merged_font_options (PangoContext *context)
PangoContext *
pango_cairo_create_context (cairo_t *cr)
{
- PangoFontMap *fontmap;
PangoContext *context;
g_return_val_if_fail (cr != NULL, NULL);
- fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new ();
pango_cairo_update_context (cr, context);
return context;
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 0541c317..1fc629fb 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -450,7 +450,7 @@ _pango_cairo_font_private_get_hex_box_info (PangoCairoFontPrivate *cf_priv)
/* load mini_font */
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new_with_font_map (fontmap);
pango_context_set_matrix (context, &pango_ctm);
pango_context_set_language (context, pango_script_get_sample_language (G_UNICODE_SCRIPT_LATIN));
diff --git a/tests/meson.build b/tests/meson.build
index b016a7ff..735abc22 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -38,7 +38,7 @@ if cairo_dep.found()
[ 'test-harfbuzz', [ 'test-harfbuzz.c' ] ],
[ 'test-break', [ 'test-break.c', 'test-common.c', 'validate-log-attrs.c' ] ],
[ 'testmisc', [ 'testmisc.c' ] ],
- [ 'testserialize', [ 'testserialize.c' ] ],
+ [ 'testserialize', [ 'testserialize.c', 'test-common.c' ] ],
[ 'testhbfont', [ 'testhbfont.c' ] ],
[ 'test-layout', [ 'test-layout.c', 'test-common.c' ] ],
[ 'test-fontsets', [ 'test-fontsets.c', 'test-common.c' ] ],
diff --git a/tests/test-bidi.c b/tests/test-bidi.c
index f4628354..c7b412f6 100644
--- a/tests/test-bidi.c
+++ b/tests/test-bidi.c
@@ -373,12 +373,9 @@ test_move_cursor_para (void)
int
main (int argc, char *argv[])
{
- PangoFontMap *fontmap;
-
setlocale (LC_ALL, "");
- fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new ();
g_test_init (&argc, &argv, NULL);
diff --git a/tests/test-break.c b/tests/test-break.c
index 42cd5346..f4f75a3b 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -390,7 +390,7 @@ main (int argc, char *argv[])
if (opt_fonts)
{
install_fonts (opt_fonts);
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
g_free (opt_fonts);
}
@@ -427,7 +427,7 @@ main (int argc, char *argv[])
if (!opt_fonts)
{
install_fonts (NULL);
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
}
path = g_test_build_filename (G_TEST_DIST, "breaks", NULL);
diff --git a/tests/test-ellipsize.c b/tests/test-ellipsize.c
index b8304442..fcd5d049 100644
--- a/tests/test-ellipsize.c
+++ b/tests/test-ellipsize.c
@@ -108,10 +108,7 @@ test_ellipsize_fully (void)
int
main (int argc, char *argv[])
{
- PangoFontMap *fontmap;
-
- fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new ();
g_test_init (&argc, &argv, NULL);
diff --git a/tests/test-font.c b/tests/test-font.c
index f5216cb9..6bb8be7f 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -202,7 +202,7 @@ test_extents (void)
PangoFontDescription *desc;
PangoDirection dir;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
desc = pango_font_description_from_string("Cantarell 11");
pango_context_set_font_description (context, desc);
pango_font_description_free (desc);
@@ -237,7 +237,7 @@ test_enumerate (void)
gboolean found_face;
fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new_with_font_map (fontmap);
g_assert_cmpint (g_list_model_get_n_items (G_LIST_MODEL (fontmap)), >, 0);
@@ -288,7 +288,6 @@ test_enumerate (void)
static void
test_roundtrip_plain (void)
{
- PangoFontMap *fontmap;
PangoContext *context;
PangoFontDescription *desc, *desc2, *desc3;
PangoFont *font, *font2;
@@ -299,9 +298,7 @@ test_roundtrip_plain (void)
desc = pango_font_description_from_string ("Cantarell 11");
#endif
- fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
-
+ context = pango_context_new ();
font = pango_context_load_font (context, desc);
desc2 = pango_font_describe (font);
@@ -323,7 +320,6 @@ test_roundtrip_plain (void)
static void
test_roundtrip_small_caps (void)
{
- PangoFontMap *fontmap;
PangoContext *context;
PangoFontDescription *desc, *desc2;
PangoFont *font;
@@ -336,8 +332,7 @@ test_roundtrip_small_caps (void)
return;
}
- fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new ();
desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
g_assert_true (pango_font_description_get_variant (desc) == PANGO_VARIANT_SMALL_CAPS);
@@ -405,13 +400,11 @@ test_roundtrip_small_caps (void)
static void
test_roundtrip_emoji (void)
{
- PangoFontMap *fontmap;
PangoContext *context;
PangoFontDescription *desc, *desc2;
PangoFont *font;
- fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new ();
/* This is how pango_itemize creates the emoji font desc */
desc = pango_font_description_from_string ("Cantarell 11");
@@ -554,7 +547,7 @@ main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
g_test_add_func ("/pango/font/metrics", test_metrics);
g_test_add_func ("/pango/fontdescription/parse", test_parse);
diff --git a/tests/test-fontsets.c b/tests/test-fontsets.c
index 814c3708..62062f84 100644
--- a/tests/test-fontsets.c
+++ b/tests/test-fontsets.c
@@ -41,7 +41,7 @@ list_fonts (const char *contents)
desc = pango_font_description_from_string (s);
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
fonts = pango_context_load_fontset (context, desc, pango_language_get_default ());
str = g_string_new (s);
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index dc03ade5..daefff17 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -332,7 +332,7 @@ main (int argc, char *argv[])
const char *name;
char *path;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
pango_context_set_language (context, pango_language_from_string ("en-us"));
/* allow to easily generate expected output for new test cases */
diff --git a/tests/test-layout.c b/tests/test-layout.c
index f83fbc36..c99b94f3 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -60,7 +60,7 @@ test_layout (gconstpointer d)
g_assert_no_error (error);
orig = g_bytes_new_take (contents, length);
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_deserialize (context, orig, PANGO_LAYOUT_DESERIALIZE_CONTEXT, &error);
g_assert_no_error (error);
@@ -143,7 +143,7 @@ main (int argc, char *argv[])
g_file_get_contents (argv[1], &contents, &length, &error);
g_assert_no_error (error);
orig = g_bytes_new_take (contents, length);
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_deserialize (context, orig, PANGO_LAYOUT_DESERIALIZE_CONTEXT, &error);
g_assert_no_error (error);
diff --git a/tests/testhbfont.c b/tests/testhbfont.c
index 293c04cb..ece94561 100644
--- a/tests/testhbfont.c
+++ b/tests/testhbfont.c
@@ -376,7 +376,7 @@ test_hbfont_load (void)
/* Make a Cat family, with the two faces Fat and Wild */
map = pango_font_map_new ();
- context = pango_font_map_create_context (PANGO_FONT_MAP (map));
+ context = pango_context_new_with_font_map (PANGO_FONT_MAP (map));
path = g_test_build_filename (G_TEST_DIST, "fonts", "Cantarell-VF.otf", NULL);
desc = pango_font_description_new ();
@@ -442,7 +442,7 @@ test_hbfont_load_variation (void)
/* Make a Cat family, with the two faces Fat and Wild */
map = pango_font_map_new ();
- context = pango_font_map_create_context (PANGO_FONT_MAP (map));
+ context = pango_context_new_with_font_map (PANGO_FONT_MAP (map));
path = g_test_build_filename (G_TEST_DIST, "fonts", "Cantarell-VF.otf", NULL);
desc = pango_font_description_new ();
@@ -514,7 +514,7 @@ test_fontmap_language (void)
gboolean found;
map = PANGO_FONT_MAP (pango_font_map_new_default ());
- context = pango_font_map_create_context (map);
+ context = pango_context_new_with_font_map (map);
desc = pango_font_description_from_string ("serif 11");
/* zz isn't assigned, so there should not be any fonts claiming to support
diff --git a/tests/testiter.c b/tests/testiter.c
index a3c128be..7cad242b 100644
--- a/tests/testiter.c
+++ b/tests/testiter.c
@@ -227,13 +227,11 @@ static void
test_line_iter (void)
{
const char **ptext;
- PangoFontMap *fontmap;
PangoContext *context;
PangoFontDescription *font_desc;
PangoLayout *layout;
- fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new ();
font_desc = pango_font_description_from_string ("cantarell 11");
pango_context_set_font_description (context, font_desc);
@@ -260,15 +258,13 @@ test_line_iter (void)
static void
test_glyphitem_iter (void)
{
- PangoFontMap *fontmap;
PangoContext *context;
PangoFontDescription *font_desc;
PangoLayout *layout;
PangoLine *line;
const char *text;
- fontmap = pango_font_map_get_default ();
- context = pango_font_map_create_context (fontmap);
+ context = pango_context_new ();
font_desc = pango_font_description_from_string ("cantarell 11");
pango_context_set_font_description (context, font_desc);
diff --git a/tests/testmisc.c b/tests/testmisc.c
index dc1cb1cf..c2158795 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -31,7 +31,7 @@ test_itemize_empty_crash (void)
{
PangoContext *context;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
pango_itemize (context, PANGO_DIRECTION_LTR, "", 0, 1, NULL);
g_object_unref (context);
@@ -43,7 +43,7 @@ test_itemize_utf8 (void)
PangoContext *context;
GList *result = NULL;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
result = pango_itemize (context, PANGO_DIRECTION_LTR, "\xc3\xa1\na", 3, 1, NULL);
g_assert (result != NULL);
@@ -61,7 +61,7 @@ test_short_string_crash (void)
PangoLayout *layout;
PangoRectangle ext;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, "short text", 200);
pango_lines_get_extents (pango_layout_get_lines (layout), &ext, &ext);
@@ -92,7 +92,7 @@ test_line_height (void)
PangoLine *line;
PangoRectangle ext;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, "one\ttwo", -1);
line = pango_lines_get_lines (pango_layout_get_lines (layout))[0];
@@ -112,7 +112,7 @@ test_line_height2 (void)
PangoLine *line;
PangoRectangle ext1, ext2;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, "one", -1);
@@ -142,7 +142,7 @@ test_line_height3 (void)
PangoRectangle ext1;
PangoRectangle ext2;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, "one", -1);
attrs = pango_attr_list_new ();
@@ -180,7 +180,7 @@ test_run_height (void)
return;
}
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, "one", -1);
@@ -207,7 +207,7 @@ test_cursor_height (void)
PangoLayout *layout;
PangoRectangle strong;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, "one\ttwo", -1);
@@ -353,7 +353,7 @@ test_fallback_shape (void)
GList *items, *l;
PangoDirection dir;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
dir = pango_context_get_base_dir (context);
text = "Some text to shape ﺄﻧﺍ ﻕﺍﺩﺭ ﻊﻟﻯ ﺄﻜﻟ ﺎﻟﺰﺟﺎﺟ ﻭ ﻩﺫﺍ ﻻ ﻱﺆﻠﻤﻨﻳ";
@@ -393,7 +393,7 @@ test_get_cursor_crash (void)
const char *string = "foo\n\rbar\r\nbaz\n\nqux\n\n..";
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
@@ -423,7 +423,7 @@ test_get_cursor (void)
PangoLayout *layout;
PangoRectangle strong, weak;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, text, -1);
@@ -456,7 +456,7 @@ test_index_to_x (void)
"acually", // zero-width space
};
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
for (int i = 0; i < G_N_ELEMENTS (tests); i++)
{
@@ -525,7 +525,7 @@ test_extents (void)
{ "paragraph", -1 }, // soft hyphens
};
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
for (int i = 0; i < G_N_ELEMENTS (tests); i++)
{
@@ -611,7 +611,7 @@ test_empty_line_height (void)
return;
}
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
description = pango_font_description_new ();
for (size = 10; size <= 20; size++)
@@ -663,7 +663,7 @@ test_gravity_metrics (void)
PangoRectangle log[4];
map = pango_font_map_get_default ();
- context = pango_font_map_create_context (map);
+ context = pango_context_new_with_font_map (map);
desc = pango_font_description_from_string ("Cantarell 64");
@@ -709,7 +709,7 @@ test_gravity_metrics2 (void)
pango_font_map_add_file (map, path);
g_free (path);
- context = pango_font_map_create_context (PANGO_FONT_MAP (map));
+ context = pango_context_new_with_font_map (PANGO_FONT_MAP (map));
desc = pango_font_description_from_string ("Cantarell 64");
@@ -786,7 +786,7 @@ test_wrap_char (void)
PangoLayout *layout;
PangoRectangle ext, ext1;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, "Rows can have suffix widgets", -1);
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
@@ -819,7 +819,7 @@ test_small_caps_crash (void)
return;
}
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
layout = pango_layout_new (context);
desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
pango_layout_set_font_description (layout, desc);
diff --git a/tests/testrandom.c b/tests/testrandom.c
index f3aeb6b5..02469587 100644
--- a/tests/testrandom.c
+++ b/tests/testrandom.c
@@ -111,7 +111,7 @@ test_wrap_char (gconstpointer data)
Size sizes[100];
gsize i, j;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
desc = pango_font_description_from_string ("Sans 10");
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, desc);
@@ -181,7 +181,7 @@ test_wrap_char_min_width (gconstpointer data)
gsize j;
int test_width, ref_width;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
desc = pango_font_description_from_string ("Sans 10");
ref_layout = pango_layout_new (context);
pango_layout_set_font_description (ref_layout, desc);
diff --git a/tests/testserialize.c b/tests/testserialize.c
index 034529d2..da2c78d7 100644
--- a/tests/testserialize.c
+++ b/tests/testserialize.c
@@ -157,7 +157,7 @@ test_serialize_font (void)
" ]\n"
"}";
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
desc = pango_font_description_from_string ("Cantarell Italic 20 @wght=600");
font = pango_context_load_font (context, desc);
@@ -200,7 +200,7 @@ test_serialize_layout_minimal (void)
GBytes *out_bytes;
const char *str;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
bytes = g_bytes_new_static (test, strlen (test) + 1);
@@ -283,7 +283,7 @@ test_serialize_layout_valid (void)
GBytes *out_bytes;
char *s;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
bytes = g_bytes_new_static (test, strlen (test) + 1);
@@ -336,7 +336,7 @@ test_serialize_layout_context (void)
PangoLayout *layout;
GError *error = NULL;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
bytes = g_bytes_new_static (test, strlen (test) + 1);
@@ -410,7 +410,7 @@ test_serialize_layout_invalid (void)
PangoContext *context;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
for (int i = 0; i < G_N_ELEMENTS (test); i++)
{
diff --git a/utils/pango-list.c b/utils/pango-list.c
index 9d69a82c..67070449 100644
--- a/utils/pango-list.c
+++ b/utils/pango-list.c
@@ -141,7 +141,7 @@ main (int argc,
}
fontmap = pango_font_map_get_default ();
- ctx = pango_font_map_create_context (fontmap);
+ ctx = pango_context_new ();
if (opt_verbose)
g_print ("Using %s\n\n", G_OBJECT_TYPE_NAME (fontmap));
diff --git a/utils/pango-segmentation.c b/utils/pango-segmentation.c
index 573e0cf2..dc34db84 100644
--- a/utils/pango-segmentation.c
+++ b/utils/pango-segmentation.c
@@ -70,7 +70,7 @@ show_segmentation (const char *input,
PangoAttrList *attributes;
PangoLayout *layout;
- context = pango_font_map_create_context (pango_font_map_get_default ());
+ context = pango_context_new ();
string = g_string_new ("");
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c
index 8c11df21..070045eb 100644
--- a/utils/viewer-pangocairo.c
+++ b/utils/viewer-pangocairo.c
@@ -102,7 +102,7 @@ pangocairo_view_get_context (gpointer instance)
CairoViewer *c = (CairoViewer *) instance;
PangoContext *context;
- context = pango_font_map_create_context (c->fontmap);
+ context = pango_context_new_with_font_map (c->fontmap);
pango_cairo_context_set_font_options (context, c->font_options);
pango_context_set_round_glyph_positions (context, !c->subpixel_positions);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]