I use the following code to draw text in a bitmap:
using (Font font = new Font("Arial", 10.0f, FontStyle.Bold, GraphicsUnit.Point)) {
It works well. The text is displayed here:
I want to make the text a little bigger. If I set 11 as the font size, here is what I get:
He is too big for what I want. I tried 10.25, 10.5 and such, but it gives the same result as 10.
I am also trying to set GraphicsUnit
on a Pixel
, but it behaves the same (there is no way to set my own font size).
Here is my question:
When drawing text using GDI + (C #), is it possible to "fine-tune" the size of the displayed text?
EDIT: a more complete code snippet (on request):
using (Bitmap bitmap = new Bitmap(width, height)) using (Graphics graphics = Graphics.FromImage(bitmap)) using (Font font = new Font("Arial", 10.0f, FontStyle.Bold, GraphicsUnit.Point)) { graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; Rectangle rect = new Rectangle(0, 0, width, height);
source share