TextRenderer.MeasureText Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Mede o texto especificado quando desenhado com a fonte especificada.
Sobrecargas
| Nome | Description |
|---|---|
| MeasureText(String, Font) |
Fornece o tamanho, em pixels, do texto especificado quando desenhado com a fonte especificada. |
| MeasureText(IDeviceContext, String, Font) |
Fornece o tamanho, em pixels, do texto especificado desenhado com a fonte especificada no contexto do dispositivo especificado. |
| MeasureText(String, Font, Size) |
Fornece o tamanho, em pixels, do texto especificado quando desenhado com a fonte especificada, usando o tamanho especificado para criar um retângulo delimitador inicial. |
| MeasureText(IDeviceContext, String, Font, Size) |
Fornece o tamanho, em pixels, do texto especificado quando desenhado com a fonte especificada no contexto do dispositivo especificado, usando o tamanho especificado para criar um retângulo delimitador inicial para o texto. |
| MeasureText(String, Font, Size, TextFormatFlags) |
Fornece o tamanho, em pixels, do texto especificado quando desenhado com as instruções de fonte e formatação especificadas, usando o tamanho especificado para criar o retângulo delimitador inicial para o texto. |
| MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags) |
Fornece o tamanho, em pixels, do texto especificado quando desenhado com as instruções de contexto, fonte e formatação do dispositivo especificadas, usando o tamanho especificado para criar o retângulo delimitador inicial para o texto. |
MeasureText(String, Font)
Fornece o tamanho, em pixels, do texto especificado quando desenhado com a fonte especificada.
public:
static System::Drawing::Size MeasureText(System::String ^ text, System::Drawing::Font ^ font);
public static System.Drawing.Size MeasureText(string text, System.Drawing.Font font);
static member MeasureText : string * System.Drawing.Font -> System.Drawing.Size
Public Shared Function MeasureText (text As String, font As Font) As Size
Parâmetros
- text
- String
O texto a ser medido.
Retornos
O Size, em pixels, de text desenhado em uma única linha com o especificado font. Você pode manipular como o texto é desenhado usando uma das DrawText(IDeviceContext, String, Font, Rectangle, Color, TextFormatFlags) sobrecargas que usa um TextFormatFlags parâmetro. Por exemplo, o comportamento padrão é TextRenderer adicionar preenchimento ao retângulo delimitador do texto desenhado para acomodar glifos pendentes. Se você precisar desenhar uma linha de texto sem esses espaços extras, deverá usar as versões de DrawText(IDeviceContext, String, Font, Point, Color) e MeasureText(IDeviceContext, String, Font) que usam um parâmetro e TextFormatFlags um Size parâmetro. Para obter um exemplo, consulte MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags).
Exemplos
O exemplo de código a seguir demonstra como usar o MeasureText método. Para executar este exemplo, cole o código em um formulário Windows e chame MeasureText1 do manipulador de eventos Paint do formulário, passando e como PaintEventArgs.
private void MeasureText1(PaintEventArgs e)
{
String text1 = "Measure this text";
Font arialBold = new Font("Arial", 12.0F);
Size textSize = TextRenderer.MeasureText(text1, arialBold);
TextRenderer.DrawText(e.Graphics, text1, arialBold,
new Rectangle(new Point(10, 10), textSize), Color.Red);
}
Private Sub MeasureText1(ByVal e As PaintEventArgs)
Dim text1 As String = "Measure this text"
Dim arialBold As New Font("Arial", 12.0F)
Dim textSize As Size = TextRenderer.MeasureText(text1, arialBold)
TextRenderer.DrawText(e.Graphics, text1, arialBold, _
New Rectangle(New Point(10, 10), textSize), Color.Red)
End Sub
Comentários
O MeasureText método requer que o texto seja desenhado em uma única linha.
Aplica-se a
MeasureText(IDeviceContext, String, Font)
Fornece o tamanho, em pixels, do texto especificado desenhado com a fonte especificada no contexto do dispositivo especificado.
public:
static System::Drawing::Size MeasureText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font);
public static System.Drawing.Size MeasureText(System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font);
static member MeasureText : System.Drawing.IDeviceContext * string * System.Drawing.Font -> System.Drawing.Size
Public Shared Function MeasureText (dc As IDeviceContext, text As String, font As Font) As Size
Parâmetros
O contexto do dispositivo no qual medir o texto.
- text
- String
O texto a ser medido.
Retornos
O Size, em pixels, de text desenhado em uma única linha com o especificado font no contexto do dispositivo especificado.
Exemplos
O exemplo de código a seguir demonstra como usar um dos MeasureText métodos. Para executar este exemplo, cole o código em um formulário Windows e chame DrawALineOfText do manipulador de eventos Paint do formulário, passando e como PaintEventArgs.
private static void DrawALineOfText(PaintEventArgs e)
{
// Declare strings to render on the form.
string[] stringsToPaint = { "Tail", "Spin", " Toys" };
// Declare fonts for rendering the strings.
Font[] fonts = { new Font("Arial", 14, FontStyle.Regular),
new Font("Arial", 14, FontStyle.Italic),
new Font("Arial", 14, FontStyle.Regular) };
Point startPoint = new Point(10, 10);
// Set TextFormatFlags to no padding so strings are drawn together.
TextFormatFlags flags = TextFormatFlags.NoPadding;
// Declare a proposed size with dimensions set to the maximum integer value.
Size proposedSize = new Size(int.MaxValue, int.MaxValue);
// Measure each string with its font and NoPadding value and
// draw it to the form.
for (int i = 0; i < stringsToPaint.Length; i++)
{
Size size = TextRenderer.MeasureText(e.Graphics, stringsToPaint[i],
fonts[i], proposedSize, flags);
Rectangle rect = new Rectangle(startPoint, size);
TextRenderer.DrawText(e.Graphics, stringsToPaint[i], fonts[i],
startPoint, Color.Black, flags);
startPoint.X += size.Width;
}
}
Private Sub DrawALineOfText(ByVal e As PaintEventArgs)
' Declare strings to render on the form.
Dim stringsToPaint() As String = {"Tail", "Spin", " Toys"}
' Declare fonts for rendering the strings.
Dim fonts() As Font = {New Font("Arial", 14, FontStyle.Regular), _
New Font("Arial", 14, FontStyle.Italic), _
New Font("Arial", 14, FontStyle.Regular)}
Dim startPoint As New Point(10, 10)
' Set TextFormatFlags to no padding so strings are drawn together.
Dim flags As TextFormatFlags = TextFormatFlags.NoPadding
' Declare a proposed size with dimensions set to the maximum integer value.
Dim proposedSize As Size = New Size(Integer.MaxValue, Integer.MaxValue)
' Measure each string with its font and NoPadding value and draw it to the form.
For i As Integer = 0 To stringsToPaint.Length - 1
Dim size As Size = TextRenderer.MeasureText(e.Graphics, _
stringsToPaint(i), fonts(i), proposedSize, flags)
Dim rect As Rectangle = New Rectangle(startPoint, size)
TextRenderer.DrawText(e.Graphics, stringsToPaint(i), fonts(i), _
startPoint, Color.Black, flags)
startPoint.X += size.Width
Next
End Sub
Comentários
O MeasureText método requer que o texto seja desenhado em uma única linha.
Aplica-se a
MeasureText(String, Font, Size)
Fornece o tamanho, em pixels, do texto especificado quando desenhado com a fonte especificada, usando o tamanho especificado para criar um retângulo delimitador inicial.
public:
static System::Drawing::Size MeasureText(System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Size proposedSize);
public static System.Drawing.Size MeasureText(string text, System.Drawing.Font font, System.Drawing.Size proposedSize);
static member MeasureText : string * System.Drawing.Font * System.Drawing.Size -> System.Drawing.Size
Public Shared Function MeasureText (text As String, font As Font, proposedSize As Size) As Size
Parâmetros
- text
- String
O texto a ser medido.
Retornos
O Size, em pixels, de text desenhado com o especificado font.
Exemplos
O exemplo de código a seguir demonstra como usar um dos MeasureText métodos. Para executar este exemplo, cole o código em um formulário Windows e chame DrawALineOfText do manipulador de eventos Paint do formulário, passando e como PaintEventArgs.
private static void DrawALineOfText(PaintEventArgs e)
{
// Declare strings to render on the form.
string[] stringsToPaint = { "Tail", "Spin", " Toys" };
// Declare fonts for rendering the strings.
Font[] fonts = { new Font("Arial", 14, FontStyle.Regular),
new Font("Arial", 14, FontStyle.Italic),
new Font("Arial", 14, FontStyle.Regular) };
Point startPoint = new Point(10, 10);
// Set TextFormatFlags to no padding so strings are drawn together.
TextFormatFlags flags = TextFormatFlags.NoPadding;
// Declare a proposed size with dimensions set to the maximum integer value.
Size proposedSize = new Size(int.MaxValue, int.MaxValue);
// Measure each string with its font and NoPadding value and
// draw it to the form.
for (int i = 0; i < stringsToPaint.Length; i++)
{
Size size = TextRenderer.MeasureText(e.Graphics, stringsToPaint[i],
fonts[i], proposedSize, flags);
Rectangle rect = new Rectangle(startPoint, size);
TextRenderer.DrawText(e.Graphics, stringsToPaint[i], fonts[i],
startPoint, Color.Black, flags);
startPoint.X += size.Width;
}
}
Private Sub DrawALineOfText(ByVal e As PaintEventArgs)
' Declare strings to render on the form.
Dim stringsToPaint() As String = {"Tail", "Spin", " Toys"}
' Declare fonts for rendering the strings.
Dim fonts() As Font = {New Font("Arial", 14, FontStyle.Regular), _
New Font("Arial", 14, FontStyle.Italic), _
New Font("Arial", 14, FontStyle.Regular)}
Dim startPoint As New Point(10, 10)
' Set TextFormatFlags to no padding so strings are drawn together.
Dim flags As TextFormatFlags = TextFormatFlags.NoPadding
' Declare a proposed size with dimensions set to the maximum integer value.
Dim proposedSize As Size = New Size(Integer.MaxValue, Integer.MaxValue)
' Measure each string with its font and NoPadding value and draw it to the form.
For i As Integer = 0 To stringsToPaint.Length - 1
Dim size As Size = TextRenderer.MeasureText(e.Graphics, _
stringsToPaint(i), fonts(i), proposedSize, flags)
Dim rect As Rectangle = New Rectangle(startPoint, size)
TextRenderer.DrawText(e.Graphics, stringsToPaint(i), fonts(i), _
startPoint, Color.Black, flags)
startPoint.X += size.Width
Next
End Sub
Comentários
O MeasureText método usa o proposedSize parâmetro para indicar a relação de altura a largura ao determinar o tamanho do texto. Ao medir o texto em uma única linha, se o proposedSize parâmetro representar um com uma Size dimensão de altura maior que Int32.MaxValue, o retornado Size será ajustado para refletir a altura real do texto.
Aplica-se a
MeasureText(IDeviceContext, String, Font, Size)
Fornece o tamanho, em pixels, do texto especificado quando desenhado com a fonte especificada no contexto do dispositivo especificado, usando o tamanho especificado para criar um retângulo delimitador inicial para o texto.
public:
static System::Drawing::Size MeasureText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Size proposedSize);
public static System.Drawing.Size MeasureText(System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Size proposedSize);
static member MeasureText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Size -> System.Drawing.Size
Public Shared Function MeasureText (dc As IDeviceContext, text As String, font As Font, proposedSize As Size) As Size
Parâmetros
O contexto do dispositivo no qual medir o texto.
- text
- String
O texto a ser medido.
Retornos
O Size, em pixels, de text desenhado com o especificado font.
Exceções
dc é null.
Exemplos
O exemplo de código a seguir demonstra como usar um dos MeasureText métodos. Para executar este exemplo, cole o código em um formulário Windows e chame DrawALineOfText do manipulador de eventos Paint do formulário, passando e como PaintEventArgs.
private static void DrawALineOfText(PaintEventArgs e)
{
// Declare strings to render on the form.
string[] stringsToPaint = { "Tail", "Spin", " Toys" };
// Declare fonts for rendering the strings.
Font[] fonts = { new Font("Arial", 14, FontStyle.Regular),
new Font("Arial", 14, FontStyle.Italic),
new Font("Arial", 14, FontStyle.Regular) };
Point startPoint = new Point(10, 10);
// Set TextFormatFlags to no padding so strings are drawn together.
TextFormatFlags flags = TextFormatFlags.NoPadding;
// Declare a proposed size with dimensions set to the maximum integer value.
Size proposedSize = new Size(int.MaxValue, int.MaxValue);
// Measure each string with its font and NoPadding value and
// draw it to the form.
for (int i = 0; i < stringsToPaint.Length; i++)
{
Size size = TextRenderer.MeasureText(e.Graphics, stringsToPaint[i],
fonts[i], proposedSize, flags);
Rectangle rect = new Rectangle(startPoint, size);
TextRenderer.DrawText(e.Graphics, stringsToPaint[i], fonts[i],
startPoint, Color.Black, flags);
startPoint.X += size.Width;
}
}
Private Sub DrawALineOfText(ByVal e As PaintEventArgs)
' Declare strings to render on the form.
Dim stringsToPaint() As String = {"Tail", "Spin", " Toys"}
' Declare fonts for rendering the strings.
Dim fonts() As Font = {New Font("Arial", 14, FontStyle.Regular), _
New Font("Arial", 14, FontStyle.Italic), _
New Font("Arial", 14, FontStyle.Regular)}
Dim startPoint As New Point(10, 10)
' Set TextFormatFlags to no padding so strings are drawn together.
Dim flags As TextFormatFlags = TextFormatFlags.NoPadding
' Declare a proposed size with dimensions set to the maximum integer value.
Dim proposedSize As Size = New Size(Integer.MaxValue, Integer.MaxValue)
' Measure each string with its font and NoPadding value and draw it to the form.
For i As Integer = 0 To stringsToPaint.Length - 1
Dim size As Size = TextRenderer.MeasureText(e.Graphics, _
stringsToPaint(i), fonts(i), proposedSize, flags)
Dim rect As Rectangle = New Rectangle(startPoint, size)
TextRenderer.DrawText(e.Graphics, stringsToPaint(i), fonts(i), _
startPoint, Color.Black, flags)
startPoint.X += size.Width
Next
End Sub
Comentários
O MeasureText método usa o proposedSize parâmetro para indicar a relação de altura a largura ao determinar o tamanho do texto. Ao medir o texto em uma única linha, se o proposedSize parâmetro representar um com uma Size dimensão de altura maior que Int32.MaxValue, o retornado Size será ajustado para refletir a altura real do texto.
Aplica-se a
MeasureText(String, Font, Size, TextFormatFlags)
Fornece o tamanho, em pixels, do texto especificado quando desenhado com as instruções de fonte e formatação especificadas, usando o tamanho especificado para criar o retângulo delimitador inicial para o texto.
public:
static System::Drawing::Size MeasureText(System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Size proposedSize, System::Windows::Forms::TextFormatFlags flags);
public static System.Drawing.Size MeasureText(string text, System.Drawing.Font font, System.Drawing.Size proposedSize, System.Windows.Forms.TextFormatFlags flags);
static member MeasureText : string * System.Drawing.Font * System.Drawing.Size * System.Windows.Forms.TextFormatFlags -> System.Drawing.Size
Public Shared Function MeasureText (text As String, font As Font, proposedSize As Size, flags As TextFormatFlags) As Size
Parâmetros
- text
- String
O texto a ser medido.
- flags
- TextFormatFlags
As instruções de formatação a serem aplicadas ao texto medido.
Retornos
O Size, em pixels, de text desenhado com o formato e especificado font .
Exemplos
O exemplo de código a seguir demonstra como usar um dos MeasureText métodos. Para executar este exemplo, cole o código em um formulário Windows e chame DrawALineOfText do manipulador de eventos Paint do formulário, passando e como PaintEventArgs.
private static void DrawALineOfText(PaintEventArgs e)
{
// Declare strings to render on the form.
string[] stringsToPaint = { "Tail", "Spin", " Toys" };
// Declare fonts for rendering the strings.
Font[] fonts = { new Font("Arial", 14, FontStyle.Regular),
new Font("Arial", 14, FontStyle.Italic),
new Font("Arial", 14, FontStyle.Regular) };
Point startPoint = new Point(10, 10);
// Set TextFormatFlags to no padding so strings are drawn together.
TextFormatFlags flags = TextFormatFlags.NoPadding;
// Declare a proposed size with dimensions set to the maximum integer value.
Size proposedSize = new Size(int.MaxValue, int.MaxValue);
// Measure each string with its font and NoPadding value and
// draw it to the form.
for (int i = 0; i < stringsToPaint.Length; i++)
{
Size size = TextRenderer.MeasureText(e.Graphics, stringsToPaint[i],
fonts[i], proposedSize, flags);
Rectangle rect = new Rectangle(startPoint, size);
TextRenderer.DrawText(e.Graphics, stringsToPaint[i], fonts[i],
startPoint, Color.Black, flags);
startPoint.X += size.Width;
}
}
Private Sub DrawALineOfText(ByVal e As PaintEventArgs)
' Declare strings to render on the form.
Dim stringsToPaint() As String = {"Tail", "Spin", " Toys"}
' Declare fonts for rendering the strings.
Dim fonts() As Font = {New Font("Arial", 14, FontStyle.Regular), _
New Font("Arial", 14, FontStyle.Italic), _
New Font("Arial", 14, FontStyle.Regular)}
Dim startPoint As New Point(10, 10)
' Set TextFormatFlags to no padding so strings are drawn together.
Dim flags As TextFormatFlags = TextFormatFlags.NoPadding
' Declare a proposed size with dimensions set to the maximum integer value.
Dim proposedSize As Size = New Size(Integer.MaxValue, Integer.MaxValue)
' Measure each string with its font and NoPadding value and draw it to the form.
For i As Integer = 0 To stringsToPaint.Length - 1
Dim size As Size = TextRenderer.MeasureText(e.Graphics, _
stringsToPaint(i), fonts(i), proposedSize, flags)
Dim rect As Rectangle = New Rectangle(startPoint, size)
TextRenderer.DrawText(e.Graphics, stringsToPaint(i), fonts(i), _
startPoint, Color.Black, flags)
startPoint.X += size.Width
Next
End Sub
Comentários
MeasureText usa os proposedSize parâmetros e para indicar a relação entre altura e flags largura ao determinar o tamanho do texto. Ao medir o texto em uma única linha, se o proposedSize parâmetro representar um com uma Size dimensão de altura maior que Int32.MaxValue, o retornado Size será ajustado para refletir a altura real do texto.
Você pode manipular como o texto é desenhado usando uma das DrawText sobrecargas que usa um TextFormatFlags parâmetro. Por exemplo, o comportamento padrão é TextRenderer adicionar preenchimento ao retângulo delimitador do texto desenhado para acomodar glifos pendentes. Se você precisar desenhar uma linha de texto sem esses espaços extras, deverá usar as versões de DrawText e MeasureText que usam um parâmetro e TextFormatFlags um Size parâmetro. Para obter um exemplo, consulte MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags).
Note
Essa sobrecarga de MeasureText(String, Font, Size, TextFormatFlags) ignorará um TextFormatFlags valor de NoPadding ou LeftAndRightPadding. Se você estiver especificando um valor de preenchimento diferente do padrão, deverá usar a sobrecarga desse MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags)IDeviceContext objeto.
Aplica-se a
MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags)
Fornece o tamanho, em pixels, do texto especificado quando desenhado com as instruções de contexto, fonte e formatação do dispositivo especificadas, usando o tamanho especificado para criar o retângulo delimitador inicial para o texto.
public:
static System::Drawing::Size MeasureText(System::Drawing::IDeviceContext ^ dc, System::String ^ text, System::Drawing::Font ^ font, System::Drawing::Size proposedSize, System::Windows::Forms::TextFormatFlags flags);
public static System.Drawing.Size MeasureText(System.Drawing.IDeviceContext dc, string text, System.Drawing.Font font, System.Drawing.Size proposedSize, System.Windows.Forms.TextFormatFlags flags);
static member MeasureText : System.Drawing.IDeviceContext * string * System.Drawing.Font * System.Drawing.Size * System.Windows.Forms.TextFormatFlags -> System.Drawing.Size
Public Shared Function MeasureText (dc As IDeviceContext, text As String, font As Font, proposedSize As Size, flags As TextFormatFlags) As Size
Parâmetros
O contexto do dispositivo no qual medir o texto.
- text
- String
O texto a ser medido.
- flags
- TextFormatFlags
As instruções de formatação a serem aplicadas ao texto medido.
Retornos
O Size, em pixels, de text desenhado com o formato e especificado font .
Exceções
dc é null.
Exemplos
O exemplo a seguir demonstra como usar e métodos MeasureTextDrawText para desenhar uma única linha de texto em diferentes estilos de fonte. Para executar este exemplo, cole o código a seguir em um formulário Windows e chame DrawALineOfText do manipulador de eventos Paint do formulário, passando e como PaintEventArgs.
private static void DrawALineOfText(PaintEventArgs e)
{
// Declare strings to render on the form.
string[] stringsToPaint = { "Tail", "Spin", " Toys" };
// Declare fonts for rendering the strings.
Font[] fonts = { new Font("Arial", 14, FontStyle.Regular),
new Font("Arial", 14, FontStyle.Italic),
new Font("Arial", 14, FontStyle.Regular) };
Point startPoint = new Point(10, 10);
// Set TextFormatFlags to no padding so strings are drawn together.
TextFormatFlags flags = TextFormatFlags.NoPadding;
// Declare a proposed size with dimensions set to the maximum integer value.
Size proposedSize = new Size(int.MaxValue, int.MaxValue);
// Measure each string with its font and NoPadding value and
// draw it to the form.
for (int i = 0; i < stringsToPaint.Length; i++)
{
Size size = TextRenderer.MeasureText(e.Graphics, stringsToPaint[i],
fonts[i], proposedSize, flags);
Rectangle rect = new Rectangle(startPoint, size);
TextRenderer.DrawText(e.Graphics, stringsToPaint[i], fonts[i],
startPoint, Color.Black, flags);
startPoint.X += size.Width;
}
}
Private Sub DrawALineOfText(ByVal e As PaintEventArgs)
' Declare strings to render on the form.
Dim stringsToPaint() As String = {"Tail", "Spin", " Toys"}
' Declare fonts for rendering the strings.
Dim fonts() As Font = {New Font("Arial", 14, FontStyle.Regular), _
New Font("Arial", 14, FontStyle.Italic), _
New Font("Arial", 14, FontStyle.Regular)}
Dim startPoint As New Point(10, 10)
' Set TextFormatFlags to no padding so strings are drawn together.
Dim flags As TextFormatFlags = TextFormatFlags.NoPadding
' Declare a proposed size with dimensions set to the maximum integer value.
Dim proposedSize As Size = New Size(Integer.MaxValue, Integer.MaxValue)
' Measure each string with its font and NoPadding value and draw it to the form.
For i As Integer = 0 To stringsToPaint.Length - 1
Dim size As Size = TextRenderer.MeasureText(e.Graphics, _
stringsToPaint(i), fonts(i), proposedSize, flags)
Dim rect As Rectangle = New Rectangle(startPoint, size)
TextRenderer.DrawText(e.Graphics, stringsToPaint(i), fonts(i), _
startPoint, Color.Black, flags)
startPoint.X += size.Width
Next
End Sub
Comentários
O MeasureText método usa o e os proposedSize parâmetros para indicar a relação entre altura e flags largura ao determinar o tamanho do texto. Ao medir o texto em uma única linha, se o proposedSize parâmetro representar um com uma Size dimensão de altura maior que Int32.MaxValue, o retornado Size será ajustado para refletir a altura real do texto.
Você pode manipular como o texto é desenhado usando uma das DrawText sobrecargas que usa um TextFormatFlags parâmetro. Por exemplo, o comportamento padrão é TextRenderer adicionar preenchimento ao retângulo delimitador do texto desenhado para acomodar glifos pendentes. Se você precisar desenhar uma linha de texto sem esses espaços extras, use as versões de DrawText e MeasureText que usam um Size parâmetro, TextFormatFlags conforme mostrado no exemplo.