How can I increase gamma level of texts?

I have an old juce program that uses juce 1.46. It has a modification to glyph rendering that changes alpha level like below;

        forcedinline void handleEdgeTablePixel (const int x, const int alphaLevel) const throw()
        {
            lineStart [x] = (uint8) gammaCorrectTable[alphaLevel];
        }

        forcedinline void handleEdgeTableLine (const int x, int width, const int alphaLevel) const throw()
        {
            uint8* d = lineStart + x;

            while (--width >= 0)
                *d++ = (uint8) gammaCorrectTable[alphaLevel];
        }

I need to do it in new JUCE. I tried to do some modification in EdgeTableFillers::SolidColour like below;

        forcedinline void handleEdgeTablePixel (int x, int alphaLevel) const noexcept
        {
            if (replaceExisting)
                getPixel (x)->set (sourceColour);
            else
                getPixel (x)->blend (sourceColour, (uint32) gammaCorrectTable[alphaLevel]);
        }

but I didnt get same results. I noticed EdgeTableFillers::SolidColour used by other things too.
I need a simple settings/modification to increase gamma level of texts.

As a test I changed SolidColour::handleEdgeTablePixel

        forcedinline void handleEdgeTablePixel (int x, int alphaLevel) const noexcept
        {
            alphaLevel = 255;

            if (replaceExisting)
                getPixel (x)->set (sourceColour);
            else
                getPixel (x)->blend (sourceColour, (uint32) alphaLevel);
        }

This resulted in very chunky text

image

so it seems that is the correct place to make the modification to text anti-aliasing that you require.

note that the JUCE ‘blend’ method is not gamma-correct because it performs the blend in the sRGB (compressed) colorspace. This results in slighty jaggy results. ideally you would gamma-correct both pixels before performing the blend, then un-convert the result.

Top is standard JUCE renderer, bottom is gamma correct rendering…

image

2 Likes