- added internationalized fonts.

This still needs a bit of fixing and tweaking but most is working.
This commit is contained in:
Christoph Oelckers 2021-05-30 10:56:31 +02:00
parent cd56fd66d2
commit 42b70a7d93
2102 changed files with 390 additions and 239 deletions

View file

@ -85,9 +85,6 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
Cursor = '_';
SpaceWidth = 0;
FontHeight = 0;
uint8_t pp = 0;
for (auto &p : PatchRemap) p = pp++;
translateUntranslated = false;
int FixedWidth = 0;
TMap<int, FGameTexture*> charMap;
@ -126,6 +123,11 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
sc.MustGetValue(false);
GlobalKerning = sc.Number;
}
if (sc.Compare("Altfont"))
{
sc.MustGetString();
AltFontName = sc.String;
}
else if (sc.Compare("Scale"))
{
sc.MustGetValue(true);
@ -154,6 +156,16 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
sc.MustGetValue(false);
FontHeight = sc.Number;
}
else if (sc.Compare("minluminosity"))
{
sc.MustGetValue(false);
MinLum = (int16_t)clamp(sc.Number, 0, 255);
}
else if (sc.Compare("maxluminosity"))
{
sc.MustGetValue(false);
MaxLum = (int16_t)clamp(sc.Number, 0, 255);
}
else if (sc.Compare("Translationtype"))
{
sc.MustGetToken(TK_Identifier);
@ -302,7 +314,6 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
auto count = maxchar - minchar + 1;
Chars.Resize(count);
int fontheight = 0;
int asciiheight = 0;
for (i = 0; i < count; i++)
{
@ -320,10 +331,6 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
{
fontheight = height;
}
if (height > asciiheight && FirstChar + 1 < 128)
{
asciiheight = height;
}
}
auto orig = pic->GetTexture();
@ -359,7 +366,6 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
}
}
if (FontHeight == 0) FontHeight = fontheight;
if (AsciiHeight == 0) AsciiHeight = asciiheight;
FixXMoves();
}
@ -1005,8 +1011,6 @@ FFont::FFont (int lump)
FontName = NAME_None;
Cursor = '_';
noTranslate = false;
uint8_t pp = 0;
for (auto &p : PatchRemap) p = pp++;
}
//==========================================================================

View file

@ -292,7 +292,6 @@ public:
FontHeight = 16;
SpaceWidth = 9;
GlobalKerning = 0;
translateUntranslated = true;
Chars.Resize(LastChar - FirstChar + 1);
for (int i = FirstChar; i <= LastChar; i++)
@ -360,7 +359,6 @@ public:
FontHeight = 18;
SpaceWidth = 9;
GlobalKerning = -1;
translateUntranslated = true;
Chars.Resize(LastChar - FirstChar + 1);
for (int i = FirstChar; i <= LastChar; i++)
{

View file

@ -227,7 +227,6 @@ void FSingleLumpFont::LoadFON1 (int lump, const uint8_t *data)
FirstChar = 0;
LastChar = 255; // This is to allow LoadTranslations to function. The way this is all set up really needs to be changed.
GlobalKerning = 0;
translateUntranslated = true;
LastChar = 0x2122;
// Move the Windows-1252 characters to their proper place.

View file

@ -103,6 +103,13 @@ FFont *V_GetFont(const char *name, const char *fontlumpname)
if (font) return font;
}
// This is only temporary until virtual fonts get implemented
if (!stricmp(name, "BIGFONT"))
{
font = FFont::FindFont("BIGFONT15");
if (font) return font;
}
int lump = -1;
int folderfile = -1;

View file

