Make Check_Property() take a OTL_GlyphItem, add a gproperties field to

Mon Jul 26 14:49:22 2004  Owen Taylor  <otaylor@redhat.com>

        * ftxgdef.[ch] otlbuffer.[ch]: Make Check_Property() take a
        OTL_GlyphItem, add a gproperties field to OTLGlyphItem,
        and use that to cache the properties for a glyph.

        * ftxgsub.c ftxgdef.c: Adapt to Check_Property() changes.

        * otlbuffer.[ch] ftxgsub.c: Add otl_buffer_copy_output_glyph()
        to use when we are copying an unmodified glyph from input
        to output that preserves the cached properties.
This commit is contained in:
Owen Taylor 2004-07-26 18:59:02 +00:00 committed by Owen Taylor
parent 81b62af423
commit 78282cda00
6 changed files with 91 additions and 60 deletions

View File

@ -1161,21 +1161,25 @@
FT_Error Check_Property( TTO_GDEFHeader* gdef,
FT_UShort index,
OTL_GlyphItem gitem,
FT_UShort flags,
FT_UShort* property )
{
FT_Error error;
if ( gdef )
{
FT_UShort basic_glyph_class;
FT_UShort desired_attachment_class;
error = TT_GDEF_Get_Glyph_Property( gdef, index, property );
if ( gitem->gproperties == OTL_GLYPH_PROPERTIES_UNKNOWN )
{
error = TT_GDEF_Get_Glyph_Property( gdef, gitem->gindex, &gitem->gproperties );
if ( error )
return error;
}
*property = gitem->gproperties;
/* If the glyph was found in the MarkAttachmentClass table,
* then that class value is the high byte of the result,

View File

@ -59,7 +59,9 @@
#define IN_GLYPH( pos ) (buffer->in_string[(pos)].gindex)
#define IN_ITEM( pos ) (&buffer->in_string[(pos)])
#define IN_CURGLYPH( pos ) (buffer->in_string[(pos) + buffer->in_pos].gindex)
#define IN_CURITEM( pos ) (&buffer->in_string[(pos) + buffer->in_pos])
#define IN_PROPERTIES( pos ) (buffer->in_string[(pos)].properties)
#define IN_LIGID( pos ) (buffer->in_string[(pos)].ligID)
#define IN_COMPONENT( pos ) (buffer->in_string[(pos)].component)
@ -1045,7 +1047,7 @@
if ( context_length != 0xFFFF && context_length < 1 )
return TTO_Err_Not_Covered;
if ( CHECK_Property( gpos->gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gpos->gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &sp->Coverage, IN_CURGLYPH( 0 ), &index );
@ -1607,7 +1609,7 @@
if ( context_length != 0xFFFF && context_length < 2 )
return TTO_Err_Not_Covered;
if ( CHECK_Property( gpos->gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gpos->gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &pp->Coverage, IN_CURGLYPH( 0 ), &index );
@ -1619,7 +1621,7 @@
first_pos = buffer->in_pos;
(buffer->in_pos)++;
while ( CHECK_Property( gpos->gdef, IN_CURGLYPH( 0 ),
while ( CHECK_Property( gpos->gdef, IN_CURITEM( 0 ),
flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
@ -1820,7 +1822,7 @@
/* Glyphs not having the right GDEF properties will be ignored, i.e.,
gpi->last won't be reset (contrary to user defined properties). */
if ( CHECK_Property( gpos->gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gpos->gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
/* We don't handle mark glyphs here. According to Andrei, this isn't
@ -2247,7 +2249,7 @@
if ( flags & IGNORE_BASE_GLYPHS )
return TTO_Err_Not_Covered;
if ( CHECK_Property( gpos->gdef, IN_CURGLYPH( 0 ),
if ( CHECK_Property( gpos->gdef, IN_CURITEM( 0 ),
flags, &property ) )
return error;
@ -2659,7 +2661,7 @@
mark_glyph = IN_CURGLYPH( 0 );
if ( CHECK_Property( gpos->gdef, mark_glyph, flags, &property ) )
if ( CHECK_Property( gpos->gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &mlp->MarkCoverage, mark_glyph, &mark_index );
@ -2994,7 +2996,7 @@
if ( flags & IGNORE_MARKS )
return TTO_Err_Not_Covered;
if ( CHECK_Property( gpos->gdef, IN_CURGLYPH( 0 ),
if ( CHECK_Property( gpos->gdef, IN_CURITEM( 0 ),
flags, &property ) )
return error;
@ -3850,7 +3852,7 @@
gdef = gpos->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &cpf1->Coverage, IN_CURGLYPH( 0 ), &index );
@ -3870,7 +3872,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < pr[k].GlyphCount; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -3920,7 +3922,7 @@
gdef = gpos->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
/* Note: The coverage table in format 2 doesn't give an index into
@ -3963,7 +3965,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < pr->GlyphCount; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
goto End;
@ -4022,7 +4024,7 @@
gdef = gpos->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
if ( context_length != 0xFFFF && context_length < cpf3->GlyphCount )
@ -4035,7 +4037,7 @@
for ( i = 1, j = 1; i < cpf3->GlyphCount; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -5122,7 +5124,7 @@
gdef = gpos->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &ccpf1->Coverage, IN_CURGLYPH( 0 ), &index );
@ -5154,7 +5156,7 @@
for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -5183,7 +5185,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -5202,7 +5204,7 @@
for ( i = 0; i < lgc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -5263,7 +5265,7 @@
gdef = gpos->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
/* Note: The coverage table in format 2 doesn't give an index into
@ -5323,7 +5325,7 @@
for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
goto End1;
@ -5355,7 +5357,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
goto End1;
@ -5385,7 +5387,7 @@
for ( i = 0; i < lgc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
goto End1;
@ -5454,7 +5456,7 @@
gdef = gpos->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
bgc = ccpf3->BacktrackGlyphCount;
@ -5478,7 +5480,7 @@
for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -5499,7 +5501,7 @@
for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ )
{
/* We already called CHECK_Property for IN_GLYPH ( buffer->in_pos ) */
while ( j > buffer->in_pos && CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -5521,7 +5523,7 @@
for ( i = 0; i < lgc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;

View File

@ -39,7 +39,9 @@
#define IN_GLYPH( pos ) buffer->in_string[(pos)].gindex
#define IN_ITEM( pos ) (&buffer->in_string[(pos)])
#define IN_CURGLYPH( pos ) buffer->in_string[(pos) + buffer->in_pos].gindex
#define IN_CURITEM( pos ) (&buffer->in_string[(pos) + buffer->in_pos])
#define IN_PROPERTIES( pos ) buffer->in_string[(pos)].properties
#define IN_LIGID( pos ) buffer->in_string[(pos)].ligID
@ -326,7 +328,7 @@
if ( context_length != 0xFFFF && context_length < 1 )
return TTO_Err_Not_Covered;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &ss->Coverage, IN_CURGLYPH( 0 ), &index );
@ -530,7 +532,7 @@
if ( context_length != 0xFFFF && context_length < 1 )
return TTO_Err_Not_Covered;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &ms->Coverage, IN_CURGLYPH( 0 ), &index );
@ -728,7 +730,7 @@
if ( context_length != 0xFFFF && context_length < 1 )
return TTO_Err_Not_Covered;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &as->Coverage, IN_CURGLYPH( 0 ), &index );
@ -1006,7 +1008,7 @@
TTO_Ligature* lig;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
if ( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS )
@ -1037,7 +1039,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < lig->ComponentCount; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -1099,7 +1101,7 @@
for ( i = 0; i < lig->ComponentCount - 1; i++ )
{
while ( CHECK_Property( gdef, IN_CURGLYPH( 0 ),
while ( CHECK_Property( gdef, IN_CURITEM( 0 ),
flags, &property ) )
if ( ADD_Glyph( buffer, IN_CURGLYPH( 0 ),
i, ligID ) )
@ -1907,7 +1909,7 @@
gdef = gsub->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &csf1->Coverage, IN_CURGLYPH( 0 ), &index );
@ -1927,7 +1929,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < sr[k].GlyphCount; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -1976,7 +1978,7 @@
gdef = gsub->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
/* Note: The coverage table in format 2 doesn't give an index into
@ -2019,7 +2021,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < sr->GlyphCount; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
goto End;
@ -2078,7 +2080,7 @@
gdef = gsub->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
if ( context_length != 0xFFFF && context_length < csf3->GlyphCount )
@ -2091,7 +2093,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < csf3->GlyphCount; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -3183,7 +3185,7 @@
gdef = gsub->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
error = Coverage_Index( &ccsf1->Coverage, IN_CURGLYPH( 0 ), &index );
@ -3215,7 +3217,7 @@
for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -3244,7 +3246,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -3263,7 +3265,7 @@
for ( i = 0; i < lgc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -3324,7 +3326,7 @@
gdef = gsub->gdef;
memory = gsub->memory;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
/* Note: The coverage table in format 2 doesn't give an index into
@ -3384,7 +3386,7 @@
for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
goto End1;
@ -3416,7 +3418,7 @@
for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
goto End1;
@ -3446,7 +3448,7 @@
for ( i = 0; i < lgc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
goto End1;
@ -3514,7 +3516,7 @@
gdef = gsub->gdef;
if ( CHECK_Property( gdef, IN_CURGLYPH( 0 ), flags, &property ) )
if ( CHECK_Property( gdef, IN_CURITEM( 0 ), flags, &property ) )
return error;
bgc = ccsf3->BacktrackGlyphCount;
@ -3538,7 +3540,7 @@
for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -3559,7 +3561,7 @@
for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ )
{
/* We already called CHECK_Property for IN_GLYPH( buffer->in_pos ) */
while ( j > buffer->in_pos && CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -3581,7 +3583,7 @@
for ( i = 0; i < lgc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_GLYPH( j ), flags, &property ) )
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
if ( error && error != TTO_Err_Not_Covered )
return error;
@ -4040,7 +4042,7 @@
error = TTO_Err_Not_Covered;
if ( error == TTO_Err_Not_Covered )
if ( ADD_Glyph( buffer, IN_CURGLYPH( 0 ), 0xFFFF, 0xFFFF ) )
if ( otl_buffer_copy_output_glyph ( buffer ) )
return error;
}

View File

@ -145,7 +145,7 @@ extern "C" {
FT_UShort property );
FT_Error Check_Property( TTO_GDEFHeader* gdef,
FT_UShort index,
OTL_GlyphItem item,
FT_UShort flags,
FT_UShort* property );

View File

@ -133,6 +133,7 @@
glyph->cluster = cluster;
glyph->component = 0;
glyph->ligID = 0;
glyph->gproperties = OTL_GLYPH_PROPERTIES_UNKNOWN;
buffer->in_length++;
@ -191,6 +192,7 @@
item->cluster = cluster;
item->component = component;
item->ligID = ligID;
item->gproperties = OTL_GLYPH_PROPERTIES_UNKNOWN;
}
buffer->in_pos += num_in;
@ -213,6 +215,21 @@
&glyph_data, component, ligID );
}
FT_Error
otl_buffer_copy_output_glyph ( OTL_Buffer buffer )
{
FT_Error error;
error = otl_buffer_ensure( buffer, buffer->out_pos + 1 );
if ( error )
return error;
buffer->out_string[buffer->out_pos++] = buffer->out_string[buffer->in_pos++];
buffer->out_length = buffer->out_pos;
return FT_Err_Ok;
}
FT_UShort
otl_buffer_allocate_ligid( OTL_Buffer buffer )
{

View File

@ -18,12 +18,15 @@
G_BEGIN_DECLS
#define OTL_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
typedef struct OTL_GlyphItemRec_ {
FT_UInt gindex;
FT_UInt properties;
FT_UInt cluster;
FT_UShort component;
FT_UShort ligID;
FT_UShort gproperties;
} OTL_GlyphItemRec, *OTL_GlyphItem;
typedef struct OTL_PositionRec_ {
@ -91,6 +94,9 @@ G_BEGIN_DECLS
FT_UShort component,
FT_UShort ligID );
FT_Error
otl_buffer_copy_output_glyph ( OTL_Buffer buffer );
FT_UShort
otl_buffer_allocate_ligid( OTL_Buffer buffer );