use a more complete font did some primitive font substitution logic.

NotoSans was chosen because it contains all Latin, Cyrillic and Greek characters in one file.
To test the substitution the separate font files for Armenian and Georgian were also added, even though the languages have not been translated.
This commit is contained in:
Christoph Oelckers 2024-01-02 18:58:39 +01:00
commit f5c4964902
11 changed files with 104 additions and 21 deletions

View file

@ -12,19 +12,7 @@ void InitWidgetResources(const char* filename)
I_FatalError("Unable to open %s", filename);
}
std::vector<uint8_t> LoadWidgetFontData(const std::string& name)
{
auto lump = WidgetResources->FindEntry("widgets/poppins/poppins-regular.ttf");
if (lump == -1)
I_FatalError("Unable to find %s", name.c_str());
auto reader = WidgetResources->GetEntryReader(lump, FileSys::READER_SHARED);
std::vector<uint8_t> buffer(reader.GetLength());
reader.Read(buffer.data(), buffer.size());
return buffer;
}
std::vector<uint8_t> LoadWidgetImageData(const std::string& name)
static std::vector<uint8_t> LoadFile(const std::string& name)
{
auto lump = WidgetResources->FindEntry(name.c_str());
if (lump == -1)
@ -35,3 +23,32 @@ std::vector<uint8_t> LoadWidgetImageData(const std::string& name)
reader.Read(buffer.data(), buffer.size());
return buffer;
}
// This interface will later require some significant redesign.
std::vector<SingleFontData> LoadWidgetFontData(const std::string& name)
{
std::vector<SingleFontData> returnv;
if (!stricmp(name.c_str(), "notosans"))
{
returnv.resize(3);
returnv[2].fontdata = LoadFile("widgets/noto/notosans-regular.ttf");
returnv[0].fontdata = LoadFile("widgets/noto/notosansarmenian-regular.ttf");
returnv[1].fontdata = LoadFile("widgets/noto/notosansgeorgian-regular.ttf");
returnv[0].ranges.push_back(std::make_pair(0x531, 0x58f));
returnv[1].ranges.push_back(std::make_pair(0x10a0, 0x10ff));
returnv[1].ranges.push_back(std::make_pair(0x1c90, 0x1cbf));
returnv[1].ranges.push_back(std::make_pair(0x2d00, 0x2d2f));
// todo: load system CJK fonts here
return returnv;
}
returnv.resize(1);
std::string fn = "widgets/font/" +name + ".ttf";
returnv[0].fontdata = LoadFile(fn);
return returnv;
}
std::vector<uint8_t> LoadWidgetImageData(const std::string& name)
{
return LoadFile(name);
}