mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-17 09:41:21 +00:00
df17a60f5d
- Fixed: FDoomEdMap needed a destructor. - Fixed: Decal animators were never freed. - Fixed: Colormaps were never freed. - Fixed: Memory allocated in R_InitTranslationTables() was never freed. - Fixed: R_InitParticles() allocated way more memory than it needed to. (And the particle memory was never freed, either.) - Fixed: FMetaTable::FreeMeta() should use delete[] to free string metadata. - Fixed: FConfigFile::ClearCurrentSection() must cast the entry to a char * before deleting it, because that's the way it was allocated. - Fixed definitions of DeadZombieMan and DeadShotgunGuy in doom/deadthings.txt. Skip_super resets the dropitem list, so having it after "DropItem None" is pointless. - Fixed: Decorate DropItem information was never freed. - Fixed: FinishStates() allocated even 0-entry state arrays. - Fixed: Default actor instances were never freed. - Fixed: FRandomSoundList never freed its sound list. - Fixed: Level and cluster strings read from MAPINFO were never freed. - Fixed: Episode names were never freed. - Fixed: InverseColormap and GoldColormap were never freed. Since they're always allocated, they can just be arrays rather than pointers. - Fixed: FFont destructor never freed any of the character data or the font's name. - Fixed: Fonts were not freed at exit. - Fixed: FStringTable::LoadLanguage() did not call SC_Close(). - Fixed: When using the -iwad parameter, IdentifyVersion() did not release the buffer it created to hold the parameter's path. SVN r88 (trunk)
146 lines
4.2 KiB
C++
146 lines
4.2 KiB
C++
/*
|
|
** v_font.h
|
|
**
|
|
**---------------------------------------------------------------------------
|
|
** Copyright 1998-2005 Randy Heit
|
|
** All rights reserved.
|
|
**
|
|
** Redistribution and use in source and binary forms, with or without
|
|
** modification, are permitted provided that the following conditions
|
|
** are met:
|
|
**
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
** notice, this list of conditions and the following disclaimer.
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
** documentation and/or other materials provided with the distribution.
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
** derived from this software without specific prior written permission.
|
|
**
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
**---------------------------------------------------------------------------
|
|
**
|
|
*/
|
|
|
|
#ifndef __V_FONT_H__
|
|
#define __V_FONT_H__
|
|
|
|
#include "doomtype.h"
|
|
#include "farchive.h"
|
|
|
|
class DCanvas;
|
|
class FTexture;
|
|
|
|
enum EColorRange
|
|
{
|
|
CR_BRICK,
|
|
CR_TAN,
|
|
CR_GRAY,
|
|
CR_GREY = CR_GRAY,
|
|
CR_GREEN,
|
|
CR_BROWN,
|
|
CR_GOLD,
|
|
CR_RED,
|
|
CR_BLUE,
|
|
CR_ORANGE,
|
|
CR_WHITE,
|
|
CR_YELLOW,
|
|
CR_UNTRANSLATED,
|
|
NUM_TEXT_COLORS
|
|
};
|
|
|
|
inline FArchive &operator<< (FArchive &arc, EColorRange &i)
|
|
{
|
|
BYTE val = (BYTE)i;
|
|
arc << val;
|
|
i = (EColorRange)val;
|
|
return arc;
|
|
}
|
|
|
|
class FFont
|
|
{
|
|
public:
|
|
FFont (const char *fontname, const char *nametemplate, int first, int count, int base);
|
|
~FFont ();
|
|
|
|
FTexture *GetChar (int code, int *const width) const;
|
|
int GetCharWidth (int code) const;
|
|
byte *GetColorTranslation (EColorRange range) const;
|
|
int GetSpaceWidth () const { return SpaceWidth; }
|
|
int GetHeight () const { return FontHeight; }
|
|
int GetDefaultKerning () const { return GlobalKerning; }
|
|
|
|
static FFont *FindFont (const char *fontname);
|
|
|
|
// Return width of string in pixels (unscaled)
|
|
int StringWidth (const byte *str) const;
|
|
inline int StringWidth (const char *str) const { return StringWidth ((const byte *)str); }
|
|
|
|
protected:
|
|
FFont ();
|
|
|
|
void BuildTranslations (const double *luminosity, const BYTE *identity);
|
|
|
|
static int SimpleTranslation (byte *colorsused, byte *translation, byte *identity, double **luminosity);
|
|
|
|
int FirstChar, LastChar;
|
|
int SpaceWidth;
|
|
int FontHeight;
|
|
int GlobalKerning;
|
|
struct CharData
|
|
{
|
|
FTexture *Pic;
|
|
} *Chars;
|
|
int ActiveColors;
|
|
BYTE *Ranges;
|
|
BYTE *PatchRemap;
|
|
|
|
char *Name;
|
|
FFont *Next;
|
|
|
|
static FFont *FirstFont;
|
|
friend struct FontsDeleter;
|
|
|
|
#if defined(_MSC_VER) && _MSC_VER < 1310
|
|
template<> friend FArchive &operator<< (FArchive &arc, FFont* &font);
|
|
#else
|
|
friend FArchive &SerializeFFontPtr (FArchive &arc, FFont* &font);
|
|
#endif
|
|
};
|
|
|
|
#if !defined(_MSC_VER) || _MSC_VER >= 1310
|
|
template<> inline FArchive &operator<< <FFont> (FArchive &arc, FFont* &font)
|
|
{
|
|
return SerializeFFontPtr (arc, font);
|
|
}
|
|
#endif
|
|
|
|
class FSingleLumpFont : public FFont
|
|
{
|
|
public:
|
|
FSingleLumpFont (const char *fontname, int lump);
|
|
|
|
protected:
|
|
void BuildTranslations2 ();
|
|
void FixupPalette (BYTE *identity, double *luminosity, const BYTE *palette, bool rescale);
|
|
void LoadFON1 (int lump, const BYTE *data);
|
|
void LoadFON2 (int lump, const BYTE *data);
|
|
void CreateFontFromPic (int picnum);
|
|
};
|
|
|
|
void RecordTextureColors (FTexture *pic, byte *colorsused);
|
|
|
|
extern FFont *SmallFont, *SmallFont2, *BigFont, *ConFont;
|
|
|
|
void V_InitCustomFonts ();
|
|
|
|
#endif //__V_FONT_H__
|