home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / ft-beta.zip / freetype / docs / apiref.txt next >
Text File  |  1997-10-06  |  45KB  |  1,184 lines

  1.             The FreeType Engine
  2.  
  3.                Core Library Reference
  4.  
  5.  
  6.         -----------------------------------
  7.  
  8.  
  9.              Table of Contents:
  10.  
  11.                 Introduction
  12.                          
  13.                             I. Types
  14.                          
  15.                            II. Functions
  16.                          
  17.                           III. Error codes
  18.                           
  19.  
  20.                         --------------------
  21.  
  22.  
  23. Introduction:
  24.  
  25.   This  reference  presents the  types,  functions  and error  codes
  26.   defined in the high-level API header file "freetype.h".  Note that
  27.   all symbols defined  in this file are prefixed  by "TT_", to avoid
  28.   name conflicts with other packages at link time.
  29.  
  30.   Some of its  parts are also dedicated to  the extension that comes
  31.   by default with this distribution of the library, which is kerning
  32.   support.
  33.  
  34. ----------------------------------------------------------------------------
  35.  
  36. I. Types:
  37.  
  38.   Here is  the list of  all the types  defined in the  core FreeType
  39.   API.  Their exact definition can be found in the file "freetype.h"
  40.   which should be included by every client application.
  41.  
  42.  
  43.   TT_Fixed
  44.  
  45.     A  signed 16.16  fixed  float value  used  to specify  transform
  46.     coefficients and other important data.
  47.  
  48.   ..................................................................
  49.  
  50.   TT_FWord
  51.  
  52.     A signed  16 bits value used  to express a  distance measured in
  53.     the font's original EM units.  These are also called 'FUnits' in
  54.     the TrueType specification.
  55.  
  56.   ..................................................................
  57.  
  58.   TT_UFWord
  59.  
  60.     Unsigned FWord.
  61.  
  62.   ..................................................................
  63.  
  64.   TT_Short
  65.   TT_UShort
  66.   TT_Long
  67.   TT_ULong
  68.  
  69.     These four  types are  aliases for 16  bits integer  (signed and
  70.     unsigned) and 32 bits one (signed and unsigned).
  71.  
  72.   ..................................................................
  73.  
  74.   TT_F2Dot14
  75.  
  76.     A  2.14 fixed  float integer  used  for unary  vectors and  some
  77.     scaling coefficients. Their layout is:
  78.  
  79.       s : 1    -- sign bit
  80.       m : 1    -- mantissa bit
  81.       f : 14   -- unsigned fractional value
  82.  
  83.     where  's:m' is  the 2-bit  signed  integer value  to which  the
  84.     always-positive fractional part 'f' should be added.
  85.  
  86.   ..................................................................
  87.  
  88.   TT_F26Dot6
  89.  
  90.     The  26.6 fixed  float format  used to  define  fractional pixel
  91.     coordinates.  Here, 1 unit = 1/64 pixel.
  92.  
  93.   ..................................................................
  94.  
  95.   TT_UnitVector
  96.  
  97.     A simple  structure used to  store a unit vector.   The vector's
  98.     coordinates are expressed in fixed float format (2.14).
  99.  
  100.       struct
  101.       { 
  102.         TT_F2Dot14  x;
  103.         TT_F2Dot14  y;
  104.       }
  105.  
  106.   ..................................................................
  107.  
  108.   TT_Vector
  109.  
  110.     A  simple   structure  used  to  store  a   single  vector.  Its
  111.     coordinates are expressed in fixed float format (26.6).
  112.  
  113.       struct
  114.       {
  115.         TT_F26Dot6  x;
  116.         TT_F26Dot6  y;
  117.       }
  118.  
  119.   ..................................................................
  120.  
  121.   TT_Matrix
  122.  
  123.     A  simple structure  used to  store  a single  2x2 matrix.   Its
  124.     coefficients are  expressed in  16.16 fixed float  format.  This
  125.     matrix is  used to perform  linear transformations on  the glyph
  126.     outline, such as slanting or rotation.
  127.  
  128.       struct
  129.       {
  130.         TT_Fixed  xx, xy;
  131.         TT_Fixed  yx, yy;
  132.       };
  133.  
  134.     The computation performed is:
  135.  
  136.        x' = xx * x  +  xy * y
  137.        y' = yx * x  +  yy * y
  138.  
  139.   ..................................................................
  140.  
  141.   TT_Glyph_Outline
  142.  
  143.     This   structure  is   used  to   describe  a   vectorial  glyph
  144.     representation to the rasterizer.  It is made of:
  145.  
  146.     - an array of points:
  147.  
  148.         The  'points'  field  gives  the  number of  points  in  the
  149.         outline, while  their coordinates are found  in the parallel
  150.         arrays 'xCoord'  and 'yCoord'.   The 'flag' array  holds for
  151.         each point a flag indicating its type.
  152.  
  153.         Currently, only the first  bit (bit 0, the least significant
  154.         bit)  of each byte  is meaningful  to the  rasterizer.  When
  155.         set, it  indicates that the  point is _on_ the  curve.  When
  156.         not set, the point is said to be _off_ the curve.  It's then
  157.         a Bezier control point.
  158.  
  159.         For more  information about point states,  read the TrueType
  160.         specification or the scan-line documentation "raster.txt".
  161.  
  162.  
  163.     - an array of contours' start-point indexes:
  164.  
  165.         The 'contours' field gives the number of contours, while the
  166.         'conStarts' array holds the  indexes of each contour's first
  167.         point.  Note that  the first contour always starts  at 0 and
  168.         has no entry in this table.
  169.  
  170.         Hence, conStarts[0]  holds the  index of the  point starting
  171.         the _second_  contour.  The first  one being defined  by the
  172.         closure of the path 0..conStarts[0]-1.
  173.  
  174.         ** IMPORTANT NOTE: **
  175.         *********************
  176.  
  177.         The last table entry _must_  always give the total number of
  178.         points used to draw the contours, i.e.:
  179.         
  180.              conStarts[contours-1] == points
  181.  
  182.         If  this value  is  bigger than  'points'  when calling  the
  183.         scan-line converter,  the component will  immediately return
  184.         an  error.   If  the  value  is  smaller,  only  the  points
  185.         contained  in the  described contours  will be  used  in the
  186.         conversion process.
  187.  
  188.  
  189.     - a dropout mode:
  190.  
  191.         Used  to specify the  method to  apply for  drop-out control
  192.         (also  called 'continuity  testing' in  other environments).
  193.         The  mode value must  be one  of the  values defined  by the
  194.         TrueType specification.
  195.  
  196.         The recent modes 4 and 5 introduced in the newest spec (1.6)
  197.         are fully supported.
  198.  
  199.         An invalid  value (i.e.,  other than  0, 1, 2,  4, or  5) is
  200.         taken as no dropout control (equivalent to mode 0).
  201.  
  202.  
  203.    NOTE1:
  204.  
  205.      A typical user would only modify the point coordinates accessed
  206.      through the 'xCoord' and  'yCoord' fields.  Changing the number
  207.      of points,  the contours  arrays or even  the flags array  is a
  208.      delicate process that should be taken seriously.
  209.  
  210.    NOTE2:
  211.  
  212.      A  glyph  outline  only  contains  pointers to  the  tables  it
  213.      describes, but it doesn't own them!
  214.  
  215.      Typically,  the  tables  are  defined  and  owned  by  a  glyph
  216.      container object (see below).  They are accessed through a call
  217.      to  TT_Get_Glyph_Outline()  which  returns  a  TT_Glyph_Outline
  218.      structure whose pointers relate to the container's data.
  219.  
  220.      These outline's  tables should never  be freed directly  by the
  221.      client  application;  they will  be  destroyed  with the  glyph
  222.      container when the latter is discarded.
  223.  
  224.     struct
  225.     {
  226.       unsigned int     contours;  /* number of contours in glyph   */
  227.       unsigned short*  conStarts; /* points to an array of each
  228.                                      contour's start point index   */
  229.       unsigned int     points;    /* number of points in the glyph */
  230.       long*            xCoord;    /* table of x coordinates        */
  231.       long*            yCoord;    /* table of y coordinates        */
  232.       unsigned char*   flag;      /* table of flags                */
  233.   
  234.       char             dropout_mode;  /* dropout mode */
  235.     }
  236.  
  237.   ..................................................................
  238.  
  239.   TT_Glyph_Metrics
  240.  
  241.     A structure  used to return simple glyph  metrics.  These values
  242.     are expressed in fractional  pixels (26.6 format) if scaling was
  243.     active, and in FUnits otherwise.
  244.  
  245.       struct
  246.       {
  247.         TT_F26Dot6  leftSideBearing;
  248.         TT_F26Dot6  advanceWidth;
  249.     
  250.         TT_F26Dot6  xMin, yMin, xMax, yMax;
  251.       };
  252.  
  253.   ..................................................................
  254.  
  255.   TT_Instance_Metrics
  256.  
  257.     A structure used to return instance (point size) metrics.
  258.  
  259.       struct
  260.       {
  261.         int  pointSize;
  262.         /* point size in points (1 point = 1/72 inch) */
  263.     
  264.         int  x_ppem;  /* horizontal pixels per EM square */
  265.         int  y_ppem;  /* vertical pixels per EM square   */
  266.     
  267.         int  x_resolution; /* device horizontal resolution in dpi */
  268.         int  y_resolution; /* device vertical resolution in dpi   */
  269.       };
  270.  
  271.   ..................................................................
  272.  
  273.   TT_Raster_Map
  274.  
  275.     This structure is  used to describe a target  bitmap (or pixmap)
  276.     to the  scan-line converter.   It must be  set up by  the client
  277.     application.
  278.  
  279.     - the  'rows' field  contains the  total number  of rows  in the
  280.       bitmap
  281.  
  282.     - the 'width' field gives the number of pixels per row (a bit or
  283.       a byte, depending on the map's nature).
  284.  
  285.     - the  'cols' field  gives the  number of  columns,  i.e. bytes,
  286.       taken by each row in the map buffer.
  287.  
  288.       ** IMPORTANT **: the 'cols' field must be a multiple of 4!
  289.  
  290.       Typically, its value should  be '(width+7)/8' for bitmaps, and
  291.       '(width+3) & -4' for pixmaps.
  292.       
  293.     - the 'flow' field gives the map's vertical orientation.
  294.  
  295.       For example, if  the first bytes of the  bitmap buffer pertain
  296.       to its upper row, the flow is said to be going 'down', and the
  297.       field should  take the  value 'TT_Flow_Down'.  If  these bytes
  298.       pertain to  its lowest  row, the flow  is going 'up',  and the
  299.       value is 'TT_Flow_Up'.
  300.  
  301.       As an example, the PC video modes use a 'down' flow, where the
  302.       first VRAM  byte corresponds to the upper  and leftmost corner
  303.       of the screen.
  304.  
  305.     - the 'bitmap' field is a typeless pointer to the map's buffer.
  306.  
  307.     - the 'size' field  contains the buffer's size in  bytes.  It is
  308.       usually computed as follows:
  309.  
  310.           size = rows * cols;
  311.  
  312.     NOTE:
  313.  
  314.       For  bitmaps, the leftmost-pixel  is   related to the  highest
  315.       (i.e.  most significant) bit  of its byte.  There is currently
  316.       no support for the opposite convention found in some systems.
  317.  
  318.       (It can  be easily added if  you really need it,  just ask the
  319.       development team)
  320.  
  321.       struct
  322.       {
  323.         int     rows;    /* number of rows                    */
  324.         int     cols;    /* number of columns (bytes) per row */
  325.         int     width;   /* number of pixels per line         */
  326.         int     flow;    /* bitmap orientation                */
  327.     
  328.         void*   bitmap;  /* bit/pixmap buffer                 */
  329.         long    size;    /* bit/pixmap size in bytes          */
  330.       } TT_Raster_Map;
  331.  
  332.   ..................................................................
  333.  
  334.   TT_Header
  335.  
  336.     This structure  is used to  hold the font's header.   Its layout
  337.     and meaning  are defined in  the TrueType specification,  in the
  338.     'head' section.
  339.  
  340.   ..................................................................
  341.  
  342.   TT_Horizontal_Header
  343.  
  344.     This  structure is used  to hold  the font's  horizontal header.
  345.     Its   layout   and  meaning   are   defined   in  the   TrueType
  346.     specification, in the 'hhead' section.
  347.  
  348.   ..................................................................
  349.  
  350.   TT_OS2
  351.  
  352.     This  structure is  used to  hold  the font's  OS/2 table.   Its
  353.     layout and meaning are defined in the TrueType specification, in
  354.     the 'OS/2' section.
  355.  
  356.   ..................................................................
  357.  
  358.   TT_Postscript
  359.  
  360.     This structure is used to hold the font's Postscript table.  Its
  361.     layout and meaning are defined in the TrueType specification, in
  362.     the 'post' section.
  363.  
  364.   ..................................................................
  365.  
  366.   TT_Face_Properties
  367.  
  368.     This structure  is used to  return an opened  face's properties.
  369.     These are:
  370.  
  371.     - The total  number of  glyphs in the  font, given by  the field
  372.       'num_Glyphs'.
  373.  
  374.     - The  maximum number  of points  for the  font's  glyphs.  This
  375.       value  is  used to  allocate  the  points  tables of  a  glyph
  376.       container's outline.  It can  be fairly large (like 256 points
  377.       for Roman fonts).
  378.  
  379.     - The maximum  number of contours  for the font's  glyphs.  This
  380.       value  is used  to allocate  the  contours tables  of a  glyph
  381.       container's outline.  It can be fairly large (over 16, even in
  382.       Roman fonts).
  383.  
  384.     - The maximum number of associated faces.  This number is always
  385.       0 for  a normal  TrueType font file.   However, when  the face
  386.       object was opened from  a TrueType collection, it contains the
  387.       maximum embedded font index used within this font collection.
  388.  
  389.     - pointers to  the face's  header, horizontal header,  OS/2, and
  390.       Postscript tables.
  391.  
  392.        struct
  393.        {
  394.          int  num_Glyphs;              /* number of glyphs in face */
  395.          int  max_Points;   /* maximum number of points in a glyph */
  396.          int  max_Contours;
  397.                           /* maximum number of contours in a glyph */
  398.      
  399.          int  max_Faces;   /* 0 for normal TrueType files, and the */
  400.                            /* number of embedded faces minus 1 for */
  401.                            /* TrueType collections                 */
  402.      
  403.          TT_Header*             header;   /* TrueType header table */
  404.          TT_Horizontal_Header*  horizontal;
  405.                                      /* TrueType horizontal header */
  406.          TT_OS2*                os2;        /* TrueType OS/2 table */
  407.          TT_Postscript*         postscript;
  408.                                       /* TrueType Postscript table */
  409.        } TT_Face_Properties;
  410.  
  411.   ..................................................................
  412.  
  413.   TT_Stream
  414.  
  415.      This handle type defines a  stream used to access a font file's
  416.      data.   A client  application  should never  deal with  streams
  417.      directly,  but some  engine  extensions may  later  need it  to
  418.      support more advanced features like font embedding.
  419.  
  420.   ..................................................................
  421.  
  422.   TT_Face
  423.  
  424.      This type  defines a  handle used to  reference a  face object.
  425.      The   objects  are   never  accessed   directly  by   a  client
  426.      application; it can only obtain handles to new objects, and use
  427.      them to query specific information or processes.
  428.  
  429.      See also:
  430.  
  431.         TT_Open_Face(), TT_Open_Collection(), TT_Close_Face(),
  432.         TT_Get_Face_Properties(), etc.
  433.  
  434.   ..................................................................
  435.  
  436.   TT_Instance
  437.  
  438.      This type defines a handle used to reference an instance object
  439.      (also called a 'pointsize' in other type engines).  An instance
  440.      is always  created from a  valid face object, and  is destroyed
  441.      with it by the engine.
  442.  
  443.      See also:
  444.  
  445.        TT_New_Instance(), TT_Close_Instance(),
  446.        TT_Set_Instance_Pointsize(), TT_Set_Instance_Resolution(),
  447.        etc.
  448.  
  449.   ..................................................................
  450.  
  451.   TT_Glyph
  452.  
  453.      This type defines a handle  used to reference a glyph container
  454.      object.  A glyph container is  an object owning tables sized to
  455.      the font's  maximum profile to hold  any glyph of  a given font
  456.      file.
  457.  
  458.      It  contains an  outline, some  metrics, as  well as  some data
  459.      related  to the  way it  should be  processed by  the scan-line
  460.      converter.
  461.  
  462.      Note  that a  glyph container  doesn't contain  any  bitmap nor
  463.      pixmap!
  464.  
  465.      See also:
  466.  
  467.        TT_New_Glyph(), TT_Close_Glyph(), TT_Get_Glyph_Metrics(),
  468.        TT_Get_Glyph_Outline(), TT_Get_Glyph_Bitmap(),
  469.        TT_Get_Glyph_Pixmap()
  470.  
  471.   ..................................................................
  472.  
  473.   TT_Error
  474.  
  475.     This is the type of all error codes returned by the API.  Nearly
  476.     all functions return an error code, set to 0 in case of success.
  477.     
  478.     A list of all error codes is given in section III.
  479.  
  480.   ..................................................................
  481.  
  482.   This distribution comes with an extension used to  support  access
  483.   to  a  font's  kerning information.  The extension's types and API
  484.   are defined in the file "ftxkern.h"
  485.  
  486. ----------------------------------------------------------------------------
  487.  
  488.  
  489. II. Functions:
  490.  
  491.   Here is a list of the core library's API.
  492.  
  493.   NOTE: A  function's  default  result  is  an  error code  of  type
  494.         TT_Error;  a list  of error  codes is  given in  section III
  495.         below.
  496.  
  497.         Some functions return integers or other types, in which case
  498.         the result type is written with its description.
  499.  
  500.   ..................................................................
  501.  
  502.   TT_Init_FreeType();
  503.  
  504.      Initialize the engine.  This  call must be performed before any
  505.      other function of FreeType is invoked.
  506.  
  507.   ..................................................................
  508.  
  509.   TT_Done_FreeType();
  510.  
  511.      Finalize the  engine.  This  calls destroys _all_  objects that
  512.      were previously created and used with the engine
  513.  
  514.   ..................................................................
  515.  
  516.   TT_Open_Face( char*     fontpathname,
  517.                 TT_face*  face );
  518.  
  519.      This  call opens a  font file,  located by  'fontpathname', and
  520.      returns a handle to the  newly corresponding face object in the
  521.      handle '*face'.
  522.  
  523.      Example:
  524.  
  525.           error = TT_Open_Face( "c:\ttf\wingding.ttf", &face );
  526.           if ( error )
  527.             fprintf( stderr, "could not open face\n" );
  528.  
  529.      Note:
  530.      The font file  can be a TrueType collection;  in this case, the
  531.      engine will  always open the  first embedded font found  in the
  532.      file.
  533.  
  534.   ..................................................................
  535.  
  536.   TT_Open_Collection( char*     collectionpathname,
  537.                       int       fontIndex,
  538.                       TT_Face*  face );
  539.  
  540.      This  call opens  one of  the font  files found  in  a TrueType
  541.      collection.   The  file  is  selected through  the  'fontIndex'
  542.      argument.
  543.  
  544.      Note  that to  know a  collection's number  of  embedded fonts,
  545.      you'll have to:
  546.  
  547.        1 - open the first collection font with TT_Open_Face().
  548.  
  549.        2 - query the face's properties through
  550.            TT_Get_Face_Properties().
  551.  
  552.      The number of embedded faces is then
  553.      'properties->max_Faces + 1'.
  554.  
  555.  
  556.      Example:
  557.  
  558.          TT_Face             face;
  559.          TT_Face_Properties  properties;
  560.  
  561.          error = TT_Open_Face( "c:\ttf\sample.ttc", &face );
  562.          if ( error ) { ...error .. }
  563.          /* Open first embedded collection font */
  564.  
  565.          error = TT_Get_Face_Properties( face, &properties );
  566.          if ( error ) { ...error .. }
  567.          /* Get face metrics */
  568.  
  569.          printf( "There are %d fonts in this collection",
  570.                  properties->max_Faces + 1 );
  571.  
  572.          TT_Close_Face( face );
  573.  
  574.          error = TT_Open_Collection( "c:\ttf\sample.ttc", 1,
  575.                                      &face );
  576.          if ( error ) { ...error .. }
  577.          /* Open second font in collection */
  578.  
  579.  
  580.      Note: If the file isn't a collection, 'fontIndex' must be zero.
  581.            Otherwise, an error will be produced.
  582.  
  583.   ..................................................................
  584.  
  585.   TT_Get_Face_Properties( TT_Face              face,
  586.                           TT_Face_Properties*  properties );
  587.  
  588.      Return  the  'face'  object's  '*properties'.   This  structure
  589.      contains  various data,  like the  total number  of  glyphs and
  590.      pointers to some mandatory TrueType tables.
  591.      
  592.      (See the definition of TT_Face_Properties in section I.)
  593.  
  594.   ..................................................................
  595.  
  596.   TT_Close_Face( TT_Face  face );
  597.  
  598.      Close a  given 'face' object.  This function  will also destroy
  599.      all  the face's child  instances.  The  face's glyphs  won't be
  600.      destroyed, however.
  601.  
  602.   ..................................................................
  603.  
  604.   TT_New_Instance( TT_Face       face,
  605.                    TT_Instance*  instance );
  606.  
  607.      Create a new  instance object related to the  'face' object.  A
  608.      handle to the newly created instance is returned in 'instance'.
  609.  
  610.      The default  instance resolution is 96dpi in  both vertical and
  611.      horizontal direction; the default point size is 10pt.
  612.  
  613.   ..................................................................
  614.  
  615.   TT_Set_Instance_Resolution( TT_Instance  instance,
  616.                               int          x_resolution,
  617.                               int          y_resolution );
  618.  
  619.      Set  the target device  resolution for  a given  instance.  The
  620.      values are expressed in dots  per inch (dpi).  A value of 96dpi
  621.      is typical for an SVGA  display, 72dpi for a Macintosh one, and
  622.      300 to 6000dpi for printers.
  623.  
  624.  
  625.   ..................................................................
  626.  
  627.   TT_Set_Instance_PointSize( TT_Instance  instance,
  628.                              int          pointsize );  
  629.  
  630.      Sets  the  point  size  for  a given  instance.   The  size  is
  631.      expressed in 'points', where 1  point = 1/72 inch.  The default
  632.      value is 10pt.
  633.  
  634.   ..................................................................
  635.  
  636.   TT_Set_Instance_Transform_Flags( TT_Instance instance,
  637.                                    int         rotated,
  638.                                    int         stretched );
  639.  
  640.      Set the transform flags for  a given instance.  These flags are
  641.      passed to  the interpreter each  time a glyph is  loaded within
  642.      the  instance.   Their role  is  to  notify  the glyph  hinting
  643.      mechanism  that the resulting  glyph will  be transformed  in a
  644.      special  way.   Setting one  of  these  flags  to true  usually
  645.      disables hinting,  though this behaviour varies  with each font
  646.      file.
  647.  
  648.      NOTE:
  649.      The glyph loader doesn't perform the rotation or the stretching
  650.      itself; this must be done explicitly by the client application.
  651.      Use the function TT_Apply_Outline_Matrix() for that purpose.
  652.  
  653.   ..................................................................
  654.  
  655.   TT_Get_Instance_Metrics( TT_Instance           instance,
  656.                            TT_Instance_Metrics*  imetrics );
  657.  
  658.      This call returns a given instance's current metrics.  They are
  659.      returned  in the  'imetrics' structure,  which  contains, among
  660.      other  things,  the  current   point  size,  ppem,  and  device
  661.      resolution (horizontal and vertical).
  662.  
  663.   ..................................................................
  664.  
  665.   TT_Done_Instance( TT_Instance  instance );
  666.  
  667.      Close a given instance  object, destroying its associated data.
  668.      Note that this is performed automatically when a face is closed
  669.      on all its child instances.  However, explicit deallocation can
  670.      help in freeing the memory used by the application earlier.
  671.  
  672.   ..................................................................
  673.  
  674.   TT_New_Glyph( TT_Face    face,
  675.                 TT_Glyph*  glyph );
  676.  
  677.      Create  a  new glyph  container  for  the  glyphs of  the  font
  678.      described by the 'face' handle.   A pointer to the container is
  679.      returned  in 'glyph'.   The  face  is said  to  be the  glyph's
  680.      parent.
  681.  
  682.      Note  that a  glyph isn't  destroyed  when the  face object  is
  683.      destroyed.  You have  to discard it manually through  a call to
  684.      TT_Done_Glyph(),  or  automatically  when  closing  the  engine
  685.      through TT_Done_FreeType().
  686.  
  687.   ..................................................................
  688.  
  689.   TT_Done_Glyph( TT_Glyph  glyph );
  690.  
  691.      Discard a glyph container.  This is also done automatically for
  692.      all glyphs when closing the engine.
  693.  
  694.   ..................................................................
  695.  
  696.   TT_Load_Glyph( TT_Instance  instance,
  697.                  TT_Glyph     glyph,
  698.                  int          glyph_index,
  699.                  int          load_flags );
  700.  
  701.      Load  and  process (scale  and/or  hint)  a  glyph at  a  given
  702.      'instance' into the 'glyph' container.
  703.      
  704.      Note that  'glyph' and 'instance'  must have the  _same_ parent
  705.      face object, or an error message will be returned.
  706.      
  707.      'glyph_index'  is the glyph's  index as  found in  the TrueType
  708.      file.  It is _not_ a  character code (see the charmap functions
  709.      below).
  710.    
  711.      'load_flags' is an integer  that specifies which operations are
  712.      to be performed on the loaded glyph.  The following values/bits
  713.      are used:
  714.    
  715.    
  716.          TTLOAD_SCALE_GLYPH
  717.    
  718.             Indicates  that   the  glyph  must  be   scaled  to  the
  719.             instance's  resolution.  The pixel  coordinates returned
  720.             in  the glyph  outline  structure (see  below) are  then
  721.             expressed in  fractional pixels represented  in the 26.6
  722.             fixed  point   floating  format  defined   by  Apple  as
  723.             'F26Dot6'.
  724.    
  725.             If scaling is disabled,  the coordinates returned in the
  726.             outline structure are  integers, also called 'FUnits' by
  727.             the TrueType specification.
  728.    
  729.    
  730.          TTLOAD_HINT_GLYPH
  731.    
  732.             This flag is only valid  when scaling is on.  It informs
  733.             the  loader   that  the  glyph  must   be  hinted  (i.e.
  734.             grid-fitted  for optimal  display).   Note that  hinting
  735.             will  occur only if  the instance's  transformations and
  736.             metrics  allow  it  (for  example,  most  font  programs
  737.             disable  hinting automatically  in case  of  rotation or
  738.             stretching).
  739.  
  740.        NOTE:
  741.        You can also use the constant TTLOAD_DEFAULT, which is simply
  742.        the  union of  TTLOAD_SCALE_GLYPH  and TTLOAD_HINT_GLYPH  for
  743.        most 'typical' loads.
  744.   
  745.   ..................................................................
  746.  
  747.   TT_Get_Glyph_Outline( TT_Glyph           glyph,
  748.                         TT_Glyph_Outline*  outline );
  749.  
  750.      This  call returns  the glyph's  'outline'.  This  is  a simple
  751.      structure which contains pointers  to the data used to describe
  752.      an   outline  to   the  rasterizer.   See  the   definition  of
  753.      TT_Glyph_Outline() in section I.
  754.  
  755.   ..................................................................
  756.  
  757.   TT_Get_Glyph_Metrics( TT_Glyph           glyph,
  758.                         TT_Glyph_Metrics*  metrics );
  759.  
  760.      Extract  the glyph's metrics  and copy  them to  the '*metrics'
  761.      structure.  Its format is described in section I.
  762.  
  763.      When the glyph has been  loaded without scaling, the values are
  764.      expressed  in FUnits  (integers relative  to the  original font
  765.      grid called the EM Square).
  766.  
  767.      When the  glyph has  been loaded _with_  scaling, which  is the
  768.      default, the  values are expressed in fractional  pixels in the
  769.      26.6 fixed  point float format  called F26Dot6 (where 1  unit =
  770.      1/64th of a pixel).
  771.  
  772.   ..................................................................
  773.  
  774.   TT_Get_Glyph_Bitmap( TT_Glyph        glyph,
  775.                        TT_Raster_Map*  bitmap,
  776.                        TT_F26Dot6      x_offset,
  777.                        TT_F26Dot6      y_offset );
  778.  
  779.      This call converts the vectorial glyph representation contained
  780.      in the object handled by 'glyph' into a bitmap.
  781.  
  782.      The  target  bitmap  is  described  by  the  'bitmap'  pointer.
  783.      Clipping will  be done if  necessary.  You can also  specify an
  784.      offset   to  be  applied   before  the   scan-line  conversion;
  785.      'x_offset'  and  'y_offset'  must  be expressed  in  fractional
  786.      pixels (where 1 unit = 1/64th pixel).
  787.  
  788.      NOTE1:
  789.        Choosing   non  integer  pixel   offsets,  i.e.,   values  of
  790.        'x_offset' and 'y_offset' that  are not multiples of 64, will
  791.        ruin the hinting performed  by the interpreter, and result in
  792.        bad rendering at small sizes.
  793.  
  794.      NOTE2:
  795.        The glyph's  point coordinates must be  scaled before calling
  796.        this function.   Never call this  function with a  glyph that
  797.        were loaded with no scaling!
  798.  
  799.   ..................................................................
  800.  
  801.   TT_Get_Glyph_Pixmap( TT_Glyph        glyph,
  802.                        TT_Raster_Map*  pixmap,
  803.                        TT_F26Dot6      x_offset,
  804.                        TT_F26Dot6      y_offset );
  805.  
  806.      This call converts the vectorial glyph representation contained
  807.      in  the object  handled  by  'glyph' into  a  pixmap (i.e.,  an
  808.      8-bit/pixel map).  The result is an anti-aliased version of the
  809.      glyph (a.k.a. font-smoothing).
  810.  
  811.      The target  pixmap is described by the  'pixmap' pointer.  Note
  812.      that  its  width _must_  be  a multiple  of  4.   For a  pixmap
  813.      definition and description, see Section I.
  814.  
  815.      As with  TT_Get_Glyph_Bitmap(), you  can specify offsets  to be
  816.      applied before the rendering ('x_offset' and 'y_offset' must be
  817.      expressed in fractional pixel coordinates).
  818.  
  819.      NOTE1:
  820.        You  don't  need  to   supply  a  temporary  bitmap  for  the
  821.        anti-aliaser.  The rasterizer uses its own scheme to optimize
  822.        memory uses.
  823.  
  824.      NOTE2:
  825.        The glyph's  point coordinates must be  scaled before calling
  826.        this function.  This means that you should never call it with
  827.        a glyph which has been loaded without scaling!
  828.  
  829.   ..................................................................
  830.  
  831.   TT_Apply_Outline_Matrix( TT_Glyph_Outline*  outline,
  832.                            TT_Matrix*         matrix );
  833.  
  834.      Apply a simple transformation  matrix on a given outline.  This
  835.      will  multiply each point  coordinate vector  by a  2x2 matrix,
  836.      which coefficients are written in the 16.16 fixed float format.
  837.  
  838.      Rotation can be performed with this function.
  839.  
  840.      NOTE:
  841.        This function takes an outline,  and not a glyph handle, as a
  842.        parameter.  This 'feature'  lets you apply transformations on
  843.        your own copies of glyphs.
  844.  
  845.   ..................................................................
  846.  
  847.   TT_Apply_Outline_Translation( TT_Glyph_Outline*  outline,
  848.                                 TT_F26Dot6         x_offset,
  849.                                 TT_F26Dot6         y_offset );
  850.  
  851.      Apply a simple translation on a given outline.
  852.  
  853.      NOTE:
  854.        This function takes an outline,  and not a glyph handle, as a
  855.        parameter.  This 'feature' lets you apply translation to your
  856.        own copies of glyphs.
  857.  
  858.   ..................................................................
  859.  
  860.   int TT_Get_CharMap_Count( TT_Face  face );
  861.   ^^^
  862.      Return the number of character mappings present in the TrueType
  863.      file described by the 'face' handle.  Returns zero if there are
  864.      no mappings, and -1 when the handle is invalid.
  865.  
  866.   ..................................................................
  867.  
  868.   TT_Get_CharMap_ID( TT_Face  face,
  869.                      int      charmapIndex,
  870.                      short*   platformID,
  871.                      short*   encodingID );
  872.  
  873.      Return the  platform ID  and platform-specific encoding  ID for
  874.      the charmap numbered 'charmapIndex'  in the 'face' object.  The
  875.      total  number of character  mapping tables  is returned  by the
  876.      TT_Get_CharMap_Count() function described above.
  877.  
  878.   ..................................................................
  879.  
  880.   TT_Get_CharMap( TT_Face      face,
  881.                   int          charmapIndex,
  882.                   TT_CharMap*  charMap );
  883.  
  884.      Return a handle for  the character map number 'charmapIndex' of
  885.      'face'.  The  handle is  placed in '*charMap'  and can  be used
  886.      later for fast lookup with the TT_Char_Index() API.
  887.  
  888.      Charmap objects  are  automatically  destroyed  when their face
  889.      object is destroyed.
  890.  
  891.   ..................................................................
  892.  
  893.   int TT_Char_Index( TT_CharMap  charMap,
  894.   ^^^                int         charCode );
  895.  
  896.      Apply a charMap to translate a charCode into a glyph index that
  897.      can be used to load and address a glyph in the TrueType file.
  898.  
  899.      The charmap handle can be obtained with TT_Get_CharMap().
  900.  
  901.   ..................................................................
  902.  
  903.   int TT_Get_Name_Count( TT_Face  face );
  904.   ^^^
  905.      Returns  the number  of name  strings  found in  a face's  name
  906.      table.  This function  will return zero when there  are no name
  907.      strings in the font file, and -1 if the face handle is invalid.
  908.  
  909.   ..................................................................
  910.  
  911.   TT_Get_Name_ID( TT_Face  face,
  912.                   int      nameIndex,
  913.                   short*   platformID,
  914.                   short*   encodingID,
  915.                   short*   languageID,
  916.                   short*   nameID );
  917.  
  918.      Return the  ID of  a given name  string, indexed by  the number
  919.      'nameIndex' in a  given face.  The name index  ranges from 0 to
  920.      the value returned by TT_Get_Name_Count() minus one.
  921.  
  922.      Each  string  has  a  platformID,  encodingID,  languageID  and
  923.      nameID, as defined by the TT specification.
  924.      
  925.      The platformID is typically in the 0..3 range.  Some font files
  926.      have  invalid name table  entries; these  can be  detected from
  927.      their platformID which is over 3.
  928.  
  929.   ..................................................................
  930.  
  931.   TT_Get_Name_String( TT_Face  face,
  932.                       int      nameIndex,
  933.                       char**   stringPtr,
  934.                       int*     length );
  935.  
  936.      Return  a  name string's  address  and  length.   Note that  an
  937.      invalid name table entry, detected  by a platformID > 3, always
  938.      returns NULL for 'stringPtr' and a zero length.
  939.  
  940.      Note: the string belongs to  the face object, and should not be
  941.            written to or freed by the client application.
  942.  
  943.   ..................................................................
  944.  
  945.   TT_Get_Kerning_Directory( TT_Face      face,
  946.                             TT_Kerning*  directory );
  947.  
  948.      Queries the  kerning directory found  in a face object.   If no
  949.      kerning  table  is  found  in  the  TrueType  file,  the  error
  950.      TT_Err_Table_Is_Missing will be returned.
  951.  
  952.      You  can  access the  subtables  through  the  pointers of  the
  953.      directory.  However,  by default, the directory  is only loaded
  954.      when a  face object  is created.  You  must load  the subtables
  955.      that interest you with a call to TT_Load_Kerning_Table().
  956.  
  957.      The layout  of all  kerning structures is  defined in  the file
  958.      "lib/extend/apikern.h".  Both formats (0  and 2) are exposed by
  959.      this API.
  960.  
  961.   ..................................................................
  962.  
  963.   TT_Load_Kerning_Table( TT_Face  face,
  964.                          int      kern_index );
  965.  
  966.      Load the kerning subtable number 'kern_index' into memory.  The
  967.      subtable can  be accessed through the pointers  provided by the
  968.      kerning     directory,    obtained     from    a     call    to
  969.      TT_Get_Kerning_Directory().
  970.  
  971.      Note that the interpretation of the kerning data is left to the
  972.      client application.   Read the TrueType  specification for more
  973.      information on kerning encoding.
  974.  
  975.  
  976.  
  977. III. Error Messages:
  978.  
  979.   Most functions return an error  code, typed to TT_Error.  A return
  980.   value of zero indicates no error.  The error values are defined in
  981.   the file 'freetype.h'.
  982.  
  983.  
  984.   Error   Unprefixed             Error
  985.   Code    Macro Name             Description          
  986.   ------------------------------------------------------------------
  987.  
  988.   0x0000  Ok                       Successful function call.
  989.                                    Always 0!
  990.  
  991.   ----------------- high-level API error codes ---------------------
  992.  
  993.   The following error codes are returned by the  high-level  API  to
  994.   indicate an invalid client request.
  995.  
  996.   0x0001  Invalid_Face_Handle      An invalid face object handle was
  997.                                    passed to an API function.
  998.  
  999.   0x0002  Invalid_Instance_Handle  An invalid instance object handle
  1000.                                    was passed to an API function.
  1001.  
  1002.   0x0003  Invalid_Glyph_Handle     An invalid glyph container handle
  1003.                                    was passed to an API function.
  1004.  
  1005.   0x0004  Invalid_CharMap_Handle   An invalid charmap handle was
  1006.                                    passed to an API function.
  1007.  
  1008.   0x0005  Invalid_Result_Address   An output parameter (a result)
  1009.                                    was given a NULL address in an
  1010.                                    API call.
  1011.  
  1012.   0x0006  Invalid_Glyph_Index      An invalid glyph index was passed
  1013.                                    to one API function
  1014.  
  1015.   0x0007  Invalid_Argument         An invalid argument was passed to
  1016.                                    one API function. Usually, this
  1017.                                    means a simple out-of-bounds
  1018.                                    error.
  1019.  
  1020.   0x0008  Could_Not_Open_File      The pathname passed doesn't point
  1021.                                    to an existing or accessible
  1022.                                    file.
  1023.  
  1024.   0x0009  File_Is_Not_Collection   Returned by TT_Open_Collection
  1025.                                    when trying to open a file which
  1026.                                    isn't a collection.
  1027.  
  1028.   0x000A  Table_Missing            A mandatory TrueType table is
  1029.                                    missing from the font file.
  1030.                                    Denotes a broken font file.
  1031.  
  1032.   0x000B  Invalid_Horiz_Metrics    The font's HMTX table is broken.
  1033.                                    Denotes a broken font.
  1034.  
  1035.   0x000C  Invalid_CharMap_Format   A font's charmap entry has an
  1036.                                    invalid format.  Some other
  1037.                                    entries may be valid though.
  1038.  
  1039.   0x0010  Invalid_File_Format      The file isn't a TrueType font or
  1040.                                    collection
  1041.  
  1042.   ----------------- memory component error codes -------------------
  1043.  
  1044.   0x0100  Out_Of_Memory            An operation couldn't be
  1045.                                    performed due to memory
  1046.                                    exhaustion.
  1047.  
  1048.   ----------------- file component error codes ---------------------
  1049.  
  1050.   0x0200  Invalid_File_Offset      Trying to seek to an invalid
  1051.                                    portion of the font file.
  1052.                                    Denotes a broken file.
  1053.  
  1054.   0x0201  Invalid_File_Read        Trying to read an invalid portion
  1055.                                    of the font file.  Denotes a
  1056.                                    broken file.
  1057.  
  1058.   0x0202  Invalid_Frame_Access     Trying to frame an invalid
  1059.                                    portion of the font file.
  1060.                                    Denotes a broken file.
  1061.  
  1062.   ----------------- glyph loader error codes -----------------------
  1063.  
  1064.   These errors are  produced by  the  glyph loader.  They denote  an
  1065.   invalid glyph record within the font file.
  1066.  
  1067.   0x0300  Too_Many_Points          The glyph has too many points to
  1068.                                    be valid for its font file.
  1069.  
  1070.   0x0301  Too_Many_Contours        The glyph has too many contours
  1071.                                    to be valid for its font file.
  1072.  
  1073.   0x0302  Invalid_Composite_Glyph  A composite glyph's description
  1074.                                    is broken.
  1075.  
  1076.   0x0303  Too_Many_Ins             The glyph has too many
  1077.                                    instructions to be valid for its
  1078.                                    font file.
  1079.  
  1080.   ----------------- byte-code interpreter error codes --------------
  1081.  
  1082.   These  error   codes  are  produced  by   the   TrueType byte-code
  1083.   interpreter.  They usually indicate a broken font file or a broken
  1084.   glyph within a font.
  1085.  
  1086.   0x0400  Invalid_Opcode         Found an invalid opcode in a
  1087.                                  TrueType byte-code stream.
  1088.  
  1089.   0x0401  Too_Few_Arguments      An opcode was invoked with too few
  1090.                                  arguments on the stack.
  1091.  
  1092.   0x0402  Stack_Overflow         The interpreter's stack has been
  1093.                                  filled up and operations can't
  1094.                                  continue.
  1095.  
  1096.   0x0403  Code_Overflow          The byte-code stream runs out of
  1097.                                  its valid bounds.
  1098.  
  1099.   0x0404  Bad_Argument           A function received an invalid
  1100.                                  argument.
  1101.  
  1102.   0x0405  Divide_By_Zero         A division by 0 operation was
  1103.                                  queried by the interpreter program.
  1104.  
  1105.   0x0406  Storage_Overflow       The program tried to access data
  1106.                                  outside of its storage area.
  1107.  
  1108.   0x0407  Cvt_Overflow           The program tried to access data
  1109.                                  outside of its control value table.
  1110.  
  1111.   0x0408  Invalid_Reference      The program tried to reference an
  1112.                                  invalid point, zone or contour.
  1113.  
  1114.   0x0409  Invalid_Distance       The program tried to use an invalid
  1115.                                  distance.
  1116.  
  1117.   0x040A  Interpolate_Twilight   The program tried to interpolate
  1118.                                  twilight points.
  1119.  
  1120.   0x040B  Debug_Opcode           The now invalid 'debug' opcode was
  1121.                                  found in the byte-code stream.
  1122.  
  1123.   0x040C  ENDF_In_Exec_Stream    A misplaced ENDF was encountered in
  1124.                                  the byte-code stream.
  1125.  
  1126.   0x040D  Out_Of_CodeRanges      The program tried to allocate too
  1127.                                  much code ranges (this is really an
  1128.                                  engine internal error that should
  1129.                                  never happen).
  1130.  
  1131.   0x040E  Nested_DEFS            Nested function definitions 
  1132.                                  encountered.
  1133.  
  1134.   0x040F  Invalid_CodeRange      The program tried to access an
  1135.                                  invalid code range.
  1136.  
  1137.   ----------------- internal failure error codes -------------------
  1138.  
  1139.   These error codes are produced if  an incoherent library state has
  1140.   been detected.   All of these reflect  a severe bug  in the engine
  1141.   (or a severe memory corruption  due to massive overwrites by  your
  1142.   application into the library's data)!
  1143.  
  1144.   If you do  encounter a font that   makes one of the  test programs
  1145.   produce such an error, please report it!
  1146.  
  1147.   0x0500  Nested_Frame_Access
  1148.   0x0501  Invalid_Cache_List
  1149.   0x0502  Could_Not_Find_Context
  1150.   0x0503  Unlisted_Object
  1151.  
  1152.   ----------------- scan-line converter error codes ----------------
  1153.  
  1154.   These  error codes are  produced  by  the raster  component.  They
  1155.   indicate that   an outline structure  was incoherently  set up, or
  1156.   that you're trying to render a horribly complex glyph.
  1157.  
  1158.   They should be _extremely_ rare, however.
  1159.  
  1160.   0x0600  Raster_Pool_Overflow   Render pool overflow. This should
  1161.                                  never happen in this release.
  1162.  
  1163.   0x0601  Raster_Negative_Height
  1164.                                  A negative height was produced.
  1165.  
  1166.   0x0602  Raster_Invalid_Value   The outline data wasn't set
  1167.                                  properly. Check that:
  1168.                                    points >= endContours[contours]
  1169.  
  1170.   0x0603  Raster_Not_Initialized
  1171.                                  You did not call TT_Init_FreeType!
  1172.  
  1173.   ----------------- engine extensions error codes ------------------
  1174.  
  1175.   The engine's extensions also provide their own error codes, within
  1176.   their own group:
  1177.  
  1178.   0x0A00  Invalid_Kerning_Table_Format
  1179.                                  A kerning subtable format was found
  1180.                                  invalid in this font.
  1181.  
  1182.  
  1183. --- end of apiref.txt ---
  1184.