+static void handleFontAlign1(TAG*tag)
+{
+ swf_SetTagPos(tag, 0);
+ U16 id = swf_GetU16(tag);
+ U8 flags = swf_GetU8(tag);
+ printf(" for font %04d, ", id);
+ if((flags&3)==0) printf("thin, ");
+ else if((flags&3)==1) printf("medium, ");
+ else if((flags&3)==2) printf("thick, ");
+ else printf("?, ");
+ int num=0;
+ while(tag->pos < tag->len) {
+ int nr = swf_GetU8(tag); // should be 2
+ int t;
+ if(nr>2) {
+ printf("*** unsupported multiboxes ***, ");
+ break;
+ }
+ for(t=0;t<nr;t++) {
+ float v1 = swf_GetF16(tag);
+ float v2 = swf_GetF16(tag);
+ }
+ U8 xyflags = swf_GetU8(tag);
+ num++;
+ }
+ printf(" %d glyphs", num);
+}
+
+#define ALIGN_WITH_GLYPHS
+static void handleFontAlign2(TAG*tag, char*prefix)
+{
+ if(!showfonts)
+ return;
+ swf_SetTagPos(tag, 0);
+ U16 id = swf_GetU16(tag);
+ swf_GetU8(tag);
+ int num = 0;
+#ifdef ALIGN_WITH_GLYPHS
+ SWF swf;
+ swf.firstTag = tag;
+ while(swf.firstTag->prev) swf.firstTag = swf.firstTag->prev;
+ SWFFONT* font = 0;
+ swf_FontExtract(&swf, id, &font);
+#endif
+ swf_SetTagPos(tag, 3);
+ while(tag->pos < tag->len) {
+ printf("%sglyph %d) ", prefix, num);
+ int nr = swf_GetU8(tag); // should be 2
+ int t;
+ for(t=0;t<2;t++) {
+ // pos
+ float v = swf_GetF16(tag);
+ printf("%f ", v*1024.0);
+ }
+ int s;
+ for(s=0;s<nr-1;s++) {
+ for(t=0;t<2;t++) {
+ // width
+ float v = swf_GetF16(tag);
+ printf("+%f ", v*1024.0);
+ }
+ }
+ U8 xyflags = swf_GetU8(tag);
+ printf("xy:%02x\n", xyflags);
+
+#ifdef ALIGN_WITH_GLYPHS
+ if(font && num<font->numchars) {
+ SHAPE2* shape = swf_ShapeToShape2(font->glyph[num].shape);
+ SHAPELINE*line = shape->lines;
+ while(line) {
+ if(line->type == moveTo) {
+ printf("%smoveTo %.2f %.2f\n", prefix, line->x/20.0, line->y/20.0);
+ } else if(line->type == lineTo) {
+ printf("%slineTo %.2f %.2f\n", prefix, line->x/20.0, line->y/20.0);
+ } else if(line->type == splineTo) {
+ printf("%ssplineTo (%.2f %.2f) %.2f %.2f\n", prefix,
+ line->sx/20.0, line->sy/20.0,
+ line->x/20.0, line->y/20.0
+ );
+ }
+ line = line->next;
+ }
+ swf_Shape2Free(shape);
+ free(shape);
+ }
+ if(num==font->numchars-1) break;
+#endif
+ num++;
+ }
+}
+
+