4 * A simple utility to generate the stroke fonts to be used in freeglut.
6 * Copyright (c) 1999-2000 by Pawel W. Olszta
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: czw sty 06 19:42:30 CET 2000
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software")
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Sotware.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 * Define the log domain
42 #define G_LOG_DOMAIN "genstroke"
45 * The alphabet we want to export.
47 char* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
48 int g_AlphabetLength = 0;
51 * All undefined characters will get replaced by this one:
56 * The stream we want to redirect our output to
58 FILE* g_Output = NULL;
63 char *g_ProgName = "";
66 * This function outputs the font file prologue
68 void OutputPrologue( char* fileName )
71 * Output the copyright and permission notices:
73 fprintf( g_Output, "/*\n * %s\n *\n * This file has been automatically generated by the genfonts utility.\n *\n", fileName );
74 fprintf( g_Output, " * Copyright (c) 1999-2000 by Pawel W. Olszta\n * Written by Pawel W. Olszta, <olszta@sourceforge.net>\n * \n" );
75 fprintf( g_Output, " * Permission is hereby granted, free of charge, to any person obtaining a\n" );
76 fprintf( g_Output, " * copy of this software and associated documentation files (the \"Software\"),\n" );
77 fprintf( g_Output, " * to deal in the Software without restriction, including without limitation\n" );
78 fprintf( g_Output, " * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n" );
79 fprintf( g_Output, " * and/or sell copies of the Software, and to permit persons to whom the\n" );
80 fprintf( g_Output, " * Software is furnished to do so, subject to the following conditions:\n *\n" );
81 fprintf( g_Output, " * The above copyright notice and this permission notice shall be included\n" );
82 fprintf( g_Output, " * in all copies or substantial portions of the Sotware.\n *\n" );
83 fprintf( g_Output, " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n" );
84 fprintf( g_Output, " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" );
85 fprintf( g_Output, " * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n" );
86 fprintf( g_Output, " * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n" );
87 fprintf( g_Output, " * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n" );
88 fprintf( g_Output, " * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n" );
91 * The obvious include headers
93 fprintf( g_Output, "\n#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include \"../include/GL/freeglut.h\"\n#include \"../include/GL/freeglut_internal.h\"\n" );
97 * This function outputs a font set
99 void OutputFont( char* freeglutFontName, char* fontName )
102 * This is an easy one. I just have to write a parser for the SRC files
103 * and dump their contents to the output file. Expect this to be done
104 * this weekend. The output data should be organized just like the bitmap
105 * fonts data, as it shown to be good.
110 * This function outputs the font file epilogue
112 void OutputEpilogue( void )
114 fprintf( g_Output, "/*** END OF FILE ***/\n" );
118 * The main function processes the command line arguments
119 * and outputs all the fonts we need to have rasterized.
121 int main( int argc, char** argv )
123 char ourCharacter[ 2 ] = { 0, 0 };
124 char* outputFileName = NULL;
127 g_ProgName = argv[0];
130 * Initialize the alphabet's length
132 g_AlphabetLength = strlen( g_Alphabet );
135 * Make sure that the no-character character is in the alphabet
137 ourCharacter[ 0 ] = g_NoChar;
139 if( strstr( g_Alphabet, ourCharacter ) == NULL )
142 "%s: the g_NoChar `%c' character not found in the alphabet `%s'\n",
143 g_ProgName, g_NoChar, g_Alphabet );
148 * Define the default output file name
150 outputFileName = strdup( "freeglut_font_stroke.c" );
153 * Process the command line arguments now. Command line arguments expected:
155 * -file <FILENAME> -- the destination file name
160 * See what the current token is
162 if( strcasecmp( argv[ i ], "-file" ) == 0 )
164 assert( (i + 1) < argc );
165 free( outputFileName );
168 * The next token is expected to contain the destination file name
170 outputFileName = strdup( argv[ ++i ] );
174 * Get to the next argument
180 * Have the destination file opened
182 g_Output = fopen( outputFileName, "wt" );
183 assert( g_Output != NULL );
186 * Output the file header first
188 OutputPrologue( outputFileName );
191 * Output all of the fonts we want to output
193 OutputFont( "Roman", "Roman.src" );
194 OutputFont( "RomanMono", "Roman_M.src" );
197 * Finally, have the file epilogue outputted
202 * Close the output stream
207 * Clean up all the rest of the mess
209 free( outputFileName );
214 return( EXIT_SUCCESS );
217 /*** END OF FILE ***/