title: Is it possible to define a precise font size when drawing text using GDI+?
body: <p>I'm using the following code to draw text on a bitmap :</p>
  
  <pre><code>using (Font font = new Font("Arial", 10.0f, FontStyle.Bold, GraphicsUnit.Point))
  {
      //draw the text
      graphics.DrawString("Some text", font, Brushes.White, rect, stringFormat);
  }
  </code></pre>
  
  <p>It works nice. Here is rendered text : </p>
  
  <p><img src="https://i.stack.imgur.com/7Z5or.png" alt="enter image description here"></p>
  
  <p>I want to make text a little bigger. If I set 11 as font size, here is what i get :</p>
  
  <p><img src="https://i.stack.imgur.com/zRllp.png" alt="enter image description here"></p>
  
  <p>It is too big for what I want.
  I tried 10.25, 10.5 and such but it gives same result as 10.</p>
  
  <p>I also try to set <code>GraphicsUnit</code> to <code>Pixel</code> but it behaves the same (no possibility to set custom font size).</p>
  
  <p>Here is my question : </p>
  
  <p><strong>When drawing text using GDI+ (C#), is there a possiblity to "fine tune" size of rendered text ?</strong> </p>
  
  <hr>
  
  <p>EDIT :
  more complete code snippet (as requested) :</p>
  
  <pre><code>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);
  
     //method 1
     StringFormat stringFormat = new StringFormat();
     stringFormat.Alignment = StringAlignment.Center;
     stringFormat.LineAlignment = StringAlignment.Center;
     graphics.DrawString("Some text", font, Brushes.White, rect, stringFormat);
  
     //method 2
     TextFormatFlags flags = TextFormatFlags.HorizontalCenter |
         TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak;       
     TextRenderer.DrawText(graphics, "Some text", font, rect, Color.White, flags);
  
     bitmap.Save(stream, ImageFormat.Png);          
  }
  </code></pre>