include_point used to flip Y so the computed line-box extents
matched the old Y-down internal model. With the library now
tracking extents in Y-up (font) space and wrapping SVG body
in <g transform="scale(1,-1)">, that flip sent the auto-fit
viewBox above the glyph ink instead of around it.
Regenerate the vector expected SVGs that had captured the
shifted viewBox.
Assisted-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
These are convenience APIs, not typesetting APIs — positioning
is the caller's responsibility via set_transform(). This
matches the GPU API which never had pen parameters.
All callers updated to use set_transform with pen position
before each _glyph call.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Nastaliq and other deep-descender scripts were clipped because
the fit used only logical extents (one em height). Now uses
the union of ink and logical extents so all ink is visible.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- demo_buffer_set_features() sets global features for hb_shape
- web_set_features() wasm export parses comma-separated features
- Shell message handler accepts { kind: "features", value }
- Features applied to all shape calls in demo_buffer_add_text
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allows the host page to simulate keypresses (e.g. 'b' for
dark mode toggle) via postMessage { kind: 'key', value }.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hb_gpu_paint() now takes an out float coverage parameter that
receives the maximum slug coverage across all paint layers.
This lets the caller apply stem darkening and gamma correction
to edge antialiasing only, without distorting interior paint
colors (gradients, semi-transparent layers).
The demo shaders (GLSL, MSL, HLSL, WGSL) use the new parameter
to share a single coverage-correction block between draw and
paint paths. Also fixes the blend func to GL_ONE for correct
premultiplied compositing.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hb_gpu_paint() returns premultiplied RGBA, as documented in
hb-gpu.cc. The GL demo was using GL_SRC_ALPHA which
double-applied alpha, darkening semi-transparent colors.
Use GL_ONE as the API docs prescribe.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The recently added --stroke option is only meaningful in
hb-view (cairo rendering). The experimental utils
(hb-raster, hb-vector, hb-gpu) don't support stroked
outline rendering. Hide from --help but keep functional;
--rainbow still enables it implicitly.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The GPU util's auto-detect only checked hb_ot_color_has_paint
(COLRv1). COLRv0 fonts like BungeeTint have layers but no
paint tree, so they were incorrectly routed to the mono draw
path.
Add hb_ot_color_has_layers and hb_ot_color_has_png to the
check, matching the raster and vector utils.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The paint SVG backend bakes all colors directly — no CSS
var(--hb-...) references remain in the output. So the util's
SVG parser, var resolver, palette cache, and slice_svg
infrastructure are all dead code.
write_blob is now just fwrite.
Removes ~340 lines: slice_svg, write_slice_resolving_palette_vars,
parse_var_color_expr, find_next_var_expr, find_matching_paren,
emit_css_color, lookup_palette_color, init_palette_color_cache,
skip_ascii_ws, trim_ascii_ws_right, parsed_var_color_expr_t,
and associated palette cache state.
Regenerated vector test expected outputs (color font SVGs
now emit directly without var resolution pass).
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Now that the draw library handles per-glyph foreground fills
and background rects, the util no longer needs to parse and
re-emit SVG for draw blobs. Draw blobs are written directly
to the output file, same as PDF.
Paint SVG still needs var(--hb-...) resolution, so paint
blobs go through the existing write_slice_resolving_palette_vars
path.
Removes ~120 lines: emit_fill_group_open/close,
emit_draw_body_with_palette, emit_fill_stroke_attrs_for_color,
emit_stroke_attrs, and the draw-specific branches in write_blob.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move foreground fill from a global wrapper (SVG <g fill>,
PDF initial rg) to per-glyph emission:
SVG: each <use> gets fill="rgb(...)" from the current
draw->foreground at emission time.
PDF: each glyph path gets an rg operator before fill.
This lets callers change foreground between glyph calls
(e.g. per-glyph palette cycling) without post-processing.
Wire per-glyph palette cycling for the draw path in the
hb-vector util, matching how paint already does it.
Regenerated vector test expected outputs.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
With --draw/--paint forcing a single mode per render, the
draw and paint paths are mutually exclusive — both can't
produce output in the same render. Remove the combined
SVG merger and simplify to a single blob output.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add hb_vector_draw_set_{foreground,background}() and getters.
SVG: foreground wraps body in <g fill="rgb(...)">; background
emits a <rect> covering the viewBox before content.
PDF: foreground sets fill color via rg operator before glyph
content; background emits a filled rect at the start of the
content stream.
Default: foreground opaque black, background transparent.
Wire both into the hb-vector CLI util alongside the paint
equivalents. Remove the old util-side emit_background_rect.
Regenerated vector test expected outputs.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The util had its own background rect emitter that wrote
directly to the output file. Now that hb_vector_paint has
set_background, the library handles it. Remove the
duplicate to avoid double background emission.
Note: the draw path currently has no background support;
this is consistent — mono/draw SVGs are typically embedded
inline where background comes from the container.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allows explicitly requesting transparent output without
needing to spell out --background=00000000.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add hb_vector_paint_set_background() / get_background() and
hb_raster_paint_set_background() / get_background().
For vector: if set to a non-transparent color, the SVG renderer
emits a <rect> covering the viewBox before glyph content, and
the PDF renderer prepends a filled rectangle to the content
stream. Both support semi-transparent backgrounds (SVG via
fill-opacity, PDF via ExtGState /ca).
For raster: the root surface is pre-filled with the background
color before glyph compositing begins.
Default is transparent (no background emitted).
The hb-vector CLI util wires --background to the new API.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
get_normalized_stroke_width() was gated on stroke_enabled,
returning the raw pixel value (1.0) when --stroke wasn't
active. The show-extents overlay uses this value regardless
of --stroke, so it got a stroke_width of 1 in font-scale
space (= 0.016 pixels after /SCALE).
Remove the stroke_enabled guard so the pixel → font-scale
conversion always applies.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The vector util was creating a separate upem-scaled font clone,
converting all shaping positions from font-scale to upem, and
setting scale_factor to upem/font_size to undo that on emit.
Simplify: use the caller's font directly. Positions from
shaping are stored as-is (in font-scale = pixel * SCALE).
scale_factor is just SCALE (= 1 << subpixel_bits), so the
lib divides by SCALE on emit to produce pixel-space output.
This removes ~40 lines: the upem_font creation, variation
coord copying, scale_to_upem_x/y helpers, and the complex
upem_per_pixel margin/stroke conversions. Margin conversion
simplifies from margin * upem * SCALE / x_scale to just
margin * SCALE.
Regenerated vector test expected outputs for the new
coordinate space.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Drop the bespoke red pen dot + magenta extents rectangle in
favor of a single foreground-color overlay that matches the
look raster, vector, and gpu now produce after their port to
the shared helper: stroked rect around each glyph's ink box,
plus a filled dot at the pen origin.
Cairo's annotation pass stays native (post-glyph drawing
through cairo, not via hb_paint funcs); only the colors and
the dot rendering changed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend the shared overlay helper (and rename it from
util_emit_extents_rect_into_* to util_emit_extents_overlay_
into_*) to emit two pieces of geometry per glyph: the
existing stroked rect around the ink box, plus a filled
dot at the pen origin via hb_draw_circle. Both go in the
foreground color through the same draw / paint flow.
The dot helps debug glyph positioning at a glance and gives
the previously-uncalled hb_draw_circle a real caller in the
suite.
Raster, vector, and gpu utils pick up the dot automatically
via the renamed helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The six public draw / paint funcs getters across raster,
vector, and gpu used to be singletons:
hb_raster_draw_get_funcs (void)
hb_raster_paint_get_funcs (void)
hb_vector_draw_get_funcs (void)
hb_vector_paint_get_funcs (void)
hb_gpu_draw_get_funcs (void)
hb_gpu_paint_get_funcs (void)
That works fine for raster and gpu, where there's a single
backend per type, but breaks for the vector backend where
SVG and PDF have separate funcs sets — callers using the
public getter always got SVG funcs and silently produced
SVG markup inside PDF output streams when invoking the new
arbitrary-path clip API on a PDF context.
Make all six take a const-pointer to the relevant context
instance. vector_paint dispatches on paint->format; the
other five just use the instance for symmetry today (room
for future format-style dispatch later).
Also expose hb_vector_draw_get_format / hb_vector_paint_
get_format public getters so callers (or third parties)
can ask a vector context for its format without poking at
internals.
Also: hb_vector_paint_push_clip_path_end now wraps the
emitted SVG clipPath's path in transform="scale(1,-1)" so
free-form arbitrary clips at base body level land in the
same coord system the per-glyph <use scale(_,-sy)>
wrappers establish. Without this, free-form clip-path
arbitrary outlines emitted between paint_glyph calls came
out mirrored across the X axis.
Updates internal callers (hb_vector_paint_glyph,
hb_pdf_emit_glyph_path, hb_raster_paint_push_clip_path_
start, hb_gpu_paint_push_clip_path_start, the GPU pen
adapter), util sites (raster-output.hh, vector-output.hh,
gpu/demo-font.cc), API tests (test-raster.cc, test-gpu.cc),
and the docs section index.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use util_emit_extents_rect_into_{draw,paint} from
helper-extents-overlay.hh so the GPU demo's extents
overlay matches the raster and vector ports — same
coordinate, padding, and stroke convention; same
foreground-color fill via the arbitrary-path clip API in
paint mode.
Adds --show-extents support for the paint (color-glyph)
path, which previously only the draw path implemented.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bake the per-glyph extents rectangle into the same draw or
paint context that rendered the glyph, via the shared
helper from helper-extents-overlay.hh. Matches the raster
util's port: in paint mode, the rect goes through
push_clip_path_start/end + paint_color (foreground); in
draw mode, hb_draw_rectangle on hb_vector_draw_get_funcs
appends to the scratch which the next glyph's entry-flush
(or render) emits as its own <path>/fill.
Drops the standalone emit_extents_overlay function and
its FF0000-dot + FF00FF-stroke SVG markup — the new
overlay renders in the glyph's foreground color, same as
the raster port.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
API rename for the not-yet-released stroked/filled
rectangle helper added to hb-draw — full names
(hb_draw_line, hb_draw_circle, hb_draw_rectangle) read
better than mixed full/abbreviated.
Updates the public header, impl, the gpu doc reference,
the GPU API test, the GPU demo's extents overlay, the
extents-overlay paint helper, and the docs section
listing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add util_emit_extents_rect_into_draw in helper-extents-
overlay.hh — takes a draw funcs pair + glyph extents + pen
position + stroke_width and emits the padded stroked rect
in one place. util_emit_extents_rect_into_paint (renamed
from _paint for clarity) now wraps it in the
push_clip_path_start/_end + paint_color + pop_clip dance.
Both raster draw loops (finish_draw_solid accumulated into
one rdr, finish_draw_palette per-glyph) now bake the extents
ring into the draw context with util_emit_extents_rect_into_
draw, alongside the glyph outline in foreground color.
finish_paint's call site collapses from an inline
coord-normalize-and-pad block to a single helper call.
Uses copysignf on the padding so the "outward" shift tracks
the y_bearing/height sign instead of needing a caller-side
normalize; pairs with the hb_draw_rect fix for negative
w/h in the same branch.
Drop the now-unused collect_ink_extents_rects /
overlay_rects_bgra / overlay_rects_rgb / rect_i_t helpers
that implemented the old manual BGRA overlay pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the manual BGRA 1-pixel overlay with a per-glyph
hb_paint_push_clip_path_start/_end + hb_draw_rect + paint
foreground sequence, wrapped in the new shared helper
util_emit_extents_rect_paint in helper-extents-overlay.hh.
Each glyph now bakes its own extents ring into the glyph's
rendered mask via the raster-paint backend's arbitrary-
path clip, so compositing picks it up alongside the glyph
ink (same code path as the color layers).
Pads the nominal rect outward by stroke_width/2 so the
stroke's inner edge sits at the ink box — otherwise the
inner half would knock out against glyph ink under non-
zero-winding clipping. Normalizes w/h to positive before
padding so the outward shift is unambiguous regardless of
y_bearing / height sign conventions.
Draw-mode loops (finish_draw_solid, finish_draw_palette)
still use the old collect+overlay path and will follow up.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Reset Since tags to XSince: REPLACEME for new non-or_fail
glyph functions (gpu, raster, vector paint).
- Remove duplicate doc comment on static
hb_vector_paint_glyph_impl helper.
- Fix hb_gpu_paint_glyph doc: remove internal LAYER_SOLID
reference.
- Drop hb_ot_color_has_svg() from color-detection in all utils
(cairo, raster, vector, hb-raster-all); HarfBuzz does not
render SVG table natively, so checking it caused fallback to
monochrome drawing of the actual outlines.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The other utils (hb-view, hb-raster) treat --margin as pixels, but
hb-vector was applying it directly to the upem-space extents. For a
font with upem=1000 rendered at font-size=72, the default 16-pixel
margin came out as 16/1000*72 = ~1.15 pixels per side, much smaller
than expected.
Convert margin from pixels to upem before adding it to the extents,
matching the per-axis x_scale/y_scale used elsewhere in the file.
Now hb-vector and hb-raster produce matching surface dimensions for
the same input (e.g. NotoNastaliqUrdu "اردو" at 72px: 137x213 in both).
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hb-cairo's render_color_glyph drops _or_fail in favor of
the synthesizing hb_font_paint_glyph, so the paint callback
handles every glyph (color or mono) through the paint
pipeline instead of returning NOT_IMPLEMENTED on non-color
glyphs and forcing cairo to fall through to the outline
path.
Hb-view's helper-cairo then picks paint vs draw the same
way the other utils do — --paint wins over --draw,
otherwise auto-detect via the font's color tables — and
expresses "draw" by setting CAIRO_COLOR_MODE_NO_COLOR on
the font options (which makes cairo skip render_color_glyph
entirely, falling through to render_glyph for the cheaper
outline path). No new public API.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move the force_draw / force_paint flags from gpu-output.hh
into the shared view-options.hh so all rendering utils
expose --draw and --paint with the same semantics: --paint
wins over --draw, otherwise auto-detect via the font's
color tables.
raster and vector previously only ran the paint pipeline
when the font had a color table; they now also honor
--paint (renders mono fonts via paint synthesis) and
--draw (forces the outline path even on color fonts).
Vector's per-glyph try-paint-then-fall-back-to-draw is
replaced with a single mode decision up front. Each
glyph then goes through hb_vector_{paint,draw}_glyph
(non-_or_fail), which handles the synthesis fallback
internally — color glyphs render in either mode (paint
synthesizes for non-color fonts; draw renders nothing for
color-only glyphs without an outline, which matches user
intent for --draw).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Consolidate the {vector,raster,gpu}_{draw,paint}_glyph APIs
to match the hb_font_{draw,paint}_glyph / _or_fail pattern:
* Each existing *_glyph() public function now returns void.
For the draw variants this is purely a return-value drop.
For the paint variants the void entry additionally gains a
synthesize fallback for non-color glyphs (calls
hb_font_paint_glyph instead of _or_fail) so a mono glyph
still produces output via a foreground-colored outline.
* New *_glyph_or_fail() variants return hb_bool_t, reporting
exactly what hb_font_{draw,paint}_glyph_or_fail() would.
Callers that care about distinguishing color paint from
synthesized outline now have a clean boolean signal.
Refactors the internal impls behind a shared static helper
parameterised by a `fallible` flag; the two public entries
delegate, passing true (for _or_fail) or false (for the void
alias).
For GPU specifically, paint_glyph_or_fail no longer folds the
encoder's unsupported flag into its return -- that state was
always better reported from hb_gpu_paint_encode() (which
returns NULL), and conflating the two prevented callers from
telling "font has no paint data" from "encoder hit a limit".
While in there, remove a dead branch at the end of
hb_vector_paint_glyph's SVG case (both inner blocks had
already returned; the tail was unreachable).
Updates docs/harfbuzz-sections.txt with the six new symbols
and the NEWS note with the Changed API callouts. Updates
in-tree callers (hb-vector-svg-all, hb-raster-all, test-gpu,
util/vector-output.hh) to the _or_fail variants where they
previously read the return value.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/5926
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hb_vector_{paint,draw}_set_extents stored caller-supplied
extents as-is, while per-glyph extents accumulated via
hb_vector_set_glyph_extents_common were divided by
scale_factor on the way in. When callers passed extents in
input-space (the natural unit alongside the glyph geometry
they're feeding) and a non-1 scale_factor, the resulting
viewBox didn't match what the glyphs drew.
Make set_extents divide by scale_factor too, matching the
accumulate path; callers can now pass input-space extents
uniformly.
Also:
* hb-vector-paint's global transform wrapper dropped the
redundant /scale_factor division. Each per-glyph
<use transform="... scale(1/scale_factor, ...)"> already
applies scale_factor; wrapping the body in another
/scale_factor matrix double-scaled the output, shrinking
color-glyph output to 1/scale_factor^2 of its intended
size. The wrapper now only fires when the user set a
non-identity paint->transform, and emits that transform
as-is.
* util/vector-output.hh simplification: now that set_extents
handles the divide, drop the local pre-multiply of extents
by upem_to_pixel -- pass the upem-space extents through.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Add hb_gpu_draw_line / _rect / _circle shape helpers
The GPU draw encoder already consumes arbitrary curves via the
hb_draw_funcs_t machinery -- that's how glyph outlines feed in.
Expose three convenience helpers so callers can emit common
shapes (tapered line, rectangle, circle) without having to
hand-roll the curve math:
hb_gpu_draw_line (draw, x0,y0,w0, x1,y1,w1);
hb_gpu_draw_rect (draw, x,y,w,h, stroke_width);
hb_gpu_draw_circle (draw, cx,cy,r, stroke_width);
stroke_width = NaN means "filled". A finite positive value
produces a stroked outline by emitting an outer contour CCW
and an inner contour CW so the fill rule carves a hole.
For shapes beyond these three helpers, callers can feed any
outline through hb_draw_move_to / _line_to / _quadratic_to /
_cubic_to / _close_path with the funcs from
hb_gpu_draw_get_funcs() and the hb_gpu_draw_t as data -- the
helpers are thin wrappers over that path.
Useful for game UI: health bars, progress rings, custom
line-art decorations, rendered through the same slug shader
as text.
Assisted-by: Claude <noreply@anthropic.com>
* [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>
* [util/gpu] Cmdline toggles mirroring interactive keybindings
Add --dark / --no-vsync / --fullscreen / --no-stem-darken /
--debug so scripts and CI can start hb-gpu in any of the
states previously reachable only by pressing a key
interactively. Applied via the same keystroke path by
synthesizing the corresponding key characters through
demo_view_type() at startup -- single source of truth for
each toggle.
Assisted-by: Claude <noreply@anthropic.com>
* [draw] Promote shape helpers from hb-gpu-draw to hb-draw
Three shape-emitting helpers (line, rect, circle) operate on
any hb_draw_funcs_t, not specifically the GPU backend. Move
them out of the GPU-only API surface into the core hb-draw
API so any pen (raster, vector, gpu, user-supplied) gets
them.
API rename / move:
hb_gpu_draw_line -> hb_draw_line (in src/hb-draw.h)
hb_gpu_draw_rect -> hb_draw_rect
hb_gpu_draw_circle -> hb_draw_circle
Signatures gain a (dfuncs, draw_data, st) prefix to match the
existing hb_draw_move_to / line_to / cubic_to / close_path
shape -- the helpers are thin wrappers over those.
Callers in test/api/test-gpu.cc and util/gpu/demo-font.cc
updated to call hb_draw_* with hb_gpu_draw_get_funcs() and a
local hb_draw_state_t.
Updated harfbuzz-sections.txt with the new entries; removed
hb_gpu_draw_line / _rect / _circle from hb-gpu.h.
Assisted-by: Claude <noreply@anthropic.com>
* [draw] hb_draw_line: NaN second width defaults to first
Common case is a uniform-width line. Letting @w1 default to
@w0 when NaN is passed makes the call shorter:
hb_draw_line (..., x0, y0, 4, x1, y1, NAN); /* uniform 4 */
Mirrors the NaN-as-sentinel convention used in hb_draw_rect /
hb_draw_circle for the stroke_width parameter.
Assisted-by: Claude <noreply@anthropic.com>
* [draw] hb_draw_line: add cap parameter (butt / square)
Add hb_draw_line_cap_t enum with HB_DRAW_LINE_CAP_BUTT (the
existing default behavior) and HB_DRAW_LINE_CAP_SQUARE, which
extends each endpoint along the line direction by half its
local stroke width.
Square caps let four hb_draw_line() calls form a closed
rectangle without gaps at the corners -- a meaningfully
cheaper alternative to hb_draw_rect() for thin outlined
rectangles, since each line's bbox is just stroke_width tall
instead of covering the full rectangle interior.
Round caps not implemented yet; can be added as a third enum
value when a use case shows up.
Assisted-by: Claude <noreply@anthropic.com>
vector-output.hh fed upem-space coordinates to the draw/paint
context and then set scale_factor=1, so the resulting SVG's
viewBox / width / height were in upem (e.g. ~2500×1400 for a
48 px "Hello" in a 1000-upem font). Browsers sized the
inline SVG at 1 upem-unit-per-CSS-pixel, rendering it ~20×
too large.
Fix: compute the upem→pixel ratio from x_scale / y_scale
(already available) and
* scale the explicit extents by that ratio before calling
set_extents (so viewBox and width/height come out in
pixels), and
* pass its inverse as set_scale_factor so upem-space input
coordinates (pen position, glyph outline points) get
divided to pixels internally.
No test expected-output changes -- the vector tests render
at FONT_SIZE_UPEM where upem_to_pixel = 1 and the patch is a
no-op.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
EM_ASM stringifies its body, but the C tokenizer still parses
single-quoted '' as an empty char constant. Use double-quoted
"" -- valid JS empty string, no warning.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous palette commit added the C entry point and the
shell.html message handler but forgot to list _web_set_palette
in EXPORTED_FUNCTIONS, so emscripten dead-stripped it and the
'palette' postMessage was a silent no-op in the iframe.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add web_set_palette() to both GL and WebGPU bindings (forwards
to demo_font_set_palette + buffer rebuild) and accept a
{ kind: 'palette', value: <int> } message in shell.html. Lets
the harfbuzz-world.cc host page push the user's CPAL pick into
the embedded GPU iframe alongside text / font / variations.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Flat mode disabled glyph reuse / caching to produce inline-
everything SVG output. Its main use case was making
hb-vector SVGs safe to concatenate side-by-side in a single
document, but the recently-added svg_set_prefix API solves
that without giving up the cache. No remaining callers in
tree (util/vector-output.hh's --flat option goes too).
Removes:
- hb_vector_draw_set_flat / get_flat
- hb_vector_paint_set_flat / get_flat
- the `flat` field on both contexts
- all `if (flat)` / `bool can_cache = !flat` branches
- the --flat option in util/vector-output.hh
- the four "flat*" expected files in test/vector/basic
- the flat_draw / flat_paint params in the vector fuzzer
- sections-list entries
meson test --no-rebuild green (241/241).
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add web_set_variations(const char *) to both the WebGL and
WebGPU hb-gpu-web wasm modules. Parses a comma-separated
"wght=400,wdth=100" string via hb_variation_from_string,
applies via hb_font_set_variations on the current font, and
rebuilds the shaping buffer. Cheap to call repeatedly --
suitable for live slider pushes once a slider UI lands.
Shell.html grows a matching applyVariations() helper and a
'variations' postMessage case. config-override.h undefs
HB_NO_VAR so the new function actually links. EXPORTED
_FUNCTIONS on both build scripts list _web_set_variations.
Also plumbed in a small cap (32 axes) on the stack so the
parser doesn't need hb's internal containers -- no font has
anywhere near that many.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The iframe-hosted case ran resizeCanvas() at script parse
time, before the iframe had laid out its canvas, which
installed a 0x0 drawing buffer. getContext('webgl2')
grabbed that 0x0 context and every subsequent setup (atlas,
viewport, swap chain) was frozen at 0x0 even when
ResizeObserver later re-ran resizeCanvas with real dims --
the existing context doesn't resize with the canvas
attribute.
Bail out of resizeCanvas when either dimension is 0, so the
canvas keeps its intrinsic default (300x150) until a real
layout arrives. getContext then grabs a non-degenerate
context, and the first ResizeObserver callback bumps it up
to the actual iframe-sized buffer.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Changing canvas.width/height directly doesn't reach
emscripten's GLFW port -- its framebuffer-size callback
fires on window 'resize' events, not canvas mutation
records. When ResizeObserver picks up the iframe's first
real layout, also dispatch a synthetic 'resize' event so
the framebuffer_size callback runs in wasm and glViewport
gets re-set to the real size.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Initial resizeCanvas() runs at script parse time -- when the
shell is inside a just-mounted iframe, the canvas's
clientWidth / clientHeight are 0 (iframe hasn't laid out
yet) and the GL drawing buffer installs at 0x0. A plain
window 'resize' event never fires just because the iframe
has sized itself, so the buffer stays 0x0 and the tab looks
blank forever.
Watch the canvas with a ResizeObserver and re-run
resizeCanvas + requestRedraw on any observed size change,
which catches the first real size the moment the iframe
lays out.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>