fix fallback font broken when using MSDF
This commit is contained in:
@@ -52,6 +52,10 @@ void Font::GetCharacter(Char c, FontCharacterEntry& result, bool enableFallback)
|
|||||||
for (int32 fallbackIndex = 0; fallbackIndex < FallbackFonts.Count(); fallbackIndex++)
|
for (int32 fallbackIndex = 0; fallbackIndex < FallbackFonts.Count(); fallbackIndex++)
|
||||||
{
|
{
|
||||||
FontAsset* fallbackFont = FallbackFonts.Get()[fallbackIndex].Get();
|
FontAsset* fallbackFont = FallbackFonts.Get()[fallbackIndex].Get();
|
||||||
|
if (fallbackFont && _asset->GetOptions().RasterMode == FontRasterMode::MSDF)
|
||||||
|
{
|
||||||
|
fallbackFont = fallbackFont->GetMSDF();
|
||||||
|
}
|
||||||
if (fallbackFont && fallbackFont->ContainsChar(c))
|
if (fallbackFont && fallbackFont->ContainsChar(c))
|
||||||
{
|
{
|
||||||
fallbackFont->CreateFont(GetSize())->GetCharacter(c, result, enableFallback);
|
fallbackFont->CreateFont(GetSize())->GetCharacter(c, result, enableFallback);
|
||||||
|
|||||||
@@ -155,6 +155,22 @@ FontAsset* FontAsset::GetItalic()
|
|||||||
return _virtualItalic;
|
return _virtualItalic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FontAsset* FontAsset::GetMSDF()
|
||||||
|
{
|
||||||
|
ScopeLock lock(Locker);
|
||||||
|
if (_options.RasterMode == FontRasterMode::MSDF)
|
||||||
|
return this;
|
||||||
|
if (!_virtualMSDF)
|
||||||
|
{
|
||||||
|
_virtualMSDF = Content::CreateVirtualAsset<FontAsset>();
|
||||||
|
_virtualMSDF->Init(_fontFile);
|
||||||
|
auto options = _options;
|
||||||
|
options.RasterMode = FontRasterMode::MSDF;
|
||||||
|
_virtualMSDF->SetOptions(options);
|
||||||
|
}
|
||||||
|
return _virtualMSDF;
|
||||||
|
}
|
||||||
|
|
||||||
bool FontAsset::Init(const BytesContainer& fontFile)
|
bool FontAsset::Init(const BytesContainer& fontFile)
|
||||||
{
|
{
|
||||||
ScopeLock lock(Locker);
|
ScopeLock lock(Locker);
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ private:
|
|||||||
Array<Font*, InlinedAllocation<32>> _fonts;
|
Array<Font*, InlinedAllocation<32>> _fonts;
|
||||||
AssetReference<FontAsset> _virtualBold;
|
AssetReference<FontAsset> _virtualBold;
|
||||||
AssetReference<FontAsset> _virtualItalic;
|
AssetReference<FontAsset> _virtualItalic;
|
||||||
|
AssetReference<FontAsset> _virtualMSDF;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -180,6 +181,12 @@ public:
|
|||||||
/// <returns>The virtual font or this.</returns>
|
/// <returns>The virtual font or this.</returns>
|
||||||
API_FUNCTION() FontAsset* GetItalic();
|
API_FUNCTION() FontAsset* GetItalic();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the MSDF version of the font. Returns itself or creates a new virtual font asset using this font but rasterized with MSDF.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The virtual font or this.</returns>
|
||||||
|
API_FUNCTION() FontAsset* GetMSDF();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the font with a custom font file data.
|
/// Initializes the font with a custom font file data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user