mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
- use a higher resolution console font with better Unicode support.
This commit is contained in:
parent
f1d931517d
commit
0884057ae1
12 changed files with 57352 additions and 109 deletions
|
@ -1125,6 +1125,7 @@ set (PCH_SOURCES
|
||||||
gamedata/fonts/singlepicfont.cpp
|
gamedata/fonts/singlepicfont.cpp
|
||||||
gamedata/fonts/specialfont.cpp
|
gamedata/fonts/specialfont.cpp
|
||||||
gamedata/fonts/font.cpp
|
gamedata/fonts/font.cpp
|
||||||
|
gamedata/fonts/hexfont.cpp
|
||||||
gamedata/fonts/v_font.cpp
|
gamedata/fonts/v_font.cpp
|
||||||
gamedata/fonts/v_text.cpp
|
gamedata/fonts/v_text.cpp
|
||||||
gamedata/p_xlat.cpp
|
gamedata/p_xlat.cpp
|
||||||
|
|
|
@ -1199,12 +1199,16 @@ static void PrintSecretString(const char *string, bool thislevel)
|
||||||
else colstr = TEXTCOLOR_GREEN;
|
else colstr = TEXTCOLOR_GREEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto brok = V_BreakLines(ConFont, screen->GetWidth()*95/100, string);
|
#if 0
|
||||||
|
auto brok = V_BreakLines(CurrentConsoleFont, screen->GetWidth()*95/100, string);
|
||||||
|
|
||||||
for (auto &line : brok)
|
for (auto &line : brok)
|
||||||
{
|
{
|
||||||
Printf("%s%s\n", colstr, line.Text.GetChars());
|
Printf("%s%s\n", colstr, line.Text.GetChars());
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
Printf("%s%s\n", string);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,11 +126,6 @@ static GameAtExit *ExitCmdList;
|
||||||
|
|
||||||
EXTERN_CVAR (Bool, show_messages)
|
EXTERN_CVAR (Bool, show_messages)
|
||||||
|
|
||||||
static unsigned int TickerAt, TickerMax;
|
|
||||||
static bool TickerPercent;
|
|
||||||
static const char *TickerLabel;
|
|
||||||
|
|
||||||
static bool TickerVisible;
|
|
||||||
static bool ConsoleDrawing;
|
static bool ConsoleDrawing;
|
||||||
|
|
||||||
// Buffer for AddToConsole()
|
// Buffer for AddToConsole()
|
||||||
|
@ -203,25 +198,25 @@ public:
|
||||||
{
|
{
|
||||||
if (scale == 1)
|
if (scale == 1)
|
||||||
{
|
{
|
||||||
screen->DrawChar(ConFont, CR_ORANGE, x, y, '\x1c', TAG_DONE);
|
screen->DrawChar(CurrentConsoleFont, CR_ORANGE, x, y, '\x1c', TAG_DONE);
|
||||||
screen->DrawText(ConFont, CR_ORANGE, x + ConFont->GetCharWidth(0x1c), y,
|
screen->DrawText(CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->GetCharWidth(0x1c), y,
|
||||||
&Text[StartPos], TAG_DONE);
|
&Text[StartPos], TAG_DONE);
|
||||||
|
|
||||||
if (cursor)
|
if (cursor)
|
||||||
{
|
{
|
||||||
screen->DrawChar(ConFont, CR_YELLOW,
|
screen->DrawChar(CurrentConsoleFont, CR_YELLOW,
|
||||||
x + ConFont->GetCharWidth(0x1c) + (CursorPosChars - StartPosChars) * ConFont->GetCharWidth(0xb),
|
x + CurrentConsoleFont->GetCharWidth(0x1c) + (CursorPosChars - StartPosChars) * CurrentConsoleFont->GetCharWidth(0xb),
|
||||||
y, '\xb', TAG_DONE);
|
y, '\xb', TAG_DONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
screen->DrawChar(ConFont, CR_ORANGE, x, y, '\x1c',
|
screen->DrawChar(CurrentConsoleFont, CR_ORANGE, x, y, '\x1c',
|
||||||
DTA_VirtualWidth, screen->GetWidth() / scale,
|
DTA_VirtualWidth, screen->GetWidth() / scale,
|
||||||
DTA_VirtualHeight, screen->GetHeight() / scale,
|
DTA_VirtualHeight, screen->GetHeight() / scale,
|
||||||
DTA_KeepRatio, true, TAG_DONE);
|
DTA_KeepRatio, true, TAG_DONE);
|
||||||
|
|
||||||
screen->DrawText(ConFont, CR_ORANGE, x + ConFont->GetCharWidth(0x1c), y,
|
screen->DrawText(CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->GetCharWidth(0x1c), y,
|
||||||
&Text[StartPos],
|
&Text[StartPos],
|
||||||
DTA_VirtualWidth, screen->GetWidth() / scale,
|
DTA_VirtualWidth, screen->GetWidth() / scale,
|
||||||
DTA_VirtualHeight, screen->GetHeight() / scale,
|
DTA_VirtualHeight, screen->GetHeight() / scale,
|
||||||
|
@ -229,8 +224,8 @@ public:
|
||||||
|
|
||||||
if (cursor)
|
if (cursor)
|
||||||
{
|
{
|
||||||
screen->DrawChar(ConFont, CR_YELLOW,
|
screen->DrawChar(CurrentConsoleFont, CR_YELLOW,
|
||||||
x + ConFont->GetCharWidth(0x1c) + (CursorPosChars - StartPosChars) * ConFont->GetCharWidth(0xb),
|
x + CurrentConsoleFont->GetCharWidth(0x1c) + (CursorPosChars - StartPosChars) * CurrentConsoleFont->GetCharWidth(0xb),
|
||||||
y, '\xb',
|
y, '\xb',
|
||||||
DTA_VirtualWidth, screen->GetWidth() / scale,
|
DTA_VirtualWidth, screen->GetWidth() / scale,
|
||||||
DTA_VirtualHeight, screen->GetHeight() / scale,
|
DTA_VirtualHeight, screen->GetHeight() / scale,
|
||||||
|
@ -616,10 +611,10 @@ void C_InitConsole (int width, int height, bool ingame)
|
||||||
int cwidth, cheight;
|
int cwidth, cheight;
|
||||||
|
|
||||||
vidactive = ingame;
|
vidactive = ingame;
|
||||||
if (ConFont != NULL)
|
if (CurrentConsoleFont != NULL)
|
||||||
{
|
{
|
||||||
cwidth = ConFont->GetCharWidth ('M');
|
cwidth = CurrentConsoleFont->GetCharWidth ('M');
|
||||||
cheight = ConFont->GetHeight();
|
cheight = CurrentConsoleFont->GetHeight();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1092,19 +1087,6 @@ void FNotifyBuffer::Draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_InitTicker (const char *label, unsigned int max, bool showpercent)
|
|
||||||
{
|
|
||||||
TickerPercent = showpercent;
|
|
||||||
TickerMax = max;
|
|
||||||
TickerLabel = label;
|
|
||||||
TickerAt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void C_SetTicker (unsigned int at, bool forceUpdate)
|
|
||||||
{
|
|
||||||
TickerAt = at > TickerMax ? TickerMax : at;
|
|
||||||
}
|
|
||||||
|
|
||||||
void C_DrawConsole ()
|
void C_DrawConsole ()
|
||||||
{
|
{
|
||||||
static int oldbottom = 0;
|
static int oldbottom = 0;
|
||||||
|
@ -1113,15 +1095,15 @@ void C_DrawConsole ()
|
||||||
int textScale = active_con_scale();
|
int textScale = active_con_scale();
|
||||||
|
|
||||||
left = LEFTMARGIN;
|
left = LEFTMARGIN;
|
||||||
lines = (ConBottom/textScale-ConFont->GetHeight()*2)/ConFont->GetHeight();
|
lines = (ConBottom/textScale-CurrentConsoleFont->GetHeight()*2)/CurrentConsoleFont->GetHeight();
|
||||||
if (-ConFont->GetHeight() + lines*ConFont->GetHeight() > ConBottom/textScale - ConFont->GetHeight()*7/2)
|
if (-CurrentConsoleFont->GetHeight() + lines*CurrentConsoleFont->GetHeight() > ConBottom/textScale - CurrentConsoleFont->GetHeight()*7/2)
|
||||||
{
|
{
|
||||||
offset = -ConFont->GetHeight()/2;
|
offset = -CurrentConsoleFont->GetHeight()/2;
|
||||||
lines--;
|
lines--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
offset = -ConFont->GetHeight();
|
offset = -CurrentConsoleFont->GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
oldbottom = ConBottom;
|
oldbottom = ConBottom;
|
||||||
|
@ -1153,71 +1135,19 @@ void C_DrawConsole ()
|
||||||
if (ConBottom >= 12)
|
if (ConBottom >= 12)
|
||||||
{
|
{
|
||||||
if (textScale == 1)
|
if (textScale == 1)
|
||||||
screen->DrawText (ConFont, CR_ORANGE, SCREENWIDTH - 8 -
|
screen->DrawText (CurrentConsoleFont, CR_ORANGE, SCREENWIDTH - 8 -
|
||||||
ConFont->StringWidth (GetVersionString()),
|
CurrentConsoleFont->StringWidth (GetVersionString()),
|
||||||
ConBottom / textScale - ConFont->GetHeight() - 4,
|
ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4,
|
||||||
GetVersionString(), TAG_DONE);
|
GetVersionString(), TAG_DONE);
|
||||||
else
|
else
|
||||||
screen->DrawText(ConFont, CR_ORANGE, SCREENWIDTH / textScale - 8 -
|
screen->DrawText(CurrentConsoleFont, CR_ORANGE, SCREENWIDTH / textScale - 8 -
|
||||||
ConFont->StringWidth(GetVersionString()),
|
CurrentConsoleFont->StringWidth(GetVersionString()),
|
||||||
ConBottom / textScale - ConFont->GetHeight() - 4,
|
ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4,
|
||||||
GetVersionString(),
|
GetVersionString(),
|
||||||
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
||||||
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
||||||
DTA_KeepRatio, true, TAG_DONE);
|
DTA_KeepRatio, true, TAG_DONE);
|
||||||
|
|
||||||
if (TickerMax)
|
|
||||||
{
|
|
||||||
char tickstr[256];
|
|
||||||
const int tickerY = ConBottom / textScale - ConFont->GetHeight() - 4;
|
|
||||||
size_t i;
|
|
||||||
int tickend = ConCols / textScale - SCREENWIDTH / textScale / 90 - 6;
|
|
||||||
int tickbegin = 0;
|
|
||||||
|
|
||||||
if (TickerLabel)
|
|
||||||
{
|
|
||||||
tickbegin = (int)strlen (TickerLabel) + 2;
|
|
||||||
mysnprintf (tickstr, countof(tickstr), "%s: ", TickerLabel);
|
|
||||||
}
|
|
||||||
if (tickend > 256 - ConFont->GetCharWidth(0x12))
|
|
||||||
tickend = 256 - ConFont->GetCharWidth(0x12);
|
|
||||||
tickstr[tickbegin] = 0x10;
|
|
||||||
memset (tickstr + tickbegin + 1, 0x11, tickend - tickbegin);
|
|
||||||
tickstr[tickend + 1] = 0x12;
|
|
||||||
tickstr[tickend + 2] = ' ';
|
|
||||||
if (TickerPercent)
|
|
||||||
{
|
|
||||||
mysnprintf (tickstr + tickend + 3, countof(tickstr) - tickend - 3,
|
|
||||||
"%d%%", Scale (TickerAt, 100, TickerMax));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tickstr[tickend+3] = 0;
|
|
||||||
}
|
|
||||||
if (textScale == 1)
|
|
||||||
screen->DrawText (ConFont, CR_BROWN, LEFTMARGIN, tickerY, tickstr, TAG_DONE);
|
|
||||||
else
|
|
||||||
screen->DrawText (ConFont, CR_BROWN, LEFTMARGIN, tickerY, tickstr,
|
|
||||||
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
|
||||||
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
|
||||||
DTA_KeepRatio, true, TAG_DONE);
|
|
||||||
|
|
||||||
// Draw the marker
|
|
||||||
i = LEFTMARGIN+5+tickbegin*8 + Scale (TickerAt, (int32_t)(tickend - tickbegin)*8, TickerMax);
|
|
||||||
if (textScale == 1)
|
|
||||||
screen->DrawChar (ConFont, CR_ORANGE, (int)i, tickerY, 0x13, TAG_DONE);
|
|
||||||
else
|
|
||||||
screen->DrawChar(ConFont, CR_ORANGE, (int)i, tickerY, 0x13,
|
|
||||||
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
|
||||||
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
|
||||||
DTA_KeepRatio, true, TAG_DONE);
|
|
||||||
|
|
||||||
TickerVisible = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TickerVisible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1230,12 +1160,12 @@ void C_DrawConsole ()
|
||||||
if (lines > 0)
|
if (lines > 0)
|
||||||
{
|
{
|
||||||
// No more enqueuing because adding new text to the console won't touch the actual print data.
|
// No more enqueuing because adding new text to the console won't touch the actual print data.
|
||||||
conbuffer->FormatText(ConFont, ConWidth / textScale);
|
conbuffer->FormatText(CurrentConsoleFont, ConWidth / textScale);
|
||||||
unsigned int consolelines = conbuffer->GetFormattedLineCount();
|
unsigned int consolelines = conbuffer->GetFormattedLineCount();
|
||||||
FBrokenLines *blines = conbuffer->GetLines();
|
FBrokenLines *blines = conbuffer->GetLines();
|
||||||
FBrokenLines *printline = blines + consolelines - 1 - RowAdjust;
|
FBrokenLines *printline = blines + consolelines - 1 - RowAdjust;
|
||||||
|
|
||||||
int bottomline = ConBottom / textScale - ConFont->GetHeight()*2 - 4;
|
int bottomline = ConBottom / textScale - CurrentConsoleFont->GetHeight()*2 - 4;
|
||||||
|
|
||||||
ConsoleDrawing = true;
|
ConsoleDrawing = true;
|
||||||
|
|
||||||
|
@ -1243,11 +1173,11 @@ void C_DrawConsole ()
|
||||||
{
|
{
|
||||||
if (textScale == 1)
|
if (textScale == 1)
|
||||||
{
|
{
|
||||||
screen->DrawText(ConFont, CR_TAN, LEFTMARGIN, offset + lines * ConFont->GetHeight(), p->Text, TAG_DONE);
|
screen->DrawText(CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
screen->DrawText(ConFont, CR_TAN, LEFTMARGIN, offset + lines * ConFont->GetHeight(), p->Text,
|
screen->DrawText(CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text,
|
||||||
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
||||||
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
||||||
DTA_KeepRatio, true, TAG_DONE);
|
DTA_KeepRatio, true, TAG_DONE);
|
||||||
|
@ -1262,14 +1192,14 @@ void C_DrawConsole ()
|
||||||
{
|
{
|
||||||
CmdLine.Draw(left, bottomline, textScale, cursoron);
|
CmdLine.Draw(left, bottomline, textScale, cursoron);
|
||||||
}
|
}
|
||||||
if (RowAdjust && ConBottom >= ConFont->GetHeight()*7/2)
|
if (RowAdjust && ConBottom >= CurrentConsoleFont->GetHeight()*7/2)
|
||||||
{
|
{
|
||||||
// Indicate that the view has been scrolled up (10)
|
// Indicate that the view has been scrolled up (10)
|
||||||
// and if we can scroll no further (12)
|
// and if we can scroll no further (12)
|
||||||
if (textScale == 1)
|
if (textScale == 1)
|
||||||
screen->DrawChar (ConFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE);
|
screen->DrawChar (CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE);
|
||||||
else
|
else
|
||||||
screen->DrawChar(ConFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10,
|
screen->DrawChar(CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10,
|
||||||
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
||||||
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
||||||
DTA_KeepRatio, true, TAG_DONE);
|
DTA_KeepRatio, true, TAG_DONE);
|
||||||
|
@ -1404,7 +1334,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
|
||||||
if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
|
if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
|
||||||
{ // Scroll console buffer up one page
|
{ // Scroll console buffer up one page
|
||||||
RowAdjust += (SCREENHEIGHT-4)/active_con_scale() /
|
RowAdjust += (SCREENHEIGHT-4)/active_con_scale() /
|
||||||
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? ConFont->GetHeight() : ConFont->GetHeight()*2) - 3;
|
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3;
|
||||||
}
|
}
|
||||||
else if (RowAdjust < conbuffer->GetFormattedLineCount())
|
else if (RowAdjust < conbuffer->GetFormattedLineCount())
|
||||||
{ // Scroll console buffer up
|
{ // Scroll console buffer up
|
||||||
|
@ -1427,7 +1357,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
|
||||||
if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
|
if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
|
||||||
{ // Scroll console buffer down one page
|
{ // Scroll console buffer down one page
|
||||||
const int scrollamt = (SCREENHEIGHT-4)/active_con_scale() /
|
const int scrollamt = (SCREENHEIGHT-4)/active_con_scale() /
|
||||||
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? ConFont->GetHeight() : ConFont->GetHeight()*2) - 3;
|
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3;
|
||||||
if (RowAdjust < scrollamt)
|
if (RowAdjust < scrollamt)
|
||||||
{
|
{
|
||||||
RowAdjust = 0;
|
RowAdjust = 0;
|
||||||
|
|
|
@ -74,9 +74,6 @@ void C_HideConsole (void);
|
||||||
void C_AdjustBottom (void);
|
void C_AdjustBottom (void);
|
||||||
void C_FlushDisplay (void);
|
void C_FlushDisplay (void);
|
||||||
|
|
||||||
void C_InitTicker (const char *label, unsigned int max, bool showpercent=true);
|
|
||||||
void C_SetTicker (unsigned int at, bool forceUpdate=false);
|
|
||||||
|
|
||||||
class FFont;
|
class FFont;
|
||||||
void C_MidPrint (FFont *font, const char *message);
|
void C_MidPrint (FFont *font, const char *message);
|
||||||
void C_MidPrintBold (FFont *font, const char *message);
|
void C_MidPrintBold (FFont *font, const char *message);
|
||||||
|
|
240
src/gamedata/fonts/hexfont.cpp
Normal file
240
src/gamedata/fonts/hexfont.cpp
Normal file
|
@ -0,0 +1,240 @@
|
||||||
|
/*
|
||||||
|
** bdffont.cpp
|
||||||
|
** Management for the VGA consolefont
|
||||||
|
**
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
** Copyright 2019 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 "doomerrors.h"
|
||||||
|
#include "textures.h"
|
||||||
|
#include "image.h"
|
||||||
|
#include "v_font.h"
|
||||||
|
#include "w_wad.h"
|
||||||
|
#include "utf8.h"
|
||||||
|
#include "sc_man.h"
|
||||||
|
|
||||||
|
#include "fontinternals.h"
|
||||||
|
|
||||||
|
// This is a font character that reads RLE compressed data.
|
||||||
|
class FHexFontChar : public FImageSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FHexFontChar(uint8_t *sourcedata, int swidth, int width, int height);
|
||||||
|
|
||||||
|
TArray<uint8_t> CreatePalettedPixels(int conversion) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int SourceWidth;
|
||||||
|
const uint8_t *SourceData;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FHexFontChar :: FHexFontChar
|
||||||
|
//
|
||||||
|
// Used by HEX fonts.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
FHexFontChar::FHexFontChar (uint8_t *sourcedata, int swidth, int width, int height)
|
||||||
|
: SourceData (sourcedata)
|
||||||
|
{
|
||||||
|
SourceWidth = swidth;
|
||||||
|
Width = width;
|
||||||
|
Height = height;
|
||||||
|
LeftOffset = 0;
|
||||||
|
TopOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FHexFontChar :: Get8BitPixels
|
||||||
|
//
|
||||||
|
// The render style has no relevance here.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
TArray<uint8_t> FHexFontChar::CreatePalettedPixels(int)
|
||||||
|
{
|
||||||
|
int destSize = Width * Height;
|
||||||
|
TArray<uint8_t> Pixels(destSize, true);
|
||||||
|
uint8_t *dest_p = Pixels.Data();
|
||||||
|
const uint8_t *src_p = SourceData;
|
||||||
|
|
||||||
|
memset(dest_p, 0, destSize);
|
||||||
|
for (int y = 0; y < Height; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < SourceWidth; x++)
|
||||||
|
{
|
||||||
|
int byte = *src_p++;
|
||||||
|
uint8_t *pixelstart = dest_p + 8 * x * Height + y;
|
||||||
|
for (int bit = 0; bit < 8; bit++)
|
||||||
|
{
|
||||||
|
if (byte & (128 >> bit))
|
||||||
|
{
|
||||||
|
pixelstart[bit*Height] = y+2;
|
||||||
|
// Add a shadow at the bottom right, similar to the old console font.
|
||||||
|
if (y != Height - 1)
|
||||||
|
{
|
||||||
|
pixelstart[bit*Height + Height + 1] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class FHexFont : public FFont
|
||||||
|
{
|
||||||
|
TArray<uint8_t> glyphdata;
|
||||||
|
unsigned glyphmap[65536] = {};
|
||||||
|
|
||||||
|
public:
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// parse a HEX font
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void ParseDefinition(int lumpnum)
|
||||||
|
{
|
||||||
|
FScanner sc;
|
||||||
|
|
||||||
|
FirstChar = INT_MAX;
|
||||||
|
LastChar = INT_MIN;
|
||||||
|
sc.OpenLumpNum(lumpnum);
|
||||||
|
sc.SetCMode(true);
|
||||||
|
glyphdata.Push(0); // ensure that index 0 can be used as 'not present'.
|
||||||
|
while (sc.GetString())
|
||||||
|
{
|
||||||
|
int codepoint = (int)strtoull(sc.String, nullptr, 16);
|
||||||
|
sc.MustGetStringName(":");
|
||||||
|
sc.MustGetString();
|
||||||
|
if (codepoint >= 0 && codepoint < 65536 && !sc.Compare("00000000000000000000000000000000")) // don't set up empty glyphs.
|
||||||
|
{
|
||||||
|
unsigned size = (unsigned)strlen(sc.String);
|
||||||
|
unsigned offset = glyphdata.Reserve(size/2 + 1);
|
||||||
|
glyphmap[codepoint] = offset;
|
||||||
|
glyphdata[offset++] = size / 2;
|
||||||
|
for(unsigned i = 0; i < size; i+=2)
|
||||||
|
{
|
||||||
|
char hex[] = { sc.String[i], sc.String[i+1], 0 };
|
||||||
|
glyphdata[offset++] = (uint8_t)strtoull(hex, nullptr, 16);
|
||||||
|
}
|
||||||
|
if (codepoint < FirstChar) FirstChar = codepoint;
|
||||||
|
if (codepoint > LastChar) LastChar = codepoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FHexFont :: FHexFont
|
||||||
|
//
|
||||||
|
// Loads a HEX font
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
FHexFont (const char *fontname, int lump)
|
||||||
|
: FFont(lump)
|
||||||
|
{
|
||||||
|
assert(lump >= 0);
|
||||||
|
|
||||||
|
FontName = fontname;
|
||||||
|
|
||||||
|
ParseDefinition(lump);
|
||||||
|
|
||||||
|
Next = FirstFont;
|
||||||
|
FirstFont = this;
|
||||||
|
FontHeight = 16;
|
||||||
|
SpaceWidth = 9;
|
||||||
|
GlobalKerning = 0;
|
||||||
|
translateUntranslated = true;
|
||||||
|
|
||||||
|
LoadTranslations();
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FHexFont :: LoadTranslations
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void LoadTranslations()
|
||||||
|
{
|
||||||
|
const int spacing = 9;
|
||||||
|
double luminosity[256];
|
||||||
|
|
||||||
|
memset (PatchRemap, 0, 256);
|
||||||
|
for (int i = 0; i < 18; i++)
|
||||||
|
{
|
||||||
|
// Create a gradient similar to the old console font.
|
||||||
|
PatchRemap[i] = i;
|
||||||
|
luminosity[i] = i == 1? 0.01 : 0.5 + (i-2) * (0.5 / 17.);
|
||||||
|
}
|
||||||
|
ActiveColors = 18;
|
||||||
|
|
||||||
|
Chars.Resize(LastChar - FirstChar + 1);
|
||||||
|
for (int i = FirstChar; i <= LastChar; i++)
|
||||||
|
{
|
||||||
|
if (glyphmap[i] > 0)
|
||||||
|
{
|
||||||
|
auto offset = glyphmap[i];
|
||||||
|
int size = glyphdata[offset] / 16;
|
||||||
|
Chars[i - FirstChar].TranslatedPic = new FImageTexture(new FHexFontChar (&glyphdata[offset+1], size, size * 9, 16));
|
||||||
|
Chars[i - FirstChar].TranslatedPic->SetUseType(ETextureType::FontChar);
|
||||||
|
Chars[i - FirstChar].XMove = size * spacing;
|
||||||
|
TexMan.AddTexture(Chars[i - FirstChar].TranslatedPic);
|
||||||
|
}
|
||||||
|
else Chars[i - FirstChar].XMove = spacing;
|
||||||
|
|
||||||
|
}
|
||||||
|
Printf("----------------------------\n");
|
||||||
|
BuildTranslations (luminosity, nullptr, &TranslationParms[1][0], ActiveColors, nullptr);
|
||||||
|
Printf("----------------------------\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
FFont *CreateHexLumpFont (const char *fontname, int lump)
|
||||||
|
{
|
||||||
|
return new FHexFont(fontname, lump);
|
||||||
|
}
|
|
@ -864,7 +864,8 @@ int stripaccent(int code)
|
||||||
|
|
||||||
FFont *V_GetFont(const char *name, const char *fontlumpname)
|
FFont *V_GetFont(const char *name, const char *fontlumpname)
|
||||||
{
|
{
|
||||||
if (!stricmp(name, "CONFONT")) name = "ConsoleFont"; // several mods have used the name CONFONT directly and effectively duplicated the font.
|
if (!stricmp(name, "DBIGFONT")) name = "BigFont"; // several mods have used the name CONFONT directly and effectively duplicated the font.
|
||||||
|
else if (!stricmp(name, "CONFONT")) name = "ConsoleFont"; // several mods have used the name CONFONT directly and effectively duplicated the font.
|
||||||
FFont *font = FFont::FindFont (name);
|
FFont *font = FFont::FindFont (name);
|
||||||
if (font == nullptr)
|
if (font == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -1441,6 +1442,13 @@ void V_InitFonts()
|
||||||
InitLowerUpper();
|
InitLowerUpper();
|
||||||
V_InitCustomFonts();
|
V_InitCustomFonts();
|
||||||
|
|
||||||
|
FFont *CreateHexLumpFont(const char *fontname, int lump);
|
||||||
|
|
||||||
|
auto lump = Wads.CheckNumForFullName("newconsolefont.hex", 0); // This is always loaded from gzdoom.pk3 to prevent overriding it with incomplete replacements.
|
||||||
|
if (lump == -1) I_FatalError("newconsolefont.hex not found"); // This font is needed - do not start up without it.
|
||||||
|
NewConsoleFont = CreateHexLumpFont("NewConsoleFont", lump);
|
||||||
|
CurrentConsoleFont = NewConsoleFont;
|
||||||
|
|
||||||
// load the heads-up font
|
// load the heads-up font
|
||||||
if (!(SmallFont = V_GetFont("SmallFont", "SMALLFNT")))
|
if (!(SmallFont = V_GetFont("SmallFont", "SMALLFNT")))
|
||||||
{
|
{
|
||||||
|
@ -1526,6 +1534,6 @@ void V_ClearFonts()
|
||||||
delete FFont::FirstFont;
|
delete FFont::FirstFont;
|
||||||
}
|
}
|
||||||
FFont::FirstFont = nullptr;
|
FFont::FirstFont = nullptr;
|
||||||
SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr;
|
CurrentConsoleFont = NewConsoleFont = SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont;
|
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *CurrentConsoleFont;
|
||||||
|
|
||||||
void V_InitFonts();
|
void V_InitFonts();
|
||||||
void V_ClearFonts();
|
void V_ClearFonts();
|
||||||
|
|
|
@ -87,6 +87,28 @@ int GetUIScale(int altval)
|
||||||
return MAX(1,MIN(scaleval, max));
|
return MAX(1,MIN(scaleval, max));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The new console font is twice as high, so the scaling calculation must factor that in.
|
||||||
|
int GetConScale(int altval)
|
||||||
|
{
|
||||||
|
int scaleval;
|
||||||
|
if (altval > 0) scaleval = altval;
|
||||||
|
else if (uiscale == 0)
|
||||||
|
{
|
||||||
|
// Default should try to scale to 640x400
|
||||||
|
int vscale = screen->GetHeight() / 800;
|
||||||
|
int hscale = screen->GetWidth() / 1280;
|
||||||
|
scaleval = clamp(vscale, 1, hscale);
|
||||||
|
}
|
||||||
|
else scaleval = uiscale / 2;
|
||||||
|
|
||||||
|
// block scales that result in something larger than the current screen.
|
||||||
|
int vmax = screen->GetHeight() / 400;
|
||||||
|
int hmax = screen->GetWidth() / 640;
|
||||||
|
int max = MAX(vmax, hmax);
|
||||||
|
return MAX(1, MIN(scaleval, max));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// [RH] Stretch values to make a 320x200 image best fit the screen
|
// [RH] Stretch values to make a 320x200 image best fit the screen
|
||||||
// without using fractional steppings
|
// without using fractional steppings
|
||||||
int CleanXfac, CleanYfac;
|
int CleanXfac, CleanYfac;
|
||||||
|
|
|
@ -145,7 +145,7 @@ public:
|
||||||
|
|
||||||
int DisplayWidth, DisplayHeight;
|
int DisplayWidth, DisplayHeight;
|
||||||
|
|
||||||
FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont;
|
FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *CurrentConsoleFont;
|
||||||
|
|
||||||
uint32_t Col2RGB8[65][256];
|
uint32_t Col2RGB8[65][256];
|
||||||
uint32_t *Col2RGB8_LessPrecision[65];
|
uint32_t *Col2RGB8_LessPrecision[65];
|
||||||
|
|
|
@ -609,6 +609,7 @@ bool AspectTallerThanWide(float aspect);
|
||||||
void ScaleWithAspect(int &w, int &h, int Width, int Height);
|
void ScaleWithAspect(int &w, int &h, int Width, int Height);
|
||||||
|
|
||||||
int GetUIScale(int altval);
|
int GetUIScale(int altval);
|
||||||
|
int GetConScale(int altval);
|
||||||
|
|
||||||
EXTERN_CVAR(Int, uiscale);
|
EXTERN_CVAR(Int, uiscale);
|
||||||
EXTERN_CVAR(Int, con_scaletext);
|
EXTERN_CVAR(Int, con_scaletext);
|
||||||
|
@ -621,7 +622,7 @@ inline int active_con_scaletext()
|
||||||
|
|
||||||
inline int active_con_scale()
|
inline int active_con_scale()
|
||||||
{
|
{
|
||||||
return GetUIScale(con_scale);
|
return GetConScale(con_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
20
wadsrc/static/credits/newconsolefont.txt
Normal file
20
wadsrc/static/credits/newconsolefont.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
The font is a combination of "Unicode VGA font" (http://www.inp.nsk.su./~bolkhov/files/fonts/univga/)
|
||||||
|
License: "The UNI-VGA font can be distributed and modified freely, according to the X license."
|
||||||
|
|
||||||
|
All code points not present in the above were taken from "GNU Unifont" (http://unifoundry.com/unifont.html)
|
||||||
|
License: GPL v2 with the following exception:
|
||||||
|
|
||||||
|
The license for the compiled fonts is covered by the above GPL terms
|
||||||
|
with the GNU font embedding exception, as follows:
|
||||||
|
|
||||||
|
As a special exception, if you create a document which uses this font,
|
||||||
|
and embed this font or unaltered portions of this font into the document,
|
||||||
|
this font does not by itself cause the resulting document to be covered
|
||||||
|
by the GNU General Public License. This exception does not however
|
||||||
|
invalidate any other reasons why the document might be covered by the
|
||||||
|
GNU General Public License. If you modify this font, you may extend
|
||||||
|
this exception to your version of the font, but you are not obligated
|
||||||
|
to do so. If you do not wish to do so, delete this exception statement
|
||||||
|
from your version.
|
||||||
|
|
||||||
|
See "http://www.gnu.org/licenses/gpl-faq.html#FontException" for more details.
|
57020
wadsrc/static/newconsolefont.hex
Normal file
57020
wadsrc/static/newconsolefont.hex
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue