- fixed: in order to ensure that all font characters are of texture type 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.
This commit is contained in:
Christoph Oelckers 2019-08-09 11:40:21 +02:00
parent afe4a45a76
commit 53c2d7e8d2
2 changed files with 15 additions and 9 deletions

View file

@ -318,10 +318,13 @@ 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) if (!noTranslate)
{ {
Chars[i].OriginalPic = pic;
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(pic->GetImage()), ""); Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(pic->GetImage()), "");
Chars[i].TranslatedPic->CopySize(pic); Chars[i].TranslatedPic->CopySize(pic);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
@ -329,7 +332,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
} }
else else
{ {
Chars[i].TranslatedPic = pic; Chars[i].TranslatedPic = Chars[i].OriginalPic;
} }
Chars[i].XMove = Chars[i].TranslatedPic->GetDisplayWidth(); 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); 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 = new FImageTexture(new FFontChar1(pic->GetImage()), "");
Chars[i].TranslatedPic->CopySize(pic); Chars[i].TranslatedPic->CopySize(pic);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
TexMan.AddTexture(Chars[i].OriginalPic);
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddTexture(Chars[i].TranslatedPic);
} }
Chars[i].XMove = width; Chars[i].XMove = width;

View file

@ -102,12 +102,12 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l
if (charlumps[i] != nullptr) if (charlumps[i] != nullptr)
{ {
// If texture is used as a sprite, do not set use type auto pic = charlumps[i];
// Changing it would break actors that use this sprite Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), "");
if (charlumps[i]->GetUseType() != ETextureType::Sprite) Chars[i].OriginalPic->SetUseType(ETextureType::FontChar);
charlumps[i]->SetUseType(ETextureType::FontChar); Chars[i].OriginalPic->CopySize(pic);
TexMan.AddTexture(Chars[i].OriginalPic);
Chars[i].OriginalPic = charlumps[i];
if (!noTranslate) if (!noTranslate)
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1 (charlumps[i]->GetImage()), ""); Chars[i].TranslatedPic = new FImageTexture(new FFontChar1 (charlumps[i]->GetImage()), "");