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.

104 lines
3.1 KiB

  1. //-----------------------------------------------------------------------------
  2. // Name: Glyphs.cpp
  3. //
  4. // Desc: Functions and global variables for keeping track of font glyphs
  5. //
  6. // Hist: 09.06.02 - Revised Fontmaker sample
  7. //
  8. // Copyright (c) Microsoft Corporation. All rights reserved.
  9. //-----------------------------------------------------------------------------
  10. #ifndef GLYPHS_H
  11. #define GLYPHS_H
  12. //-----------------------------------------------------------------------------
  13. // Name: struct GLYPH_ATTR
  14. // Desc: A structure to hold attributes for one glpyh. The left, right, etc.
  15. // values are texture coordinate offsets into the resulting texture image
  16. // (which ends up in the .tga file). The offset, width, etc. values are
  17. // spacing information, used when rendering the font.
  18. //-----------------------------------------------------------------------------
  19. struct FILE_GLYPH_ATTR
  20. {
  21. FLOAT fLeft, fTop, fRight, fBottom;
  22. };
  23. struct GLYPH_ATTR : public FILE_GLYPH_ATTR
  24. {
  25. int a, b, c;
  26. int x, y, w, h;
  27. };
  28. //-----------------------------------------------------------------------------
  29. // Name: class CTextureFont
  30. // Desc: A class to hold all information about a texture-based font
  31. //-----------------------------------------------------------------------------
  32. class CTextureFont
  33. {
  34. public:
  35. // current ttf font
  36. LOGFONT m_LogFont;
  37. HFONT m_hFont;
  38. BOOL m_bAntialiasEffect;
  39. BOOL m_bShadowEffect;
  40. BOOL m_bOutlineEffect;
  41. int m_nBlur;
  42. int m_nScanlines;
  43. // Glyph info
  44. BYTE* m_ValidGlyphs;
  45. WCHAR m_cMaxGlyph;
  46. WORD* m_TranslatorTable;
  47. BOOL m_bIncludeNullCharacter;
  48. DWORD m_dwNumGlyphs;
  49. GLYPH_ATTR* m_pGlyphs;
  50. // Texture info
  51. DWORD m_dwTextureWidth;
  52. DWORD m_dwTextureHeight;
  53. DWORD* m_pBits;
  54. CHAR m_strFontName[MAX_PATH];
  55. // current custom font
  56. const char *m_pCustomFilename;
  57. unsigned char m_customGlyphs[256];
  58. char *m_pCustomGlyphFiles[256];
  59. int m_maxCustomCharHeight;
  60. public:
  61. HRESULT DeleteGlyph( WORD wGlyph );
  62. HRESULT InsertGlyph( WORD wGlyph );
  63. HRESULT ExtractValidGlyphsFromRange( WORD wStartGlyph, WORD wEndGlyph );
  64. HRESULT ExtractValidGlyphsFromFile( const CHAR* strFileName );
  65. HRESULT BuildTranslatorTable();
  66. HRESULT CalculateAndRenderGlyphs();
  67. HRESULT ReadCustomFontFile( CHAR* strFileName );
  68. HRESULT ReadFontInfoFile( CHAR* strFileName );
  69. HRESULT WriteFontInfoFile( CHAR* strFileName );
  70. HRESULT WriteFontImageFile( CHAR* strFileName, bool bAdditiveMode, bool bCustomFont );
  71. VOID ClearFont();
  72. VOID DestroyObjects();
  73. CTextureFont();
  74. ~CTextureFont();
  75. private:
  76. GLYPH_ATTR* RenderCustomGlyphs( HBITMAP hBitmap );
  77. GLYPH_ATTR* RenderTTFGlyphs( HFONT hFont, HBITMAP hBitmap,
  78. DWORD dwTextureWidth, DWORD dwTextureHeight,
  79. BOOL bOutlineEffect, BOOL bShadowEffect,
  80. int nScanlineEffect, int nBlurEffect,
  81. BOOL bAntialias,
  82. BYTE* ValidGlyphs, DWORD dwNumGlyphs );
  83. };
  84. #endif // GLYPHS_H