Merge pull request #1916 from tobil4sk/fix/hb-add-utf8

Fix utf8 conversions in hb_buffer_add_utf8
This commit is contained in:
Chris Speciale
2025-03-10 07:04:56 -04:00
committed by GitHub

View File

@@ -258,14 +258,20 @@ namespace lime {
void lime_hb_buffer_add_utf8 (value buffer, HxString text, int itemOffset, int itemLength) {
hb_buffer_add_utf8 ((hb_buffer_t*)val_data (buffer), text.c_str (), text.length, itemOffset, itemLength);
int textLength = text.length;
if (hxs_encoding (text) == hx::StringUtf16) {
// hxs_utf8 doesn't give us the length, so treat it as null terminated
textLength = -1;
}
hb_buffer_add_utf8 ((hb_buffer_t*)val_data (buffer), hxs_utf8 (text, nullptr), textLength, itemOffset, itemLength);
}
HL_PRIM void HL_NAME(hl_hb_buffer_add_utf8) (HL_CFFIPointer* buffer, hl_vstring* text, int itemOffset, int itemLength) {
hb_buffer_add_utf8 ((hb_buffer_t*)buffer->ptr, text ? hl_to_utf8 (text->bytes) : NULL, text ? text->length : 0, itemOffset, itemLength);
hb_buffer_add_utf8 ((hb_buffer_t*)buffer->ptr, text ? hl_to_utf8 (text->bytes) : NULL, -1, itemOffset, itemLength);
}