Font Constructores

Definición

Inicializa un nuevo objeto Font que usa el objeto Font existente especificado y FontStyle.

Sobrecargas

Font(Font, FontStyle)

Inicializa un nuevo objeto Font que utiliza el objeto Font existente especificado y la enumeración FontStyle.

Font(String, Single, FontStyle, GraphicsUnit, Byte, Boolean)

Inicializa un nuevo Font utilizando el juego de caracteres, la unidad, el estilo y el tamaño especificados.

Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte, Boolean)

Inicializa un nuevo Font usando un juego de caracteres, una unidad, un estilo y un tamaño especificados.

Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte)

Inicializa un nuevo Font usando un juego de caracteres, una unidad, un estilo y un tamaño especificados.

Font(String, Single, FontStyle, GraphicsUnit)

Inicializa un nuevo Font usando una unidad, un estilo y un tamaño especificados.

Font(FontFamily, Single, FontStyle, GraphicsUnit)

Inicializa un nuevo Font usando una unidad, un estilo y un tamaño especificados.

Font(String, Single, FontStyle, GraphicsUnit, Byte)

Inicializa un nuevo Font usando un juego de caracteres, una unidad, un estilo y un tamaño especificados.

Font(String, Single, FontStyle)

Inicializa un nuevo objeto Font utilizando un tamaño y estilo especificados.

Font(FontFamily, Single, GraphicsUnit)

Inicializa un nuevo objeto Font usando una unidad y un tamaño especificados. Establece el estilo en Regular.

Font(FontFamily, Single, FontStyle)

Inicializa un nuevo objeto Font utilizando un tamaño y estilo especificados.

Font(String, Single)

Inicializa un nuevo objeto Font utilizando un tamaño especificado.

Font(FontFamily, Single)

Inicializa un nuevo objeto Font utilizando un tamaño especificado.

Font(String, Single, GraphicsUnit)

Inicializa un nuevo objeto Font usando una unidad y un tamaño especificados. El estilo se establece en Regular.

Font(Font, FontStyle)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo objeto Font que utiliza el objeto Font existente especificado y la enumeración FontStyle.

public:
 Font(System::Drawing::Font ^ prototype, System::Drawing::FontStyle newStyle);
public Font (System.Drawing.Font prototype, System.Drawing.FontStyle newStyle);
new System.Drawing.Font : System.Drawing.Font * System.Drawing.FontStyle -> System.Drawing.Font
Public Sub New (prototype As Font, newStyle As FontStyle)

Parámetros

prototype
Font

Objeto Font existente a partir del cual se creará el nuevo objeto Font.

newStyle
FontStyle

FontStyle que se va a aplicar a la nueva Font. Se pueden combinar varios valores de la enumeración FontStyle con el operador OR.

Ejemplos

En el ejemplo de código siguiente se muestra el Inequality operador, el Font constructor y la Bold propiedad . Este ejemplo está diseñado para usarse con un formulario Windows Forms que contiene un botón denominado Button2. Pegue el código siguiente en el formulario y asocie el Button2_Click método con el evento del Click botón.

void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   if ( this->BackColor != SystemColors::ControlDark )
   {
      this->BackColor = SystemColors::ControlDark;
   }

   if (  !(this->Font->Bold) )
   {
      this->Font = gcnew System::Drawing::Font( this->Font,FontStyle::Bold );
   }
}
private void Button2_Click(System.Object sender, System.EventArgs e)
{

    if (this.BackColor != SystemColors.ControlDark)
    {
        this.BackColor = SystemColors.ControlDark;
    }
    if (!(this.Font.Bold))
    {
        this.Font = new Font(this.Font, FontStyle.Bold);
    }
}
Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click

    If (Color.op_Inequality(Me.BackColor, SystemColors.ControlDark)) Then
        Me.BackColor = SystemColors.ControlDark
    End If
    If Not (Me.Font.Bold) Then
        Me.Font = New Font(Me.Font, FontStyle.Bold)
    End If
