godot/thirdparty/freetype/src/pfr/pfrload.c

/****************************************************************************
 *
 * pfrload.c
 *
 *   FreeType PFR loader (body).
 *
 * Copyright (C) 2002-2023 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.
 *
 */


#include "pfrload.h"
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>

#include "pfrerror.h"

#undef  FT_COMPONENT
#define FT_COMPONENT


  /*
   * The overall structure of a PFR file is as follows.
   *
   *   PFR header
   *     58 bytes (contains nPhysFonts)
   *
   *   Logical font directory (size at most 2^16 bytes)
   *     2 bytes (nLogFonts)
   *     + nLogFonts * 5 bytes
   *
   *        ==>  nLogFonts <= 13106
   *
   *   Logical font section (size at most 2^24 bytes)
   *     nLogFonts * logFontRecord
   *
   *     logFontRecord (size at most 2^16 bytes)
   *       12 bytes (fontMatrix)
   *       + 1 byte (flags)
   *       + 0-5 bytes (depending on `flags')
   *       + 0-(1+255*(2+255)) = 0-65536 (depending on `flags')
   *       + 5 bytes (physical font info)
   *       + 0-1 bytes (depending on PFR header)
   *
   *        ==>  minimum size 18 bytes
   *
   *   Physical font section (size at most 2^24 bytes)
   *     nPhysFonts * (physFontRecord
   *                   + nBitmapSizes * nBmapChars * bmapCharRecord)
   *
   *     physFontRecord (size at most 2^24 bytes)
   *       14 bytes (font info)
   *       + 1 byte (flags)
   *       + 0-2 (depending on `flags')
   *       + 0-? (structure too complicated to be shown here; depending on
   *              `flags'; contains `nBitmapSizes' and `nBmapChars')
   *       + 3 bytes (nAuxBytes)
   *       + nAuxBytes
   *       + 1 byte (nBlueValues)
   *       + 2 * nBlueValues
   *       + 6 bytes (hinting data)
   *       + 2 bytes (nCharacters)
   *       + nCharacters * (4-10 bytes) (depending on `flags')
   *
   *        ==>  minimum size 27 bytes
   *
   *     bmapCharRecord
   *       4-7 bytes
   *
   *   Glyph program strings (three possible types: simpleGps, compoundGps,
   *                          and bitmapGps; size at most 2^24 bytes)
   *     simpleGps (size at most 2^16 bytes)
   *       1 byte (flags)
   *       1-2 bytes (n[XY]orus, depending on `flags')
   *       0-(64+512*2) = 0-1088 bytes (depending on `n[XY]orus')
   *       0-? (structure too complicated to be shown here; depending on
   *            `flags')
   *       1-? glyph data (faintly resembling PS Type 1 charstrings)
   *
   *        ==>  minimum size 3 bytes
   *
   *     compoundGps (size at most 2^16 bytes)
   *       1 byte (nElements <= 63, flags)
   *       + 0-(1+255*(2+255)) = 0-65536 (depending on `flags')
   *       + nElements * (6-14 bytes)
   *
   *     bitmapGps (size at most 2^16 bytes)
   *       1 byte (flags)
   *       3-13 bytes (position info, depending on `flags')
   *       0-? bitmap data
   *
   *        ==>  minimum size 4 bytes
   *
   *   PFR trailer
   *       8 bytes
   *
   *
   * ==>  minimum size of a valid PFR:
   *        58 (header)
   *        + 2 (nLogFonts)
   *        + 27 (1 physFontRecord)
   *        + 8 (trailer)
   *       -----
   *        95 bytes
   *
   */


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                          EXTRA ITEMS                          *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/


  FT_LOCAL_DEF( FT_Error )
  pfr_extra_items_skip( FT_Byte*  *pp,
                        FT_Byte*   limit )
  {}


  FT_LOCAL_DEF( FT_Error )
  pfr_extra_items_parse( FT_Byte*       *pp,
                         FT_Byte*        limit,
                         PFR_ExtraItem   item_list,
                         FT_Pointer      item_data )
  {}


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                          PFR HEADER                           *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

   static const FT_Frame_Field  pfr_header_fields[] =;


  FT_LOCAL_DEF( FT_Error )
  pfr_header_load( PFR_Header  header,
                   FT_Stream   stream )
  {}


  FT_LOCAL_DEF( FT_Bool )
  pfr_header_check( PFR_Header  header )
  {}


  /***********************************************************************/
  /***********************************************************************/
  /*****                                                             *****/
  /*****                    PFR LOGICAL FONTS                        *****/
  /*****                                                             *****/
  /***********************************************************************/
  /***********************************************************************/


  FT_LOCAL_DEF( FT_Error )
  pfr_log_font_count( FT_Stream  stream,
                      FT_UInt32  section_offset,
                      FT_Long   *acount )
  {}


  FT_LOCAL_DEF( FT_Error )
  pfr_log_font_load( PFR_LogFont  log_font,
                     FT_Stream    stream,
                     FT_UInt      idx,
                     FT_UInt32    section_offset,
                     FT_Bool      size_increment )
  {}


  /***********************************************************************/
  /***********************************************************************/
  /*****                                                             *****/
  /*****                    PFR PHYSICAL FONTS                       *****/
  /*****                                                             *****/
  /***********************************************************************/
  /***********************************************************************/


  /* load bitmap strikes lists */
  FT_CALLBACK_DEF( FT_Error )
  pfr_extra_item_load_bitmap_info( FT_Byte*  p,
                                   FT_Byte*  limit,
                                   void*     phy_font_ )
  {}


  /* Load font ID.  This is a so-called `unique' name that is rather
   * long and descriptive (like `Tiresias ScreenFont v7.51').
   *
   * Note that a PFR font's family name is contained in an *undocumented*
   * string of the `auxiliary data' portion of a physical font record.  This
   * may also contain the `real' style name!
   *
   * If no family name is present, the font ID is used instead for the
   * family.
   */
  FT_CALLBACK_DEF( FT_Error )
  pfr_extra_item_load_font_id( FT_Byte*  p,
                               FT_Byte*  limit,
                               void*     phy_font_ )
  {}


  /* load stem snap tables */
  FT_CALLBACK_DEF( FT_Error )
  pfr_extra_item_load_stem_snaps( FT_Byte*  p,
                                  FT_Byte*  limit,
                                  void*     phy_font_ )
  {}


  /* load kerning pair data */
  FT_CALLBACK_DEF( FT_Error )
  pfr_extra_item_load_kerning_pairs( FT_Byte*  p,
                                     FT_Byte*  limit,
                                     void*     phy_font_ )
  {}


  static const PFR_ExtraItemRec  pfr_phy_font_extra_items[] =;


  /*
   * Load a name from the auxiliary data.  Since this extracts undocumented
   * strings from the font file, we need to be careful here.
   */
  static FT_Error
  pfr_aux_name_load( FT_Byte*     p,
                     FT_UInt      len,
                     FT_Memory    memory,
                     FT_String*  *astring )
  {}


  FT_LOCAL_DEF( void )
  pfr_phy_font_done( PFR_PhyFont  phy_font,
                     FT_Memory    memory )
  {}


  FT_LOCAL_DEF( FT_Error )
  pfr_phy_font_load( PFR_PhyFont  phy_font,
                     FT_Stream    stream,
                     FT_UInt32    offset,
                     FT_UInt32    size )
  {}


/* END */