Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SDL_ttf.h

00001 /*
00002     SDL_ttf:  A companion library to SDL for working with TrueType (tm) fonts
00003     Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003  Sam Lantinga
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019     Sam Lantinga
00020     slouken@libsdl.org
00021 */
00022 
00023 /* $Id: SDL_ttf.h,v 1.3 2003/11/18 17:02:53 nct Exp $ */
00024 
00025 /* This library is a wrapper around the excellent FreeType 2.0 library,
00026    available at:
00027     http://www.freetype.org/
00028 */
00029 
00030 #ifndef _SDL_TTF_H
00031 #define _SDL_TTF_H
00032 
00033 #include <SDL.h>
00034 /* #include <begin_code.h> */
00035 
00036 /* Set up for C function definitions, even when using C++ */
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
00042 */
00043 #define SDL_TTF_MAJOR_VERSION   2
00044 #define SDL_TTF_MINOR_VERSION   0
00045 #define SDL_TTF_PATCHLEVEL  7
00046 
00047 /* This macro can be used to fill a version structure with the compile-time
00048  * version of the SDL_ttf library.
00049  */
00050 #define SDL_TTF_VERSION(X)                      \
00051 {                                   \
00052     (X)->major = SDL_TTF_MAJOR_VERSION;             \
00053     (X)->minor = SDL_TTF_MINOR_VERSION;             \
00054     (X)->patch = SDL_TTF_PATCHLEVEL;                \
00055 }
00056 
00057 /* Backwards compatibility */
00058 #define TTF_MAJOR_VERSION   SDL_TTF_MAJOR_VERSION
00059 #define TTF_MINOR_VERSION   SDL_TTF_MINOR_VERSION
00060 #define TTF_PATCHLEVEL      SDL_TTF_PATCHLEVEL
00061 #define TTF_VERSION(X)      SDL_TTF_VERSION(X)
00062 
00063 /* This function gets the version of the dynamically linked SDL_ttf library.
00064    it should NOT be used to fill a version structure, instead you should
00065    use the SDL_TTF_VERSION() macro.
00066  */
00067 extern DECLSPEC const SDL_version * SDLCALL TTF_Linked_Version(void);
00068 
00069 /* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */
00070 #define UNICODE_BOM_NATIVE  0xFEFF
00071 #define UNICODE_BOM_SWAPPED 0xFFFE
00072 
00073 /* This function tells the library whether UNICODE text is generally
00074    byteswapped.  A UNICODE BOM character in a string will override
00075    this setting for the remainder of that string.
00076 */
00077 extern DECLSPEC void SDLCALL TTF_ByteSwappedUNICODE(int swapped);
00078 
00079 /* The internal structure containing font information */
00080 typedef struct _TTF_Font TTF_Font;
00081 
00082 /* Initialize the TTF engine - returns 0 if successful, -1 on error */
00083 extern DECLSPEC int SDLCALL TTF_Init(void);
00084 
00085 /* Open a font file and create a font of the specified point size.
00086  * Some .fon fonts will have several sizes embedded in the file, so the
00087  * point size becomes the index of choosing which size.  If the value
00088  * is too high, the last indexed size will be the default. */
00089 extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFont(const char *file, int ptsize);
00090 extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndex(const char *file, int ptsize, long index);
00091 extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize);
00092 extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index);
00093 
00094 /* Set and retrieve the font style
00095    This font style is implemented by modifying the font glyphs, and
00096    doesn't reflect any inherent properties of the truetype font file.
00097 */
00098 #define TTF_STYLE_NORMAL    0x00
00099 #define TTF_STYLE_BOLD      0x01
00100 #define TTF_STYLE_ITALIC    0x02
00101 #define TTF_STYLE_UNDERLINE 0x04
00102 extern DECLSPEC int SDLCALL TTF_GetFontStyle(TTF_Font *font);
00103 extern DECLSPEC void SDLCALL TTF_SetFontStyle(TTF_Font *font, int style);
00104 
00105 /* Get the total height of the font - usually equal to point size */
00106 extern DECLSPEC int SDLCALL TTF_FontHeight(TTF_Font *font);
00107 
00108 /* Get the offset from the baseline to the top of the font
00109    This is a positive value, relative to the baseline.
00110  */
00111 extern DECLSPEC int SDLCALL TTF_FontAscent(TTF_Font *font);
00112 
00113 /* Get the offset from the baseline to the bottom of the font
00114    This is a negative value, relative to the baseline.
00115  */
00116 extern DECLSPEC int SDLCALL TTF_FontDescent(TTF_Font *font);
00117 
00118 /* Get the recommended spacing between lines of text for this font */
00119 extern DECLSPEC int SDLCALL TTF_FontLineSkip(TTF_Font *font);
00120 
00121 /* Get the number of faces of the font */
00122 extern DECLSPEC long SDLCALL TTF_FontFaces(TTF_Font *font);
00123 
00124 /* Get the font face attributes, if any */
00125 extern DECLSPEC int SDLCALL TTF_FontFaceIsFixedWidth(TTF_Font *font);
00126 extern DECLSPEC char * SDLCALL TTF_FontFaceFamilyName(TTF_Font *font);
00127 extern DECLSPEC char * SDLCALL TTF_FontFaceStyleName(TTF_Font *font);
00128 
00129 /* Get the metrics (dimensions) of a glyph
00130    To understand what these metrics mean, here is a useful link:
00131     http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
00132  */
00133 extern DECLSPEC int SDLCALL TTF_GlyphMetrics(TTF_Font *font, Uint16 ch,
00134                      int *minx, int *maxx,
00135                                      int *miny, int *maxy, int *advance);
00136 
00137 /* Get the dimensions of a rendered string of text */
00138 extern DECLSPEC int SDLCALL TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h);
00139 extern DECLSPEC int SDLCALL TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h);
00140 extern DECLSPEC int SDLCALL TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h);
00141 
00142 /* Create an 8-bit palettized surface and render the given text at
00143    fast quality with the given font and color.  The 0 pixel is the
00144    colorkey, giving a transparent background, and the 1 pixel is set
00145    to the text color.
00146    This function returns the new surface, or NULL if there was an error.
00147 */
00148 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font,
00149                 const char *text, SDL_Color fg);
00150 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font,
00151                 const char *text, SDL_Color fg);
00152 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font,
00153                 const Uint16 *text, SDL_Color fg);
00154 
00155 /* Create an 8-bit palettized surface and render the given glyph at
00156    fast quality with the given font and color.  The 0 pixel is the
00157    colorkey, giving a transparent background, and the 1 pixel is set
00158    to the text color.  The glyph is rendered without any padding or
00159    centering in the X direction, and aligned normally in the Y direction.
00160    This function returns the new surface, or NULL if there was an error.
00161 */
00162 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Solid(TTF_Font *font,
00163                     Uint16 ch, SDL_Color fg);
00164 
00165 /* Create an 8-bit palettized surface and render the given text at
00166    high quality with the given font and colors.  The 0 pixel is background,
00167    while other pixels have varying degrees of the foreground color.
00168    This function returns the new surface, or NULL if there was an error.
00169 */
00170 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font,
00171                 const char *text, SDL_Color fg, SDL_Color bg);
00172 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded(TTF_Font *font,
00173                 const char *text, SDL_Color fg, SDL_Color bg);
00174 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded(TTF_Font *font,
00175                 const Uint16 *text, SDL_Color fg, SDL_Color bg);
00176 
00177 /* Create an 8-bit palettized surface and render the given glyph at
00178    high quality with the given font and colors.  The 0 pixel is background,
00179    while other pixels have varying degrees of the foreground color.
00180    The glyph is rendered without any padding or centering in the X
00181    direction, and aligned normally in the Y direction.
00182    This function returns the new surface, or NULL if there was an error.
00183 */
00184 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Shaded(TTF_Font *font,
00185                 Uint16 ch, SDL_Color fg, SDL_Color bg);
00186 
00187 /* Create a 32-bit ARGB surface and render the given text at high quality,
00188    using alpha blending to dither the font with the given color.
00189    This function returns the new surface, or NULL if there was an error.
00190 */
00191 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font,
00192                 const char *text, SDL_Color fg);
00193 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended(TTF_Font *font,
00194                 const char *text, SDL_Color fg);
00195 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended(TTF_Font *font,
00196                 const Uint16 *text, SDL_Color fg);
00197 
00198 /* Create a 32-bit ARGB surface and render the given glyph at high quality,
00199    using alpha blending to dither the font with the given color.
00200    The glyph is rendered without any padding or centering in the X
00201    direction, and aligned normally in the Y direction.
00202    This function returns the new surface, or NULL if there was an error.
00203 */
00204 extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Blended(TTF_Font *font,
00205                         Uint16 ch, SDL_Color fg);
00206 
00207 /* For compatibility with previous versions, here are the old functions */
00208 #define TTF_RenderText(font, text, fg, bg)  \
00209     TTF_RenderText_Shaded(font, text, fg, bg)
00210 #define TTF_RenderUTF8(font, text, fg, bg)  \
00211     TTF_RenderUTF8_Shaded(font, text, fg, bg)
00212 #define TTF_RenderUNICODE(font, text, fg, bg)   \
00213     TTF_RenderUNICODE_Shaded(font, text, fg, bg)
00214 
00215 /* Close an opened font file */
00216 extern DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font);
00217 
00218 /* De-initialize the TTF engine */
00219 extern DECLSPEC void SDLCALL TTF_Quit(void);
00220 
00221 /* Check if the TTF engine is initialized */
00222 extern DECLSPEC int SDLCALL TTF_WasInit(void);
00223 
00224 /* We'll use SDL for reporting errors */
00225 #define TTF_SetError    SDL_SetError
00226 #define TTF_GetError    SDL_GetError
00227 
00228 /* Ends C function definitions when using C++ */
00229 #ifdef __cplusplus
00230 }
00231 #endif
00232 /*#include "close_code.h"*/
00233 
00234 #endif /* _SDL_TTF_H */

Generated on Mon Oct 24 17:38:25 2005 for Teem by  doxygen 1.4.2