Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Baked Bitmap fonts
  4. //
  5. //===========================================================================
  6. #ifndef _BITMAPFONT_H_
  7. #define _BITMAPFONT_H_
  8. #include "vguifont.h"
  9. #include "BitmapFontFile.h"
  10. class ITexture;
  11. //-----------------------------------------------------------------------------
  12. // Purpose: encapsulates a windows font
  13. //-----------------------------------------------------------------------------
  14. class CBitmapFont : public font_t
  15. {
  16. public:
  17. CBitmapFont();
  18. virtual ~CBitmapFont();
  19. // creates the font. returns false if the compiled font does not exist.
  20. virtual bool Create(const char *windowsFontName, float scalex, float scaley, int flags);
  21. // returns true if the font is equivalent to that specified
  22. virtual bool IsEqualTo(const char *windowsFontName, float scalex, float scaley, int flags);
  23. // gets the abc widths for a character
  24. virtual void GetCharABCWidths(int ch, int &a, int &b, int &c);
  25. // writes the char into the specified 32bpp texture. We're overloading this because
  26. // we derive off font_t, and the implementation there doesn't work for bitmap fonts.
  27. virtual void GetCharRGBA( wchar_t ch, int rgbaWide, int rgbaTall, unsigned char *prgba );
  28. // gets the width of ch given its position around before and after chars
  29. virtual void GetKernedCharWidth( wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC );
  30. // gets the texture coords in the compiled texture page
  31. void GetCharCoords( int ch, float *left, float *top, float *right, float *bottom );
  32. // sets the scale of the font.
  33. void SetScale( float sx, float sy );
  34. // gets the compiled texture page
  35. ITexture *GetTexturePage();
  36. private:
  37. int m_bitmapFontHandle;
  38. float m_scalex;
  39. float m_scaley;
  40. };
  41. #endif // _BITMAPFONT_H