2000-10-12 07:05:40 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftcimage.c */
|
|
|
|
/* */
|
|
|
|
/* FreeType Image cache (body). */
|
|
|
|
/* */
|
2001-06-28 19:49:10 +02:00
|
|
|
/* Copyright 2000-2001 by */
|
2000-10-12 07:05:40 +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_IMAGE_H
|
2001-10-26 18:58:27 +02:00
|
|
|
#include FT_CACHE_INTERNAL_GLYPH_H
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_INTERNAL_MEMORY_H
|
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
|
|
|
#include "ftcerror.h"
|
|
|
|
|
2000-10-29 01:34:45 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
/* the FT_Glyph image node type */
|
|
|
|
typedef struct FTC_ImageNodeRec_
|
2000-10-29 01:34:45 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_GlyphNodeRec gnode;
|
|
|
|
FT_Glyph glyph;
|
2000-10-29 01:34:45 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
} FTC_ImageNodeRec, *FTC_ImageNode;
|
2000-10-29 01:34:45 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
#define FTC_IMAGE_NODE( x ) ( (FTC_ImageNode)( x ) )
|
2001-12-05 02:22:05 +01:00
|
|
|
#define FTC_IMAGE_NODE_GINDEX( x ) FTC_GLYPH_NODE_GINDEX( x )
|
|
|
|
|
2000-10-29 01:34:45 +02:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
/* the glyph image query */
|
|
|
|
typedef struct FTC_ImageQueryRec_
|
2000-10-29 01:34:45 +02:00
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_GlyphQueryRec gquery;
|
2002-09-08 23:29:11 +02:00
|
|
|
FTC_ImageTypeRec type;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
} FTC_ImageQueryRec, *FTC_ImageQuery;
|
2000-10-29 01:34:45 +02:00
|
|
|
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
#define FTC_IMAGE_QUERY( x ) ( (FTC_ImageQuery)( x ) )
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-10-29 01:34:45 +02:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
/* the glyph image set type */
|
|
|
|
typedef struct FTC_ImageFamilyRec_
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_GlyphFamilyRec gfam;
|
2002-09-08 23:29:11 +02:00
|
|
|
FTC_ImageTypeRec type;
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
} FTC_ImageFamilyRec, *FTC_ImageFamily;
|
|
|
|
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
#define FTC_IMAGE_FAMILY( x ) ( (FTC_ImageFamily)( x ) )
|
|
|
|
#define FTC_IMAGE_FAMILY_MEMORY( x ) FTC_GLYPH_FAMILY_MEMORY( &(x)->gfam )
|
2000-10-26 12:04:16 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** GLYPH IMAGE NODES *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
/* finalize a given glyph image node */
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( void )
|
2001-12-05 16:59:33 +01:00
|
|
|
ftc_image_node_done( FTC_ImageNode inode,
|
|
|
|
FTC_Cache cache )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( inode->glyph )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
FT_Done_Glyph( inode->glyph );
|
|
|
|
inode->glyph = NULL;
|
|
|
|
}
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
ftc_glyph_node_done( FTC_GLYPH_NODE( inode ), cache );
|
|
|
|
}
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
/* initialize a new glyph image node */
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_image_node_init( FTC_ImageNode inode,
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_GlyphQuery gquery,
|
|
|
|
FTC_Cache cache )
|
2000-10-12 07:05:40 +02:00
|
|
|
{
|
2001-12-20 18:49:10 +01:00
|
|
|
FTC_ImageFamily ifam = FTC_IMAGE_FAMILY( gquery->query.family );
|
|
|
|
FT_Error error;
|
|
|
|
FT_Face face;
|
|
|
|
FT_Size size;
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2000-10-31 23:13:54 +01:00
|
|
|
/* initialize its inner fields */
|
2001-12-20 18:49:10 +01:00
|
|
|
ftc_glyph_node_init( FTC_GLYPH_NODE( inode ),
|
2001-12-05 16:59:33 +01:00
|
|
|
gquery->gindex,
|
2001-12-20 18:49:10 +01:00
|
|
|
FTC_GLYPH_FAMILY( ifam ) );
|
2000-08-29 18:50:01 +02:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
/* we will now load the glyph image */
|
2001-12-20 18:49:10 +01:00
|
|
|
error = FTC_Manager_Lookup_Size( FTC_FAMILY( ifam )->cache->manager,
|
2002-09-08 23:29:11 +02:00
|
|
|
&ifam->type.font,
|
2000-08-23 13:22:30 +02:00
|
|
|
&face, &size );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2002-09-18 13:32:12 +02:00
|
|
|
FT_UInt gindex = FTC_GLYPH_NODE_GINDEX( inode );
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2002-09-08 23:29:11 +02:00
|
|
|
error = FT_Load_Glyph( face, gindex, ifam->type.flags );
|
2000-08-23 23:11:13 +02:00
|
|
|
if ( !error )
|
|
|
|
{
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
if ( face->glyph->format == FT_GLYPH_FORMAT_BITMAP ||
|
|
|
|
face->glyph->format == FT_GLYPH_FORMAT_OUTLINE )
|
2000-10-12 07:05:40 +02:00
|
|
|
{
|
2000-08-23 23:11:13 +02:00
|
|
|
/* ok, copy it */
|
|
|
|
FT_Glyph glyph;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
|
2000-08-23 23:11:13 +02:00
|
|
|
error = FT_Get_Glyph( face->glyph, &glyph );
|
|
|
|
if ( !error )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
inode->glyph = glyph;
|
|
|
|
goto Exit;
|
|
|
|
}
|
2000-08-23 23:11:13 +02:00
|
|
|
}
|
2000-08-29 18:04:28 +02:00
|
|
|
else
|
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_Invalid_Argument;
|
2000-08-23 23:11:13 +02:00
|
|
|
}
|
|
|
|
}
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
/* in case of error */
|
2001-12-05 16:59:33 +01:00
|
|
|
ftc_glyph_node_done( FTC_GLYPH_NODE(inode), cache );
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 23:11:13 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
2000-09-19 03:11:11 +02:00
|
|
|
}
|
2000-08-23 23:11:13 +02:00
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_ULong )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_image_node_weight( FTC_ImageNode inode )
|
2000-08-23 23:11:13 +02:00
|
|
|
{
|
2000-10-12 07:05:40 +02:00
|
|
|
FT_ULong size = 0;
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Glyph glyph = inode->glyph;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
switch ( glyph->format )
|
2000-08-23 23:11:13 +02:00
|
|
|
{
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
case FT_GLYPH_FORMAT_BITMAP:
|
2000-10-12 07:05:40 +02:00
|
|
|
{
|
|
|
|
FT_BitmapGlyph bitg;
|
|
|
|
|
|
|
|
|
|
|
|
bitg = (FT_BitmapGlyph)glyph;
|
|
|
|
size = bitg->bitmap.rows * labs( bitg->bitmap.pitch ) +
|
|
|
|
sizeof ( *bitg );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
case FT_GLYPH_FORMAT_OUTLINE:
|
2000-10-12 07:05:40 +02:00
|
|
|
{
|
|
|
|
FT_OutlineGlyph outg;
|
|
|
|
|
|
|
|
|
|
|
|
outg = (FT_OutlineGlyph)glyph;
|
|
|
|
size = outg->outline.n_points *
|
2001-12-05 02:22:05 +01:00
|
|
|
( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
|
2000-10-12 07:05:40 +02:00
|
|
|
outg->outline.n_contours * sizeof ( FT_Short ) +
|
|
|
|
sizeof ( *outg );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2000-08-23 23:11:13 +02:00
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
size += sizeof ( *inode );
|
2000-09-19 03:11:11 +02:00
|
|
|
return size;
|
2000-08-23 23:11:13 +02:00
|
|
|
}
|
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
2000-10-29 01:34:45 +02:00
|
|
|
/***** GLYPH IMAGE SETS *****/
|
2000-10-12 07:05:40 +02:00
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-08-24 18:29:15 +02:00
|
|
|
|
2000-08-23 23:11:13 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2001-12-05 16:59:33 +01:00
|
|
|
ftc_image_family_init( FTC_ImageFamily ifam,
|
|
|
|
FTC_ImageQuery iquery,
|
|
|
|
FTC_Cache cache )
|
2000-08-23 23:11:13 +02:00
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_Manager manager = cache->manager;
|
|
|
|
FT_Error error;
|
|
|
|
FT_Face face;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2002-09-08 23:29:11 +02:00
|
|
|
ifam->type = iquery->type;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
/* we need to compute "iquery.item_total" now */
|
|
|
|
error = FTC_Manager_Lookup_Face( manager,
|
2002-09-08 23:29:11 +02:00
|
|
|
iquery->type.font.face_id,
|
2001-12-05 16:59:33 +01:00
|
|
|
&face );
|
|
|
|
if ( !error )
|
|
|
|
{
|
2001-12-20 18:49:10 +01:00
|
|
|
error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( ifam ),
|
2002-09-08 23:29:11 +02:00
|
|
|
FTC_IMAGE_TYPE_HASH( &ifam->type ),
|
2001-12-05 16:59:33 +01:00
|
|
|
1,
|
|
|
|
face->num_glyphs,
|
2001-12-20 18:49:10 +01:00
|
|
|
FTC_GLYPH_QUERY( iquery ),
|
2001-12-05 16:59:33 +01:00
|
|
|
cache );
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
2000-08-23 23:11:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Bool )
|
2001-12-05 16:59:33 +01:00
|
|
|
ftc_image_family_compare( FTC_ImageFamily ifam,
|
|
|
|
FTC_ImageQuery iquery )
|
2000-08-23 23:11:13 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Bool result;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2002-09-08 23:29:11 +02:00
|
|
|
result = FT_BOOL( FTC_IMAGE_TYPE_COMPARE( &ifam->type, &iquery->type ) );
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( result )
|
2001-12-20 18:49:10 +01:00
|
|
|
FTC_GLYPH_FAMILY_FOUND( ifam, iquery );
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
return result;
|
2000-08-23 23:11:13 +02:00
|
|
|
}
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** GLYPH IMAGE CACHE *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-08-29 18:04:28 +02:00
|
|
|
|
2000-08-23 23:11:13 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2000-11-04 02:55:49 +01:00
|
|
|
FT_CALLBACK_TABLE_DEF
|
2001-10-26 18:58:27 +02:00
|
|
|
const FTC_Cache_ClassRec ftc_image_cache_class =
|
2000-08-23 23:11:13 +02:00
|
|
|
{
|
2001-12-20 18:49:10 +01:00
|
|
|
sizeof ( FTC_CacheRec ),
|
|
|
|
(FTC_Cache_InitFunc) ftc_cache_init,
|
|
|
|
(FTC_Cache_ClearFunc)ftc_cache_clear,
|
|
|
|
(FTC_Cache_DoneFunc) ftc_cache_done,
|
|
|
|
|
|
|
|
sizeof ( FTC_ImageFamilyRec ),
|
|
|
|
(FTC_Family_InitFunc) ftc_image_family_init,
|
|
|
|
(FTC_Family_CompareFunc)ftc_image_family_compare,
|
|
|
|
(FTC_Family_DoneFunc) ftc_glyph_family_done,
|
|
|
|
|
|
|
|
sizeof ( FTC_ImageNodeRec ),
|
|
|
|
(FTC_Node_InitFunc) ftc_image_node_init,
|
|
|
|
(FTC_Node_WeightFunc) ftc_image_node_weight,
|
|
|
|
(FTC_Node_CompareFunc)ftc_glyph_node_compare,
|
|
|
|
(FTC_Node_DoneFunc) ftc_image_node_done
|
2000-09-19 03:11:11 +02:00
|
|
|
};
|
2000-08-23 23:11:13 +02:00
|
|
|
|
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
/* documentation is in ftcimage.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_ImageCache_New( FTC_Manager manager,
|
|
|
|
FTC_ImageCache *acache )
|
2000-08-23 23:11:13 +02:00
|
|
|
{
|
2000-09-19 03:11:11 +02:00
|
|
|
return FTC_Manager_Register_Cache(
|
2000-10-31 23:13:54 +01:00
|
|
|
manager,
|
2001-12-05 02:22:05 +01:00
|
|
|
(FTC_Cache_Class)&ftc_image_cache_class,
|
|
|
|
FTC_CACHE_P( acache ) );
|
2000-08-23 23:11:13 +02:00
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 23:11:13 +02:00
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
/* documentation is in ftcimage.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_ImageCache_Lookup( FTC_ImageCache cache,
|
2002-09-08 23:29:11 +02:00
|
|
|
FTC_ImageType type,
|
2001-12-05 16:59:33 +01:00
|
|
|
FT_UInt gindex,
|
|
|
|
FT_Glyph *aglyph,
|
|
|
|
FTC_Node *anode )
|
2000-08-23 23:11:13 +02:00
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_ImageQueryRec iquery;
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_ImageNode node;
|
|
|
|
FT_Error error;
|
2001-12-05 02:22:05 +01:00
|
|
|
|
|
|
|
|
2002-04-28 04:48:20 +02:00
|
|
|
/* some argument checks are delayed to ftc_cache_lookup */
|
|
|
|
if ( !aglyph )
|
|
|
|
return FTC_Err_Invalid_Argument;
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( anode )
|
|
|
|
*anode = NULL;
|
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
iquery.gquery.gindex = gindex;
|
2002-09-08 23:29:11 +02:00
|
|
|
iquery.type = *type;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
error = ftc_cache_lookup( FTC_CACHE( cache ),
|
|
|
|
FTC_QUERY( &iquery ),
|
|
|
|
(FTC_Node*)&node );
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( !error )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
*aglyph = node->glyph;
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
if ( anode )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2001-12-05 02:22:05 +01:00
|
|
|
*anode = (FTC_Node)node;
|
2001-12-20 18:49:10 +01:00
|
|
|
FTC_NODE( node )->ref_count++;
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
|
|
|
}
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
return error;
|
2001-12-05 02:22:05 +01:00
|
|
|
}
|
2000-08-24 18:29:15 +02:00
|
|
|
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
/* backwards-compatibility functions */
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FTC_Image_Cache_New( FTC_Manager manager,
|
|
|
|
FTC_Image_Cache *acache )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2001-12-05 16:59:33 +01:00
|
|
|
return FTC_ImageCache_New( manager, (FTC_ImageCache*)acache );
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2000-08-23 23:11:13 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FTC_Image_Cache_Lookup( FTC_Image_Cache icache,
|
|
|
|
FTC_Image_Desc* desc,
|
|
|
|
FT_UInt gindex,
|
|
|
|
FT_Glyph *aglyph )
|
|
|
|
{
|
2002-09-08 23:29:11 +02:00
|
|
|
FTC_ImageTypeRec type0;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
if ( !desc )
|
2002-04-28 04:48:20 +02:00
|
|
|
return FTC_Err_Invalid_Argument;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2002-09-08 23:29:11 +02:00
|
|
|
type0.font = desc->font;
|
|
|
|
|
|
|
|
/* convert image type flags to load flags */
|
|
|
|
{
|
|
|
|
FT_UInt load_flags = FT_LOAD_DEFAULT;
|
|
|
|
FT_UInt type = desc->image_type;
|
|
|
|
|
|
|
|
|
|
|
|
/* determine load flags, depending on the font description's */
|
|
|
|
/* image type */
|
|
|
|
|
|
|
|
if ( ftc_image_format( type ) == ftc_image_format_bitmap )
|
|
|
|
{
|
|
|
|
if ( type & ftc_image_flag_monochrome )
|
|
|
|
load_flags |= FT_LOAD_MONOCHROME;
|
|
|
|
|
|
|
|
/* disable embedded bitmaps loading if necessary */
|
|
|
|
if ( type & ftc_image_flag_no_sbits )
|
|
|
|
load_flags |= FT_LOAD_NO_BITMAP;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we want an outline, don't load embedded bitmaps */
|
|
|
|
load_flags |= FT_LOAD_NO_BITMAP;
|
|
|
|
|
|
|
|
if ( type & ftc_image_flag_unscaled )
|
|
|
|
load_flags |= FT_LOAD_NO_SCALE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* always render glyphs to bitmaps */
|
|
|
|
load_flags |= FT_LOAD_RENDER;
|
|
|
|
|
|
|
|
if ( type & ftc_image_flag_unhinted )
|
|
|
|
load_flags |= FT_LOAD_NO_HINTING;
|
|
|
|
|
|
|
|
if ( type & ftc_image_flag_autohinted )
|
|
|
|
load_flags |= FT_LOAD_FORCE_AUTOHINT;
|
|
|
|
|
|
|
|
type0.flags = load_flags;
|
|
|
|
}
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
|
2002-09-08 23:29:11 +02:00
|
|
|
&type0,
|
2001-12-05 16:59:33 +01:00
|
|
|
gindex,
|
|
|
|
aglyph,
|
|
|
|
NULL );
|
2000-08-23 23:11:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/* END */
|