mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
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:
parent
6544747e70
commit
6518f2e442
1 changed files with 11 additions and 12 deletions
|
@ -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;
|
||||
}
|
Loading…
Add table
Reference in a new issue