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.
40 * Define the log domain
43 #define G_LOG_DOMAIN "genstroke"
46 * The alphabet we want to export.
48 gchar* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
49 gint g_AlphabetLength = 0;
52 * All undefined characters will get replaced by this one:
57 * The stream we want to redirect our output to
59 FILE* g_Output = NULL;
62 * This function outputs the font file prologue
64 void OutputPrologue( gchar* fileName )
67 * Output the copyright and permission notices:
69 fprintf( g_Output, "/*\n * %s\n *\n * This file has been automatically generated by the genfonts utility.\n *\n", fileName );
70 fprintf( g_Output, " * Copyright (c) 1999-2000 by Pawel W. Olszta\n * Written by Pawel W. Olszta, <olszta@sourceforge.net>\n * \n" );
71 fprintf( g_Output, " * Permission is hereby granted, free of charge, to any person obtaining a\n" );
72 fprintf( g_Output, " * copy of this software and associated documentation files (the \"Software\"),\n" );
73 fprintf( g_Output, " * to deal in the Software without restriction, including without limitation\n" );
74 fprintf( g_Output, " * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n" );
75 fprintf( g_Output, " * and/or sell copies of the Software, and to permit persons to whom the\n" );
76 fprintf( g_Output, " * Software is furnished to do so, subject to the following conditions:\n *\n" );
77 fprintf( g_Output, " * The above copyright notice and this permission notice shall be included\n" );
78 fprintf( g_Output, " * in all copies or substantial portions of the Sotware.\n *\n" );
79 fprintf( g_Output, " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n" );
80 fprintf( g_Output, " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" );
81 fprintf( g_Output, " * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n" );
82 fprintf( g_Output, " * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n" );
83 fprintf( g_Output, " * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n" );
84 fprintf( g_Output, " * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n" );
87 * The obvious include headers
89 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" );
93 * This function outputs a font set
95 void OutputFont( gchar* freeglutFontName, gchar* fontName )
98 * This is an easy one. I just have to write a parser for the SRC files
99 * and dump their contents to the output file. Expect this to be done
100 * this weekend. The output data should be organized just like the bitmap
101 * fonts data, as it shown to be good.
106 * This function outputs the font file epilogue
108 void OutputEpilogue( void )
110 fprintf( g_Output, "/*** END OF FILE ***/\n" );
114 * The main function processes the command line arguments
115 * and outputs all the fonts we need to have rasterized.
117 int main( int argc, char** argv )
119 gchar ourCharacter[ 2 ] = { 0, 0 };
120 gchar* outputFileName = NULL;
124 * Initialize the alphabet's length
126 g_AlphabetLength = strlen( g_Alphabet );
129 * Make sure that the no-character character is in the alphabet
131 ourCharacter[ 0 ] = g_NoChar;
133 if( strstr( g_Alphabet, ourCharacter ) == NULL )
134 g_error( "the g_NoChar `%c' character not found in the alphabet `%s'", g_NoChar, g_Alphabet );
137 * Define the default output file name
139 outputFileName = g_strdup( "freeglut_font_stroke.c" );
142 * Process the command line arguments now. Command line arguments expected:
144 * -file <FILENAME> -- the destination file name
149 * See what the current token is
151 if( g_strcasecmp( argv[ i ], "-file" ) == 0 )
153 g_assert( (i + 1) < argc );
154 g_free( outputFileName );
157 * The next token is expected to contain the destination file name
159 outputFileName = g_strdup( (gchar *) argv[ ++i ] );
163 * Get to the next argument
169 * Have the destination file opened
171 g_Output = fopen( outputFileName, "wt" );
172 g_assert( g_Output != NULL );
175 * Output the file header first
177 OutputPrologue( outputFileName );
180 * Output all of the fonts we want to output
182 OutputFont( "Roman", "Roman.src" );
183 OutputFont( "RomanMono", "Roman_M.src" );
186 * Finally, have the file epilogue outputted
191 * Close the output stream
196 * Clean up all the rest of the mess
198 g_free( outputFileName );
203 return( EXIT_SUCCESS );
206 /*** END OF FILE ***/