From a003890e8462b001cc522e0d7785fd4248c8365f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 21 Sep 2024 11:30:56 -0600 Subject: [PATCH] [buffer] Add hb_buffer_[sg]et_not_found_variation_selector_glyph() Unused. --- src/hb-buffer.cc | 41 ++++++++++++++++++++++++++++++++++++ src/hb-buffer.h | 7 ++++++ src/hb-buffer.hh | 1 + src/hb-ot-shape-normalize.cc | 7 +++--- src/hb-ot-shape-normalize.hh | 1 - 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index d621a7cc5..b7be00ea4 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -271,6 +271,7 @@ hb_buffer_t::similar (const hb_buffer_t &src) replacement = src.replacement; invisible = src.invisible; not_found = src.not_found; + not_found_variation_selector = src.not_found_variation_selector; } void @@ -283,6 +284,7 @@ hb_buffer_t::reset () replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT; invisible = 0; not_found = 0; + not_found_variation_selector = HB_CODEPOINT_INVALID; clear (); } @@ -705,6 +707,7 @@ DEFINE_NULL_INSTANCE (hb_buffer_t) = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, 0, /* invisible */ 0, /* not_found */ + HB_CODEPOINT_INVALID, /* not_found_variation_selector */ HB_BUFFER_CONTENT_TYPE_INVALID, @@ -1360,6 +1363,44 @@ hb_buffer_get_not_found_glyph (const hb_buffer_t *buffer) return buffer->not_found; } +/** + * hb_buffer_set_not_found_variation_selector_glyph: + * @buffer: An #hb_buffer_t + * @not_found_variation_selector: the not-found-variation-selector #hb_codepoint_t + * + * Sets the #hb_codepoint_t that replaces variation-selector characters not resolved + * in the font during shaping. + * + * The not-found-variation-selector glyph defaults to #HB_CODEPOINT_INVALID, + * in which case it will be removed from the glyph string during shaping. + * This API allows for changing that and retaining the glyph. + * + * XSince: REPLACEME + **/ +void +hb_buffer_set_not_found_variation_selector_glyph (hb_buffer_t *buffer, + hb_codepoint_t not_found_variation_selector) +{ + buffer->not_found_variation_selector = not_found_variation_selector; +} + +/** + * hb_buffer_get_not_found_variation_selector_glyph: + * @buffer: An #hb_buffer_t + * + * See hb_buffer_set_not_found_variation_selector_glyph(). + * + * Return value: + * The @buffer not-found-variation-selector #hb_codepoint_t + * + * XSince: REPLACEME + **/ +hb_codepoint_t +hb_buffer_get_not_found_variation_selector_glyph (const hb_buffer_t *buffer) +{ + return buffer->not_found_variation_selector; +} + /** * hb_buffer_set_random_state: * @buffer: An #hb_buffer_t diff --git a/src/hb-buffer.h b/src/hb-buffer.h index f75fe96b2..dd0edb9b7 100644 --- a/src/hb-buffer.h +++ b/src/hb-buffer.h @@ -487,6 +487,13 @@ hb_buffer_set_not_found_glyph (hb_buffer_t *buffer, HB_EXTERN hb_codepoint_t hb_buffer_get_not_found_glyph (const hb_buffer_t *buffer); +HB_EXTERN void +hb_buffer_set_not_found_variation_selector_glyph (hb_buffer_t *buffer, + hb_codepoint_t not_found_variation_selector); + +HB_EXTERN hb_codepoint_t +hb_buffer_get_not_found_variation_selector_glyph (const hb_buffer_t *buffer); + HB_EXTERN void hb_buffer_set_random_state (hb_buffer_t *buffer, unsigned state); diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 0a198722d..abf87e7a6 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -80,6 +80,7 @@ struct hb_buffer_t hb_codepoint_t replacement; /* U+FFFD or something else. */ hb_codepoint_t invisible; /* 0 or something else. */ hb_codepoint_t not_found; /* 0 or something else. */ + hb_codepoint_t not_found_variation_selector; /* HB_CODEPOINT_INVALID or something else. */ /* * Buffer contents diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 7948899ab..4da711c85 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -153,7 +153,7 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor hb_codepoint_t u = buffer->cur().codepoint; hb_codepoint_t glyph = 0; - if (shortest && c->font->get_nominal_glyph (u, &glyph, c->not_found)) + if (shortest && c->font->get_nominal_glyph (u, &glyph, buffer->not_found)) { next_char (buffer, glyph); return; @@ -165,7 +165,7 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor return; } - if (!shortest && c->font->get_nominal_glyph (u, &glyph, c->not_found)) + if (!shortest && c->font->get_nominal_glyph (u, &glyph, buffer->not_found)) { next_char (buffer, glyph); return; @@ -295,7 +295,8 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, buffer, font, buffer->unicode, - buffer->not_found, + plan->shaper->decompose ? plan->shaper->decompose : hb_ot_shape_normalize_context_t::decompose_unicode, + plan->shaper->compose ? plan->shaper->compose : hb_ot_shape_normalize_context_t::compose_unicode }; c.override_decompose_and_compose (plan->shaper->decompose, plan->shaper->compose); diff --git a/src/hb-ot-shape-normalize.hh b/src/hb-ot-shape-normalize.hh index 0e8a54b60..f12cb35c0 100644 --- a/src/hb-ot-shape-normalize.hh +++ b/src/hb-ot-shape-normalize.hh @@ -89,7 +89,6 @@ struct hb_ot_shape_normalize_context_t hb_buffer_t *buffer; hb_font_t *font; hb_unicode_funcs_t *unicode; - const hb_codepoint_t not_found; bool (*decompose) (const hb_ot_shape_normalize_context_t *c, hb_codepoint_t ab, hb_codepoint_t *a,