End Sub

Comentarios

En el caso de las aplicaciones localizadas basadas en .NET Framework 2.0 y versiones anteriores, especificar una fuente para prototype cuando esa fuente no se haya instalado en el equipo que se usa para compilar la aplicación hará que se use la fuente Microsoft Sans Serif en su lugar. Si la aplicación depende de este comportamiento y debe volver a compilar la aplicación para .NET Framework 3.0, debe especificar la fuente Microsoft Sans Serif para prototype.

Se aplica a

Font(String, Single, FontStyle, GraphicsUnit, Byte, Boolean)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo Font utilizando el juego de caracteres, la unidad, el estilo y el tamaño especificados.

public:
 Font(System::String ^ familyName, float emSize, System::Drawing::FontStyle style, System::Drawing::GraphicsUnit unit, System::Byte gdiCharSet, bool gdiVerticalFont);
public Font (string familyName, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont);
new System.Drawing.Font : string * single * System.Drawing.FontStyle * System.Drawing.GraphicsUnit * byte * bool -> System.Drawing.Font
Public Sub New (familyName As String, emSize As Single, style As FontStyle, unit As GraphicsUnit, gdiCharSet As Byte, gdiVerticalFont As Boolean)

Parámetros

familyName
String

Representación de cadena del objeto FontFamily para el nuevo objeto Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en las unidades especificadas por el parámetro unit.

style
FontStyle

FontStyle de la nueva fuente.

unit
GraphicsUnit

GraphicsUnit de la nueva fuente.

gdiCharSet
Byte

que Byte especifica un juego de caracteres GDI que se va a usar para esta fuente.

gdiVerticalFont
Boolean

Valor booleano que indica si el nuevo Font se deriva de una fuente vertical GDI.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

Comentarios

El gdiCharSet parámetro toma un valor de la lista definida en el archivo de encabezado Windows SDK WinGDI.h. Si el familyName parámetro especifica una fuente que no está instalada en la máquina que ejecuta la aplicación o no se admite, Serif de Microsoft Sans se reemplazará.

Consulte también

Se aplica a

Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte, Boolean)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo Font usando un juego de caracteres, una unidad, un estilo y un tamaño especificados.

public:
 Font(System::Drawing::FontFamily ^ family, float emSize, System::Drawing::FontStyle style, System::Drawing::GraphicsUnit unit, System::Byte gdiCharSet, bool gdiVerticalFont);
public Font (System.Drawing.FontFamily family, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont);
new System.Drawing.Font : System.Drawing.FontFamily * single * System.Drawing.FontStyle * System.Drawing.GraphicsUnit * byte * bool -> System.Drawing.Font
Public Sub New (family As FontFamily, emSize As Single, style As FontStyle, unit As GraphicsUnit, gdiCharSet As Byte, gdiVerticalFont As Boolean)

Parámetros

family
FontFamily

FontFamily de la nueva Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en las unidades especificadas por el parámetro unit.

style
FontStyle

FontStyle de la nueva fuente.

unit
GraphicsUnit

GraphicsUnit de la nueva fuente.

gdiCharSet
Byte

Objeto Byte que especifica un

Juego de caracteres GDI que se usará para esta fuente.

gdiVerticalFont
Boolean

Valor booleano que indica si la nueva fuente se deriva de una fuente vertical GDI.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

family es null

Comentarios

El gdiCharSet parámetro toma un valor de la lista definida en el archivo de encabezado Windows SDK WinGDI.h.

Se aplica a

Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo Font usando un juego de caracteres, una unidad, un estilo y un tamaño especificados.

public:
 Font(System::Drawing::FontFamily ^ family, float emSize, System::Drawing::FontStyle style, System::Drawing::GraphicsUnit unit, System::Byte gdiCharSet);
