A first try to integrate the Infinality patches for the autohinter.
It provides a framework for properties and adds a single property, `adjust glyph heights'.
This commit is contained in:
parent
e343e87d4f
commit
84f034aed9
|
@ -4,7 +4,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* Build macros of the FreeType 2 library. */
|
/* Build macros of the FreeType 2 library. */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
|
/* Copyright 1996-2008, 2010, 2012 by */
|
||||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of the FreeType project, and may only be used, */
|
/* This file is part of the FreeType project, and may only be used, */
|
||||||
|
@ -706,6 +706,18 @@
|
||||||
#define FT_LCD_FILTER_H <freetype/ftlcdfil.h>
|
#define FT_LCD_FILTER_H <freetype/ftlcdfil.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* @macro:
|
||||||
|
* FT_AUTOHINTER_H
|
||||||
|
*
|
||||||
|
* @description:
|
||||||
|
* A macro used in #include statements to name the file containing the
|
||||||
|
* FreeType~2 API which controls the behaviour of the auto-hinter.
|
||||||
|
*/
|
||||||
|
#define FT_AUTOHINTER_H <freetype/ftautoh.h>
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
*
|
*
|
||||||
* @macro:
|
* @macro:
|
||||||
|
|
|
@ -0,0 +1,195 @@
|
||||||
|
/***************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* ftautoh.h */
|
||||||
|
/* */
|
||||||
|
/* FreeType API for setting and accessing auto-hinter properties */
|
||||||
|
/* (specification). */
|
||||||
|
/* */
|
||||||
|
/* Copyright 2012 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 __FTAUTOH_H__
|
||||||
|
#define __FTAUTOH_H__
|
||||||
|
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
#ifdef FREETYPE_H
|
||||||
|
#error "freetype.h of FreeType 1 has been loaded!"
|
||||||
|
#error "Please fix the directory search order for header files"
|
||||||
|
#error "so that freetype.h of FreeType 2 is found first."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
FT_BEGIN_HEADER
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* <Section> */
|
||||||
|
/* autohinter */
|
||||||
|
/* */
|
||||||
|
/* <Title> */
|
||||||
|
/* The Auto-hinter */
|
||||||
|
/* */
|
||||||
|
/* <Abstract> */
|
||||||
|
/* Controlling the behaviour of the auto-hinting engine. */
|
||||||
|
/* */
|
||||||
|
/* <Description> */
|
||||||
|
/* This section contains the declaration of functions specific to the */
|
||||||
|
/* auto-hinter. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* @enum:
|
||||||
|
* FT_AUTOHINTER_XXX
|
||||||
|
*
|
||||||
|
* @description:
|
||||||
|
* A list of bit-field constants used with
|
||||||
|
* @FT_Library_GetAutohinterProperties,
|
||||||
|
* @FT_Face_GetAutohinterProperties,
|
||||||
|
* @FT_Library_SetAutohinterProperties, and
|
||||||
|
* @FT_Face_SetAutohinterProperties to control the behaviour of the
|
||||||
|
* auto-hinter.
|
||||||
|
*
|
||||||
|
* @values:
|
||||||
|
* FT_AUTOHINTER_DEFAULT::
|
||||||
|
* Corresponding to~0, this value indicates the default value.
|
||||||
|
*
|
||||||
|
* FT_AUTOHINTER_INCREASE_GLYPH_HEIGHTS ::
|
||||||
|
* For glyphs in the size range 5 < PPEM < 15, round up the glyph
|
||||||
|
* height much more often than normally.
|
||||||
|
*/
|
||||||
|
#define FT_AUTOHINTER_DEFAULT 0x0
|
||||||
|
#define FT_AUTOHINTER_INCREASE_GLYPH_HEIGHTS ( 1L << 0 )
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* @function:
|
||||||
|
* FT_Library_GetAutohinterProperties
|
||||||
|
*
|
||||||
|
* @description:
|
||||||
|
* Retrieve the global property flags which control the behaviour of the
|
||||||
|
* auto-hinter.
|
||||||
|
*
|
||||||
|
* @output:
|
||||||
|
* properties ::
|
||||||
|
* The current global auto-hinter property flags, consisting of
|
||||||
|
* @FT_AUTOHINTER_XXX constants which are ORed together.
|
||||||
|
*
|
||||||
|
* Use @FT_Face_GetAutohinterProperties to retrieve the local
|
||||||
|
* properties of a face.
|
||||||
|
*
|
||||||
|
* @return:
|
||||||
|
* FreeType error code. 0~means success.
|
||||||
|
*/
|
||||||
|
FT_EXPORT( FT_Error )
|
||||||
|
FT_Library_GetAutohinterProperties( FT_Library library,
|
||||||
|
FT_Int32 *properties );
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* @function:
|
||||||
|
* FT_Library_SetAutohinterProperties
|
||||||
|
*
|
||||||
|
* @description:
|
||||||
|
* Set the global property flags which control the behaviour of the
|
||||||
|
* auto-hinter.
|
||||||
|
*
|
||||||
|
* @input:
|
||||||
|
* properties ::
|
||||||
|
* The auto-hinter property flags to be set globally, consisting of
|
||||||
|
* @FT_AUTOHINTER_XXX constants which are ORed together. All faces
|
||||||
|
* created after a call to this function inherit the new auto-hinter
|
||||||
|
* properties.
|
||||||
|
*
|
||||||
|
* Use @FT_Face_SetAutohinterProperties to override the properties
|
||||||
|
* locally.
|
||||||
|
*
|
||||||
|
* @return:
|
||||||
|
* FreeType error code. 0~means success.
|
||||||
|
*/
|
||||||
|
FT_EXPORT( FT_Error )
|
||||||
|
FT_Library_SetAutohinterProperties( FT_Library library,
|
||||||
|
FT_Int32 properties );
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* @function:
|
||||||
|
* FT_Face_GetAutohinterProperties
|
||||||
|
*
|
||||||
|
* @description:
|
||||||
|
* Retrieve the property flags which control the behaviour of the
|
||||||
|
* auto-hinter for the given face.
|
||||||
|
*
|
||||||
|
* @input:
|
||||||
|
* face ::
|
||||||
|
* A handle to the input face.
|
||||||
|
*
|
||||||
|
* @output:
|
||||||
|
* properties ::
|
||||||
|
* The current auto-hinter property flags of the given face,
|
||||||
|
* consisting of @FT_AUTOHINTER_XXX constants which are ORed
|
||||||
|
* together.
|
||||||
|
*
|
||||||
|
* @return:
|
||||||
|
* FreeType error code. 0~means success.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
FT_EXPORT( FT_Error )
|
||||||
|
FT_Face_GetAutohinterProperties( FT_Face face,
|
||||||
|
FT_Int32 *properties );
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* @function:
|
||||||
|
* FT_Face_SetAutohinterProperties
|
||||||
|
*
|
||||||
|
* @description:
|
||||||
|
* Set the property flags which control the behaviour of the autolhinter
|
||||||
|
* for the given face.
|
||||||
|
*
|
||||||
|
* @input:
|
||||||
|
* face ::
|
||||||
|
* A handle to the input face.
|
||||||
|
*
|
||||||
|
* properties ::
|
||||||
|
* The auto-hinter property flags to be set for the given face,
|
||||||
|
* consisting of @FT_AUTOHINTER_XXX constants which are ORed
|
||||||
|
* together.
|
||||||
|
*
|
||||||
|
* By default, a face inherits the global auto-hinter properties (set
|
||||||
|
* with @FT_Library_SetAutohinterProperties, if any) at the time of
|
||||||
|
* its creation. Using this function you can override them locally.
|
||||||
|
*
|
||||||
|
* @return:
|
||||||
|
* FreeType error code. 0~means success.
|
||||||
|
*/
|
||||||
|
FT_EXPORT( FT_Error )
|
||||||
|
FT_Face_SetAutohinterProperties( FT_Face face,
|
||||||
|
FT_Int32 properties );
|
||||||
|
|
||||||
|
/* */
|
||||||
|
|
||||||
|
FT_END_HEADER
|
||||||
|
|
||||||
|
#endif /* __FTAUTOH_H__ */
|
||||||
|
|
||||||
|
|
||||||
|
/* END */
|
|
@ -100,5 +100,6 @@
|
||||||
/* lzw */
|
/* lzw */
|
||||||
/* bzip2 */
|
/* bzip2 */
|
||||||
/* lcd_filtering */
|
/* lcd_filtering */
|
||||||
|
/* autohinter */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* The FreeType private base classes (specification). */
|
/* The FreeType private base classes (specification). */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010 by */
|
/* Copyright 1996-2006, 2008, 2010, 2012 by */
|
||||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of the FreeType project, and may only be used, */
|
/* This file is part of the FreeType project, and may only be used, */
|
||||||
|
@ -305,6 +305,9 @@ FT_BEGIN_HEADER
|
||||||
/* this data when first opened. This field exists only if */
|
/* this data when first opened. This field exists only if */
|
||||||
/* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
|
/* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
|
||||||
/* */
|
/* */
|
||||||
|
/* auto_hinter_flags :: */
|
||||||
|
/* Flags controlling the behaviour of the auto-hinter locally. */
|
||||||
|
/* */
|
||||||
/* ignore_unpatented_hinter :: */
|
/* ignore_unpatented_hinter :: */
|
||||||
/* This boolean flag instructs the glyph loader to ignore the */
|
/* This boolean flag instructs the glyph loader to ignore the */
|
||||||
/* native font hinter, if one is found. This is exclusively used */
|
/* native font hinter, if one is found. This is exclusively used */
|
||||||
|
@ -333,6 +336,8 @@ FT_BEGIN_HEADER
|
||||||
FT_Incremental_InterfaceRec* incremental_interface;
|
FT_Incremental_InterfaceRec* incremental_interface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
FT_Int32 auto_hinter_flags;
|
||||||
|
|
||||||
FT_Bool ignore_unpatented_hinter;
|
FT_Bool ignore_unpatented_hinter;
|
||||||
FT_UInt refcount;
|
FT_UInt refcount;
|
||||||
|
|
||||||
|
@ -803,7 +808,10 @@ FT_BEGIN_HEADER
|
||||||
/* handle to the current renderer for the */
|
/* handle to the current renderer for the */
|
||||||
/* FT_GLYPH_FORMAT_OUTLINE format. */
|
/* FT_GLYPH_FORMAT_OUTLINE format. */
|
||||||
/* */
|
/* */
|
||||||
/* auto_hinter :: XXX */
|
/* auto_hinter :: The current auto-hinter. */
|
||||||
|
/* */
|
||||||
|
/* auto_hinter_flags :: Flags controlling the behaviour of the */
|
||||||
|
/* auto-hinter globally. */
|
||||||
/* */
|
/* */
|
||||||
/* raster_pool :: The raster object's render pool. This can */
|
/* raster_pool :: The raster object's render pool. This can */
|
||||||
/* ideally be changed dynamically at run-time. */
|
/* ideally be changed dynamically at run-time. */
|
||||||
|
@ -850,6 +858,8 @@ FT_BEGIN_HEADER
|
||||||
FT_ListRec renderers; /* list of renderers */
|
FT_ListRec renderers; /* list of renderers */
|
||||||
FT_Renderer cur_renderer; /* current outline renderer */
|
FT_Renderer cur_renderer; /* current outline renderer */
|
||||||
FT_Module auto_hinter;
|
FT_Module auto_hinter;
|
||||||
|
FT_Int32 auto_hinter_flags; /* global flags controlling */
|
||||||
|
/* the autohinter behaviour */
|
||||||
|
|
||||||
FT_Byte* raster_pool; /* scan-line conversion */
|
FT_Byte* raster_pool; /* scan-line conversion */
|
||||||
/* render pool */
|
/* render pool */
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* Auto-fitter hinting routines for latin script (body). */
|
/* Auto-fitter hinting routines for latin script (body). */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 2003-2011 by */
|
/* Copyright 2003-2012 by */
|
||||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of the FreeType project, and may only be used, */
|
/* This file is part of the FreeType project, and may only be used, */
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_ADVANCES_H
|
#include FT_ADVANCES_H
|
||||||
|
#include FT_AUTOHINTER_H
|
||||||
#include FT_INTERNAL_DEBUG_H
|
#include FT_INTERNAL_DEBUG_H
|
||||||
|
|
||||||
#include "aflatin.h"
|
#include "aflatin.h"
|
||||||
|
@ -569,10 +570,22 @@
|
||||||
|
|
||||||
if ( blue )
|
if ( blue )
|
||||||
{
|
{
|
||||||
FT_Pos scaled = FT_MulFix( blue->shoot.org, scaler->y_scale );
|
FT_Pos scaled;
|
||||||
FT_Pos fitted = ( scaled + 40 ) & ~63;
|
FT_Pos threshold;
|
||||||
|
FT_Pos fitted;
|
||||||
|
|
||||||
|
|
||||||
|
scaled = FT_MulFix( blue->shoot.org, scaler->y_scale );
|
||||||
|
|
||||||
|
threshold = 40;
|
||||||
|
if ( ( metrics->root.scaler.face->internal->auto_hinter_flags &
|
||||||
|
FT_AUTOHINTER_INCREASE_GLYPH_HEIGHTS ) &&
|
||||||
|
metrics->root.scaler.face->size->metrics.x_ppem < 15 &&
|
||||||
|
metrics->root.scaler.face->size->metrics.x_ppem > 5 )
|
||||||
|
threshold = 52;
|
||||||
|
|
||||||
|
fitted = ( scaled + threshold ) & ~63;
|
||||||
|
|
||||||
if ( scaled != fitted )
|
if ( scaled != fitted )
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
/***************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* ftautoh.c */
|
||||||
|
/* */
|
||||||
|
/* FreeType API for setting and accessing auto-hinter properties */
|
||||||
|
/* (body). */
|
||||||
|
/* */
|
||||||
|
/* Copyright 2012 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. */
|
||||||
|
/* */
|
||||||
|
/***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_INTERNAL_OBJECTS_H
|
||||||
|
|
||||||
|
|
||||||
|
/* documentation is in ftautoh.h */
|
||||||
|
|
||||||
|
FT_EXPORT_DEF( FT_Error )
|
||||||
|
FT_Library_GetAutohinterProperties( FT_Library library,
|
||||||
|
FT_Int32 *properties )
|
||||||
|
{
|
||||||
|
if ( !library || !properties )
|
||||||
|
return FT_Err_Invalid_Argument;
|
||||||
|
|
||||||
|
*properties = library->auto_hinter_flags;
|
||||||
|
|
||||||
|
return FT_Err_Ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* documentation is in ftautoh.h */
|
||||||
|
|
||||||
|
FT_EXPORT_DEF( FT_Error )
|
||||||
|
FT_Library_SetAutohinterProperties( FT_Library face,
|
||||||
|
FT_Int32 properties )
|
||||||
|
{
|
||||||
|
if ( !library )
|
||||||
|
return FT_Err_Invalid_Argument;
|
||||||
|
|
||||||
|
library->auto_hinter_flags = properties;
|
||||||
|
|
||||||
|
return FT_Err_Ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* documentation is in ftautoh.h */
|
||||||
|
|
||||||
|
FT_EXPORT_DEF( FT_Error )
|
||||||
|
FT_Face_GetAutohinterProperties( FT_Face face,
|
||||||
|
FT_Int32 *properties )
|
||||||
|
{
|
||||||
|
if ( !face || !properties )
|
||||||
|
return FT_Err_Invalid_Argument;
|
||||||
|
|
||||||
|
*properties = face->internal->auto_hinter_flags;
|
||||||
|
|
||||||
|
return FT_Err_Ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* documentation is in ftautoh.h */
|
||||||
|
|
||||||
|
FT_EXPORT_DEF( FT_Error )
|
||||||
|
FT_Face_SetAutohinterProperties( FT_Face face,
|
||||||
|
FT_Int32 properties )
|
||||||
|
{
|
||||||
|
if ( !face )
|
||||||
|
return FT_Err_Invalid_Argument;
|
||||||
|
|
||||||
|
face->internal->auto_hinter_flags = properties;
|
||||||
|
|
||||||
|
return FT_Err_Ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* END */
|
|
@ -4,7 +4,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* The FreeType private base classes (body). */
|
/* The FreeType private base classes (body). */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 1996-2011 by */
|
/* Copyright 1996-2012 by */
|
||||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of the FreeType project, and may only be used, */
|
/* This file is part of the FreeType project, and may only be used, */
|
||||||
|
@ -2222,6 +2222,8 @@
|
||||||
internal->transform_delta.x = 0;
|
internal->transform_delta.x = 0;
|
||||||
internal->transform_delta.y = 0;
|
internal->transform_delta.y = 0;
|
||||||
|
|
||||||
|
internal->auto_hinter_flags = library->auto_hinter_flags;
|
||||||
|
|
||||||
internal->refcount = 1;
|
internal->refcount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue