Hash :
8fe65390
Author :
Date :
2006-04-29T07:31:16
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
/***************************************************************************/
/* */
/* ftcimage.c */
/* */
/* FreeType Image cache (body). */
/* */
/* Copyright 2000-2001, 2003, 2004, 2006 by */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_CACHE_H
#include "ftcimage.h"
#include FT_INTERNAL_MEMORY_H
#include "ftccback.h"
#include "ftcerror.h"
/* finalize a given glyph image node */
FT_LOCAL_DEF( void )
ftc_inode_free( FTC_Node ftcinode,
FTC_Cache cache )
{
FTC_INode inode = (FTC_INode)ftcinode;
FT_Memory memory = cache->memory;
if ( inode->glyph )
{
FT_Done_Glyph( inode->glyph );
inode->glyph = NULL;
}
FTC_GNode_Done( FTC_GNODE( inode ), cache );
FT_FREE( inode );
}
FT_LOCAL_DEF( void )
FTC_INode_Free( FTC_INode inode,
FTC_Cache cache )
{
ftc_inode_free( FTC_NODE( inode ), cache );
}
/* initialize a new glyph image node */
FT_LOCAL_DEF( FT_Error )
FTC_INode_New( FTC_INode *pinode,
FTC_GQuery gquery,
FTC_Cache cache )
{
FT_Memory memory = cache->memory;
FT_Error error;
FTC_INode inode;
if ( !FT_NEW( inode ) )
{
FTC_GNode gnode = FTC_GNODE( inode );
FTC_Family family = gquery->family;
FT_UInt gindex = gquery->gindex;
FTC_IFamilyClass clazz = FTC_CACHE__IFAMILY_CLASS( cache );
/* initialize its inner fields */
FTC_GNode_Init( gnode, gindex, family );
/* we will now load the glyph image */
error = clazz->family_load_glyph( family, gindex, cache,
&inode->glyph );
if ( error )
{
FTC_INode_Free( inode, cache );
inode = NULL;
}
}
*pinode = inode;
return error;
}
FT_LOCAL_DEF( FT_Error )
ftc_inode_new( FTC_Node *ftcpinode,
FT_Pointer ftcgquery,
FTC_Cache cache )
{
FTC_INode *pinode = (FTC_INode*)ftcpinode;
FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
return FTC_INode_New( pinode, gquery, cache );
}
FT_LOCAL_DEF( FT_ULong )
ftc_inode_weight( FTC_Node ftcinode,
FTC_Cache ftccache )
{
FTC_INode inode = (FTC_INode)ftcinode;
FT_ULong size = 0;
FT_Glyph glyph = inode->glyph;
FT_UNUSED( ftccache );
switch ( glyph->format )
{
case FT_GLYPH_FORMAT_BITMAP:
{
FT_BitmapGlyph bitg;
bitg = (FT_BitmapGlyph)glyph;
size = bitg->bitmap.rows * ft_labs( bitg->bitmap.pitch ) +
sizeof ( *bitg );
}
break;
case FT_GLYPH_FORMAT_OUTLINE:
{
FT_OutlineGlyph outg;
outg = (FT_OutlineGlyph)glyph;
size = outg->outline.n_points *
( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
outg->outline.n_contours * sizeof ( FT_Short ) +
sizeof ( *outg );
}
break;
default:
;
}
size += sizeof ( *inode );
return size;
}
#if 0
FT_LOCAL_DEF( FT_ULong )
FTC_INode_Weight( FTC_INode inode )
{
return ftc_inode_weight( FTC_NODE( inode ), NULL );
}
#endif /* 0 */
/* END */