public Font (System.Drawing.FontFamily family, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit, byte gdiCharSet);
new System.Drawing.Font : System.Drawing.FontFamily * single * System.Drawing.FontStyle * System.Drawing.GraphicsUnit * byte -> System.Drawing.Font
Public Sub New (family As FontFamily, emSize As Single, style As FontStyle, unit As GraphicsUnit, gdiCharSet As Byte)

Parámetros

family
FontFamily

FontFamily de la nueva Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en las unidades especificadas por el parámetro unit.

style
FontStyle

FontStyle de la nueva fuente.

unit
GraphicsUnit

GraphicsUnit de la nueva fuente.

gdiCharSet
Byte

Objeto Byte que especifica un

Juego de caracteres GDI que se usará para la nueva fuente.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

family es null.

Comentarios

El gdiCharSet parámetro toma un valor de la lista definida en el archivo de encabezado Windows SDK WinGDI.h.

Se aplica a

Font(String, Single, FontStyle, GraphicsUnit)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo Font usando una unidad, un estilo y un tamaño especificados.

public:
 Font(System::String ^ familyName, float emSize, System::Drawing::FontStyle style, System::Drawing::GraphicsUnit unit);
public Font (string familyName, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit);
new System.Drawing.Font : string * single * System.Drawing.FontStyle * System.Drawing.GraphicsUnit -> System.Drawing.Font
Public Sub New (familyName As String, emSize As Single, style As FontStyle, unit As GraphicsUnit)

Parámetros

familyName
String

Representación de cadena del objeto FontFamily para el nuevo objeto Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en las unidades especificadas por el parámetro unit.

style
FontStyle

FontStyle de la nueva fuente.

unit
GraphicsUnit

GraphicsUnit de la nueva fuente.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el Font constructor . Este ejemplo está diseñado para usarse con Windows Forms. Para ejecutar este ejemplo, pegue este código en un formulario que contenga un botón denominado Button2y asocie el Button2_Click método con el Click evento del botón.


private:
    void Button2_Click(System::Object^ sender,
        System::EventArgs^ e)
    {
        Button2->Font = gcnew System::Drawing::Font
            (FontFamily::GenericMonospace, 12.0F,
            FontStyle::Italic, GraphicsUnit::Pixel);
    }

private void Button2_Click(System.Object sender, System.EventArgs e)
{

    Button2.Font = new Font(FontFamily.GenericMonospace, 12.0F, 
        FontStyle.Italic, GraphicsUnit.Pixel);
}

Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click

    Button2.Font = New Font(FontFamily.GenericMonospace, 12.0F, _
        FontStyle.Italic, GraphicsUnit.Pixel)

End Sub

Comentarios

Windows Forms las aplicaciones admiten fuentes TrueType y tienen compatibilidad limitada con fuentes OpenType. Si el familyName parámetro especifica una fuente que no está instalada en la máquina que ejecuta la aplicación o no se admite, Serif de Microsoft Sans se reemplazará.

Se aplica a

Font(FontFamily, Single, FontStyle, GraphicsUnit)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo Font usando una unidad, un estilo y un tamaño especificados.

public:
 Font(System::Drawing::FontFamily ^ family, float emSize, System::Drawing::FontStyle style, System::Drawing::GraphicsUnit unit);
public Font (System.Drawing.FontFamily family, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit);
new System.Drawing.Font : System.Drawing.FontFamily * single * System.Drawing.FontStyle * System.Drawing.GraphicsUnit -> System.Drawing.Font
Public Sub New (family As FontFamily, emSize As Single, style As FontStyle, unit As GraphicsUnit)

Parámetros

family
FontFamily

FontFamily de la nueva Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en las unidades especificadas por el parámetro unit.

style
FontStyle

FontStyle de la nueva fuente.

unit
GraphicsUnit

GraphicsUnit de la nueva fuente.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

family es null.

Se aplica a

Font(String, Single, FontStyle, GraphicsUnit, Byte)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo Font usando un juego de caracteres, una unidad, un estilo y un tamaño especificados.

