/src/SDLx/SFont.h

http://github.com/PerlGameDev/SDL · C Header · 79 lines · 27 code · 9 blank · 43 comment · 0 complexity · 261b0c96b8ab50802077d2591285160a MD5 · raw file

  1. /* */
  2. /* SFont.h */
  3. /* */
  4. /* Original SFont code Copyright (C) Karl Bartel */
  5. /* Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org> */
  6. /* */
  7. /* ------------------------------------------------------------------------------ */
  8. /* */
  9. /* This library is free software; you can redistribute it and/or */
  10. /* modify it under the terms of the GNU Lesser General Public */
  11. /* License as published by the Free Software Foundation; either */
  12. /* version 2.1 of the License, or (at your option) any later version. */
  13. /* */
  14. /* This library is distributed in the hope that it will be useful, */
  15. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  16. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
  17. /* Lesser General Public License for more details. */
  18. /* */
  19. /* You should have received a copy of the GNU Lesser General Public */
  20. /* License along with this library; if not, write to the Free Software */
  21. /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
  22. /* */
  23. /* ------------------------------------------------------------------------------ */
  24. /* */
  25. /* Please feel free to send questions, suggestions or improvements to: */
  26. /* */
  27. /* David J. Goehrig */
  28. /* dgoehrig@cpan.org */
  29. /* */
  30. #include <SDL.h>
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Delcare one variable of this type for each font you are using. */
  35. /* To load the fonts, load the font image into YourFont->Surface */
  36. /* and call InitFont( YourFont ); */
  37. typedef struct {
  38. SDL_Surface *Surface;
  39. int CharPos[512];
  40. int h;
  41. } SFont_FontInfo;
  42. /* Initializes the font */
  43. /* Font: this contains the suface with the font. */
  44. /* The font must be loaded before using this function. */
  45. void InitFont (SDL_Surface *Font);
  46. void InitFont2(SFont_FontInfo *Font);
  47. /* Blits a string to a surface */
  48. /* Destination: the suface you want to blit to */
  49. /* text: a string containing the text you want to blit. */
  50. void PutString (SDL_Surface *Surface, int x, int y, char *text);
  51. void PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y, char *text);
  52. /* Returns the width of "text" in pixels */
  53. #ifdef MACOSX
  54. int SFont_TextWidth(char *text);
  55. int SFont_TextWidth2(SFont_FontInfo *Font, char *text);
  56. #else
  57. int TextWidth(char *text);
  58. int TextWidth2(SFont_FontInfo *Font, char *text);
  59. #endif
  60. /* Blits a string to with centered x position */
  61. void XCenteredString (SDL_Surface *Surface, int y, char *text);
  62. void XCenteredString2(SDL_Surface *Surface, SFont_FontInfo *Font, int y, char *text);
  63. /* Allows the user to enter text */
  64. /* Width: What is the maximum width of the text (in pixels) */
  65. /* text: This string contains the text which was entered by the user */
  66. void SFont_Input ( SDL_Surface *Destination, int x, int y, int Width, char *text);
  67. void SFont_Input2( SDL_Surface *Destination, SFont_FontInfo *Font, int x, int y, int Width, char *text);
  68. #ifdef __cplusplus
  69. }
  70. #endif