Why does myTextRenderComponent fill the screen on my packaged game?

Hi, we were doing a test-package today, and realised that the TextRenderComponents we have on our 3d-HUD literally fills the screen:

6191-screenshot+2014-05-13+15.25.24.png

It seems to be something to do with it’s original scale, as when we scale the blueproint that owns these components, they scale with it as well (get even bigger). Is this a bug or something we’re doing wrong (it works fine in all preview-modes)?

//Thanks in Advance

Hey SkyInAPond -

Could you upload a screenshot of you HUD blueprints so we can try to reproduce and diagnose the issue for you?

Also take a glance at the Content Examples Blueprint_HUD level as this HUD uses a slightly different way of rendering out the HUD based on screen space which might work better for your goal.

Thanks

-Eric Ketchum

It is literally just a Pawn-blueprint, in which I’ve added a few TextRenderComponents (along with other objects, since the HUD is actually attached to the Pawn). I never set the size in the graph, only the text:

Hey SkyInAPond -

I have been working on trying to reproduce your issue and have been unsuccessful as of yet. I do want to check does any element within the Pawn class have a function which scales them? If you are willing, I would be happy to look at the actual uasset, but either way I will keep working on it.

-Eric Ketchum

Can I send it to you personally, I’d rather not have others accessing it? :stuck_out_tongue:

BTW, changing the original to about 5% of the original worked and got them back close to the correct size.

I understand. If you are able to fix it by just reducing the correct size it sounds like there could be a scale that is being applied somewhere in the assets chain. I noticed in you component screenshot you have multiple world size values for your text render objects, but the same X and Y scale. Is the world size how you are adjusting the scale or are you doing it through the Transform scaling?

Eric Ketchum

Indeed I am adjusting it via the World Size variable! Is this the wrong approach?

Hi SkyInAPond -

Not necessarily, but the scaling issue you are having is somewhere in the asset creation chain whether in import or a blueprint, you will have to track down any part in the chain where the text is changed and ensure that it is not also associated with a change in scale setting or font size change.

-Eric Ketchum

Ok, thank you very much! :wink:

This is really annoying. TextRenderComponent is useless after packaging. The text is 40 billion times larger in packaged games, and the characters are all wrong.

Hey MulleDK19 -

Have you looked into your asset creation chain as mentioned below? As a test you should be able to package Content Examples which has many text render components in and out of blueprints which should package correctly.

Thank You

Eric Ketchum

Now sure what you mean by creation chain.

But this has been a problem since the first UE4 release. It’s all TextRenderComponents in any project of any asset. But only after packaging.

Hey MulleDK19 -

By Creation Chain, I mean the process that you have in getting the text render component into your world, be it either through a blueprint of just placing the component directly into the level.

Just to confirm exact what you are saying, if you package Content Examples all Text Render Components increase in scale, or only projects you have created with text render components increase in scale?

Thank You

Eric Ketchum

It seems to work with the Content Examples. And trying to reproduce it on new projects has yielded no results.

I just know that every time I’ve tried to use the TextRenderComponent in any of my projects, they become oversized in the packaged game, and I have to make them tiny in the editor, to have them a reasonable size in the packaged game. It’s not based on scaling on any parents, or any calls that scales them. And I’d assume that would show in the editor if that was the case.

Recently I added a text render component to two different actors; my character, and a simple actor with just a mesh, and both were enormous in the packaged game. Furthermore, all the characters appeared as just squares, like ☐☐☐☐☐☐☐☐

Hey MulleDK19 -

This has to do with font setup when you first import it into the engine, since the engine treats fonts as a texture, some fonts will include pages and those pages will vary based on imported font size, larger font usually equals more pages. However, all of this should be visible in the Editor before packaging. And you are not doing anything more than spawning the text render component? I am happy to continue to look into this if you can send me a project in which this occurs and if you are using a custom (not engine specific) font I will need that as well. You can upload a zip here if small enough or upload to dropbox and post a link.

Thank You

Eric Ketchum

I’ve been having the same issue for a while now for my offline fonts (runtime fonts in UMG are fine). I’ve done some digging using the latest engine version, 4.7.6, and I think I have an answer.

The root of the problem seems to be that an offline font asset isn’t loaded into memory when an actor’s TextRenderComponent is being setup. For me, this happens only on Windows cooked/packaged builds (iOS doesn’t have this issue). Playing in the editor or playing a stand-alone instance through the editor avoids the issue. I suspect the offline font asset is already in memory at this point.

The TextRenderComponent has a property, InvDefaultSize, that is used in the render matrix calculations for the characters to display. Normally, this should be a small number (at WorldSize 26 this is 1.0/26.0, or 0.03846). However, in my cooked Windows builds, I was seeing this value as 1.0 when my breakpoint in AActor::BeingPlay was hit on the offending actor. Digging into the engine source, UTextRenderComponent will set InvDefaultSize to 1.0f in two scenarios:

  1. If the font’s GetMaxCharHeight() returns 1 (meaning the characters are 1 pixel tall in the texture sheet).

  2. If UTextRenderComponent::SetFont is called without a valid UFont pointer (TextRenderComponent.cpp, line 870). This is the most likely cause.

Only actors I placed in the level seem to have this issue. As a work-around, any actors that have a TextRenderComponent with a custom font should be spawned after the player has entered the level (I do this in my GameMode’s BeginPlay function). There’s a better solution out there (or one that may require a fix in the engine code), but this will at least get you around the problem in the meantime.

Hope this helps someone out there!

In case anyone else is running into this issue, I was able to fix this by making a minor change to the engine source in TextRenderComponent.cpp, thanks to the hints in vanzeipel’s post. As stated above it seems that InvDefaultSize isn’t correctly initialised in some situations (one of those being a text render component with a custom font in a standalone windows build). To fix, I added this small snippet to the bottom of UTextRenderComponent::PostLoad() :

		if (Font)
		{
			float LocalWorldSize = Font->GetMaxCharHeight();
			InvDefaultSize = 1.0f / LocalWorldSize;
		}

Hope that’s of use to someone!

Further to Tom’s fix…I’ve come across a case where even this doesn’t work because the PostLoad for the TextRenderComponent is called BEFORE the PostLoad for the Font (which initialises GetMaxCharHeight()).

IMHO the most robust solution is for GetMaxCharHeight to self-test and call CacheCharacterCountAndMaxCharHeight() if it’s uninitialised - but that still requires Tom’s fix to correctly set up the TextRenderComponents.