---
title: "Font..::.MeasureString Method "
canonical: https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Drawing_Font_MeasureString_1_bb3a7a4f.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# Font.MeasureString Method 
 
Gets the extent (both width and height) of the string draw by the [GdiGraphics.DrawString](https://www.graphicsmill.com/docs/gm5/O_T_Aurigma_GraphicsMill_Drawing_GdiGraphics_DrawString.htm.md) method.
 
**Namespace:** [Aurigma.GraphicsMill.Drawing](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Drawing.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
Public Function MeasureString ( _text As String _
) As SizeF
```
 
```csharp
public SizeF MeasureString(string text
)
```
 
### Parameters
 
 - text
     - Type: [System.String](http://msdn2.microsoft.com/en-us/s1wwdcbf)
String you want to measure.
 
### Return Value
Dimensions of the rectangle occupied with string when it will be drawn.
 
## Examples
  
```
' Create Bitmap object.
Dim bitmap As New Aurigma.GraphicsMill.Bitmap(250, 40, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)

bitmap.Unit = Aurigma.GraphicsMill.Unit.Point

Dim graphics As Aurigma.GraphicsMill.Drawing.GdiGraphics = bitmap.GetGdiGraphics()

' Fill background.
graphics.FillRectangle(New Aurigma.GraphicsMill.Drawing.SolidBrush( _
    Aurigma.GraphicsMill.RgbColor.White), 0, 0, bitmap.Width, bitmap.Height)

' Adjust font settings.
Dim timesFont As New Aurigma.GraphicsMill.Drawing.Font("Times New Roman", 25, False, True)

Dim text As String = "Single-line text..."

' Measure the text size.
Dim size As System.Drawing.SizeF = timesFont.MeasureString(text)

Dim blackBrush As New Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.Black)

graphics.DrawString(text, timesFont, blackBrush, 0, 0)

Dim redBrush As New Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.Red)

Dim tahomaFont As New Aurigma.GraphicsMill.Drawing.Font("Tahoma", 12)

text = "Height: " & size.Height
graphics.DrawString(text, tahomaFont, redBrush, size.Width + 1, 20)

text = "Width: " & size.Width
graphics.DrawString(text, tahomaFont, redBrush, size.Width + 1, 0)
```
 
```csharp
// Create Bitmap object.
Aurigma.GraphicsMill.Bitmap bitmap = 
    new Aurigma.GraphicsMill.Bitmap(250, 40, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);

bitmap.Unit = Aurigma.GraphicsMill.Unit.Point;

Aurigma.GraphicsMill.Drawing.GdiGraphics graphics = bitmap.GetGdiGraphics();

// Fill background.
graphics.FillRectangle(new Aurigma.GraphicsMill.Drawing.SolidBrush( 
    Aurigma.GraphicsMill.RgbColor.White), 0, 0, bitmap.Width, bitmap.Height);

// Adjust font settings.
Aurigma.GraphicsMill.Drawing.Font timesFont = 
    new Aurigma.GraphicsMill.Drawing.Font("Times New Roman", 25, false, true);

string text = "Single-line text...";

// Measure the text size.
System.Drawing.SizeF size = timesFont.MeasureString(text);

Aurigma.GraphicsMill.Drawing.SolidBrush blackBrush = 
    new Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.Black);

graphics.DrawString(text, timesFont, blackBrush, 0, 0);

Aurigma.GraphicsMill.Drawing.SolidBrush redBrush = 
    new Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.Red);

Aurigma.GraphicsMill.Drawing.Font tahomaFont = new 
    Aurigma.GraphicsMill.Drawing.Font("Tahoma", 12); 

text = "Height: " + size.Height.ToString();
graphics.DrawString(text, tahomaFont, redBrush, size.Width + 1, 20);

text = "Width: " + size.Width.ToString();
graphics.DrawString(text, tahomaFont, redBrush, size.Width + 1, 0);
```
   
## See Also

### Reference

- [Font Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Drawing_Font.htm.md)
- [Aurigma.GraphicsMill.Drawing Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Drawing.htm.md)
