Files
harfbuzz/util/gpu/demo-font.h
T
Behdad Esfahbod a150fc2218 [util/gpu] Add --show-extents flag
Exercises hb_gpu_draw_rect: when the flag is set, each glyph
blob encodes its ink-extent frame as an extra stroked
rectangle alongside the glyph outline, so the frame is cached
with the glyph and renders with no extra draw call.

The frame is padded outward by stroke_width / 2 so the stroke
sits entirely outside the glyph ink (otherwise the inner half
would knock out against the glyph shape, since both fill in
the same blob).

Cmdline-only for now -- a runtime 'e' toggle would require a
buffer re-shape hook that native hb-gpu doesn't yet expose.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-15 02:19:53 -06:00

73 lines
1.5 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);
/* Embed a stroked frame at each glyph's ink extents into the
* same blob as the glyph outline. Cached with the glyph;
* changing this invalidates the cache. */
void
demo_font_set_show_extents (demo_font_t *font,
hb_bool_t show);
void
demo_font_clear_cache (demo_font_t *font);
void
demo_font_print_stats (demo_font_t *font);
#endif /* DEMO_FONT_H */