Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Reimplement text contrast using greyscale dilation. #17511
Our current text contrast rendering cheats by drawing four copies of the text, offset in x/y. This looks ok when the offset is small relative to the pixel scale, but completely breaks on high DPI displays (e.g. using 150% UI scaling on a 200% DPI display):
This PR implements the feature properly, calculating contrast glyphs by applying a modified greyscale dilation operator. Wikipedia has a helpful animation demonstrating the process: https://en.wikipedia.org/wiki/Dilation_%28morphology%29#/media/File:Grayscale_Morphological_Dilation.gif. The implementation here uses a floating point structural element, which lets us blend out partially overlapping pixels instead of having harsh edges.
This produces the intended result (150% UI scaling on a 200% DPI display):
Now, this highlights that the default 2px contrast offset on
Required for #10382.
Updated. This will now require an entry in https://github.com/OpenRA/OpenRAModSDK/wiki/Update-notes:-hotfix-release-to-next-release about adding the new metric options.