Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

FreeType on OpenGL ES (iPhone)

, 24 Nov 2010
Faster, smarter and better looking fonts rendered with OpenGL ES
OpenGLFont.zip
OpenGLFont
.DS_Store
__MACOSX
OpenGLFont
._.DS_Store
arial.ttf
Classes
.DS_Store
Classes
._.DS_Store
EAGLView.mm
._EAGLView.mm
freetype-2.4.3
.DS_Store
freetype-2.4.3
._.DS_Store
.gitignore
include
.DS_Store
include
._.DS_Store
freetype
.DS_Store
freetype
._.DS_Store
config
config
internal
services
src
.DS_Store
src
._.DS_Store
OpenGLFontAppDelegate.mm
main.m
MainWindow.xib
OpenGLFont-Info.plist
._OpenGLFont-Info.plist
OpenGLFont.xcodeproj
lefty.mode1v3
lefty.pbxuser
project.pbxproj
OpenGLFont_Prefix.pch
Shaders
Shader.fsh
Shader.vsh
times.ttf
OpenGLFont_1.01.zip
.DS_Store
arial.ttf
.DS_Store
EAGLView.mm
.DS_Store
.gitignore
.DS_Store
.DS_Store
.DS_Store
OpenGLFontAppDelegate.mm
main.m
MainWindow.xib
OpenGLFont-Info.plist
lefty.mode1v3
lefty.pbxuser
project.pbxproj
Shader.fsh
Shader.vsh
times.ttf
/***************************************************************************/
/*                                                                         */
/*  aflatin.h                                                              */
/*                                                                         */
/*    Auto-fitter hinting routines for latin script (specification).       */
/*                                                                         */
/*  Copyright 2003, 2004, 2005, 2006, 2007, 2009 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.                                        */
/*                                                                         */
/***************************************************************************/


#ifndef __AFLATIN_H__
#define __AFLATIN_H__

#include "afhints.h"


FT_BEGIN_HEADER


  /* the latin-specific script class */

  AF_DECLARE_SCRIPT_CLASS(af_latin_script_class)


/* constants are given with units_per_em == 2048 in mind */
#define AF_LATIN_CONSTANT( metrics, c ) \
  ( ( (c) * (FT_Long)( (AF_LatinMetrics)(metrics) )->units_per_em ) / 2048 )


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****            L A T I N   G L O B A L   M E T R I C S            *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/


  /*
   *  The following declarations could be embedded in the file `aflatin.c';
   *  they have been made semi-public to allow alternate script hinters to
   *  re-use some of them.
   */


  /* Latin (global) metrics management */

  enum
  {
    AF_LATIN_BLUE_CAPITAL_TOP,
    AF_LATIN_BLUE_CAPITAL_BOTTOM,
    AF_LATIN_BLUE_SMALL_F_TOP,
    AF_LATIN_BLUE_SMALL_TOP,
    AF_LATIN_BLUE_SMALL_BOTTOM,
    AF_LATIN_BLUE_SMALL_MINOR,

    AF_LATIN_BLUE_MAX
  };


#define AF_LATIN_IS_TOP_BLUE( b )  ( (b) == AF_LATIN_BLUE_CAPITAL_TOP || \
                                     (b) == AF_LATIN_BLUE_SMALL_F_TOP || \
                                     (b) == AF_LATIN_BLUE_SMALL_TOP   )

