2021-05-30 21:00:06 +00:00
|
|
|
/*
|
|
|
|
** razefont.cpp
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2021 Christoph Oelckers
|
|
|
|
** 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.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "razefont.h"
|
2021-05-30 22:52:40 +00:00
|
|
|
#include "gamecontrol.h"
|
|
|
|
#include "c_cvars.h"
|
2021-05-30 21:00:06 +00:00
|
|
|
#include "i_interface.h"
|
|
|
|
|
|
|
|
FGameTexture* GetBaseForChar(FGameTexture* t);
|
|
|
|
void FontCharCreated(FGameTexture* base, FGameTexture* glyph);
|
|
|
|
|
|
|
|
|
|
|
|
FFont* IndexFont;
|
|
|
|
FFont* DigiFont;
|
2021-05-30 22:52:40 +00:00
|
|
|
FFont* BigFont13, * BigFont15;
|
|
|
|
|
|
|
|
CUSTOM_CVAR(Int, duke_menufont, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
|
|
|
{
|
|
|
|
if (!(g_gameType & GAMEFLAG_DUKE) || !BigFont13 || !BigFont15) return;
|
|
|
|
if (self < -1 || self > 1) self = -1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Font info must be copied so that BigFont does not change its address.
|
|
|
|
if (self == 0 || (self == -1 && isPlutoPak())) BigFont->CopyFrom(*BigFont15);
|
|
|
|
else if (self == 1 || (self == -1 && !isPlutoPak())) BigFont->CopyFrom(*BigFont13);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-30 21:00:06 +00:00
|
|
|
|
|
|
|
static void SetupHires(FFont *font)
|
|
|
|
{
|
|
|
|
if (!font) return;
|
|
|
|
auto altfont = font->AltFont();
|
|
|
|
if (!altfont) return;
|
|
|
|
// Set up hightile links for the font.
|
|
|
|
for (int i = 33; i < 127; i++)
|
|
|
|
{
|
|
|
|
auto mycode = font->GetCharCode(i, true);
|
|
|
|
if (mycode != i) continue;
|
|
|
|
auto mychar = font->GetChar(i, CR_UNDEFINED, nullptr);
|
|
|
|
if (mychar == nullptr) continue;
|
|
|
|
|
|
|
|
auto altcode = altfont->GetCharCode(i, true);
|
|
|
|
if (altcode != i) continue;
|
|
|
|
auto altchar = altfont->GetChar(i, CR_UNDEFINED, nullptr);
|
|
|
|
if (altchar == nullptr) continue;
|
|
|
|
|
|
|
|
auto base = GetBaseForChar(altchar);
|
|
|
|
if (base == nullptr) continue;
|
|
|
|
FontCharCreated(base, mychar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitFont()
|
|
|
|
{
|
|
|
|
V_InitFonts();
|
|
|
|
BigFont = V_GetFont("BigFont");
|
|
|
|
SmallFont = V_GetFont("SmallFont");
|
|
|
|
SmallFont2 = V_GetFont("SmallFont2");
|
|
|
|
IndexFont = V_GetFont("IndexFont");
|
|
|
|
DigiFont = V_GetFont("DigiFont");
|
|
|
|
|
|
|
|
SetupHires(BigFont);
|
|
|
|
SetupHires(SmallFont);
|
|
|
|
|
2021-05-30 22:52:40 +00:00
|
|
|
if (g_gameType & GAMEFLAG_DUKE)
|
|
|
|
{
|
|
|
|
BigFont13 = V_GetFont("BigFont13");
|
|
|
|
BigFont15 = V_GetFont("BigFont15");
|
|
|
|
BigFont = new FFont(0, "BigFont");
|
|
|
|
}
|
|
|
|
|
2021-05-30 21:00:06 +00:00
|
|
|
// todo: Compare small and big fonts with the base font and decide which one to use.
|
|
|
|
}
|