How to change spritefont sizes without anit-aliasing

I’m using a custom font for a small game in MonoGame, and it is made on an 8x8 grid, so I have to scale it to make it bigger. Currently I am scaling the scale in the spriteBatch.Begin() method, but this means I have to call the End() and Begin() method for every font size I want, which is very inefficient. I found a solution online to prevent anti-aliasing for the Begin() method, but what I want to know is: is there a way to prevent anti-aliasing when scaling by changing the XML file of the spritefont? Any help would be appreciated! :smiley:

You can pass the scale you want to draw at to the SpriteBatch.DrawString method. You will want to enable point sampling and use whole numbers as the scaling factor. To use point sampling you can pass SamplerState.PointSampling to SpriteBatch.Begin as the sampler state.

This is not anti alias by the way. Anti alias is for geometry but SpriteBatch only renders rectangles. You just don’t want that colors from the texture are interpolated, which means you have to change from linear sampling to point sampling.

EDIT: I said you should pass the scale to SpriteBatch.Begin, but I meant to SpriteBatch.DrawString!

1 Like

You can also change a monogame generated fonts size by editing the xml, (Opening up the spritefont within vs and look to the item labled size=).

For me, only SamplerState.PointClamp and SamplerState.PointWrap are available. Has the name changed?