home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / ft-beta.zip / freetype / lib / ttcmap.h < prev    next >
C/C++ Source or Header  |  1997-10-06  |  4KB  |  143 lines

  1. /*******************************************************************
  2.  *
  3.  *  ttcmap.h                                                    1.0
  4.  *
  5.  *    TrueType Character Mappings                      
  6.  *
  7.  *  Copyright 1996, 1997 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 TTCMAP_H
  20. #define TTCMAP_H
  21.  
  22. #include "ttcommon.h"
  23. #include "tttypes.h"
  24.  
  25.   /* format 0 */
  26.  
  27.   typedef struct _TCMap0
  28.   {
  29.     PByte   glyphIdArray;
  30.  
  31.   } TCMap0;
  32.  
  33.   typedef TCMap0*  PCMap0;
  34.  
  35.   /* format 2 */
  36.  
  37.   typedef struct  _TCMap2SubHeader
  38.   {
  39.     UShort  firstCode;      /* first valid low byte         */
  40.     UShort  entryCount;     /* number of valid low bytes    */
  41.     Short   idDelta;        /* delta value to glyphIndex    */
  42.     UShort  idRangeOffset;  /* offset from here to 1st code */
  43.  
  44.   } TCMap2SubHeader;
  45.  
  46.   typedef TCMap2SubHeader*  PCMap2SubHeader;
  47.  
  48.  
  49.   typedef struct _TCMap2
  50.   {
  51.     PUShort subHeaderKeys;
  52.     /* high byte mapping table            */
  53.     /* value = subHeader index * 8        */
  54.  
  55.     PCMap2SubHeader  subHeaders;
  56.     PUShort          glyphIdArray;
  57.  
  58.   } TCMap2;
  59.   
  60.   typedef TCMap2*  PCMap2;
  61.  
  62.   /* format 4 */
  63.  
  64.   typedef struct  _TCMap4Segment
  65.   {
  66.     UShort  endCount;
  67.     UShort  startCount;
  68.     Short   idDelta;        /* in the specs defined as UShort but the
  69.                                example there gives negative values... */
  70.     UShort  idRangeOffset;
  71.   } TCMap4Segment;
  72.  
  73.   typedef TCMap4Segment*  PCMap4Segment;
  74.  
  75.  
  76.   typedef struct _TCMap4
  77.   {
  78.     UShort  segCountX2;     /* segments number * 2          */
  79.     UShort  searchRange;    /* these parameters can be used */
  80.     UShort  entrySelector;  /* for a binary search          */
  81.     UShort  rangeShift;
  82.  
  83.     PCMap4Segment  segments;
  84.     PUShort        glyphIdArray;
  85.  
  86.   } TCMap4;
  87.  
  88.   typedef TCMap4*  PCMap4;
  89.  
  90.   /* format 6 */
  91.  
  92.   typedef struct _TCMap6
  93.   {
  94.     UShort   firstCode;      /* first character code of subrange      */
  95.     UShort   entryCount;     /* number of character codes in subrange */
  96.  
  97.     PUShort  glyphIdArray;
  98.   } TCMap6;
  99.  
  100.   typedef TCMap6*  PCMap6;
  101.  
  102.   /* charmap table */
  103.  
  104.   struct _TCMapTable
  105.   {
  106.     UShort  platformID;
  107.     UShort  platformEncodingID;
  108.     UShort  format;
  109.     UShort  length;
  110.     UShort  version;
  111.  
  112.     Bool    loaded;
  113.     Long    offset;
  114.  
  115.     union
  116.     {
  117.       TCMap0  cmap0;
  118.       TCMap2  cmap2;
  119.       TCMap4  cmap4;
  120.       TCMap6  cmap6;
  121.     } c;
  122.   };
  123.   
  124.   typedef struct _TCMapTable   TCMapTable;
  125.   typedef TCMapTable*          PCMapTable;
  126.  
  127.  
  128.   /* Load character mappings directory when face is loaded */
  129.   /* the mappings themselves are only loaded on demand     */
  130.   TT_Error  CharMap_Load( PCMapTable  table, TT_Stream  input );
  131.  
  132.   /* Destroy one character mapping table */
  133.   TT_Error  CharMap_Free( PCMapTable  table );
  134.  
  135.   /* Use character mapping table to perform mapping */
  136.   Int  CharMap_Index( PCMapTable  cmap,
  137.                       UShort      charcode );
  138.  
  139.   /* NOTE : The PFace type isn't defined at this point */
  140.  
  141. #endif /* TTCMAP_H */
  142.  
  143.