Counter Strike : Global Offensive Source Code
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.

90 lines
2.0 KiB

  1. // Copyright Electonic Arts(C) 2006 - All Rights Reserved
  2. #ifndef TLFONT_H
  3. #define TLFONT_H
  4. #include "../materialsystem/ifont.h"
  5. // Forward declerations
  6. class IFileSystem;
  7. class CTLFont;
  8. namespace TLFont
  9. {
  10. class FusionRasterizer;
  11. }
  12. namespace TLFontAux
  13. {
  14. class FontAuxTexture;
  15. }
  16. // Cache TTF font file
  17. #define MAX_FONTDATACACHE 20
  18. struct sFontDataCache
  19. {
  20. char m_dataName[256];
  21. unsigned char * m_dataMem;
  22. unsigned int m_dataSize;
  23. int m_refCount;
  24. };
  25. // Font manager
  26. class CTLFontManager
  27. {
  28. public:
  29. CTLFontManager(IFileSystem *pFileSystem);
  30. ~CTLFontManager();
  31. CTLFont* CreateFont(const char *pName, const char *pFontPath, int tall, int weight);
  32. void DestroyFont(CTLFont *pFont);
  33. private:
  34. unsigned char* LoadFontFile(const char *pFontPath, unsigned int *pDataSize);
  35. IFileSystem *m_pFileSystem;
  36. sFontDataCache m_fontDataCache[MAX_FONTDATACACHE];
  37. };
  38. // Font instance
  39. class CTLFont : public IFont
  40. {
  41. public:
  42. CTLFont(const char *pName, unsigned char *pData, unsigned int dataSize, int tall, int weight);
  43. ~CTLFont();
  44. virtual void RenderToBuffer(int ch, int offsetx, int width, int height, unsigned char *pBuffer);
  45. virtual bool GetCharABCWidth(int ch, int &a, int &b, int &c);
  46. virtual int GetMaxHeight();
  47. virtual int GetMaxWidth();
  48. virtual int GetAscent();
  49. virtual void* GetData(size_t * pSizeOut=NULL);
  50. virtual const char * GetName();
  51. private:
  52. // Convert a logical size to a point size
  53. static float LSToPoint(float ls);
  54. static const int MAX_NAME = 128;
  55. char m_name[MAX_NAME];
  56. int m_tall;
  57. int m_weight;
  58. float m_pointSize;
  59. // TLFont variables
  60. TLFont::FusionRasterizer *m_pRasterizer;
  61. // The TTF file
  62. unsigned char *m_pData;
  63. unsigned int m_dataSize;
  64. // Required for our Marlett hack
  65. wchar_t m_charOffset;
  66. };
  67. #endif