1 /****************************************************************************
5 * FreeType Image cache (body).
7 * Copyright (C) 2000-2023 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
10 * This file is part of the FreeType project, and may only be used,
11 * modified, and distributed under the terms of the FreeType project
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
19 #include <freetype/ftcache.h>
21 #include <freetype/internal/ftmemory.h>
22 #include <freetype/internal/ftobjs.h>
28 /* finalize a given glyph image node */
30 ftc_inode_free( FTC_Node ftcinode,
33 FTC_INode inode = (FTC_INode)ftcinode;
34 FT_Memory memory = cache->memory;
39 FT_Done_Glyph( inode->glyph );
43 FTC_GNode_Done( FTC_GNODE( inode ), cache );
49 FTC_INode_Free( FTC_INode inode,
52 ftc_inode_free( FTC_NODE( inode ), cache );
56 /* initialize a new glyph image node */
57 FT_LOCAL_DEF( FT_Error )
58 FTC_INode_New( FTC_INode *pinode,
62 FT_Memory memory = cache->memory;
64 FTC_INode inode = NULL;
67 if ( !FT_QNEW( inode ) )
69 FTC_GNode gnode = FTC_GNODE( inode );
70 FTC_Family family = gquery->family;
71 FT_UInt gindex = gquery->gindex;
72 FTC_IFamilyClass clazz = FTC_CACHE_IFAMILY_CLASS( cache );
75 /* initialize its inner fields */
76 FTC_GNode_Init( gnode, gindex, family );
79 /* we will now load the glyph image */
80 error = clazz->family_load_glyph( family, gindex, cache,
84 FTC_INode_Free( inode, cache );
94 FT_LOCAL_DEF( FT_Error )
95 ftc_inode_new( FTC_Node *ftcpinode,
99 FTC_INode *pinode = (FTC_INode*)ftcpinode;
100 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
103 return FTC_INode_New( pinode, gquery, cache );
107 FT_LOCAL_DEF( FT_Offset )
108 ftc_inode_weight( FTC_Node ftcinode,
111 FTC_INode inode = (FTC_INode)ftcinode;
113 FT_Glyph glyph = inode->glyph;
115 FT_UNUSED( ftccache );
118 switch ( glyph->format )
120 case FT_GLYPH_FORMAT_BITMAP:
125 bitg = (FT_BitmapGlyph)glyph;
126 size = bitg->bitmap.rows * (FT_Offset)FT_ABS( bitg->bitmap.pitch ) +
131 case FT_GLYPH_FORMAT_OUTLINE:
133 FT_OutlineGlyph outg;
136 outg = (FT_OutlineGlyph)glyph;
137 size = (FT_Offset)outg->outline.n_points *
138 ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
139 (FT_Offset)outg->outline.n_contours * sizeof ( FT_Short ) +
148 size += sizeof ( *inode );
155 FT_LOCAL_DEF( FT_Offset )
156 FTC_INode_Weight( FTC_INode inode )
158 return ftc_inode_weight( FTC_NODE( inode ), NULL );