📄 psobjs.c
字号:
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 ) 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 || ALLOC( result, len + 1 ) ) return 0; /* now copy the string */ 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 T1_Load_Field( T1_Parser* parser, const T1_Field* field, void** objects, FT_UInt max_objects, FT_ULong* pflags ) { T1_Token token; FT_Byte* cur; FT_Byte* limit; FT_UInt count; FT_UInt index; FT_Error error; T1_ToToken( parser, &token ); if ( !token.type ) goto Fail; count = 1; index = 0; cur = token.start; limit = token.limit; if ( token.type == t1_token_array ) { /* if this is an array, and we have no blend, an error occurs */ if ( max_objects == 0 ) goto Fail; count = max_objects; index = 1; } for ( ; count > 0; count--, index++ ) { FT_Byte* q = (FT_Byte*)objects[index] + field->offset; FT_Long val; FT_String* string; switch ( field->type ) { case t1_field_bool: val = t1_tobool( &cur, limit ); goto Store_Integer; case t1_field_fixed: val = t1_tofixed( &cur, limit, 3 ); goto Store_Integer; case t1_field_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_string: { FT_Memory memory = parser->memory; FT_UInt len = limit-cur; if ( *(FT_String**)q ) /* with synthetic fonts, it's possible to find a field twice */ break; if ( ALLOC( string, len + 1 ) ) goto Exit; MEM_Copy( string, cur, len ); string[len] = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -