godot/thirdparty/freetype/src/autofit/aftypes.h

/****************************************************************************
 *
 * aftypes.h
 *
 *   Auto-fitter types (specification only).
 *
 * Copyright (C) 2003-2023 by
 * David Turner, Robert Wilhelm, and Werner Lemberg.
 *
 * This file is part of the FreeType project, and may only be used,
 * modified, and distributed under the terms of the FreeType project
 * license, LICENSE.TXT.  By continuing to use, modify, or distribute
 * this file you indicate that you have read the license and
 * understand and accept it fully.
 *
 */


  /*************************************************************************
   *
   * The auto-fitter is a complete rewrite of the old auto-hinter.
   * Its main feature is the ability to differentiate between different
   * writing systems and scripts in order to apply specific rules.
   *
   * The code has also been compartmentalized into several entities that
   * should make algorithmic experimentation easier than with the old
   * code.
   *
   *************************************************************************/


#ifndef AFTYPES_H_
#define AFTYPES_H_


#include <freetype/freetype.h>
#include <freetype/ftoutln.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>

#include "afblue.h"

#ifdef FT_DEBUG_AUTOFIT
#include FT_CONFIG_STANDARD_LIBRARY_H
#endif


FT_BEGIN_HEADER

  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                    D E B U G G I N G                          *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

#ifdef FT_DEBUG_AUTOFIT

extern int    af_debug_disable_horz_hints_;
extern int    af_debug_disable_vert_hints_;
extern int    af_debug_disable_blue_hints_;
extern void*  af_debug_hints_;

#endif /* FT_DEBUG_AUTOFIT */


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                 U T I L I T Y   S T U F F                     *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  AF_Width;


  FT_LOCAL( void )
  af_sort_pos( FT_UInt  count,
               FT_Pos*  table );

  FT_LOCAL( void )
  af_sort_and_quantize_widths( FT_UInt*  count,
                               AF_Width  widths,
                               FT_Pos    threshold );


  /*
   * opaque handle to glyph-specific hints -- see `afhints.h' for more
   * details
   */
  AF_GlyphHints;


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                       S C A L E R S                           *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  /*
   * A scaler models the target pixel device that will receive the
   * auto-hinted glyph image.
   */

#define AF_SCALER_FLAG_NO_HORIZONTAL
#define AF_SCALER_FLAG_NO_VERTICAL
#define AF_SCALER_FLAG_NO_ADVANCE


  AF_Scaler;


#define AF_SCALER_EQUAL_SCALES( a, b )


  AF_StyleMetrics;

  /*
   * This function parses an FT_Face to compute global metrics for
   * a specific style.
   */
  AF_WritingSystem_InitMetricsFunc;

  AF_WritingSystem_ScaleMetricsFunc;

  AF_WritingSystem_DoneMetricsFunc;

  AF_WritingSystem_GetStdWidthsFunc;


  AF_WritingSystem_InitHintsFunc;

  AF_WritingSystem_ApplyHintsFunc;


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                W R I T I N G   S Y S T E M S                  *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  /*
   * For the auto-hinter, a writing system consists of multiple scripts that
   * can be handled similarly *in a typographical way*; the relationship is
   * not based on history.  For example, both the Greek and the unrelated
   * Armenian scripts share the same features like ascender, descender,
   * x-height, etc.  Essentially, a writing system is covered by a
   * submodule of the auto-fitter; it contains
   *
   * - a specific global analyzer that computes global metrics specific to
   *   the script (based on script-specific characters to identify ascender
   *   height, x-height, etc.),
   *
   * - a specific glyph analyzer that computes segments and edges for each
   *   glyph covered by the script,
   *
   * - a specific grid-fitting algorithm that distorts the scaled glyph
   *   outline according to the results of the glyph analyzer.
   */

#undef  WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS )

  /* The list of known writing systems. */
  AF_WritingSystem;


  AF_WritingSystemClassRec;

  AF_WritingSystemClass;


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                        S C R I P T S                          *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  /*
   * Each script is associated with two sets of Unicode ranges to test
   * whether the font face supports the script, and which non-base
   * characters the script contains.
   *
   * We use four-letter script tags from the OpenType specification,
   * extended by `NONE', which indicates `no script'.
   */

#undef  SCRIPT
#define SCRIPT( s, S, d, h, H, ss )

  /* The list of known scripts. */
  AF_Script;


  AF_Script_UniRangeRec;

#define AF_UNIRANGE_REC( a, b )

  AF_Script_UniRange;


  AF_ScriptClassRec;

  AF_ScriptClass;


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                      C O V E R A G E S                        *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  /*
   * Usually, a font contains more glyphs than can be addressed by its
   * character map.
   *
   * In the PostScript font world, encoding vectors specific to a given
   * task are used to select such glyphs, and these glyphs can be often
   * recognized by having a suffix in its glyph names.  For example, a
   * superscript glyph `A' might be called `A.sup'.  Unfortunately, this
   * naming scheme is not standardized and thus unusable for us.
   *
   * In the OpenType world, a better solution was invented, namely
   * `features', which cleanly separate a character's input encoding from
   * the corresponding glyph's appearance, and which don't use glyph names
   * at all.  For our purposes, and slightly generalized, an OpenType
   * feature is a name of a mapping that maps character codes to
   * non-standard glyph indices (features get used for other things also).
   * For example, the `sups' feature provides superscript glyphs, thus
   * mapping character codes like `A' or `B' to superscript glyph
   * representation forms.  How this mapping happens is completely
   * uninteresting to us.
   *
   * For the auto-hinter, a `coverage' represents all glyphs of an OpenType
   * feature collected in a set (as listed below) that can be hinted
   * together.  To continue the above example, superscript glyphs must not
   * be hinted together with normal glyphs because the blue zones
   * completely differ.
   *
   * Note that FreeType itself doesn't compute coverages; it only provides
   * the glyphs addressable by the default Unicode character map.  Instead,
   * we use the HarfBuzz library (if available), which has many functions
   * exactly for this purpose.
   *
   * AF_COVERAGE_DEFAULT is special: It should cover everything that isn't
   * listed separately (including the glyphs addressable by the character
   * map).  In case HarfBuzz isn't available, it exactly covers the glyphs
   * addressable by the character map.
   *
   */

#undef  COVERAGE
#define COVERAGE( name, NAME, description, \
                  tag1, tag2, tag3, tag4 )


  AF_Coverage;


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                         S T Y L E S                           *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  /*
   * The topmost structure for modelling the auto-hinter glyph input data
   * is a `style class', grouping everything together.
   */

#undef  STYLE
#define STYLE( s, S, d, ws, sc, ss, c )

  /* The list of known styles. */
  AF_Style;


  AF_StyleClassRec;

  AF_StyleClass;


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****                   S T Y L E   M E T R I C S                   *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  AF_FaceGlobals;

  /* This is the main structure that combines everything.  Autofit modules */
  /* specific to writing systems derive their structures from it, for      */
  /* example `AF_LatinMetrics'.                                            */

  AF_StyleMetricsRec;


#define AF_HINTING_BOTTOM_TO_TOP
#define AF_HINTING_TOP_TO_BOTTOM


  /* Declare and define vtables for classes */
#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class )

#define AF_DEFINE_WRITING_SYSTEM_CLASS(                  \
          writing_system_class,                          \
          system,                                        \
          m_size,                                        \
          m_init,                                        \
          m_scale,                                       \
          m_done,                                        \
          m_stdw,                                        \
          h_init,                                        \
          h_apply )


#define AF_DECLARE_SCRIPT_CLASS( script_class )

#define AF_DEFINE_SCRIPT_CLASS(           \
          script_class,                   \
          script,                         \
          ranges,                         \
          nonbase_ranges,                 \
          top_to_bottom,                  \
          std_charstring )


#define AF_DECLARE_STYLE_CLASS( style_class )

#define AF_DEFINE_STYLE_CLASS(          \
          style_class,                  \
          style,                        \
          writing_system,               \
          script,                       \
          blue_stringset,               \
          coverage )

/* */


FT_END_HEADER

#endif /* AFTYPES_H_ */


/* END */