ttf.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Wengier: STYLED TEXT support
  2. #ifndef _TTF_H
  3. #define _TTF_H
  4. #include "video.h"
  5. // The internal structure containing font information
  6. typedef struct _TTF_Font TTF_Font;
  7. // Initialize the TTF engine
  8. extern void TTF_Init(void);
  9. extern TTF_Font* TTF_New_Memory_Face(const unsigned char* file_base, long file_size, int ptsize, char* fName);
  10. extern void TTF_SetCharSize(TTF_Font* font, int ptsize);
  11. #define TTF_STYLE_NORMAL 0x00
  12. #define TTF_STYLE_BOLD 0x01
  13. #define TTF_STYLE_ITALIC 0x02
  14. #define TTF_STYLE_UNDERLINE 0x04
  15. #define TTF_STYLE_STRIKETHROUGH 0x08
  16. #define TTF_STYLE_SUBSCRIPT 0x10
  17. #define TTF_STYLE_SUPERSCRIPT 0x20
  18. #define TTF_STYLE_SMALL 0x40
  19. #define TTF_STYLE_DOUBLEUNDERLINE 0x80
  20. // Get the total height of the font - usually equal to point size
  21. extern int TTF_FontHeight(const TTF_Font *font);
  22. // Check wether a glyph is provided by the font or not
  23. extern int TTF_GlyphIsProvided(const TTF_Font *font, Bit16u ch);
  24. extern int TTF_FontWidth(TTF_Font *font);
  25. typedef struct {
  26. struct {
  27. Bitu width, height;
  28. int minX, minY, maxX, maxY;
  29. } cache;
  30. RGB_Color pal[256];
  31. } Render_t;
  32. typedef struct {
  33. TTF_Font *font;
  34. TTF_Font *fontb;
  35. TTF_Font *fonti;
  36. TTF_Font *fontbi;
  37. bool vDos; // Is internal vDos font active
  38. int pointsize; // Pointsize of characters
  39. int charHeight; // Height of character cell
  40. int charWidth; // Width ,,
  41. int cursor; // Cursor position
  42. int lins; // Number of lines 24-60
  43. int cols; // Number of columns 80-160
  44. bool fullScrn; // In fake fullscreen
  45. int offX; // Horizontal offset to center content
  46. int offY; // vertical ,,
  47. } Render_ttf;
  48. extern Render_t render;
  49. extern Render_ttf ttf;
  50. extern Bit16u curAttrChar[]; // currently displayed textpage
  51. extern Bit16u *newAttrChar; // to be replaced by
  52. /* Create an 8-bit palettized surface and render the given text at
  53. high quality with the given font and colors. The 0 pixel is background,
  54. while other pixels have varying degrees of the foreground color.
  55. */
  56. extern vSurface* TTF_RenderASCII(TTF_Font* font, TTF_Font *fontb, TTF_Font *fonti, TTF_Font *fontbi, const char* text, int textlen, RGB_Color fg, RGB_Color bg, int style);
  57. // After changing the code page, the glyph cache has to be cleared!
  58. extern void TTF_Flush_Cache(TTF_Font* font);
  59. // Close an opened font file
  60. extern void TTF_CloseFont(TTF_Font *font);
  61. // De-initialize the TTF engine
  62. extern void TTF_Quit(void);
  63. #endif /* _TTF_H */