2019-10-23 23:20:58 +00:00
|
|
|
/*
|
|
|
|
** 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.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2020-04-05 20:51:53 +00:00
|
|
|
#include "engineerrors.h"
|
2019-10-23 23:20:58 +00:00
|
|
|
#include "textures.h"
|
|
|
|
#include "image.h"
|
|
|
|
#include "v_font.h"
|
2020-04-05 20:51:53 +00:00
|
|
|
#include "filesystem.h"
|
2019-10-23 23:20:58 +00:00
|
|
|
#include "utf8.h"
|
|
|
|
#include "sc_man.h"
|
2020-05-24 14:32:52 +00:00
|
|
|
#include "texturemanager.h"
|
2019-10-23 23:20:58 +00:00
|
|
|
|
|
|
|
#include "fontinternals.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct HexDataSource
|
|
|
|
{
|
|
|
|
int FirstChar = INT_MAX, LastChar = INT_MIN;
|
|
|
|
TArray<uint8_t> glyphdata;
|
|
|
|
unsigned glyphmap[65536] = {};
|
|
|
|
|
2021-05-24 14:02:43 +00:00
|
|
|
PalEntry ConsolePal[18], SmallPal[18];
|
|
|
|
|
2019-10-23 23:20:58 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// parse a HEX font
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2022-06-06 09:45:02 +00:00
|
|
|
void ParseDefinition(FResourceLump* font)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
|
|
|
FScanner sc;
|
2020-04-05 20:51:53 +00:00
|
|
|
|
2022-06-06 09:45:02 +00:00
|
|
|
auto data = font->Lock();
|
|
|
|
sc.OpenMem("newconsolefont.hex", (const char*)data, font->Size());
|
2019-10-23 23:20:58 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2021-05-24 14:02:43 +00:00
|
|
|
|
|
|
|
ConsolePal[0] = SmallPal[0] = 0;
|
|
|
|
for (int i = 1; i < 18; i++)
|
|
|
|
{
|
|
|
|
double lum = i == 1 ? 0.01 : 0.5 + (i - 2) * (0.5 / 17.);
|
|
|
|
uint8_t lumb = (uint8_t(lum * 255));
|
|
|
|
|
|
|
|
ConsolePal[i] = PalEntry(255, lumb, lumb, lumb);
|
|
|
|
lumb = i * 255 / 17;
|
|
|
|
SmallPal[i] = PalEntry(255, lumb, lumb, lumb);
|
|
|
|
}
|
2022-06-06 09:45:02 +00:00
|
|
|
font->Unlock();
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static HexDataSource hexdata;
|
|
|
|
|
|
|
|
// This is a font character that reads RLE compressed data.
|
2020-05-24 14:32:52 +00:00
|
|
|
class FHexFontChar : public FImageSource
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FHexFontChar(uint8_t *sourcedata, int swidth, int width, int height);
|
|
|
|
|
2020-05-24 14:32:52 +00:00
|
|
|
TArray<uint8_t> CreatePalettedPixels(int conversion) override;
|
2021-05-24 14:02:43 +00:00
|
|
|
int CopyPixels(FBitmap* bmp, int conversion);
|
2019-10-23 23:20:58 +00:00
|
|
|
|
|
|
|
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;
|
2020-05-24 14:32:52 +00:00
|
|
|
Width = width;
|
|
|
|
Height = height;
|
|
|
|
LeftOffset = 0;
|
|
|
|
TopOffset = 0;
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FHexFontChar :: Get8BitPixels
|
|
|
|
//
|
|
|
|
// The render style has no relevance here.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2020-05-24 14:32:52 +00:00
|
|
|
TArray<uint8_t> FHexFontChar::CreatePalettedPixels(int)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2020-05-24 14:32:52 +00:00
|
|
|
int destSize = Width * Height;
|
|
|
|
TArray<uint8_t> Pixels(destSize, true);
|
|
|
|
uint8_t *dest_p = Pixels.Data();
|
2019-10-23 23:20:58 +00:00
|
|
|
const uint8_t *src_p = SourceData;
|
|
|
|
|
|
|
|
memset(dest_p, 0, destSize);
|
2020-05-24 14:32:52 +00:00
|
|
|
for (int y = 0; y < Height; y++)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
|
|
|
for (int x = 0; x < SourceWidth; x++)
|
|
|
|
{
|
|
|
|
int byte = *src_p++;
|
2020-05-24 14:32:52 +00:00
|
|
|
uint8_t *pixelstart = dest_p + 8 * x * Height + y;
|
2019-10-23 23:20:58 +00:00
|
|
|
for (int bit = 0; bit < 8; bit++)
|
|
|
|
{
|
|
|
|
if (byte & (128 >> bit))
|
|
|
|
{
|
2020-05-24 14:32:52 +00:00
|
|
|
pixelstart[bit*Height] = y+2;
|
2019-10-23 23:20:58 +00:00
|
|
|
// Add a shadow at the bottom right, similar to the old console font.
|
2020-05-24 14:32:52 +00:00
|
|
|
if (y != Height - 1)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2020-05-24 14:32:52 +00:00
|
|
|
pixelstart[bit*Height + Height + 1] = 1;
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-24 14:32:52 +00:00
|
|
|
return Pixels;
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
|
2021-05-24 14:02:43 +00:00
|
|
|
int FHexFontChar::CopyPixels(FBitmap* bmp, int conversion)
|
|
|
|
{
|
|
|
|
if (conversion == luminance) conversion = normal; // luminance images have no use as an RGB source.
|
|
|
|
PalEntry* palette = hexdata.ConsolePal;
|
|
|
|
auto ppix = CreatePalettedPixels(conversion);
|
|
|
|
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, palette, nullptr);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-10-23 23:20:58 +00:00
|
|
|
class FHexFontChar2 : public FHexFontChar
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FHexFontChar2(uint8_t *sourcedata, int swidth, int width, int height);
|
|
|
|
|
2020-05-24 14:32:52 +00:00
|
|
|
TArray<uint8_t> CreatePalettedPixels(int conversion) override;
|
2021-05-24 14:02:43 +00:00
|
|
|
int CopyPixels(FBitmap* bmp, int conversion);
|
2019-10-23 23:20:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FHexFontChar :: FHexFontChar
|
|
|
|
//
|
|
|
|
// Used by HEX fonts.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FHexFontChar2::FHexFontChar2(uint8_t *sourcedata, int swidth, int width, int height)
|
|
|
|
: FHexFontChar(sourcedata, swidth, width, height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FHexFontChar :: Get8BitPixels
|
|
|
|
//
|
|
|
|
// The render style has no relevance here.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2020-05-24 14:32:52 +00:00
|
|
|
TArray<uint8_t> FHexFontChar2::CreatePalettedPixels(int)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2020-05-24 14:32:52 +00:00
|
|
|
int destSize = Width * Height;
|
|
|
|
TArray<uint8_t> Pixels(destSize, true);
|
|
|
|
uint8_t *dest_p = Pixels.Data();
|
2019-10-23 23:20:58 +00:00
|
|
|
|
|
|
|
assert(SourceData);
|
|
|
|
if (SourceData)
|
|
|
|
{
|
|
|
|
auto drawLayer = [&](int ix, int iy, int color)
|
|
|
|
{
|
|
|
|
const uint8_t *src_p = SourceData;
|
2020-05-24 14:32:52 +00:00
|
|
|
for (int y = 0; y < Height - 2; y++)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
|
|
|
for (int x = 0; x < SourceWidth; x++)
|
|
|
|
{
|
|
|
|
int byte = *src_p++;
|
2020-05-24 14:32:52 +00:00
|
|
|
uint8_t *pixelstart = dest_p + (ix + 8 * x) * Height + (iy + y);
|
2019-10-23 23:20:58 +00:00
|
|
|
for (int bit = 0; bit < 8; bit++)
|
|
|
|
{
|
|
|
|
if (byte & (128 >> bit))
|
|
|
|
{
|
2020-05-24 14:32:52 +00:00
|
|
|
pixelstart[bit*Height] = color;
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
memset(dest_p, 0, destSize);
|
|
|
|
|
|
|
|
const int darkcolor = 1;
|
|
|
|
const int brightcolor = 14;
|
|
|
|
for (int xx = 0; xx < 3; xx++) for (int yy = 0; yy < 3; yy++) if (xx != 1 || yy != 1)
|
|
|
|
drawLayer(xx, yy, darkcolor);
|
|
|
|
drawLayer(1, 1, brightcolor);
|
|
|
|
}
|
2020-05-24 14:32:52 +00:00
|
|
|
return Pixels;
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
|
2021-05-24 14:02:43 +00:00
|
|
|
int FHexFontChar2::CopyPixels(FBitmap* bmp, int conversion)
|
|
|
|
{
|
|
|
|
if (conversion == luminance) conversion = normal; // luminance images have no use as an RGB source.
|
|
|
|
PalEntry* palette = hexdata.SmallPal;
|
|
|
|
auto ppix = CreatePalettedPixels(conversion);
|
|
|
|
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, palette, nullptr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-23 23:20:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FHexFont : public FFont
|
|
|
|
{
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2019-10-23 23:20:58 +00:00
|
|
|
public:
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FHexFont :: FHexFont
|
|
|
|
//
|
|
|
|
// Loads a HEX font
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2020-04-05 20:51:53 +00:00
|
|
|
FHexFont (const char *fontname, int lump)
|
|
|
|
: FFont(lump)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2020-05-01 11:13:46 +00:00
|
|
|
const int spacing = 9;
|
2020-04-05 20:51:53 +00:00
|
|
|
assert(lump >= 0);
|
|
|
|
|
2019-10-23 23:20:58 +00:00
|
|
|
FontName = fontname;
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2019-10-23 23:20:58 +00:00
|
|
|
FirstChar = hexdata.FirstChar;
|
|
|
|
LastChar = hexdata.LastChar;
|
|
|
|
|
|
|
|
FontHeight = 16;
|
|
|
|
SpaceWidth = 9;
|
|
|
|
GlobalKerning = 0;
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-05-01 11:13:46 +00:00
|
|
|
Chars.Resize(LastChar - FirstChar + 1);
|
|
|
|
for (int i = FirstChar; i <= LastChar; i++)
|
|
|
|
{
|
|
|
|
if (hexdata.glyphmap[i] > 0)
|
|
|
|
{
|
|
|
|
auto offset = hexdata.glyphmap[i];
|
|
|
|
int size = hexdata.glyphdata[offset] / 16;
|
2021-05-24 17:27:07 +00:00
|
|
|
Chars[i - FirstChar].OriginalPic = MakeGameTexture(new FImageTexture(new FHexFontChar(&hexdata.glyphdata[offset + 1], size, size * 9, 16)), nullptr, ETextureType::FontChar);
|
2020-05-01 11:13:46 +00:00
|
|
|
Chars[i - FirstChar].XMove = size * spacing;
|
2021-05-24 17:27:07 +00:00
|
|
|
TexMan.AddGameTexture(Chars[i - FirstChar].OriginalPic);
|
2020-05-01 11:13:46 +00:00
|
|
|
}
|
|
|
|
else Chars[i - FirstChar].XMove = spacing;
|
|
|
|
|
|
|
|
}
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FHexFont :: LoadTranslations
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void LoadTranslations()
|
|
|
|
{
|
2021-05-24 14:02:43 +00:00
|
|
|
int minlum = hexdata.ConsolePal[1].r;
|
|
|
|
int maxlum = hexdata.ConsolePal[17].r;
|
|
|
|
|
|
|
|
Translations.Resize(NumTextColors);
|
|
|
|
for (int i = 0; i < NumTextColors; i++)
|
|
|
|
{
|
|
|
|
if (i == CR_UNTRANSLATED) Translations[i] = 0;
|
|
|
|
else Translations[i] = LuminosityTranslation(i * 2 + 1, minlum, maxlum);
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2019-10-23 23:20:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FHexFont2 : public FFont
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FHexFont :: FHexFont
|
|
|
|
//
|
|
|
|
// Loads a HEX font
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2020-04-05 20:51:53 +00:00
|
|
|
FHexFont2(const char *fontname, int lump)
|
|
|
|
: FFont(lump)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2020-05-01 11:13:46 +00:00
|
|
|
const int spacing = 9;
|
2020-04-05 20:51:53 +00:00
|
|
|
assert(lump >= 0);
|
2019-10-23 23:20:58 +00:00
|
|
|
|
|
|
|
FontName = fontname;
|
|
|
|
|
|
|
|
FirstChar = hexdata.FirstChar;
|
|
|
|
LastChar = hexdata.LastChar;
|
|
|
|
|
|
|
|
FontHeight = 18;
|
2020-02-02 15:45:32 +00:00
|
|
|
SpaceWidth = 9;
|
2019-10-23 23:20:58 +00:00
|
|
|
GlobalKerning = -1;
|
2020-05-01 11:13:46 +00:00
|
|
|
Chars.Resize(LastChar - FirstChar + 1);
|
|
|
|
for (int i = FirstChar; i <= LastChar; i++)
|
|
|
|
{
|
|
|
|
if (hexdata.glyphmap[i] > 0)
|
|
|
|
{
|
|
|
|
auto offset = hexdata.glyphmap[i];
|
|
|
|
int size = hexdata.glyphdata[offset] / 16;
|
2021-05-24 17:27:07 +00:00
|
|
|
Chars[i - FirstChar].OriginalPic = MakeGameTexture(new FImageTexture(new FHexFontChar2(&hexdata.glyphdata[offset + 1], size, 2 + size * 8, 18)), nullptr, ETextureType::FontChar);
|
2020-05-01 11:13:46 +00:00
|
|
|
Chars[i - FirstChar].XMove = size * spacing;
|
2021-05-24 17:27:07 +00:00
|
|
|
TexMan.AddGameTexture(Chars[i - FirstChar].OriginalPic);
|
2020-05-01 11:13:46 +00:00
|
|
|
}
|
|
|
|
else Chars[i - FirstChar].XMove = spacing;
|
2019-10-23 23:20:58 +00:00
|
|
|
|
2020-05-01 11:13:46 +00:00
|
|
|
}
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FHexFont :: LoadTranslations
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2020-01-07 00:11:19 +00:00
|
|
|
void LoadTranslations() override
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2021-05-24 14:02:43 +00:00
|
|
|
int minlum = hexdata.SmallPal[1].r;
|
|
|
|
int maxlum = hexdata.SmallPal[17].r;
|
2019-10-23 23:20:58 +00:00
|
|
|
|
2021-05-24 14:02:43 +00:00
|
|
|
Translations.Resize(NumTextColors);
|
|
|
|
for (int i = 0; i < NumTextColors; i++)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2021-05-24 14:02:43 +00:00
|
|
|
if (i == CR_UNTRANSLATED) Translations[i] = 0;
|
|
|
|
else Translations[i] = LuminosityTranslation(i * 2, minlum, maxlum);
|
2019-10-23 23:20:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2020-04-05 20:51:53 +00:00
|
|
|
FFont *CreateHexLumpFont (const char *fontname, int lump)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2022-06-06 09:45:02 +00:00
|
|
|
assert(hexdata.FirstChar != INT_MAX);
|
2019-10-23 23:20:58 +00:00
|
|
|
return new FHexFont(fontname, lump);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2020-04-05 20:51:53 +00:00
|
|
|
FFont *CreateHexLumpFont2(const char *fontname, int lump)
|
2019-10-23 23:20:58 +00:00
|
|
|
{
|
2022-06-06 09:45:02 +00:00
|
|
|
assert(hexdata.FirstChar != INT_MAX);
|
2019-10-23 23:20:58 +00:00
|
|
|
return new FHexFont2(fontname, lump);
|
|
|
|
}
|
2022-06-06 09:45:02 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
uint8_t* GetHexChar(int codepoint)
|
|
|
|
{
|
|
|
|
assert(hexdata.FirstChar != INT_MAX);
|
|
|
|
|
|
|
|
if (hexdata.glyphmap[codepoint] > 0)
|
|
|
|
{
|
|
|
|
auto offset = hexdata.glyphmap[codepoint];
|
|
|
|
return &hexdata.glyphdata[offset];
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoadHexFont(const char* filename)
|
|
|
|
{
|
|
|
|
auto resf = FResourceFile::OpenResourceFile(filename);
|
|
|
|
if (resf == nullptr) I_FatalError("Unable to open %s", filename);
|
|
|
|
auto hexfont = resf->FindLump("newconsolefont.hex");
|
|
|
|
if (hexfont == nullptr) I_FatalError("Unable to find newconsolefont.hex in %s", filename);
|
|
|
|
hexdata.ParseDefinition(hexfont);
|
|
|
|
}
|