2 * Based on the code from the ft2.library from MorphOS, the ttf.library by
3 * Richard Griffith and the type1.library by Amish S. Dave
5 #include "ftglyphengine.h"
9 #include <proto/utility.h>
10 #include <aros/debug.h>
11 #include <exec/memory.h>
12 #include <utility/tagitem.h>
13 #include <diskfont/oterrors.h>
14 #include <diskfont/diskfonttag.h>
15 #include <diskfont/glyph.h>
17 #include LC_LIBDEFS_FILE
19 /* given an Amiga character, return a filled in GlyphMap */
20 static struct GlyphMap
*GetGlyph(FT_GlyphEngine
*ge
, int glyph_8bits
)
22 if (ge
->instance_changed
)
24 /* reset everything first */
25 if(SetInstance(ge
)!=OTERR_Success
)
29 /*if(ge->cmap_index==NO_CMAP_SET)
31 //if(ChooseEncoding(ge)!=0)
35 UnicodeToGlyphIndex(ge
);
37 { /* has code, try to render */
38 /* first, get a GlyphMap structure to fill in */
39 ge
->GMap
=AllocVec((ULONG
)sizeof(struct GlyphMap
),
40 MEMF_PUBLIC
| MEMF_CLEAR
);
42 RenderGlyph(ge
, glyph_8bits
);
46 set_last_error(ge
,OTERR_UnknownGlyph
);
50 /* odd ball glyph (includes SPACE, arrrgghhh) mimic bullet */
51 if (ge
->GMap
->glm_Width
== 0)
53 set_last_error(ge
,OTERR_UnknownGlyph
);
65 AROS_LH2(ULONG
, ObtainInfoA
,
66 AROS_LHA(struct GlyphEngine
*, ge
, A0
),
67 AROS_LHA(struct TagItem
*, tags
, A1
),
68 LIBBASETYPEPTR
, LIBBASE
, 8, FreeType2
73 FT_GlyphEngine
*engine
=(FT_GlyphEngine
*)ge
;
74 struct GlyphMap
**gm_p
;
75 struct MinList
**gw_p
;
78 struct TagItem
*tstate
;
83 D(bug("ObtainInfoA engine = 0x%lx tags = 0x%lx\n",engine
,tags
));
85 /* establish the correct face */
86 switch_family(engine
);
88 /* can't do anything without a face */
89 if (engine
->face_established
==FALSE
)
93 while ((tag
= NextTagItem(&tstate
)))
95 otagtag
= tag
->ti_Tag
;
96 otagdata
= tag
->ti_Data
;
101 D(bug("Obtain: OT_GlyphMap Data=%lx\n", otagdata
));
103 gm_p
= (struct GlyphMap
**)otagdata
;
105 if((*gm_p
= GetGlyph(engine
, FALSE
))==NULL
)
107 D(bug("Could not obtain GlyphMap\n"));
108 rc
= (ULONG
) engine
->last_error
;
112 case OT_GlyphMap8Bits
:
113 case OT_GlyphMap8Bit_Old
:
114 D(bug("Obtain: OT_GlyphMap8Bit Data=%lx\n", otagdata
));
116 gm_p
= (struct GlyphMap
**)otagdata
;
118 if((*gm_p
= GetGlyph(engine
, TRUE
))==NULL
)
120 D(bug("Could not obtain GlyphMap8Bit\n"));
121 rc
= (ULONG
) engine
->last_error
;
126 D(bug("Obtain: OT_WidthList Data=%lx\n", otagdata
));
128 gw_p
= (struct MinList
**)otagdata
;
130 if((*gw_p
= GetWidthList(engine
))==NULL
)
131 rc
= (ULONG
) engine
->last_error
;
134 case OT_TextKernPair
:
135 case OT_DesignKernPair
:
136 D(bug("Obtain: KernPair Data=%lx\n", otagdata
));
137 *((ULONG
*)otagdata
)=get_kerning_dir(engine
);
141 D(bug("Unanswered Obtain: Tag=%lx Data=%lx\n",(LONG
)otagtag
, otagdata
));