[mort] Make ligatures work
./hb-shape Apple_Chancery_10_12.ttf "Th th ll te to tr fr fu fj" [T_h=0+2308|space=2+569|t_h=3+1687|space=5+569|l_l=6+1108|space=8+569|t_e=9+1408|space=11+569|t_o=12+1531|space=14+569|t_r=15+1385|space=17+569|f_r=18+1432|space=20+569|f_u=21+1733|space=23+569|f_j=24+1098] Part of https://github.com/harfbuzz/harfbuzz/issues/1331
This commit is contained in:
parent
c077989600
commit
c962d5e714
|
@ -448,10 +448,11 @@ struct LigatureSubtable
|
||||||
* into the component table. */
|
* into the component table. */
|
||||||
};
|
};
|
||||||
|
|
||||||
inline driver_context_t (const LigatureSubtable *table,
|
inline driver_context_t (const LigatureSubtable *table_,
|
||||||
hb_aat_apply_context_t *c_) :
|
hb_aat_apply_context_t *c_) :
|
||||||
ret (false),
|
ret (false),
|
||||||
c (c_),
|
c (c_),
|
||||||
|
table (table_),
|
||||||
ligAction (table+table->ligAction),
|
ligAction (table+table->ligAction),
|
||||||
component (table+table->component),
|
component (table+table->component),
|
||||||
ligature (table+table->ligature),
|
ligature (table+table->ligature),
|
||||||
|
@ -497,6 +498,9 @@ struct LigatureSubtable
|
||||||
return false; // TODO Work on previous instead?
|
return false; // TODO Work on previous instead?
|
||||||
|
|
||||||
unsigned int cursor = match_length;
|
unsigned int cursor = match_length;
|
||||||
|
const HBUINT32 *actionData = Types::extended ?
|
||||||
|
&ligAction[action_idx] :
|
||||||
|
&StructAtOffset<HBUINT32> (table, action_idx);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (unlikely (!cursor))
|
if (unlikely (!cursor))
|
||||||
|
@ -510,17 +514,20 @@ struct LigatureSubtable
|
||||||
DEBUG_MSG (APPLY, nullptr, "Moving to stack position %d", cursor - 1);
|
DEBUG_MSG (APPLY, nullptr, "Moving to stack position %d", cursor - 1);
|
||||||
buffer->move_to (match_positions[--cursor]);
|
buffer->move_to (match_positions[--cursor]);
|
||||||
|
|
||||||
const HBUINT32 &actionData = ligAction[action_idx];
|
if (unlikely (!actionData->sanitize (&c->sanitizer))) return false;
|
||||||
if (unlikely (!actionData.sanitize (&c->sanitizer))) return false;
|
action = *actionData;
|
||||||
action = actionData;
|
|
||||||
|
|
||||||
uint32_t uoffset = action & LigActionOffset;
|
uint32_t uoffset = action & LigActionOffset;
|
||||||
if (uoffset & 0x20000000)
|
if (uoffset & 0x20000000)
|
||||||
uoffset |= 0xC0000000; /* Sign-extend. */
|
uoffset |= 0xC0000000; /* Sign-extend. */
|
||||||
int32_t offset = (int32_t) uoffset;
|
int32_t offset = (int32_t) uoffset;
|
||||||
unsigned int component_idx = buffer->cur().codepoint + offset;
|
unsigned int component_idx = buffer->cur().codepoint + offset;
|
||||||
|
if (!Types::extended)
|
||||||
|
component_idx *= 2;
|
||||||
|
|
||||||
const HBUINT16 &componentData = component[component_idx];
|
const HBUINT16 &componentData = Types::extended ?
|
||||||
|
component[component_idx] :
|
||||||
|
StructAtOffset<HBUINT16> (table, component_idx);
|
||||||
if (unlikely (!componentData.sanitize (&c->sanitizer))) return false;
|
if (unlikely (!componentData.sanitize (&c->sanitizer))) return false;
|
||||||
ligature_idx += componentData;
|
ligature_idx += componentData;
|
||||||
|
|
||||||
|
@ -529,8 +536,9 @@ struct LigatureSubtable
|
||||||
bool (action & LigActionLast));
|
bool (action & LigActionLast));
|
||||||
if (action & (LigActionStore | LigActionLast))
|
if (action & (LigActionStore | LigActionLast))
|
||||||
{
|
{
|
||||||
|
const GlyphID &ligatureData = Types::extended ?
|
||||||
const GlyphID &ligatureData = ligature[ligature_idx];
|
ligature[ligature_idx] :
|
||||||
|
StructAtOffset<GlyphID> (table, ligature_idx);
|
||||||
if (unlikely (!ligatureData.sanitize (&c->sanitizer))) return false;
|
if (unlikely (!ligatureData.sanitize (&c->sanitizer))) return false;
|
||||||
hb_codepoint_t lig = ligatureData;
|
hb_codepoint_t lig = ligatureData;
|
||||||
|
|
||||||
|
@ -550,7 +558,7 @@ struct LigatureSubtable
|
||||||
buffer->merge_out_clusters (match_positions[cursor], buffer->out_len);
|
buffer->merge_out_clusters (match_positions[cursor], buffer->out_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
action_idx++;
|
actionData++;
|
||||||
}
|
}
|
||||||
while (!(action & LigActionLast));
|
while (!(action & LigActionLast));
|
||||||
buffer->move_to (end);
|
buffer->move_to (end);
|
||||||
|
@ -563,6 +571,7 @@ struct LigatureSubtable
|
||||||
bool ret;
|
bool ret;
|
||||||
private:
|
private:
|
||||||
hb_aat_apply_context_t *c;
|
hb_aat_apply_context_t *c;
|
||||||
|
const LigatureSubtable *table;
|
||||||
const UnsizedArrayOf<HBUINT32> &ligAction;
|
const UnsizedArrayOf<HBUINT32> &ligAction;
|
||||||
const UnsizedArrayOf<HBUINT16> &component;
|
const UnsizedArrayOf<HBUINT16> &component;
|
||||||
const UnsizedArrayOf<GlyphID> &ligature;
|
const UnsizedArrayOf<GlyphID> &ligature;
|
||||||
|
|
Loading…
Reference in New Issue