Skip to content

Commit

Permalink
- font system fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed May 28, 2021
1 parent d445008 commit 22be26b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions source/common/fonts/font.cpp
Expand Up @@ -656,6 +656,10 @@ int FFont::GetLuminosity (uint32_t *colorsused, TArray<double> &Luminosity, int*

int FFont::GetColorTranslation (EColorRange range, PalEntry *color) const
{
// Single pic fonts do not set up their translation table and must always return 0.
if (Translations.Size() == 0) return 0;
assert(Translations.Size() == NumTextColors);

if (noTranslate)
{
PalEntry retcolor = PalEntry(255, 255, 255, 255);
Expand Down
11 changes: 11 additions & 0 deletions source/common/fonts/specialfont.cpp
Expand Up @@ -141,6 +141,17 @@ void FSpecialFont::LoadTranslations()
{
FFont::LoadTranslations();

bool empty = true;
for (auto& c : Chars)
{
if (c.OriginalPic != nullptr)
{
empty = false;
break;
}
}
if (empty) return; // Font has no characters.

bool needsnotrans = false;
// exclude the non-translated colors from the translation calculation
for (int i = 0; i < 256; i++)
Expand Down
7 changes: 5 additions & 2 deletions source/common/fonts/v_font.cpp
Expand Up @@ -714,13 +714,16 @@ static void CalcDefaultTranslation(FFont* base, int index)
{
int index = int(lum * 255);
remap[index] = GPalette.BaseColors[i];
remap[index].a = 255;
}
}

// todo: fill the gaps.
remap[0] = 0;
//remap[0] = 0;
int lowindex = 0;
int highindex = 1;
while (lowindex < 255 && remap[lowindex].a == 0) lowindex++;
lowindex++;
int highindex = lowindex + 1;

while (lowindex < 255)
{
Expand Down

0 comments on commit 22be26b

Please sign in to comment.