#define AF_LATIN_MAX_WIDTHS  16
#define AF_LATIN_MAX_BLUES   AF_LATIN_BLUE_MAX


  enum
  {
    AF_LATIN_BLUE_ACTIVE     = 1 << 0,
    AF_LATIN_BLUE_TOP        = 1 << 1,
    AF_LATIN_BLUE_ADJUSTMENT = 1 << 2,  /* used for scale adjustment */
                                        /* optimization              */
    AF_LATIN_BLUE_FLAG_MAX
  };


  typedef struct  AF_LatinBlueRec_
  {
    AF_WidthRec  ref;
    AF_WidthRec  shoot;
    FT_UInt      flags;

  } AF_LatinBlueRec, *AF_LatinBlue;


  typedef struct  AF_LatinAxisRec_
  {
    FT_Fixed         scale;
    FT_Pos           delta;

    FT_UInt          width_count;
    AF_WidthRec      widths[AF_LATIN_MAX_WIDTHS];
    FT_Pos           edge_distance_threshold;
    FT_Pos           standard_width;
    FT_Bool          extra_light;

    /* ignored for horizontal metrics */
    FT_Bool          control_overshoot;
    FT_UInt          blue_count;
    AF_LatinBlueRec  blues[AF_LATIN_BLUE_MAX];

    FT_Fixed         org_scale;
    FT_Pos           org_delta;

  } AF_LatinAxisRec, *AF_LatinAxis;


  typedef struct  AF_LatinMetricsRec_
  {
    AF_ScriptMetricsRec  root;
    FT_UInt              units_per_em;
    AF_LatinAxisRec      axis[AF_DIMENSION_MAX];

  } AF_LatinMetricsRec, *AF_LatinMetrics;


  FT_LOCAL( FT_Error )
  af_latin_metrics_init( AF_LatinMetrics  metrics,
                         FT_Face          face );

  FT_LOCAL( void )
  af_latin_metrics_scale( AF_LatinMetrics  metrics,
                          AF_Scaler        scaler );

  FT_LOCAL( void )
  af_latin_metrics_init_widths( AF_LatinMetrics  metrics,
                                FT_Face          face,
                                FT_ULong         charcode );

  FT_LOCAL( void )
  af_latin_metrics_check_digits( AF_LatinMetrics  metrics,
                                 FT_Face          face );


  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****           L A T I N   G L Y P H   A N A L Y S I S             *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  enum
  {
    AF_LATIN_HINTS_HORZ_SNAP   = 1 << 0, /* enable stem width snapping  */
    AF_LATIN_HINTS_VERT_SNAP   = 1 << 1, /* enable stem height snapping */
    AF_LATIN_HINTS_STEM_ADJUST = 1 << 2, /* enable stem width/height    */
                                         /* adjustment                  */
    AF_LATIN_HINTS_MONO        = 1 << 3  /* indicate monochrome         */
                                         /* rendering                   */
  };


#define AF_LATIN_HINTS_DO_HORZ_SNAP( h )             \
  AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_HORZ_SNAP )

#define AF_LATIN_HINTS_DO_VERT_SNAP( h )             \
  AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_VERT_SNAP )

#define AF_LATIN_HINTS_DO_STEM_ADJUST( h )             \
  AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_STEM_ADJUST )

#define AF_LATIN_HINTS_DO_MONO( h )             \
  AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_MONO )


  /*
   *  This shouldn't normally be exported.  However, other scripts might
   *  like to use this function as-is.
   */
  FT_LOCAL( FT_Error )
  af_latin_hints_compute_segments( AF_GlyphHints  hints,
                                   AF_Dimension   dim );

  /*
   *  This shouldn't normally be exported.  However, other scripts might
   *  want to use this function as-is.
   */
  FT_LOCAL( void )
  af_latin_hints_link_segments( AF_GlyphHints  hints,
                                AF_Dimension   dim );

  /*
   *  This shouldn't normally be exported.  However, other scripts might
   *  want to use this function as-is.
   */
  FT_LOCAL( FT_Error )
  af_latin_hints_compute_edges( AF_GlyphHints  hints,
                                AF_Dimension   dim );

  FT_LOCAL( FT_Error )
  af_latin_hints_detect_features( AF_GlyphHints  hints,
                                  AF_Dimension   dim );

/* */

FT_END_HEADER

#endif /* __AFLATIN_H__ */


/* END */

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ed welch
Software Developer Astronautz
Spain Spain
After working in the software industry for many years, I've started my own games company that specialises in strategy games for mobile platforms.

| Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 24 Nov 2010
Article Copyright 2010 by ed welch
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid