2 * Based on the code from the ft2.library from MorphOS and the ttf.library by
5 #include "ftglyphengine.h"
8 #include <aros/debug.h>
9 #include <exec/memory.h>
10 #include <diskfont/oterrors.h>
11 #include <libraries/codesets.h>
13 #include <proto/codesets.h>
14 #include <proto/exec.h>
15 #include <proto/dos.h>
17 int set_last_error(FT_GlyphEngine
*ge
,int error
)
23 void set_default_codepage(FT_GlyphEngine
*ge
)
25 struct Library
*CodesetsBase
;
26 struct codeset
*sys_codeset
;
33 D(bug("getting codepage environment var\n"));
35 if (GetVar("ftcodepage", (STRPTR
)&ge
->codepage
, 512,
36 LV_VAR
| GVF_BINARY_VAR
| GVF_DONT_NULL_TERM
) == 512)
39 CodesetsBase
= OpenLibrary("codesets.library", 0);
43 sys_codeset
= CodesetsFindA(NULL
, NULL
);
45 for (i
= 0; i
< 256; i
++)
46 ge
->codepage
[i
] = sys_codeset
->table
[i
].ucs4
;
49 CloseLibrary(CodesetsBase
);
52 /* close down and dispose of GlyphEngine */
53 void FreeGE(FT_GlyphEngine
*ge
)
57 if(ge
->face_established
)
58 FT_Done_Face( ge
->face
);
60 FT_Done_Library( ge
->engine
);
65 /* initialize and setup the GlyphEngine structure */
66 FT_GlyphEngine
*AllocGE(void)
71 D(bug("Allocating new glyph engine\n"));
73 ge
=AllocVec(sizeof(FT_GlyphEngine
),MEMF_PUBLIC
| MEMF_CLEAR
);
75 D(bug(" at 0x%lx\n",ge
));
79 set_last_error(ge
,OTERR_Success
);
81 D(bug("FT_Init_FreeType( 0x%lx ) ...\n",&ge
->engine
));
83 if ((error
= FT_Init_FreeType( &ge
->engine
) ))
85 D(bug("Error initializing engine, code = %ld.\n",
94 ge
->shear_matrix
.xx
= 0x10000;
95 ge
->shear_matrix
.yy
= 0x10000;
96 ge
->rotate_matrix
= ge
->shear_matrix
;
97 ge
->matrix
= ge
->shear_matrix
;
99 ge
->cmap_index
=NO_CMAP_SET
;
101 D(bug("Setting default codepage\n"));
103 set_default_codepage(ge
);
106 D(bug("Returning new glyph engine 0x%lx\n",ge
));