Slate Measure text wrong scale in 4k screen

Hi Guys
I am a bit lost here, I am trying to mesure the text size of a custom widget I am working on, because I want to draw something else in top of it.
Apparently is not working in my 4k screen, but in a regular fullHD screen is working well, I got the right resolution.

this is the way I am using:



    FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
    float LineWeight = FontMeasureService->Measure("Hello", TextStyle->Font).X;


I guess I have to divide that for some DPI scale factor, but I cannot find the thing, does someone know what’s that value?

Thanks guys

Yes, there is DPI scaling involved. Here is the answer hub on how to get the current DPI scale. https://answers.unrealengine.com/questions/120050/current-dpi-scaling.html

Hey Thanks I saw that but it did not work for me, instead I found it looking inside the code itself, finally you have to find the master SWindow for your widget like this:



TSharedPtr WidgetWindow = FSlateApplication::Get().FindWidgetWindow(this->AsShared());
    float DPIScale = 1;
    if (WidgetWindow.IsValid())
    {
        DPIScale = WidgetWindow->GetNativeWindow()->GetDPIScaleFactor();
    }

    FVector2D Position = FVector2D(OutSize.X, ((TextLocation.GetLineIndex() * LineHeight) - EditableTextLayout->GetScrollOffset().Y) + LineHeight);
    Position.X /= DPIScale;


Now I have my widget in the right position regardless of my screen size, kind of cool

I have posted here if someone is messing around with this

Cheers