Skip to content
Permalink
Browse files

- fixed: in order to ensure that all font characters are of texture t…

…ype FontChar it is necessary to clone the texture instead of changing its use type.

The use type is being used for texture lookup, so changing this alters the texture lookup rules and may cause return of incorrect textures.
This also ensures that context depending upscaling rules get used, because FontChars are separate from regular textures.
  • Loading branch information...
coelckers committed Aug 9, 2019
1 parent afe4a45 commit 53c2d7e8d2022a9dcddfccb04f6ab31731d8e5a9
Showing with 15 additions and 9 deletions.
  1. +10 −4 src/gamedata/fonts/font.cpp
  2. +5 −5 src/gamedata/fonts/specialfont.cpp
@@ -318,18 +318,21 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
}
}

pic->SetUseType(ETextureType::FontChar);
Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), "");
Chars[i].OriginalPic->SetUseType(ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic);
TexMan.AddTexture(Chars[i].OriginalPic);

if (!noTranslate)
{
Chars[i].OriginalPic = pic;
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(pic->GetImage()), "");
Chars[i].TranslatedPic->CopySize(pic);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
TexMan.AddTexture(Chars[i].TranslatedPic);
}
else
{
Chars[i].TranslatedPic = pic;
Chars[i].TranslatedPic = Chars[i].OriginalPic;
}

Chars[i].XMove = Chars[i].TranslatedPic->GetDisplayWidth();
@@ -444,10 +447,13 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height

auto b = pic->Get8BitPixels(false);

Chars[i].OriginalPic = pic;
Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), "");
Chars[i].OriginalPic->SetUseType(ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic);
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(pic->GetImage()), "");
Chars[i].TranslatedPic->CopySize(pic);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
TexMan.AddTexture(Chars[i].OriginalPic);
TexMan.AddTexture(Chars[i].TranslatedPic);
}
Chars[i].XMove = width;
@@ -102,12 +102,12 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l

if (charlumps[i] != nullptr)
{
// If texture is used as a sprite, do not set use type
// Changing it would break actors that use this sprite
if (charlumps[i]->GetUseType() != ETextureType::Sprite)
charlumps[i]->SetUseType(ETextureType::FontChar);
auto pic = charlumps[i];
Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), "");
Chars[i].OriginalPic->SetUseType(ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic);
TexMan.AddTexture(Chars[i].OriginalPic);

Chars[i].OriginalPic = charlumps[i];
if (!noTranslate)
{
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1 (charlumps[i]->GetImage()), "");

0 comments on commit 53c2d7e

Please sign in to comment.
You can’t perform that action at this time.