3 Example for how to construct an SWF font from another SWF font.
5 Part of the swftools package.
7 Copyright (c) 2004 Matthias Kramm <kramm@quiss.org>
9 This file is distributed under the GPL, see file COPYING for details
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
28 #include "../rfxswf.h"
32 char* hex = "0123456789ABCDEF";
33 SWFFONT* font = swf_LoadFont("Courier.swf");
36 memset(&hexfont, 0, sizeof(hexfont));
37 hexfont.name = "HexFont";
38 hexfont.layout = malloc(sizeof(SWFLAYOUT));
39 hexfont.numchars = 256;
40 hexfont.maxascii = 256;
41 hexfont.encoding = 32;
42 hexfont.glyph2ascii = malloc(sizeof(U16)*256);
43 hexfont.ascii2glyph = malloc(sizeof(int)*256);
44 hexfont.glyph = malloc(sizeof(SWFGLYPH)*256);
45 hexfont.glyphnames = malloc(sizeof(char*)*256);
46 hexfont.layout->bounds = malloc(sizeof(SRECT)*256);
47 hexfont.layout->kerningcount = 0;
48 hexfont.layout->kerning = 0;
50 int ymax =-0x7fffffff;
51 int ymin = 0x7fffffff;
61 swf_Shape01DrawerInit(&draw, 0);
62 swf_DrawText(&draw, font, (int)(10*20), nr);
64 hexfont.glyph[t].shape = swf_ShapeDrawerToShape(&draw);
65 hexfont.layout->bounds[t] = swf_ShapeDrawerGetBBox(&draw);
66 hexfont.glyph[t].advance = hexfont.layout->bounds[t].xmax + hexfont.layout->bounds[t].xmin;
68 hexfont.glyph2ascii[t] = t;
69 hexfont.ascii2glyph[t] = t;
70 hexfont.glyphnames[t] = strdup(nr);
71 if(hexfont.layout->bounds[t].ymax > ymax)
72 ymax = hexfont.layout->bounds[t].ymax;
73 if(hexfont.layout->bounds[t].ymin < ymin)
74 ymin = hexfont.layout->bounds[t].ymin;
76 hexfont.glyph2ascii[t] = 0;
80 hexfont.layout->ascent = ymin<0?-ymin:0;
81 hexfont.layout->descent = ymax>0?ymax:0;
82 hexfont.layout->leading = hexfont.layout->ascent + hexfont.layout->descent;
84 swf_WriteFont(&hexfont, "hexfont.swf");