+++ /dev/null
-/****************************************************************************************/\r
-/* FONT.H */\r
-/* */\r
-/* Author: Thom Robertson */\r
-/* Description: Bitmapped font support interface */\r
-/* This implementation supports any TrueType fonts provided by Windows */\r
-/* */\r
-/* The contents of this file are subject to the Genesis3D Public License */\r
-/* Version 1.01 (the "License"); you may not use this file except in */\r
-/* compliance with the License. You may obtain a copy of the License at */\r
-/* http://www.genesis3d.com */\r
-/* */\r
-/* Software distributed under the License is distributed on an "AS IS" */\r
-/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */\r
-/* the License for the specific language governing rights and limitations */\r
-/* under the License. */\r
-/* */\r
-/* The Original Code is Genesis3D, released March 25, 1999. */\r
-/* Genesis3D Version 1.1 released November 15, 1999 */\r
-/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */\r
-/* */\r
-/****************************************************************************************/\r
-#ifndef GE_FONT_H\r
-#define GE_FONT_H\r
-\r
-// includes\r
-#include "genesis.h"\r
-#include "basetype.h"\r
-#include "bitmap.h"\r
-// **************************\r
-// to use this API:\r
-\r
-// 2. geFont_CreateFont().\r
-\r
-// 3. (Optionally) geFont_AddCharacters().\r
-// 3A. Otherwise, IF you intend to use geFont_DrawText(), call geFont_AddBitmapBuffer().\r
-\r
-// 4. Between geEngine_BeginFrame() and geEngine_EndFrame(), and after geEngine_RenderWorld(),\r
-// geFont_DrawText(). You may call geFont_DrawTextToBitmap() anytime, though.\r
-\r
-// 5. When finished, geFont_Destroy().\r
-\r
-\r
-\r
-//*************************************************************************************** \r
-// these are bit flags for _DrawText(). Currently only _WORDWRAP is implemented, and without\r
-// it, the function will still wrap, just not on word boundaries.\r
-// Note that these will fail for non ascii fonts.\r
-#define GE_FONT_WRAP 0x00000001 // wrap to fit inside the drawing rect\r
-#define GE_FONT_WORDWRAP 0x00000002 // wrap on word boundaries\r
-#define GE_FONT_JUST_RETURN_FIT 0x00000004 // returns number of characters that fit in drawing rectangle, WITHOUT drawing anything.\r
-#define GE_FONT_JUSTIFY_RIGHT 0x00000008\r
-#define GE_FONT_JUSTIFY_CENTER 0x00000010\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-// opaque structure headers.\r
-typedef struct geFont geFont; // an instance of a font\r
-\r
-\r
-//*************************************************************************************** \r
-GENESISAPI geFont *GENESISCC geFont_Create(const geEngine *Engine, const char *fontNameString, \r
- const int fontSize,\r
- const int fontWeight , const geBoolean antialiased) ;\r
- // Creates a font, and returns a pointer to it.\r
- // Pass in the string name of the TrueType font (case sensitive), and the height in pixels.\r
- \r
- // ARGUMENTS:\r
- // fontNameString - char pointer to a string containing the case sensitive name of the font.\r
- // fontSize - the pixel height of the requested font.\r
-\r
- // RETURNS:\r
- // success: pointer to the newly created font.\r
- // failure: NULL.\r
-\r
- // NOTE: the new font set has NO actual characters in it at first. You must add characters\r
- // to it with the _AddCharacters() function before you can use the font.\r
- // NOTE: all fonts start out with a grayscale palette, with the range 0 to 128.\r
-\r
-//*************************************************************************************** \r
-GENESISAPI void GENESISCC geFont_CreateRef(geFont *font);\r
-\r
-\r
-//*************************************************************************************** \r
-GENESISAPI void GENESISCC geFont_Destroy(geFont **font);\r
- // destroys a font.\r
-\r
- // ARGUMENTS:\r
- // font - pointer to the font to be destroyed.\r
-\r
- // RETURNS:\r
- // nothing.\r
-\r
-//*************************************************************************************** \r
-GENESISAPI geBoolean GENESISCC geFont_AddCharacters(geFont *font, \r
- unsigned char leastIndex, \r
- unsigned char mostIndex\r
- );\r
- // Adds a set of characters to the font defined by the ascii range passed in \r
- // (leastIndex and mostIndex, inclusive).\r
-\r
- // ARGUMENTS:\r
- // font - pointer to the font to add characters to.\r
- // e - pointer to a valid geEngine.\r
- // leastIndex and mostIndex - the ASCII range of characters to add.\r
- // cellBuffer - an allocated hunk of ram to temproarily store the character image\r
- // bufferSize - length of the above buffer\r
-\r
- // RETURNS:\r
- // success: GE_TRUE.\r
- // failure: GE_FALSE.\r
-\r
- // NOTES:\r
- // This is the function that actually uses the\r
- // Win32 GetGlyphOutline() function to draw the character onto a geBitmap, which can be\r
- // blitted to the screen.\r
-\r
-\r
-//*******************************************************************************\r
-GENESISAPI void GENESISCC geFont_DestroyBitmapBuffer( geFont *font );\r
- // destroys any valid "scratch-pad" buffer attached to the geFont.\r
- // ARGUMENTS:\r
- // font - pointer to the geFont.\r
- //\r
- // NOTES:\r
- // you'll rarely need to call this function; it's called by geFont_Destroy() anyway.\r
- // Calling this function with a geFont that has no initialized buffer doesn't\r
- // hurt anything.\r
-\r
-//*******************************************************************************\r
-GENESISAPI geBoolean GENESISCC geFont_AddBitmapBuffer(\r
- geFont *font, const uint32 width, const uint32 height);\r
- // Adds a geBitmap to the geFont, to be used as a temporary "scratch-pad". This is\r
- // required for using geFont_DrawText() when no characters have been added.\r
-\r
- // ARGUMENTS:\r
- // font - pointer to the geFont to add a buffer to.\r
- // width and height - the size of the buffer to create. Make sure this size is >=\r
- // the biggest rectagle of text you'll want to write to the screen using this geFont\r
- // and DrawText().\r
-\r
- // RETURNS:\r
- // success: GE_TRUE.\r
- // failure: GE_FALSE.\r
-\r
- // NOTES:\r
- // You don't need to call this function IF you _AddCharacters() to this geFont.\r
- // You call this function for each geFont you need to use. geFont's don't share buffers.\r
- // if you call this function on a geFont that already has a valid buffer, the buffer is\r
- // destroyed, and replaced by the new one.\r
-\r
-//*************************************************************************************** \r
-GENESISAPI geBoolean GENESISCC geFont_DrawText(geFont *font, const char *textString, \r
- const GE_Rect *Rect, const GE_RGBA *Color, \r
- uint32 flags, const GE_Rect *clipRect);\r
- // This is the function you put between geEngine_BeginFrame() and _EndFrame(), the function\r
- // that draws text to the screen.\r
-\r
- // ARGUMENTS:\r
- // font - pointer to the font to draw with. IF the font has NO characters in it\r
- // (added by geFont_AddCharacters() ) then a different, more windows-intensive way is\r
- // used to draw out the characters.\r
- // textString - pointer to the text string to output to the screen.\r
- // Rect - screen rectangle to place the text within.\r
- // Color - RGB color the text should be.\r
- // flags - a bitfield of GE_FONT_ values.\r
- // clipRect - pointer to a screen rectangle to clip the text to. MAY BE NULL, in which\r
- // case the text is only clipped by the boundaries of the screen.\r
-\r
- // RETURNS:\r
- // success: GE_TRUE.\r
- // failure: GE_FALSE.\r
-\r
- // NOTES:\r
- // Assuming you've added characters to the font, characters which have NOT been added\r
- // WILL cause an assert if you try to draw them. \r
- // Only GE_FONTSET_WORDWRAP is meaningfull right now. Using any other flags will cause\r
- // an assert.\r
- // As stated above, you can use an entirely different way of creating a string, by\r
- // making a font with no characters in it. This\r
- // jumps through Windows DIB hoops, and draws the text in a non-anti-aliased, but\r
- // (hopefully) more unicode-tolerant way (DrawText() ).\r
-\r
-\r
-//*************************************************************************************** \r
-GENESISAPI geBoolean GENESISCC geFont_DrawTextToBitmap(geFont *font, const char *textString, \r
- const GE_Rect *Rect, const GE_RGBA *Color, \r
- uint32 flags, const GE_Rect *clipRect,\r
- geBitmap *targetBitmap);\r
- // This is the function you put between geEngine_BeginFrame() and _EndFrame(), the function\r
- // that draws text to the screen.\r
-\r
- // ARGUMENTS:\r
- // font - pointer to the font to draw with. IF the font has NO characters in it\r
- // (added by geFont_AddCharacters() ) then a different, more windows-intensive way is\r
- // used to draw out the characters.\r
- // textString - pointer to the text string to output to the screen.\r
- // Rect - screen rectangle to place the text within.\r
- // Color - RGB color the text should be.\r
- // flags - a bitfield of GE_FONT_ values.\r
- // clipRect - pointer to a screen rectangle to clip the text to. MAY BE NULL, in which\r
- // case the text is only clipped by the boundaries of the screen.\r
- // targetBitmap - pointer to a target bitmap to draw the text into. MAY NOT BE NULL,\r
- // and MUST BE GE_PIXELFORMAT_8BIT.\r
-\r
- // RETURNS:\r
- // success: GE_TRUE.\r
- // failure: GE_FALSE.\r
-\r
- // NOTES:\r
- // Assuming you've added characters to the font, characters which have NOT been added\r
- // WILL cause an assert if you try to draw them. \r
- // Only GE_FONTSET_WORDWRAP is meaningfull right now. Using any other flags will cause\r
- // an assert.\r
- // As stated above, you can use an entirely different way of creating a string, by\r
- // making a font with no characters in it. This\r
- // jumps through Windows DIB hoops, and draws the text in a non-anti-aliased, but\r
- // (hopefully) more unicode-tolerant way (DrawText() ).\r
- // The Color argument is will be used to modify the existing palette of the targetBitmap\r
- // passed in. Therefore, you won't be able to _DrawTextToBitmap() a red piece of text,\r
- // then a green piece, then a blue piece. You'll end up with three lines of blue text.\r
-\r
-\r
-//*************************************************************************************** \r
-GENESISAPI int32 GENESISCC geFont_GetStringPixelWidth (geFont *font, const char *textString);\r
-GENESISAPI int32 GENESISCC geFont_GetStringPixelHeight(geFont *font, const char *textString);\r
- // These two functions return the pixel width and height of the string passed in.\r
-\r
- // ARGUMENTS:\r
- // font - pointer to the font to draw with.\r
- // textString - pointer to the text string to output to the screen.\r
-\r
- // RETURNS:\r
- // success: a positive value in pixels. IF the text passed in contains characters\r
- // which haven't been added to the font yet, BUT other characters HAVE\r
- // been added, the function asserts.\r
- // failure: -1.\r
- // NOTES:\r
- // these two functions assume no text wrapping!\r
-\r
-//*************************************************************************************** \r
-GENESISAPI geBitmap* GENESISCC geFont_GetBuffer(geFont *font);\r
- // This function returns a pointer to the drawing buffer contained by the font.\r
-\r
- // ARGUMENTS:\r
- // font - pointer to the font.\r
-\r
- // RETURNS:\r
- // a valid pointer to a geBitmap, OR NULL, signifying that the buffer wasn't initialized.\r
-\r
-\r
-//*************************************************************************************** \r
-GENESISAPI geBoolean GENESISCC geFont_GetCharMap(geFont *font, uint8 character, GE_Rect *Rect, \r
- geBitmap **targetBitmap, int32 *fullWidth, int32 *fullHeight, \r
- int32 *offsetX, int32 *offsetY);\r
-\r
-//*************************************************************************************** \r
-GENESISAPI void GENESISCC geFont_EnableAntialiasing(geFont *font, const geBoolean anti);\r
-//*************************************************************************************** \r
-GENESISAPI geBoolean GENESISCC geFont_IsAntialiased(geFont *font);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
-\r