You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-01 16:38:31 +00:00
HarfBuzz: Update to version 2.8.0
This commit is contained in:
101
thirdparty/harfbuzz/src/hb-buffer.hh
vendored
101
thirdparty/harfbuzz/src/hb-buffer.hh
vendored
@@ -139,7 +139,7 @@ struct hb_buffer_t
|
||||
|
||||
/* Methods */
|
||||
|
||||
bool in_error () const { return !successful; }
|
||||
HB_NODISCARD bool in_error () const { return !successful; }
|
||||
|
||||
void allocate_var (unsigned int start, unsigned int count)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ struct hb_buffer_t
|
||||
hb_glyph_info_t &prev () { return out_info[out_len ? out_len - 1 : 0]; }
|
||||
hb_glyph_info_t prev () const { return out_info[out_len ? out_len - 1 : 0]; }
|
||||
|
||||
bool has_separate_output () const { return info != out_info; }
|
||||
HB_NODISCARD bool has_separate_output () const { return info != out_info; }
|
||||
|
||||
|
||||
HB_INTERNAL void reset ();
|
||||
@@ -210,86 +210,89 @@ struct hb_buffer_t
|
||||
HB_INTERNAL void clear_output ();
|
||||
HB_INTERNAL void clear_positions ();
|
||||
|
||||
HB_INTERNAL void replace_glyphs (unsigned int num_in,
|
||||
unsigned int num_out,
|
||||
const hb_codepoint_t *glyph_data);
|
||||
|
||||
void replace_glyph (hb_codepoint_t glyph_index)
|
||||
template <typename T>
|
||||
HB_NODISCARD bool replace_glyphs (unsigned int num_in,
|
||||
unsigned int num_out,
|
||||
const T *glyph_data)
|
||||
{
|
||||
if (unlikely (out_info != info || out_len != idx)) {
|
||||
if (unlikely (!make_room_for (1, 1))) return;
|
||||
out_info[out_len] = info[idx];
|
||||
if (unlikely (!make_room_for (num_in, num_out))) return false;
|
||||
|
||||
assert (idx + num_in <= len);
|
||||
|
||||
merge_clusters (idx, idx + num_in);
|
||||
|
||||
hb_glyph_info_t &orig_info = idx < len ? cur() : prev();
|
||||
|
||||
hb_glyph_info_t *pinfo = &out_info[out_len];
|
||||
for (unsigned int i = 0; i < num_out; i++)
|
||||
{
|
||||
*pinfo = orig_info;
|
||||
pinfo->codepoint = glyph_data[i];
|
||||
pinfo++;
|
||||
}
|
||||
out_info[out_len].codepoint = glyph_index;
|
||||
|
||||
idx++;
|
||||
out_len++;
|
||||
idx += num_in;
|
||||
out_len += num_out;
|
||||
return true;
|
||||
}
|
||||
|
||||
HB_NODISCARD bool replace_glyph (hb_codepoint_t glyph_index)
|
||||
{ return replace_glyphs (1, 1, &glyph_index); }
|
||||
|
||||
/* Makes a copy of the glyph at idx to output and replace glyph_index */
|
||||
hb_glyph_info_t & output_glyph (hb_codepoint_t glyph_index)
|
||||
HB_NODISCARD bool output_glyph (hb_codepoint_t glyph_index)
|
||||
{ return replace_glyphs (0, 1, &glyph_index); }
|
||||
|
||||
HB_NODISCARD bool output_info (const hb_glyph_info_t &glyph_info)
|
||||
{
|
||||
if (unlikely (!make_room_for (0, 1))) return Crap (hb_glyph_info_t);
|
||||
|
||||
if (unlikely (idx == len && !out_len))
|
||||
return Crap (hb_glyph_info_t);
|
||||
|
||||
out_info[out_len] = idx < len ? info[idx] : out_info[out_len - 1];
|
||||
out_info[out_len].codepoint = glyph_index;
|
||||
|
||||
out_len++;
|
||||
|
||||
return out_info[out_len - 1];
|
||||
}
|
||||
void output_info (const hb_glyph_info_t &glyph_info)
|
||||
{
|
||||
if (unlikely (!make_room_for (0, 1))) return;
|
||||
if (unlikely (!make_room_for (0, 1))) return false;
|
||||
|
||||
out_info[out_len] = glyph_info;
|
||||
|
||||
out_len++;
|
||||
return true;
|
||||
}
|
||||
/* Copies glyph at idx to output but doesn't advance idx */
|
||||
void copy_glyph ()
|
||||
HB_NODISCARD bool copy_glyph ()
|
||||
{
|
||||
if (unlikely (!make_room_for (0, 1))) return;
|
||||
|
||||
out_info[out_len] = info[idx];
|
||||
|
||||
out_len++;
|
||||
/* Extra copy because cur()'s return can be freed within
|
||||
* output_info() call if buffer reallocates. */
|
||||
return output_info (hb_glyph_info_t (cur()));
|
||||
}
|
||||
|
||||
/* Copies glyph at idx to output and advance idx.
|
||||
* If there's no output, just advance idx. */
|
||||
void
|
||||
next_glyph ()
|
||||
HB_NODISCARD bool next_glyph ()
|
||||
{
|
||||
if (have_output)
|
||||
{
|
||||
if (out_info != info || out_len != idx)
|
||||
{
|
||||
if (unlikely (!make_room_for (1, 1))) return;
|
||||
if (unlikely (!make_room_for (1, 1))) return false;
|
||||
out_info[out_len] = info[idx];
|
||||
}
|
||||
out_len++;
|
||||
}
|
||||
|
||||
idx++;
|
||||
return true;
|
||||
}
|
||||
/* Copies n glyphs at idx to output and advance idx.
|
||||
* If there's no output, just advance idx. */
|
||||
void
|
||||
next_glyphs (unsigned int n)
|
||||
HB_NODISCARD bool next_glyphs (unsigned int n)
|
||||
{
|
||||
if (have_output)
|
||||
{
|
||||
if (out_info != info || out_len != idx)
|
||||
{
|
||||
if (unlikely (!make_room_for (n, n))) return;
|
||||
if (unlikely (!make_room_for (n, n))) return false;
|
||||
memmove (out_info + out_len, info + idx, n * sizeof (out_info[0]));
|
||||
}
|
||||
out_len += n;
|
||||
}
|
||||
|
||||
idx += n;
|
||||
return true;
|
||||
}
|
||||
/* Advance idx without copying to output. */
|
||||
void skip_glyph () { idx++; }
|
||||
@@ -329,14 +332,14 @@ struct hb_buffer_t
|
||||
|
||||
|
||||
/* Internal methods */
|
||||
HB_INTERNAL bool move_to (unsigned int i); /* i is output-buffer index. */
|
||||
HB_NODISCARD HB_INTERNAL bool move_to (unsigned int i); /* i is output-buffer index. */
|
||||
|
||||
HB_INTERNAL bool enlarge (unsigned int size);
|
||||
HB_NODISCARD HB_INTERNAL bool enlarge (unsigned int size);
|
||||
|
||||
bool ensure (unsigned int size)
|
||||
HB_NODISCARD bool ensure (unsigned int size)
|
||||
{ return likely (!size || size < allocated) ? true : enlarge (size); }
|
||||
|
||||
bool ensure_inplace (unsigned int size)
|
||||
HB_NODISCARD bool ensure_inplace (unsigned int size)
|
||||
{ return likely (!size || size < allocated); }
|
||||
|
||||
void assert_glyphs ()
|
||||
@@ -349,7 +352,7 @@ struct hb_buffer_t
|
||||
assert ((content_type == HB_BUFFER_CONTENT_TYPE_UNICODE) ||
|
||||
(!len && (content_type == HB_BUFFER_CONTENT_TYPE_INVALID)));
|
||||
}
|
||||
bool ensure_glyphs ()
|
||||
HB_NODISCARD bool ensure_glyphs ()
|
||||
{
|
||||
if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
|
||||
{
|
||||
@@ -360,7 +363,7 @@ struct hb_buffer_t
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool ensure_unicode ()
|
||||
HB_NODISCARD bool ensure_unicode ()
|
||||
{
|
||||
if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
|
||||
{
|
||||
@@ -372,8 +375,8 @@ struct hb_buffer_t
|
||||
return true;
|
||||
}
|
||||
|
||||
HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
|
||||
HB_INTERNAL bool shift_forward (unsigned int count);
|
||||
HB_NODISCARD HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
|
||||
HB_NODISCARD HB_INTERNAL bool shift_forward (unsigned int count);
|
||||
|
||||
typedef long scratch_buffer_t;
|
||||
HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size);
|
||||
|
||||
Reference in New Issue
Block a user