|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
/* */ |
|
|
|
|
/* autohint.h */ |
|
|
|
|
/* */ |
|
|
|
|
/* High-level `autohint" module-specific interface (specification) */ |
|
|
|
|
/* High-level `autohint' module-specific interface (specification). */ |
|
|
|
|
/* */ |
|
|
|
|
/* Copyright 1996-2000 by */ |
|
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
|
|
|
@ -13,159 +13,172 @@ |
|
|
|
|
/* this file you indicate that you have read the license and */ |
|
|
|
|
/* understand and accept it fully. */ |
|
|
|
|
/* */ |
|
|
|
|
/* */ |
|
|
|
|
/* The auto-hinter is used to load and automatically hint glyphs */ |
|
|
|
|
/* when a format-specific hinter isn't available.. */ |
|
|
|
|
/* */ |
|
|
|
|
/***************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
|
/* The auto-hinter is used to load and automatically hint glyphs if a */ |
|
|
|
|
/* format-specific hinter isn't available. */ |
|
|
|
|
/* */ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef AUTOHINT_H |
|
|
|
|
#define AUTOHINT_H |
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
|
* |
|
|
|
|
* A small technical note regarding automatic hinting in order to clarify |
|
|
|
|
* this module interface. |
|
|
|
|
* |
|
|
|
|
* An automatic hinter might compute two kinds of data for a given face: |
|
|
|
|
* |
|
|
|
|
* - global hints: usually some metrics that describe global properties |
|
|
|
|
* of the face. It is computed by scanning more or less |
|
|
|
|
* agressively the glyphs in the face, and thus can be |
|
|
|
|
* very slow to compute (even if the size of global hints |
|
|
|
|
* is really small) |
|
|
|
|
* |
|
|
|
|
* - glyph hints: these describe some important features of the glyph |
|
|
|
|
* outline, as well as how to align them. They are generally |
|
|
|
|
* much faster to compute than global hints. |
|
|
|
|
* |
|
|
|
|
* The current FreeType auto-hinter does a pretty good job while performing |
|
|
|
|
* fast computations for both global and glyph hints. However, we might be |
|
|
|
|
* interested in introducing more complex and powerful algorithms in the |
|
|
|
|
* future, like the one described in the John D. Hobby paper, which |
|
|
|
|
* unfortunately require a lot more horsepower. |
|
|
|
|
* |
|
|
|
|
* Because a sufficiently sophisticated font management system would |
|
|
|
|
* typically implement a LRU cache of opened face objects to reduce memory |
|
|
|
|
* usage, it is a good idea to be able to avoid recomputing global hints |
|
|
|
|
* every time the same face is re-opened. |
|
|
|
|
* |
|
|
|
|
* We thus provide the ability to cache global hints outside of the face |
|
|
|
|
* object, in order to speed up font re-opening time. Of course, this |
|
|
|
|
* feature is purely optional, so most client programs won't even notice |
|
|
|
|
* it :o) |
|
|
|
|
* |
|
|
|
|
* I initially though that it'd be a good idea to cache the glyph hints too, |
|
|
|
|
* however, if my general idea now is that if you really need to cache these |
|
|
|
|
* too, you're simply in need of a new font format, where all this information |
|
|
|
|
* could be stored within the font file and decoded on the fly :-) |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
|
/* A small technical note regarding automatic hinting in order to */ |
|
|
|
|
/* clarify this module interface. */ |
|
|
|
|
/* */ |
|
|
|
|
/* An automatic hinter might compute two kinds of data for a given face: */ |
|
|
|
|
/* */ |
|
|
|
|
/* - global hints: Usually some metrics that describe global properties */ |
|
|
|
|
/* of the face. It is computed by scanning more or less */ |
|
|
|
|
/* agressively the glyphs in the face, and thus can be */ |
|
|
|
|
/* very slow to compute (even if the size of global */ |
|
|
|
|
/* hints is really small). */ |
|
|
|
|
/* */ |
|
|
|
|
/* - glyph hints: These describe some important features of the glyph */ |
|
|
|
|
/* outline, as well as how to align them. They are */ |
|
|
|
|
/* generally much faster to compute than global hints. */ |
|
|
|
|
/* */ |
|
|
|
|
/* The current FreeType auto-hinter does a pretty good job while */ |
|
|
|
|
/* performing fast computations for both global and glyph hints. */ |
|
|
|
|
/* However, we might be interested in introducing more complex and */ |
|
|
|
|
/* powerful algorithms in the future, like the one described in the John */ |
|
|
|
|
/* D. Hobby paper, which unfortunately requires a lot more horsepower. */ |
|
|
|
|
/* */ |
|
|
|
|
/* Because a sufficiently sophisticated font management system would */ |
|
|
|
|
/* typically implement an LRU cache of opened face objects to reduce */ |
|
|
|
|
/* memory usage, it is a good idea to be able to avoid recomputing */ |
|
|
|
|
/* global hints every time the same face is re-opened. */ |
|
|
|
|
/* */ |
|
|
|
|
/* We thus provide the ability to cache global hints outside of the face */ |
|
|
|
|
/* object, in order to speed up font re-opening time. Of course, this */ |
|
|
|
|
/* feature is purely optional, so most client programs won't even notice */ |
|
|
|
|
/* it. */ |
|
|
|
|
/* */ |
|
|
|
|
/* I initially thought that it would be a good idea to cache the glyph */ |
|
|
|
|
/* hints too. However, my general idea now is that if you really need */ |
|
|
|
|
/* to cache these too, you are simply in need of a new font format, */ |
|
|
|
|
/* where all this information could be stored within the font file and */
|
|
|
|
|
/* decoded on the fly. */ |
|
|
|
|
/* */ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <freetype/freetype.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct FT_AutoHinterRec_ *FT_AutoHinter; |
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* |
|
|
|
|
* <FuncType> |
|
|
|
|
* FT_AutoHinter_Get_Global_Func |
|
|
|
|
* |
|
|
|
|
* <Description> |
|
|
|
|
* Retrieve the global hints computed for a given face object |
|
|
|
|
* the resulting data is dissociated from the face and will survive |
|
|
|
|
* a call to FT_Done_Face. It must be discarded through the API |
|
|
|
|
* FT_AutoHinter_Done_Global_Func. |
|
|
|
|
* |
|
|
|
|
* <Input> |
|
|
|
|
* hinter :: handle to source auto-hinter |
|
|
|
|
* face :: handle to source face object |
|
|
|
|
* |
|
|
|
|
* <Output> |
|
|
|
|
* global_hints :: typeless pointer to the global hints |
|
|
|
|
* global_len :: size in bytes of global hints |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
typedef void (*FT_AutoHinter_Get_Global_Func)( FT_AutoHinter hinter, |
|
|
|
|
FT_Face face, |
|
|
|
|
void* *global_hints, |
|
|
|
|
long *global_len ); |
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* |
|
|
|
|
* <FuncType> |
|
|
|
|
* FT_AutoHinter_Done_Global_Func |
|
|
|
|
* |
|
|
|
|
* <Description> |
|
|
|
|
* Discards the global hints retrieved through |
|
|
|
|
* FT_AutoHinter_Get_Global_Func. This is the only way these hints |
|
|
|
|
* are freed from memory. |
|
|
|
|
* |
|
|
|
|
* <Input> |
|
|
|
|
* hinter :: handle to auto-hinter module |
|
|
|
|
* global :: pointer to retrieved global hints to discard |
|
|
|
|
*/ |
|
|
|
|
typedef void (*FT_AutoHinter_Done_Global_Func)( FT_AutoHinter hinter, |
|
|
|
|
void* global ); |
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* |
|
|
|
|
* <FuncType> |
|
|
|
|
* FT_AutoHinter_Reset_Func |
|
|
|
|
* |
|
|
|
|
* <Description> |
|
|
|
|
* This function is used to recompute the global metrics in a given
|
|
|
|
|
* font. This is useful when global font data changes (e.g. multiple |
|
|
|
|
* masters fonts where blend coordinates change..) |
|
|
|
|
* |
|
|
|
|
* <Input> |
|
|
|
|
* hinter :: handle to source auto-hinter |
|
|
|
|
* face :: handle to the face. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
typedef void (*FT_AutoHinter_Reset_Func)( FT_AutoHinter hinter, |
|
|
|
|
FT_Face face ); |
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* |
|
|
|
|
* <FuncType> |
|
|
|
|
* FT_AutoHinter_Load_Func |
|
|
|
|
* |
|
|
|
|
* <Description> |
|
|
|
|
* This function is used to load, scale and automatically hint a glyph |
|
|
|
|
* from a given face. |
|
|
|
|
* |
|
|
|
|
* <Input> |
|
|
|
|
* face :: handle to the face. |
|
|
|
|
* glyph_index :: glyph index |
|
|
|
|
* load_flags :: load flags |
|
|
|
|
* |
|
|
|
|
* <Note> |
|
|
|
|
* This function is capable of loading composite glyphs by hinting |
|
|
|
|
* each sub-glyph independently (which improves quality). |
|
|
|
|
* |
|
|
|
|
* It will call the font driver with FT_Load_Glyph, with FT_LOAD_NO_SCALE |
|
|
|
|
* set.. |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
typedef FT_Error (*FT_AutoHinter_Load_Func)( |
|
|
|
|
FT_AutoHinter hinter, |
|
|
|
|
FT_GlyphSlot slot, |
|
|
|
|
FT_Size size, |
|
|
|
|
FT_UInt glyph_index, |
|
|
|
|
FT_ULong load_flags ); |
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* |
|
|
|
|
* <Struct> |
|
|
|
|
* FT_AutoHinter_Interface |
|
|
|
|
* |
|
|
|
|
* <Description> |
|
|
|
|
* The auto-hinter module's interface. |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
typedef struct FT_AutoHinter_Interface |
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
|
/* <FuncType> */ |
|
|
|
|
/* FT_AutoHinter_Get_Global_Func */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Description> */ |
|
|
|
|
/* Retrieves the global hints computed for a given face object the */ |
|
|
|
|
/* resulting data is dissociated from the face and will survive a */ |
|
|
|
|
/* call to FT_Done_Face(). It must be discarded through the API */ |
|
|
|
|
/* FT_AutoHinter_Done_Global_Func(). */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Input> */ |
|
|
|
|
/* hinter :: A handle to the source auto-hinter. */ |
|
|
|
|
/* */ |
|
|
|
|
/* face :: A handle to the source face object. */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Output> */ |
|
|
|
|
/* global_hints :: A typeless pointer to the global hints. */ |
|
|
|
|
/* */ |
|
|
|
|
/* global_len :: The size in bytes of the global hints. */ |
|
|
|
|
/* */ |
|
|
|
|
typedef void (*FT_AutoHinter_Get_Global_Func)( |
|
|
|
|
FT_AutoHinter hinter, |
|
|
|
|
FT_Face face, |
|
|
|
|
void** global_hints, |
|
|
|
|
long* global_len ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
|
/* <FuncType> */ |
|
|
|
|
/* FT_AutoHinter_Done_Global_Func */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Description> */ |
|
|
|
|
/* Discards the global hints retrieved through */ |
|
|
|
|
/* FT_AutoHinter_Get_Global_Func(). This is the only way these hints */ |
|
|
|
|
/* are freed from memory. */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Input> */ |
|
|
|
|
/* hinter :: A handle to the auto-hinter module. */ |
|
|
|
|
/* */ |
|
|
|
|
/* global :: A pointer to retrieved global hints to discard. */ |
|
|
|
|
/* */ |
|
|
|
|
typedef void (*FT_AutoHinter_Done_Global_Func)( FT_AutoHinter hinter, |
|
|
|
|
void* global ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
|
/* <FuncType> */ |
|
|
|
|
/* FT_AutoHinter_Reset_Func */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Description> */ |
|
|
|
|
/* This function is used to recompute the global metrics in a given */ |
|
|
|
|
/* font. This is useful when global font data changes (e.g. Multiple */ |
|
|
|
|
/* Masters fonts where blend coordinates change). */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Input> */ |
|
|
|
|
/* hinter :: A handle to the source auto-hinter. */ |
|
|
|
|
/* */ |
|
|
|
|
/* face :: A handle to the face. */ |
|
|
|
|
/* */ |
|
|
|
|
typedef void (*FT_AutoHinter_Reset_Func)( FT_AutoHinter hinter, |
|
|
|
|
FT_Face face ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
|
/* <FuncType> */ |
|
|
|
|
/* FT_AutoHinter_Load_Func */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Description> */ |
|
|
|
|
/* This function is used to load, scale, and automatically hint a */ |
|
|
|
|
/* glyph from a given face. */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Input> */ |
|
|
|
|
/* face :: A handle to the face. */ |
|
|
|
|
/* glyph_index :: The glyph index. */ |
|
|
|
|
/* load_flags :: The load flags. */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Note> */ |
|
|
|
|
/* This function is capable of loading composite glyphs by hinting */ |
|
|
|
|
/* each sub-glyph independently (which improves quality). */ |
|
|
|
|
/* */ |
|
|
|
|
/* It will call the font driver with FT_Load_Glyph(), with */ |
|
|
|
|
/* FT_LOAD_NO_SCALE set. */ |
|
|
|
|
/* */ |
|
|
|
|
typedef FT_Error (*FT_AutoHinter_Load_Func)( FT_AutoHinter hinter, |
|
|
|
|
FT_GlyphSlot slot, |
|
|
|
|
FT_Size size, |
|
|
|
|
FT_UInt glyph_index, |
|
|
|
|
FT_ULong load_flags ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
|
/* <Struct> */ |
|
|
|
|
/* FT_AutoHinter_Interface */ |
|
|
|
|
/* */ |
|
|
|
|
/* <Description> */ |
|
|
|
|
/* The auto-hinter module's interface. */ |
|
|
|
|
/* */ |
|
|
|
|
typedef struct FT_AutoHinter_Interface |
|
|
|
|
{ |
|
|
|
|
FT_AutoHinter_Reset_Func reset_face; |
|
|
|
|
FT_AutoHinter_Load_Func load_glyph; |
|
|
|
@ -175,5 +188,8 @@ |
|
|
|
|
|
|
|
|
|
} FT_AutoHinter_Interface; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* AUTOHINT_H */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* END */ |
|
|
|
|