Convert additional cleanup patterns across the codebase to use
HB_SCOPE_GUARD / hb_make_scope_guard. All changes are mechanical
replacements of goto-based cleanup with scope guards; no behavior
changes.
Destroy-on-fail funcs-setter pattern (identical body in four files):
- hb-draw.cc _hb_draw_funcs_set_middle
- hb-font.cc _hb_font_funcs_set_middle
- hb-paint.cc _hb_paint_funcs_set_middle
- hb-unicode.cc HB_UNICODE_FUNC_IMPLEMENT macro
Replace two goto-fail sites per function with one scope guard that
runs destroy(user_data), released on the success path.
Resource cleanup with multi-exit paths:
- hb-gdi.cc _hb_gdi_reference_table: GDI DC + hb_malloc buffer
via paired scope guards; collapse three fail labels to returns.
- hb-wasm-shape.cc face-data init: wasm_blob + wasm_module via
scope guards.
- hb-uniscribe.cc _hb_rename_font: hb_blob + hb_calloc'd sfnt
buffer via scope guards.
- hb-ft.cc _hb_ft_reference_table: hb_malloc'd FT buffer via
scope guard.
- hb-ot-font.cc hb_ot_draw_glyph_or_fail: release_gvar_cache via
scope guard; remove the goto done cascade in the backend walk.
- hb-raster-draw.cc hb_raster_draw_render: per-exit state reset
via scope guard; image cleanup via scope guard released on
success.
- hb-coretext.cc CTFontCopyAvailableTables walker + variations
extractor: CFRelease pairs via scope guards.
Pure control-flow cleanup (no RAII, just goto→return):
- hb-raster-paint.cc: four "goto done" sites in gradient paint
funcs where done: body was only (void) stops_ — remove label,
use return directly.
All 240 tests still pass.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
It makes sense to disable this code these if editing is not needed.
However, this is also necessary to correctly display emoji sequences
in right-to-left direction. For that reason, don't auto-disable it.
UCDN was ~120kb of data. New implementatoin is 69kb in default builds,
and 49kb if built with HB_OPTIMIZE_SIZE or __OPTIMIZE_SIZE__. The
latter automatically enabled if built with -Os or -Oz.
There's room to shave off another 10kb or 20kb. That will follow later.
Fixes https://github.com/harfbuzz/harfbuzz/issues/1652
https://bugs.freedesktop.org/show_bug.cgi?id=91228
Commit cdcdfe61b9 changed two `#pragma
message` to `#pragma error` in hb-unicode.cc, however MSVC uses #error,
just like the #else branch. `#pragma error` is an unknown pragma so
MSVC does not fail the build because of it, which I believe was the
intention of that commit.
If it's meant to be an #error, then the #ifdef for _MSC_VER can be
removed entirely.