Light UI fonts look wrong when scaling

I fixed a bug yesterday where FreeType was sometimes failing to scale advances for glyphs, this might be the same issue.

If you have a source build of 4.16 you could try out the fix to confirm?

In Engine\Source\Runtime\SlateCore\Private\Fonts\FontCacheFreeType.cpp FFreeTypeAdvanceCache::FindOrCache

replace:

FreeTypeUtils::ApplySizeAndScale(InFace, InFontSize, InFontScale);

with:

FreeTypeUtils::ApplySizeAndScale(InFace, InFontSize, 1.0f);

after:

if (Error == 0)
{

add

// We apply our own scaling as FreeType doesn't always produce the correct results for all fonts when applying the scale via the transform matrix
const FT_Long FixedFontScale = FreeTypeUtils::ConvertPixelTo16Dot16<FT_Long>(InFontScale);
OutCachedAdvance = FT_MulFix(OutCachedAdvance, FixedFontScale);

Since switching to UE 4.16, all my UMG text blocks using the “Roboto Light” font look wrong when the UI is not shown at 1:1 scale (both in the UMG editor and in game). All other font styles (regular, italic etc.) look fine. I’ve attached an image illustrating the issue with a regular font TextBlock above and a light font TextBlock below:

139152-umg+font+scaling.png

I’m not currently on a source build but I could switch if it helps clearing up the issue.

Ok I can confirm that this fixes it, thanks a lot for the quick reaction! Will the fix end up in 16.1?

I missed the 4.16.1 cutoff, but it’s in the 4.16 release branch now so will be part of 4.16.2.

I fixed the issue by upgrading the custom fonts.

Open your font asset, upgrade it and create one or several font faces (depending on your font).

Then in font face assets that were created adjust the hinting algorithm, for me ‘Auto’ worked out fine.