@ -127,6 +127,7 @@ public:
char GetCursor() const { return Cursor; }
void SetCursor(char c) { Cursor = c; }
void SetKerning(int c) { GlobalKerning = c; }
void SetHeight(int c) { FontHeight = c; }
bool NoTranslate() const { return noTranslate; }
virtual void RecordAllTextureColors(uint32_t *usedcolors);
void CheckCase();
@ -145,16 +146,16 @@ protected:
void ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height, const DVector2 &Scale);
EFontType Type = EFontType::Unknown;
FName AltFontName = NAME_None;
int FirstChar, LastChar;
int SpaceWidth;
int FontHeight;
int AsciiHeight = 0;
int GlobalKerning;
int TranslationType = 0;
int Displacement = 0;
int16_t MinLum = -1, MaxLum = -1;
char Cursor;
bool noTranslate = false;
bool translateUntranslated;
bool MixedCase = false;
bool forceremap = false;
struct CharData
@ -164,7 +165,6 @@ protected:
};
TArray<CharData> Chars;
TArray<int> Translations;
uint8_t PatchRemap[256];
int Lump;
FName FontName = NAME_None;

View file

@ -59,11 +59,8 @@ int gScreenTilt;
FFont* DigiFont;
void FontSet(int id, int tile, int space)
FFont* FontSet(const char* name, int tile, int space)
{
if (id < 0 || id >= kFontNum || tile < 0 || tile >= kMaxTiles)
return;
GlyphSet glyphs;
for (int i = 1; i < 96; i++)
{
@ -75,12 +72,14 @@ void FontSet(int id, int tile, int space)
}
}
const char *names[] = { "smallfont", "bigfont", "gothfont", "smallfont2", "digifont"};
const char *defs[] = { "defsmallfont", "defbigfont", nullptr, "defsmallfont2", nullptr};
FFont ** ptrs[] = { &SmallFont, &BigFont, nullptr, &SmallFont2, &DigiFont};
auto fnt = new ::FFont(names[id], nullptr, defs[id], 0, 0, 0, 0, tileWidth(tile), false, false, false, &glyphs);
auto fnt = V_GetFont(name);
if (!fnt)
{
fnt = new ::FFont(name, nullptr, nullptr, 0, 0, 0, 0, tileWidth(tile), false, false, false, &glyphs);
fnt->SetKerning(space);
if (ptrs[id]) *ptrs[id] = fnt;
}
return fnt;
}
void viewBackupView(int nPlayer)
@ -165,11 +164,16 @@ extern int dword_172CE0[16][3];
void viewInit(void)
{
Printf("Initializing status bar\n");
FontSet(0, 4096, 0);
FontSet(1, 4192, 1);
FontSet(2, 4288, 1);
FontSet(3, 4384, 1);
FontSet(4, 4480, 0);
FontSet("tilesmallfont", 4096, 0);
FontSet("tilebigfont", 4192, 1);
FontSet("gothfont", 4288, 1);
SmallFont2 = FontSet("smallfont2", 4384, 1);
DigiFont = FontSet("digifont", 4480, 0);
BigFont = V_GetFont("BIGFONT");
SmallFont = V_GetFont("SMALLFONT");
lensdata = fileSystem.LoadFile("lens.dat");
assert(lensdata.Size() == kLensSize * kLensSize * sizeof(int));

View file

@ -55,6 +55,8 @@ void InitFonts_d()
{
GlyphSet fontdata;
if (!V_GetFont("TileSmallFont"))
{
// Small font
for (int i = 0; i < 95; i++)
{
@ -66,11 +68,14 @@ void InitFonts_d()
tile->SetOffsetsNotForFont();
}
}
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 5, false, false, false, &fontdata);
new ::FFont("TileSmallFont", nullptr, nullptr, 0, 0, 0, -1, 5, false, false, false, &fontdata);
fontdata.Clear();
}
// Big font
if (!V_GetFont("TileBigFont"))
{
// This font is VERY messy...
fontdata.Insert('_', tileGetTexture(BIGALPHANUM - 11));
fontdata.Insert('-', tileGetTexture(BIGALPHANUM - 11));
@ -92,9 +97,13 @@ void InitFonts_d()
GlyphSet::Iterator it(fontdata);
GlyphSet::Pair* pair;
while (it.NextPair(pair)) pair->Value->SetOffsetsNotForFont();
BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, 5, false, false, false, &fontdata);
new ::FFont("TileBigFont", nullptr, nullptr, 0, 0, 0, -1, 5, false, false, false, &fontdata);
fontdata.Clear();
}
SmallFont2 = V_GetFont("SmallFont2");
if (!SmallFont2)
{
// Tiny font
for (int i = 0; i < 95; i++)
{
@ -107,10 +116,14 @@ void InitFonts_d()
}
}
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, 3, false, false, false, &fontdata);
SmallFont2 = new ::FFont("SmallFont2", nullptr, nullptr, 0, 0, 0, -1, 3, false, false, false, &fontdata);
SmallFont2->SetKerning(1);
fontdata.Clear();
}
IndexFont = V_GetFont("IndexFont");
if (!IndexFont)
{
// SBAR index font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE0 + i));
fontdata.Insert(':', tileGetTexture(THREEBYFIVE0 + 10));
@ -118,18 +131,27 @@ void InitFonts_d()
fontdata.Insert('%', tileGetTexture(MINIFONT + '%' - '!'));
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
GlyphSet::Iterator iti(fontdata);
GlyphSet::Pair* pair;
while (iti.NextPair(pair)) pair->Value->SetOffsetsNotForFont();
IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
}
DigiFont = V_GetFont("DigiFont");
if (!DigiFont)
{
// digital font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(DIGITALNUM + i));
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
GlyphSet::Iterator itd(fontdata);
GlyphSet::Pair* pair;
while (itd.NextPair(pair)) pair->Value->SetOffsetsNotForFont();
DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
}
// Todo: virtualize this;
BigFont = V_GetFont("BIGFONT");
SmallFont = V_GetFont("SMALLFONT");
}

