====================================== AD GL FONT CREATOR v. 1.0.0.8 28th December 2003 Copyright ®2003-2004, Davide Angeli davideangeli@estelnet.it ADGLFont Creator v 1.0.0.8 is Free software and come absolutely with no warranty. ====================================== 0. SUMMARY ------- 1. WHAT IS THIS? 2. REQUIREMENTS 3. WHAT'S NEW (UPDATES & CHANGES) 4. KNOWN PROBLEMS AND ISSUES 5. ADF File Structure 1. WHAT IS THIS? ------------- This program was developed to create a useful tool to convert the TrueType font file format in another cross platform format suitable to be used to render text very quickly and efficiently with the OpenGL texture rendering routines. The program was originally inspired by Brad Fish's glFont2 (see http://students.cs.byu.edu/~bfish/) and was required me by my brother Paolo. For anyone who is interested the program is developed with Delphi. The resulting ADF font file format is the standard format used by the CELUI library developed by Paolo Angeli (see http://members.xoom.virgilio.it/pangeli70). Italic format fonts are not supported, only normal and bold style are saved to file. With the program it is possible to: - use antialiasing to render TrueType fonts with a smoother appearance. - set a filter to select the available charsets contained in a TrueType file. - save power of two texture with a size up to 1024 x 1024. Actually there isn't an official website so the file and the pages are hosted by my brother's website: http://members.xoom.virgilio.it/pangeli70/ADGLFont/index.htm If you have any request or suggestion about this program you can send me an e-mail at the address davideangeli@estelnet.it . 2. REQUIREMENTS ------------ The program is tested to run on Windows 2000 and Windows XP. Probably it will run well under windows 9x and ME too, but without unicode support. The program creates itself its own ini file to save the preferences so it is sufficient to copy the executable file in the desired folder. No specific installation is required nor any file extension association is provided. 3. KNOWN PROBLEMS AND ISSUES ------------------------- Under windows XP it is possible to use the ClearType functionality to improve smoothness and readability of characters on the video and is especially recommended for LCD monitors. If ClearType is enabled when using ADGLFont Creator the resulting texture is not perfectly suitable to be used in OpenGL because characters will appear too much “foggy”. Invalid characters are automatically excluded before the texture generation to avoid wasting precious texture space. The API routine that tests invalid chars fails with some characters in some particular TrueType fonts, specially with the ones that contains symbols. The texture is saved with the coordinate 0.0 in the top left corner. OpenGL considers the coordinate 0.0 in the bottom left corner So when the texture is rendered it is necessary to pay attention to this issue. Obviously the texture characters are size and scale dependent. So if the quads used to render the single characters are scaled too much the final result will be very poor. It is recommended to use a min scale factor of 0.5 and a max scale factor of 2 if the true type size is between 10 and 14. Over 14 the scale factor should vary a little bit more. Under 10 is recommended a scale factor of 1. In any case the better results will be obtained with a scale factor of 1. 4. WHAT'S NEW (UPDATES & CHANGES) ------------------------------ Version 1.0.0.8 (25-12-2003): - Solved a problem with a white line ad the right & bottom borders of the textures. Version 1.0.0.7 (21-12-2003): - Changed char positioning (increased distance between chars). Version 1.0.0.6 (16-12-2003): - Unicode Filter Improved. - Correct errors in char's zoom. Version 1.0.0.5 (14-12-2003): - Correct a grid index out range error when changing font and the new font has less valid chars of the previous font painted. - Correct errors in initial drawing of then zoomed char. - Solved same problems with font dimensions of the grid. - Chars zoom Improved : now the char is centered in the drawing space and the scrollbars appear only if necessary. - Added support to 1024x1024 textures. - Added visualization of the number of effective chars painted (if the texture is too small). - Added visualization of the unicode charset of the char painted. - Added the Char's filter to select the Unicode Charsets available in the TrueType font. - Added a new section in the header of the file to save the included Charsets. Version 1.0.0.4 (12-12-2003): - Added the Char viewer with some zoom capabilities. - Some minor bug corrections. Version 1.0.0.3 (10-12-2003): - The characters not contained in the true type file are excluded from rendering. - Major improvements in toolbars and user interface. - A message is displayed if the size of the texture is not sufficient to contain all the selected chars. - Some bug corrections. Version 1.0.0.2 (07-12-2003): - Saves the first version of ADF file format. - Minor changes due to OpenGL tests. Version 1.0.0.1 (01-12-2003): - First version draws only the font in a defined interval of unicode chars. 5. ADF File Structure ------------------ This code was excerpted from the CELUI library developed by Paolo Angeli. The first 256 bytes are the header of the file and are described by the following data structure. // uiADGLFontHeader // // Header of the Angeli Davide GL Font file format //-------------------------------------------------------------- struct uiADGLFontHeader { char fileID[5]; // 001-005 "ADFGL" uiByte fileVer; // 006-006 File Format version char fontName[50]; // 007-056 Font name uiByte fontSize; // 057-057 Size of the font uiByte fontFlag; // 058-058 1 = bold uiWord charSet; // 059-060 Code of used charset uiByte filler1[10]; // 061-070 Actually not used uiWord texWidth; // 071-072 Texture Width in pixels uiWord texHeight; // 073-074 Texture Height in pixels uiWord firstChar; // 075-076 First UNICODE CHAR stored uiWord lastChar; // 077-078 Last UNICODE CHAR stored uiWord charsNum; // 079-080 Effective number of chars stored uiWord charsHeight; // 081-082 Height of chars in the texture uiWord charsMaxWidth; // 083-084 Max width of the stored chars uiByte filler2[44]; // 085-128 actually not used uiByte uniCharSets[128]; // 129-256 Reserved }; After the header there is the Character map that is an array of the following data structures that contain the boundary data for each character. // uiADGLFontChar // // Character description for the Angeli Davide GL Font file format //---------------------------------------------------------------- struct uiADGLFontChar { uiWord unicode; // unicode character value 0x0000..0xffff uiWord left; // left coordinate in pixels of char in the texture uiWord top; // top coordinate in pixels of char in the texture uiWord width; // width in pixels (height is the same for all chars and is // contained in the fontSize header field }; After the character map an array of texWidth x texHeight bytes represents the raw OpenGL texture. It is possible to allocate dynamically the memory required by this array and declare it as: char* imgData = new char[texHeight * texWidth]; To create the texture it is possible to use the following routines: int texHandle; glGenTextures(1, (GLuint*) &texHandle); glBindTexture(GL_TEXTURE_2D, texHandle); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texWidth, texHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, (void *)imgData);