Home | History | Annotate | Download | only in pfr
      1 /***************************************************************************/
      2 /*                                                                         */
      3 /*  pfrload.h                                                              */
      4 /*                                                                         */
      5 /*    FreeType PFR loader (specification).                                 */
      6 /*                                                                         */
      7 /*  Copyright 2002-2018 by                                                 */
      8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
      9 /*                                                                         */
     10 /*  This file is part of the FreeType project, and may only be used,       */
     11 /*  modified, and distributed under the terms of the FreeType project      */
     12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
     13 /*  this file you indicate that you have read the license and              */
     14 /*  understand and accept it fully.                                        */
     15 /*                                                                         */
     16 /***************************************************************************/
     17 
     18 
     19 #ifndef PFRLOAD_H_
     20 #define PFRLOAD_H_
     21 
     22 #include "pfrobjs.h"
     23 #include FT_INTERNAL_STREAM_H
     24 
     25 
     26 FT_BEGIN_HEADER
     27 
     28   /* some size checks should be always done (mainly to prevent */
     29   /* excessive allocation for malformed data), ...             */
     30 #define PFR_CHECK_SIZE( x )  do                       \
     31                              {                        \
     32                                if ( p + (x) > limit ) \
     33                                  goto Too_Short;      \
     34                              } while ( 0 )
     35 
     36   /* ... and some only if intensive checking is explicitly requested */
     37 #ifdef PFR_CONFIG_NO_CHECKS
     38 #define PFR_CHECK( x )  do { } while ( 0 )
     39 #else
     40 #define PFR_CHECK  PFR_CHECK_SIZE
     41 #endif
     42 
     43 #define PFR_NEXT_BYTE( p )    FT_NEXT_BYTE( p )
     44 #define PFR_NEXT_INT8( p )    FT_NEXT_CHAR( p )
     45 #define PFR_NEXT_SHORT( p )   FT_NEXT_SHORT( p )
     46 #define PFR_NEXT_USHORT( p )  FT_NEXT_USHORT( p )
     47 #define PFR_NEXT_LONG( p )    FT_NEXT_OFF3( p )
     48 #define PFR_NEXT_ULONG( p )   FT_NEXT_UOFF3( p )
     49 
     50 
     51  /* handling extra items */
     52 
     53   typedef FT_Error
     54   (*PFR_ExtraItem_ParseFunc)( FT_Byte*    p,
     55                               FT_Byte*    limit,
     56                               FT_Pointer  data );
     57 
     58   typedef struct  PFR_ExtraItemRec_
     59   {
     60     FT_UInt                  type;
     61     PFR_ExtraItem_ParseFunc  parser;
     62 
     63   } PFR_ExtraItemRec;
     64 
     65   typedef const struct PFR_ExtraItemRec_*  PFR_ExtraItem;
     66 
     67 
     68   FT_LOCAL( FT_Error )
     69   pfr_extra_items_skip( FT_Byte*  *pp,
     70                         FT_Byte*  limit );
     71 
     72   FT_LOCAL( FT_Error )
     73   pfr_extra_items_parse( FT_Byte*      *pp,
     74                          FT_Byte*       limit,
     75                          PFR_ExtraItem  item_list,
     76                          FT_Pointer     item_data );
     77 
     78 
     79   /* load a PFR header */
     80   FT_LOCAL( FT_Error )
     81   pfr_header_load( PFR_Header  header,
     82                    FT_Stream   stream );
     83 
     84   /* check a PFR header */
     85   FT_LOCAL( FT_Bool )
     86   pfr_header_check( PFR_Header  header );
     87 
     88 
     89   /* return number of logical fonts in this file */
     90   FT_LOCAL( FT_Error )
     91   pfr_log_font_count( FT_Stream   stream,
     92                       FT_UInt32   log_section_offset,
     93                       FT_Long    *acount );
     94 
     95   /* load a pfr logical font entry */
     96   FT_LOCAL( FT_Error )
     97   pfr_log_font_load( PFR_LogFont  log_font,
     98                      FT_Stream    stream,
     99                      FT_UInt      face_index,
    100                      FT_UInt32    section_offset,
    101                      FT_Bool      size_increment );
    102 
    103 
    104   /* load a physical font entry */
    105   FT_LOCAL( FT_Error )
    106   pfr_phy_font_load( PFR_PhyFont  phy_font,
    107                      FT_Stream    stream,
    108                      FT_UInt32    offset,
    109                      FT_UInt32    size );
    110 
    111   /* finalize a physical font */
    112   FT_LOCAL( void )
    113   pfr_phy_font_done( PFR_PhyFont  phy_font,
    114                      FT_Memory    memory );
    115 
    116   /* */
    117 
    118 FT_END_HEADER
    119 
    120 #endif /* PFRLOAD_H_ */
    121 
    122 
    123 /* END */
    124