Slate SDF font - fix for excessive signed distance spread when text is tiny

[CL 34502721 by viktor chlumsky in ue5-main branch]
This commit is contained in:
viktor chlumsky
2024-06-19 12:03:49 -04:00
parent 0c4a02b45d
commit 377db39495

View File

@@ -1206,15 +1206,15 @@ FSdfGlyphFontAtlasData FSlateFontCache::GetSdfGlyphFontAtlasData(const FShapedGl
const bool bPlaceholderOnly = InRasterizationMode == EFontRasterizationMode::SdfApproximation;
#if WITH_FREETYPE
const float TargetPpem = static_cast<float>(FreeTypeUtils::ComputeFontPixelSize(InShapedGlyph.FontFaceData->FontSize, InShapedGlyph.FontFaceData->FontScale));
const float TargetPpem = FMath::Max(1.f, static_cast<float>(FreeTypeUtils::ComputeFontPixelSize(InShapedGlyph.FontFaceData->FontSize, InShapedGlyph.FontFaceData->FontScale)));
#else
const float TargetPpem = 1.f/72.f*FontConstants::RenderDPI*InShapedGlyph.FontFaceData->FontSize*InShapedGlyph.FontFaceData->FontScale;
const float TargetPpem = FMath::Max(1.f, 1.f/72.f*static_cast<float>(FontConstants::RenderDPI)*InShapedGlyph.FontFaceData->FontSize*InShapedGlyph.FontFaceData->FontScale);
#endif
const float SdfPpem = static_cast<float>(InSdfSettings.GetClampedPpem());
const float Scale = TargetPpem/SdfPpem;
const float EmOutlineSize = FMath::RoundToFloat(InOutlineSettings.OutlineSize * InShapedGlyph.FontFaceData->FontScale)/TargetPpem;
float EmInnerSpread = FMath::Clamp(2.f/TargetPpem, 0.05f, 8.f);
float EmInnerSpread = FMath::Clamp(2.f/TargetPpem, 0.05f, 0.25f);
float EmOuterSpread = FMath::Min(EmInnerSpread + EmOutlineSize, 8.f);
FSlateSdfGenerator::ESdfType SdfType = FSlateSdfGenerator::ESdfType::MultichannelAndSimple;