revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / freetype2 / obtaininfoa.c
blobe28b98ea9865e86127e672c38c268bfef49f11ef
1 /*
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
4 */
5 #include "ftglyphengine.h"
6 #include "glyph.h"
7 #include "kerning.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)
26 return NULL;
29 /*if(ge->cmap_index==NO_CMAP_SET)
31 //if(ChooseEncoding(ge)!=0)
32 return(NULL);
33 }*/
35 UnicodeToGlyphIndex(ge);
36 if(ge->glyph_code)
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);
41 if(ge->GMap)
42 RenderGlyph(ge, glyph_8bits);
44 else
46 set_last_error(ge,OTERR_UnknownGlyph);
47 return NULL;
50 /* odd ball glyph (includes SPACE, arrrgghhh) mimic bullet */
51 if (ge->GMap->glm_Width == 0)
53 set_last_error(ge,OTERR_UnknownGlyph);
54 FreeVec(ge->GMap);
55 ge->GMap = NULL;
56 return NULL;
59 return ge->GMap;
62 /**
63 * ObtainInfoA
64 **/
65 AROS_LH2(ULONG, ObtainInfoA,
66 AROS_LHA(struct GlyphEngine *, ge, A0),
67 AROS_LHA(struct TagItem *, tags, A1),
68 LIBBASETYPEPTR, LIBBASE, 8, FreeType2
71 AROS_LIBFUNC_INIT
73 FT_GlyphEngine *engine=(FT_GlyphEngine *)ge;
74 struct GlyphMap **gm_p;
75 struct MinList **gw_p;
76 Tag otagtag;
77 IPTR otagdata;
78 struct TagItem *tstate;
79 struct TagItem *tag;
81 ULONG rc = 0;
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)
90 return OTERR_Failure;
92 tstate = tags;
93 while ((tag = NextTagItem(&tstate)))
95 otagtag = tag->ti_Tag;
96 otagdata = tag->ti_Data;
98 switch (otagtag)
100 case OT_GlyphMap:
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;
110 break;
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;
123 break;
125 case OT_WidthList:
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;
132 break;
134 case OT_TextKernPair:
135 case OT_DesignKernPair:
136 D(bug("Obtain: KernPair Data=%lx\n", otagdata));
137 *((ULONG *)otagdata)=get_kerning_dir(engine);
138 break;
140 default:
141 D(bug("Unanswered Obtain: Tag=%lx Data=%lx\n",(LONG)otagtag, otagdata));
142 rc=OTERR_UnknownTag;
143 break;
147 return rc;
149 AROS_LIBFUNC_EXIT