X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=genfonts%2Fgenfonts.c;fp=genfonts%2Fgenfonts.c;h=0000000000000000000000000000000000000000;hb=253d4391eda11ac537499d607130acd7d35a4411;hp=913d2de16cba12de57a92313441959aea701c5a5;hpb=c535ef5ef520519f60ea16251d2926c4a7aa452c;p=freeglut diff --git a/genfonts/genfonts.c b/genfonts/genfonts.c deleted file mode 100644 index 913d2de..0000000 --- a/genfonts/genfonts.c +++ /dev/null @@ -1,486 +0,0 @@ -/* - * main.c - * - * A simple utility to generate the bitmap fonts to be used in freeglut. - * - * Copyright (c) 1999-2000 by Pawel W. Olszta - * Written by Pawel W. Olszta, - * Creation date: nie gru 26 21:52:36 CET 1999 - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software") - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Sotware. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H - #include -#endif - -#include -#include - -#include -#include -#include -#include - -/* - * Define the log domain - */ -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "genfonts" - -/* - * The alphabet we want to export. - */ -char* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\""; -int g_AlphabetLength = 0; - -/* - * All undefined characters will get replaced by this one: - */ -char g_NoChar = '*'; - -/* - * The stream we want to redirect our output to - */ -FILE* g_Output = NULL; - -/* - * The display we're getting the fonts from - */ -Display* g_Display; - -/* - * Our argv[0] - */ -char *g_ProgName = ""; - -/* - * This function outputs the font file prologue - */ -void OutputPrologue( char* fileName ) -{ - /* - * Output the copyright and permission notices: - */ - fprintf( g_Output, "/*\n * %s\n *\n * This file has been automatically generated by the genfonts utility.\n *\n", fileName ); - fprintf( g_Output, " * Copyright (c) 1999-2000 by Pawel W. Olszta\n * Written by Pawel W. Olszta, \n * \n" ); - fprintf( g_Output, " * Permission is hereby granted, free of charge, to any person obtaining a\n" ); - fprintf( g_Output, " * copy of this software and associated documentation files (the \"Software\"),\n" ); - fprintf( g_Output, " * to deal in the Software without restriction, including without limitation\n" ); - fprintf( g_Output, " * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n" ); - fprintf( g_Output, " * and/or sell copies of the Software, and to permit persons to whom the\n" ); - fprintf( g_Output, " * Software is furnished to do so, subject to the following conditions:\n *\n" ); - fprintf( g_Output, " * The above copyright notice and this permission notice shall be included\n" ); - fprintf( g_Output, " * in all copies or substantial portions of the Sotware.\n *\n" ); - fprintf( g_Output, " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n" ); - fprintf( g_Output, " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" ); - fprintf( g_Output, " * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n" ); - fprintf( g_Output, " * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n" ); - fprintf( g_Output, " * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n" ); - fprintf( g_Output, " * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n" ); - - /* - * The obvious include headers - */ - 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" ); -} - -/* - * This function outputs a font set - */ -void OutputFont( char* freeglutFontName, char* fontName ) -{ - int character, lineWidth, maxWidth = 0, maxHeight = 0; - XFontStruct* fontStruct = NULL; - XGCValues contextValues; - XImage* image = NULL; - unsigned char* lineBuffer; - Pixmap buffer; - GC context; - - /* - * Check if there is a font that meets our requirements - */ - fontStruct = XLoadQueryFont( g_Display, fontName ); - - if( fontStruct == NULL ) - { - /* - * Whoops, the font was not found - */ - fprintf( stderr, "%s: couldn't get font `%s' using local display\n", - g_ProgName, fontName ); - exit( 1 ); - } - - /* - * Get the maximum size of the font characters - */ - maxWidth = fontStruct->max_bounds.rbearing - fontStruct->min_bounds.lbearing; - maxHeight = fontStruct->max_bounds.ascent + fontStruct->max_bounds.descent; - - /* - * Allocate the line buffer for storing the font bitmap lines - */ - lineBuffer = malloc( maxWidth ); - - /* - * Create a pixmap buffer where we'll be rendering our fonts to. - */ - buffer = XCreatePixmap( - g_Display, - RootWindow( g_Display, DefaultScreen( g_Display ) ), - maxWidth, - maxHeight, - 1 - ); - - /* - * We'll need a graphics context to handle the font writes and buffer clears - */ - context = XCreateGC( - g_Display, - buffer, - 0, - &contextValues - ); - - /* - * Have the font assigned to the graphics context - */ - XSetFont( g_Display, context, fontStruct->fid ); - - /* - * For every character we want to have outputted... - */ - for( character=0; charactermin_bounds.lbearing, - fontStruct->max_bounds.ascent, - (g_Alphabet + character), - 1 - ); - - /* - * We need some a way to access the font we've just drawn: - */ - image = XGetImage( - g_Display, - buffer, - 0, 0, - maxWidth, maxHeight, - 1, XYPixmap - ); - - /* - * Find the first non-empty column: - */ - start_x = -1; stop_x = -1; - - for( x=0; x=0; x-- ) - for( y=0; y=0; y-- ) - { - /* - * Prepare the line buffer for being used again - */ - memset( lineBuffer, 0, maxWidth ); - - /* - * Grab the rasterized character face into the line buffer - */ - for( x=start_x, lineWidth=0; x -- the display to connect to - * -file -- the destination file name - */ - while( i < argc ) - { - /* - * See what the current token is - */ - if( strcasecmp( argv[ i ], "-display" ) == 0 ) - { - assert( (i + 1) < argc ); - free( displayName ); - - /* - * The next token is expected to contain the X display name to use - */ - displayName = strdup( argv[ ++i ] ); - } - else if( strcasecmp( argv[ i ], "-file" ) == 0 ) - { - assert( (i + 1) < argc ); - free( outputFileName ); - - /* - * The next token is expected to contain the destination file name - */ - outputFileName = strdup( argv[ ++i ] ); - } - - /* - * Get to the next argument - */ - i++; - } - - /* - * Connect to the X display - */ - g_Display = XOpenDisplay( displayName ); - assert( g_Display != NULL ); - - /* - * Have the destination file opened - */ - g_Output = fopen( outputFileName, "wt" ); - assert( g_Output != NULL ); - - /* - * Output the file header first - */ - OutputPrologue( outputFileName ); - - /* - * In the file header, have the list of the fonts written: - */ - fprintf( g_Output, "\n/*\n * Following fonts are defined in this file:\n * \n" ); - - for( i=0; i\n", - i + 1, fontsList[ i*2 + 0 ], fontsList[ i*2 + 1 ] - ); - - fprintf( g_Output, " */\n\n" ); - - /* - * Output all of the fonts we want to output - */ - for( i=0; i