zenilib: zenilib/jni/external/freetype2/src/cache/ftcimage.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ftcimage.c
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ftcimage.c */
4 /* */
5 /* FreeType Image cache (body). */
6 /* */
7 /* Copyright 2000-2001, 2003, 2004, 2006, 2010 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
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. */
15 /* */
16 /***************************************************************************/
17
18
19 #include <ft2build.h>
20 #include FT_CACHE_H
21 #include "ftcimage.h"
22 #include FT_INTERNAL_MEMORY_H
23
24 #include "ftccback.h"
25 #include "ftcerror.h"
26
27
28 /* finalize a given glyph image node */
29 FT_LOCAL_DEF( void )
30 ftc_inode_free( FTC_Node ftcinode,
31 FTC_Cache cache )
32 {
33 FTC_INode inode = (FTC_INode)ftcinode;
34 FT_Memory memory = cache->memory;
35
36
37 if ( inode->glyph )
38 {
39 FT_Done_Glyph( inode->glyph );
40 inode->glyph = NULL;
41 }
42
43 FTC_GNode_Done( FTC_GNODE( inode ), cache );
44 FT_FREE( inode );
45 }
46
47
48 FT_LOCAL_DEF( void )
49 FTC_INode_Free( FTC_INode inode,
50 FTC_Cache cache )
51 {
52 ftc_inode_free( FTC_NODE( inode ), cache );
53 }
54
55
56 /* initialize a new glyph image node */
57 FT_LOCAL_DEF( FT_Error )
58 FTC_INode_New( FTC_INode *pinode,
59 FTC_GQuery gquery,
60 FTC_Cache cache )
61 {
62 FT_Memory memory = cache->memory;
63 FT_Error error;
64 FTC_INode inode = NULL;
65
66
67 if ( !FT_NEW( inode ) )
68 {
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 );
73
74
75 /* initialize its inner fields */
76 FTC_GNode_Init( gnode, gindex, family );
77
78 /* we will now load the glyph image */
79 error = clazz->family_load_glyph( family, gindex, cache,
80 &inode->glyph );
81 if ( error )
82 {
83 FTC_INode_Free( inode, cache );
84 inode = NULL;
85 }
86 }
87
88 *pinode = inode;
89 return error;
90 }
91
92
93 FT_LOCAL_DEF( FT_Error )
94 ftc_inode_new( FTC_Node *ftcpinode,
95 FT_Pointer ftcgquery,
96 FTC_Cache cache )
97 {
98 FTC_INode *pinode = (FTC_INode*)ftcpinode;
99 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
100
101
102 return FTC_INode_New( pinode, gquery, cache );
103 }
104
105
106 FT_LOCAL_DEF( FT_Offset )
107 ftc_inode_weight( FTC_Node ftcinode,
108 FTC_Cache ftccache )
109 {
110 FTC_INode inode = (FTC_INode)ftcinode;
111 FT_Offset size = 0;
112 FT_Glyph glyph = inode->glyph;
113
114 FT_UNUSED( ftccache );
115
116
117 switch ( glyph->format )
118 {
119 case FT_GLYPH_FORMAT_BITMAP:
120 {
121 FT_BitmapGlyph bitg;
122
123
124 bitg = (FT_BitmapGlyph)glyph;
125 size = bitg->bitmap.rows * ft_labs( bitg->bitmap.pitch ) +
126 sizeof ( *bitg );
127 }
128 break;
129
130 case FT_GLYPH_FORMAT_OUTLINE:
131 {
132 FT_OutlineGlyph outg;
133
134
135 outg = (FT_OutlineGlyph)glyph;
136 size = outg->outline.n_points *
137 ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
138 outg->outline.n_contours * sizeof ( FT_Short ) +
139 sizeof ( *outg );
140 }
141 break;
142
143 default:
144 ;
145 }
146
147 size += sizeof ( *inode );
148 return size;
149 }
150
151
152 #if 0
153
154 FT_LOCAL_DEF( FT_Offset )
155 FTC_INode_Weight( FTC_INode inode )
156 {
157 return ftc_inode_weight( FTC_NODE( inode ), NULL );
158 }
159
160 #endif /* 0 */
161
162
163 /* END */
FTC_IFamilyClassRec_::family_load_glyph
FTC_IFamily_LoadGlyphFunc family_load_glyph
Definition: ftcimage.h:67
FT_Error
int FT_Error
Definition: fttypes.h:296
FTC_CACHE__IFAMILY_CLASS
#define FTC_CACHE__IFAMILY_CLASS(x)
Definition: ftcimage.h:75
FT_OutlineGlyph
struct FT_OutlineGlyphRec_ * FT_OutlineGlyph
Definition: ftglyph.h:179
ftcimage.h
FT_BitmapGlyphRec_::bitmap
FT_Bitmap bitmap
Definition: ftglyph.h:165
NULL
#define NULL
Definition: ftobjs.h:61
FT_Outline_::n_contours
short n_contours
Definition: ftimage.h:385
FT_Bitmap_::rows
int rows
Definition: ftimage.h:312
ftc_inode_free
ftc_inode_free(FTC_Node inode, FTC_Cache cache)
Definition: ftcimage.c:30
FTC_INode_New
FTC_INode_New(FTC_INode *pinode, FTC_GQuery gquery, FTC_Cache cache)
Definition: ftcimage.c:58
FTC_CacheRec_
Definition: ftccache.h:150
FT_Bitmap_::pitch
int pitch
Definition: ftimage.h:314
FTC_NODE
#define FTC_NODE(x)
Definition: ftccache.h:70
ftcerror.h
FT_BitmapGlyph
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:127
FTC_GNodeRec_
Definition: ftcglyph.h:148
FT_Byte
unsigned char FT_Byte
Definition: fttypes.h:150
ftc_inode_weight
ftc_inode_weight(FTC_Node inode, FTC_Cache cache)
Definition: ftcimage.c:107
FTC_GNode_Init
FTC_GNode_Init(FTC_GNode gnode, FT_UInt gindex, FTC_Family family)
Definition: ftcglyph.c:31
FT_OutlineGlyphRec_::outline
FT_Outline outline
Definition: ftglyph.h:211
FT_FREE
#define FT_FREE(ptr)
Definition: ftmemory.h:286
FT_LOCAL_DEF
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:467
error
FT_Error error
Definition: cffdrivr.c:407
FTC_INode_Free
FTC_INode_Free(FTC_INode inode, FTC_Cache cache)
Definition: ftcimage.c:49
FT_Pointer
void * FT_Pointer
Definition: fttypes.h:307
FTC_IFamilyClassRec_
Definition: ftcimage.h:64
ftc_inode_new
ftc_inode_new(FTC_Node *pinode, FT_Pointer gquery, FTC_Cache cache)
Definition: ftcimage.c:94
FT_GlyphRec_
Definition: ftglyph.h:108
FT_BitmapGlyphRec_
Definition: ftglyph.h:160
FTC_GNODE
#define FTC_GNODE(x)
Definition: ftcglyph.h:156
FT_Outline_::n_points
short n_points
Definition: ftimage.h:386
FT_Short
signed short FT_Short
Definition: fttypes.h:194
FT_Memory
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
sizeof
sizeof(FT_AutofitterRec)
FTC_Family
FT_BEGIN_HEADER struct FTC_FamilyRec_ * FTC_Family
FT_Vector
struct FT_Vector_ FT_Vector
FTC_GNode_Done
FTC_GNode_Done(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:55
ft2build.h
FT_GlyphRec_::format
FT_Glyph_Format format
Definition: ftglyph.h:112
FT_OutlineGlyphRec_
Definition: ftglyph.h:208
FT_UInt
unsigned int FT_UInt
Definition: fttypes.h:227
FTC_GQueryRec_
Definition: ftcglyph.h:160
FTC_INode
FT_BEGIN_HEADER struct FTC_INodeRec_ * FTC_INode
FTC_GQuery
struct FTC_GQueryRec_ * FTC_GQuery
ft_labs
#define ft_labs
Definition: ftstdlib.h:145
FT_NEW
#define FT_NEW(ptr)
Definition: ftmemory.h:288
FTC_NodeRec_
Definition: ftccache.h:59
ftccback.h
FT_Done_Glyph
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:611
FT_UNUSED
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
FT_GLYPH_FORMAT_OUTLINE
FT_Module_Constructor FT_GLYPH_FORMAT_OUTLINE
Definition: ftrend1.c:283
FT_Offset
size_t FT_Offset
Definition: fttypes.h:320
size
GLsizei size
Definition: gl2ext.h:1467