View file

@ -55,6 +55,8 @@ void InitFonts_r()
{
GlyphSet fontdata;
if (!V_GetFont("TileSmallFont"))
{
// Small font
for (int i = 0; i < 95; i++)
{
@ -65,12 +67,15 @@ void InitFonts_r()
tile->SetOffsetsNotForFont();
}
}
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 10, false, false, false, &fontdata);
auto SmallFont = new ::FFont("TileSmallFont", nullptr, nullptr, 0, 0, 0, -1, 10, false, false, false, &fontdata);
SmallFont->SetKerning(2);
fontdata.Clear();
}
// Big font
if (!V_GetFont("TileBigFont"))
{
// This font is VERY messy...
fontdata.Insert('_', tileGetTexture(BIGALPHANUM - 11));
fontdata.Insert('-', tileGetTexture(BIGALPHANUM - 11));
@ -91,10 +96,14 @@ void InitFonts_r()
GlyphSet::Iterator it(fontdata);
GlyphSet::Pair* pair;
while (it.NextPair(pair)) pair->Value->SetOffsetsNotForFont();
BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, 10, false, false, false, &fontdata);
auto BigFont = new ::FFont("TileBigFont", nullptr, nullptr, 0, 0, 0, -1, 10, false, false, false, &fontdata);
BigFont->SetKerning(6);
fontdata.Clear();
}
SmallFont2 = V_GetFont("SmallFont2");
if (!SmallFont2)
{
// Tiny font
for (int i = 0; i < 95; i++)
{
@ -103,10 +112,14 @@ void InitFonts_r()
fontdata.Insert('!' + i, tile);
}
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, 6, false, false, false, &fontdata);
SmallFont2 = new ::FFont("SmallFont2", nullptr, nullptr, 0, 0, 0, -1, 6, false, false, false, &fontdata);
SmallFont2->SetKerning(2);
fontdata.Clear();
}
IndexFont = V_GetFont("IndexFont");
if (!IndexFont)
{
// SBAR index font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE + i));
fontdata.Insert(':', tileGetTexture(THREEBYFIVE + 10));
@ -116,11 +129,19 @@ void InitFonts_r()
IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
}
DigiFont = V_GetFont("DigiFont");
if (!DigiFont)
{
// digital font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(DIGITALNUM + i));
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
}
BigFont = V_GetFont("BIGFONT");
SmallFont = V_GetFont("SMALLFONT");
}

