I have submitted something similar to this a long time ago, but this version is an entirely different approach...
We print some text overlaid onto the 3DView but quite often it does not contrast enough with the background and is hard to see. Change to the "2D Animation" workspace and you will see it does badly against the white background.
We are currently adding a contrasting shadow below the text, but that does not go far enough. It is (necessarily) blurry and low opacity. It adds to contrast best in the mid-range where it is not needed, far too much at one end of the brightness spectrum, and does nothing at the other.
This patch replaces the blurry shadow with a crisp outline. The strokes of the glyphs are expanded in each direction, without any increased advance, and then moved slightly left and down. This is done in a single pass. And then regular text is drawn over top:
It is isn't perfect - notice the incorrect left upper of the "d" - but works quite well for this purpose. It adds contrast nicely for both light and dark text.
The outline color is chosen to match the current background color then the desired text color is mixed to provide contrast with that outline color. The outline is printed at full opacity, so that you don't see it in normal circumstances. But it will come into play when you have anything that differs greatly from the background color. You only see the outline when it is needed.
Font colors are carefully mixed to remain differentiated yet retain the desired theme hue. Shown here with the Overlay "Measurements" enabled, current on left, patch on right:
This patch should always give better result than we get currently. Vastly better at the extremes, like when you have a white or black background with highly contrasting object colors.
This patch contains a lot of changes, but almost all are single-line changes where I had to pass the v3d around. Creating the text outline is only about 5 lines. Then just a few new functions of about 45 lines in total.





