2000-08-23 19:32:42 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
2000-08-24 18:29:15 +02:00
|
|
|
/* ftcmanag.c */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* */
|
2000-08-24 18:29:15 +02:00
|
|
|
/* FreeType Cache Manager (body). */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* */
|
2001-06-28 19:49:10 +02:00
|
|
|
/* Copyright 2000-2001 by */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_CACHE_H
|
|
|
|
#include FT_CACHE_MANAGER_H
|
2001-10-26 18:58:27 +02:00
|
|
|
#include FT_CACHE_INTERNAL_LRU_H
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
2001-10-07 15:30:26 +02:00
|
|
|
#include FT_SIZES_H
|
2000-08-23 13:22:30 +02:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "ftcerror.h"
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_cache
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
#define FTC_LRU_GET_MANAGER( lru ) ( (FTC_Manager)(lru)->user_data )
|
2000-08-23 19:32:42 +02:00
|
|
|
|
|
|
|
|
2000-08-29 18:50:01 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
2001-10-26 18:58:27 +02:00
|
|
|
/***** FACE LRU IMPLEMENTATION *****/
|
2000-08-29 18:50:01 +02:00
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
typedef struct FTC_FaceNodeRec_* FTC_FaceNode;
|
|
|
|
typedef struct FTC_SizeNodeRec_* FTC_SizeNode;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
typedef struct FTC_FaceNodeRec_
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
FT_LruNodeRec lru;
|
|
|
|
FT_Face face;
|
|
|
|
|
|
|
|
} FTC_FaceNodeRec;
|
|
|
|
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
typedef struct FTC_SizeNodeRec_
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
FT_LruNodeRec lru;
|
|
|
|
FT_Size size;
|
|
|
|
|
|
|
|
} FTC_SizeNodeRec;
|
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2001-12-20 18:49:10 +01:00
|
|
|
ftc_face_node_init( FTC_FaceNode node,
|
|
|
|
FTC_FaceID face_id,
|
|
|
|
FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
FT_Error error;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
error = manager->request_face( face_id,
|
2000-08-23 23:11:13 +02:00
|
|
|
manager->library,
|
2000-08-23 13:22:30 +02:00
|
|
|
manager->request_data,
|
2001-10-26 18:58:27 +02:00
|
|
|
&node->face );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
/* destroy initial size object; it will be re-created later */
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( node->face->size )
|
|
|
|
FT_Done_Size( node->face->size );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
/* helper function for ftc_face_node_done() */
|
2001-12-05 02:22:05 +01:00
|
|
|
FT_CALLBACK_DEF( FT_Bool )
|
|
|
|
ftc_size_node_select( FTC_SizeNode node,
|
|
|
|
FT_Face face )
|
|
|
|
{
|
|
|
|
return FT_BOOL( node->size->face == face );
|
|
|
|
}
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( void )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_face_node_done( FTC_FaceNode node,
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
FT_Face face = node->face;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
/* we must begin by removing all sizes for the target face */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* from the manager's list */
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_LruList_Remove_Selection( manager->sizes_list,
|
2001-12-05 02:22:05 +01:00
|
|
|
(FT_LruNode_SelectFunc)ftc_size_node_select,
|
2001-10-26 18:58:27 +02:00
|
|
|
face );
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/* all right, we can discard the face now */
|
2000-08-23 13:22:30 +02:00
|
|
|
FT_Done_Face( face );
|
2001-10-26 18:58:27 +02:00
|
|
|
node->face = NULL;
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_CALLBACK_TABLE_DEF
|
2001-12-05 02:22:05 +01:00
|
|
|
const FT_LruList_ClassRec ftc_face_list_class =
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2001-12-05 02:22:05 +01:00
|
|
|
sizeof ( FT_LruListRec ),
|
2001-12-20 18:49:10 +01:00
|
|
|
(FT_LruList_InitFunc)0,
|
|
|
|
(FT_LruList_DoneFunc)0,
|
2001-12-05 02:22:05 +01:00
|
|
|
|
|
|
|
sizeof ( FTC_FaceNodeRec ),
|
|
|
|
(FT_LruNode_InitFunc) ftc_face_node_init,
|
|
|
|
(FT_LruNode_DoneFunc) ftc_face_node_done,
|
|
|
|
(FT_LruNode_FlushFunc) 0, /* no flushing needed */
|
|
|
|
(FT_LruNode_CompareFunc)0, /* direct comparison of FTC_FaceID handles */
|
2001-10-26 18:58:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
/* documentation is in ftcache.h */
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FTC_Manager_Lookup_Face( FTC_Manager manager,
|
|
|
|
FTC_FaceID face_id,
|
|
|
|
FT_Face *aface )
|
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FTC_FaceNode node;
|
|
|
|
|
|
|
|
|
|
|
|
if ( aface == NULL )
|
|
|
|
return FTC_Err_Bad_Argument;
|
|
|
|
|
|
|
|
*aface = NULL;
|
|
|
|
|
|
|
|
if ( !manager )
|
|
|
|
return FTC_Err_Invalid_Cache_Handle;
|
|
|
|
|
|
|
|
error = FT_LruList_Lookup( manager->faces_list,
|
|
|
|
(FT_LruKey)face_id,
|
|
|
|
(FT_LruNode*)&node );
|
|
|
|
if ( !error )
|
|
|
|
*aface = node->face;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** SIZES LRU IMPLEMENTATION *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct FTC_SizeQueryRec_
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Face face;
|
|
|
|
FT_UInt width;
|
|
|
|
FT_UInt height;
|
|
|
|
|
|
|
|
} FTC_SizeQueryRec, *FTC_SizeQuery;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_size_node_init( FTC_SizeNode node,
|
|
|
|
FTC_SizeQuery query )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Face face = query->face;
|
|
|
|
FT_Size size;
|
|
|
|
FT_Error error;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
node->size = NULL;
|
2000-08-24 13:53:35 +02:00
|
|
|
error = FT_New_Size( face, &size );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-10-07 15:30:26 +02:00
|
|
|
FT_Activate_Size( size );
|
2001-10-26 18:58:27 +02:00
|
|
|
error = FT_Set_Pixel_Sizes( query->face,
|
|
|
|
query->width,
|
|
|
|
query->height );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error )
|
|
|
|
FT_Done_Size( size );
|
2000-08-23 13:22:30 +02:00
|
|
|
else
|
2001-10-26 18:58:27 +02:00
|
|
|
node->size = size;
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
return error;
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( void )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_size_node_done( FTC_SizeNode node )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( node->size )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
FT_Done_Size( node->size );
|
|
|
|
node->size = NULL;
|
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
}
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_size_node_flush( FTC_SizeNode node,
|
|
|
|
FTC_SizeQuery query )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Size size = node->size;
|
|
|
|
FT_Error error;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( size->face == query->face )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
Fixed a bug in `glnames.py' that prevented it from generating
correct glyph names tables. This resulted in the unavailability of
certain glyphs like `Cacute', `cacute' and `lslash' in Unicode
charmaps, even if these were present in the font (causing problems
for Polish users).
* src/tools/glnames.py (mac_standard_names): Fixed.
(t1_standard_strings): Some fixes and renamed to ...
(sid_standard_names): This.
(t1_expert_encoding): Fixed.
(the_adobe_glyph_list): Renamed to ...
(adobe_glyph_names): This.
(the_adobe_glyphs): Renamed to ...
(adobe_glyph_values): This.
(dump_mac_indices, dump_glyph_list, dump_unicode_values, main):
Updated.
* src/psnames/pstables.h: Regenerated.
* src/psnames/psmodule.c (PS_Unicode_Value): Fix offset.
Fix return value.
Use `sid_standard_table' and `ps_names_to_unicode' instead of
`t1_standard_glyphs' and `names_to_unicode'.
(PS_Macintosh_Name): Use `ps_glyph_names' instead of
`standard_glyph_names'.
(PS_Standard_Strings): Use `sid_standard_names' instead of
`t1_standard_glyphs'.
* doc/BUGS, doc/TODO: New documents.
* src/cache/ftlru.c (FT_Lru_Lookup_Node): Fixed a bug that prevented
correct LRU behaviour.
setjmp() and longjmp() are now used for rollback (i.e. when memory
pool overflow occurs).
Function names are now all uniformly prefixed with `gray_'.
* src/smooth/ftgrays.c: Include <setjmp.h>.
(ErrRaster_MemoryOverflow): New macro.
(TArea): New type to store area values in each cell (using `int' was
too small on 16-bit systems). <limits.h> is included to properly
get the needed data type.
(TCell, TRaster): Use it.
(TRaster): New element `jump_buffer'.
(gray_compute_cbox): Use `RAS_ARG' as the only parameter and get
`outline' from it.
(gray_record_cell): Use longjmp().
(gray_set_cell): Use gray_record_cell() for error handling.
(gray_render_line, gray_render_conic, gray_render_cubic): Simplify.
(gray_convert_glyph_inner): New function, using setjmp().
(gray_convert_glyph): Use it.
Provide a public API to manage multiple size objects for a given
FT_Face in the new header file `ftsizes.h'.
* include/freetype/ftsizes.h: New header file,
* include/freetype/internal/ftobjs.h: Use it.
Remove declarations of FT_New_Size and FT_Done_Size (moved to
ftsizes.h).
* include/freetype/config/ftheader.h (FT_SIZES_H): New macro.
* src/base/ftobjs.c (FT_Activate_Size): New function.
* src/cache/ftcmanag.c: Include ftsizes.h.
(ftc_manager_init_size, ftc_manager_flush_size): Use
FT_Activate_Size.
2001-10-10 21:56:42 +02:00
|
|
|
FT_Activate_Size( size );
|
2001-10-26 18:58:27 +02:00
|
|
|
error = FT_Set_Pixel_Sizes( query->face, query->width, query->height );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2000-08-23 13:22:30 +02:00
|
|
|
FT_Done_Size( size );
|
2001-10-26 18:58:27 +02:00
|
|
|
node->size = NULL;
|
|
|
|
}
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_Done_Size( size );
|
2001-10-26 18:58:27 +02:00
|
|
|
node->size = NULL;
|
|
|
|
|
|
|
|
error = ftc_size_node_init( node, query );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Bool )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_size_node_compare( FTC_SizeNode node,
|
|
|
|
FTC_SizeQuery query )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Size size = node->size;
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
|
|
|
return FT_BOOL( size->face == query->face &&
|
|
|
|
(FT_UInt)size->metrics.x_ppem == query->width &&
|
|
|
|
(FT_UInt)size->metrics.y_ppem == query->height );
|
2000-08-23 19:32:42 +02:00
|
|
|
}
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-11-04 02:55:49 +01:00
|
|
|
FT_CALLBACK_TABLE_DEF
|
2001-10-26 18:58:27 +02:00
|
|
|
const FT_LruList_ClassRec ftc_size_list_class =
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
sizeof ( FT_LruListRec ),
|
2001-12-20 18:49:10 +01:00
|
|
|
(FT_LruList_InitFunc)0,
|
|
|
|
(FT_LruList_DoneFunc)0,
|
2001-12-05 02:22:05 +01:00
|
|
|
|
|
|
|
sizeof ( FTC_SizeNodeRec ),
|
|
|
|
(FT_LruNode_InitFunc) ftc_size_node_init,
|
|
|
|
(FT_LruNode_DoneFunc) ftc_size_node_done,
|
|
|
|
(FT_LruNode_FlushFunc) ftc_size_node_flush,
|
|
|
|
(FT_LruNode_CompareFunc)ftc_size_node_compare
|
2000-08-23 13:22:30 +02:00
|
|
|
};
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
/* documentation is in ftcache.h */
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FTC_Manager_Lookup_Size( FTC_Manager manager,
|
|
|
|
FTC_Font font,
|
|
|
|
FT_Face *aface,
|
|
|
|
FT_Size *asize )
|
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
|
|
|
|
|
|
|
|
/* check for valid `manager' delayed to FTC_Manager_Lookup_Face() */
|
|
|
|
if ( aface )
|
|
|
|
*aface = 0;
|
|
|
|
|
|
|
|
if ( asize )
|
|
|
|
*asize = 0;
|
|
|
|
|
|
|
|
error = FTC_Manager_Lookup_Face( manager, font->face_id, aface );
|
|
|
|
if ( !error )
|
|
|
|
{
|
|
|
|
FTC_SizeQueryRec query;
|
|
|
|
FTC_SizeNode node;
|
|
|
|
|
|
|
|
|
|
|
|
query.face = *aface;
|
|
|
|
query.width = font->pix_width;
|
|
|
|
query.height = font->pix_height;
|
|
|
|
|
|
|
|
error = FT_LruList_Lookup( manager->sizes_list,
|
|
|
|
(FT_LruKey)&query,
|
|
|
|
(FT_LruNode*)&node );
|
|
|
|
if ( !error )
|
|
|
|
{
|
|
|
|
/* select the size as the current one for this face */
|
|
|
|
FT_Activate_Size( node->size );
|
|
|
|
|
|
|
|
if ( asize )
|
|
|
|
*asize = node->size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** SET TABLE MANAGEMENT *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
ftc_family_table_init( FTC_FamilyTable table )
|
|
|
|
{
|
|
|
|
table->count = 0;
|
|
|
|
table->size = 0;
|
|
|
|
table->entries = NULL;
|
|
|
|
table->free = FTC_FAMILY_ENTRY_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ftc_family_table_done( FTC_FamilyTable table,
|
|
|
|
FT_Memory memory )
|
|
|
|
{
|
|
|
|
FREE( table->entries );
|
|
|
|
table->free = 0;
|
|
|
|
table->count = 0;
|
|
|
|
table->size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-16 09:17:33 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2001-12-05 16:59:33 +01:00
|
|
|
ftc_family_table_alloc( FTC_FamilyTable table,
|
|
|
|
FT_Memory memory,
|
|
|
|
FTC_FamilyEntry *aentry )
|
|
|
|
{
|
|
|
|
FTC_FamilyEntry entry;
|
|
|
|
FT_Error error = 0;
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
|
|
|
|
/* re-allocate table size when needed */
|
2001-12-05 16:59:33 +01:00
|
|
|
if ( table->free == FTC_FAMILY_ENTRY_NONE && table->count >= table->size )
|
|
|
|
{
|
|
|
|
FT_UInt old_size = table->size;
|
|
|
|
FT_UInt new_size, index;
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
if ( old_size == 0 )
|
|
|
|
new_size = 8;
|
|
|
|
else
|
|
|
|
{
|
2001-12-20 18:49:10 +01:00
|
|
|
new_size = old_size * 2;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
/* check for (unlikely) overflow */
|
|
|
|
if ( new_size < old_size )
|
|
|
|
new_size = 65534;
|
|
|
|
}
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
if ( REALLOC_ARRAY( table->entries, old_size, new_size,
|
|
|
|
FTC_FamilyEntryRec ) )
|
2001-12-05 16:59:33 +01:00
|
|
|
return error;
|
|
|
|
|
|
|
|
table->size = new_size;
|
|
|
|
|
|
|
|
entry = table->entries + old_size;
|
|
|
|
table->free = old_size;
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
for ( index = old_size; index + 1 < new_size; index++, entry++ )
|
2001-12-05 16:59:33 +01:00
|
|
|
{
|
2001-12-20 18:49:10 +01:00
|
|
|
entry->link = index + 1;
|
2001-12-05 16:59:33 +01:00
|
|
|
entry->index = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry->link = FTC_FAMILY_ENTRY_NONE;
|
|
|
|
entry->index = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( table->free != FTC_FAMILY_ENTRY_NONE )
|
|
|
|
{
|
|
|
|
entry = table->entries + table->free;
|
|
|
|
table->free = entry->link;
|
|
|
|
}
|
|
|
|
else if ( table->count < table->size )
|
|
|
|
{
|
|
|
|
entry = table->entries + table->count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-12-20 18:49:10 +01:00
|
|
|
FT_ERROR(( "ftc_family_table_alloc: internal bug!" ));
|
2001-12-05 16:59:33 +01:00
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry->link = FTC_FAMILY_ENTRY_NONE;
|
|
|
|
table->count++;
|
|
|
|
|
|
|
|
*aentry = entry;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-16 09:17:33 +01:00
|
|
|
FT_EXPORT_DEF( void )
|
2001-12-05 16:59:33 +01:00
|
|
|
ftc_family_table_free( FTC_FamilyTable table,
|
|
|
|
FT_UInt index )
|
|
|
|
{
|
|
|
|
/* simply add it to the linked list of free entries */
|
|
|
|
if ( index < table->count )
|
|
|
|
{
|
|
|
|
FTC_FamilyEntry entry = table->entries + index;
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
if ( entry->link != FTC_FAMILY_ENTRY_NONE )
|
2001-12-20 18:49:10 +01:00
|
|
|
FT_ERROR(( "ftc_family_table_free: internal bug!\n" ));
|
2001-12-05 16:59:33 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
entry->link = table->free;
|
|
|
|
table->free = entry->index;
|
|
|
|
table->count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** CACHE MANAGER ROUTINES *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
/* documentation is in ftcache.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FTC_Manager_New( FT_Library library,
|
|
|
|
FT_UInt max_faces,
|
|
|
|
FT_UInt max_sizes,
|
|
|
|
FT_ULong max_bytes,
|
|
|
|
FTC_Face_Requester requester,
|
|
|
|
FT_Pointer req_data,
|
|
|
|
FTC_Manager *amanager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
|
|
|
FT_Error error;
|
2000-08-24 18:29:15 +02:00
|
|
|
FT_Memory memory;
|
2000-08-23 13:22:30 +02:00
|
|
|
FTC_Manager manager = 0;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( !library )
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return FTC_Err_Invalid_Library_Handle;
|
2000-08-24 18:29:15 +02:00
|
|
|
|
|
|
|
memory = library->memory;
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( ALLOC( manager, sizeof ( *manager ) ) )
|
2000-08-23 13:22:30 +02:00
|
|
|
goto Exit;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( max_faces == 0 )
|
2000-09-19 03:11:11 +02:00
|
|
|
max_faces = FTC_MAX_FACES_DEFAULT;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( max_sizes == 0 )
|
2000-09-19 03:11:11 +02:00
|
|
|
max_sizes = FTC_MAX_SIZES_DEFAULT;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
if ( max_bytes == 0 )
|
|
|
|
max_bytes = FTC_MAX_BYTES_DEFAULT;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
error = FT_LruList_New( &ftc_face_list_class,
|
|
|
|
max_faces,
|
|
|
|
manager,
|
|
|
|
memory,
|
|
|
|
&manager->faces_list );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error )
|
2000-08-23 13:22:30 +02:00
|
|
|
goto Exit;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
error = FT_LruList_New( &ftc_size_list_class,
|
|
|
|
max_sizes,
|
|
|
|
manager,
|
|
|
|
memory,
|
|
|
|
&manager->sizes_list );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error )
|
2000-08-23 13:22:30 +02:00
|
|
|
goto Exit;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
manager->library = library;
|
2001-10-26 18:58:27 +02:00
|
|
|
manager->max_weight = max_bytes;
|
|
|
|
manager->cur_weight = 0;
|
2001-10-29 11:45:57 +01:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
manager->request_face = requester;
|
|
|
|
manager->request_data = req_data;
|
2001-10-07 15:30:26 +02:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
ftc_family_table_init( &manager->families );
|
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
*amanager = manager;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
Exit:
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error && manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_LruList_Destroy( manager->faces_list );
|
|
|
|
FT_LruList_Destroy( manager->sizes_list );
|
2000-08-23 13:22:30 +02:00
|
|
|
FREE( manager );
|
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
return error;
|
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
/* documentation is in ftcache.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FTC_Manager_Done( FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-24 18:29:15 +02:00
|
|
|
FT_Memory memory;
|
2000-09-19 03:11:11 +02:00
|
|
|
FT_UInt index;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( !manager || !manager->library )
|
|
|
|
return;
|
|
|
|
|
|
|
|
memory = manager->library->memory;
|
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
/* now discard all caches */
|
|
|
|
for (index = 0; index < FTC_MAX_CACHES; index++ )
|
|
|
|
{
|
|
|
|
FTC_Cache cache = manager->caches[index];
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
if ( cache )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
cache->clazz->cache_done( cache );
|
2000-10-12 07:05:40 +02:00
|
|
|
FREE( cache );
|
2000-09-19 03:11:11 +02:00
|
|
|
manager->caches[index] = 0;
|
|
|
|
}
|
|
|
|
}
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
/* discard families table */
|
|
|
|
ftc_family_table_done( &manager->families, memory );
|
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
/* discard faces and sizes */
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_LruList_Destroy( manager->faces_list );
|
|
|
|
manager->faces_list = 0;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_LruList_Destroy( manager->sizes_list );
|
|
|
|
manager->sizes_list = 0;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
FREE( manager );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
/* documentation is in ftcache.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FTC_Manager_Reset( FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( manager )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_LruList_Reset( manager->sizes_list );
|
|
|
|
FT_LruList_Reset( manager->faces_list );
|
2000-09-19 03:11:11 +02:00
|
|
|
}
|
2000-10-31 23:13:54 +01:00
|
|
|
/* XXX: FIXME: flush the caches? */
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
#ifdef FT_DEBUG_ERROR
|
2001-12-20 18:49:10 +01:00
|
|
|
|
|
|
|
FT_EXPORT_DEF( void )
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_Manager_Check( FTC_Manager manager )
|
|
|
|
{
|
|
|
|
FTC_Node node, first;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
first = manager->nodes_list;
|
|
|
|
|
|
|
|
/* check node weights */
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( first )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
FT_ULong weight = 0;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
node = first;
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
do
|
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_FamilyEntry entry = manager->families.entries + node->fam_index;
|
|
|
|
FTC_Cache cache;
|
|
|
|
|
|
|
|
if ( (FT_UInt)node->fam_index >= manager->families.count ||
|
|
|
|
entry->link != FTC_FAMILY_ENTRY_NONE )
|
2001-12-20 18:49:10 +01:00
|
|
|
FT_ERROR(( "FTC_Manager_Check: invalid node (family index = %ld\n",
|
2001-12-05 16:59:33 +01:00
|
|
|
node->fam_index ));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cache = entry->cache;
|
|
|
|
weight += cache->clazz->node_weight( node, cache );
|
|
|
|
}
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
node = node->mru_next;
|
2001-12-20 18:49:10 +01:00
|
|
|
|
|
|
|
} while ( node != first );
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( weight != manager->cur_weight )
|
2001-12-20 18:49:10 +01:00
|
|
|
FT_ERROR(( "FTC_Manager_Check: invalid weight %ld instead of %ld\n",
|
|
|
|
manager->cur_weight, weight ));
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check circular list */
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( first )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
FT_UFast count = 0;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
node = first;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
node = node->mru_next;
|
2001-12-20 18:49:10 +01:00
|
|
|
|
|
|
|
} while ( node != first );
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( count != manager->num_nodes )
|
2001-12-05 02:22:05 +01:00
|
|
|
FT_ERROR((
|
2001-12-20 18:49:10 +01:00
|
|
|
"FTC_Manager_Check: invalid cache node count %d instead of %d\n",
|
2001-12-05 02:22:05 +01:00
|
|
|
manager->num_nodes, count ));
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
|
|
|
}
|
2001-12-20 18:49:10 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
#endif /* FT_DEBUG_ERROR */
|
2001-10-26 18:58:27 +02:00
|
|
|
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/* `Compress' the manager's data, i.e., get rid of old cache nodes */
|
2000-09-19 03:11:11 +02:00
|
|
|
/* that are not referenced anymore in order to limit the total */
|
2000-10-12 07:05:40 +02:00
|
|
|
/* memory used by the cache. */
|
2001-06-28 19:49:10 +02:00
|
|
|
|
|
|
|
/* documentation is in ftcmanag.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FTC_Manager_Compress( FTC_Manager manager )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_Node node, first;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( !manager )
|
|
|
|
return;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
first = manager->nodes_list;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
#ifdef FT_DEBUG_ERROR
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_Manager_Check( manager );
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_ERROR(( "compressing, weight = %ld, max = %ld, nodes = %d\n",
|
2001-12-05 02:22:05 +01:00
|
|
|
manager->cur_weight, manager->max_weight,
|
|
|
|
manager->num_nodes ));
|
2001-10-26 18:58:27 +02:00
|
|
|
#endif
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( manager->cur_weight < manager->max_weight || first == NULL )
|
|
|
|
return;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
/* go to last node - it's a circular list */
|
|
|
|
node = first->mru_prev;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
FTC_Node prev = node->mru_prev;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
prev = ( node == first ) ? NULL : node->mru_prev;
|
|
|
|
|
|
|
|
if ( node->ref_count <= 0 )
|
|
|
|
ftc_node_destroy( node, manager );
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
node = prev;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
} while ( node && manager->cur_weight > manager->max_weight );
|
|
|
|
}
|
2000-09-19 03:11:11 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
/* documentation is in ftcmanag.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_Manager_Register_Cache( FTC_Manager manager,
|
|
|
|
FTC_Cache_Class clazz,
|
|
|
|
FTC_Cache *acache )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Error error = FTC_Err_Invalid_Argument;
|
|
|
|
FTC_Cache cache = NULL;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
if ( manager && clazz && acache )
|
|
|
|
{
|
|
|
|
FT_Memory memory = manager->library->memory;
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_UInt index = 0;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
|
|
|
|
/* check for an empty cache slot in the manager's table */
|
|
|
|
for ( index = 0; index < FTC_MAX_CACHES; index++ )
|
|
|
|
{
|
|
|
|
if ( manager->caches[index] == 0 )
|
|
|
|
break;
|
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
/* return an error if there are too many registered caches */
|
2000-10-12 07:05:40 +02:00
|
|
|
if ( index >= FTC_MAX_CACHES )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
error = FTC_Err_Too_Many_Caches;
|
2000-09-19 03:11:11 +02:00
|
|
|
FT_ERROR(( "FTC_Manager_Register_Cache:" ));
|
2000-10-12 07:05:40 +02:00
|
|
|
FT_ERROR(( " too many registered caches\n" ));
|
2000-09-19 03:11:11 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( !ALLOC( cache, clazz->cache_size ) )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
|
|
|
cache->manager = manager;
|
|
|
|
cache->memory = memory;
|
|
|
|
cache->clazz = clazz;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
/* THIS IS VERY IMPORTANT! IT WILL WRETCH THE MANAGER */
|
|
|
|
/* IF IT IS NOT SET CORRECTLY */
|
2000-10-31 11:58:23 +01:00
|
|
|
cache->cache_index = index;
|
2000-09-19 03:11:11 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( clazz->cache_init )
|
|
|
|
{
|
|
|
|
error = clazz->cache_init( cache );
|
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
if ( clazz->cache_done )
|
|
|
|
clazz->cache_done( cache );
|
|
|
|
|
|
|
|
FREE( cache );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
manager->caches[index] = cache;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
*acache = cache;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
/* documentation is in ftcmanag.h */
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
FT_EXPORT_DEF( void )
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_Node_Unref( FTC_Node node,
|
|
|
|
FTC_Manager manager )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
if ( node && (FT_UInt)node->fam_index < manager->families.count &&
|
|
|
|
manager->families.entries[node->fam_index].cache )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
node->ref_count--;
|
2001-12-05 16:59:33 +01:00
|
|
|
}
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
/* END */
|