mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Android: Attempt to load legacy emoji font if fallback selects incompatible font
This commit is contained in:
parent
b42fd71c9e
commit
9c1c61a06e
1 changed files with 27 additions and 9 deletions
|
|
@ -316,18 +316,36 @@ private:
|
|||
if (cache == nullptr)
|
||||
return {}; // Perhaps we're shutting down
|
||||
|
||||
return cache->get ({ matchedFile, (int) matchedIndex }, [] (const TypefaceFileAndIndex& info) -> Typeface::Ptr
|
||||
{
|
||||
FileInputStream stream { info.file };
|
||||
return cache->get ({ matchedFile, (int) matchedIndex }, &loadCompatibleFont);
|
||||
}
|
||||
|
||||
if (! stream.openedOk())
|
||||
return {};
|
||||
static Typeface::Ptr loadCompatibleFont (const TypefaceFileAndIndex& info)
|
||||
{
|
||||
FileInputStream stream { info.file };
|
||||
|
||||
MemoryBlock mb;
|
||||
stream.readIntoMemoryBlock (mb);
|
||||
if (! stream.openedOk())
|
||||
return {};
|
||||
|
||||
return fromMemory (DoCache::no, { static_cast<const std::byte*> (mb.getData()), mb.getSize() }, (unsigned int) info.index);
|
||||
});
|
||||
MemoryBlock mb;
|
||||
stream.readIntoMemoryBlock (mb);
|
||||
|
||||
auto result = fromMemory (DoCache::no,
|
||||
{ static_cast<const std::byte*> (mb.getData()), mb.getSize() },
|
||||
(unsigned int) info.index);
|
||||
|
||||
if (result == nullptr)
|
||||
return {};
|
||||
|
||||
const auto tech = result->getColourGlyphFormats();
|
||||
const auto hasSupportedColours = (tech & (colourGlyphFormatCOLRv0 | colourGlyphFormatBitmap)) != 0;
|
||||
|
||||
// If the font only uses unsupported colour technologies, assume it's the system emoji font
|
||||
// and try to return a compatible version of the font
|
||||
if (tech != 0 && ! hasSupportedColours)
|
||||
if (auto fallback = from ({ "NotoColorEmojiLegacy", FontValues::defaultFontHeight, Font::plain }); fallback != nullptr)
|
||||
return fallback;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static Typeface::Ptr fromMemory (DoCache cache, Span<const std::byte> blob, unsigned int index = 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue