- Aurigma Graphics Mill 5.5 for .NET
- Introduction
- What's New?
- Overview of Features
- Getting Started
- Programming with Graphics Mill for .NET
- File Formats
- Graphics Mill for .NET Add-ons
- Class Library Reference
- Aurigma.GraphicsMill Namespace
- Aurigma.GraphicsMill.AjaxControls Namespace
- Aurigma.GraphicsMill.AjaxControls.VectorObjects Namespace
- Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math Namespace
- Aurigma.GraphicsMill.AjaxControls.VectorObjects.RedoUndo Namespace
- Aurigma.GraphicsMill.Codecs Namespace
- Aurigma.GraphicsMill.Drawing Namespace
- Brush Class
- BrushType Enumeration
- Charset Enumeration
- Font Class
- GdiGraphics Class
- GdiGraphicsMode Enumeration
- HatchBrush Class
- HatchStyle Enumeration
- HorizontalAlignment Enumeration
- LineCap Enumeration
- Pen Class
- SolidBrush Class
- TextTrimmingMode Enumeration
- VerticalAlignment Enumeration
- Aurigma.GraphicsMill.Licensing Namespace
- Aurigma.GraphicsMill.Transforms Namespace
- Aurigma.GraphicsMill.WebControls Namespace
- Aurigma.GraphicsMill.WinControls Namespace
- GraphicsMill Namespace (Client Class Library)
- Aurigma.GraphicsMill.AjaxControls Namespace (Client Class Library)
- Aurigma.GraphicsMill.AjaxControls.VectorObjects Namespace (Client Class Library)
- Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math Namespace (Client Class Library)
- Aurigma.GraphicsMill.AjaxControls.VectorObjects.RedoUndo Namespace (Client Class Library)
- Samples
- Licensing
- Copyright Notices
This documentation is for the old version. Go to the latest Graphics Mill docs
Font.MeasureString Method
Gets the extent (both width and height) of the string draw by the GdiGraphics.DrawString method.
Namespace:
Aurigma.GraphicsMill.Drawing
Assembly:
Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
Syntax
Parameters
- text
-
Type: System.String
String you want to measure.
Return Value
Dimensions of the rectangle occupied with string when it will be drawn.Examples
Visual Basic
' 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)
C#
// 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);