wip: hb_font_paint_glyph

This commit is contained in:
Matthias Clasen 2022-12-14 06:22:00 -05:00 committed by Behdad Esfahbod
parent 83d0a49f71
commit 71efa0dcf1
3 changed files with 55 additions and 0 deletions

View File

@ -30,6 +30,7 @@
#include "hb-font.hh" #include "hb-font.hh"
#include "hb-draw.hh" #include "hb-draw.hh"
#include "hb-paint.hh"
#include "hb-machinery.hh" #include "hb-machinery.hh"
#include "hb-ot.h" #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 { typedef struct hb_font_get_glyph_shape_default_adaptor_t {
hb_draw_funcs_t *draw_funcs; hb_draw_funcs_t *draw_funcs;
@ -639,6 +649,18 @@ hb_font_get_glyph_shape_default (hb_font_t *font,
&adaptor); &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) = DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
{ {
HB_OBJECT_HEADER_STATIC, 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); 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 */ /* A bit higher-level, and with fallback */
/** /**

View File

@ -34,6 +34,7 @@
#include "hb-common.h" #include "hb-common.h"
#include "hb-face.h" #include "hb-face.h"
#include "hb-draw.h" #include "hb-draw.h"
#include "hb-paint.h"
HB_BEGIN_DECLS 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); 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 */ /* 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, hb_font_get_glyph_shape_func_t func,
void *user_data, hb_destroy_func_t destroy); 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 */ /* func dispatch */
HB_EXTERN hb_bool_t HB_EXTERN hb_bool_t
@ -890,6 +901,11 @@ hb_font_get_glyph_shape (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_draw_funcs_t *dfuncs, void *draw_data); 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 */ /* high-level funcs, with fallback */

View File

@ -58,6 +58,7 @@
HB_FONT_FUNC_IMPLEMENT (glyph_name) \ HB_FONT_FUNC_IMPLEMENT (glyph_name) \
HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \
HB_FONT_FUNC_IMPLEMENT (glyph_shape) \ HB_FONT_FUNC_IMPLEMENT (glyph_shape) \
HB_FONT_FUNC_IMPLEMENT (glyph_paint) \
/* ^--- Add new callbacks here */ /* ^--- Add new callbacks here */
struct hb_font_funcs_t struct hb_font_funcs_t
@ -401,6 +402,14 @@ struct hb_font_t
!klass->user_data ? nullptr : klass->user_data->glyph_shape); !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 */ /* A bit higher-level, and with fallback */