Font Constructeurs
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Surcharges
| Nom | Description |
|---|---|
| Font(Font, FontStyle) |
Initialise un nouveau Font qui utilise l’énumération et FontStyle l’existant Font spécifiés. |
| Font(String, Single, FontStyle, GraphicsUnit, Byte, Boolean) |
Initialise une nouvelle Font à l’aide de la taille, du style, de l’unité et du jeu de caractères spécifiés. |
| Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte, Boolean) |
Initialise un nouveau Font jeu de caractères à l’aide d’une taille, d’un style, d’une unité et d’un jeu de caractères spécifiés. |
| Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte) |
Initialise un nouveau Font jeu de caractères à l’aide d’une taille, d’un style, d’une unité et d’un jeu de caractères spécifiés. |
| Font(String, Single, FontStyle, GraphicsUnit) |
Initialise un nouveau Font à l’aide d’une taille, d’un style et d’une unité spécifiés. |
| Font(FontFamily, Single, FontStyle, GraphicsUnit) |
Initialise un nouveau Font à l’aide d’une taille, d’un style et d’une unité spécifiés. |
| Font(String, Single, FontStyle, GraphicsUnit, Byte) |
Initialise un nouveau Font jeu de caractères à l’aide d’une taille, d’un style, d’une unité et d’un jeu de caractères spécifiés. |
| Font(String, Single, FontStyle) |
Initialise un nouveau Font style à l’aide d’une taille et d’un style spécifiés. |
| Font(FontFamily, Single, GraphicsUnit) |
Initialise un nouveau Font à l’aide d’une taille et d’une unité spécifiées. Définit le style sur Regular. |
| Font(FontFamily, Single, FontStyle) |
Initialise un nouveau Font style à l’aide d’une taille et d’un style spécifiés. |
| Font(String, Single) |
Initialise une nouvelle Font taille à l’aide d’une taille spécifiée. |
| Font(FontFamily, Single) |
Initialise une nouvelle Font taille à l’aide d’une taille spécifiée. |
| Font(String, Single, GraphicsUnit) |
Initialise un nouveau Font à l’aide d’une taille et d’une unité spécifiées. Le style est défini sur 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)
Paramètres
- newStyle
- FontStyle
À FontStyle appliquer au nouveau Font. Plusieurs valeurs de l’énumération FontStyle peuvent être combinées avec l’opérateur OR .
Exemples
L’exemple de code suivant illustre l’opérateur Inequality , le Font constructeur et la Bold propriété. Cet exemple est conçu pour être utilisé avec un Windows Form qui contient un bouton nommé Button2. Collez le code suivant dans votre formulaire et associez la Button2_Click méthode à l’événement du Click bouton.
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
S’applique à
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
Initialise une nouvelle Font à l’aide de la taille, du style, de l’unité et du jeu de caractères spécifiés.
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)
Paramètres
- familyName
- String
Représentation sous forme de chaîne du FontFamily nouveau Font.
- emSize
- Single
Taille em de la nouvelle police dans les unités spécifiées par le unit paramètre.
- unit
- GraphicsUnit
Nouvelle GraphicsUnit police.
- gdiVerticalFont
- Boolean
Valeur booléenne indiquant si le nouveau Font est dérivé d’une police verticale GDI.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
Remarques
Le gdiCharSet paramètre prend une valeur dans la liste définie dans le fichier d’en-tête du Kit de développement logiciel (SDK) Windows WinGDI.h. Si le familyName paramètre spécifie une police qui n’est pas installée sur l’ordinateur exécutant l’application ou n’est pas prise en charge, Microsoft Sans Serif est remplacé.
Voir aussi
S’applique à
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
Initialise un nouveau Font jeu de caractères à l’aide d’une taille, d’un style, d’une unité et d’un jeu de caractères spécifiés.
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)
Paramètres
- family
- FontFamily
Le FontFamily nouveau Font.
- emSize
- Single
Taille em de la nouvelle police dans les unités spécifiées par le unit paramètre.
- unit
- GraphicsUnit
Nouvelle GraphicsUnit police.
- gdiVerticalFont
- Boolean
Valeur booléenne indiquant si la nouvelle police est dérivée d’une police verticale GDI.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
family est null
Remarques
Le gdiCharSet paramètre prend une valeur dans la liste définie dans le fichier d’en-tête du Kit de développement logiciel (SDK) Windows WinGDI.h.
S’applique à
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
Initialise un nouveau Font jeu de caractères à l’aide d’une taille, d’un style, d’une unité et d’un jeu de caractères spécifiés.
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)
Paramètres
- family
- FontFamily
Le FontFamily nouveau Font.
- emSize
- Single
Taille em de la nouvelle police dans les unités spécifiées par le unit paramètre.
- unit
- GraphicsUnit
Nouvelle GraphicsUnit police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
family a la valeur null.
Remarques
Le gdiCharSet paramètre prend une valeur dans la liste définie dans le fichier d’en-tête du Kit de développement logiciel (SDK) Windows WinGDI.h.
S’applique à
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
Initialise un nouveau Font à l’aide d’une taille, d’un style et d’une unité spécifiés.
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)
Paramètres
- familyName
- String
Représentation sous forme de chaîne du FontFamily nouveau Font.
- emSize
- Single
Taille em de la nouvelle police dans les unités spécifiées par le unit paramètre.
- unit
- GraphicsUnit
Nouvelle GraphicsUnit police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
Exemples
L’exemple de code suivant montre comment utiliser le Font constructeur. Cet exemple est conçu pour être utilisé avec Windows Forms. Pour exécuter cet exemple, collez ce code dans un formulaire qui contient un bouton nommé Button2et associez la Button2_Click méthode à l’événement Click du bouton.
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
Remarques
Les applications Windows Forms prennent en charge les polices TrueType et ont une prise en charge limitée des polices OpenType. Si le familyName paramètre spécifie une police qui n’est pas installée sur l’ordinateur exécutant l’application ou n’est pas prise en charge, Microsoft Sans Serif est remplacé.
S’applique à
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
Initialise un nouveau Font à l’aide d’une taille, d’un style et d’une unité spécifiés.
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)
Paramètres
- family
- FontFamily
Le FontFamily nouveau Font.
- emSize
- Single
Taille em de la nouvelle police dans les unités spécifiées par le unit paramètre.
- unit
- GraphicsUnit
Nouvelle GraphicsUnit police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
family a la valeur null.
S’applique à
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
Initialise un nouveau Font jeu de caractères à l’aide d’une taille, d’un style, d’une unité et d’un jeu de caractères spécifiés.
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)
Paramètres
- familyName
- String
Représentation sous forme de chaîne du FontFamily nouveau Font.
- emSize
- Single
Taille em de la nouvelle police dans les unités spécifiées par le unit paramètre.
- unit
- GraphicsUnit
Nouvelle GraphicsUnit police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
Remarques
Le gdiCharSet paramètre prend une valeur dans la liste définie dans le fichier d’en-tête du Kit de développement logiciel (SDK) Windows WinGDI.h. Les applications Windows Forms prennent en charge les polices TrueType et ont une prise en charge limitée des polices OpenType. Si le familyName paramètre spécifie une police qui n’est pas installée sur l’ordinateur exécutant l’application ou n’est pas prise en charge, Microsoft Sans Serif est remplacé.
Voir aussi
S’applique à
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
Initialise un nouveau Font style à l’aide d’une taille et d’un style spécifiés.
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)
Paramètres
- familyName
- String
Représentation sous forme de chaîne du FontFamily nouveau Font.
- emSize
- Single
Taille em, en points, de la nouvelle police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
Remarques
La police résultante a sa Unit propriété définie sur Point. Les applications Windows Forms prennent en charge les polices TrueType et ont une prise en charge limitée des polices OpenType. Si le familyName paramètre spécifie une police qui n’est pas installée sur l’ordinateur exécutant l’application ou n’est pas prise en charge, Microsoft Sans Serif est remplacé.
S’applique à
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)
Paramètres
- family
- FontFamily
Le FontFamily nouveau Font.
- emSize
- Single
Taille em de la nouvelle police dans les unités spécifiées par le unit paramètre.
- unit
- GraphicsUnit
Nouvelle GraphicsUnit police.
Exceptions
family a la valeur null.
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
Remarques
La police résultante a sa Style propriété définie sur FontStyle.Regular.
S’applique à
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
Initialise un nouveau Font style à l’aide d’une taille et d’un style spécifiés.
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)
Paramètres
- family
- FontFamily
Le FontFamily nouveau Font.
- emSize
- Single
Taille em, en points, de la nouvelle police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
family a la valeur null.
Exemples
L’exemple de code suivant montre comment définir la Font propriété d’un bouton sur un nouveau style Fontgras. Cet exemple est conçu pour être utilisé avec un Windows Form qui contient un bouton nommé Button1. Collez le code suivant dans votre formulaire et associez la Button1_Click méthode à l’événement du Click bouton.
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
Remarques
La police résultante a sa Unit propriété définie sur Point.
S’applique à
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
Initialise une nouvelle Font taille à l’aide d’une taille spécifiée.
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)
Paramètres
- familyName
- String
Représentation sous forme de chaîne du FontFamily nouveau Font.
- emSize
- Single
Taille em, en points, de la nouvelle police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
Exemples
L’exemple de code suivant montre comment utiliser le Font constructeur. Cet exemple est conçu pour être utilisé avec un Windows Form et nécessite un PaintEventArgseparamètre de l’événement Paint .
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
Remarques
La police résultante a sa Style propriété définie FontStyle.Regular sur et sa Unit propriété définie sur GraphicsUnit.Point. Les applications Windows Forms prennent en charge les polices TrueType et ont une prise en charge limitée des polices OpenType. Si le familyName paramètre spécifie une police qui n’est pas installée sur l’ordinateur exécutant l’application ou n’est pas prise en charge, Microsoft Sans Serif est remplacé.
S’applique à
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
Initialise une nouvelle Font taille à l’aide d’une taille spécifiée.
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)
Paramètres
- family
- FontFamily
Le FontFamily nouveau Font.
- emSize
- Single
Taille em, en points, de la nouvelle police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
Remarques
La police résultante a sa Style propriété définie Regular sur et sa Unit propriété définie sur Point.
S’applique à
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)
Paramètres
- familyName
- String
Représentation sous forme de chaîne du FontFamily nouveau Font.
- emSize
- Single
Taille em de la nouvelle police dans les unités spécifiées par le unit paramètre.
- unit
- GraphicsUnit
Nouvelle GraphicsUnit police.
Exceptions
emSize est inférieur ou égal à 0, correspond à l’infini ou n’est pas un nombre valide.
Remarques
La police résultante a sa Style propriété définie sur FontStyle.Regular.