Files
harfbuzz/util/gpu/demo-font.h
T
Behdad Esfahbod 819fce8352 [gpu] Document Paint renderer; drop encode-time foreground API
Integrates the paint renderer into the hb-gpu module docs:

- Intro notes two renderers (Draw for monochrome, Paint for
  COLRv0/COLRv1, with explicit note that Paint also handles
  monochrome outlines at some cost).
- New Paint section parallel to Draw covers encoding, shader
  composition, and fragment shader, referencing Draw for the
  shared atlas / vertex / dilation / stem-darkening pieces.
- Encoding examples drop hb_gpu_*_reset() in favour of
  hb_gpu_*_encode()'s auto-clear.

Drops hb_gpu_paint_set_foreground() / _get_foreground() and the
foreground field from hb_gpu_paint_t.  The encoded blob only
records an is_foreground flag per layer/stop; the actual
foreground color has always been a shader uniform passed to
hb_gpu_paint() at render time.  The encoder API was never
load-bearing -- the value was handed to hb_font_paint_glyph() but
the encoder callback ignores everything except the flag.

Also makes hb_gpu_paint_encode() auto-clear on return (matching
hb_gpu_draw_encode()), and removes the now-dead
demo_font_set_foreground() wrapper from the demo layer.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 15:15:53 -06:00

66 lines
1.3 KiB
C

/*
* Copyright 2026 Behdad Esfahbod. All Rights Reserved.
*/
#ifndef DEMO_FONT_H
#define DEMO_FONT_H
#include "demo-common.h"
#include "demo-atlas.h"
typedef struct {
demo_extents_t extents;
double advance;
hb_bool_t is_empty;
unsigned int upem;
unsigned int atlas_offset;
} glyph_info_t;
typedef struct demo_font_t demo_font_t;
demo_font_t *
demo_font_create (hb_font_t *font,
demo_atlas_t *atlas,
hb_bool_t draw_only);
void
demo_font_destroy (demo_font_t *font);
hb_face_t *
demo_font_get_face (demo_font_t *font);
hb_font_t *
demo_font_get_font (demo_font_t *font);
void
demo_font_lookup_glyph (demo_font_t *font,
unsigned int glyph_index,
glyph_info_t *glyph_info);
/* Forward paint-encoder configuration to the underlying
* hb_gpu_paint_t and clear the glyph cache (colors are baked into
* encoded blobs, so palette / override changes invalidate them). */
void
demo_font_set_palette (demo_font_t *font,
unsigned palette_index);
void
demo_font_clear_custom_palette_colors (demo_font_t *font);
hb_bool_t
demo_font_set_custom_palette_color (demo_font_t *font,
unsigned int color_index,
hb_color_t color);
void
demo_font_clear_cache (demo_font_t *font);
void
demo_font_print_stats (demo_font_t *font);
#endif /* DEMO_FONT_H */