Skip to content

Commit

Permalink
Add hb-paint definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledhosny committed Jan 20, 2024
1 parent 0e591cc commit bd17e7f
Showing 1 changed file with 274 additions and 3 deletions.
277 changes: 274 additions & 3 deletions src/uharfbuzz/charfbuzz.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cdef extern from "hb.h":
ctypedef long hb_position_t
ctypedef unsigned long hb_mask_t
ctypedef unsigned long hb_tag_t
ctypedef uint32_t hb_color_t

ctypedef enum hb_direction_t:
HB_DIRECTION_LTR
Expand Down Expand Up @@ -48,6 +49,11 @@ cdef extern from "hb.h":
hb_script_t hb_ot_tag_to_script(hb_tag_t tag)
const char* hb_version_string()

uint8_t hb_color_get_alpha(hb_color_t color)
uint8_t hb_color_get_red(hb_color_t color)
uint8_t hb_color_get_green(hb_color_t color)
uint8_t hb_color_get_blue(hb_color_t color)

ctypedef struct hb_user_data_key_t:
pass

Expand Down Expand Up @@ -433,6 +439,21 @@ cdef extern from "hb.h":
hb_codepoint_t *glyph)
void hb_font_destroy(hb_font_t* font)

void hb_font_draw_glyph(
hb_font_t *font,
hb_codepoint_t glyph,
const hb_draw_funcs_t *dfuncs,
void *draw_data)

void hb_font_paint_glyph(
hb_font_t *font,
hb_codepoint_t glyph,
hb_paint_funcs_t *pfuncs,
void *paint_data,
unsigned int palette_index,
hb_color_t foreground)

# hb-draw.h
ctypedef struct hb_draw_state_t:
hb_bool_t path_open
float path_start_x
Expand Down Expand Up @@ -528,11 +549,261 @@ cdef extern from "hb.h":

void hb_draw_funcs_destroy(hb_draw_funcs_t* funcs)

void hb_font_draw_glyph(
# hb-paint.h
ctypedef struct hb_paint_funcs_t:
pass

ctypedef struct hb_color_stop_t:
float offset
hb_bool_t is_foreground
hb_color_t color

ctypedef enum hb_paint_extend_t:
HB_PAINT_EXTEND_PAD
HB_PAINT_EXTEND_REPEAT
HB_PAINT_EXTEND_REFLECT

ctypedef struct hb_color_line_t:
pass

ctypedef enum hb_paint_composite_mode_t:
HB_PAINT_COMPOSITE_MODE_CLEAR
HB_PAINT_COMPOSITE_MODE_SRC
HB_PAINT_COMPOSITE_MODE_DEST
HB_PAINT_COMPOSITE_MODE_SRC_OVER
HB_PAINT_COMPOSITE_MODE_DEST_OVER
HB_PAINT_COMPOSITE_MODE_SRC_IN
HB_PAINT_COMPOSITE_MODE_DEST_IN
HB_PAINT_COMPOSITE_MODE_SRC_OUT
HB_PAINT_COMPOSITE_MODE_DEST_OUT
HB_PAINT_COMPOSITE_MODE_SRC_ATOP
HB_PAINT_COMPOSITE_MODE_DEST_ATOP
HB_PAINT_COMPOSITE_MODE_XOR
HB_PAINT_COMPOSITE_MODE_PLUS
HB_PAINT_COMPOSITE_MODE_SCREEN
HB_PAINT_COMPOSITE_MODE_OVERLAY
HB_PAINT_COMPOSITE_MODE_DARKEN
HB_PAINT_COMPOSITE_MODE_LIGHTEN
HB_PAINT_COMPOSITE_MODE_COLOR_DODGE
HB_PAINT_COMPOSITE_MODE_COLOR_BURN
HB_PAINT_COMPOSITE_MODE_HARD_LIGHT
HB_PAINT_COMPOSITE_MODE_SOFT_LIGHT
HB_PAINT_COMPOSITE_MODE_DIFFERENCE
HB_PAINT_COMPOSITE_MODE_EXCLUSION
HB_PAINT_COMPOSITE_MODE_MULTIPLY
HB_PAINT_COMPOSITE_MODE_HSL_HUE
HB_PAINT_COMPOSITE_MODE_HSL_SATURATION
HB_PAINT_COMPOSITE_MODE_HSL_COLOR
HB_PAINT_COMPOSITE_MODE_HSL_LUMINOSITY

hb_paint_funcs_t *hb_paint_funcs_create()
hb_paint_funcs_t *hb_paint_funcs_get_empty()
hb_paint_funcs_t *hb_paint_funcs_reference(hb_paint_funcs_t *funcs)
void hb_paint_funcs_destroy(hb_paint_funcs_t *funcs)
hb_bool_t hb_paint_funcs_set_user_data(
hb_paint_funcs_t *funcs,
hb_user_data_key_t *key,
void *data,
hb_destroy_func_t destroy,
hb_bool_t replace)
void *hb_paint_funcs_get_user_data(
const hb_paint_funcs_t *funcs,
hb_user_data_key_t *key)
void hb_paint_funcs_make_immutable(hb_paint_funcs_t *funcs)
hb_bool_t hb_paint_funcs_is_immutable(hb_paint_funcs_t *funcs)

unsigned int hb_color_line_get_color_stops(
hb_color_line_t *color_line,
unsigned int start,
unsigned int *count,
hb_color_stop_t *color_stops)

hb_paint_extend_t hb_color_line_get_extend(hb_color_line_t *color_line)

ctypedef void (*hb_paint_push_transform_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
float xx, float yx,
float xy, float yy,
float dx, float dy,
void *user_data)
ctypedef void (*hb_paint_pop_transform_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
void *user_data)
ctypedef hb_bool_t (*hb_paint_color_glyph_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
hb_codepoint_t glyph,
hb_font_t *font,
void *user_data)
ctypedef void (*hb_paint_push_clip_glyph_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
hb_codepoint_t glyph,
const hb_draw_funcs_t *dfuncs,
void *draw_data)
hb_font_t *font,
void *user_data)
ctypedef void (*hb_paint_push_clip_rectangle_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
float xmin, float ymin,
float xmax, float ymax,
void *user_data)
ctypedef void (*hb_paint_pop_clip_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
void *user_data)
ctypedef void (*hb_paint_color_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
hb_bool_t is_foreground,
hb_color_t color,
void *user_data)
ctypedef hb_bool_t (*hb_paint_image_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
hb_blob_t *image,
unsigned int width,
unsigned int height,
hb_tag_t format,
float slant,
hb_glyph_extents_t *extents,
void *user_data)
ctypedef unsigned int (*hb_color_line_get_color_stops_func_t) (
hb_color_line_t *color_line,
void *color_line_data,
unsigned int start,
unsigned int *count,
hb_color_stop_t *color_stops,
void *user_data)
ctypedef hb_paint_extend_t (*hb_color_line_get_extend_func_t) (
hb_color_line_t *color_line,
void *color_line_data,
void *user_data)
ctypedef struct hb_color_line_t:
void *data
hb_color_line_get_color_stops_func_t get_color_stops
void *get_color_stops_user_data
hb_color_line_get_extend_func_t get_extend
void *get_extend_user_data
void *reserved0
void *reserved1
void *reserved2
void *reserved3
void *reserved5
void *reserved6
void *reserved7
void *reserved8

