From 53c2d7e8d2022a9dcddfccb04f6ab31731d8e5a9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Aug 2019 11:40:21 +0200 Subject: [PATCH] - 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. --- src/gamedata/fonts/font.cpp | 14 ++++++++++---- src/gamedata/fonts/specialfont.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/gamedata/fonts/font.cpp b/src/gamedata/fonts/font.cpp index b3de95197..e7ec668fa 100644 --- a/src/gamedata/fonts/font.cpp +++ b/src/gamedata/fonts/font.cpp @@ -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) { - Chars[i].OriginalPic = pic; Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(pic->GetImage()), ""); Chars[i].TranslatedPic->CopySize(pic); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); @@ -329,7 +332,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla } 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 &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; diff --git a/src/gamedata/fonts/specialfont.cpp b/src/gamedata/fonts/specialfont.cpp index c87c49241..da0756899 100644 --- a/src/gamedata/fonts/specialfont.cpp +++ b/src/gamedata/fonts/specialfont.cpp @@ -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()), "");