return HB_Err_Ok;
}
+static HB_UInt Calculate_Class2RecordSize(HB_UShort format1, HB_UShort format2)
+{
+ // Return number of 16 bit values in two value records with given formats
+ return (format1 & 0x01) + (format2 & 0x01)
+ + ((format1 & 0x02) >> 1) + ((format2 & 0x02) >> 1)
+ + ((format1 & 0x04) >> 2) + ((format2 & 0x04) >> 2)
+ + ((format1 & 0x08) >> 3) + ((format2 & 0x08) >> 3)
+ + ((format1 & 0x10) >> 4) + ((format2 & 0x10) >> 4)
+ + ((format1 & 0x20) >> 5) + ((format2 & 0x20) >> 5)
+ + ((format1 & 0x40) >> 6) + ((format2 & 0x40) >> 6)
+ + ((format1 & 0x80) >> 7) + ((format2 & 0x80) >> 7);
+}
/*****************************
* SubTable related functions
return HB_Err_Ok;
}
-
/* LookupType 2 */
/* PairSet */
HB_UShort n, m, count;
HB_UInt base_offset;
+#ifdef HB_USE_FLEXIBLE_VALUE_RECORD
+ HB_UInt record_size = 0;
+ HB_Short *vr;
+#else
HB_PairValueRecord* pvr;
-
+#endif
base_offset = FILE_Pos();
FORGET_Frame();
+#ifndef HB_USE_FLEXIBLE_VALUE_RECORD
ps->PairValueRecord = NULL;
if ( ALLOC_ARRAY( ps->PairValueRecord, count, HB_PairValueRecord ) )
if ( format1 )
{
error = Load_ValueRecord( &pvr[n].Value1, format1,
- base_offset, stream );
+ base_offset, stream );
if ( error )
- goto Fail;
+ goto Fail;
}
if ( format2 )
{
error = Load_ValueRecord( &pvr[n].Value2, format2,
- base_offset, stream );
+ base_offset, stream );
if ( error )
{
- if ( format1 )
- Free_ValueRecord( &pvr[n].Value1, format1 );
- goto Fail;
+ if ( format1 )
+ Free_ValueRecord( &pvr[n].Value1, format1 );
+ goto Fail;
}
}
}
+#else
+ ps->ValueRecords = 0;
+
+ // Add one for the SecondGlyph part of each record
+ record_size = Calculate_Class2RecordSize( format1, format2 ) + 1;
+
+ if ( ALLOC_ARRAY( ps->ValueRecords, record_size * count, HB_Short ) )
+ return error;
+
+ vr = ps->ValueRecords;
+
+ for ( n = 0; n < count; n++ )
+ {
+ if ( ACCESS_Frame( 2L ) )
+ goto Fail;
+
+ for ( m = 0; m < record_size; m++ )
+ *(vr++) = GET_Short();
+
+ FORGET_Frame();
+ }
+#endif
+
return HB_Err_Ok;
Fail:
+#ifndef HB_USE_FLEXIBLE_VALUE_RECORD
for ( m = 0; m < n; m++ )
{
if ( format1 )
}
FREE( pvr );
+#else
+ FREE ( ps->ValueRecords );
+#endif
+
return error;
}
static void Free_PairSet( HB_PairSet* ps,
HB_UShort format1,
- HB_UShort format2 )
+ HB_UShort format2)
{
+#ifndef HB_USE_FLEXIBLE_VALUE_RECORD
HB_UShort n, count;
HB_PairValueRecord* pvr;
-
if ( ps->PairValueRecord )
{
count = ps->PairValueCount;
FREE( pvr );
}
+#else
+ if ( ps->ValueRecords )
+ {
+ FREE( ps->ValueRecords );
+ }
+#endif
}
}
}
-static HB_UInt Calculate_Class2RecordSize(HB_UShort format1, HB_UShort format2)
-{
- // Return number of 16 bit values in two value records with given formats
- return (format1 & 0x01) + (format2 & 0x01)
- + ((format1 & 0x02) >> 1) + ((format2 & 0x02) >> 1)
- + ((format1 & 0x04) >> 2) + ((format2 & 0x04) >> 2)
- + ((format1 & 0x08) >> 3) + ((format2 & 0x08) >> 3)
- + ((format1 & 0x10) >> 4) + ((format2 & 0x10) >> 4)
- + ((format1 & 0x20) >> 5) + ((format2 & 0x20) >> 5)
- + ((format1 & 0x40) >> 6) + ((format2 & 0x40) >> 6)
- + ((format1 & 0x80) >> 7) + ((format2 & 0x80) >> 7);
-}
-
/* PairPosFormat2 */
_HB_OPEN_Free_Coverage( &pp->Coverage );
}
-
static HB_Error Lookup_PairPos1( GPOS_Instance* gpi,
HB_PairPosFormat1* ppf1,
HB_Buffer buffer,
HB_Error error;
HB_UShort numpvr, glyph2;
+#ifndef HB_USE_FLEXIBLE_VALUE_RECORD
HB_PairValueRecord* pvr;
-
+#else
+ HB_Short *vr;
+ HB_UShort second_glyph;
+ HB_UInt record_size1, record_size2;
+#endif
if ( index >= ppf1->PairSetCount )
return ERR(HB_Err_Invalid_SubTable);
if (!ppf1->PairSet[index].PairValueCount)
return HB_Err_Not_Covered;
+ glyph2 = IN_CURGLYPH();
+
+#ifndef HB_USE_FLEXIBLE_VALUE_RECORD
pvr = ppf1->PairSet[index].PairValueRecord;
if ( !pvr )
return ERR(HB_Err_Invalid_SubTable);
- glyph2 = IN_CURGLYPH();
-
for ( numpvr = ppf1->PairSet[index].PairValueCount;
numpvr;
numpvr--, pvr++ )
error = Get_ValueRecord( gpi, &pvr->Value1, format1,
POSITION( first_pos ) );
if ( error )
- return error;
+ return error;
return Get_ValueRecord( gpi, &pvr->Value2, format2,
POSITION( buffer->in_pos ) );
}
}
+#else
+ vr = ppf1->PairSet[index].ValueRecords;
+ if ( !vr )
+ return ERR(HB_Err_Invalid_SubTable);
+
+ record_size1 = Calculate_Class2RecordSize( format1, 0 );
+ record_size2 = Calculate_Class2RecordSize( format2, 0 );
+
+ for ( numpvr = ppf1->PairSet[index].PairValueCount; numpvr; numpvr-- )
+ {
+ second_glyph = *((HB_UShort *)vr);
+ vr++;
+ if ( glyph2 == second_glyph )
+ {
+ error = Get_FlexibleValueRecord( gpi, vr, format1, POSITION( first_pos ) );
+ if ( error )
+ return error;
+ vr += record_size1;
+
+ return Get_FlexibleValueRecord( gpi, vr, format2, POSITION( buffer->in_pos ) );
+ }
+ else
+ {
+ vr += record_size1 + record_size2;
+ }
+ }
+#endif
return HB_Err_Not_Covered;
}