GameFont.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: GameFont.h ///////////////////////////////////////////////////////////////////////////////
  24. // Created: Colin Day, June 2001
  25. // Desc: Game representations for fonts
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __GAMEFONT_H_
  29. #define __GAMEFONT_H_
  30. #include "Common/SubsystemInterface.h"
  31. #include "Lib/BaseType.h"
  32. #include "Common/AsciiString.h"
  33. #include "Common/GameMemory.h"
  34. //-------------------------------------------------------------------------------------------------
  35. /** A font for use in the device independent game */
  36. //-------------------------------------------------------------------------------------------------
  37. class GameFont : public MemoryPoolObject
  38. {
  39. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(GameFont, "GameFont")
  40. public:
  41. GameFont* next; ///< for library use
  42. AsciiString nameString;
  43. Int pointSize; ///< point size of font
  44. Int height; ///< pixel height of font
  45. void* fontData; ///< font data to be filled out for device specific font
  46. Bool bold; ///< is this font bold
  47. };
  48. EMPTY_DTOR(GameFont)
  49. //-------------------------------------------------------------------------------------------------
  50. /** Interface to access fonts for the system */
  51. //-------------------------------------------------------------------------------------------------
  52. class FontLibrary : public SubsystemInterface
  53. {
  54. public:
  55. public:
  56. FontLibrary( void );
  57. virtual ~FontLibrary( void );
  58. virtual void init( void );
  59. virtual void reset( void );
  60. virtual void update( void ) { }
  61. GameFont *getFont( AsciiString name, Int pointSize, Bool bold ); ///< get a font pointer
  62. GameFont *firstFont( void ); ///< return first font
  63. GameFont *nextFont( GameFont *font ); ///< get next font in library
  64. Int getCount( void ); ///< return how many fonts are loaded in this lib
  65. protected:
  66. void deleteAllFonts( void ); ///< delete all fonts in this library
  67. void linkFont( GameFont *font ); ///< add to font list
  68. void unlinkFont( GameFont *font ); ///< remove font from list
  69. /// load the font data pointer based on everything else we already have set
  70. virtual Bool loadFontData( GameFont *font ) = 0;
  71. /// release the font data pointer
  72. virtual void releaseFontData( GameFont *font ) { };
  73. GameFont *m_fontList; ///< list of fonts we have loaded
  74. Int m_count; ///< number of unique fonts loaded in this lib
  75. };
  76. // INLINING ///////////////////////////////////////////////////////////////////////////////////////
  77. inline Int FontLibrary::getCount( void ) { return m_count; }
  78. inline GameFont *FontLibrary::firstFont( void ) { return m_fontList; }
  79. inline GameFont *FontLibrary::nextFont( GameFont *font )
  80. {
  81. if( font )
  82. return font->next;
  83. return NULL;
  84. }
  85. // EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
  86. extern FontLibrary *TheFontLibrary; ///< font library external
  87. #endif // __GAMEFONT_H_