Hash :
80ed03e2
Author :
Date :
2004-08-13T06:09:08
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
/***************************************************************************/
/* */
/* otlgdef.c */
/* */
/* OpenType layout support, GDEF table (body). */
/* */
/* Copyright 2002, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "otlgdef.h"
#include "otlcommn.h"
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** ATTACHMENTS LIST *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
otl_attach_point_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt count;
OTL_CHECK( 2 );
count = OTL_NEXT_USHORT( p );
OTL_CHECK( count * 2 );
}
static void
otl_attach_list_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_Bytes coverage;
OTL_UInt num_glyphs;
OTL_CHECK( 4 );
coverage = table + OTL_NEXT_USHORT( p );
num_glyphs = OTL_NEXT_USHORT( p );
otl_coverage_validate( coverage, valid );
if ( num_glyphs != otl_coverage_get_count( coverage ) )
OTL_INVALID_DATA;
OTL_CHECK( num_glyphs * 2 );
/* scan attach point records */
for ( ; num_glyphs > 0; num_glyphs-- )
otl_attach_point_validate( table + OTL_NEXT_USHORT( p ), valid );
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** LIGATURE CARETS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
otl_caret_value_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_Int format;
OTL_CHECK( 4 );
format = OTL_NEXT_USHORT( p );
switch ( format )
{
case 1:
/* skip coordinate, no test */
break;
case 2:
/* skip contour point index, no test */
break;
case 3:
p += 2; /* skip coordinate */
OTL_CHECK( 2 );
otl_device_table_validate( table + OTL_PEEK_USHORT( p ), valid );
break;
default:
OTL_INVALID_DATA;
}
}
static void
otl_ligature_glyph_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt num_carets;
OTL_CHECK( 2 );
num_carets = OTL_NEXT_USHORT( p );
OTL_CHECK( num_carets * 2 );
/* scan caret value records */
for ( ; num_carets > 0; num_carets-- )
otl_caret_value_validate( table + OTL_NEXT_USHORT( p ), valid );
}
static void
otl_ligature_caret_list_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_Bytes coverage;
OTL_UInt num_ligglyphs;
OTL_CHECK( 4 );
coverage = table + OTL_NEXT_USHORT( p );
num_ligglyphs = OTL_NEXT_USHORT( p );
otl_coverage_validate( coverage, valid );
if ( num_ligglyphs != otl_coverage_get_count( coverage ) )
OTL_INVALID_DATA;
OTL_CHECK( num_ligglyphs * 2 );
/* scan ligature glyph records */
for ( ; num_ligglyphs > 0; num_ligglyphs-- )
otl_ligature_glyph_validate( table + OTL_NEXT_USHORT( p ), valid );
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** GDEF TABLE *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
OTL_APIDEF( void )
otl_gdef_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt val;
OTL_CHECK( 12 );
/* check format */
if ( OTL_NEXT_ULONG( p ) != 0x00010000UL )
OTL_INVALID_FORMAT;
/* validate glyph class definition table */
val = OTL_NEXT_USHORT( p );
if ( val )
otl_class_definition_validate( table + val, valid );
/* validate attachment point list */
val = OTL_NEXT_USHORT( p );
if ( val )
otl_attach_list_validate( table + val, valid );
/* validate ligature caret list */
val = OTL_NEXT_USHORT( p );
if ( val )
otl_ligature_caret_list_validate( table + val, valid );
/* validate mark attachment class definition table */
val = OTL_NEXT_USHORT( p );
if ( val )
otl_class_definition_validate( table + val, valid );
}
/* END */