Add hb_buffer_clear()
Which is like _reset(), but does NOT clear unicode-funcs.
This commit is contained in:
parent
da43a92b04
commit
82ecaff736
|
@ -133,6 +133,7 @@ struct hb_buffer_t {
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
HB_INTERNAL void reset (void);
|
HB_INTERNAL void reset (void);
|
||||||
|
HB_INTERNAL void clear (void);
|
||||||
|
|
||||||
inline unsigned int backtrack_len (void) const
|
inline unsigned int backtrack_len (void) const
|
||||||
{ return have_output? out_len : idx; }
|
{ return have_output? out_len : idx; }
|
||||||
|
|
|
@ -142,6 +142,15 @@ hb_buffer_t::reset (void)
|
||||||
hb_unicode_funcs_destroy (unicode);
|
hb_unicode_funcs_destroy (unicode);
|
||||||
unicode = hb_unicode_funcs_get_default ();
|
unicode = hb_unicode_funcs_get_default ();
|
||||||
|
|
||||||
|
clear ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
hb_buffer_t::clear (void)
|
||||||
|
{
|
||||||
|
if (unlikely (hb_object_is_inert (this)))
|
||||||
|
return;
|
||||||
|
|
||||||
hb_segment_properties_t default_props = _HB_BUFFER_PROPS_DEFAULT;
|
hb_segment_properties_t default_props = _HB_BUFFER_PROPS_DEFAULT;
|
||||||
props = default_props;
|
props = default_props;
|
||||||
|
|
||||||
|
@ -722,6 +731,12 @@ hb_buffer_reset (hb_buffer_t *buffer)
|
||||||
buffer->reset ();
|
buffer->reset ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
hb_buffer_clear (hb_buffer_t *buffer)
|
||||||
|
{
|
||||||
|
buffer->clear ();
|
||||||
|
}
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size)
|
hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -135,6 +135,10 @@ hb_buffer_get_language (hb_buffer_t *buffer);
|
||||||
void
|
void
|
||||||
hb_buffer_reset (hb_buffer_t *buffer);
|
hb_buffer_reset (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
/* Like reset, but does NOT clear unicode_funcs. */
|
||||||
|
void
|
||||||
|
hb_buffer_clear (hb_buffer_t *buffer);
|
||||||
|
|
||||||
/* Returns false if allocation failed */
|
/* Returns false if allocation failed */
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_buffer_pre_allocate (hb_buffer_t *buffer,
|
hb_buffer_pre_allocate (hb_buffer_t *buffer,
|
||||||
|
|
|
@ -128,7 +128,27 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
|
||||||
g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1));
|
g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1));
|
||||||
|
|
||||||
|
|
||||||
/* test reset clears properties */
|
|
||||||
|
/* test clear clears all properties but unicode_funcs */
|
||||||
|
|
||||||
|
hb_buffer_clear (b);
|
||||||
|
|
||||||
|
g_assert (hb_buffer_get_unicode_funcs (b) == ufuncs);
|
||||||
|
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
|
||||||
|
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
|
||||||
|
g_assert (hb_buffer_get_language (b) == NULL);
|
||||||
|
|
||||||
|
|
||||||
|
/* test reset clears all properties */
|
||||||
|
|
||||||
|
hb_buffer_set_direction (b, HB_DIRECTION_RTL);
|
||||||
|
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_RTL);
|
||||||
|
|
||||||
|
hb_buffer_set_script (b, HB_SCRIPT_ARABIC);
|
||||||
|
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_ARABIC);
|
||||||
|
|
||||||
|
hb_buffer_set_language (b, hb_language_from_string ("fa", -1));
|
||||||
|
g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1));
|
||||||
|
|
||||||
hb_buffer_reset (b);
|
hb_buffer_reset (b);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue