20 #include FT_INTERNAL_POSTSCRIPT_AUX_H 21 #include FT_INTERNAL_DEBUG_H 22 #include FT_INTERNAL_CALC_H 39 #define FT_COMPONENT trace_psobjs 129 table->block = old_base;
141 table->capacity = new_size;
175 if ( idx < 0 || idx >=
table->max_elems )
177 FT_ERROR((
"ps_table_add: invalid index\n" ));
178 return FT_THROW( Invalid_Argument );
197 new_size += ( new_size >> 2 ) + 1;
205 if ( in_offset >= 0 )
206 object =
table->block + in_offset;
328 #define IS_OCTAL_DIGIT( c ) ( '0' <= (c) && (c) <= '7' ) 429 if ( cur < limit && *cur != '>
' ) 431 FT_ERROR(( "skip_string: missing closing delimiter `>'\
n" )); 432 err = FT_THROW( Invalid_File_Format ); 442 /* first character must be the opening brace that */ 443 /* starts the procedure */ 445 /* NB: [ and ] need not match: */ 446 /* `/foo {[} def' is a valid PostScript fragment, */ 447 /* even within a Type1 font */ 450 skip_procedure( FT_Byte* *acur, 455 FT_Error error = FT_Err_Ok; 458 FT_ASSERT( **acur == '{' ); 460 for ( cur = *acur; cur < limit && error == FT_Err_Ok; cur++ ) 478 error = skip_literal_string( &cur, limit ); 482 error = skip_string( &cur, limit ); 486 skip_comment( &cur, limit ); 493 error = FT_THROW( Invalid_File_Format ); 501 /***********************************************************************/ 503 /* All exported parsing routines handle leading whitespace and stop at */ 504 /* the first character which isn't part of the just handled token. */ 506 /***********************************************************************/ 510 ps_parser_skip_PS_token( PS_Parser parser ) 512 /* Note: PostScript allows any non-delimiting, non-whitespace */ 513 /* character in a name (PS Ref Manual, 3rd ed, p31). */ 514 /* PostScript delimiters are (, ), <, >, [, ], {, }, /, and %. */ 516 FT_Byte* cur = parser->cursor; 517 FT_Byte* limit = parser->limit; 518 FT_Error error = FT_Err_Ok; 521 skip_spaces( &cur, limit ); /* this also skips comments */ 525 /* self-delimiting, single-character tokens */ 526 if ( *cur == '[' || *cur == ']' ) 532 /* skip balanced expressions (procedures and strings) */ 534 if ( *cur == '{' ) /* {...} */ 536 error = skip_procedure( &cur, limit ); 540 if ( *cur == '(' ) /* (...) */ 542 error = skip_literal_string( &cur, limit ); 546 if ( *cur == '<' ) /* <...> */ 548 if ( cur + 1 < limit && *(cur + 1) == '<' ) /* << */ 554 error = skip_string( &cur, limit ); 562 if ( cur >= limit || *cur != '>' ) /* >> */ 566 error = FT_THROW( Invalid_File_Format ); 577 while ( cur < limit ) 579 /* *cur might be invalid (e.g., ')
' or '}
'), but this */ 580 /* is handled by the test `cur == parser->cursor' below */
588 if ( cur < limit && cur == parser->
cursor )
590 FT_ERROR((
"ps_parser_skip_PS_token:" 591 " current token is `%c' which is self-delimiting\n" 593 " but invalid at this point\n",
673 while ( cur < limit && !parser->
error )
679 else if ( *
cur ==
']' )
763 parser->cursor = old_cursor;
764 parser->limit = old_limit;
828 if ( old_cur ==
cur )
908 if ( old_cur ==
cur )
966 else if ( *
cur ==
')' )
1065 parser->cursor = old_cur;
1066 parser->limit = old_limit;
1076 count = max_objects;
1080 if ( max_objects == 0 )
1118 switch (
field->size )
1129 *(FT_UInt32*)
q = (FT_UInt32)
val;
1167 " expected a name or string\n" 1169 " but found token of type %d instead\n",
1179 FT_TRACE0((
"ps_parser_load_field: overwriting field %s\n",
1207 " expected four integers in bounding box\n" ));
1230 for (
i = 0;
i < 4;
i++ )
1233 temp +
i * max_objects, 0 );
1237 " expected %d integer%s in the %s subarray\n" 1239 " of /FontBBox in the /Blend dictionary\n",
1240 max_objects, max_objects > 1 ?
"s" :
"",
1242 : (
i == 1 ?
"second" 1243 : (
i == 2 ?
"third" 1254 for (
i = 0;
i < max_objects;
i++ )
1277 *pflags |= 1
L <<
field->flag_bit;
1293 #define T1_MAX_TABLE_ELEMENTS 32 1319 if ( num_elements < 0 )
1327 old_cursor =
parser->cursor;
1328 old_limit =
parser->limit;
1338 for ( ; num_elements > 0; num_elements--,
token++ )
1356 *pflags |= 1
L <<
field->flag_bit;
1361 parser->cursor = old_cursor;
1362 parser->limit = old_limit;
1400 FT_ERROR((
"ps_parser_to_bytes: Missing starting delimiter `<'\n" ));
1415 if ( cur < parser->
limit && *
cur !=
'>' )
1417 FT_ERROR((
"ps_parser_to_bytes: Missing closing delimiter `>'\n" ));
1460 max_values,
values, power_ten );
1540 builder->load_points = 1;
1542 builder->face =
face;
1543 builder->glyph = glyph;
1544 builder->memory =
face->memory;
1551 builder->loader = loader;
1556 builder->hints_globals =
size->internal->module_data;
1557 builder->hints_funcs =
NULL;
1560 builder->hints_funcs = glyph->internal->glyph_hints;
1566 builder->left_bearing.x = 0;
1567 builder->left_bearing.y = 0;
1568 builder->advance.x = 0;
1569 builder->advance.y = 0;
1595 glyph->
outline = *builder->base;
1618 if ( builder->load_points )
1660 FT_ERROR((
"t1_builder_add_contour: no outline to add points to\n" ));
1661 return FT_THROW( Invalid_File_Format );
1664 if ( !builder->load_points )
1673 if (
outline->n_contours > 0 )
1742 if ( p1->
x == p2->
x && p1->
y == p2->
y )
1747 if (
outline->n_contours > 0 )
1799 builder->path_begun = 0;
1800 builder->load_points = 1;
1802 builder->face =
face;
1803 builder->glyph = glyph;
1804 builder->memory =
face->root.memory;
1811 builder->loader = loader;
1816 builder->hints_globals =
NULL;
1817 builder->hints_funcs =
NULL;
1819 if ( hinting &&
size )
1826 builder->hints_globals = (
void *)
internal->topfont;
1827 builder->hints_funcs = glyph->root.internal->glyph_hints;
1835 builder->left_bearing.x = 0;
1836 builder->left_bearing.y = 0;
1837 builder->advance.x = 0;
1838 builder->advance.y = 0;
1887 if ( builder->load_points )
1940 if ( !builder->load_points )
1949 if (
outline->n_contours > 0 )
1970 if ( !builder->path_begun )
1972 builder->path_begun = 1;
2007 if ( p1->
x == p2->
x && p1->
y == p2->
y )
2012 if (
outline->n_contours > 0 )
2071 ps_builder->loader = t1builder->
loader;
2072 ps_builder->
base = t1builder->
base;
2073 ps_builder->current = t1builder->
current;
2075 ps_builder->pos_x = &t1builder->
pos_x;
2076 ps_builder->pos_y = &t1builder->
pos_y;
2079 ps_builder->advance = &t1builder->
advance;
2081 ps_builder->bbox = &t1builder->
bbox;
2082 ps_builder->path_begun = 0;
2084 ps_builder->no_recurse = t1builder->
no_recurse;
2095 ps_builder->glyph = cffbuilder->
glyph;
2096 ps_builder->loader = cffbuilder->
loader;
2097 ps_builder->
base = cffbuilder->
base;
2098 ps_builder->current = cffbuilder->
current;
2100 ps_builder->pos_x = &cffbuilder->
pos_x;
2101 ps_builder->pos_y = &cffbuilder->
pos_y;
2104 ps_builder->advance = &cffbuilder->
advance;
2106 ps_builder->bbox = &cffbuilder->
bbox;
2107 ps_builder->path_begun = cffbuilder->
path_begun;
2108 ps_builder->load_points = cffbuilder->
load_points;
2109 ps_builder->no_recurse = cffbuilder->
no_recurse;
2114 ps_builder->is_t1 = is_t1;
2162 if ( builder->load_points )
2171 if ( !builder->is_t1 &&
2179 #ifdef T1_CONFIG_OPTION_OLD_ENGINE 2180 #ifndef CFF_CONFIG_OPTION_OLD_ENGINE 2183 if ( builder->is_t1 &&
2230 FT_ERROR((
"ps_builder_add_contour: no outline to add points to\n" ));
2231 return FT_THROW( Invalid_File_Format );
2234 if ( !builder->load_points )
2243 if (
outline->n_contours > 0 )
2264 if ( !builder->path_begun )
2266 builder->path_begun = 1;
2309 if ( p1->
x == p2->
x && p1->
y == p2->
y )
2314 if (
outline->n_contours > 0 )
2373 ps_decoder->psnames = t1_decoder->
psnames;
2375 ps_decoder->num_glyphs = t1_decoder->
num_glyphs;
2376 ps_decoder->glyph_names = t1_decoder->
glyph_names;
2377 ps_decoder->hint_mode = t1_decoder->
hint_mode;
2378 ps_decoder->blend = t1_decoder->
blend;
2381 ps_decoder->locals = t1_decoder->
subrs;
2382 ps_decoder->locals_len = t1_decoder->
subrs_len;
2383 ps_decoder->locals_hash = t1_decoder->
subrs_hash;
2385 ps_decoder->buildchar = t1_decoder->
buildchar;
2388 ps_decoder->lenIV = t1_decoder->
lenIV;
2399 ps_decoder->cff = cff_decoder->
cff;
2403 ps_decoder->num_globals = cff_decoder->
num_globals;
2404 ps_decoder->globals = cff_decoder->
globals;
2406 ps_decoder->num_locals = cff_decoder->
num_locals;
2407 ps_decoder->locals = cff_decoder->
locals;
2408 ps_decoder->locals_bias = cff_decoder->
locals_bias;
2410 ps_decoder->glyph_width = &cff_decoder->
glyph_width;
2411 ps_decoder->width_only = cff_decoder->
width_only;
2413 ps_decoder->hint_mode = cff_decoder->
hint_mode;
2467 cpriv->
lenIV = priv->lenIV;
2475 if (
face->internal->random_seed != -1 )
2479 subfont->
random = (FT_UInt32)
face->internal->random_seed;
2480 if (
face->internal->random_seed )
2485 (FT_UInt32)
face->internal->random_seed );
2487 }
while (
face->internal->random_seed < 0 );
2490 if ( !subfont->random )
2496 seed = (FT_UInt32)( (
FT_Offset)(
char*)&seed ^
2499 seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
2503 subfont->random = seed;
static void shift_elements(PS_Table table, FT_Byte *old_base)
#define FT_ALLOC(ptr, size)
ps_table_add(PS_Table table, FT_Int idx, void *object, FT_UInt length)
FT_CALLBACK_TABLE_DEF const PS_Builder_FuncsRec ps_builder_funcs
#define CFF_CONFIG_OPTION_OLD_ENGINE
FT_BEGIN_HEADER typedef signed long FT_Pos
#define FT_HINTING_FREETYPE
static FT_Error skip_string(FT_Byte **acur, FT_Byte *limit)
t1_builder_done(T1_Builder builder)
t1_builder_add_point1(T1_Builder builder, FT_Pos x, FT_Pos y)
FT_Size_Internal internal
cff_builder_init(CFF_Builder *builder, TT_Face face, CFF_Size size, CFF_GlyphSlot glyph, FT_Bool hinting)
PS_Conv_ToFixed(FT_Byte **cursor, FT_Byte *limit, FT_Long power_ten)
#define FT_CURVE_TAG_CUBIC
enum T1_FieldType_ T1_FieldType
struct T1_DecoderRec_ * T1_Decoder
GLdouble GLdouble GLdouble r
GLuint GLuint GLsizei count
GLboolean GLenum GLenum GLvoid * values
ps_parser_load_field_table(PS_Parser parser, const T1_Field field, void **objects, FT_UInt max_objects, FT_ULong *pflags)
t1_builder_start_point(T1_Builder builder, FT_Pos x, FT_Pos y)
ps_parser_done(PS_Parser parser)
FT_Service_PsCMaps psnames
PS_Conv_EexecDecode(FT_Byte **cursor, FT_Byte *limit, FT_Byte *buffer, FT_Offset n, FT_UShort *seed)
CFF_Decoder_Free_Glyph_Callback free_glyph_callback
CFF_SubFont current_subfont
cff_check_points(CFF_Builder *builder, FT_Int count)
GLint GLint GLint GLint GLint x
ps_parser_to_fixed(PS_Parser parser, FT_Int power_ten)
#define IS_PS_NEWLINE(ch)
ps_parser_skip_PS_token(PS_Parser parser)
ps_builder_check_points(PS_Builder *builder, FT_Int count)
ps_parser_to_fixed_array(PS_Parser parser, FT_Int max_values, FT_Fixed *values, FT_Int power_ten)
static char memory[1024 *256]
ps_builder_add_point1(PS_Builder *builder, FT_Pos x, FT_Pos y)
FT_BEGIN_HEADER struct PS_DriverRec_ * PS_Driver
ps_parser_to_token(PS_Parser parser, T1_Token token)
#define FT_FACE_DRIVER(x)
FT_BEGIN_HEADER typedef unsigned char FT_Bool
static FT_Error reallocate_t1_table(PS_Table table, FT_Offset new_size)
ps_table_new(PS_Table table, FT_Int count, FT_Memory memory)
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
static const CLSID * objects[]
FT_CALLBACK_TABLE_DEF const T1_Builder_FuncsRec t1_builder_funcs
static unsigned char bytes[4]
ps_builder_init(PS_Builder *ps_builder, void *builder, FT_Bool is_t1)
#define FT_ERROR(varformat)
#define FT_PAD_CEIL(x, n)
FT_Byte num_family_other_blues
ps_builder_close_contour(PS_Builder *builder)
FT_CALLBACK_TABLE_DEF const PS_Parser_FuncsRec ps_parser_funcs
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
GLenum GLuint GLenum GLsizei length
cff_builder_add_contour(CFF_Builder *builder)
cff_builder_add_point1(CFF_Builder *builder, FT_Pos x, FT_Pos y)
struct T1_FieldRec_ * T1_Field
ps_parser_skip_spaces(PS_Parser parser)
ps_table_release(PS_Table table)
ps_parser_load_field(PS_Parser parser, const T1_Field field, void **objects, FT_UInt max_objects, FT_ULong *pflags)
ps_parser_to_int(PS_Parser parser)
#define FT_TRACE0(varformat)
struct @1628::@1629 driver
PS_Conv_ASCIIHexDecode(FT_Byte **cursor, FT_Byte *limit, FT_Byte *buffer, FT_Offset n)
FT_Fixed expansion_factor
#define IS_OCTAL_DIGIT(c)
static void skip_spaces(FT_Byte **acur, FT_Byte *limit)
struct FT_FaceRec_ * FT_Face
static FT_Int ps_tofixedarray(FT_Byte **acur, FT_Byte *limit, FT_Int max_values, FT_Fixed *values, FT_Int power_ten)
GLdouble GLdouble GLdouble GLdouble q
ps_table_done(PS_Table table)
CFF_Decoder_Get_Glyph_Callback get_glyph_callback
ps_builder_start_point(PS_Builder *builder, FT_Pos x, FT_Pos y)
static int ps_tobool(FT_Byte **acur, FT_Byte *limit)
t1_builder_close_contour(T1_Builder builder)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
cff_builder_close_contour(CFF_Builder *builder)
_CRTIMP void __cdecl unexpected(void)
FT_CALLBACK_TABLE_DEF const CFF_Builder_FuncsRec cff_builder_funcs
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
t1_decrypt(FT_Byte *buffer, FT_Offset length, FT_UShort seed)
ps_builder_add_contour(PS_Builder *builder)
struct T1_BuilderRec_ * T1_Builder
static FT_Error skip_literal_string(FT_Byte **acur, FT_Byte *limit)
ps_parser_to_coord_array(PS_Parser parser, FT_Int max_coords, FT_Short *coords)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
ps_parser_to_bytes(PS_Parser parser, FT_Byte *bytes, FT_Offset max_bytes, FT_ULong *pnum_bytes, FT_Bool delimiters)
static FT_Error skip_procedure(FT_Byte **acur, FT_Byte *limit)
#define T1_MAX_TABLE_ELEMENTS
FT_GlyphLoader_Rewind(FT_GlyphLoader loader)
ps_decoder_init(PS_Decoder *ps_decoder, void *decoder, FT_Bool is_t1)
static void skip_comment(FT_Byte **acur, FT_Byte *limit)
t1_make_subfont(FT_Face face, PS_Private priv, CFF_SubFont subfont)
GLint GLint GLint GLint GLint GLint y
ios_base &_STLP_CALL internal(ios_base &__s)
t1_builder_add_point(T1_Builder builder, FT_Pos x, FT_Pos y, FT_Byte flag)
ps_parser_init(PS_Parser parser, FT_Byte *base, FT_Byte *limit, FT_Memory memory)
t1_builder_add_contour(T1_Builder builder)
cff_builder_start_point(CFF_Builder *builder, FT_Pos x, FT_Pos y)
struct CFF_InternalRec_ * CFF_Internal
t1_builder_init(T1_Builder builder, FT_Face face, FT_Size size, FT_GlyphSlot glyph, FT_Bool hinting)
#define FT_MEM_COPY(dest, source, count)
GLuint GLuint GLsizei GLenum type
PS_Conv_ToInt(FT_Byte **cursor, FT_Byte *limit)
#define FT_GLYPHLOADER_CHECK_POINTS(_loader, _points, _contours)
FT_Pos family_other_blues[10]
cff_builder_add_point(CFF_Builder *builder, FT_Pos x, FT_Pos y, FT_Byte flag)
static FT_Int ps_tocoordarray(FT_Byte **acur, FT_Byte *limit, FT_Int max_coords, FT_Short *coords)
ps_parser_to_token_array(PS_Parser parser, T1_Token tokens, FT_UInt max_tokens, FT_Int *pnum_tokens)
t1_builder_check_points(T1_Builder builder, FT_Int count)
GLenum GLuint GLint GLenum face
cff_builder_done(CFF_Builder *builder)
ps_builder_done(PS_Builder *builder)
FT_CALLBACK_TABLE_DEF const PS_Table_FuncsRec ps_table_funcs
ps_builder_add_point(PS_Builder *builder, FT_Pos x, FT_Pos y, FT_Byte flag)