Font Constructores
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Sobrecargas
| Nombre | Description |
|---|---|
| Font(Font, FontStyle) |
Inicializa un nuevo Font objeto que usa la enumeración y FontStyle existente Font especificadas. |
| Font(String, Single, FontStyle, GraphicsUnit, Byte, Boolean) |
Inicializa un nuevo Font con el tamaño, el estilo, la unidad y el juego de caracteres especificados. |
| Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte, Boolean) |
Inicializa un nuevo Font con un tamaño, estilo, unidad y juego de caracteres especificados. |
| Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte) |
Inicializa un nuevo Font con un tamaño, estilo, unidad y juego de caracteres especificados. |
| Font(String, Single, FontStyle, GraphicsUnit) |
Inicializa un nuevo Font con un tamaño, un estilo y una unidad especificados. |
| Font(FontFamily, Single, FontStyle, GraphicsUnit) |
Inicializa un nuevo Font con un tamaño, un estilo y una unidad especificados. |
| Font(String, Single, FontStyle, GraphicsUnit, Byte) |
Inicializa un nuevo Font con un tamaño, estilo, unidad y juego de caracteres especificados. |
| Font(String, Single, FontStyle) |
Inicializa un nuevo Font con un estilo y un tamaño especificados. |
| Font(FontFamily, Single, GraphicsUnit) |
Inicializa un nuevo Font con un tamaño y una unidad especificados. Establece el estilo en Regular. |
| Font(FontFamily, Single, FontStyle) |
Inicializa un nuevo Font con un estilo y un tamaño especificados. |
| Font(String, Single) |
Inicializa un nuevo Font con un tamaño especificado. |
| Font(FontFamily, Single) |
Inicializa un nuevo Font con un tamaño especificado. |
| Font(String, Single, GraphicsUnit) |
Inicializa un nuevo Font con un tamaño y una unidad especificados. El estilo se establece en Regular. |
Font(Font, FontStyle)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
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
- newStyle
- FontStyle
que FontStyle se va a aplicar al nuevo Font. Se pueden combinar varios valores de la FontStyle enumeración con el OR operador .
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 Form que contiene un botón denominado Button2. Pegue el código siguiente en el formulario y asocie el Button2_Click método al 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
Se aplica a
Font(String, Single, FontStyle, GraphicsUnit, Byte, Boolean)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con el tamaño, el estilo, la unidad y el juego de caracteres 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 de para FontFamily el nuevo Fontobjeto .
- emSize
- Single
Tamaño em de la nueva fuente en las unidades especificadas por el unit parámetro .
- unit
- GraphicsUnit
GraphicsUnit de la nueva fuente.
- gdiVerticalFont
- Boolean
Valor booleano que indica si el nuevo Font se deriva de una fuente vertical GDI.
Excepciones
emSize es menor o igual que 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 de 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, se sustituirá Microsoft Sans Serif.
Consulte también
Se aplica a
Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte, Boolean)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con un tamaño, estilo, unidad y juego de caracteres 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 del nuevo Fontobjeto .
- emSize
- Single
Tamaño em de la nueva fuente en las unidades especificadas por el unit parámetro .
- unit
- GraphicsUnit
GraphicsUnit de la nueva fuente.
- gdiCharSet
- Byte
que Byte especifica un objeto
Juego de caracteres GDI que se va a 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 que 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 de Windows SDK WinGDI.h.
Se aplica a
Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con un tamaño, estilo, unidad y juego de caracteres 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 del nuevo Fontobjeto .
- emSize
- Single
Tamaño em de la nueva fuente en las unidades especificadas por el unit parámetro .
- unit
- GraphicsUnit
GraphicsUnit de la nueva fuente.
- gdiCharSet
- Byte
que Byte especifica un objeto
Juego de caracteres GDI que se va a usar para la nueva fuente.
Excepciones
emSize es menor o igual que 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 de Windows SDK WinGDI.h.
Se aplica a
Font(String, Single, FontStyle, GraphicsUnit)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con un tamaño, un estilo y una unidad 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 de para FontFamily el nuevo Fontobjeto .
- emSize
- Single
Tamaño em de la nueva fuente en las unidades especificadas por el unit parámetro .
- unit
- GraphicsUnit
GraphicsUnit de la nueva fuente.
Excepciones
emSize es menor o igual que 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
Las aplicaciones de Windows Forms 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, se sustituirá Microsoft Sans Serif.
Se aplica a
Font(FontFamily, Single, FontStyle, GraphicsUnit)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con un tamaño, un estilo y una unidad 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 del nuevo Fontobjeto .
- emSize
- Single
Tamaño em de la nueva fuente en las unidades especificadas por el unit parámetro .
- unit
- GraphicsUnit
GraphicsUnit de la nueva fuente.
Excepciones
emSize es menor o igual que 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
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con un tamaño, estilo, unidad y juego de caracteres 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 de para FontFamily el nuevo Fontobjeto .
- emSize
- Single
Tamaño em de la nueva fuente en las unidades especificadas por el unit parámetro .
- unit
- GraphicsUnit
GraphicsUnit de la nueva fuente.
Excepciones
emSize es menor o igual que 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 de Windows SDK WinGDI.h. Las aplicaciones de Windows Forms 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, se sustituirá Microsoft Sans Serif.
Consulte también
Se aplica a
Font(String, Single, FontStyle)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con un estilo y un tamaño 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 de para FontFamily el nuevo Fontobjeto .
- emSize
- Single
Tamaño em, en puntos, de la nueva fuente.
Excepciones
emSize es menor o igual que 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. Las aplicaciones de Windows Forms 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, se sustituirá Microsoft Sans Serif.
Se aplica a
Font(FontFamily, Single, GraphicsUnit)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
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 del nuevo Fontobjeto .
- emSize
- Single
Tamaño em de la nueva fuente en las unidades especificadas por el unit parámetro .
- unit
- GraphicsUnit
GraphicsUnit de la nueva fuente.
Excepciones
family es null.
emSize es menor o igual que 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
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con un estilo y un tamaño 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 del nuevo Fontobjeto .
- emSize
- Single
Tamaño em, en puntos, de la nueva fuente.
Excepciones
emSize es menor o igual que 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 Form que contiene un botón denominado Button1. Pegue el código siguiente en el formulario y asocie el Button1_Click método al 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
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con 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 de para FontFamily el nuevo Fontobjeto .
- emSize
- Single
Tamaño em, en puntos, de la nueva fuente.
Excepciones
emSize es menor o igual que 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 FontStyle.Regular en y su Unit propiedad establecida en GraphicsUnit.Point. Las aplicaciones de Windows Forms 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, se sustituirá Microsoft Sans Serif.
Se aplica a
Font(FontFamily, Single)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
Inicializa un nuevo Font con 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 del nuevo Fontobjeto .
- emSize
- Single
Tamaño em, en puntos, de la nueva fuente.
Excepciones
emSize es menor o igual que 0, se evalúa como infinito o no es un número válido.
Comentarios
La fuente resultante tiene su Style propiedad establecida Regular en y su Unit propiedad establecida en Point.
Se aplica a
Font(String, Single, GraphicsUnit)
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
- Source:
- Font.cs
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 de para FontFamily el nuevo Fontobjeto .
- emSize
- Single
Tamaño em de la nueva fuente en las unidades especificadas por el unit parámetro .
- unit
- GraphicsUnit
GraphicsUnit de la nueva fuente.
Excepciones
emSize es menor o igual que 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.