* [buffer] Add deserializers with byte offsets
Buffer deserializers return a pointer into caller-owned input. GIR
describes it as an owned UTF-8 string, so bindings can free an
interior pointer or read beyond explicitly sized input.
Add _with_offset variants with bounded byte-array inputs and optional
byte counts. Preserve the existing return values and partial buffer
contents, including on failure. Cross-check both variants against the
existing deserializers in the buffer API tests.
Testing: full Meson suite, buffer tests under Valgrind, and GIR and
PyGObject checks.
Fixes: #6446
Assisted-by: OpenAI Codex
* [buffer] Rename new deserializers to use 2 suffix
Use the established 2 suffix for the new buffer deserializers,
following hb_shape_plan_create2(). Update API docs, NEWS, and tests.
Testing: full Meson suite, generated GIR, and PyGObject checks.
Assisted-by: OpenAI Codex
Every hb_buffer_set_*() is meant to be a no-op on an immutable
buffer, which is what keeps the static _hb_Null_hb_buffer_t
(returned by hb_buffer_get_empty(), and by hb_buffer_create() on
allocation failure) inert. Three entry points skipped that guard:
- hb_buffer_set_not_found_variation_selector_glyph() stored into
the singleton;
- hb_buffer_guess_segment_properties() wrote direction and
language into it;
- hb_buffer_create_similar() called similar() on the singleton
when its internal hb_buffer_create() failed, copying the source
buffer's settings onto the shared empty buffer and leaking a
reference to its unicode funcs.
Add the same hb_object_is_immutable() early return the sibling
setters use, and guard the create_similar() allocation-failure path
the way hb_font_create_sub_font() already does. No other public
setter in hb-buffer.cc lacks the check. No API/ABI change; the
only behaviour change is that these calls on the empty buffer now
do nothing, as the documented object model promises.
A regression check is appended to test_buffer_empty().
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-RNK5DQFY.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Buffer reset has retained message callbacks since their introduction,
although its documentation promised a freshly created buffer state.
Clarify that callbacks, their associated data, and attached user data
survive reset. Document explicit callback removal and destruction.
Add a regression test for callback-directed lookup skipping after
clear/reset, restoration of ligatures after removal, and exactly-once
destruction on replacement, removal, and final buffer destruction.
Tested with meson test -C build: 287 passed, 1 skipped, 0 failed.
The API test also compiles without buffer messages or OT shaping.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6341
Assisted-by: OpenAI Codex
Widen position differences before taking their absolute value. This
avoids signed overflow when hb_buffer_diff() compares positions near
opposite ends of the hb_position_t range.
Add an API regression covering INT32_MIN versus INT32_MAX.
Tested with: meson test -C build --print-errorlogs
Assisted-by: OpenAI Codex
Add focused API tests for hb_buffer_create_similar() and buffer
configuration persistence across clear/reset. Also exercise public hb_map
copy, equality, hash, update, iteration, keys, and values paths with
order-independent assertions.
Validation:
meson test -C build-tgl-precheck --print-errorlogs --suite api test-buffer
meson test -C build-tgl-precheck --print-errorlogs --suite api test-map
meson test -C build-tgl-precheck --print-errorlogs --suite api test-buffer test-map
Assisted-by: OpenAI Codex <codex@openai.com>
Co-authored-by: jeffhuang <jeff@docker.xydrsucermoubd24xgo33yhsgd.bx.internal.cloudapp.net>
After 763e5466c0, one doesn't
need to set flags for different pieces of text. The flags now
are something the client sets up once, depending on how it
actually uses the buffer. As such, don't clear it in
clear_contents().
Tests updated.
With this change, we now by default replace broken UTF-8/16/32 bits
with U+FFFD. This can be changed by calling new API on the buffer.
Previously the replacement value used to be (hb_codepoint_t)-1.
Note that hb_buffer_clear_contents() does NOT reset the replacement
character.
See discussion here:
https://github.com/behdad/harfbuzz/commit/6f13b6d62daae4989e3cc2fe4b168e5c59650964
New API:
hb_buffer_set_replacement_codepoint()
hb_buffer_get_replacement_codepoint()
New API:
hb_buffer_flags_t
HB_BUFFER_FLAGS_DEFAULT
HB_BUFFER_FLAG_BOT
HB_BUFFER_FLAG_EOT
HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES
hb_buffer_set_flags()
hb_buffer_get_flags()
We use the BOT flag to decide whether to insert dottedcircle if the
first char in the buffer is a combining mark.
The PRESERVE_DEFAULT_IGNORABLES flag prevents removal of characters like
ZWNJ/ZWJ/...