GRAPHICS: MACGUI: Switch TTFMap to saner data structure not requiring global constructor

This commit is contained in:
Eugene Sandulenko 2024-05-12 15:23:30 +02:00
parent 3334871e3a
commit 5bd7b57282
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
3 changed files with 9 additions and 8 deletions

View File

@ -672,12 +672,12 @@ int MacFontManager::registerFontName(Common::String name, int preferredId) {
return id;
}
int MacFontManager::registerTTFFont(const Common::Array<TTFMap> &ttfList) {
int MacFontManager::registerTTFFont(const TTFMap ttfList[]) {
int defaultValue = 1;
int realId = 100;
auto checkId = [&](int id) {
for (auto &&i : ttfList) {
if (_fontInfo.contains(id + i.slant)) {
for (const TTFMap *i = ttfList; i->ttfName; i++) {
if (_fontInfo.contains(id + i->slant)) {
return true;
}
}
@ -687,9 +687,9 @@ int MacFontManager::registerTTFFont(const Common::Array<TTFMap> &ttfList) {
while (checkId(realId))
realId++;
for (auto &&i : ttfList) {
for (const TTFMap *i = ttfList; i->ttfName; i++) {
int id = realId;
Common::String name = i.ttfName;
Common::String name = i->ttfName;
if (name.empty()) {
if (defaultValue == 1)
@ -705,7 +705,7 @@ int MacFontManager::registerTTFFont(const Common::Array<TTFMap> &ttfList) {
int slant = 0;
id += slant | i.slant;
id += slant | i->slant;
FontInfo *info = new FontInfo;
info->name = name;

View File

@ -179,7 +179,7 @@ public:
void printFontRegistry(int debugLevel, uint32 channel);
int registerTTFFont(const Common::Array<Graphics::TTFMap> &ttfList);
int registerTTFFont(const Graphics::TTFMap ttfList[]);
int getFamilyId(int newId, int newSlant);

View File

@ -34,11 +34,12 @@
namespace GUI {
Common::Array<Graphics::TTFMap> ttfFamily = {
const Graphics::TTFMap ttfFamily[] = {
{"NotoSans-Regular.ttf", Graphics::kMacFontRegular},
{"NotoSans-Bold.ttf", Graphics::kMacFontBold},
{"NotoSerif-Italic.ttf", Graphics::kMacFontItalic},
{"NotoSerif-Bold-Italic.ttf", Graphics::kMacFontBold | Graphics::kMacFontItalic},
{nullptr, 0}
};
RichTextWidget::RichTextWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &text, const Common::U32String &tooltip)