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"
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
)
25 struct TagItem
*tstate
;
30 while ((tag
= NextTagItem(&tstate
)))
32 otagtag
= tag
->ti_Tag
;
33 otagdata
= tag
->ti_Data
;
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';
47 case OT_Spec2_DefCodePage
: /* direct = use default */
48 D(bug("SetInfo: Tag=OT_Spec2 Default Code Page\n"));
49 set_default_codepage(ge
);
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
));
57 case OT_Spec3_AFMFile
:
58 strcpy(ge
->afm_filename
,(char *)otagdata
);
61 /* OT_Spec4 = metric source */
63 D(bug("SetInfo: Tag=OT_Spec4 Metric Source=%lx\n",otagdata
));
65 if(ge
->metric_source
!=temp
)
67 ge
->metric_source
= temp
;
68 ge
->instance_changed
=TRUE
;
72 /* OT_Spec5 = custom metrics */
74 D(bug("SetInfo: Tag=OT_Spec5 Custom Metrics=%lx\n",otagdata
));
76 if(ge
->metric_custom
!=temp
)
78 ge
->metric_custom
= temp
;
79 ge
->instance_changed
=TRUE
;
83 case OT_Spec6_FaceNum
:
84 D(bug("SetInfo: Tag=OT_Spec6_FaceNum\n"));
85 ge
->face_num
= otagdata
;
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
;
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.) */
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
;
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
))
121 ge
->instance_changed
=TRUE
;
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
);
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)
138 /* argh! counter clockwise rotation
139 * swapped .xy and .yx to match bullet.
140 * hmmm, shear is clockwise...arrggghhh! */
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
;
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
);
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)
169 temp
=FT_MulDiv(ge
->hold_sin
,
170 0x10000,ge
->hold_cos
);
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;
182 D(bug("SetInfo: Tag=OT_EmboldenX data=%lx\n",otagdata
));
185 ge
->embold_x
= (ULONG
)otagdata
;
186 if(ge
->embold_x
|| ge
->embold_y
)
194 D(bug("SetInfo: Tag=OT_EmboldenY data=%lx\n",otagdata
));
197 ge
->embold_y
= (ULONG
)otagdata
;
198 if(ge
->embold_x
|| ge
->embold_y
)
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
216 D(bug("SetInfo: Tag=OT_GlyphCode data=%lx\n",otagdata
));
217 ge
->request_char
= (ULONG
)otagdata
;
221 D(bug("SetInfo: Tag=OT_GlyphCode2 data=%lx\n",otagdata
));
222 ge
->request_char2
= (ULONG
)otagdata
;
225 case OT_OTagList
: /* a tag of tags? */
226 D(bug("SetInfo: Tag=OT_OTagList data=%lx\n",otagdata
));
228 scantags(ge
, (struct TagItem
*)otagdata
);
232 D(bug("Ignored Set: Tag=%lx Data=%lx\n",(LONG
)otagtag
, otagdata
));
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
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
);