3 Example for including and using fonts
5 Part of the swftools package.
7 Copyright (c) 2001 Rainer Böhme <rfxswf@reflex-studio.de>
9 This file is distributed under the GPL, see file COPYING for details
16 #include "../rfxswf.h"
18 #include "demofont.c" // five glyphs only: f, l, o, s, w
21 Due to copyright reasons we don't include full typesets into
22 the swftools package. But you can easily create fontdumps
25 * Create a swf file with all characters of your desired fonts
26 (with any tool that can output swf files)
28 * use the dumpfont example in this directory to dump font code
30 * include dump code and adjust Font_<Fontname>() calls.
32 Note: pdf2swf (Version 0.1.0) doesn't write ST_DEFINEFONTINFO tags,
33 so you can't extract fonts out of documents made with pdf2swf.
37 #define BANNER_TEXT "swftools"
39 #define ID_BANNER 2001
41 int main(int argc, char ** argv)
53 int points = 50; // <- change global text size here
55 int textsize = points*20; // adjust height
56 int textscale = points*10; // adjust spacing
59 SWFFONT * font = Font_Demo_Font(ID_FONT); // change font name here
61 /* adding layout to a font has the side effect that the
62 advance information is stored in the font itself, not
63 in accompanying textfields- this is needed e.g. for
66 swf_FontAddLayout(font,0,0,0);
68 swf_FontInitUsage(&use);
69 swf_FontUse(&use,BANNER_TEXT); // SWF reduces font information to the used glyphs
70 swf_FontReduce(font,&use);
72 memset(&swf,0x00,sizeof(SWF));
75 swf.frameRate = 0x4000;
76 swf.movieSize.xmax = 20*width;
77 swf.movieSize.ymax = 20*height;
79 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
88 t = swf_InsertTag(t,ST_DEFINEFONT2);
89 swf_FontSetDefine2(t, font);
91 t = swf_InsertTag(t,ST_DEFINEFONT);
92 swf_FontSetDefine(t, font);
93 t = swf_InsertTag(t,ST_DEFINEFONTINFO);
94 swf_FontSetInfo(t, font);
97 t = swf_InsertTag(t,ST_DEFINETEXT);
99 swf_SetU16(t,ID_BANNER); // ID
103 r.xmax = swf_TextGetWidth(font,BANNER_TEXT,textscale);
108 swf_SetMatrix(t,NULL);
110 swf_TextCountBits(font,BANNER_TEXT,textscale,&gbits,&abits);
119 swf_TextSetInfoRecord(t,font,textsize,&rgb,0,textsize);
120 swf_TextSetCharRecord(t,font,BANNER_TEXT,textscale,gbits,abits);
125 t = swf_InsertTag(t,ST_PLACEOBJECT2);
127 swf_ObjectPlace(t,ID_BANNER,1,NULL,NULL,NULL);
129 t = swf_InsertTag(t,ST_SHOWFRAME);
131 t = swf_InsertTag(t,ST_END);
133 // swf_WriteCGI(&swf);
136 f = open("text.swf",O_RDWR|O_CREAT|O_TRUNC,0644);
137 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
141 // swf_FontFree(font);
144 system("start ..\\text.swf");