home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / ft-beta.zip / freetype / docs / user.txt < prev   
Text File  |  1997-10-06  |  32KB  |  863 lines

  1.  
  2.             The FreeType Engine
  3.  
  4.               Core Library User Guide
  5.  
  6.                  or
  7.  
  8.     How to use the engine in your applications and font servers
  9.               by David Turner
  10.  
  11.     ---------------------------------------------------
  12.  
  13.                 Introduction
  14.  
  15.  
  16.              I. Basic Concepts:
  17.   
  18.                        1. Concepts
  19.                        2. Handles
  20.                        3. Conventions of use
  21.                        4. Object classes
  22.  
  23.               II. Extensions:
  24.  
  25.                      1. What is an extension?
  26.                      2. Where to find them
  27.                      3. Writing your own extension
  28.  
  29.                              Conclusion
  30.  
  31.             ----------------------------
  32.  
  33. Introduction:
  34.  
  35. This file has  been written to present the  FreeType core library to
  36. would-be  writers  of  applications  and  font  servers.   It  first
  37. describes the concepts on which the engine is based, then how to use
  38. it to obtain glyph metrics, outlines and bitmaps.
  39.  
  40. The last part discusses the ability to add and use extensions to the
  41. core library to get access to supplemental TrueType tables which are
  42. not currently  provided by  the core engine.   If you would  like to
  43. write your own extensions, read also the FreeType developer's guide.
  44.  
  45.  
  46.  
  47. I. Basic Concepts:
  48.  
  49.  
  50. 1. Concepts:
  51.  
  52.     FreeType defines several  kinds of structures, called "objects",
  53.     that  are used to  manage the  various abstractions  required to
  54.     access and display fonts.
  55.  
  56.     In a care of good  encapsulation, these objects are not directly
  57.     accessible from a client application.  Rather, the user receives
  58.     a 'handle'  for each object it  queries and wants  to use.  This
  59.     handle  is a  stand-alone reference,  it cannot  be used  like a
  60.     pointer to access directly the object's data.
  61.  
  62. 2. Properties:
  63.  
  64.     It  is however  possible  to obtain  and  set object  properties
  65.     through  several  functions of  the  API.   For  example, it  is
  66.     possible to query a face  object's properties with only a handle
  67.     for it, using the function TT_Get_Face_Properties().
  68.  
  69.     Note  that  the  data  will  be  returned  in  a  user-allocated
  70.     structure,  but will also  contain pointers  addressing directly
  71.     some data found within the object.
  72.  
  73.     A client application should  never modify the data through these
  74.     pointers!  In order to set new properties' values, the user must
  75.     always call  a specific  API to  do so, as  a certain  number of
  76.     other related  data might not  appear in the  returned structure
  77.     and imply various non-visible coherency and coercion rules.
  78.  
  79.     NOTE:
  80.  
  81.     A notable  exception to this rule  is the ability  to move point
  82.     coordinates in a glyph  container's outline through the pointers
  83.     returned by TT_Get_Glyph_Outline.  However, this operation isn't
  84.     necessary for most programs.
  85.  
  86.  
  87. 3. Conventions of use:
  88.  
  89.      o All API functions have their label prefixed by 'TT_', as well
  90.        as all external (i.e. client-side) types.
  91.  
  92.  
  93.      o To allow  the  use  of  FreeType's  core  engine in  threaded
  94.        environments, nearly all API  functions return an error code,
  95.        which is always set to 0 in case of success.
  96.  
  97.        The error codes'  type is TT_Error, and a  listing of them is
  98.        given in the API reference (see "apiref.txt").
  99.  
  100.        Some functions do not return  an error code.  Their result is
  101.        usually a value that takes  a negative value in case of error
  102.        (this is used for functions  where only one kind of error can
  103.        be reported, like an invalid glyph index).
  104.  
  105.        An important note  is that the engine should  not leak memory
  106.        when  returning an error,  e.g. querying  the creation  of an
  107.        object  will allocate  several internal  tables that  will be
  108.        freed if a disk error occurs during a load.
  109.  
  110.  
  111.      o A handle is acquired through API functions labelled along the
  112.        names:
  113.  
  114.           TT_Open_xxxx(), TT_New_xxxx()
  115.  
  116.           where xxxx is the object's class (Face, Instance, etc.)
  117.  
  118.           examples:
  119.  
  120.              TT_Open_Face(), TT_Open_Collection(),
  121.              TT_New_Instance(), TT_New_Glyph()
  122.  
  123.  
  124.      o A handle is closed through an API labelled
  125.  
  126.           TT_Close_xxxx() or TT_Done_xxxx()
  127.  
  128.           where xxxx is the object's class (Face, Instance, etc.)
  129.  
  130.           examples:
  131.              TT_Close_Face(), TT_Done_Instance(), TT_Done_Glyph()
  132.  
  133.  
  134.      o Properties are obtained through an API labelled
  135.  
  136.           TT_Get_xxxx_yyyy()
  137.  
  138.           where xxxx is the object's class, and yyyy its property
  139.  
  140.           examples:
  141.  
  142.              TT_Get_Face_Properties(), TT_Get_Instance_Metrics()
  143.              TT_Get_Glyph_Outline(), TT_Get_Glyph_Bitmap()
  144.  
  145.  
  146.      o Properties are set through an API labelled
  147.  
  148.           TT_Set_xxxx_yyyy()
  149.           
  150.           where xxxx is the object's class, and yyyy its property
  151.  
  152.           examples:
  153.  
  154.              TT_Set_Instance_Resolution(),
  155.              TT_Set_Instance_Pointsize()
  156.  
  157.  
  158. 4. Object Classes:
  159.  
  160.     The following object classes are  defined in this release of the
  161.     engine:
  162.  
  163.     * The Face objects:
  164.  
  165.         A  face contains  the  data  that is  specific  to a  single
  166.         TrueType font  file.  It presents information  common to all
  167.         glyphs and  all point  sizes like font-specific  metrics and
  168.         properties.
  169.  
  170.         You can  open a face object  by simply giving  a pathname to
  171.         the TrueType  file.  You can later close  (i.e. discard) the
  172.         face object.
  173.  
  174.         You  can also  open a  single  face embedded  in a  TrueType
  175.         collection.
  176.  
  177.         See also:
  178.  
  179.            TT_Open_Face(), TT_Open_Collection(), TT_Close_Face(),
  180.            TT_Get_face_Properties()
  181.  
  182.  
  183.      * The Instance objects:
  184.  
  185.         An instance is also called  a 'pointsize' or a 'fontsize' in
  186.         some windowing  systems.  An instance  holds the information
  187.         used to render glyphs on  a specific device at a given point
  188.         size; it is always related to an opened face object.
  189.  
  190.         For instance, if  you want to generate glyphs  for text from
  191.         the same  typeface at 'sizes' of  10 and 12  points, all you
  192.         need  is  one face  object,  from  which  you'll create  two
  193.         distinct instances.
  194.         
  195.         A  device   is  defined  by  its   horizontal  and  vertical
  196.         resolution,  usually specified  in dots  per inch  (dpi).  A
  197.         point size  is a scaling number, given  as _absolute_ values
  198.         in points, where 1 point = 1/72 inch.
  199.  
  200.         The 'pixel' size, also known as the 'ppem' value (for Points
  201.         Per EM  square) is computed from both  the device resolution
  202.         and the point size.  It determines the size of the resulting
  203.         glyph bitmaps on your screen or sheet of paper.
  204.  
  205.         The default device resolution  for any new instance is 96dpi
  206.         in both  directions, which corresponds to  VGA screens.  The
  207.         default point  size is 10pt.  The high-level  API allows you
  208.         to  change this  whenever you  want for  any  given instance
  209.         object.
  210.  
  211.         Note that  closing a face object  will automatically destroy
  212.         all its  child instances (even  though you can  release them
  213.         yourself to free memory).
  214.  
  215.         See also:
  216.  
  217.           TT_New_Instance(), TT_Done_Instance(),
  218.           TT_Get_Instance_Metrics(), TT_Set_Instance_Resolution(),
  219.           TT_Set_Instance_Pointsize()
  220.  
  221.  
  222.      * The Glyph objects:
  223.  
  224.         A Glyph object is a  _container_ for the data that describes
  225.         any glyph  of a  given font.  This  means that  it typically
  226.         holds:
  227.  
  228.          - glyph metrics  information, like bounding  box or advance
  229.            width.
  230.  
  231.          - outline arrays, sized large enough to hold any glyph from
  232.            the  face.   This  size  is  extracted  from  the  face's
  233.            internal 'maxProfile' table to optimize memory costs.
  234.  
  235.          - other   important  parameters   related  to   the  'fine'
  236.            rendering of  the glyphs.  This includes  things like the
  237.            dropout-control mode used at low sizes.
  238.  
  239.          - and it doesn't contain a bitmap or a pixmap!
  240.  
  241.         A glyph object is used  to load, hint and rasterize a single
  242.         glyph, as taken from the font file.
  243.  
  244.         See also:
  245.  
  246.           TT_New_Glyph(), TT_Done_Glyph(), TT_Get_Glyph_Metrics(),
  247.           TT_Get_Glyph_Outline(), TT_Get_Glyph_Bitmap(),
  248.           TT_Get_Glyph_Pixmap()
  249.  
  250.  
  251.      * The Character Map (CharMap) handle:
  252.  
  253.         Glyphs  can be  indexed in  a  TrueType file  in any  order,
  254.         independent of  any standard character  encoding, like ASCII
  255.         or Unicode.   For this reason,  each file comes with  one or
  256.         more character  mapping tables,  used to translate  from one
  257.         specific encoding's charcodes to font glyph indexes.
  258.  
  259.         There  are  many  encoding  formats,  and each  one  can  be
  260.         distinguished by two values:
  261.  
  262.            - its platform ID
  263.            - its platform-specific encoding ID
  264.  
  265.         Their values  are defined in the  TrueType specification and
  266.         won't be commented there.
  267.  
  268.         It  is possible  to  enumerate the  charmaps  provided by  a
  269.         TrueType  font   and  to  use   any  of  these   to  perform
  270.         translations.
  271.  
  272.         The charmaps are loaded in memory only on demand to save the
  273.         space taken by the maps  that are not needed on your system.
  274.         They are part of the face object, however.
  275.  
  276.         This  means  that even  though  a  charmap  can be  accessed
  277.         through  a  handle  (obtained through  the  TT_Get_CharMap()
  278.         function), it isn't a  stand-alone object.  For example, you
  279.         never need to de-allocate  it; this is done automatically by
  280.         the engine when its face object expires.
  281.  
  282.         See also:
  283.  
  284.           TT_Get_CharMap_Count(), TT_Get_CharMap_ID(),
  285.           TT_Get_CharMap(), TT_Char_Index().
  286.  
  287.  
  288. II. Step-by-step Example:
  289.  
  290.   Here  is  an  example  to  show,  step by  step,  how  one  client
  291.   application can  open a font  file, set one or  several instances,
  292.   load any glyph, then render it to a bitmap.
  293.  
  294.   a. Initialize the engine:
  295.  
  296.     This  is the  first thing  to do.   You need  to  initialize the
  297.     engine through a call to TT_Init_FreeType().  This function will
  298.     set up a various number of structures needed by the library.
  299.  
  300.     This allocates about 68kByte,  of which 64kByte are dedicated to
  301.     the scan-line  converter's "render  pool", a workspace  used for
  302.     bitmap generation.  Note that even though this space is bounded,
  303.     the raster is able to render a glyph to any size or bitmap.
  304.  
  305.     NOTE: You  can reduce  the size  of this  pool by  modifying the
  306.           constant  RASTER_RENDER_POOL  in  the  file  'ttraster.c'.
  307.           Take care  of never assigning a value  smaller than 4kByte
  308.           however.  A  smaller pool will result  in slower rendering
  309.           at large sizes.
  310.  
  311.   b. Open the font file:
  312.  
  313.     There are  two ways to open  a font face, depending  on its file
  314.     format:
  315.  
  316.      - If it's  a TrueType  file (ttf), you  can simply use  the API
  317.        named  TT_Open_Face(),  which takes  the  file's pathname  as
  318.        argument, as well as the address of the returned face handle.
  319.  
  320.        Check the  returned error  code to see  if the file  could be
  321.        opened and accessed successfully.
  322.  
  323.          TT_Face  face;  /* face handle */
  324.  
  325.          error = TT_Open_Face( "c:\work\ttf\wingding.ttf", &face );
  326.          if ( error )
  327.          {
  328.            printf( "could not open the file\n" );
  329.            ...
  330.          }
  331.  
  332.  
  333.      - If the font  is embedded in a TrueType  collection (ttc), you
  334.        can use the API  named TT_Open_Collection(), which takes also
  335.        the font's index within the collection's directory.
  336.  
  337.          TT_Face  face;  /* face handle */
  338.  
  339.          /* Load the collection's second face (index=1) */
  340.          error = TT_Open_Collection( "c:\work\ttf\whatever.ttc",
  341.                                      1, &face );
  342.          if ( error )
  343.          {
  344.            printf( "could not open the file\n" );
  345.            ...
  346.          }
  347.  
  348.  
  349.      - Finally, when you do not know the number of faces embedded in
  350.        a TrueType collection, the following technique can be used:
  351.  
  352.         o call  TT_Open_Face() with the  collection file's pathname.
  353.           This API  recognizes collections automatically  and always
  354.           return a handle for its first embedded font.
  355.  
  356.         o get       the       face's        properties       through
  357.           TT_Get_Face_Properties().   These   contain,  among  other
  358.           things, the maximum font collection index that can be used
  359.           in a  call to the  API TT_Open_Collection(), in  its field
  360.           'max_Faces'.
  361.  
  362.  
  363.              TT_Face             face;  /* face handle     */
  364.              TT_Face_Properties  props; /* face properties */
  365.     
  366.              /* open the first collection font */
  367.              error = TT_Open_Face( "c:\work\ttf\collection.ttc",
  368.                                    &face );
  369.              if ( error )
  370.              {
  371.                printf( "could not open the file\n" );
  372.                ...
  373.              }
  374.     
  375.              /* Get the face properties */
  376.              TT_Get_Face_Properties( face, &props );
  377.     
  378.              /* Now print the number of faces */
  379.              printf( "there are %d faces in this collection file\n",
  380.                      props->max_Faces + 1 );
  381.  
  382.  
  383.   c. Create an instance from the face object:
  384.  
  385.      You must create an  instance (a.k.a a pointsize) which contains
  386.      information relative to  the target output device's resolutions
  387.      and a given point size.
  388.  
  389.      o The instance object is created through TT_New_Instance():
  390.  
  391.            TT_Instance  instance;
  392.  
  393.            error = TT_New_Instance( face, &instance );
  394.            if ( error )
  395.            {
  396.              printf( "could not create instance\n" );
  397.              ...
  398.            }
  399.  
  400.        TECHNICAL NOTE:
  401.        Creating a new instance  executes its font program.  This can
  402.        fail if the font is broken.  Never assume that the error code
  403.        returned here is always 0.
  404.  
  405.      o You  must set the  instance's properties to suit  your needs.
  406.        They   are  simply  its   device  resolutions,   set  through
  407.        TT_Set_Instance_Resolution(), and its point size, set through
  408.        TT_Set_Instance_Pointsize():
  409.  
  410.          /* set the target horizontal and vertical resolution to */
  411.          /* 300dpi in each direction (typically for a printer)   */
  412.          /* A fresh instance's default resolutions are 96dpi in  */
  413.          /* both directions.                                     */
  414.          error = TT_Set_Instance_Resolution( instance, 300, 300 );
  415.          if ( error )
  416.          {
  417.             printf( "could not set resolution" );
  418.             ...
  419.          }
  420.  
  421.          /* Now set the point size. Default is 10pt. */
  422.          error = TT_Set_Instance_Pointsize( instance, 12 );
  423.          if ( error )
  424.          {
  425.            printf( "could not set point size" );
  426.            ...
  427.          }
  428.  
  429.          TECH NOTE:
  430.          These calls may execute  the font's prep program, which can
  431.          fail when the font is  broken.  Never assume that the error
  432.          codes returned there are always successful.
  433.  
  434.  
  435.      o You can also set  the instance's transformation flags to tell
  436.        the  glyph loading function  that you're  going to  perform a
  437.        transformation  (like  rotation or  slanting)  on the  glyph.
  438.        Note   that   the    glyph   loader   doesn't   perform   the
  439.        transformation.    It  only   informs  the   glyphs'  hinting
  440.        instruction  streams about these  flags which  may use  it to
  441.        disable  or enable  various features  (grid-fitting, drop-out
  442.        control etc).
  443.  
  444.  
  445.            TT_Set_Instance_Transforms( FALSE, TRUE );
  446.  
  447.            to indicate that you're going to stretch, but not rotate,
  448.            this  instance's  glyphs.  Default  is, of  course,  both
  449.            FALSE.
  450.  
  451.  
  452.   d. Create a glyph container:
  453.  
  454.      You need a glyph object to  serve as a container for the glyphs
  455.      you want to load from the face.  This is done simply by
  456.  
  457.            TT_Glyph  glyph;  /* glyph object handle */
  458.  
  459.            error = TT_New_Glyph( face, &glyph );
  460.            if ( error )
  461.            {
  462.              printf( "could not create glyph\n" );
  463.              ...
  464.            }
  465.  
  466.      Note that in  spite of the fact that a  glyph is always related
  467.      to a given face, the glyph isn't destroyed when its parent face
  468.      object is discarded, unlike instances.
  469.  
  470.  
  471.   e. Load the glyph:
  472.  
  473.      The  glyph loader  is easily  queried  through TT_Load_Glyph().
  474.      This API function takes several arguments:
  475.  
  476.       o an  instance  handle, to  specify  at which  point size  and
  477.         resolution   the   loaded  glyph   should   be  scaled   and
  478.         grid-fitted.
  479.  
  480.       o a glyph container, used  to hold the glyph's data in memory.
  481.         Note  that the  instance and  the glyph  must relate  to the
  482.         _same_ font  file.  An  error would be  produced immediately
  483.         otherwise.
  484.  
  485.       o a glyph  index, used to reference the  glyph within the font
  486.         file.  This index is not a platform specific character code.
  487.         Charmap objects are provided  to translate from charcodes to
  488.         glyph  indexes.  All  you need  is to  know  your platform's
  489.         encoding IDs  according to the  TrueType specification, then
  490.         to obtain a charmap for it  (if the font comes with it), and
  491.         finally  to use it  through TT_Char_Index()  to get  a glyph
  492.         index.   We  strongly recommend  using  the Unicode  charmap
  493.         whenever possible.
  494.  
  495.       o a  load mode, indicating  what kind of operations  you need.
  496.         There are only two defined:
  497.  
  498.            TTLOAD_SCALE_GLYPH:
  499.  
  500.               When set,  this flag  indicates that the  loaded glyph
  501.               will be scaled to fractional pixel coordinates (26.6).
  502.               If  not, the coordinates  will remain  integer FUnits.
  503.               Please  refer to  the TrueType  specification  and the
  504.               FreeType  header files  for more  details on  the 26.6
  505.               format and other data types.
  506.  
  507.            TTLOAD_HINT_GLYPH:
  508.  
  509.               This    flag   is    only   in    effect    when   the
  510.               TTLOAD_SCALE_GLYPH flag is set.  It indicates that the
  511.               glyph  must  also be  'hinted',  or 'grid-fitted'  for
  512.               better display results.
  513.  
  514.         You can  'or' the flags  simply.  As most  applications will
  515.         require both flags to be set, the constant TTLOAD_DEFAULT is
  516.         defined as:
  517.  
  518.            #define TTLOAD_DEFAULT  (TTLOAD_SCALE_GLYPH | \
  519.                                     TTLOAD_HINT_GLYPH )
  520.  
  521.  
  522.     example:
  523.  
  524.       error = TT_Load_Glyph( instance, glyph, 65, TTLOAD_DEFAULT );
  525.       if ( error )
  526.       {
  527.         printf("could not load the glyph\n");
  528.         ...
  529.       }
  530.  
  531.  
  532.   f. Query glyph properties:
  533.  
  534.      You're then able to query various glyph properties:
  535.  
  536.      o The    glyph     metrics    can    be     obtained    through
  537.        TT_Get_Glyph_Metrics().   The data  returned  in the  metrics
  538.        structure is:
  539.  
  540.          - the glyph's left side bearing
  541.          - the glyph's advance width
  542.          - the glyph's bounding box
  543.          - its drop out control mode for better rendering
  544.  
  545.        These values are expressed in 26.6 pixel units when the glyph
  546.        was loaded with scaling, or in FUnits if not.
  547.  
  548.      o The     glyph    outline     can    be     queried    through
  549.        TT_Get_Glyph_Outline().   This can be  useful to  process the
  550.        points  coordinates (e.g.   applying stretching  or rotation)
  551.        with    functions   like    TT_Apply_Outline_Transform()   or
  552.        TT_Apply_Outline_Translation().  Note that these functions do
  553.        not recompute a glyph's metrics after the transformation!
  554.  
  555.        The  outline's  structure   is  described  in  the  reference
  556.        "apiref.txt".
  557.  
  558.        A bitmap or pixmap for the glyph can be queried with the APIs
  559.        TT_Get_Glyph_Bitmap()   and   TT_Get_Glyph_Pixmap().    These
  560.        functions take  a glyph handle as  an argument, as  well as a
  561.        bitmap/pixmap description block and two offsets.
  562.  
  563.        The target  map is described through  a TT_Raster_Map object,
  564.        which   structure   is   defined   in  the   reference   (see
  565.        "apiref.txt").  The  offsets are given  in the same  units as
  566.        the points  coordinates and  glyph metrics: 26.6  pixel units
  567.        for a scaled glyph, and FUnits for an unscaled one.
  568.  
  569.        IMPORTANT TECH NOTE: **
  570.        ***********************
  571.  
  572.        When the glyph has been scaled and hinted, the offsets _must_
  573.        be multiples of 64  (i.e. integer pixel offsets).  Otherwise,
  574.        you would simply ruin the grid fitting (which usually results
  575.        in ugly glyphs).
  576.  
  577.    examples:
  578.  
  579.        TT_Glyph_Metrics   metrics;
  580.        TT_Glyph_Outline   outline;
  581.        TT_Raster_Map      bitmap;
  582.  
  583.        TT_Get_Glyph_Metrics( glyph, &metrics );
  584.        TT_Get_Glyph_Outline( glyph, &outline );
  585.  
  586.        /* set up the bitmap */
  587.        ...
  588.        TT_Get_Glyph_Bitmap( glyph, &bitmap, 0, 0 );
  589.  
  590.  
  591.   g. When you're done:
  592.  
  593.      o You  can  close any  font face  object  with TT_Close_Face().
  594.        This call will automatically  discard its child instances and
  595.        charmaps.  However,  the related glyph will  remain in memory
  596.        and  it is  the user's  responsibility  not to  use them  for
  597.        further loads.
  598.  
  599.      o You  can  also  close  the  engine  with  a  single  call  to
  600.        TT_Done_FreeType().  This  will simply release  _all_ objects
  601.        that were previously allocated, and close all font files.
  602.  
  603.  
  604. III. Extensions:
  605.  
  606. 1. What is an extension?
  607.  
  608.   FreeType allows you to access a various number of TrueType tables,
  609.   as well as to render individual glyphs. However:
  610.  
  611.   1 - it doesn't perform some high-level operations, like generating
  612.       a string text from many individual glyphs.
  613.  
  614.   2 - it doesn't perform kerning (which can be needed by topic 1).
  615.  
  616.   3 - it doesn't  give  access to  all the defined  TrueType tables,
  617.       especially the optional ones.
  618.  
  619.  
  620.   While point 1 is a feature that will never go into FreeType's core
  621.   engine,  which goal is  to provide  easy access  to font  data and
  622.   rendering _individual_ glyphs,  point 2 and 3 can  be added to the
  623.   engine's features through extensions.
  624.  
  625.   An  extension is simply  a small  piece of  code that  extends the
  626.   engine's abilities and APIs.  It  is possible to extend the engine
  627.   without  touching the  core's source  code, this  is  described in
  628.   chapter 3 below.
  629.  
  630.  
  631. 2. The two kinds of extensions:
  632.  
  633.   There  are  basically  two  kinds  of  extensions,  which  require
  634.   different implementations.
  635.  
  636.   a. API extensions:
  637.  
  638.     An API extension is a  set of functions that extend the FreeType
  639.     core API to give access to tables that are already loaded by the
  640.     engine, but not  provided for now.  An example  of such data can
  641.     be:
  642.  
  643.       - the horizontal metrics table (HMTX)
  644.       - the gasp table
  645.  
  646.     This kind of extension is made of:
  647.  
  648.      o an API extension  header file, following the usage convention
  649.        introduced here  (all labels prefixed with  'TT_'), and which
  650.        will  be  included by  the  clients  which  want to  use  the
  651.        extension.  By convention, such header names begin with 'ftx'
  652.        (for FreeType eXtension).
  653.  
  654.        examples: ftxgasp.h, ftxhtmx.h
  655.   
  656.      o One or more functions used  to give access to the tables that
  657.        are already  loaded and managed by the  engine.  They usually
  658.        only  copy pointers  to  the target  structure  given by  the
  659.        client application since  these structures are not accessible
  660.        through the 'normal' API.
  661.  
  662.  
  663.   b. engine extensions:
  664.  
  665.     It can  be sometimes  useful to load  and manage  several tables
  666.     that are  not considered by  the core engine.   These extensions
  667.     need  to provide  additional  functions to  fit into  FreeType's
  668.     internal  object management  model, and  are  more sophisticated
  669.     than API extensions.
  670.  
  671.     An  example is  given in  this distribution  to  provide kerning
  672.     support  (or  more technically  spoken,  access  to the  kerning
  673.     tables found within the TrueType files). It is made of:
  674.  
  675.     o An  API  extension  providing  new  interfaces  to the  client
  676.       applications that need it. See the file "ftxkern.h".
  677.  
  678.     o A specific implementation,  providing services to create, load
  679.       and  manage  kerning tables  as  additional  parts  of a  face
  680.       object.  In  the case of  kerning, the directory of  tables is
  681.       loaded  when the  face is  opened, and  tables  themselves are
  682.       fetched from the file on demand.  This implies several 'hooks'
  683.       in the  core engine. See the files  "ttkern.h" and "ttkern.c".
  684.       These are called 'engine extensions'.
  685.  
  686.  
  687. 3. Writing your own extensions:
  688.  
  689.     As it was  suggested earlier, writing an engine  extensions is a
  690.     delicate process,  as the additional code must  follow a certain
  691.     number  of design  rules,  presented in  the FreeType  developer
  692.     guide.  There  is also an  extension writer's guide in  the file
  693.     "extend.txt".
  694.  
  695.     ** NOTE **: The developer  and  extension writer guides  are not
  696.                 present in this beta.   These documents will be part
  697.                 of FreeType 1.0, however.
  698.  
  699.     By writing your  own extensions, it will be  possible to support
  700.     more advanced TrueType formats like TrueType GX or OpenType in a
  701.     near future, without having to torture the engine core source at
  702.     each iteration.
  703.  
  704.     If you  encounter some difficulties  when trying to  create your
  705.     own extension,  please read the core source  file carefully, and
  706.     in the  event that you may  need changes that are  not fitted to
  707.     the current extension mechanism,  do not hesitate to contact the
  708.     authors at 'freetype-devel@lists.lrz-muenchen.de'
  709.  
  710.     
  711. Conclusion:
  712.  
  713.    This  is  the  first   version  of  this  document,  released  in
  714.    FreeType's first public  beta.  We consider it as  a "real" beta,
  715.    i.e., a functional  version with a complete API,  released to the
  716.    public to help us find bugs.
  717.  
  718.    We invite  you to  read the test  programs' source code  to learn
  719.    more about the high-level interface.
  720.  
  721.    The API is now considered  frozen, and won't evolve in the future
  722.    unless we encounter important  incoherencies which must be fixed.
  723.    Unlike the four previous alphas,  we invite you to test and start
  724.    development of your own tools based on this API.
  725.  
  726.    The engine's internals may still vary during this last phase, and
  727.    we may  decide to make some  of the provided  extensions parts of
  728.    the core engine, but this  should not affect the already existing
  729.    APIs.
  730.  
  731.    We hope you have success and fun in using this engine.  Much time
  732.    has been taken to make it one of the best in its genre.  Remember
  733.    that it  is not  intended to  be a complete  font server  or text
  734.    rendering library,  but a  pretty solid base  for these  kinds of
  735.    applications, as well as others.
  736.  
  737.    We would  like you to report  the bugs you  find, _after_ reading
  738.    the current bug report at our web page:
  739.  
  740.       http://www.physiol.med.tu-muenchen.de/~robert/freetype.html
  741.  
  742.    We have already many  volunteers for the current projects, though
  743.    additional help can still be useful:
  744.  
  745.       - an OS/2 font server based on FreeType
  746.  
  747.       - an X11 font server based on FreeType
  748.  
  749.       - TrueType support for the Wine Windows emulator
  750.  
  751.       - ttf2bdf, a  conversion tool  for producing bitmaps  from TTF
  752.         files
  753.  
  754.  
  755.    We also welcome volunteers to the following ideas:
  756.  
  757.  
  758.       - a text rendering library based on FreeType.
  759.  
  760.           To  provide  various  features  that are  not  covered  by
  761.           FreeType's core library,  like string text rendering (with
  762.           or  without  kerning, with  or  without gray-scaling  like
  763.           Win95), rotation, stretching, blitting, etc.
  764.  
  765.           This library would be  of great help for many environments
  766.           which cannot  access a TrueType renderer.  It  can also be
  767.           the base  of some extended font servers  for some specific
  768.           systems.
  769.  
  770.  
  771.       - a font server for  any graphical system that doesn't support
  772.         TrueType properly.
  773.  
  774.           OS/2  and  BeOS  come  to  mind as  systems  that  provide
  775.           mediocre  TrueType support, which  is not  surprising when
  776.           one sees  the fuzzy  quality of the  specs.  Note  that we
  777.           already have an OS/2 renderer on its way.
  778.  
  779.           Some systems, like the AmigaOS  or RISC OS, do not support
  780.           TrueType even though  they provide scalable font services.
  781.           Adapting  a  font server  from  the  FreeType source  code
  782.           should be a relatively easy task.
  783.  
  784.           There  are many other  systems that  could benefit  from a
  785.           royalty-free  TrueType  engine,  and  we  encourage  their
  786.           implementors to contact us and experiment with our engine.
  787.           
  788.  
  789.       - TrueType GX support (the font part of GX, of course)
  790.  
  791.           Provided  through  extensions.  We  have  no  idea of  the
  792.           difficulty of such support.
  793.  
  794.  
  795.       - OpenType support
  796.  
  797.           Also  through  extensions.  It  would  need  a real  Type1
  798.           engine!
  799.  
  800.           Note from the author:
  801.  
  802.             By the way, anyone wanting to rewrite the horrible Type1
  803.             renderer found in X11R5 would be MORE than welcomed!
  804.  
  805.             This code is probably the worst design I've ever seen in
  806.             my life!  It's  slow, eats a lot of  memory, uses stupid
  807.             algorithms, and the auto-hinter is a shame!
  808.             
  809.             We're used to it because it 'works' more or less.
  810.  
  811.             
  812.       ISN'T IT TIME TO RAISE THE STANDARD OF FREE SOFTWARE ?!?
  813.       ********************************************************
  814.  
  815.           Resist bloat! Resist free junk!
  816.  
  817.             PS:
  818.  
  819.               I  wouldn't like  to offend  mrz, author  of  T1lib, a
  820.               better derivative to the original renderer.  I admit I
  821.               couldn't have done  what he did, as bad  code makes me
  822.               sick... but  he uses the original  engine, which still
  823.               requires about  150kByte to do much less  that what we
  824.               do in about 55kByte, and renders poorly...
  825.  
  826.           End of note
  827.  
  828.  
  829.       - Java / Java2D support
  830.  
  831.         There are two possibilities:
  832.  
  833.             - One could  rewrite the engine entirely  in Java.  This
  834.               would be a hard task, and probably won't run on a JVM.
  835.               However, a native Java  compiler could do wonders with
  836.               this code.
  837.  
  838.             - A more practical thing would be to embed the engine in
  839.               a native  Java class and integrate it  to Java2D. This
  840.               would give excellent  performance and good portability
  841.               (the engine is written in ANSI C).
  842.  
  843.             - Alternatively, only  the scan-line converter  could be
  844.               kept in  C for obvious performance  reasons, while the
  845.               rest of the engine would be translated to Java.  There
  846.               are delicate technical issues explaining why it is not
  847.               possible to  use Java2D's current  scan-line converter
  848.               to do this work.
  849.  
  850.  
  851.       - conversions and  dumping tools for all kinds  of formats and
  852.         platforms.
  853.  
  854.  
  855.  
  856.     We thank you for your time and consideration.
  857.  
  858.                         David Turner, Robert Wilhelm, Werner Lemberg,
  859.                                   and all the FreeType enthusiasts...
  860.  
  861.  
  862. --- End of user.txt ---
  863.