[pango/userfont: 12/15] Tweak callbacks
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/userfont: 12/15] Tweak callbacks
- Date: Fri, 28 Jan 2022 14:04:51 +0000 (UTC)
commit b3f4addddfcfbee33b8b68c33df2e1fcf6054dc1
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 28 01:04:17 2022 -0500
Tweak callbacks
pango/pango-userface-private.h | 7 +++----
pango/pango-userface.c | 29 +++++++++++++----------------
pango/pango-userface.h | 35 ++++++++++++++++-------------------
pango/pango-userfont.c | 21 ++++++++++++++++++---
pango/pangocairo-font.c | 20 +++++++++-----------
5 files changed, 59 insertions(+), 53 deletions(-)
---
diff --git a/pango/pango-userface-private.h b/pango/pango-userface-private.h
index 3bbb8dd3..d63c7c5d 100644
--- a/pango/pango-userface-private.h
+++ b/pango/pango-userface-private.h
@@ -36,10 +36,9 @@ struct _PangoUserFace
/* up to here shared with PangoHbFace */
- PangoUserFaceGetFontExtentsFunc font_extents_func;
- PangoUserFaceGetNominalGlyphFunc glyph_func;
- PangoUserFaceGetGlyphAdvanceFunc advance_func;
- PangoUserFaceGetGlyphExtentsFunc glyph_extents_func;
+ PangoUserFaceGetFontInfoFunc font_info_func;
+ PangoUserFaceUnicodeToGlyphFunc glyph_func;
+ PangoUserFaceGetGlyphInfoFunc glyph_info_func;
PangoUserFaceRenderGlyphFunc render_func;
gpointer user_data;
GDestroyNotify destroy;
diff --git a/pango/pango-userface.c b/pango/pango-userface.c
index fcf3fa55..8e45ab01 100644
--- a/pango/pango-userface.c
+++ b/pango/pango-userface.c
@@ -238,10 +238,9 @@ pango_user_face_get_faceid (PangoUserFace *self)
/**
* pango_user_face_new:
- * @font_extents_func: the `PangoUserFaceGetFontExtentsFunc`
- * @glyph_func: the `PangoUserFaceGetNominalGlyphFunc`
- * @advance_func: the `PangoUserFaceGetGlyphAdvanceFunc`
- * @glyph_extents_func: the `PangoUserFaceGetGlyphExtentsFunc`
+ * @font_info_func: the `PangoUserFaceGetFontInfoFunc`
+ * @glyph_func: the `PangoUserFaceUnicodetoGlyphFunc`
+ * @glyph_info_func: the `PangoUserFaceGetGlyphInfoFunc`
* @render_func: the `PangoUserFaceRenderGlyphFunc`
* @user_data: user data that will be assed to the callbacks
* @destroy: destroy notify for @user_data
@@ -259,24 +258,22 @@ pango_user_face_get_faceid (PangoUserFace *self)
* Since: 1.52
*/
PangoUserFace *
-pango_user_face_new (PangoUserFaceGetFontExtentsFunc font_extents_func,
- PangoUserFaceGetNominalGlyphFunc glyph_func,
- PangoUserFaceGetGlyphAdvanceFunc advance_func,
- PangoUserFaceGetGlyphExtentsFunc glyph_extents_func,
- PangoUserFaceRenderGlyphFunc render_func,
- gpointer user_data,
- GDestroyNotify destroy,
- const char *name,
- const PangoFontDescription *description)
+pango_user_face_new (PangoUserFaceGetFontInfoFunc font_info_func,
+ PangoUserFaceUnicodeToGlyphFunc glyph_func,
+ PangoUserFaceGetGlyphInfoFunc glyph_info_func,
+ PangoUserFaceRenderGlyphFunc render_func,
+ gpointer user_data,
+ GDestroyNotify destroy,
+ const char *name,
+ const PangoFontDescription *description)
{
PangoUserFace *self;
self = g_object_new (PANGO_TYPE_USER_FACE, NULL);
- self->font_extents_func = font_extents_func;
+ self->font_info_func = font_info_func;
self->glyph_func = glyph_func;
- self->advance_func = advance_func;
- self->glyph_extents_func = glyph_extents_func,
+ self->glyph_info_func = glyph_info_func;
self->render_func = render_func;
self->user_data = user_data;
self->destroy = destroy;
diff --git a/pango/pango-userface.h b/pango/pango-userface.h
index e5036291..dd4f8550 100644
--- a/pango/pango-userface.h
+++ b/pango/pango-userface.h
@@ -32,45 +32,42 @@ typedef struct _PangoUserFont PangoUserFont;
PANGO_AVAILABLE_IN_1_52
G_DECLARE_FINAL_TYPE (PangoUserFace, pango_user_face, PANGO, USER_FACE, PangoFontFace)
-typedef gboolean (* PangoUserFaceGetFontExtentsFunc) (PangoUserFace *face,
+typedef gboolean (* PangoUserFaceGetFontInfoFunc) (PangoUserFace *face,
int size,
hb_font_extents_t *extents,
+ gboolean *has_color_glyphs,
gpointer user_data);
-typedef gboolean (* PangoUserFaceGetNominalGlyphFunc) (PangoUserFace *face,
+typedef gboolean (* PangoUserFaceUnicodeToGlyphFunc) (PangoUserFace *face,
hb_codepoint_t unicode,
hb_codepoint_t *glyph,
gpointer user_data);
-typedef gboolean (* PangoUserFaceGetGlyphAdvanceFunc) (PangoUserFace *face,
- int size,
- hb_codepoint_t glyph,
- hb_position_t *h_advance,
- hb_position_t *v_advance,
- gpointer user_data);
-
-typedef gboolean (* PangoUserFaceGetGlyphExtentsFunc) (PangoUserFace *face,
+typedef gboolean (* PangoUserFaceGetGlyphInfoFunc) (PangoUserFace *face,
int size,
hb_codepoint_t glyph,
hb_glyph_extents_t *extents,
+ hb_position_t *h_advance,
+ hb_position_t *v_advance,
+ gboolean *is_color_glyph,
gpointer user_data);
typedef gboolean (* PangoUserFaceRenderGlyphFunc) (PangoUserFace *face,
int size,
hb_codepoint_t glyph,
+ gboolean use_color,
gpointer user_data,
const char *backend_id,
gpointer backend_data);
PANGO_AVAILABLE_IN_1_52
-PangoUserFace * pango_user_face_new (PangoUserFaceGetFontExtentsFunc font_extents_func,
- PangoUserFaceGetNominalGlyphFunc glyph_func,
- PangoUserFaceGetGlyphAdvanceFunc advance_func,
- PangoUserFaceGetGlyphExtentsFunc glyph_extents_func,
- PangoUserFaceRenderGlyphFunc render_glyph,
- gpointer user_data,
- GDestroyNotify destroy,
- const char *name,
- const PangoFontDescription *description);
+PangoUserFace * pango_user_face_new (PangoUserFaceGetFontInfoFunc font_info_func,
+ PangoUserFaceUnicodeToGlyphFunc glyph_func,
+ PangoUserFaceGetGlyphInfoFunc advance_func,
+ PangoUserFaceRenderGlyphFunc render_glyph,
+ gpointer user_data,
+ GDestroyNotify destroy,
+ const char *name,
+ const PangoFontDescription *description);
G_END_DECLS
diff --git a/pango/pango-userfont.c b/pango/pango-userfont.c
index 36920bdc..8178e880 100644
--- a/pango/pango-userfont.c
+++ b/pango/pango-userfont.c
@@ -275,8 +275,14 @@ glyph_h_advance_func (hb_font_t *font, void *font_data,
PangoUserFont *self = font_data;
int size = self->size * self->dpi / 72.;
hb_position_t h_advance, v_advance;
+ hb_glyph_extents_t glyph_extents;
+ gboolean is_color;
- self->face->advance_func (self->face, size, glyph, &h_advance, &v_advance, self->face->user_data);
+ self->face->glyph_info_func (self->face, size, glyph,
+ &glyph_extents,
+ &h_advance, &v_advance,
+ &is_color,
+ self->face->user_data);
return h_advance;
}
@@ -289,8 +295,14 @@ glyph_extents_func (hb_font_t *font, void *font_data,
{
PangoUserFont *self = font_data;
int size = self->size * self->dpi / 72.;
+ hb_position_t h_advance, v_advance;
+ gboolean is_color;
- return self->face->glyph_extents_func (self->face, size, glyph, extents, self->face->user_data);
+ return self->face->glyph_info_func (self->face, size, glyph,
+ &extents,
+ &h_advance, &v_advance,
+ &is_color,
+ self->face->user_data);
}
static hb_bool_t
@@ -300,8 +312,11 @@ font_extents_func (hb_font_t *font, void *font_data,
{
PangoUserFont *self = font_data;
int size = self->size * self->dpi / 72.;
+ gboolean has_color;
- return self->face->font_extents_func (self->face, size, extents, self->face->user_data);
+ return self->face->font_info_func (self->face, size,
+ extents, &has_color,
+ self->face->user_data);
}
static hb_font_t *
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 7534cb4c..2a221708 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -88,27 +88,25 @@ render_func (cairo_scaled_font_t *scaled_font,
hb_glyph_extents_t glyph_extents;
hb_position_t h_advance;
hb_position_t v_advance;
+ gboolean is_color;
font_face = cairo_scaled_font_get_font_face (scaled_font);
font = cairo_font_face_get_user_data (font_face, &cairo_user_data);
+ font->face->glyph_info_func (font->face, 1024,
+ (hb_codepoint_t)glyph,
+ &glyph_extents,
+ &h_advance, &v_advance,
+ &is_color,
+ font->face->user_data);
+
font->face->render_func (font->face, font->size,
(hb_codepoint_t)glyph,
+ is_color,
font->face->user_data,
"cairo",
cr);
- font->face->advance_func (font->face, 1024,
- (hb_codepoint_t)glyph,
- &h_advance,
- &v_advance,
- font->face->user_data);
-
- font->face->glyph_extents_func (font->face, 1024,
- (hb_codepoint_t)glyph,
- &glyph_extents,
- font->face->user_data);
-
extents->x_bearing = glyph_extents.x_bearing / (double) 1024;
extents->y_bearing = glyph_extents.y_bearing / (double) 1024;
extents->width = glyph_extents.width / (double) 1024;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]