View file

@ -57,8 +57,9 @@ BEGIN_PS_NS
void InitFonts()
{
GlyphSet fontdata;
fontdata.Insert(127, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
if (!V_GetFont("TileSmallFont"))
{
for (int i = 0; i < 26; i++)
{
fontdata.Insert('A' + i, tileGetTexture(3522 + i));
@ -79,12 +80,15 @@ void InitFonts()
GlyphSet::Iterator it(fontdata);
GlyphSet::Pair* pair;
while (it.NextPair(pair)) pair->Value->SetOffsetsNotForFont();
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 4, false, false, false, &fontdata);
auto SmallFont = new ::FFont("TileSmallFont", nullptr, nullptr, 0, 0, 0, -1, 4, false, false, false, &fontdata);
SmallFont->SetKerning(1);
SmallFont->SetHeight(11); // FFont calculates a bad value for this.
fontdata.Clear();
}
fontdata.Insert(127, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
SmallFont2 = V_GetFont("SmallFont2");
if (!SmallFont2)
{
for (int i = 0; i < 26; i++)
{
fontdata.Insert('A' + i, tileGetTexture(3624 + i));
@ -103,9 +107,15 @@ void InitFonts()
fontdata.Insert('?', tileGetTexture(3652));
fontdata.Insert(127, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
GlyphSet::Iterator it2(fontdata);
GlyphSet::Pair* pair;
while (it2.NextPair(pair)) pair->Value->SetOffsetsNotForFont();
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, 4, false, false, false, &fontdata);
SmallFont2 = new ::FFont("SmallFont2", nullptr, nullptr, 0, 0, 0, -1, 4, false, false, false, &fontdata);
SmallFont2->SetKerning(1);
}
BigFont = V_GetFont("BIGFONT");
SmallFont = V_GetFont("SMALLFONT");
}

View file

@ -49,6 +49,8 @@ void InitFonts()
{
GlyphSet fontdata;
if (!V_GetFont("TileSmallFont"))
{
// Small font
for (int i = 0; i < 95; i++)
{
@ -59,8 +61,13 @@ void InitFonts()
tile->SetOffsetsNotForFont();
}
}
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 4, false, false, false, &fontdata);
new ::FFont("TileSmallFont", nullptr, nullptr, 0, 0, 0, -1, 4, false, false, false, &fontdata);
fontdata.Clear();
}
SmallFont2 = V_GetFont("SmallFont2");
if (!SmallFont2)
{
// Tiny font
for (int i = 0; i < 95; i++)
@ -72,8 +79,12 @@ void InitFonts()
tile->SetOffsetsNotForFont();
}
}
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, 4, false, false, false, &fontdata);
SmallFont2 = new ::FFont("SmallFont2", nullptr, nullptr, 0, 0, 0, -1, 4, false, false, false, &fontdata);
fontdata.Clear();
}
if (!V_GetFont("TileBigFont"))
{
const int FONT_LARGE_ALPHA = 3706;
const int FONT_LARGE_DIGIT = 3732;
@ -98,8 +109,13 @@ void InitFonts()
}
}
BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, 10, false, false, false, &fontdata);
auto BigFont = new ::FFont("TileBigFont", nullptr, nullptr, 0, 0, 0, -1, 10, false, false, false, &fontdata);
BigFont->SetKerning(1);
}
BigFont = V_GetFont("BIGFONT");
SmallFont = V_GetFont("SMALLFONT");
}
//---------------------------------------------------------------------------

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more