ftoutln.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:31k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /*  ftoutln.h                                                              */
  4. /*                                                                         */
  5. /*    Support for the FT_Outline type used to store glyph shapes of        */
  6. /*    most scalable font formats (specification).                          */
  7. /*                                                                         */
  8. /*  Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007 by                   */
  9. /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
  10. /*                                                                         */
  11. /*  This file is part of the FreeType project, and may only be used,       */
  12. /*  modified, and distributed under the terms of the FreeType project      */
  13. /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
  14. /*  this file you indicate that you have read the license and              */
  15. /*  understand and accept it fully.                                        */
  16. /*                                                                         */
  17. /***************************************************************************/
  18. #ifndef __FTOUTLN_H__
  19. #define __FTOUTLN_H__
  20. #include <ft2build.h>
  21. #include FT_FREETYPE_H
  22. #ifdef FREETYPE_H
  23. #error "freetype.h of FreeType 1 has been loaded!"
  24. #error "Please fix the directory search order for header files"
  25. #error "so that freetype.h of FreeType 2 is found first."
  26. #endif
  27. FT_BEGIN_HEADER
  28.   /*************************************************************************/
  29.   /*                                                                       */
  30.   /* <Section>                                                             */
  31.   /*    outline_processing                                                 */
  32.   /*                                                                       */
  33.   /* <Title>                                                               */
  34.   /*    Outline Processing                                                 */
  35.   /*                                                                       */
  36.   /* <Abstract>                                                            */
  37.   /*    Functions to create, transform, and render vectorial glyph images. */
  38.   /*                                                                       */
  39.   /* <Description>                                                         */
  40.   /*    This section contains routines used to create and destroy scalable */
  41.   /*    glyph images known as `outlines'.  These can also be measured,     */
  42.   /*    transformed, and converted into bitmaps and pixmaps.               */
  43.   /*                                                                       */
  44.   /* <Order>                                                               */
  45.   /*    FT_Outline                                                         */
  46.   /*    FT_OUTLINE_FLAGS                                                   */
  47.   /*    FT_Outline_New                                                     */
  48.   /*    FT_Outline_Done                                                    */
  49.   /*    FT_Outline_Copy                                                    */
  50.   /*    FT_Outline_Translate                                               */
  51.   /*    FT_Outline_Transform                                               */
  52.   /*    FT_Outline_Embolden                                                */
  53.   /*    FT_Outline_Reverse                                                 */
  54.   /*    FT_Outline_Check                                                   */
  55.   /*                                                                       */
  56.   /*    FT_Outline_Get_CBox                                                */
  57.   /*    FT_Outline_Get_BBox                                                */
  58.   /*                                                                       */
  59.   /*    FT_Outline_Get_Bitmap                                              */
  60.   /*    FT_Outline_Render                                                  */
  61.   /*                                                                       */
  62.   /*    FT_Outline_Decompose                                               */
  63.   /*    FT_Outline_Funcs                                                   */
  64.   /*    FT_Outline_MoveTo_Func                                             */
  65.   /*    FT_Outline_LineTo_Func                                             */
  66.   /*    FT_Outline_ConicTo_Func                                            */
  67.   /*    FT_Outline_CubicTo_Func                                            */
  68.   /*                                                                       */
  69.   /*************************************************************************/
  70.   /*************************************************************************/
  71.   /*                                                                       */
  72.   /* <Function>                                                            */
  73.   /*    FT_Outline_Decompose                                               */
  74.   /*                                                                       */
  75.   /* <Description>                                                         */
  76.   /*    Walks over an outline's structure to decompose it into individual  */
  77.   /*    segments and Bézier arcs.  This function is also able to emit      */
  78.   /*    `move to' and `close to' operations to indicate the start and end  */
  79.   /*    of new contours in the outline.                                    */
  80.   /*                                                                       */
  81.   /* <Input>                                                               */
  82.   /*    outline        :: A pointer to the source target.                  */
  83.   /*                                                                       */
  84.   /*    func_interface :: A table of `emitters', i.e,. function pointers   */
  85.   /*                      called during decomposition to indicate path     */
  86.   /*                      operations.                                      */
  87.   /*                                                                       */
  88.   /* <InOut>                                                               */
  89.   /*    user           :: A typeless pointer which is passed to each       */
  90.   /*                      emitter during the decomposition.  It can be     */
  91.   /*                      used to store the state during the               */
  92.   /*                      decomposition.                                   */
  93.   /*                                                                       */
  94.   /* <Return>                                                              */
  95.   /*    FreeType error code.  0 means success.                             */
  96.   /*                                                                       */
  97.   FT_EXPORT( FT_Error )
  98.   FT_Outline_Decompose( FT_Outline*              outline,
  99.                         const FT_Outline_Funcs*  func_interface,
  100.                         void*                    user );
  101.   /*************************************************************************/
  102.   /*                                                                       */
  103.   /* <Function>                                                            */
  104.   /*    FT_Outline_New                                                     */
  105.   /*                                                                       */
  106.   /* <Description>                                                         */
  107.   /*    Creates a new outline of a given size.                             */
  108.   /*                                                                       */
  109.   /* <Input>                                                               */
  110.   /*    library     :: A handle to the library object from where the       */
  111.   /*                   outline is allocated.  Note however that the new    */
  112.   /*                   outline will *not* necessarily be *freed*, when     */
  113.   /*                   destroying the library, by @FT_Done_FreeType.       */
  114.   /*                                                                       */
  115.   /*    numPoints   :: The maximal number of points within the outline.    */
  116.   /*                                                                       */
  117.   /*    numContours :: The maximal number of contours within the outline.  */
  118.   /*                                                                       */
  119.   /* <Output>                                                              */
  120.   /*    anoutline   :: A handle to the new outline.  NULL in case of       */
  121.   /*                   error.                                              */
  122.   /*                                                                       */
  123.   /* <Return>                                                              */
  124.   /*    FreeType error code.  0 means success.                             */
  125.   /*                                                                       */
  126.   /* <Note>                                                                */
  127.   /*    The reason why this function takes a `library' parameter is simply */
  128.   /*    to use the library's memory allocator.                             */
  129.   /*                                                                       */
  130.   FT_EXPORT( FT_Error )
  131.   FT_Outline_New( FT_Library   library,
  132.                   FT_UInt      numPoints,
  133.                   FT_Int       numContours,
  134.                   FT_Outline  *anoutline );
  135.   FT_EXPORT( FT_Error )
  136.   FT_Outline_New_Internal( FT_Memory    memory,
  137.                            FT_UInt      numPoints,
  138.                            FT_Int       numContours,
  139.                            FT_Outline  *anoutline );
  140.   /*************************************************************************/
  141.   /*                                                                       */
  142.   /* <Function>                                                            */
  143.   /*    FT_Outline_Done                                                    */
  144.   /*                                                                       */
  145.   /* <Description>                                                         */
  146.   /*    Destroys an outline created with @FT_Outline_New.                  */
  147.   /*                                                                       */
  148.   /* <Input>                                                               */
  149.   /*    library :: A handle of the library object used to allocate the     */
  150.   /*               outline.                                                */
  151.   /*                                                                       */
  152.   /*    outline :: A pointer to the outline object to be discarded.        */
  153.   /*                                                                       */
  154.   /* <Return>                                                              */
  155.   /*    FreeType error code.  0 means success.                             */
  156.   /*                                                                       */
  157.   /* <Note>                                                                */
  158.   /*    If the outline's `owner' field is not set, only the outline        */
  159.   /*    descriptor will be released.                                       */
  160.   /*                                                                       */
  161.   /*    The reason why this function takes an `library' parameter is       */
  162.   /*    simply to use ft_mem_free().                                       */
  163.   /*                                                                       */
  164.   FT_EXPORT( FT_Error )
  165.   FT_Outline_Done( FT_Library   library,
  166.                    FT_Outline*  outline );
  167.   FT_EXPORT( FT_Error )
  168.   FT_Outline_Done_Internal( FT_Memory    memory,
  169.                             FT_Outline*  outline );
  170.   /*************************************************************************/
  171.   /*                                                                       */
  172.   /* <Function>                                                            */
  173.   /*    FT_Outline_Check                                                   */
  174.   /*                                                                       */
  175.   /* <Description>                                                         */
  176.   /*    Check the contents of an outline descriptor.                       */
  177.   /*                                                                       */
  178.   /* <Input>                                                               */
  179.   /*    outline :: A handle to a source outline.                           */
  180.   /*                                                                       */
  181.   /* <Return>                                                              */
  182.   /*    FreeType error code.  0 means success.                             */
  183.   /*                                                                       */
  184.   FT_EXPORT( FT_Error )
  185.   FT_Outline_Check( FT_Outline*  outline );
  186.   /*************************************************************************/
  187.   /*                                                                       */
  188.   /* <Function>                                                            */
  189.   /*    FT_Outline_Get_CBox                                                */
  190.   /*                                                                       */
  191.   /* <Description>                                                         */
  192.   /*    Returns an outline's `control box'.  The control box encloses all  */
  193.   /*    the outline's points, including Bézier control points.  Though it  */
  194.   /*    coincides with the exact bounding box for most glyphs, it can be   */
  195.   /*    slightly larger in some situations (like when rotating an outline  */
  196.   /*    which contains Bézier outside arcs).                               */
  197.   /*                                                                       */
  198.   /*    Computing the control box is very fast, while getting the bounding */
  199.   /*    box can take much more time as it needs to walk over all segments  */
  200.   /*    and arcs in the outline.  To get the latter, you can use the       */
  201.   /*    `ftbbox' component which is dedicated to this single task.         */
  202.   /*                                                                       */
  203.   /* <Input>                                                               */
  204.   /*    outline :: A pointer to the source outline descriptor.             */
  205.   /*                                                                       */
  206.   /* <Output>                                                              */
  207.   /*    acbox   :: The outline's control box.                              */
  208.   /*                                                                       */
  209.   FT_EXPORT( void )
  210.   FT_Outline_Get_CBox( const FT_Outline*  outline,
  211.                        FT_BBox           *acbox );
  212.   /*************************************************************************/
  213.   /*                                                                       */
  214.   /* <Function>                                                            */
  215.   /*    FT_Outline_Translate                                               */
  216.   /*                                                                       */
  217.   /* <Description>                                                         */
  218.   /*    Applies a simple translation to the points of an outline.          */
  219.   /*                                                                       */
  220.   /* <InOut>                                                               */
  221.   /*    outline :: A pointer to the target outline descriptor.             */
  222.   /*                                                                       */
  223.   /* <Input>                                                               */
  224.   /*    xOffset :: The horizontal offset.                                  */
  225.   /*                                                                       */
  226.   /*    yOffset :: The vertical offset.                                    */
  227.   /*                                                                       */
  228.   FT_EXPORT( void )
  229.   FT_Outline_Translate( const FT_Outline*  outline,
  230.                         FT_Pos             xOffset,
  231.                         FT_Pos             yOffset );
  232.   /*************************************************************************/
  233.   /*                                                                       */
  234.   /* <Function>                                                            */
  235.   /*    FT_Outline_Copy                                                    */
  236.   /*                                                                       */
  237.   /* <Description>                                                         */
  238.   /*    Copies an outline into another one.  Both objects must have the    */
  239.   /*    same sizes (number of points & number of contours) when this       */
  240.   /*    function is called.                                                */
  241.   /*                                                                       */
  242.   /* <Input>                                                               */
  243.   /*    source :: A handle to the source outline.                          */
  244.   /*                                                                       */
  245.   /* <Output>                                                              */
  246.   /*    target :: A handle to the target outline.                          */
  247.   /*                                                                       */
  248.   /* <Return>                                                              */
  249.   /*    FreeType error code.  0 means success.                             */
  250.   /*                                                                       */
  251.   FT_EXPORT( FT_Error )
  252.   FT_Outline_Copy( const FT_Outline*  source,
  253.                    FT_Outline        *target );
  254.   /*************************************************************************/
  255.   /*                                                                       */
  256.   /* <Function>                                                            */
  257.   /*    FT_Outline_Transform                                               */
  258.   /*                                                                       */
  259.   /* <Description>                                                         */
  260.   /*    Applies a simple 2x2 matrix to all of an outline's points.  Useful */
  261.   /*    for applying rotations, slanting, flipping, etc.                   */
  262.   /*                                                                       */
  263.   /* <InOut>                                                               */
  264.   /*    outline :: A pointer to the target outline descriptor.             */
  265.   /*                                                                       */
  266.   /* <Input>                                                               */
  267.   /*    matrix  :: A pointer to the transformation matrix.                 */
  268.   /*                                                                       */
  269.   /* <Note>                                                                */
  270.   /*    You can use @FT_Outline_Translate if you need to translate the     */
  271.   /*    outline's points.                                                  */
  272.   /*                                                                       */
  273.   FT_EXPORT( void )
  274.   FT_Outline_Transform( const FT_Outline*  outline,
  275.                         const FT_Matrix*   matrix );
  276.   /*************************************************************************/
  277.   /*                                                                       */
  278.   /* <Function>                                                            */
  279.   /*    FT_Outline_Embolden                                                */
  280.   /*                                                                       */
  281.   /* <Description>                                                         */
  282.   /*    Emboldens an outline.  The new outline will be at most 4 times     */
  283.   /*    `strength' pixels wider and higher.  You may think of the left and */
  284.   /*    bottom borders as unchanged.                                       */
  285.   /*                                                                       */
  286.   /*    Negative `strength' values to reduce the outline thickness are     */
  287.   /*    possible also.                                                     */
  288.   /*                                                                       */
  289.   /* <InOut>                                                               */
  290.   /*    outline  :: A handle to the target outline.                        */
  291.   /*                                                                       */
  292.   /* <Input>                                                               */
  293.   /*    strength :: How strong the glyph is emboldened.  Expressed in      */
  294.   /*                26.6 pixel format.                                     */
  295.   /*                                                                       */
  296.   /* <Return>                                                              */
  297.   /*    FreeType error code.  0 means success.                             */
  298.   /*                                                                       */
  299.   /* <Note>                                                                */
  300.   /*    The used algorithm to increase or decrease the thickness of the    */
  301.   /*    glyph doesn't change the number of points; this means that certain */
  302.   /*    situations like acute angles or intersections are sometimes        */
  303.   /*    handled incorrectly.                                               */
  304.   /*                                                                       */
  305.   /*    Example call:                                                      */
  306.   /*                                                                       */
  307.   /*    {                                                                  */
  308.   /*      FT_Load_Glyph( face, index, FT_LOAD_DEFAULT );                   */
  309.   /*      if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE )             */
  310.   /*        FT_Outline_Embolden( &face->slot->outline, strength );         */
  311.   /*    }                                                                  */
  312.   /*                                                                       */
  313.   FT_EXPORT( FT_Error )
  314.   FT_Outline_Embolden( FT_Outline*  outline,
  315.                        FT_Pos       strength );
  316.   /*************************************************************************/
  317.   /*                                                                       */
  318.   /* <Function>                                                            */
  319.   /*    FT_Outline_Reverse                                                 */
  320.   /*                                                                       */
  321.   /* <Description>                                                         */
  322.   /*    Reverses the drawing direction of an outline.  This is used to     */
  323.   /*    ensure consistent fill conventions for mirrored glyphs.            */
  324.   /*                                                                       */
  325.   /* <InOut>                                                               */
  326.   /*    outline :: A pointer to the target outline descriptor.             */
  327.   /*                                                                       */
  328.   /* <Note>                                                                */
  329.   /*    This functions toggles the bit flag @FT_OUTLINE_REVERSE_FILL in    */
  330.   /*    the outline's `flags' field.                                       */
  331.   /*                                                                       */
  332.   /*    It shouldn't be used by a normal client application, unless it     */
  333.   /*    knows what it is doing.                                            */
  334.   /*                                                                       */
  335.   FT_EXPORT( void )
  336.   FT_Outline_Reverse( FT_Outline*  outline );
  337.   /*************************************************************************/
  338.   /*                                                                       */
  339.   /* <Function>                                                            */
  340.   /*    FT_Outline_Get_Bitmap                                              */
  341.   /*                                                                       */
  342.   /* <Description>                                                         */
  343.   /*    Renders an outline within a bitmap.  The outline's image is simply */
  344.   /*    OR-ed to the target bitmap.                                        */
  345.   /*                                                                       */
  346.   /* <Input>                                                               */
  347.   /*    library :: A handle to a FreeType library object.                  */
  348.   /*                                                                       */
  349.   /*    outline :: A pointer to the source outline descriptor.             */
  350.   /*                                                                       */
  351.   /* <InOut>                                                               */
  352.   /*    abitmap :: A pointer to the target bitmap descriptor.              */
  353.   /*                                                                       */
  354.   /* <Return>                                                              */
  355.   /*    FreeType error code.  0 means success.                             */
  356.   /*                                                                       */
  357.   /* <Note>                                                                */
  358.   /*    This function does NOT CREATE the bitmap, it only renders an       */
  359.   /*    outline image within the one you pass to it!                       */
  360.   /*                                                                       */
  361.   /*    It will use the raster corresponding to the default glyph format.  */
  362.   /*                                                                       */
  363.   FT_EXPORT( FT_Error )
  364.   FT_Outline_Get_Bitmap( FT_Library        library,
  365.                          FT_Outline*       outline,
  366.                          const FT_Bitmap  *abitmap );
  367.   /*************************************************************************/
  368.   /*                                                                       */
  369.   /* <Function>                                                            */
  370.   /*    FT_Outline_Render                                                  */
  371.   /*                                                                       */
  372.   /* <Description>                                                         */
  373.   /*    Renders an outline within a bitmap using the current scan-convert. */
  374.   /*    This functions uses an @FT_Raster_Params structure as an argument, */
  375.   /*    allowing advanced features like direct composition, translucency,  */
  376.   /*    etc.                                                               */
  377.   /*                                                                       */
  378.   /* <Input>                                                               */
  379.   /*    library :: A handle to a FreeType library object.                  */
  380.   /*                                                                       */
  381.   /*    outline :: A pointer to the source outline descriptor.             */
  382.   /*                                                                       */
  383.   /* <InOut>                                                               */
  384.   /*    params  :: A pointer to an @FT_Raster_Params structure used to     */
  385.   /*               describe the rendering operation.                       */
  386.   /*                                                                       */
  387.   /* <Return>                                                              */
  388.   /*    FreeType error code.  0 means success.                             */
  389.   /*                                                                       */
  390.   /* <Note>                                                                */
  391.   /*    You should know what you are doing and how @FT_Raster_Params works */
  392.   /*    to use this function.                                              */
  393.   /*                                                                       */
  394.   /*    The field `params.source' will be set to `outline' before the scan */
  395.   /*    converter is called, which means that the value you give to it is  */
  396.   /*    actually ignored.                                                  */
  397.   /*                                                                       */
  398.   FT_EXPORT( FT_Error )
  399.   FT_Outline_Render( FT_Library         library,
  400.                      FT_Outline*        outline,
  401.                      FT_Raster_Params*  params );
  402.  /**************************************************************************
  403.   *
  404.   * @enum:
  405.   *   FT_Orientation
  406.   *
  407.   * @description:
  408.   *   A list of values used to describe an outline's contour orientation.
  409.   *
  410.   *   The TrueType and Postscript specifications use different conventions
  411.   *   to determine whether outline contours should be filled or unfilled.
  412.   *
  413.   * @values:
  414.   *   FT_ORIENTATION_TRUETYPE ::
  415.   *     According to the TrueType specification, clockwise contours must
  416.   *     be filled, and counter-clockwise ones must be unfilled.
  417.   *
  418.   *   FT_ORIENTATION_POSTSCRIPT ::
  419.   *     According to the Postscript specification, counter-clockwise contours
  420.   *     must be filled, and clockwise ones must be unfilled.
  421.   *
  422.   *   FT_ORIENTATION_FILL_RIGHT ::
  423.   *     This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
  424.   *     remember that in TrueType, everything that is to the right of
  425.   *     the drawing direction of a contour must be filled.
  426.   *
  427.   *   FT_ORIENTATION_FILL_LEFT ::
  428.   *     This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
  429.   *     remember that in Postscript, everything that is to the left of
  430.   *     the drawing direction of a contour must be filled.
  431.   *
  432.   *   FT_ORIENTATION_NONE ::
  433.   *     The orientation cannot be determined.  That is, different parts of
  434.   *     the glyph have different orientation.
  435.   *
  436.   */
  437.   typedef enum
  438.   {
  439.     FT_ORIENTATION_TRUETYPE   = 0,
  440.     FT_ORIENTATION_POSTSCRIPT = 1,
  441.     FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
  442.     FT_ORIENTATION_FILL_LEFT  = FT_ORIENTATION_POSTSCRIPT,
  443.     FT_ORIENTATION_NONE
  444.   } FT_Orientation;
  445.  /**************************************************************************
  446.   *
  447.   * @function:
  448.   *   FT_Outline_Get_Orientation
  449.   *
  450.   * @description:
  451.   *   This function analyzes a glyph outline and tries to compute its
  452.   *   fill orientation (see @FT_Orientation).  This is done by computing
  453.   *   the direction of each global horizontal and/or vertical extrema
  454.   *   within the outline.
  455.   *
  456.   *   Note that this will return @FT_ORIENTATION_TRUETYPE for empty
  457.   *   outlines.
  458.   *
  459.   * @input:
  460.   *   outline ::
  461.   *     A handle to the source outline.
  462.   *
  463.   * @return:
  464.   *   The orientation.
  465.   *
  466.   */
  467.   FT_EXPORT( FT_Orientation )
  468.   FT_Outline_Get_Orientation( FT_Outline*  outline );
  469.   /* */
  470. FT_END_HEADER
  471. #endif /* __FTOUTLN_H__ */
  472. /* END */
  473. /* Local Variables: */
  474. /* coding: utf-8    */
  475. /* End:             */