[pango/userfont: 11/15] examples: Adapt
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/userfont: 11/15] examples: Adapt
- Date: Fri, 28 Jan 2022 14:04:51 +0000 (UTC)
commit ddb082cd779162e1c862ddbf7102725571157e4b
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 28 00:31:55 2022 -0500
examples: Adapt
examples/cairoshape.c | 23 ++++++++++++++++++-----
examples/userfont.c | 28 ++++++++++++++++++++--------
2 files changed, 38 insertions(+), 13 deletions(-)
---
diff --git a/examples/cairoshape.c b/examples/cairoshape.c
index 07d62f44..4aec3b0f 100644
--- a/examples/cairoshape.c
+++ b/examples/cairoshape.c
@@ -187,16 +187,21 @@ glyph_cb (PangoUserFace *face,
return FALSE;
}
-static hb_position_t
+static gboolean
advance_cb (PangoUserFace *face,
int size,
hb_codepoint_t glyph,
+ hb_position_t *h_advance,
+ hb_position_t *v_advance,
gpointer user_data)
{
if (glyph == 0x2022)
- return size;
+ {
+ *h_advance = size;
+ *v_advance = size;
+ }
- return 0;
+ return FALSE;
}
static gboolean
@@ -218,7 +223,7 @@ extents_cb (PangoUserFace *face,
return TRUE;
}
-static void
+static gboolean
font_extents_cb (PangoUserFace *face,
int size,
hb_font_extents_t *extents,
@@ -227,17 +232,23 @@ font_extents_cb (PangoUserFace *face,
extents->ascender = size;
extents->descender = 0;
extents->line_gap = 0;
+
+ return TRUE;
}
-static void
+static gboolean
render_cb (PangoUserFace *face,
int size,
hb_codepoint_t glyph,
gpointer user_data,
+ const char *backend_id,
gpointer backend_data)
{
cairo_t *cr = backend_data;
+ if (strcmp (backend_id, "cairo") != 0)
+ return FALSE;
+
if (glyph == 0x2022)
{
MiniSvg *shape = &GnomeFootLogo;
@@ -247,6 +258,8 @@ render_cb (PangoUserFace *face,
mini_svg_render (shape, cr, FALSE);
}
+
+ return TRUE;
}
static void
diff --git a/examples/userfont.c b/examples/userfont.c
index 2d5773df..9da8b16f 100644
--- a/examples/userfont.c
+++ b/examples/userfont.c
@@ -114,19 +114,23 @@ glyph_cb (PangoUserFace *face,
return FALSE;
}
-static hb_position_t
+static gboolean
advance_cb (PangoUserFace *face,
int size,
hb_codepoint_t glyph,
+ hb_position_t *h_advance,
+ hb_position_t *v_advance,
gpointer user_data)
{
test_scaled_font_glyph_t *glyphs = user_data;
- return glyphs[glyph].width / 4.0 * size;
+ *h_advance = *v_advance = glyphs[glyph].width / 4.0 * size;
+
+ return TRUE;
}
-static void
-font_extents_cb (PangoUserFace *face,
+static gboolean
+font_extents_cb (PangoUserFace *face,
int size,
hb_font_extents_t *extents,
gpointer user_data)
@@ -134,10 +138,12 @@ font_extents_cb (PangoUserFace *face,
extents->ascender = 0.75 * size;
extents->descender = 0.25 * size;
extents->line_gap = 0;
+
+ return TRUE;
}
static gboolean
-glyph_extents_cb (PangoUserFace *face,
+glyph_extents_cb (PangoUserFace *face,
int size,
hb_codepoint_t glyph,
hb_glyph_extents_t *extents,
@@ -151,11 +157,12 @@ glyph_extents_cb (PangoUserFace *face,
return TRUE;
}
-static void
-render_cb (PangoUserFace *face,
+static gboolean
+render_cb (PangoUserFace *face,
int size,
hb_codepoint_t glyph,
gpointer user_data,
+ const char *backend_id,
gpointer backend_data)
{
test_scaled_font_glyph_t *glyphs = user_data;
@@ -164,6 +171,9 @@ render_cb (PangoUserFace *face,
div_t d;
double x, y;
+ if (strcmp (backend_id, "cairo") != 0)
+ return FALSE;
+
cairo_set_line_width (cr, 0.1);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
@@ -190,6 +200,8 @@ render_cb (PangoUserFace *face,
}
cairo_stroke (cr);
+
+ return TRUE;
}
static void
@@ -207,7 +219,7 @@ setup_fontmap (PangoHbFontMap *fontmap)
render_cb,
(gpointer) glyphs, NULL,
"Black", desc);
- pango_hb_font_map_add_face (fontmap, face);
+ pango_hb_font_map_add_face (fontmap, PANGO_FONT_FACE (face));
pango_font_description_free (desc);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]