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

  1. /*******************************************************************
  2.  *
  3.  *  ftxkern.h                                                   1.0
  4.  *
  5.  *    High-Level API Kerning extension
  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.  *  The kerning support is currently part of the engine extensions.
  18.  *
  19.  *  This file should _not_ depend on engine internal types
  20.  *
  21.  ******************************************************************/
  22.  
  23. #ifndef FTXKERN_H
  24. #define FTXKERN_H
  25.  
  26.   /* This file must be include _after_ "freetype.h"                */
  27.  
  28. #ifndef FREETYPE_H
  29. #error freetype.h has not been included
  30. #endif
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36.   /* The kerning support in FreeType is minimal. This means that   */
  37.   /* we do not try to interpret the kerning data in any way to     */
  38.   /* 'cook' it for a user application. This API let's you access   */
  39.   /* directly the kerning tables found in the TrueType file, it's  */
  40.   /* up to the client application to apply its own processing on   */
  41.   /* these..                                                       */
  42.                                                                    
  43.   /* The reason for this is that we generally do not encourage     */
  44.   /* feature-bloat of the core engine. Moreover, not all libraries */
  45.   /* or font servers really need kerning data, or all formats of   */
  46.   /* of this data.                                                 */
  47.  
  48.   /************** kerning error codes *****************************/
  49.  
  50.   /* we chose the class 0x0A for our errors, this should not match */
  51.   /* with any error code class used in any other extension         */
  52.  
  53.   #define TT_Err_Invalid_Kerning_Table_Format  0x0A00
  54.  
  55.   /********** structures definitions ******************************/
  56.  
  57.   /* remember that all types and function are accessible by client */
  58.   /* applications in this section, and thus should have the 'TT_'  */
  59.   /* prefix.                                                       */
  60.  
  61.   /* format 0 kerning pair */
  62.  
  63.   typedef struct _TT_Kern_0_Pair
  64.   {
  65.     short  left;   /* index of left  glyph in pair */
  66.     short  right;  /* index of right glyph in pair */
  67.     short  value;  /* kerning value                */
  68.   } TT_Kern_0_Pair;
  69.  
  70.  
  71.   /* format 0 kerning subtable */
  72.  
  73.   typedef struct _TT_Kern_0
  74.   {
  75.     int  nPairs;         /* number of kerning pairs */
  76.  
  77.     int  searchRange;    /* these values are defined by the TT spec */
  78.     int  entrySelector;  /* for table searchs.                      */
  79.     int  rangeShift;
  80.  
  81.     TT_Kern_0_Pair*  pairs;  /* a table of nPairs 'pairs' */
  82.  
  83.   } TT_Kern_0;
  84.  
  85.  
  86.   /* format 2 kerning glyph class */
  87.  
  88.   typedef struct _TT_Kern_2_Class
  89.   {
  90.     int     firstGlyph;  /* first glyph in range                    */
  91.     int     nGlyphs;     /* number of glyphs in range               */
  92.     short*  classes;     /* a table giving for each ranged glyph    */
  93.                          /* it's class offset in the subtable pairs */
  94.                          /* two-dimensional array                   */
  95.   } TT_Kern_2_Class;
  96.  
  97.  
  98.   /* format 2 kerning subtable */
  99.  
  100.   typedef struct _TT_Kern_2
  101.   {
  102.     int               rowWidth;   /* length of one row in bytes         */
  103.     TT_Kern_2_Class   leftClass;  /* left class table                   */
  104.     TT_Kern_2_Class   rightClass; /* right class table                  */
  105.     short*            array;      /* 2-dimensional kerning values array */
  106.  
  107.   } TT_Kern_2;
  108.  
  109.  
  110.   /* kerning subtable */
  111.  
  112.   typedef struct _TT_Kern_Subtable
  113.   {
  114.     int  loaded;   /* boolean, indicates wether the table is loaded */
  115.     int  version;  /* table version number                          */
  116.     long offset;   /* file offset of table                          */
  117.     int  length;   /* length of table in bytes, _excluding_ header  */
  118.     char coverage; /* coverage lowest bit fields                    */
  119.     char format;   /* the subtable format, as found in the coverage */
  120.  
  121.     union
  122.     {
  123.       TT_Kern_0  kern0;
  124.       TT_Kern_2  kern2;
  125.     } t;
  126.  
  127.   } TT_Kern_Subtable;
  128.  
  129.  
  130.   struct _TT_Kerning
  131.   {
  132.     int                version;  /* kern table version number. starts at 0 */
  133.     int                nTables;  /* number of tables                       */
  134.  
  135.     TT_Kern_Subtable*  tables;   /* the kerning sub-tables                 */
  136.   };
  137.   typedef struct _TT_Kerning  TT_Kerning;
  138.  
  139.   /***************** high-level API extension **************************/
  140.  
  141.   /* Note on the implemented mechanism :                             */
  142.  
  143.   /* The kerning table directory is loaded with the face through the */
  144.   /* extension constructor. However, the tables will only be loaded  */
  145.   /* on demand, as they may represent a lot of data, unnecessary to  */
  146.   /* most applications..                                             */
  147.  
  148.   /* Queries a pointer to the kerning directory for the face object */
  149.   TT_Error  TT_Get_Kerning_Directory( TT_Face      face,
  150.                                       TT_Kerning*  directory );
  151.  
  152.   /* Load the kerning table number 'kern_index' in the kerning */
  153.   /* directory. The table will stay in memory until the face   */
  154.   /* face is destroyed                                         */
  155.   TT_Error  TT_Load_Kerning_Table( TT_Face  face,
  156.                                    int      kern_index );
  157.  
  158. #ifdef __cplusplus
  159. }
  160. #endif
  161.  
  162. #endif /* FTXKERN_H */
  163.  
  164. /* END - that's all we need */
  165.