public:
 Font(System::String ^ familyName, float emSize, System::Drawing::FontStyle style, System::Drawing::GraphicsUnit unit, System::Byte gdiCharSet);
public Font (string familyName, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit, byte gdiCharSet);
new System.Drawing.Font : string * single * System.Drawing.FontStyle * System.Drawing.GraphicsUnit * byte -> System.Drawing.Font
Public Sub New (familyName As String, emSize As Single, style As FontStyle, unit As GraphicsUnit, gdiCharSet As Byte)

Parámetros

familyName
String

Representación de cadena del objeto FontFamily para el nuevo objeto Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en las unidades especificadas por el parámetro unit.

style
FontStyle

FontStyle de la nueva fuente.

unit
GraphicsUnit

GraphicsUnit de la nueva fuente.

gdiCharSet
Byte

que Byte especifica un juego de caracteres GDI que se va a usar para esta fuente.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

Comentarios

El gdiCharSet parámetro toma un valor de la lista definida en el archivo de encabezado Windows SDK WinGDI.h. Windows Forms las aplicaciones admiten fuentes TrueType y tienen compatibilidad limitada con fuentes OpenType. Si el familyName parámetro especifica una fuente que no está instalada en la máquina que ejecuta la aplicación o no se admite, Serif de Microsoft Sans se reemplazará.

Consulte también

Se aplica a

Font(String, Single, FontStyle)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo objeto Font utilizando un tamaño y estilo especificados.

public:
 Font(System::String ^ familyName, float emSize, System::Drawing::FontStyle style);
public Font (string familyName, float emSize, System.Drawing.FontStyle style);
new System.Drawing.Font : string * single * System.Drawing.FontStyle -> System.Drawing.Font
Public Sub New (familyName As String, emSize As Single, style As FontStyle)

Parámetros

familyName
String

Representación de cadena del objeto FontFamily para el nuevo objeto Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en puntos.

style
FontStyle

FontStyle de la nueva fuente.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

Comentarios

La fuente resultante tiene su Unit propiedad establecida en Point. Windows Forms las aplicaciones admiten fuentes TrueType y tienen compatibilidad limitada con fuentes OpenType. Si el familyName parámetro especifica una fuente que no está instalada en la máquina que ejecuta la aplicación o no se admite, Serif de Microsoft Sans se reemplazará.

Se aplica a

Font(FontFamily, Single, GraphicsUnit)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo objeto Font usando una unidad y un tamaño especificados. Establece el estilo en Regular.

public:
 Font(System::Drawing::FontFamily ^ family, float emSize, System::Drawing::GraphicsUnit unit);
public Font (System.Drawing.FontFamily family, float emSize, System.Drawing.GraphicsUnit unit);
new System.Drawing.Font : System.Drawing.FontFamily * single * System.Drawing.GraphicsUnit -> System.Drawing.Font
Public Sub New (family As FontFamily, emSize As Single, unit As GraphicsUnit)

Parámetros

family
FontFamily

FontFamily de la nueva Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en las unidades especificadas por el parámetro unit.

unit
GraphicsUnit

GraphicsUnit de la nueva fuente.

Excepciones

family es null.

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

Comentarios

La fuente resultante tiene su Style propiedad establecida en FontStyle.Regular.

Se aplica a

Font(FontFamily, Single, FontStyle)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo objeto Font utilizando un tamaño y estilo especificados.

public:
 Font(System::Drawing::FontFamily ^ family, float emSize, System::Drawing::FontStyle style);
public Font (System.Drawing.FontFamily family, float emSize, System.Drawing.FontStyle style);
new System.Drawing.Font : System.Drawing.FontFamily * single * System.Drawing.FontStyle -> System.Drawing.Font
Public Sub New (family As FontFamily, emSize As Single, style As FontStyle)

Parámetros

family
FontFamily

FontFamily de la nueva Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en puntos.

style
FontStyle

FontStyle de la nueva fuente.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

