common: force the use of ttf loader for font data

Providing an incorrect mimetype or not specifying one
was not handled and resulted in data not being loaded
when loading the font from memory.
Now, the use of the TTF loader is enforced regardless
of the provided mimetype.
This commit is contained in:
Mira Grudzinska 2024-06-15 14:36:38 +02:00 committed by Hermet Park
parent 6544747e70
commit 6518f2e442

View file

@ -436,23 +436,22 @@ LoadModule* LoaderMgr::loader(const uint32_t *data, uint32_t w, uint32_t h, bool
//loads fonts from memory - loader is cached (regardless of copy value) in order to access it while setting font
LoadModule* LoaderMgr::loader(const char* name, const char* data, uint32_t size, const string& mimeType, bool copy)
LoadModule* LoaderMgr::loader(const char* name, const char* data, uint32_t size, TVG_UNUSED const string& mimeType, bool copy)
{
//TODO: add check for mimetype ?
if (auto loader = _findFromCache(name)) return loader;
if (auto loader = _findByType(mimeType)) {
//function is dedicated for ttf loader (the only supported font loader)
auto loader = new TtfLoader;
if (loader->open(data, size, "", copy)) {
loader->hashpath = strdup(name);
loader->pathcache = true;
ScopedLock lock(key);
_activeLoaders.back(loader);
return loader;
} else {
TVGLOG("LOADER", "The font data \"%s\" could not be loaded.", name);
delete(loader);
}
}
TVGLOG("LOADER", "The font data \"%s\" could not be loaded.", name);
delete(loader);
return nullptr;
}