changes used to implement the auto-hinting support
This commit is contained in:
parent
203bb47cfe
commit
5ae831c101
@ -184,7 +184,7 @@ static void dump_mem( void )
|
||||
}
|
||||
}
|
||||
if (!bad)
|
||||
fprintf( stderr, "no leaked memory block, congratulations ;-)" );
|
||||
fprintf( stderr, "no leaked memory block\n\n" );
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
@ -302,7 +302,7 @@ int main( int argc, char** argv )
|
||||
{
|
||||
for ( id = 0; id < num_glyphs; id++ )
|
||||
{
|
||||
error = FT_Load_Glyph( face, id, FT_LOAD_DEFAULT );
|
||||
error = FT_Load_Glyph( face, id, FT_LOAD_RENDER | FT_LOAD_ANTI_ALIAS );
|
||||
if (error)
|
||||
{
|
||||
if ( Fail < 10 )
|
||||
|
@ -20,19 +20,22 @@ FreeType 2.0 Internals</h1></center>
|
||||
|
||||
<center>
|
||||
<h2>
|
||||
Version 1.0</h2></center>
|
||||
Version 1.2</h2></center>
|
||||
|
||||
<center>
|
||||
<h3>
|
||||
© 1999 David Turner (<a href="fichier :///david@freetype.org">david@freetype.org</a>)<br>
|
||||
© 1999 The FreeType Development Team (<a href="fichier :///devel@freetype.org">devel@freetype.org</a>)</h3></center>
|
||||
© 1999-2000 David Turner (<a href="fichier :///david@freetype.org">david@freetype.org</a>)<br>
|
||||
© 1999-2000 The FreeType Development Team (<a href="fichier :///devel@freetype.org">devel@freetype.org</a>)</h3></center>
|
||||
|
||||
<p><br>
|
||||
<hr WIDTH="100%">
|
||||
<br>
|
||||
<h2>
|
||||
Introduction:</h2>
|
||||
<h2>Introduction:</h2>
|
||||
|
||||
<p>This document describes in great deatils the internals of FreeType 2.
|
||||
It is a must read for porters and developers alike. Its purpose is to
|
||||
|
||||
present the
|
||||
<blockquote>This document describes in great details the internals of the
|
||||
FreeType 2.0 library. It is a must read for porters and developers alike.
|
||||
Its purpose is to present the engine's objects, their roles and interactions.
|
||||
|
@ -645,7 +645,7 @@
|
||||
FT_CharMap charmap;
|
||||
FT_ListRec sizes_list;
|
||||
|
||||
void* autohint_globals;
|
||||
FT_Generic autohint;
|
||||
void* extensions;
|
||||
|
||||
FT_UShort max_points;
|
||||
|
@ -23,11 +23,15 @@
|
||||
/* module bit flags */
|
||||
typedef enum FT_Module_Flags_
|
||||
{
|
||||
ft_module_font_driver = 1, /* this module is a font driver */
|
||||
ft_module_renderer = 2, /* this module is a renderer */
|
||||
ft_module_font_driver = 1, /* this module is a font driver */
|
||||
ft_module_renderer = 2, /* this module is a renderer */
|
||||
ft_module_hinter = 4, /* this module is a glyph hinter */
|
||||
ft_module_styler = 8, /* this module is a styler */
|
||||
|
||||
ft_module_driver_scalable = 4, /* this driver supports scalable fonts */
|
||||
ft_module_driver_no_outlines = 8 /* this driver does not support vector outlines */
|
||||
ft_module_driver_scalable = 0x100, /* the driver supports scalable fonts */
|
||||
ft_module_driver_no_outlines = 0x200, /* the driver does not support vector outlines */
|
||||
|
||||
ft_module_driver_has_hinter = 0x400 /* the driver provides its own hinter */
|
||||
|
||||
} FT_Module_Flags;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* */
|
||||
/* autohint.h */
|
||||
/* */
|
||||
/* High-level `autohint" driver interface (specification) */
|
||||
/* High-level `autohint" module-specific interface (specification) */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
@ -108,47 +108,6 @@
|
||||
typedef void (*FT_AutoHinter_Done_Global_Func)( FT_AutoHinter hinter,
|
||||
void* global );
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <FuncType>
|
||||
* FT_AutoHinter_Init_Func
|
||||
*
|
||||
* <Description>
|
||||
* Compute or set the global hints for a given face object.
|
||||
*
|
||||
* <Input>
|
||||
* hinter :: handle to source auto-hinter module
|
||||
* face :: handle to target face object.
|
||||
* global_hints :: typeless pointer to global hints. If 0, the
|
||||
* hints are computed for the face
|
||||
*
|
||||
* <Note>
|
||||
* it is up to client applications to ensure that the global hints
|
||||
* were retrieved for the same face object. Strange results may occur
|
||||
* otherwise..
|
||||
*
|
||||
*/
|
||||
typedef FT_Error (*FT_AutoHinter_Init_Func)( FT_AutoHinter hinter,
|
||||
FT_Face face,
|
||||
void* global_hints );
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <FuncType>
|
||||
* FT_AutoHinter_Done_Func
|
||||
*
|
||||
* <Description>
|
||||
* Discards the global hints for a given face..
|
||||
*
|
||||
* <Input>
|
||||
* hinter :: handle to source auto-hinter module
|
||||
* face :: handle to target face object.
|
||||
*
|
||||
*/
|
||||
typedef FT_Error (*FT_AutoHinter_Done_Func)( FT_AutoHinter hinter,
|
||||
FT_Face face );
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <FuncType>
|
||||
@ -165,8 +124,8 @@
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef FT_Error (*FT_AutoHinter_Reset_Func)( FT_AutoHinter hinter,
|
||||
FT_Face face );
|
||||
typedef void (*FT_AutoHinter_Reset_Func)( FT_AutoHinter hinter,
|
||||
FT_Face face );
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
@ -190,9 +149,12 @@
|
||||
* set..
|
||||
*
|
||||
*/
|
||||
typedef FT_Error (*FT_AutoHinter_Load_Func)( FT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_ULong load_flags );
|
||||
typedef FT_Error (*FT_AutoHinter_Load_Func)(
|
||||
FT_AutoHinter hinter,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Size size,
|
||||
FT_UInt glyph_index,
|
||||
FT_ULong load_flags );
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
@ -205,10 +167,8 @@
|
||||
*/
|
||||
typedef struct FT_AutoHinter_Interface
|
||||
{
|
||||
FT_AutoHinter_Init_Func init_autohinter;
|
||||
FT_AutoHinter_Done_Func done_autohinter;
|
||||
FT_AutoHinter_Reset_Func reset_face;
|
||||
FT_AutoHinter_Load_Func load_glyph;
|
||||
FT_AutoHinter_Reset_Func reset_face;
|
||||
FT_AutoHinter_Load_Func load_glyph;
|
||||
|
||||
FT_AutoHinter_Get_Global_Func get_global_hints;
|
||||
FT_AutoHinter_Done_Global_Func done_global_hints;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <freetype/internal/ftmemory.h>
|
||||
#include <freetype/ftrender.h>
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
#include <freetype/internal/autohint.h>
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
@ -120,12 +121,20 @@
|
||||
#define FT_MODULE_IS_RENDERER(x) (FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_renderer )
|
||||
|
||||
#define FT_MODULE_IS_HINTER(x) (FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_hinter )
|
||||
|
||||
#define FT_MODULE_IS_STYLER(x) (FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_styler )
|
||||
|
||||
#define FT_DRIVER_IS_SCALABLE(x) (FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_driver_scalable )
|
||||
|
||||
#define FT_DRIVER_USES_OUTLINES(x) !(FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_driver_no_outlines )
|
||||
|
||||
#define FT_DRIVER_HAS_HINTER(x) (FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_driver_has_hinter )
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
@ -389,6 +398,7 @@
|
||||
|
||||
FT_ListRec renderers; /* list of renderers */
|
||||
FT_Renderer cur_renderer; /* current outline renderer */
|
||||
FT_Module auto_hinter;
|
||||
|
||||
void* raster_pool; /* scan-line conversion render pool */
|
||||
unsigned long raster_pool_size; /* size of render pool in bytes */
|
||||
|
@ -678,8 +678,15 @@
|
||||
static
|
||||
void ft_glyphslot_clear( FT_GlyphSlot slot )
|
||||
{
|
||||
/* free bitmap if needed */
|
||||
if ( slot->flags & ft_glyph_own_bitmap )
|
||||
{
|
||||
FT_Memory memory = FT_FACE_MEMORY( slot->face );
|
||||
FREE( slot->bitmap.buffer );
|
||||
slot->flags &= ~ft_glyph_own_bitmap;
|
||||
}
|
||||
|
||||
/* clear all public fields in the glyph slot */
|
||||
|
||||
MEM_Set( &slot->metrics, 0, sizeof ( slot->metrics ) );
|
||||
MEM_Set( &slot->outline, 0, sizeof ( slot->outline ) );
|
||||
MEM_Set( &slot->bitmap, 0, sizeof ( slot->bitmap ) );
|
||||
@ -931,6 +938,9 @@
|
||||
FT_Error error;
|
||||
FT_Driver driver;
|
||||
FT_GlyphSlot slot;
|
||||
FT_Library library;
|
||||
FT_Bool autohint;
|
||||
FT_Module hinter;
|
||||
|
||||
|
||||
if ( !face || !face->size || !face->glyph )
|
||||
@ -948,10 +958,31 @@
|
||||
if ( load_flags & FT_LOAD_NO_RECURSE )
|
||||
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
|
||||
|
||||
error = driver->clazz->load_glyph( slot,
|
||||
face->size,
|
||||
glyph_index,
|
||||
load_flags );
|
||||
/* do we need to load the glyph through the auto-hinter ?? */
|
||||
library = driver->root.library;
|
||||
hinter = library->auto_hinter;
|
||||
autohint = hinter &&
|
||||
!(load_flags & (FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING));
|
||||
if (autohint)
|
||||
{
|
||||
if ( FT_DRIVER_HAS_HINTER( driver ) &&
|
||||
!(load_flags & FT_LOAD_FORCE_AUTOHINT) )
|
||||
autohint = 0;
|
||||
}
|
||||
|
||||
if (autohint)
|
||||
{
|
||||
FT_AutoHinter_Interface* hinting;
|
||||
|
||||
hinting = (FT_AutoHinter_Interface*)hinter->clazz->module_interface;
|
||||
error = hinting->load_glyph( (FT_AutoHinter)hinter, slot, face->size,
|
||||
glyph_index, load_flags );
|
||||
}
|
||||
else
|
||||
error = driver->clazz->load_glyph( slot,
|
||||
face->size,
|
||||
glyph_index,
|
||||
load_flags );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
@ -982,6 +1013,16 @@
|
||||
FT_Vector_Transform( &slot->advance, &face->transform_matrix );
|
||||
}
|
||||
|
||||
/* do we need to render the image now ? */
|
||||
if ( !error &&
|
||||
slot->format != ft_glyph_format_bitmap &&
|
||||
slot->format != ft_glyph_format_composite &&
|
||||
load_flags & FT_LOAD_RENDER )
|
||||
{
|
||||
error = FT_Render_Glyph( slot, (load_flags & FT_LOAD_ANTI_ALIAS) ?
|
||||
ft_render_mode_antialias : 0 );
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
@ -1039,8 +1080,7 @@
|
||||
if ( face->charmap )
|
||||
glyph_index = FT_Get_Char_Index( face, char_code );
|
||||
|
||||
return glyph_index ? FT_Load_Glyph( face, glyph_index, load_flags )
|
||||
: FT_Err_Invalid_Character_Code;
|
||||
return FT_Load_Glyph( face, glyph_index, load_flags );
|
||||
}
|
||||
|
||||
|
||||
@ -2618,14 +2658,18 @@
|
||||
static
|
||||
void Destroy_Module( FT_Module module )
|
||||
{
|
||||
FT_Memory memory = module->memory;
|
||||
FT_Module_Class* clazz = module->clazz;
|
||||
FT_Memory memory = module->memory;
|
||||
FT_Module_Class* clazz = module->clazz;
|
||||
FT_Library library = module->library;
|
||||
|
||||
|
||||
/* finalize client-data - before anything else */
|
||||
if ( module->generic.finalizer )
|
||||
module->generic.finalizer( module );
|
||||
|
||||
if ( library && library->auto_hinter == module )
|
||||
library->auto_hinter = 0;
|
||||
|
||||
/* if the module is a renderer */
|
||||
if ( FT_MODULE_IS_RENDERER( module ) )
|
||||
ft_remove_renderer( module );
|
||||
@ -2729,6 +2773,10 @@
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
/* is the module a auto-hinter ? */
|
||||
if ( FT_MODULE_IS_HINTER(module) )
|
||||
library->auto_hinter = module;
|
||||
|
||||
/* if the module is a font driver */
|
||||
if ( FT_MODULE_IS_DRIVER( module ) )
|
||||
{
|
||||
|
@ -491,6 +491,7 @@
|
||||
|
||||
/* set up remaining glyph fields */
|
||||
glyph->num_subglyphs = 2;
|
||||
glyph->subglyphs = loader->current.subglyphs;
|
||||
glyph->format = ft_glyph_format_composite;
|
||||
|
||||
loader->current.num_subglyphs = 2;
|
||||
|
@ -84,7 +84,7 @@
|
||||
}
|
||||
|
||||
/* check mode */
|
||||
if ( !(mode & ft_render_mode_antialias) )
|
||||
if ( mode != ft_render_mode_antialias )
|
||||
return FT_Err_Cannot_Render_Glyph;
|
||||
|
||||
outline = &slot->outline;
|
||||
|
@ -423,7 +423,10 @@
|
||||
const FT_Driver_Class tt_driver_class =
|
||||
{
|
||||
{
|
||||
ft_module_font_driver | ft_module_driver_scalable,
|
||||
ft_module_font_driver |
|
||||
ft_module_driver_scalable |
|
||||
ft_module_driver_has_hinter,
|
||||
|
||||
sizeof ( TT_DriverRec ),
|
||||
|
||||
"truetype", /* driver name */
|
||||
|
@ -313,6 +313,7 @@
|
||||
|
||||
/* set up remaining glyph fields */
|
||||
glyph->num_subglyphs = 2;
|
||||
glyph->subglyphs = loader->current.subglyphs;
|
||||
glyph->format = ft_glyph_format_composite;
|
||||
|
||||
loader->current.num_subglyphs = 2;
|
||||
|
@ -455,6 +455,7 @@
|
||||
|
||||
/* set up remaining glyph fields */
|
||||
glyph->num_subglyphs = 2;
|
||||
glyph->subglyphs = loader->base.subglyphs;
|
||||
glyph->format = ft_glyph_format_composite;
|
||||
|
||||
loader->current.num_subglyphs = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user