family es null.

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer la Font propiedad de un botón en un nuevo estilo Fontde negrita . Este ejemplo está diseñado para usarse con un formulario Windows Forms que contiene un botón denominado Button1. Pegue el código siguiente en el formulario y asocie el Button1_Click método con el evento del Click botón.

private:
   void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      Button1->Font = gcnew System::Drawing::Font( FontFamily::GenericSansSerif,12.0F,FontStyle::Bold );
   }
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    if (Button1.Font.Style != FontStyle.Bold)
            Button1.Font = new Font(FontFamily.GenericSansSerif,
            12.0F, FontStyle.Bold);
}
 Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    If Not Button1.Font.Style = FontStyle.Bold Then
        Button1.Font = New Font(FontFamily.GenericSansSerif, _
            12.0F, FontStyle.Bold)
    End If
End Sub

Comentarios

La fuente resultante tiene su Unit propiedad establecida en Point.

Se aplica a

Font(String, Single)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo objeto Font utilizando un tamaño especificado.

public:
 Font(System::String ^ familyName, float emSize);
public Font (string familyName, float emSize);
new System.Drawing.Font : string * single -> System.Drawing.Font
Public Sub New (familyName As String, emSize As Single)

Parámetros

familyName
String

Representación de cadena del objeto FontFamily para el nuevo objeto Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en puntos.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el Font constructor . Este ejemplo está diseñado para usarse con un formulario Windows Forms y requiere un PaintEventArgse, que es un parámetro del Paint evento .

private void ConstructFontWithString(PaintEventArgs e)
{
    Font font1 = new Font("Arial", 20);
    e.Graphics.DrawString("Arial Font", font1, Brushes.Red, new PointF(10, 10));
}
Private Sub ConstructFontWithString(ByVal e As PaintEventArgs)
    Dim font1 As New Font("Arial", 20)
    e.Graphics.DrawString("Arial Font", font1, Brushes.Red, New PointF(10, 10))
End Sub

Comentarios

La fuente resultante tiene su Style propiedad establecida en FontStyle.Regular y su Unit propiedad establecida en GraphicsUnit.Point. Windows Forms las aplicaciones admiten fuentes TrueType y tienen compatibilidad limitada con fuentes OpenType. Si el familyName parámetro especifica una fuente que no está instalada en la máquina que ejecuta la aplicación o no se admite, Serif de Microsoft Sans se reemplazará.

Se aplica a

Font(FontFamily, Single)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo objeto Font utilizando un tamaño especificado.

public:
 Font(System::Drawing::FontFamily ^ family, float emSize);
public Font (System.Drawing.FontFamily family, float emSize);
new System.Drawing.Font : System.Drawing.FontFamily * single -> System.Drawing.Font
Public Sub New (family As FontFamily, emSize As Single)

Parámetros

family
FontFamily

FontFamily de la nueva Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en puntos.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

Comentarios

La fuente resultante tiene su Style propiedad establecida en Regular y su Unit propiedad establecida en Point.

Se aplica a

Font(String, Single, GraphicsUnit)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

Inicializa un nuevo objeto Font usando una unidad y un tamaño especificados. El estilo se establece en Regular.

public:
 Font(System::String ^ familyName, float emSize, System::Drawing::GraphicsUnit unit);
public Font (string familyName, float emSize, System.Drawing.GraphicsUnit unit);
new System.Drawing.Font : string * single * System.Drawing.GraphicsUnit -> System.Drawing.Font
Public Sub New (familyName As String, emSize As Single, unit As GraphicsUnit)

Parámetros

familyName
String

Representación de cadena del objeto FontFamily para el nuevo objeto Font.

emSize
Single

Tamaño Em de la nueva fuente, expresado en las unidades especificadas por el parámetro unit.

unit
GraphicsUnit

GraphicsUnit de la nueva fuente.

Excepciones

emSize es menor o igual a 0, se evalúa como infinito o no es un número válido.

Comentarios

La fuente resultante tiene su Style propiedad establecida en FontStyle.Regular.

Se aplica a