Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Displays Corrupted on XSX/PS5 #28

Open
JOSKevinW opened this issue Jan 30, 2024 · 5 comments
Open

Font Displays Corrupted on XSX/PS5 #28

JOSKevinW opened this issue Jan 30, 2024 · 5 comments

Comments

@JOSKevinW
Copy link

We've recently integrated Cog into our Unreal Engine using 5.2.1. We've encountered the font looks corrupted when on the XSX and PS5 platforms; they look correct on Windows. When we increase the DpiScale, it still looks incorrect. Do you expect that this would work on these other platforms too?

@arnaud-jamin
Copy link
Owner

Hello,

I was not able to test on other platforms than PC. I do not have any devkit.

Sorry.

@arnaud-jamin
Copy link
Owner

Btw, the code handling the font in Cog is very small. Imgui is handling 99% of it.

@JOSKevinW
Copy link
Author

This appears to be addressed by replacing the texture loading code in FCogImguiContext::BuildFont.

It's also notable that the texture format is not PF_R8G8B8A8, it is 4 bytes per pixel, not 8.

`FontAtlasTexture = UTexture2D::CreateTransient(TextureWidth, TextureHeight);
FontAtlasTexture->UpdateResource();

auto SrcDataCleanup = [](uint8* Data) { delete[] Data; };

FUpdateTextureRegion2D* TextureRegion = new FUpdateTextureRegion2D(0, 0, 0, 0, TextureWidth, TextureHeight);
auto DataCleanup = [SrcDataCleanup](uint8* Data, const FUpdateTextureRegion2D* UpdateRegion)
{
	delete UpdateRegion;
};
FontAtlasTexture->UpdateTextureRegions(0, 1u, TextureRegion, BytesPerPixel * TextureWidth, BytesPerPixel, TextureDataRaw, DataCleanup);`

As a separate issue, Cog rendered on console is very small as opposed to PC. I adapted SCogImguiWidget::OnPaint's calculation of Transform to match what imGui's Unreal integration does. The original code only accounts for transform and not scale.

FSlateRenderTransform displayPosition(DrawData.DisplayPos); const FSlateRenderTransform& WidgetToScreen = AllottedGeometry.GetAccumulatedRenderTransform(); const FSlateRenderTransform Transform = FCogImguiHelper::RoundTranslation(displayPosition.Concatenate(WidgetToScreen));

@arnaud-jamin
Copy link
Owner

arnaud-jamin commented Feb 16, 2024

Thanks a lot for the research! Don't hesitate to make a pull request!

Sorry I didn't reply sooner, was too busy.

@JailbreakPapa
Copy link

This appears to be addressed by replacing the texture loading code in FCogImguiContext::BuildFont.

It's also notable that the texture format is not PF_R8G8B8A8, it is 4 bytes per pixel, not 8.

`FontAtlasTexture = UTexture2D::CreateTransient(TextureWidth, TextureHeight); FontAtlasTexture->UpdateResource();

auto SrcDataCleanup = [](uint8* Data) { delete[] Data; };

FUpdateTextureRegion2D* TextureRegion = new FUpdateTextureRegion2D(0, 0, 0, 0, TextureWidth, TextureHeight);
auto DataCleanup = [SrcDataCleanup](uint8* Data, const FUpdateTextureRegion2D* UpdateRegion)
{
	delete UpdateRegion;
};
FontAtlasTexture->UpdateTextureRegions(0, 1u, TextureRegion, BytesPerPixel * TextureWidth, BytesPerPixel, TextureDataRaw, DataCleanup);`

As a separate issue, Cog rendered on console is very small as opposed to PC. I adapted SCogImguiWidget::OnPaint's calculation of Transform to match what imGui's Unreal integration does. The original code only accounts for transform and not scale.

FSlateRenderTransform displayPosition(DrawData.DisplayPos); const FSlateRenderTransform& WidgetToScreen = AllottedGeometry.GetAccumulatedRenderTransform(); const FSlateRenderTransform Transform = FCogImguiHelper::RoundTranslation(displayPosition.Concatenate(WidgetToScreen));

Thanks for these fixes! we just started using cog and were wondering why fonts were messing up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants