changes used to implement the auto-hinting support
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
diff --git a/demos/src/memtest.c b/demos/src/memtest.c
index b780101..b37afb7 100644
--- a/demos/src/memtest.c
+++ b/demos/src/memtest.c
@@ -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 )
diff --git a/docs/design/index.html b/docs/design/index.html
index f52953d..50f7f29 100644
--- a/docs/design/index.html
+++ b/docs/design/index.html
@@ -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.
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 023e0f1..884089a 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -645,7 +645,7 @@
FT_CharMap charmap;
FT_ListRec sizes_list;
- void* autohint_globals;
+ FT_Generic autohint;
void* extensions;
FT_UShort max_points;
diff --git a/include/freetype/ftmodule.h b/include/freetype/ftmodule.h
index bc8e961..6175b2a 100644
--- a/include/freetype/ftmodule.h
+++ b/include/freetype/ftmodule.h
@@ -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;
diff --git a/include/freetype/internal/autohint.h b/include/freetype/internal/autohint.h
index 277461b..b3409f5 100644
--- a/include/freetype/internal/autohint.h
+++ b/include/freetype/internal/autohint.h
@@ -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. */
@@ -111,47 +111,6 @@
/***********************************************************************
*
* <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>
* FT_AutoHinter_Reset_Func
*
* <Description>
@@ -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;
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index a1ed6c2..bb8c24c 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -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 */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index e4b7271..1df4ec7 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -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 ) )
{
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 3501990..756fb87 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -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;
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 0b25d44..7cd4929 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -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;
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 07c0b20..d43220d 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -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 */
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index bef4a4a..f0e6782 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -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;
diff --git a/src/type1z/z1gload.c b/src/type1z/z1gload.c
index ababad1..25c1264 100644
--- a/src/type1z/z1gload.c
+++ b/src/type1z/z1gload.c
@@ -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;