revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / freetype2 / ftglyphengine.c
blob6649e3cb879413f5b9bf2b7fb399b0e77936b03f
1 /*
2 * Based on the code from the ft2.library from MorphOS and the ttf.library by
3 * Richard Griffith
4 */
5 #include "ftglyphengine.h"
7 //#define DEBUG 1
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)
19 ge->last_error=error;
20 return(error);
23 void set_default_codepage(FT_GlyphEngine *ge)
25 struct Library *CodesetsBase;
26 struct codeset *sys_codeset;
28 int i;
30 for(i=0;i<256;++i)
31 ge->codepage[i]=i;
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)
37 return;
39 CodesetsBase = OpenLibrary("codesets.library", 0);
40 if (!CodesetsBase)
41 return;
43 sys_codeset = CodesetsFindA(NULL, NULL);
44 if (sys_codeset) {
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)
55 if(ge==NULL) return;
57 if(ge->face_established)
58 FT_Done_Face( ge->face );
60 FT_Done_Library( ge->engine );
62 FreeVec(ge);
65 /* initialize and setup the GlyphEngine structure */
66 FT_GlyphEngine *AllocGE(void)
68 FT_GlyphEngine *ge;
69 FT_Error error;
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));
77 if(ge!=NULL)
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",
86 (LONG) error ));
88 FreeVec(ge);
89 ge=NULL;
91 else
93 /* pre-inits */
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));
109 return(ge);