From 71efa0dcf12eb3924697f96d3a4ed203bb71962b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 14 Dec 2022 06:22:00 -0500 Subject: [PATCH] wip: hb_font_paint_glyph --- src/hb-font.cc | 30 ++++++++++++++++++++++++++++++ src/hb-font.h | 16 ++++++++++++++++ src/hb-font.hh | 9 +++++++++ 3 files changed, 55 insertions(+) diff --git a/src/hb-font.cc b/src/hb-font.cc index 0ce3e2608..59512b049 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -30,6 +30,7 @@ #include "hb-font.hh" #include "hb-draw.hh" +#include "hb-paint.hh" #include "hb-machinery.hh" #include "hb-ot.h" @@ -512,6 +513,15 @@ hb_font_get_glyph_shape_nil (hb_font_t *font HB_UNUSED, { } +static void +hb_font_get_glyph_paint_nil (hb_font_t *font HB_UNUSED, + void *font_data HB_UNUSED, + hb_codepoint_t glyph HB_UNUSED, + hb_paint_funcs_t *paint_funcs HB_UNUSED, + void *paint_data HB_UNUSED, + void *user_data HB_UNUSED) +{ +} typedef struct hb_font_get_glyph_shape_default_adaptor_t { hb_draw_funcs_t *draw_funcs; @@ -639,6 +649,18 @@ hb_font_get_glyph_shape_default (hb_font_t *font, &adaptor); } +static void +hb_font_get_glyph_paint_default (hb_font_t *font, + void *font_data, + hb_codepoint_t glyph, + hb_paint_funcs_t *paint_funcs, + void *paint_data, + void *user_data) +{ + // FIXME adaptor like for draw funcs + font->parent->get_glyph_paint (glyph, paint_funcs, paint_data); +} + DEFINE_NULL_INSTANCE (hb_font_funcs_t) = { HB_OBJECT_HEADER_STATIC, @@ -1366,6 +1388,14 @@ hb_font_get_glyph_shape (hb_font_t *font, font->get_glyph_shape (glyph, dfuncs, draw_data); } +void +hb_font_paint_glyph (hb_font_t *font, + hb_codepoint_t glyph, + hb_paint_funcs_t *funcs, void *paint_data) +{ + font->get_glyph_paint (glyph, funcs, paint_data); +} + /* A bit higher-level, and with fallback */ /** diff --git a/src/hb-font.h b/src/hb-font.h index e2c3df4a5..99c73a217 100644 --- a/src/hb-font.h +++ b/src/hb-font.h @@ -34,6 +34,7 @@ #include "hb-common.h" #include "hb-face.h" #include "hb-draw.h" +#include "hb-paint.h" HB_BEGIN_DECLS @@ -531,6 +532,11 @@ typedef void (*hb_font_get_glyph_shape_func_t) (hb_font_t *font, void *font_data void *user_data); +typedef void (*hb_font_get_glyph_paint_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, + hb_paint_funcs_t *paint_funcs, void *paint_data, + void *user_data); + /* func setters */ /** @@ -805,6 +811,11 @@ hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs, hb_font_get_glyph_shape_func_t func, void *user_data, hb_destroy_func_t destroy); +HB_EXTERN void +hb_font_funcs_set_glyph_paint_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_paint_func_t func, + void *user_data, hb_destroy_func_t destroy); + /* func dispatch */ HB_EXTERN hb_bool_t @@ -890,6 +901,11 @@ hb_font_get_glyph_shape (hb_font_t *font, hb_codepoint_t glyph, hb_draw_funcs_t *dfuncs, void *draw_data); +HB_EXTERN void +hb_font_paint_glyph (hb_font_t *font, + hb_codepoint_t glyph, + hb_paint_funcs_t *funcs, void *paint_data); + /* high-level funcs, with fallback */ diff --git a/src/hb-font.hh b/src/hb-font.hh index a8b3ee5c4..d45c6a8f7 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -58,6 +58,7 @@ HB_FONT_FUNC_IMPLEMENT (glyph_name) \ HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ HB_FONT_FUNC_IMPLEMENT (glyph_shape) \ + HB_FONT_FUNC_IMPLEMENT (glyph_paint) \ /* ^--- Add new callbacks here */ struct hb_font_funcs_t @@ -401,6 +402,14 @@ struct hb_font_t !klass->user_data ? nullptr : klass->user_data->glyph_shape); } + void get_glyph_paint (hb_codepoint_t glyph, + hb_paint_funcs_t *paint_funcs, void *paint_data) + { + klass->get.f.glyph_paint (this, user_data, + glyph, + paint_funcs, paint_data, + !klass->user_data ? nullptr : klass->user_data->glyph_paint); + } /* A bit higher-level, and with fallback */