5 |
// modify it under the terms of the GNU General Public License |
// modify it under the terms of the GNU General Public License |
6 |
// as published by the Free Software Foundation; either version 2 |
// as published by the Free Software Foundation; either version 2 |
7 |
// of the License, or (at your option) any later version. |
// of the License, or (at your option) any later version. |
8 |
// |
// |
9 |
// This program is distributed in the hope that it will be useful, |
// This program is distributed in the hope that it will be useful, |
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
// GNU General Public License for more details. |
// GNU General Public License for more details. |
13 |
// |
// |
14 |
// You should have received a copy of the GNU General Public License along |
// You should have received a copy of the GNU General Public License along |
15 |
// with this program; if not, write to the Free Software Foundation, Inc., |
// with this program; if not, write to the Free Software Foundation, Inc., |
16 |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
17 |
//====================================================================== |
//====================================================================== |
18 |
|
|
19 |
/* |
/* |
20 |
* This program converts TrueType fonts to special bitmapped fonts. |
* This program converts TrueType fonts to special bitmapped fonts. |
21 |
* These bitmap fonts constists (a) of an image file containing the |
* These bitmap fonts constists (a) of an image file containing the |
22 |
* individual character glyphs and (b) a simplified font metrics file |
* individual character glyphs and (b) a simplified font metrics file |
71 |
/* Name of the output file (without extension). */ |
/* Name of the output file (without extension). */ |
72 |
string output_file; |
string output_file; |
73 |
|
|
74 |
SDL_Color fgcolor = {0x0ff,0xff, 0xff}; |
SDL_Color fgcolor = { 0xff, 0xff, 0xff, 0}; |
75 |
SDL_Color bgcolor = {0,0,0}; |
SDL_Color bgcolor = { 0, 0, 0, 0 }; |
76 |
|
|
77 |
|
|
78 |
//---------------------------------------- |
//---------------------------------------- |
81 |
|
|
82 |
|
|
83 |
static void |
static void |
84 |
usage() |
usage() |
85 |
{ |
{ |
86 |
cout << "ttf2bmf [options] file.ttf\n\n" |
cout << "ttf2bmf [options] file.ttf\n\n" |
87 |
<< "-o name basename of the output files\n" |
<< "-o name basename of the output files\n" |
149 |
SDL_SaveBMP(glyphs, (output_file + ".bmp").c_str()); |
SDL_SaveBMP(glyphs, (output_file + ".bmp").c_str()); |
150 |
} |
} |
151 |
|
|
152 |
int |
int |
153 |
main (int argc, char **argv) |
main (int argc, char **argv) |
154 |
{ |
{ |
155 |
for (int c=firstchar; c<=lastchar; ++c) |
for (int c=firstchar; c<=lastchar; ++c) |
170 |
chars_to_render = optarg; |
chars_to_render = optarg; |
171 |
break; |
break; |
172 |
case 'c': |
case 'c': |
173 |
{ |
{ |
174 |
int color; |
int color; |
175 |
sscanf(optarg, "%x", &color); |
sscanf(optarg, "%x", &color); |
176 |
fgcolor.r = (color >> 16) & 0xff; |
fgcolor.r = (color >> 16) & 0xff; |