summaryrefslogtreecommitdiff
path: root/src/gxvalid/gxvjust.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gxvalid/gxvjust.c')
-rw-r--r--src/gxvalid/gxvjust.c200
1 files changed, 121 insertions, 79 deletions
diff --git a/src/gxvalid/gxvjust.c b/src/gxvalid/gxvjust.c
index 97ab17d3c..a841b406f 100644
--- a/src/gxvalid/gxvjust.c
+++ b/src/gxvalid/gxvjust.c
@@ -16,20 +16,20 @@
/***************************************************************************/
/***************************************************************************/
+/* */
/* gxvalid is derived from both gxlayout module and otvalid module. */
-/* Development of gxlayout was support of Information-technology Promotion */
-/* Agency(IPA), Japan. */
+/* Development of gxlayout is supported by the Information-technology */
+/* Promotion Agency(IPA), Japan. */
+/* */
/***************************************************************************/
+
#include "gxvalid.h"
#include "gxvcommn.h"
#include FT_SFNT_NAMES_H
-
-
-
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -39,18 +39,19 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_gxvjust
- /*
- * refered just table format specification:
- * http://developer.apple.com/fonts/TTRefMan/RM06/Chap6just.html
- * last update is 2000.
- * ----------------------------------------------
- * [JUST HEADER]: GXV_JUST_HEADER_SIZE
- * version (fixed: 32bit) = 0x00010000
- * format (uint16: 16bit) = 0 is only defined (2000)
- * horizOffset (uint16: 16bit)
- * vertOffset (uint16: 16bit)
- * ----------------------------------------------
- */
+ /*
+ * referred `just' table format specification:
+ * http://developer.apple.com/fonts/TTRefMan/RM06/Chap6just.html
+ * last updated 2000.
+ * ----------------------------------------------
+ * [JUST HEADER]: GXV_JUST_HEADER_SIZE
+ * version (fixed: 32bit) = 0x00010000
+ * format (uint16: 16bit) = 0 is only defined (2000)
+ * horizOffset (uint16: 16bit)
+ * vertOffset (uint16: 16bit)
+ * ----------------------------------------------
+ */
+
typedef struct GXV_just_DataRec_
{
FT_UShort wdc_offset_max;
@@ -60,8 +61,10 @@
} GXV_just_DataRec, *GXV_just_Data;
+
#define GXV_JUST_DATA( a ) GXV_TABLE_DATA( just, a )
+
static void
gxv_just_wdp_entry_validate( FT_Bytes table,
FT_Bytes limit,
@@ -86,9 +89,9 @@
growFlags = FT_NEXT_USHORT( p );
shrinkFlags = FT_NEXT_USHORT( p );
- /* TODO: decode flags for human readabilty */
+ /* TODO: decode flags for human readability */
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
}
@@ -110,30 +113,33 @@
p += valid->subtable_length;
}
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
}
+
static void
gxv_just_widthDeltaClusters_validate( FT_Bytes table,
FT_Bytes limit,
GXV_Validator valid )
{
- FT_Bytes p = table ;
- FT_Bytes wdc_end = table + GXV_JUST_DATA( wdc_offset_max );
- FT_UInt i;
+ FT_Bytes p = table ;
+ FT_Bytes wdc_end = table + GXV_JUST_DATA( wdc_offset_max );
+ FT_UInt i;
GXV_NAME_ENTER( "just justDeltaClusters" );
if ( limit <= wdc_end )
FT_INVALID_OFFSET;
+
for ( i = 0; p <= wdc_end; i++ )
{
gxv_just_wdc_entry_validate( p, limit, valid );
p += valid->subtable_length;
}
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
+
GXV_EXIT;
}
@@ -143,12 +149,15 @@
FT_Bytes limit,
GXV_Validator valid )
{
- FT_Bytes p = table;
- FT_Fixed lowerLimit;
- FT_Fixed upperLimit;
- FT_UShort order;
- FT_UShort decomposedCount;
- FT_UInt i;
+ FT_Bytes p = table;
+
+ FT_Fixed lowerLimit;
+ FT_Fixed upperLimit;
+
+ FT_UShort order;
+ FT_UShort decomposedCount;
+
+ FT_UInt i;
GXV_LIMIT_CHECK( 4 + 4 + 2 + 2 );
@@ -166,7 +175,7 @@
glyphs = FT_NEXT_USHORT( p );
}
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
}
@@ -175,14 +184,14 @@
FT_Bytes limit,
GXV_Validator valid )
{
- FT_Bytes p = table;
- FT_UShort addGlyph;
+ FT_Bytes p = table;
+ FT_UShort addGlyph;
GXV_LIMIT_CHECK( 2 );
addGlyph = FT_NEXT_USHORT( p );
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
}
@@ -202,9 +211,10 @@
addGlyph = FT_NEXT_USHORT( p );
substGlyph = FT_NEXT_USHORT( p );
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
}
+
static void
gxv_just_actSubrecord_type4_validate( FT_Bytes table,
FT_Bytes limit,
@@ -223,9 +233,10 @@
noStretchValue = FT_NEXT_ULONG( p );
maximumLimit = FT_NEXT_ULONG( p );
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
}
+
static void
gxv_just_actSubrecord_type5_validate( FT_Bytes table,
FT_Bytes limit,
@@ -240,20 +251,20 @@
flags = FT_NEXT_USHORT( p );
glyph = FT_NEXT_USHORT( p );
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
}
/* parse single actSubrecord */
static void
- gxv_just_actSubrecord_validate( FT_Bytes table,
- FT_Bytes limit,
- GXV_Validator valid )
+ gxv_just_actSubrecord_validate( FT_Bytes table,
+ FT_Bytes limit,
+ GXV_Validator valid )
{
- FT_Bytes p = table;
- FT_UShort actionClass;
- FT_UShort actionType;
- FT_ULong actionLength;
+ FT_Bytes p = table;
+ FT_UShort actionClass;
+ FT_UShort actionType;
+ FT_ULong actionLength;
GXV_NAME_ENTER( "just actSubrecord" );
@@ -270,7 +281,7 @@
else if ( actionType == 2 )
gxv_just_actSubrecord_type2_validate( p, limit, valid );
else if ( actionType == 3 )
- ; /* Stretch glyph action: no actionData */
+ ; /* Stretch glyph action: no actionData */
else if ( actionType == 4 )
gxv_just_actSubrecord_type4_validate( p, limit, valid );
else if ( actionType == 5 )
@@ -279,6 +290,7 @@
FT_INVALID_DATA;
valid->subtable_length = actionLength;
+
GXV_EXIT;
}
@@ -303,7 +315,8 @@
p += valid->subtable_length;
}
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
+
GXV_EXIT;
}
@@ -313,6 +326,8 @@
GXV_LookupValueDesc value,
GXV_Validator valid )
{
+ FT_UNUSED( glyph );
+
if ( value.u > GXV_JUST_DATA( pc_offset_max ) )
GXV_JUST_DATA( pc_offset_max ) = value.u;
if ( value.u < GXV_JUST_DATA( pc_offset_max ) )
@@ -327,14 +342,18 @@
{
FT_Bytes p = table;
+
GXV_NAME_ENTER( "just pcLookupTable" );
GXV_JUST_DATA( pc_offset_max ) = 0x0000;
- GXV_JUST_DATA( pc_offset_min ) = 0xFFFF;
+ GXV_JUST_DATA( pc_offset_min ) = 0xFFFFU;
valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
valid->lookupval_func = gxv_just_pcTable_LookupValue_entry_validate;
+
gxv_LookupTable_validate( p, limit, valid );
+
/* subtable_length is set by gxv_LookupTable_validate() */
+
GXV_EXIT;
}
@@ -344,39 +363,49 @@
FT_Bytes limit,
GXV_Validator valid )
{
- FT_Bytes p = table;
+ FT_Bytes p = table;
GXV_NAME_ENTER( "just postcompTable" );
gxv_just_pcLookupTable_validate( p, limit, valid );
p += valid->subtable_length;
+
gxv_just_pcActionRecord_validate( p, limit, valid );
p += valid->subtable_length;
- valid->subtable_length = ( p - table );
+ valid->subtable_length = p - table;
+
GXV_EXIT;
}
static void
- gxv_just_classTable_entry_validate( FT_Byte state,
- FT_UShort flags,
- GXV_StateTable_GlyphOffsetDesc glyphOffset,
- FT_Bytes table,
- FT_Bytes limit,
- GXV_Validator valid )
+ gxv_just_classTable_entry_validate(
+ FT_Byte state,
+ FT_UShort flags,
+ GXV_StateTable_GlyphOffsetDesc glyphOffset,
+ FT_Bytes table,
+ FT_Bytes limit,
+ GXV_Validator valid )
{
FT_UShort setMark;
FT_UShort dontAdvance;
FT_UShort markClass;
FT_UShort currentClass;
+ FT_UNUSED( state );
+ FT_UNUSED( glyphOffset );
+ FT_UNUSED( table );
+ FT_UNUSED( limit );
+ FT_UNUSED( valid );
+
+
+ setMark = ( 0x8000U & flags ) / 0x8000U;
+ dontAdvance = ( 0x4000 & flags ) / 0x4000;
+ markClass = ( 0x3F80 & flags ) / 0x0080;
+ currentClass = 0x007F & flags ;
- setMark = ( 0x8000 & flags ) / 0x8000;
- dontAdvance = ( 0x4000 & flags ) / 0x4000;
- markClass = ( 0x3F80 & flags ) / 0x0080;
- currentClass = 0x007F & flags ;
/* TODO: validate markClass & currentClass */
}
@@ -399,19 +428,22 @@
coverage = FT_NEXT_USHORT( p );
subFeatureFlags = FT_NEXT_ULONG( p );
- GXV_TRACE(( " justClassTable: coverage = 0x%04x (%s)", coverage,
- (0x4000 & coverage) == 0 ? "ascending" : "descending"
- ));
+ GXV_TRACE(( " justClassTable: coverage = 0x%04x (%s)",
+ coverage,
+ ( 0x4000 & coverage ) == 0 ? "ascending" : "descending" ));
valid->statetable.optdata = NULL;
valid->statetable.optdata_load_func = NULL;
valid->statetable.subtable_setup_func = NULL;
valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
- valid->statetable.entry_validate_func = gxv_just_classTable_entry_validate;
+ valid->statetable.entry_validate_func =
+ gxv_just_classTable_entry_validate;
+
gxv_StateTable_validate( p, table + length, valid );
+
/* subtable_length is set by gxv_LookupTable_validate() */
- GXV_EXIT;
+ GXV_EXIT;
}
@@ -420,6 +452,8 @@
GXV_LookupValueDesc value,
GXV_Validator valid )
{
+ FT_UNUSED( glyph );
+
if ( value.u > GXV_JUST_DATA( wdc_offset_max ) )
GXV_JUST_DATA( wdc_offset_max ) = value.u;
if ( value.u < GXV_JUST_DATA( wdc_offset_min ) )
@@ -432,15 +466,19 @@
FT_Bytes limit,
GXV_Validator valid )
{
- FT_Bytes p = table;
+ FT_Bytes p = table;
GXV_JUST_DATA( wdc_offset_max ) = 0x0000;
- GXV_JUST_DATA( wdc_offset_min ) = 0xFFFF;
+ GXV_JUST_DATA( wdc_offset_min ) = 0xFFFFU;
+
valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
valid->lookupval_func = gxv_just_wdcTable_LookupValue_validate;
+
gxv_LookupTable_validate( p, limit, valid );
+
/* subtable_length is set by gxv_LookupTable_validate() */
+
GXV_EXIT;
}
@@ -449,17 +487,19 @@
* gxv_just_justData_validate() parses and validates horizData, vertData.
*/
static void
- gxv_just_justData_validate ( FT_Bytes table,
- FT_Bytes limit,
- GXV_Validator valid )
+ gxv_just_justData_validate( FT_Bytes table,
+ FT_Bytes limit,
+ GXV_Validator valid )
{
- /* following 3 offsets are measured from the start of just
- * which table points to), not justData
+ /*
+ * following 3 offsets are measured from the start of `just'
+ * (which table points to), not justData
*/
FT_UShort justClassTableOffset;
FT_UShort wdcTableOffset;
FT_UShort pcTableOffset;
FT_Bytes p = table;
+
GXV_ODTECT( 4, odtect );
@@ -475,14 +515,14 @@
GXV_TRACE(( " (wdcTableOffset = 0x%04x)\n", wdcTableOffset ));
GXV_TRACE(( " (pcTableOffset = 0x%04x)\n", pcTableOffset ));
-
gxv_just_justData_lookuptable_validate( p, limit, valid );
- gxv_odtect_add_range( p, valid->subtable_length, "just_LookupTable", odtect );
+ gxv_odtect_add_range( p, valid->subtable_length,
+ "just_LookupTable", odtect );
if ( wdcTableOffset )
{
- gxv_just_widthDeltaClusters_validate( valid->root->base + wdcTableOffset,
- limit, valid );
+ gxv_just_widthDeltaClusters_validate(
+ valid->root->base + wdcTableOffset, limit, valid );
gxv_odtect_add_range( valid->root->base + wdcTableOffset,
valid->subtable_length, "just_wdcTable", odtect );
}
@@ -497,10 +537,11 @@
if ( justClassTableOffset )
{
- gxv_just_justClassTable_validate( valid->root->base + justClassTableOffset,
- limit, valid );
+ gxv_just_justClassTable_validate(
+ valid->root->base + justClassTableOffset, limit, valid );
gxv_odtect_add_range( valid->root->base + justClassTableOffset,
- valid->subtable_length, "just_justClassTable", odtect );
+ valid->subtable_length, "just_justClassTable",
+ odtect );
}
gxv_odtect_validate( odtect, valid );
@@ -537,11 +578,12 @@
valid->table_data = just;
valid->face = face;
- FT_TRACE3(( "validation just table\n" ));
+ FT_TRACE3(( "validating `just' table\n" ));
GXV_INIT;
limit = valid->root->limit;
table_size = limit - table;
+
GXV_LIMIT_CHECK( 4 + 2 + 2 + 2 );
version = FT_NEXT_ULONG( p );
format = FT_NEXT_USHORT( p );