📄 psobjs.c
字号:
else if ( radixBase > 10 && (*cur)[0] >= 'A' && (*cur)[0] < radixEndChar1 ) result = result * radixBase + ( (*cur)[0] - 'A' + 10 ); else if ( radixBase > 10 && (*cur)[0] >= 'a' && (*cur)[0] < radixEndChar2 ) result = result * radixBase + ( (*cur)[0] - 'a' + 10 ); else return result; (*cur)++; } return result; } static FT_Long t1_toint( FT_Byte** cursor, FT_Byte* limit ) { FT_Long result = 0; FT_Byte* cur = *cursor; FT_Byte c = '\0', d; for ( ; cur < limit; cur++ ) { c = *cur; d = (FT_Byte)( c - '0' ); if ( d < 10 ) break; if ( c == '-' ) { cur++; break; } } if ( cur < limit ) { do { d = (FT_Byte)( cur[0] - '0' ); if ( d >= 10 ) { if ( cur[0] == '#' ) { cur++; result = T1Radix( result, &cur, limit ); } break; } result = result * 10 + d; cur++; } while ( cur < limit ); if ( c == '-' ) result = -result; } *cursor = cur; return result; } static FT_Long t1_tofixed( FT_Byte** cursor, FT_Byte* limit, FT_Long power_ten ) { FT_Byte* cur = *cursor; FT_Long num, divider, result; FT_Int sign = 0; FT_Byte d; if ( cur >= limit ) return 0; /* first of all, check the sign */ if ( *cur == '-' ) { sign = 1; cur++; } /* then, read the integer part, if any */ if ( *cur != '.' ) result = t1_toint( &cur, limit ) << 16; else result = 0; num = 0; divider = 1; if ( cur >= limit ) goto Exit; /* read decimal part, if any */ if ( *cur == '.' && cur + 1 < limit ) { cur++; for (;;) { d = (FT_Byte)( *cur - '0' ); if ( d >= 10 ) break; if ( divider < 10000000L ) { num = num * 10 + d; divider *= 10; } cur++; if ( cur >= limit ) break; } } /* read exponent, if any */ if ( cur + 1 < limit && ( *cur == 'e' || *cur == 'E' ) ) { cur++; power_ten += t1_toint( &cur, limit ); } Exit: /* raise to power of ten if needed */ while ( power_ten > 0 ) { result = result * 10; num = num * 10; power_ten--; } while ( power_ten < 0 ) { result = result / 10; divider = divider * 10; power_ten++; } if ( num ) result += FT_DivFix( num, divider ); if ( sign ) result = -result; *cursor = cur; return result; } static FT_Int t1_tocoordarray( FT_Byte** cursor, FT_Byte* limit, FT_Int max_coords, FT_Short* coords ) { FT_Byte* cur = *cursor; FT_Int count = 0; FT_Byte c, ender; if ( cur >= limit ) goto Exit; /* check for the beginning of an array; if not, only one number will */ /* be read */ c = *cur; ender = 0; if ( c == '[' ) ender = ']'; if ( c == '{' ) ender = '}'; if ( ender ) cur++; /* now, read the coordinates */ for ( ; cur < limit; ) { /* skip whitespace in front of data */ for (;;) { c = *cur; if ( c != ' ' && c != '\t' ) break; cur++; if ( cur >= limit ) goto Exit; } if ( count >= max_coords || c == ender ) break; coords[count] = (FT_Short)( t1_tofixed( &cur, limit, 0 ) >> 16 ); count++; if ( !ender ) break; } Exit: *cursor = cur; return count; } static FT_Int t1_tofixedarray( FT_Byte** cursor, FT_Byte* limit, FT_Int max_values, FT_Fixed* values, FT_Int power_ten ) { FT_Byte* cur = *cursor; FT_Int count = 0; FT_Byte c, ender; if ( cur >= limit ) goto Exit; /* check for the beginning of an array. If not, only one number will */ /* be read */ c = *cur; ender = 0; if ( c == '[' ) ender = ']'; if ( c == '{' ) ender = '}'; if ( ender ) cur++; /* now, read the values */ for ( ; cur < limit; ) { /* skip whitespace in front of data */ for (;;) { c = *cur; if ( c != ' ' && c != '\t' ) break; cur++; if ( cur >= limit ) goto Exit; } if ( count >= max_values || c == ender ) break; values[count] = t1_tofixed( &cur, limit, power_ten ); count++; if ( !ender ) break; } Exit: *cursor = cur; return count; }#if 0 static FT_String* t1_tostring( FT_Byte** cursor, FT_Byte* limit, FT_Memory memory ) { FT_Byte* cur = *cursor; FT_Int len = 0; FT_Int count; FT_String* result; FT_Error error; /* XXX: some stupid fonts have a `Notice' or `Copyright' string */ /* that simply doesn't begin with an opening parenthesis, even */ /* though they have a closing one! E.g. "amuncial.pfb" */ /* */ /* We must deal with these ill-fated cases there. Note that */ /* these fonts didn't work with the old Type 1 driver as the */ /* notice/copyright was not recognized as a valid string token */ /* and made the old token parser commit errors. */ while ( cur < limit && ( *cur == ' ' || *cur == '\t' ) ) cur++; if ( cur + 1 >= limit ) return 0; if ( *cur == '(' ) cur++; /* skip the opening parenthesis, if there is one */ *cursor = cur; count = 0; /* then, count its length */ for ( ; cur < limit; cur++ ) { if ( *cur == '(' ) count++; else if ( *cur == ')' ) { count--; if ( count < 0 ) break; } } len = cur - *cursor; if ( cur >= limit || FT_ALLOC( result, len + 1 ) ) return 0; /* now copy the string */ FT_MEM_COPY( result, *cursor, len ); result[len] = '\0'; *cursor = cur; return result; }#endif /* 0 */ static int t1_tobool( FT_Byte** cursor, FT_Byte* limit ) { FT_Byte* cur = *cursor; FT_Bool result = 0; /* return 1 if we find `true', 0 otherwise */ if ( cur + 3 < limit && cur[0] == 't' && cur[1] == 'r' && cur[2] == 'u' && cur[3] == 'e' ) { result = 1; cur += 5; } else if ( cur + 4 < limit && cur[0] == 'f' && cur[1] == 'a' && cur[2] == 'l' && cur[3] == 's' && cur[4] == 'e' ) { result = 0; cur += 6; } *cursor = cur; return result; } /* Load a simple field (i.e. non-table) into the current list of objects */ FT_LOCAL_DEF( FT_Error ) PS_Parser_LoadField( PS_Parser parser, const T1_Field field, void** objects, FT_UInt max_objects, FT_ULong* pflags ) { T1_TokenRec token; FT_Byte* cur; FT_Byte* limit; FT_UInt count; FT_UInt idx; FT_Error error; PS_Parser_ToToken( parser, &token ); if ( !token.type ) goto Fail; count = 1; idx = 0; cur = token.start; limit = token.limit; if ( token.type == T1_TOKEN_TYPE_ARRAY ) { /* if this is an array, and we have no blend, an error occurs */ if ( max_objects == 0 ) goto Fail; count = max_objects; idx = 1; } for ( ; count > 0; count--, idx++ ) { FT_Byte* q = (FT_Byte*)objects[idx] + field->offset; FT_Long val; FT_String* string; switch ( field->type ) { case T1_FIELD_TYPE_BOOL: val = t1_tobool( &cur, limit ); goto Store_Integer; case T1_FIELD_TYPE_FIXED: val = t1_tofixed( &cur, limit, 3 ); goto Store_Integer; case T1_FIELD_TYPE_INTEGER: val = t1_toint( &cur, limit ); Store_Integer: switch ( field->size ) { case 1: *(FT_Byte*)q = (FT_Byte)val; break; case 2: *(FT_UShort*)q = (FT_UShort)val; break; case 4: *(FT_UInt32*)q = (FT_UInt32)val; break; default: /* for 64-bit systems */ *(FT_Long*)q = val; } break; case T1_FIELD_TYPE_STRING: { FT_Memory memory = parser->memory; FT_UInt len = (FT_UInt)( limit - cur );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -