(root)/
freetype-2.13.2/
src/
pshinter/
pshmod.c
       1  /****************************************************************************
       2   *
       3   * pshmod.c
       4   *
       5   *   FreeType PostScript hinter module implementation (body).
       6   *
       7   * Copyright (C) 2001-2023 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  #include <freetype/internal/ftobjs.h>
      20  #include "pshrec.h"
      21  #include "pshalgo.h"
      22  #include "pshmod.h"
      23  
      24  
      25    /* the Postscript Hinter module structure */
      26    typedef struct  PS_Hinter_Module_Rec_
      27    {
      28      FT_ModuleRec          root;
      29      PS_HintsRec           ps_hints;
      30  
      31      PSH_Globals_FuncsRec  globals_funcs;
      32      T1_Hints_FuncsRec     t1_funcs;
      33      T2_Hints_FuncsRec     t2_funcs;
      34  
      35    } PS_Hinter_ModuleRec, *PS_Hinter_Module;
      36  
      37  
      38    /* finalize module */
      39    FT_CALLBACK_DEF( void )
      40    ps_hinter_done( FT_Module  module_ )    /* PS_Hinter_Module */
      41    {
      42      PS_Hinter_Module  module = (PS_Hinter_Module)module_;
      43  
      44  
      45      module->t1_funcs.hints = NULL;
      46      module->t2_funcs.hints = NULL;
      47  
      48      ps_hints_done( &module->ps_hints );
      49    }
      50  
      51  
      52    /* initialize module, create hints recorder and the interface */
      53    FT_CALLBACK_DEF( FT_Error )
      54    ps_hinter_init( FT_Module  module_ )    /* PS_Hinter_Module */
      55    {
      56      PS_Hinter_Module  module = (PS_Hinter_Module)module_;
      57  
      58      FT_Memory  memory = module->root.memory;
      59      void*      ph     = &module->ps_hints;
      60  
      61  
      62      ps_hints_init( &module->ps_hints, memory );
      63  
      64      psh_globals_funcs_init( &module->globals_funcs );
      65  
      66      t1_hints_funcs_init( &module->t1_funcs );
      67      module->t1_funcs.hints = (T1_Hints)ph;
      68  
      69      t2_hints_funcs_init( &module->t2_funcs );
      70      module->t2_funcs.hints = (T2_Hints)ph;
      71  
      72      return 0;
      73    }
      74  
      75  
      76    /* returns global hints interface */
      77    FT_CALLBACK_DEF( PSH_Globals_Funcs )
      78    pshinter_get_globals_funcs( FT_Module  module )
      79    {
      80      return &((PS_Hinter_Module)module)->globals_funcs;
      81    }
      82  
      83  
      84    /* return Type 1 hints interface */
      85    FT_CALLBACK_DEF( T1_Hints_Funcs )
      86    pshinter_get_t1_funcs( FT_Module  module )
      87    {
      88      return &((PS_Hinter_Module)module)->t1_funcs;
      89    }
      90  
      91  
      92    /* return Type 2 hints interface */
      93    FT_CALLBACK_DEF( T2_Hints_Funcs )
      94    pshinter_get_t2_funcs( FT_Module  module )
      95    {
      96      return &((PS_Hinter_Module)module)->t2_funcs;
      97    }
      98  
      99  
     100    FT_DEFINE_PSHINTER_INTERFACE(
     101      pshinter_interface,
     102  
     103      pshinter_get_globals_funcs,
     104      pshinter_get_t1_funcs,
     105      pshinter_get_t2_funcs
     106    )
     107  
     108  
     109    FT_DEFINE_MODULE(
     110      pshinter_module_class,
     111  
     112      0,
     113      sizeof ( PS_Hinter_ModuleRec ),
     114      "pshinter",
     115      0x10000L,
     116      0x20000L,
     117  
     118      &pshinter_interface,        /* module-specific interface */
     119  
     120      (FT_Module_Constructor)ps_hinter_init,  /* module_init   */
     121      (FT_Module_Destructor) ps_hinter_done,  /* module_done   */
     122      (FT_Module_Requester)  NULL             /* get_interface */
     123    )
     124  
     125  /* END */