wwfont.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /G/wwlib/wwfont.h $*
  25. * *
  26. * $Author:: Scott_b $*
  27. * *
  28. * $Modtime:: 4/21/00 1:03p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef WWFONT_H
  36. #define WWFONT_H
  37. #include "font.h"
  38. #include "surface.h"
  39. class ConvertClass;
  40. /*
  41. ** This is a concrete font class object that is used to handle font data as generated by
  42. ** the legacy FONTMAKE.EXE utility.
  43. */
  44. class WWFontClass : public FontClass
  45. {
  46. typedef FontClass BASECLASS;
  47. public:
  48. WWFontClass(void const * fontdata, bool isoutlined=false, int shadow=0, ConvertClass *convert = 0, unsigned char *remap = 0);
  49. virtual ~WWFontClass(void) {}
  50. void *Set_Font_Data(void const * fontdata);
  51. void *Get_Font_Data() {
  52. return((void *)FontData);
  53. }
  54. // User can setup a palette to use for this font.
  55. // If set, this will override all other colors (even fore and background colors).
  56. // User should reset to default when done.
  57. unsigned char *Set_Remap_Palette(unsigned char *palette) {
  58. unsigned char *old = RemapPalette;
  59. RemapPalette = palette;
  60. return(old);
  61. }
  62. unsigned char *Get_Remap_Palette() const {
  63. return(RemapPalette);
  64. }
  65. ConvertClass *Set_Converter(ConvertClass *convert) {
  66. ConvertClass *old = Converter;
  67. Converter = convert;
  68. return(old);
  69. }
  70. ConvertClass *Get_Converter() const {
  71. return(Converter);
  72. }
  73. virtual int Char_Pixel_Width(char c) const;
  74. virtual int String_Pixel_Width(char const * string) const;
  75. virtual int Get_Width(void) const;
  76. virtual int Get_Height(void) const;
  77. virtual Point2D Print(char const * string, Surface & surface, Rect const & cliprect, Point2D const & point, ConvertClass const & converter, unsigned char const * remap=NULL) const;
  78. virtual int Set_XSpacing(int x);
  79. virtual int Set_YSpacing(int y);
  80. private:
  81. /*
  82. ** Is the font an outline type font (with special outline
  83. ** pixels in the source art)?
  84. */
  85. bool IsOutlinedData;
  86. /*
  87. ** Shadow type to use when displaying this font. The value only applies if the
  88. ** font is equipped with outline data.
  89. */
  90. int Shadow;
  91. /*
  92. ** Override font X spacing value.
  93. */
  94. int FontXSpacing;
  95. /*
  96. ** Override font Y spacing value.
  97. */
  98. int FontYSpacing;
  99. /*
  100. ** Header structure of the font data file.
  101. */
  102. typedef struct FontType {
  103. unsigned short FontLength;
  104. unsigned char FontCompress;
  105. unsigned char FontDataBlocks;
  106. unsigned short InfoBlockOffset;
  107. unsigned short OffsetBlockOffset;
  108. unsigned short WidthBlockOffset;
  109. unsigned short DataBlockOffset;
  110. unsigned short HeightOffset;
  111. } FontType;
  112. FontType const * FontData;
  113. // Pointer to a font palette for the font.
  114. unsigned char *RemapPalette;
  115. // Pointer to a converter.
  116. ConvertClass *Converter;
  117. int Raw_Width(void) const;
  118. int Raw_Height(void) const;
  119. };
  120. #endif