ctypedef void (*hb_paint_linear_gradient_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
hb_color_line_t *color_line,
float x0, float y0,
float x1, float y1,
float x2, float y2,
void *user_data)
ctypedef void (*hb_paint_radial_gradient_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
hb_color_line_t *color_line,
float x0, float y0, float r0,
float x1, float y1, float r1,
void *user_data)
ctypedef void (*hb_paint_sweep_gradient_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
hb_color_line_t *color_line,
float x0, float y0,
float start_angle,
float end_angle,
void *user_data)
ctypedef void (*hb_paint_push_group_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
void *user_data)
ctypedef void (*hb_paint_pop_group_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
hb_paint_composite_mode_t mode,
void *user_data)
ctypedef hb_bool_t (*hb_paint_custom_palette_color_func_t) (
hb_paint_funcs_t *funcs,
void *paint_data,
unsigned int color_index,
hb_color_t *color,
void *user_data)

void hb_paint_funcs_set_push_transform_func(
hb_paint_funcs_t *funcs,
hb_paint_push_transform_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_pop_transform_func(
hb_paint_funcs_t *funcs,
hb_paint_pop_transform_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_color_glyph_func(
hb_paint_funcs_t *funcs,
hb_paint_color_glyph_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_push_clip_glyph_func(
hb_paint_funcs_t *funcs,
hb_paint_push_clip_glyph_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_push_clip_rectangle_func(
hb_paint_funcs_t *funcs,
hb_paint_push_clip_rectangle_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_pop_clip_func(
hb_paint_funcs_t *funcs,
hb_paint_pop_clip_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_color_func(
hb_paint_funcs_t *funcs,
hb_paint_color_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_image_func(
hb_paint_funcs_t *funcs,
hb_paint_image_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_linear_gradient_func (
hb_paint_funcs_t *funcs,
hb_paint_linear_gradient_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_radial_gradient_func(
hb_paint_funcs_t *funcs,
hb_paint_radial_gradient_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_sweep_gradient_func(
hb_paint_funcs_t *funcs,
hb_paint_sweep_gradient_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_push_group_func(
hb_paint_funcs_t *funcs,
hb_paint_push_group_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_pop_group_func(
hb_paint_funcs_t *funcs,
hb_paint_pop_group_func_t func,
void *user_data,
hb_destroy_func_t destroy)
void hb_paint_funcs_set_custom_palette_color_func(
hb_paint_funcs_t *funcs,
hb_paint_custom_palette_color_func_t func,
void *user_data,
hb_destroy_func_t destroy)

# hb-shape.h
void hb_shape(
Expand Down

0 comments on commit bd17e7f

Please sign in to comment.