ReactOS 0.4.15-dev-7953-g1f49173
test_afm.c File Reference
#include <ft2build.h>
Include dependency graph for test_afm.c:

Go to the source code of this file.

Functions

void dump_fontinfo (AFM_FontInfo fi)
 
int dummy_get_index (const char *name, FT_Offset len, void *user_data)
 
FT_Error parse_afm (FT_Library library, FT_Stream stream, AFM_FontInfo fi)
 
int main (int argc, char **argv)
 

Function Documentation

◆ dummy_get_index()

int dummy_get_index ( const char name,
FT_Offset  len,
void user_data 
)

Definition at line 65 of file test_afm.c.

68 {
69 if ( len )
70 return name[0];
71 else
72 return 0;
73 }
GLenum GLsizei len
Definition: glext.h:6722
Definition: name.c:39

Referenced by parse_afm().

◆ dump_fontinfo()

void dump_fontinfo ( AFM_FontInfo  fi)

Definition at line 10 of file test_afm.c.

11 {
12 FT_UInt i;
13
14
15 printf( "This AFM is for %sCID font.\n\n",
16 ( fi->IsCIDFont ) ? "" : "non-" );
17
18 printf( "FontBBox: %.2f %.2f %.2f %.2f\n", fi->FontBBox.xMin / 65536.,
19 fi->FontBBox.yMin / 65536.,
20 fi->FontBBox.xMax / 65536.,
21 fi->FontBBox.yMax / 65536. );
22 printf( "Ascender: %.2f\n", fi->Ascender / 65536. );
23 printf( "Descender: %.2f\n\n", fi->Descender / 65536. );
24
25 if ( fi->NumTrackKern )
26 printf( "There are %d sets of track kernings:\n",
27 fi->NumTrackKern );
28 else
29 printf( "There is no track kerning.\n" );
30
31 for ( i = 0; i < fi->NumTrackKern; i++ )
32 {
33 AFM_TrackKern tk = fi->TrackKerns + i;
34
35
36 printf( "\t%2d: %5.2f %5.2f %5.2f %5.2f\n", tk->degree,
37 tk->min_ptsize / 65536.,
38 tk->min_kern / 65536.,
39 tk->max_ptsize / 65536.,
40 tk->max_kern / 65536. );
41 }
42
43 printf( "\n" );
44
45 if ( fi->NumKernPair )
46 printf( "There are %d kerning pairs:\n",
47 fi->NumKernPair );
48 else
49 printf( "There is no kerning pair.\n" );
50
51 for ( i = 0; i < fi->NumKernPair; i++ )
52 {
53 AFM_KernPair kp = fi->KernPairs + i;
54
55
56 printf( "\t%3d + %3d => (%4d, %4d)\n", kp->index1,
57 kp->index2,
58 kp->x,
59 kp->y );
60 }
61
62 }
#define printf
Definition: freeldr.h:97
unsigned int FT_UInt
Definition: fttypes.h:231
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FT_Fixed Ascender
Definition: t1types.h:173
AFM_KernPair KernPairs
Definition: t1types.h:177
FT_Fixed Descender
Definition: t1types.h:174
FT_Bool IsCIDFont
Definition: t1types.h:171
FT_UInt NumKernPair
Definition: t1types.h:178
AFM_TrackKern TrackKerns
Definition: t1types.h:175
FT_UInt NumTrackKern
Definition: t1types.h:176
FT_BBox FontBBox
Definition: t1types.h:172
FT_UInt index2
Definition: t1types.h:163
FT_UInt index1
Definition: t1types.h:162
FT_Fixed max_ptsize
Definition: t1types.h:155
FT_Fixed min_ptsize
Definition: t1types.h:153
FT_Fixed max_kern
Definition: t1types.h:156
FT_Fixed min_kern
Definition: t1types.h:154
FT_Pos xMin
Definition: ftimage.h:117
FT_Pos yMax
Definition: ftimage.h:118
FT_Pos yMin
Definition: ftimage.h:117
FT_Pos xMax
Definition: ftimage.h:118

Referenced by main().

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 111 of file test_afm.c.

113 {
118
119
120 if ( argc < 2 )
121 return FT_ERR( Invalid_Argument );
122
124 if ( error )
125 return error;
126
127 FT_ZERO( &stream );
129 if ( error )
130 goto Exit;
131 stream.memory = library->memory;
132
133 FT_ZERO( &fi );
134 error = parse_afm( library, &stream, &fi );
135
136 if ( !error )
137 {
139
140
141 dump_fontinfo( &fi );
142
143 if ( fi.KernPairs )
144 FT_FREE( fi.KernPairs );
145 if ( fi.TrackKerns )
146 FT_FREE( fi.TrackKerns );
147 }
148 else
149 printf( "parse error\n" );
150
152
153 Exit:
155
156 return error;
157 }
static int argc
Definition: ServiceArgs.c:12
FT_Library library
Definition: cffdrivr.c:654
FT_Done_FreeType(FT_Library library)
Definition: ftinit.c:356
FT_Init_FreeType(FT_Library *alibrary)
Definition: ftinit.c:320
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_FREE(ptr)
Definition: ftmemory.h:329
#define FT_ZERO(p)
Definition: ftmemory.h:237
FT_Stream_Close(FT_Stream stream)
Definition: ftstream.c:49
FT_Stream_Open(FT_Stream stream, const char *filepathname)
Definition: ftsystem.c:224
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
int FT_Error
Definition: fttypes.h:300
#define FT_ERR(e)
Definition: fttypes.h:586
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
#define argv
Definition: mplay32.c:18
static void Exit(void)
Definition: sock.c:1330
FT_Memory memory
Definition: ftobjs.h:918
Definition: parse.h:23
FT_Error parse_afm(FT_Library library, FT_Stream stream, AFM_FontInfo fi)
Definition: test_afm.c:76
void dump_fontinfo(AFM_FontInfo fi)
Definition: test_afm.c:10

◆ parse_afm()

FT_Error parse_afm ( FT_Library  library,
FT_Stream  stream,
AFM_FontInfo  fi 
)

Definition at line 76 of file test_afm.c.

79 {
80 PSAux_Service psaux;
83
84
86 if ( !psaux || !psaux->afm_parser_funcs )
87 return -1;
88
90 if ( error )
91 return error;
92
95 stream->cursor,
96 stream->limit );
97 if ( error )
98 return error;
99
100 parser.FontInfo = fi;
101 parser.get_index = dummy_get_index;
102
103 error = psaux->afm_parser_funcs->parse( &parser );
104
105 psaux->afm_parser_funcs->done( &parser );
106
107 return error;
108 }
FT_Get_Module_Interface(FT_Library library, const char *mod_name)
Definition: ftobjs.c:4865
FT_Stream_EnterFrame(FT_Stream stream, FT_ULong count)
Definition: ftstream.c:234
struct PSAux_ServiceRec_ * PSAux_Service
FT_Error(* init)(AFM_Parser parser, FT_Memory memory, FT_Byte *base, FT_Byte *limit)
Definition: psaux.h:1197
FT_Error(* parse)(AFM_Parser parser)
Definition: psaux.h:1206
void(* done)(AFM_Parser parser)
Definition: psaux.h:1203
const AFM_Parser_FuncsRec * afm_parser_funcs
Definition: psaux.h:1307
Definition: import.c:81
unsigned int size
Definition: parse.h:27
int dummy_get_index(const char *name, FT_Offset len, void *user_data)
Definition: test_afm.c:65

Referenced by main().