Edit

kc3-lang/freetype/src/psaux/psobjs.h

Branch :

  • Show log

    Commit

  • Author : Werner Lemberg
    Date : 2003-10-07 05:49:41
    Hash : 52f911a1
    Message : Heavy modification of the PS parser to handle comments and strings correctly. This doesn't slow down the loading of PS fonts significantly since charstrings aren't affected. * include/freetype/config/ftstdlib.h (ft_xdigit): Renamed to... (ft_isxdigit): This. Updated all callers. (ft_isdigit): New alias to `isdigit'. * include/freetype/internal/psaux.h (PS_Parser_FuncsRec): Renamed `skip_alpha' to `skip_PS_token'. Add parameter to `to_bytes' and change some argument types. * src/psaux/psauxmod.c (ps_parser_funcs): Updated. * src/psaux/psobjs.c (ft_char_table): New array to map character codes (ASCII and EBCDIC) of digits to numbers. (OP): New auxiliary macro holding either `>=' or `<' depending on the character encoding. (skip_comment): New function. (skip_spaces): Use it. (skip_alpha): Removed. (skip_literal_string, skip_string): New functions. (ps_parser_skip_PS_token): New function. This is a better replacement of... (ps_parser_skip_alpha): Removed. (ps_parser_to_token, ps+parser_to_token_array): Updated. (T1Radix): Rewritten, using `ft_char_table'. (t1_toint): Renamed to... (ps_toint): This. Update all callers. Use `ft_char_table'. (ps_tobytes): Add parameter to handle delimiters and change some argument types. Use `ft_char_table'. (t1_tofixed): Renamed to... (ps_tofixed): This. Update all callers. Use `ft_char_table'. (t1_tocoordarray): Renamed and updated to... (ps_tocoordarray): This. Update all callers. (t1_tofixedarray): Renamed and updated to... (ps_tofixedarray): This. Update all callers. (t1_tobool): Renamed to... (ps_tobool): This. Update all callers. (ps_parser_load_field): Updated. (ps_parser_load_field_table): Use `T1_MAX_TABLE_ELEMENTS' everywhere. (ps_parser_to_int, ps_parser_to_fixed, ps_parser_to_coord_array, ps_parser_to_fixed_array): Skip spaces. Updated. (ps_parser_to_bytes): Add parameter to handle delimiters and change some argument types. Updated. * src/psaux/psobjs.h: Updated. * src/cid/cidload.c (cid_parse_dict): Updated. * src/cid/cidparse.c (cid_parser_new): Check whether the `StartData' token was really found. * src/cid/cidparse.h (cid_parser_skip_alpha): Updated and renamed to... (cid_parser_skip_PS_token): This. * src/type1/t1parse.h (T1_ParserRec): Use `FT_Bool' for boolean fields. (T1_Skip_Alpha): Replaced with... (T1_Skip_PS_Token): This new macro. * src/type1/t1parse.c (hexa_value): Removed. (T1_Get_Private_Dict): Use `ft_isxdigit' and `psaux->ps_parser_funcs_to_bytes' for handling ASCII hexadecimal encoding. After decrypting, replace the four random bytes at the beginning with whitespace. * src/type1/t1load.c (t1_allocate_blend): Use proper error values. (parser_blend_design_positions, parse_blend_design_map, parse_weight_vector): Updated. (is_space): Handle `\f' also. (is_name_char): Removed. (read_binary_data): Updated. (parse_encoding): Use `ft_isdigit'. Updated. (parse_subrs): Updated. (TABLE_EXTEND): New macro. (parse_charstrings): Updated. Provide a workaround for buggy fonts which have more entries in the /CharStrings dictionary then expected; the function now adds some slots and skips entries which still exceed the new limit. (parse_dict): Updated. Terminate on the token `closefile'. * src/type42/t42parse.c (T1_Skip_Alpha): Replaced with... (T1_Skip_PS_Token): This new macro. Updated all callers. (t42_parse_encoding): Use `ft_isdigit'. * src/base/ftmm.c (ft_face_get_mm_service): Return FT_Err_OK if success.

  • src/psaux/psobjs.h
  • /***************************************************************************/
    /*                                                                         */
    /*  psobjs.h                                                               */
    /*                                                                         */
    /*    Auxiliary functions for PostScript fonts (specification).            */
    /*                                                                         */
    /*  Copyright 1996-2001, 2002, 2003 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.                                        */
    /*                                                                         */
    /***************************************************************************/
    
    
    #ifndef __PSOBJS_H__
    #define __PSOBJS_H__
    
    
    #include <ft2build.h>
    #include FT_INTERNAL_POSTSCRIPT_AUX_H
    
    
    FT_BEGIN_HEADER
    
    
      /*************************************************************************/
      /*************************************************************************/
      /*****                                                               *****/
      /*****                             T1_TABLE                          *****/
      /*****                                                               *****/
      /*************************************************************************/
      /*************************************************************************/
    
    
      FT_CALLBACK_TABLE
      const PS_Table_FuncsRec    ps_table_funcs;
    
      FT_CALLBACK_TABLE
      const PS_Parser_FuncsRec   ps_parser_funcs;
    
      FT_CALLBACK_TABLE
      const T1_Builder_FuncsRec  t1_builder_funcs;
    
    
      FT_LOCAL( FT_Error )
      ps_table_new( PS_Table   table,
                    FT_Int     count,
                    FT_Memory  memory );
    
      FT_LOCAL( FT_Error )
      ps_table_add( PS_Table    table,
                    FT_Int      idx,
                    void*       object,
                    FT_PtrDist  length );
    
      FT_LOCAL( void )
      ps_table_done( PS_Table  table );
    
    
      FT_LOCAL( void )
      ps_table_release( PS_Table  table );
    
    
      /*************************************************************************/
      /*************************************************************************/
      /*****                                                               *****/
      /*****                            T1 PARSER                          *****/
      /*****                                                               *****/
      /*************************************************************************/
      /*************************************************************************/
    
    
      FT_LOCAL( void )
      ps_parser_skip_spaces( PS_Parser  parser );
    
      FT_LOCAL( void )
      ps_parser_skip_PS_token( PS_Parser  parser );
    
      FT_LOCAL( void )
      ps_parser_to_token( PS_Parser  parser,
                          T1_Token   token );
    
      FT_LOCAL( void )
      ps_parser_to_token_array( PS_Parser  parser,
                                T1_Token   tokens,
                                FT_UInt    max_tokens,
                                FT_Int*    pnum_tokens );
    
      FT_LOCAL( FT_Error )
      ps_parser_load_field( PS_Parser       parser,
                            const T1_Field  field,
                            void**          objects,
                            FT_UInt         max_objects,
                            FT_ULong*       pflags );
    
      FT_LOCAL( FT_Error )
      ps_parser_load_field_table( PS_Parser       parser,
                                  const T1_Field  field,
                                  void**          objects,
                                  FT_UInt         max_objects,
                                  FT_ULong*       pflags );
    
      FT_LOCAL( FT_Long )
      ps_parser_to_int( PS_Parser  parser );
    
    
      FT_LOCAL( FT_Error )
      ps_parser_to_bytes( PS_Parser  parser,
                          FT_Byte*   bytes,
                          FT_Long    max_bytes,
                          FT_Long*   pnum_bytes,
                          FT_Bool    delimiters );
    
    
      FT_LOCAL( FT_Fixed )
      ps_parser_to_fixed( PS_Parser  parser,
                          FT_Int     power_ten );
    
    
      FT_LOCAL( FT_Int )
      ps_parser_to_coord_array( PS_Parser  parser,
                                FT_Int     max_coords,
                                FT_Short*  coords );
    
      FT_LOCAL( FT_Int )
      ps_parser_to_fixed_array( PS_Parser  parser,
                                FT_Int     max_values,
                                FT_Fixed*  values,
                                FT_Int     power_ten );
    
    
      FT_LOCAL( void )
      ps_parser_init( PS_Parser  parser,
                      FT_Byte*   base,
                      FT_Byte*   limit,
                      FT_Memory  memory );
    
      FT_LOCAL( void )
      ps_parser_done( PS_Parser  parser );
    
    
      /*************************************************************************/
      /*************************************************************************/
      /*****                                                               *****/
      /*****                            T1 BUILDER                         *****/
      /*****                                                               *****/
      /*************************************************************************/
      /*************************************************************************/
    
      FT_LOCAL( void )
      t1_builder_init( T1_Builder    builder,
                       FT_Face       face,
                       FT_Size       size,
                       FT_GlyphSlot  glyph,
                       FT_Bool       hinting );
    
      FT_LOCAL( void )
      t1_builder_done( T1_Builder  builder );
    
      FT_LOCAL( FT_Error )
      t1_builder_check_points( T1_Builder  builder,
                               FT_Int      count );
    
      FT_LOCAL( void )
      t1_builder_add_point( T1_Builder  builder,
                            FT_Pos      x,
                            FT_Pos      y,
                            FT_Byte     flag );
    
      FT_LOCAL( FT_Error )
      t1_builder_add_point1( T1_Builder  builder,
                             FT_Pos      x,
                             FT_Pos      y );
    
      FT_LOCAL( FT_Error )
      t1_builder_add_contour( T1_Builder  builder );
    
    
      FT_LOCAL( FT_Error )
      t1_builder_start_point( T1_Builder  builder,
                              FT_Pos      x,
                              FT_Pos      y );
    
    
      FT_LOCAL( void )
      t1_builder_close_contour( T1_Builder  builder );
    
    
      /*************************************************************************/
      /*************************************************************************/
      /*****                                                               *****/
      /*****                            OTHER                              *****/
      /*****                                                               *****/
      /*************************************************************************/
      /*************************************************************************/
    
      FT_LOCAL( void )
      t1_decrypt( FT_Byte*   buffer,
                  FT_Offset  length,
                  FT_UShort  seed );
    
    
    FT_END_HEADER
    
    #endif /* __PSOBJS_H__ */
    
    
    /* END */