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)
52 int points = 50; // <- change global text size here
54 int textsize = points*20; // adjust height
55 int textscale = points*10; // adjust spacing
58 SWFFONT * font = Font_Demo_Font(ID_FONT); // change font name here
60 swf_FontInitUsage(&use);
61 swf_FontUse(&use,BANNER_TEXT); // SWF reduces font information to the used glyphs
62 swf_FontReduce(font,&use);
64 memset(&swf,0x00,sizeof(SWF));
67 swf.frameRate = 0x4000;
68 swf.movieSize.xmax = 20*width;
69 swf.movieSize.ymax = 20*height;
71 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
79 t = swf_InsertTag(t,ST_DEFINEFONT);
81 swf_FontSetDefine(t,font);
83 t = swf_InsertTag(t,ST_DEFINEFONTINFO);
85 swf_FontSetInfo(t,font);
87 t = swf_InsertTag(t,ST_DEFINETEXT);
89 swf_SetU16(t,ID_BANNER); // ID
93 r.xmax = swf_TextGetWidth(font,BANNER_TEXT,textscale);
98 swf_SetMatrix(t,NULL);
100 swf_TextCountBits(font,BANNER_TEXT,textscale,&gbits,&abits);
109 swf_TextSetInfoRecord(t,font,textsize,&rgb,0,textsize);
110 swf_TextSetCharRecord(t,font,BANNER_TEXT,textscale,gbits,abits);
115 t = swf_InsertTag(t,ST_PLACEOBJECT2);
117 swf_ObjectPlace(t,ID_BANNER,1,NULL,NULL,NULL);
119 t = swf_InsertTag(t,ST_SHOWFRAME);
121 t = swf_InsertTag(t,ST_END);
123 // swf_WriteCGI(&swf);
126 f = open("text.swf",O_RDWR|O_CREAT|O_TRUNC,0644);
127 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
131 // swf_FontFree(font);
134 system("start ..\\text.swf");