Move setting lig_id/component out of buffer and to the gsub code
This commit is contained in:
parent
2e2b2480c0
commit
fe263272a2
|
@ -62,23 +62,17 @@ HB_INTERNAL void
|
||||||
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
||||||
unsigned int num_in,
|
unsigned int num_in,
|
||||||
unsigned int num_out,
|
unsigned int num_out,
|
||||||
const hb_codepoint_t *glyph_data,
|
const hb_codepoint_t *glyph_data);
|
||||||
unsigned short component,
|
|
||||||
unsigned short ligID);
|
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
|
||||||
unsigned int num_in,
|
unsigned int num_in,
|
||||||
unsigned int num_out,
|
unsigned int num_out,
|
||||||
const uint16_t *glyph_data_be,
|
const uint16_t *glyph_data_be);
|
||||||
unsigned short component,
|
|
||||||
unsigned short ligID);
|
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
||||||
hb_codepoint_t glyph_index,
|
hb_codepoint_t glyph_index);
|
||||||
unsigned short component,
|
|
||||||
unsigned short ligID);
|
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_next_glyph (hb_buffer_t *buffer);
|
_hb_buffer_next_glyph (hb_buffer_t *buffer);
|
||||||
|
@ -136,20 +130,14 @@ struct _hb_buffer_t {
|
||||||
inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
|
inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
|
||||||
inline void add_output_glyphs (unsigned int num_in,
|
inline void add_output_glyphs (unsigned int num_in,
|
||||||
unsigned int num_out,
|
unsigned int num_out,
|
||||||
const hb_codepoint_t *glyph_data,
|
const hb_codepoint_t *glyph_data)
|
||||||
unsigned short component,
|
{ _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data); }
|
||||||
unsigned short ligID)
|
|
||||||
{ _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); }
|
|
||||||
inline void add_output_glyphs_be16 (unsigned int num_in,
|
inline void add_output_glyphs_be16 (unsigned int num_in,
|
||||||
unsigned int num_out,
|
unsigned int num_out,
|
||||||
const uint16_t *glyph_data_be,
|
const uint16_t *glyph_data_be)
|
||||||
unsigned short component,
|
{ _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be); }
|
||||||
unsigned short ligID)
|
inline void add_output_glyph (hb_codepoint_t glyph_index)
|
||||||
{ _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); }
|
{ _hb_buffer_add_output_glyph (this, glyph_index); }
|
||||||
inline void add_output_glyph (hb_codepoint_t glyph_index,
|
|
||||||
unsigned short component = 0xFFFF,
|
|
||||||
unsigned short ligID = 0xFFFF)
|
|
||||||
{ _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); }
|
|
||||||
inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
|
inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
|
||||||
|
|
||||||
inline void reset_masks (hb_mask_t mask)
|
inline void reset_masks (hb_mask_t mask)
|
||||||
|
|
|
@ -314,14 +314,8 @@ void
|
||||||
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
||||||
unsigned int num_in,
|
unsigned int num_in,
|
||||||
unsigned int num_out,
|
unsigned int num_out,
|
||||||
const hb_codepoint_t *glyph_data,
|
const hb_codepoint_t *glyph_data)
|
||||||
unsigned short component,
|
|
||||||
unsigned short lig_id)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
unsigned int mask;
|
|
||||||
unsigned int cluster;
|
|
||||||
|
|
||||||
if (buffer->out_info != buffer->info ||
|
if (buffer->out_info != buffer->info ||
|
||||||
buffer->out_len + num_out > buffer->i + num_in)
|
buffer->out_len + num_out > buffer->i + num_in)
|
||||||
{
|
{
|
||||||
|
@ -329,21 +323,13 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mask = buffer->info[buffer->i].mask;
|
hb_glyph_info_t orig_info = buffer->info[buffer->i];
|
||||||
cluster = buffer->info[buffer->i].cluster;
|
|
||||||
if (component == 0xFFFF)
|
|
||||||
component = buffer->info[buffer->i].component();
|
|
||||||
if (lig_id == 0xFFFF)
|
|
||||||
lig_id = buffer->info[buffer->i].lig_id();
|
|
||||||
|
|
||||||
for (i = 0; i < num_out; i++)
|
for (unsigned int i = 0; i < num_out; i++)
|
||||||
{
|
{
|
||||||
hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i];
|
hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i];
|
||||||
|
*info = orig_info;
|
||||||
info->codepoint = glyph_data[i];
|
info->codepoint = glyph_data[i];
|
||||||
info->mask = mask;
|
|
||||||
info->cluster = cluster;
|
|
||||||
info->component() = component;
|
|
||||||
info->lig_id() = lig_id;
|
|
||||||
info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,14 +341,8 @@ void
|
||||||
_hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
|
||||||
unsigned int num_in,
|
unsigned int num_in,
|
||||||
unsigned int num_out,
|
unsigned int num_out,
|
||||||
const uint16_t *glyph_data_be,
|
const uint16_t *glyph_data_be)
|
||||||
unsigned short component,
|
|
||||||
unsigned short lig_id)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
unsigned int mask;
|
|
||||||
unsigned int cluster;
|
|
||||||
|
|
||||||
if (buffer->out_info != buffer->info ||
|
if (buffer->out_info != buffer->info ||
|
||||||
buffer->out_len + num_out > buffer->i + num_in)
|
buffer->out_len + num_out > buffer->i + num_in)
|
||||||
{
|
{
|
||||||
|
@ -370,21 +350,13 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mask = buffer->info[buffer->i].mask;
|
hb_glyph_info_t orig_info = buffer->info[buffer->i];
|
||||||
cluster = buffer->info[buffer->i].cluster;
|
|
||||||
if (component == 0xFFFF)
|
|
||||||
component = buffer->info[buffer->i].component();
|
|
||||||
if (lig_id == 0xFFFF)
|
|
||||||
lig_id = buffer->info[buffer->i].lig_id();
|
|
||||||
|
|
||||||
for (i = 0; i < num_out; i++)
|
for (unsigned int i = 0; i < num_out; i++)
|
||||||
{
|
{
|
||||||
hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i];
|
hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i];
|
||||||
|
*info = orig_info;
|
||||||
info->codepoint = hb_be_uint16 (glyph_data_be[i]);
|
info->codepoint = hb_be_uint16 (glyph_data_be[i]);
|
||||||
info->mask = mask;
|
|
||||||
info->cluster = cluster;
|
|
||||||
info->component() = component;
|
|
||||||
info->lig_id() = lig_id;
|
|
||||||
info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,9 +366,7 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
|
||||||
|
|
||||||
void
|
void
|
||||||
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
||||||
hb_codepoint_t glyph_index,
|
hb_codepoint_t glyph_index)
|
||||||
unsigned short component,
|
|
||||||
unsigned short lig_id)
|
|
||||||
{
|
{
|
||||||
hb_glyph_info_t *info;
|
hb_glyph_info_t *info;
|
||||||
|
|
||||||
|
@ -410,10 +380,6 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
||||||
|
|
||||||
info = &buffer->out_info[buffer->out_len];
|
info = &buffer->out_info[buffer->out_len];
|
||||||
info->codepoint = glyph_index;
|
info->codepoint = glyph_index;
|
||||||
if (component != 0xFFFF)
|
|
||||||
info->component() = component;
|
|
||||||
if (lig_id != 0xFFFF)
|
|
||||||
info->lig_id() = lig_id;
|
|
||||||
info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
||||||
|
|
||||||
buffer->i++;
|
buffer->i++;
|
||||||
|
|
|
@ -164,9 +164,7 @@ struct Sequence
|
||||||
if (unlikely (!substitute.len))
|
if (unlikely (!substitute.len))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
c->buffer->add_output_glyphs_be16 (1,
|
c->buffer->add_output_glyphs_be16 (1, substitute.len, (const uint16_t *) substitute.array);
|
||||||
substitute.len, (const uint16_t *) substitute.array,
|
|
||||||
0xFFFF, 0xFFFF);
|
|
||||||
|
|
||||||
/* This is a guess only ... */
|
/* This is a guess only ... */
|
||||||
if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
|
if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
|
||||||
|
@ -392,15 +390,18 @@ struct Ligature
|
||||||
is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
|
is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
|
||||||
: HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
|
: HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
|
||||||
|
|
||||||
|
/* Allocate new ligature id */
|
||||||
|
unsigned int lig_id = c->buffer->allocate_lig_id ();
|
||||||
|
c->buffer->info[c->buffer->i].component() = 0;
|
||||||
|
c->buffer->info[c->buffer->i].lig_id() = lig_id;
|
||||||
|
|
||||||
if (j == c->buffer->i + i) /* No input glyphs skipped */
|
if (j == c->buffer->i + i) /* No input glyphs skipped */
|
||||||
c->buffer->add_output_glyphs_be16 (i,
|
{
|
||||||
1, (const uint16_t *) &ligGlyph,
|
c->buffer->add_output_glyphs_be16 (i, 1, (const uint16_t *) &ligGlyph);
|
||||||
0,
|
}
|
||||||
c->buffer->allocate_lig_id ());
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int lig_id = c->buffer->allocate_lig_id ();
|
c->buffer->add_output_glyph (ligGlyph);
|
||||||
c->buffer->add_output_glyph (ligGlyph, 0, lig_id);
|
|
||||||
|
|
||||||
/* Now we must do a second loop to copy the skipped glyphs to
|
/* Now we must do a second loop to copy the skipped glyphs to
|
||||||
`out' and assign component values to it. We start with the
|
`out' and assign component values to it. We start with the
|
||||||
|
@ -409,10 +410,14 @@ struct Ligature
|
||||||
value it is later possible to check whether a specific
|
value it is later possible to check whether a specific
|
||||||
component value really belongs to a given ligature. */
|
component value really belongs to a given ligature. */
|
||||||
|
|
||||||
for ( i = 1; i < count; i++ )
|
for (i = 1; i < count; i++)
|
||||||
{
|
{
|
||||||
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_flag, NULL))
|
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_flag, NULL))
|
||||||
c->buffer->add_output_glyph (c->buffer->info[c->buffer->i].codepoint, i, lig_id);
|
{
|
||||||
|
c->buffer->info[c->buffer->i].component() = i;
|
||||||
|
c->buffer->info[c->buffer->i].lig_id() = lig_id;
|
||||||
|
c->buffer->add_output_glyph (c->buffer->info[c->buffer->i].codepoint);
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip the base glyph */
|
/* Skip the base glyph */
|
||||||
c->buffer->i++;
|
c->buffer->i++;
|
||||||
|
|
Loading…
Reference in New Issue