提交 c0505f3b 编写于 作者: B Behdad Esfahbod 提交者: Behdad Esfahbod

Patches from #170414. Reviewed by Matthias Clasen.

2005-11-03  Behdad Esfahbod  <behdad@gnome.org>

        Patches from #170414.  Reviewed by Matthias Clasen.

        * pango/opentype/ftxgpos.c, pango/opentype/ftxgsub.c: Use call table
        to dispatch different lookup types.

        * pango/opentype/pango-ot-buffer.c, pango/opentype/pango-ot-ruleset.c:
        Small cleanup.
上级 c6b22b91
......@@ -1027,16 +1027,27 @@
Free_Coverage( &sp->Coverage, memory );
}
static FT_Error Lookup_DefaultPos( GPOS_Instance* gpi,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
return TTO_Err_Not_Covered;
}
static FT_Error Lookup_SinglePos( GPOS_Instance* gpi,
TTO_SinglePos* sp,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length )
FT_UShort context_length,
int nesting_level )
{
FT_UShort index, property;
FT_Error error;
TTO_GPOSHeader* gpos = gpi->gpos;
TTO_SinglePos* sp = &st->single;
if ( context_length != 0xFFFF && context_length < 1 )
......@@ -1588,14 +1599,16 @@
static FT_Error Lookup_PairPos( GPOS_Instance* gpi,
TTO_PairPos* pp,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length )
FT_UShort context_length,
int nesting_level )
{
FT_Error error;
FT_UShort index, property, first_pos;
TTO_GPOSHeader* gpos = gpi->gpos;
TTO_PairPos* pp = &st->pair;
if ( buffer->in_pos >= buffer->in_length - 1 )
......@@ -1794,14 +1807,16 @@
static FT_Error Lookup_CursivePos( GPOS_Instance* gpi,
TTO_CursivePos* cp,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length )
FT_UShort context_length,
int nesting_level )
{
FT_UShort index, property;
FT_Error error;
TTO_GPOSHeader* gpos = gpi->gpos;
TTO_CursivePos* cp = &st->cursive;
TTO_EntryExitRecord* eer;
FT_Pos entry_x, entry_y;
......@@ -2219,15 +2234,17 @@
static FT_Error Lookup_MarkBasePos( GPOS_Instance* gpi,
TTO_MarkBasePos* mbp,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length )
FT_UShort context_length,
int nesting_level )
{
FT_UShort i, j, mark_index, base_index, property, class;
FT_Pos x_mark_value, y_mark_value, x_base_value, y_base_value;
FT_Error error;
TTO_GPOSHeader* gpos = gpi->gpos;
TTO_MarkBasePos* mbp = &st->markbase;
TTO_MarkArray* ma;
TTO_BaseArray* ba;
......@@ -2626,16 +2643,18 @@
static FT_Error Lookup_MarkLigPos( GPOS_Instance* gpi,
TTO_MarkLigPos* mlp,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length )
FT_UShort context_length,
int nesting_level )
{
FT_UShort i, j, mark_index, lig_index, property, class;
FT_UShort mark_glyph;
FT_Pos x_mark_value, y_mark_value, x_lig_value, y_lig_value;
FT_Error error;
TTO_GPOSHeader* gpos = gpi->gpos;
TTO_MarkLigPos* mlp = &st->marklig;
TTO_MarkArray* ma;
TTO_LigatureArray* la;
......@@ -2965,16 +2984,18 @@
static FT_Error Lookup_MarkMarkPos( GPOS_Instance* gpi,
TTO_MarkMarkPos* mmp,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length )
FT_UShort context_length,
int nesting_level )
{
FT_UShort j, mark1_index, mark2_index, property, class;
FT_Pos x_mark1_value, y_mark1_value,
x_mark2_value, y_mark2_value;
FT_Error error;
TTO_GPOSHeader* gpos = gpi->gpos;
TTO_MarkMarkPos* mmp = &st->markmark;
TTO_MarkArray* ma1;
TTO_Mark2Array* ma2;
......@@ -4055,12 +4076,14 @@
static FT_Error Lookup_ContextPos( GPOS_Instance* gpi,
TTO_ContextPos* cp,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
TTO_ContextPos* cp = &st->context;
switch ( cp->PosFormat )
{
case 1:
......@@ -5543,12 +5566,14 @@
static FT_Error Lookup_ChainContextPos(
GPOS_Instance* gpi,
TTO_ChainContextPos* ccp,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
TTO_ChainContextPos* ccp = &st->chain;
switch ( ccp->PosFormat )
{
case 1:
......@@ -5863,6 +5888,25 @@
}
typedef FT_Error (*Lookup_Func_Type) ( GPOS_Instance* gpi,
TTO_GPOS_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level );
static const Lookup_Func_Type Lookup_Call_Table[] = {
Lookup_DefaultPos,
Lookup_SinglePos, /* GPOS_LOOKUP_SINGLE 1 */
Lookup_PairPos, /* GPOS_LOOKUP_PAIR 2 */
Lookup_CursivePos, /* GPOS_LOOKUP_CURSIVE 3 */
Lookup_MarkBasePos, /* GPOS_LOOKUP_MARKBASE 4 */
Lookup_MarkLigPos, /* GPOS_LOOKUP_MARKLIG 5 */
Lookup_MarkMarkPos, /* GPOS_LOOKUP_MARKMARK 6 */
Lookup_ContextPos, /* GPOS_LOOKUP_CONTEXT 7 */
Lookup_ChainContextPos, /* GPOS_LOOKUP_CHAIN 8 */
Lookup_DefaultPos, /* GPOS_LOOKUP_EXTENSION 9 */
};
/* Do an individual subtable lookup. Returns TT_Err_Ok if positioning
has been done, or TTO_Err_Not_Covered if not. */
......@@ -5876,6 +5920,8 @@
FT_UShort i, flags, lookup_count;
TTO_GPOSHeader* gpos = gpi->gpos;
TTO_Lookup* lo;
int lt;
Lookup_Func_Type Lookup_Func;
nesting_level++;
......@@ -5889,69 +5935,18 @@
lo = &gpos->LookupList.Lookup[lookup_index];
flags = lo->LookupFlag;
lt = lo->LookupType;
if (lt >= sizeof Lookup_Call_Table / sizeof Lookup_Call_Table[0])
lt = 0;
Lookup_Func = Lookup_Call_Table[lt];
for ( i = 0; i < lo->SubTableCount; i++ )
{
switch ( lo->LookupType )
{
case GPOS_LOOKUP_SINGLE:
error = Lookup_SinglePos( gpi,
&lo->SubTable[i].st.gpos.single,
buffer,
flags, context_length );
break;
case GPOS_LOOKUP_PAIR:
error = Lookup_PairPos( gpi,
&lo->SubTable[i].st.gpos.pair,
buffer,
flags, context_length );
break;
case GPOS_LOOKUP_CURSIVE:
error = Lookup_CursivePos( gpi,
&lo->SubTable[i].st.gpos.cursive,
buffer,
flags, context_length );
break;
case GPOS_LOOKUP_MARKBASE:
error = Lookup_MarkBasePos( gpi,
&lo->SubTable[i].st.gpos.markbase,
buffer,
flags, context_length );
break;
case GPOS_LOOKUP_MARKLIG:
error = Lookup_MarkLigPos( gpi,
&lo->SubTable[i].st.gpos.marklig,
buffer,
flags, context_length );
break;
case GPOS_LOOKUP_MARKMARK:
error = Lookup_MarkMarkPos( gpi,
&lo->SubTable[i].st.gpos.markmark,
buffer,
flags, context_length );
break;
case GPOS_LOOKUP_CONTEXT:
error = Lookup_ContextPos( gpi,
&lo->SubTable[i].st.gpos.context,
buffer,
flags, context_length,
nesting_level );
break;
case GPOS_LOOKUP_CHAIN:
error = Lookup_ChainContextPos( gpi,
&lo->SubTable[i].st.gpos.chain,
buffer,
flags, context_length,
nesting_level );
break;
}
error = Lookup_Func ( gpi,
&lo->SubTable[i].st.gpos,
buffer,
flags, context_length,
nesting_level );
/* Check whether we have a successful positioning or an error other
than TTO_Err_Not_Covered */
......
......@@ -208,6 +208,16 @@
* SubTable related functions
*****************************/
static FT_Error Lookup_DefaultSubst( TTO_GSUBHeader* gsub,
TTO_GSUB_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
return TTO_Err_Not_Covered;
}
/* LookupType 1 */
......@@ -311,14 +321,17 @@
}
static FT_Error Lookup_SingleSubst( TTO_SingleSubst* ss,
static FT_Error Lookup_SingleSubst( TTO_GSUBHeader* gsub,
TTO_GSUB_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
TTO_GDEFHeader* gdef )
int nesting_level )
{
FT_UShort index, value, property;
FT_Error error;
TTO_SingleSubst* ss = &st->single;
TTO_GDEFHeader* gdef = gsub->gdef;
if ( context_length != 0xFFFF && context_length < 1 )
......@@ -514,15 +527,18 @@
}
static FT_Error Lookup_MultipleSubst( TTO_MultipleSubst* ms,
static FT_Error Lookup_MultipleSubst( TTO_GSUBHeader* gsub,
TTO_GSUB_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
TTO_GDEFHeader* gdef )
int nesting_level )
{
FT_Error error;
FT_UShort index, property, n, count;
FT_UShort*s;
TTO_MultipleSubst* ms = &st->multiple;
TTO_GDEFHeader* gdef = gsub->gdef;
if ( context_length != 0xFFFF && context_length < 1 )
......@@ -711,14 +727,17 @@
static FT_Error Lookup_AlternateSubst( TTO_GSUBHeader* gsub,
TTO_AlternateSubst* as,
TTO_GSUB_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
TTO_GDEFHeader* gdef )
int nesting_level )
{
FT_Error error;
FT_UShort index, alt_index, property;
TTO_AlternateSubst* as = &st->alternate;
TTO_GDEFHeader* gdef = gsub->gdef;
TTO_AlternateSet aset;
......@@ -990,16 +1009,19 @@
}
static FT_Error Lookup_LigatureSubst( TTO_LigatureSubst* ls,
static FT_Error Lookup_LigatureSubst( TTO_GSUBHeader* gsub,
TTO_GSUB_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
TTO_GDEFHeader* gdef )
int nesting_level )
{
FT_UShort index, property;
FT_Error error;
FT_UShort numlig, i, j, is_mark, first_is_mark = FALSE;
FT_UShort* c;
TTO_LigatureSubst* ls = &st->ligature;
TTO_GDEFHeader* gdef = gsub->gdef;
TTO_Ligature* lig;
......@@ -2112,12 +2134,14 @@
static FT_Error Lookup_ContextSubst( TTO_GSUBHeader* gsub,
TTO_ContextSubst* cs,
TTO_GSUB_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
TTO_ContextSubst* cs = &st->context;
switch ( cs->SubstFormat )
{
case 1:
......@@ -3604,12 +3628,14 @@
static FT_Error Lookup_ChainContextSubst(
TTO_GSUBHeader* gsub,
TTO_ChainContextSubst* ccs,
TTO_GSUB_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
TTO_ChainContextSubst* ccs = &st->chain;
switch ( ccs->SubstFormat )
{
case 1:
......@@ -3930,6 +3956,23 @@
}
typedef FT_Error (*Lookup_Func_Type) ( TTO_GSUBHeader* gsub,
TTO_GSUB_SubTable* st,
OTL_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level );
static const Lookup_Func_Type Lookup_Call_Table[] = {
Lookup_DefaultSubst,
Lookup_SingleSubst, /* GSUB_LOOKUP_SINGLE 1 */
Lookup_MultipleSubst, /* GSUB_LOOKUP_MULTIPLE 2 */
Lookup_AlternateSubst, /* GSUB_LOOKUP_ALTERNATE 3 */
Lookup_LigatureSubst, /* GSUB_LOOKUP_LIGATURE 4 */
Lookup_ContextSubst, /* GSUB_LOOKUP_CONTEXT 5 */
Lookup_ChainContextSubst, /* GSUB_LOOKUP_CHAIN 6 */
Lookup_DefaultSubst, /* GSUB_LOOKUP_EXTENSION 7 */
};
/* Do an individual subtable lookup. Returns TT_Err_Ok if substitution
has been done, or TTO_Err_Not_Covered if not. */
......@@ -3942,6 +3985,8 @@
FT_Error error = TTO_Err_Not_Covered;
FT_UShort i, flags, lookup_count;
TTO_Lookup* lo;
int lt;
Lookup_Func_Type Lookup_Func;
nesting_level++;
......@@ -3955,50 +4000,18 @@
lo = &gsub->LookupList.Lookup[lookup_index];
flags = lo->LookupFlag;
lt = lo->LookupType;
if (lt >= sizeof Lookup_Call_Table / sizeof Lookup_Call_Table[0])
lt = 0;
Lookup_Func = Lookup_Call_Table[lt];
for ( i = 0; i < lo->SubTableCount; i++ )
{
switch ( lo->LookupType )
{
case GSUB_LOOKUP_SINGLE:
error = Lookup_SingleSubst( &lo->SubTable[i].st.gsub.single,
buffer,
flags, context_length, gsub->gdef );
break;
case GSUB_LOOKUP_MULTIPLE:
error = Lookup_MultipleSubst( &lo->SubTable[i].st.gsub.multiple,
buffer,
flags, context_length, gsub->gdef );
break;
case GSUB_LOOKUP_ALTERNATE:
error = Lookup_AlternateSubst( gsub,
&lo->SubTable[i].st.gsub.alternate,
buffer,
flags, context_length, gsub->gdef );
break;
case GSUB_LOOKUP_LIGATURE:
error = Lookup_LigatureSubst( &lo->SubTable[i].st.gsub.ligature,
buffer,
flags, context_length, gsub->gdef );
break;
case GSUB_LOOKUP_CONTEXT:
error = Lookup_ContextSubst( gsub, &lo->SubTable[i].st.gsub.context,
buffer,
flags, context_length, nesting_level );
break;
case GSUB_LOOKUP_CHAIN:
error = Lookup_ChainContextSubst( gsub,
&lo->SubTable[i].st.gsub.chain,
buffer,
flags, context_length,
nesting_level );
break;
}
error = Lookup_Func ( gsub,
&lo->SubTable[i].st.gsub,
buffer,
flags, context_length,
nesting_level );
/* Check whether we have a successful substitution or an error other
than TTO_Err_Not_Covered */
......
......@@ -79,8 +79,7 @@ void
pango_ot_buffer_set_rtl (PangoOTBuffer *buffer,
gboolean rtl)
{
rtl = rtl != FALSE;
buffer->rtl = rtl;
buffer->rtl = rtl != FALSE;
}
/**
......
......@@ -144,40 +144,27 @@ pango_ot_ruleset_substitute (PangoOTRuleset *ruleset,
TTO_GSUB gsub = NULL;
gboolean need_gsub = FALSE;
g_return_if_fail (PANGO_OT_IS_RULESET (ruleset));
for (i = 0; i < ruleset->rules->len; i++)
{
PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
if (rule->table_type == PANGO_OT_TABLE_GSUB)
need_gsub = TRUE;
}
if (need_gsub)
{
gsub = pango_ot_info_get_gsub (ruleset->info);
if (gsub)
TT_GSUB_Clear_Features (gsub);
}
for (i = 0; i < ruleset->rules->len; i++)
{
PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
if (rule->table_type != PANGO_OT_TABLE_GSUB)
continue;
if (rule->table_type == PANGO_OT_TABLE_GSUB)
if (!gsub)
{
gsub = pango_ot_info_get_gsub (ruleset->info);
if (gsub)
TT_GSUB_Add_Feature (gsub, rule->feature_index, rule->property_bit);
TT_GSUB_Clear_Features (gsub);
else
return;
}
}
if (!gsub)
return;
TT_GSUB_Add_Feature (gsub, rule->feature_index, rule->property_bit);
}
TT_GSUB_Apply_String (gsub, buffer->buffer);
}
......@@ -190,43 +177,31 @@ pango_ot_ruleset_position (PangoOTRuleset *ruleset,
TTO_GPOS gpos = NULL;
gboolean need_gpos = FALSE;
g_return_if_fail (PANGO_OT_IS_RULESET (ruleset));
for (i = 0; i < ruleset->rules->len; i++)
{
PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
if (rule->table_type == PANGO_OT_TABLE_GPOS)
need_gpos = TRUE;
}
if (rule->table_type != PANGO_OT_TABLE_GPOS)
continue;
if (need_gpos)
gpos = pango_ot_info_get_gpos (ruleset->info);
if (!gpos)
{
gpos = pango_ot_info_get_gpos (ruleset->info);
if (gpos)
{
TT_GPOS_Clear_Features (gpos);
if (gpos)
TT_GPOS_Clear_Features (gpos);
else
return;
}
for (i = 0; i < ruleset->rules->len; i++)
{
PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
if (rule->table_type == PANGO_OT_TABLE_GPOS)
TT_GPOS_Add_Feature (gpos, rule->feature_index, rule->property_bit);
}
TT_GPOS_Add_Feature (gpos, rule->feature_index, rule->property_bit);
}
/* Apply GPOS rules */
if (gpos)
{
if (TT_GPOS_Apply_String (ruleset->info->face, gpos, 0, buffer->buffer,
FALSE /* enable device-dependant values */,
buffer->rtl) == FT_Err_Ok)
{
buffer->applied_gpos = TRUE;
}
}
if (TT_GPOS_Apply_String (ruleset->info->face, gpos, 0, buffer->buffer,
FALSE /* enable device-dependant values */,
buffer->rtl) == FT_Err_Ok)
buffer->applied_gpos = TRUE;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册