To turn off antialiasing, all you have to do is change your sampler state to SamplerState.PointClamp
in your spriteBatch.Begin()
call. Here's a short code example:
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.AlphaBlend,
SamplerState.PointClamp,
null, null, null, null));
// Draw text here using DrawString
spriteBatch.End();
spriteBatch.Begin()
// Draw textures, etc
spriteBatch.End()
Alternatively to this, you can permanently set the SamplerState
of the graphics device to PointClamp
in your Initialize()
method with the following code (this should work in any method that is only called once, maybe even the constructor):
graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
This way, you could use the normal spriteBatch.Begin()
call with no parameters. Note that this method would apply SamplerState.PointClamp to everything that you draw, not just text
References:
Here's the reference for XNA's SamplerState, which should be the same as MonoGame's: https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.samplerstate_fields%28v=xnagamestudio.40%29.aspx
Behind the scenes when actually drawing, SamplerState.PointClamp actually evaluates to:
Filter = TextureFilter.Point,
AddressU = TextureAddressMode.Clamp,
AddressV = TextureAddressMode.Clamp,
AddressW = TextureAddressMode.Clamp,
(according to the documentation)
Notes:
Another possibility to disable antialiasing would be to change this graphics device setting:
Game1.GraphicsDevice.RenderState.MultiSampleAntiAlias = false;
SamplerState.PointClamp
in your SpriteBatch.Begin? \$\endgroup\$