/project/jni/sdl_ttf/include/SDL_ttf.h

https://github.com/aichunyu/FFPlayer · C Header · 249 lines · 103 code · 39 blank · 107 comment · 0 complexity · 9d6ef89b1decb7865cbc1780fc7d309b MD5 · raw file

  1. /*
  2. SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
  3. Copyright (C) 2001-2012 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /* This library is a wrapper around the excellent FreeType 2.0 library,
  19. available at:
  20. http://www.freetype.org/
  21. */
  22. #ifndef _SDL_TTF_H
  23. #define _SDL_TTF_H
  24. #include "SDL.h"
  25. #include "begin_code.h"
  26. /* Set up for C function definitions, even when using C++ */
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
  31. */
  32. #define SDL_TTF_MAJOR_VERSION 2
  33. #define SDL_TTF_MINOR_VERSION 0
  34. #define SDL_TTF_PATCHLEVEL 12
  35. /* This macro can be used to fill a version structure with the compile-time
  36. * version of the SDL_ttf library.
  37. */
  38. #define SDL_TTF_VERSION(X) \
  39. { \
  40. (X)->major = SDL_TTF_MAJOR_VERSION; \
  41. (X)->minor = SDL_TTF_MINOR_VERSION; \
  42. (X)->patch = SDL_TTF_PATCHLEVEL; \
  43. }
  44. /* Backwards compatibility */
  45. #define TTF_MAJOR_VERSION SDL_TTF_MAJOR_VERSION
  46. #define TTF_MINOR_VERSION SDL_TTF_MINOR_VERSION
  47. #define TTF_PATCHLEVEL SDL_TTF_PATCHLEVEL
  48. #define TTF_VERSION(X) SDL_TTF_VERSION(X)
  49. /* This function gets the version of the dynamically linked SDL_ttf library.
  50. it should NOT be used to fill a version structure, instead you should
  51. use the SDL_TTF_VERSION() macro.
  52. */
  53. extern DECLSPEC const SDL_version * SDLCALL TTF_Linked_Version(void);
  54. /* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */
  55. #define UNICODE_BOM_NATIVE 0xFEFF
  56. #define UNICODE_BOM_SWAPPED 0xFFFE
  57. /* This function tells the library whether UNICODE text is generally
  58. byteswapped. A UNICODE BOM character in a string will override
  59. this setting for the remainder of that string.
  60. */
  61. extern DECLSPEC void SDLCALL TTF_ByteSwappedUNICODE(int swapped);
  62. /* The internal structure containing font information */
  63. typedef struct _TTF_Font TTF_Font;
  64. /* Initialize the TTF engine - returns 0 if successful, -1 on error */
  65. extern DECLSPEC int SDLCALL TTF_Init(void);
  66. /* Open a font file and create a font of the specified point size.
  67. * Some .fon fonts will have several sizes embedded in the file, so the
  68. * point size becomes the index of choosing which size. If the value
  69. * is too high, the last indexed size will be the default. */
  70. extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFont(const char *file, int ptsize);
  71. extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndex(const char *file, int ptsize, long index);
  72. extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize);
  73. extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index);
  74. /* Set and retrieve the font style */
  75. #define TTF_STYLE_NORMAL 0x00
  76. #define TTF_STYLE_BOLD 0x01
  77. #define TTF_STYLE_ITALIC 0x02
  78. #define TTF_STYLE_UNDERLINE 0x04
  79. #define TTF_STYLE_STRIKETHROUGH 0x08
  80. extern DECLSPEC int SDLCALL TTF_GetFontStyle(const TTF_Font *font);
  81. extern DECLSPEC void SDLCALL TTF_SetFontStyle(TTF_Font *font, int style);
  82. extern DECLSPEC int SDLCALL TTF_GetFontOutline(const TTF_Font *font);
  83. extern DECLSPEC void SDLCALL TTF_SetFontOutline(TTF_Font *font, int outline);
  84. /* Set and retrieve FreeType hinter settings */
  85. #define TTF_HINTING_NORMAL 0
  86. #define TTF_HINTING_LIGHT 1
  87. #define TTF_HINTING_MONO 2
  88. #define TTF_HINTING_NONE 3
  89. extern DECLSPEC int SDLCALL TTF_GetFontHinting(const TTF_Font *font);
  90. extern DECLSPEC void SDLCALL TTF_SetFontHinting(TTF_Font *font, int hinting);
  91. /* Get the total height of the font - usually equal to point size */
  92. extern DECLSPEC int SDLCALL TTF_FontHeight(const TTF_Font *font);
  93. /* Get the offset from the baseline to the top of the font
  94. This is a positive value, relative to the baseline.
  95. */
  96. extern DECLSPEC int SDLCALL TTF_FontAscent(const TTF_Font *font);
  97. /* Get the offset from the baseline to the bottom of the font
  98. This is a negative value, relative to the baseline.
  99. */
  100. extern DECLSPEC int SDLCALL TTF_FontDescent(const TTF_Font *font);
  101. /* Get the recommended spacing between lines of text for this font */
  102. extern DECLSPEC int SDLCALL TTF_FontLineSkip(const TTF_Font *font);
  103. /* Get/Set whether or not kerning is allowed for this font */
  104. extern DECLSPEC int SDLCALL TTF_GetFontKerning(const TTF_Font *font);
  105. extern DECLSPEC void SDLCALL TTF_SetFontKerning(TTF_Font *font, int allowed);
  106. /* Get the number of faces of the font */
  107. extern DECLSPEC long SDLCALL TTF_FontFaces(const TTF_Font *font);
  108. /* Get the font face attributes, if any */
  109. extern DECLSPEC int SDLCALL TTF_FontFaceIsFixedWidth(const TTF_Font *font);
  110. extern DECLSPEC char * SDLCALL TTF_FontFaceFamilyName(const TTF_Font *font);
  111. extern DECLSPEC char * SDLCALL TTF_FontFaceStyleName(const TTF_Font *font);
  112. /* Check wether a glyph is provided by the font or not */
  113. extern DECLSPEC int SDLCALL TTF_GlyphIsProvided(const TTF_Font *font, Uint16 ch);
  114. /* Get the metrics (dimensions) of a glyph
  115. To understand what these metrics mean, here is a useful link:
  116. http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
  117. */
  118. extern DECLSPEC int SDLCALL TTF_GlyphMetrics(TTF_Font *font, Uint16 ch,
  119. int *minx, int *maxx,
  120. int *miny, int *maxy, int *advance);
  121. /* Get the dimensions of a rendered string of text */
  122. extern DECLSPEC int SDLCALL TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h);
  123. extern DECLSPEC int SDLCALL TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h);
  124. extern DECLSPEC int SDLCALL TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h);
  125. /* Create an 8-bit palettized surface and render the given text at
  126. fast quality with the given font and color. The 0 pixel is the
  127. colorkey, giving a transparent background, and the 1 pixel is set
  128. to the text color.
  129. This function returns the new surface, or NULL if there was an error.
  130. */
  131. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font,
  132. const char *text, SDL_Color fg);
  133. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font,
  134. const char *text, SDL_Color fg);
  135. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font,
  136. const Uint16 *text, SDL_Color fg);
  137. /* Create an 8-bit palettized surface and render the given glyph at
  138. fast quality with the given font and color. The 0 pixel is the
  139. colorkey, giving a transparent background, and the 1 pixel is set
  140. to the text color. The glyph is rendered without any padding or
  141. centering in the X direction, and aligned normally in the Y direction.
  142. This function returns the new surface, or NULL if there was an error.
  143. */
  144. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Solid(TTF_Font *font,
  145. Uint16 ch, SDL_Color fg);
  146. /* Create an 8-bit palettized surface and render the given text at
  147. high quality with the given font and colors. The 0 pixel is background,
  148. while other pixels have varying degrees of the foreground color.
  149. This function returns the new surface, or NULL if there was an error.
  150. */
  151. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font,
  152. const char *text, SDL_Color fg, SDL_Color bg);
  153. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded(TTF_Font *font,
  154. const char *text, SDL_Color fg, SDL_Color bg);
  155. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded(TTF_Font *font,
  156. const Uint16 *text, SDL_Color fg, SDL_Color bg);
  157. /* Create an 8-bit palettized surface and render the given glyph at
  158. high quality with the given font and colors. The 0 pixel is background,
  159. while other pixels have varying degrees of the foreground color.
  160. The glyph is rendered without any padding or centering in the X
  161. direction, and aligned normally in the Y direction.
  162. This function returns the new surface, or NULL if there was an error.
  163. */
  164. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Shaded(TTF_Font *font,
  165. Uint16 ch, SDL_Color fg, SDL_Color bg);
  166. /* Create a 32-bit ARGB surface and render the given text at high quality,
  167. using alpha blending to dither the font with the given color.
  168. This function returns the new surface, or NULL if there was an error.
  169. */
  170. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font,
  171. const char *text, SDL_Color fg);
  172. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended(TTF_Font *font,
  173. const char *text, SDL_Color fg);
  174. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended(TTF_Font *font,
  175. const Uint16 *text, SDL_Color fg);
  176. /* Create a 32-bit ARGB surface and render the given glyph at high quality,
  177. using alpha blending to dither the font with the given color.
  178. The glyph is rendered without any padding or centering in the X
  179. direction, and aligned normally in the Y direction.
  180. This function returns the new surface, or NULL if there was an error.
  181. */
  182. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Blended(TTF_Font *font,
  183. Uint16 ch, SDL_Color fg);
  184. /* For compatibility with previous versions, here are the old functions */
  185. #define TTF_RenderText(font, text, fg, bg) \
  186. TTF_RenderText_Shaded(font, text, fg, bg)
  187. #define TTF_RenderUTF8(font, text, fg, bg) \
  188. TTF_RenderUTF8_Shaded(font, text, fg, bg)
  189. #define TTF_RenderUNICODE(font, text, fg, bg) \
  190. TTF_RenderUNICODE_Shaded(font, text, fg, bg)
  191. /* Close an opened font file */
  192. extern DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font);
  193. /* De-initialize the TTF engine */
  194. extern DECLSPEC void SDLCALL TTF_Quit(void);
  195. /* Check if the TTF engine is initialized */
  196. extern DECLSPEC int SDLCALL TTF_WasInit(void);
  197. /* Get the kerning size of two glyphs */
  198. extern DECLSPEC int TTF_GetFontKerningSize(TTF_Font *font, int prev_index, int index);
  199. /* We'll use SDL for reporting errors */
  200. #define TTF_SetError SDL_SetError
  201. #define TTF_GetError SDL_GetError
  202. /* Ends C function definitions when using C++ */
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #include "close_code.h"
  207. #endif /* _SDL_TTF_H */