revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / freetype2 / setinfoa.c
blobf29b6a3a560ff333a47eeca9193a278d3786b5c8
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"
8 #include <aros/libcall.h>
9 #include <proto/utility.h>
10 #include <aros/debug.h>
11 #include <utility/tagitem.h>
12 #include <diskfont/oterrors.h>
13 #include <diskfont/diskfonttag.h>
14 #include <diskfont/glyph.h>
16 #include LC_LIBDEFS_FILE
18 /* scantags, from SetInfoA, looking for the ones we care about
19 just ignore anything we don't recognize for now */
21 static void scantags(FT_GlyphEngine *ge, struct TagItem *tags)
23 Tag otagtag;
24 IPTR otagdata;
25 struct TagItem *tstate;
26 struct TagItem *tag;
27 int temp, temp2;
29 tstate = tags;
30 while ((tag = NextTagItem(&tstate)))
32 otagtag = tag->ti_Tag;
33 otagdata = tag->ti_Data;
35 switch (otagtag)
37 /* OT_Spec1 = the filename of the ft file */
38 case OT_Spec1_FontFile:
39 D(bug("SetInfo: Tag=OT_Spec1 ft file=%ls\n",otagdata));
40 /* if(OpenFace(ge,(char *)otagdata)) return; */
41 strcpy(ge->base_filename,(char *)otagdata);
42 /* clear all other names */
43 ge->afm_filename[0] = '\0';
44 switch_family(ge);
45 break;
47 case OT_Spec2_DefCodePage: /* direct = use default */
48 D(bug("SetInfo: Tag=OT_Spec2 Default Code Page\n"));
49 set_default_codepage(ge);
50 break;
52 case OT_Spec2_CodePage:
53 D(bug("SetInfo: Tag=OT_Spec2 Custom Code Page\n"));
54 CopyMem((char *)otagdata,ge->codepage,sizeof(ge->codepage));
55 break;
57 case OT_Spec3_AFMFile:
58 strcpy(ge->afm_filename,(char *)otagdata);
59 break;
61 /* OT_Spec4 = metric source */
62 case OT_Spec4_Metric:
63 D(bug("SetInfo: Tag=OT_Spec4 Metric Source=%lx\n",otagdata));
64 temp=(ULONG)otagdata;
65 if(ge->metric_source!=temp)
67 ge->metric_source = temp;
68 ge->instance_changed=TRUE;
70 break;
72 /* OT_Spec5 = custom metrics */
73 case OT_Spec5_BBox:
74 D(bug("SetInfo: Tag=OT_Spec5 Custom Metrics=%lx\n",otagdata));
75 temp=(ULONG)otagdata;
76 if(ge->metric_custom!=temp)
78 ge->metric_custom = temp;
79 ge->instance_changed=TRUE;
81 break;
83 case OT_Spec6_FaceNum:
84 D(bug("SetInfo: Tag=OT_Spec6_FaceNum\n"));
85 ge->face_num = otagdata;
86 break;
88 case OT_Spec7_BMSize:
89 break;
91 case OT_Spec9_Hinter:
92 break;
94 case OT_SymbolSet: /* index to charmap encodings */
95 D(bug("SetInfo: Tag=OT_SymbolSet cmap=%lx\n",otagdata));
96 ge->requested_cmap = (ULONG)otagdata;
97 ge->cmap_index=NO_CMAP_SET;
98 break;
100 /* some programs specify point and DPI with every glyph
101 * request, so check if they really changed before setting
102 * instance_changed. (Note: OpenFace ALWAYS sets it.) */
103 case OT_PointHeight:
104 D(bug("SetInfo: Tag=OT_PointHeight size=%lx\n",otagdata));
105 temp = ((ULONG)otagdata) >> 16;
106 if(ge->point_size != temp)
108 ge->point_size = temp;
109 ge->instance_changed=TRUE;
111 break;
113 case OT_DeviceDPI:
114 temp = ((ULONG)otagdata) >> 16;
115 temp2 = ((ULONG)otagdata) & 0xffff;
116 D(bug("SetInfo: Tag=OT_DeviceDPI xres=%ld yres=%ld\n",temp,temp2));
117 if((temp!=ge->xres) || (temp2!=ge->yres))
119 ge->xres = temp;
120 ge->yres = temp2;
121 ge->instance_changed=TRUE;
123 break;
125 case OT_RotateSin: /* by spec set SIN then COS */
126 D(bug("SetInfo: Tag=OT_RotateSin sin=%lx\n",otagdata));
127 ge->hold_sin = ((ULONG)otagdata);
128 break;
130 case OT_RotateCos: /* process both SIN and COS */
131 D(bug("SetInfo: Tag=OT_RotateCos cos=%lx\n",otagdata));
132 ge->hold_cos = ((ULONG)otagdata);
133 /* sin=0.0 cos=1.0 is no rotation */
134 if(ge->hold_sin==0 && ge->hold_cos==0x10000)
135 ge->do_rotate=0;
136 else
138 /* argh! counter clockwise rotation
139 * swapped .xy and .yx to match bullet.
140 * hmmm, shear is clockwise...arrggghhh! */
141 ge->do_rotate=1;
142 ge->rotate_matrix.xx = ge->hold_cos;
143 ge->rotate_matrix.xy = -ge->hold_sin;
144 ge->rotate_matrix.yx = ge->hold_sin;
145 ge->rotate_matrix.yy = ge->hold_cos;
147 set_transform(ge);
148 break;
150 case OT_ShearSin: /* by spec set SIN then COS */
151 D(bug("SetInfo: Tag=OT_ShearSin sin=%lx\n",otagdata));
152 ge->hold_sin = ((ULONG)otagdata);
153 break;
155 case OT_ShearCos:
156 D(bug("SetInfo: Tag=OT_ShearCos cos=%lx\n",otagdata));
157 ge->hold_cos = ((ULONG)otagdata);
158 /* sin=0.0 cos=1.0 is no shear */
159 if(ge->hold_sin==0 && ge->hold_cos==0x10000)
161 ge->do_shear=0;
162 // ge->italic_sig=0;
164 else
166 ge->do_shear=1;
167 // ge->italic_sig=1;
168 if(ge->hold_cos)
169 temp=FT_MulDiv(ge->hold_sin,
170 0x10000,ge->hold_cos);
171 else temp=0;
172 ge->shear_matrix.xx = 1<<16;
173 ge->shear_matrix.xy = temp;
174 ge->shear_matrix.yx = 0;
175 ge->shear_matrix.yy = 1<<16;
177 set_transform(ge);
178 break;
180 #if 0
181 case OT_EmboldenX:
182 D(bug("SetInfo: Tag=OT_EmboldenX data=%lx\n",otagdata));
183 ge->do_embold=0;
184 ge->bold_sig=0;
185 ge->embold_x = (ULONG)otagdata;
186 if(ge->embold_x || ge->embold_y)
188 ge->do_embold=1;
189 ge->bold_sig=2;
191 break;
193 case OT_EmboldenY:
194 D(bug("SetInfo: Tag=OT_EmboldenY data=%lx\n",otagdata));
195 ge->do_embold=0;
196 ge->bold_sig=0;
197 ge->embold_y = (ULONG)otagdata;
198 if(ge->embold_x || ge->embold_y)
200 ge->do_embold=1;
201 ge->bold_sig=2;
203 break;
204 #endif
205 #if 0
206 Diskfont Bold signature
207 <Set: Tag=8000000E Data=E75
208 <Set: Tag=8000000F Data=99E
210 Diskfont Italic signature
211 <Set: Tag=8000000A Data=4690
212 <Set: Tag=8000000B Data=F615
213 #endif
215 case OT_GlyphCode:
216 D(bug("SetInfo: Tag=OT_GlyphCode data=%lx\n",otagdata));
217 ge->request_char = (ULONG)otagdata;
218 break;
220 case OT_GlyphCode2:
221 D(bug("SetInfo: Tag=OT_GlyphCode2 data=%lx\n",otagdata));
222 ge->request_char2 = (ULONG)otagdata;
223 break;
225 case OT_OTagList: /* a tag of tags? */
226 D(bug("SetInfo: Tag=OT_OTagList data=%lx\n",otagdata));
227 if (otagdata)
228 scantags(ge, (struct TagItem *)otagdata);
229 break;
231 default:
232 D(bug("Ignored Set: Tag=%lx Data=%lx\n",(LONG)otagtag, otagdata));
233 break;
238 /* SetInfoA, store request into our engine structure. */
239 AROS_LH2(ULONG, SetInfoA,
240 AROS_LHA(struct GlyphEngine *, ge, A0),
241 AROS_LHA(struct TagItem *, tags, A1),
242 LIBBASETYPEPTR, LIBBASE, 7, FreeType2
245 AROS_LIBFUNC_INIT
247 FT_GlyphEngine *engine = (FT_GlyphEngine *)ge
248 D(bug("LIB_SetInfoA libbase = 0x%lx engine = 0x%lx tags = 0x%lx\n",FTBase,engine,tags));
250 set_last_error(engine,OTERR_Success);
251 scantags(engine, tags);
253 return (ULONG)(engine->last_error);
255 AROS_LIBFUNC_EXIT