Hash :
46b5c4ac
Author :
Date :
2004-08-17T23:02:06
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 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
/***************************************************************************/
/* */
/* otlbase.c */
/* */
/* OpenType layout support, BASE 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 "otlbase.h"
#include "otlcommn.h"
static void
otl_base_coord_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt format;
OTL_CHECK( 4 );
format = OTL_NEXT_USHORT( p );
p += 2; /* skip coordinate */
switch ( format )
{
case 1:
break;
case 2:
OTL_CHECK( 4 );
break;
case 3:
OTL_CHECK( 2 );
otl_device_table_validate( table + OTL_PEEK_USHORT( p ), valid );
break;
default:
OTL_INVALID_DATA;
}
}
static void
otl_base_tag_list_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 * 4 );
}
static void
otl_base_values_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt num_coord;
OTL_CHECK( 4 );
p += 2; /* skip default index */
num_coord = OTL_NEXT_USHORT( p );
OTL_CHECK( num_coord * 2 );
/* scan base coordinate records */
for ( ; num_coord > 0; num_coord-- )
otl_base_coord_validate( table + OTL_NEXT_USHORT( p ), valid );
}
static void
otl_base_minmax_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt min_coord, max_coord, num_minmax;
OTL_CHECK( 6 );
min_coord = OTL_NEXT_USHORT( p );
max_coord = OTL_NEXT_USHORT( p );
num_minmax = OTL_NEXT_USHORT( p );
if ( min_coord )
otl_base_coord_validate( table + min_coord, valid );
if ( max_coord )
otl_base_coord_validate( table + max_coord, valid );
OTL_CHECK( num_minmax * 8 );
/* scan feature minmax records */
for ( ; num_minmax > 0; num_minmax-- )
{
p += 4; /* skip tag */
min_coord = OTL_NEXT_USHORT( p );
max_coord = OTL_NEXT_USHORT( p );
if ( min_coord )
otl_base_coord_validate( table + min_coord, valid );
if ( max_coord )
otl_base_coord_validate( table + max_coord, valid );
}
}
static void
otl_base_script_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt values, default_minmax, num_langsys;
OTL_CHECK( 6 );
values = OTL_NEXT_USHORT( p );
default_minmax = OTL_NEXT_USHORT( p );
num_langsys = OTL_NEXT_USHORT( p );
if ( values )
otl_base_values_validate( table + values, valid );
if ( default_minmax )
otl_base_minmax_validate( table + default_minmax, valid );
OTL_CHECK( num_langsys * 6 );
/* scan base langsys records */
for ( ; num_langsys > 0; num_langsys-- )
{
p += 4; /* skip tag */
otl_base_minmax_validate( table + OTL_NEXT_USHORT( p ), valid );
}
}
static void
otl_base_script_list_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt num_scripts;
OTL_CHECK( 2 );
num_scripts = OTL_NEXT_USHORT( p );
OTL_CHECK( num_scripts * 6 );
/* scan base script records */
for ( ; num_scripts > 0; num_scripts-- )
{
p += 4; /* skip tag */
otl_base_script_validate( table + OTL_NEXT_USHORT( p ), valid );
}
}
static void
otl_axis_table_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt tags;
OTL_CHECK( 4 );
tags = OTL_NEXT_USHORT( p );
if ( tags )
otl_base_tag_list_validate( table + tags, valid );
otl_base_script_list_validate( table + OTL_NEXT_USHORT( p ), valid );
}
OTL_LOCALDEF( void )
otl_base_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt val;
OTL_CHECK( 6 );
if ( OTL_NEXT_ULONG( p ) != 0x10000UL )
OTL_INVALID_DATA;
/* validate horizontal axis table */
val = OTL_NEXT_USHORT( p );
if ( val )
otl_axis_table_validate( table + val, valid );
/* validate vertical axis table */
val = OTL_NEXT_USHORT( p );
if ( val )
otl_axis_table_validate( table + val, valid );
}
/* END */