[BUG] FCanvasTextItem::Draw - outline behind shadow

I’ve implemented a custom HUD class in order to draw text with outline and shadow (the “Draw Text” blueprint function does not have these parameters).

This is my (unfinished) function:

void DrawFancyText(const FString& Text, FVector2D Position, UFont* TextFont, FVector2D FontScale, FColor TextColor){
	float XL, YL;

	Canvas->TextSize(TextFont, Text, XL, YL);
	const float X = Canvas->ClipX / 2.0f - XL / 2.0f + Position.X;
	const float Y = Canvas->ClipY / 2.0f - YL / 2.0f + Position.Y;

	FCanvasTextItem TextItem(FVector2D(X, Y), FText::FromString(Text), TextFont, FLinearColor(TextColor));
	TextItem.bOutlined = true;
	TextItem.OutlineColor = FLinearColor(0.5, 0.4, 0.7);
	TextItem.EnableShadow(FLinearColor::Black, FVector2D{ 2 * FontScale.X, 2 * FontScale.Y });

	TextItem.Scale = FontScale;


I noticed that the outline is drawn behind the shadow, like so:


I traced this back to the [FCanvasTextItem::Draw][2] function which draws the outline first, and then the shadow on top of it. I’m pretty sure this is not the intended behavior.

[Here][3] is a project reproducing this issue.

Hello Astronovice,

Thank you for taking the time to report this issue. I believe you’re correct in saying that this is a bug and I would like to report it. I will need a reproduction case however and it would be very helpful if you could provide me with such, as it would take quite a bit of time to attempt to recreate your custom function and everything around it. Could you upload the existing project or a sample project with this problem inside of it? If you wish for it to remain private you can send it to me in a Private Message on the [forums][1].

Hello, and thanks for replying.

I’ll create a small project that reproduces the issue, and add it to the original post. I’ve also opened a pull request on the github repository since I believe the fix is simple. Does it have any chance of being reviewed or even merged?

Thanks again.

I can guarantee that it will be reviewed at some point, but as to when it’ll be and if it’ll be merged, I’m not sure. If the change fixes the issue and doesn’t pose any others, it will be merged. Since you made a Pull Request, it’s already logged in our database so there isn’t much reason in me placing a bug in for it. If you wish however, I can still attach the project that you provide to give a repro case for it.

Thanks again for the quick reply. Here is a project reproducing the issue: .com/alexpana/ue_hud_canvas_bug