I think this may already be addressed in SDL 3.4.0, since you added a new SDL_SCALEMODE_PIXELART. When I change the palette of a pixel art surface that I convert to a texture, in this case a font with an opaque background, based on the colors both the top y and bottom y coordinate of the tiles rendered will change by one pixel. The x coordinates don’t change at all. I think this probably has to do with how SDL_SCALEMODE_NEAREST works. I have my renderer set to 320 by 320 pixels with integer scaling.
Here’s a sample of the function used to render the font, in case my code is the problem:
The text is in the same position, but the background box surrounding it changes by one pixel. In the second picture, the top line moves up one pixel compared to the first picture, and in the third picture, the bottom line moves up one pixel compared to the second picture. I tried changing from SDL 3.2.10 to SDL 3.2.14, and the bug is still present.
The weird part is that my rects aren’t changing, just the palette of the texture used. That’s why I was saying before it might be the nearest neighbor scaling, and the new pixel art scaling in SDL 3.4.0 will fix it.
I think I see what’s happening, and it’s not a software issue, but rather an optical illusion.
I accept that I might be wrong, you might be describing something else, but try this decaf87:
Right-Click the image that you posted, and hit open in new tab. Then in the new tab, hit “ctrl +” to zoom in. Do this until it won’t zoom in any further.
Now count the pixels that are concerning you. (Or try using the mouse cursor as a measuring tool)
If the image seems correct when fully zoomed in, here’s the reasoning:
Yellow stimulates both red and green cones in our eyes, so we perceive it with better contrast than most other colors. Blue is a very low contrast color because the blue detecting cones make up less than 5% of all the cones in our eye.
In essence we get high resolution in yellow and low resolution when dealing with blue.
This is not the case. I do agree that it looks like there is a bigger margin between the text and the edge of the yellow box but I think that might just be because the contrast between the yellow and black colours is so strong.