次の方法で共有


Font コンストラクター

定義

指定した既存の FontFontStyleを使用する新しい Font を初期化します。

オーバーロード

Font(Font, FontStyle)

指定した既存の FontFontStyle 列挙体を使用する新しい Font を初期化します。

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

指定したサイズ、スタイル、単位、および文字セットを使用して、新しい Font を初期化します。

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

指定したサイズ、スタイル、単位、および文字セットを使用して、新しい Font を初期化します。

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

指定したサイズ、スタイル、単位、および文字セットを使用して、新しい Font を初期化します。

Font(String, Single, FontStyle, GraphicsUnit)

指定したサイズ、スタイル、および単位を使用して、新しい Font を初期化します。

Font(FontFamily, Single, FontStyle, GraphicsUnit)

指定したサイズ、スタイル、および単位を使用して、新しい Font を初期化します。

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

指定したサイズ、スタイル、単位、および文字セットを使用して、新しい Font を初期化します。

Font(String, Single, FontStyle)

指定したサイズとスタイルを使用して、新しい Font を初期化します。

Font(FontFamily, Single, GraphicsUnit)

指定したサイズと単位を使用して、新しい Font を初期化します。 スタイルを Regularに設定します。

Font(FontFamily, Single, FontStyle)

指定したサイズとスタイルを使用して、新しい Font を初期化します。

Font(String, Single)

指定したサイズを使用して新しい Font を初期化します。

Font(FontFamily, Single)

指定したサイズを使用して新しい Font を初期化します。

Font(String, Single, GraphicsUnit)

指定したサイズと単位を使用して、新しい Font を初期化します。 スタイルは Regularに設定されます。

Font(Font, FontStyle)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定した既存の FontFontStyle 列挙体を使用する新しい Font を初期化します。

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)

パラメーター

prototype
Font

新しい Fontの作成元となる既存の Font

newStyle
FontStyle

新しい Fontに適用する FontStyleFontStyle 列挙体の複数の値を OR 演算子と組み合わせることができます。

次のコード例では、Inequality 演算子、Font コンストラクター、および Bold プロパティを示します。 この例は、Button2という名前のボタンを含む Windows フォームで使用するように設計されています。 次のコードをフォームに貼り付け、Button2_Click メソッドをボタンの Click イベントに関連付けます。

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

注釈

.NET Framework 2.0 以前のリリースに基づくローカライズされたアプリケーションの場合、そのフォントがアプリケーションのビルドに使用されるコンピューターにインストールされていない場合に prototype のフォントを指定すると、代わりに Microsoft Sans Serif フォントが使用されます。 アプリケーションがこの動作に依存していて、.NET Framework 3.0 用にアプリケーションを再コンパイルする必要がある場合は、prototypeに Microsoft Sans Serif フォントを指定する必要があります。

適用対象

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

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズ、スタイル、単位、および文字セットを使用して、新しい Font を初期化します。

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)

パラメーター

familyName
String

新しい FontFontFamily の文字列形式。

emSize
Single

unit パラメーターで指定された単位での新しいフォントの em サイズ。

style
FontStyle

新しいフォントの FontStyle

unit
GraphicsUnit

新しいフォントの GraphicsUnit

gdiCharSet
Byte

このフォントに使用する GDI 文字セットを指定する Byte

gdiVerticalFont
Boolean

新しい Font が GDI 縦書きフォントから派生しているかどうかを示すブール値。

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

注釈

gdiCharSet パラメーターは、Windows SDK ヘッダー ファイル WinGDI.h で定義されているリストから値を受け取ります。 familyName パラメーターで、アプリケーションを実行しているコンピューターにインストールされていないフォントまたはサポートされていないフォントが指定されている場合は、Microsoft Sans Serif が置き換えられます。

こちらもご覧ください

適用対象

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

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズ、スタイル、単位、および文字セットを使用して、新しい Font を初期化します。

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)

パラメーター

family
FontFamily

新しい FontFontFamily

emSize
Single

unit パラメーターで指定された単位での新しいフォントの em サイズ。

style
FontStyle

新しいフォントの FontStyle

unit
GraphicsUnit

新しいフォントの GraphicsUnit

gdiCharSet
Byte

を指定する Byte

このフォントに使用する GDI 文字セット。

gdiVerticalFont
Boolean

新しいフォントが GDI 縦書きフォントから派生しているかどうかを示すブール値。

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

familynull

注釈

gdiCharSet パラメーターは、Windows SDK ヘッダー ファイル WinGDI.h で定義されているリストから値を受け取ります。

適用対象

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

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズ、スタイル、単位、および文字セットを使用して、新しい Font を初期化します。

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)

パラメーター

family
FontFamily

新しい FontFontFamily

emSize
Single

unit パラメーターで指定された単位での新しいフォントの em サイズ。

style
FontStyle

新しいフォントの FontStyle

unit
GraphicsUnit

新しいフォントの GraphicsUnit

gdiCharSet
Byte

を指定する Byte

新しいフォントに使用する GDI 文字セット。

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

familynullです。

注釈

gdiCharSet パラメーターは、Windows SDK ヘッダー ファイル WinGDI.h で定義されているリストから値を受け取ります。

適用対象

Font(String, Single, FontStyle, GraphicsUnit)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズ、スタイル、および単位を使用して、新しい Font を初期化します。

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)

パラメーター

familyName
String

新しい FontFontFamily の文字列形式。

emSize
Single

unit パラメーターで指定された単位での新しいフォントの em サイズ。

style
FontStyle

新しいフォントの FontStyle

unit
GraphicsUnit

新しいフォントの GraphicsUnit

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

次のコード例は、Font コンストラクターの使用方法を示しています。 この例は、Windows フォームで使用するように設計されています。 この例を実行するには、このコードを Button2という名前のボタンを含むフォームに貼り付け、Button2_Click メソッドをボタンの Click イベントに関連付けます。


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

注釈

Windows フォーム アプリケーションは TrueType フォントをサポートしており、OpenType フォントのサポートは限られています。 familyName パラメーターで、アプリケーションを実行しているコンピューターにインストールされていないフォントまたはサポートされていないフォントが指定されている場合は、Microsoft Sans Serif が置き換えられます。

適用対象

Font(FontFamily, Single, FontStyle, GraphicsUnit)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズ、スタイル、および単位を使用して、新しい Font を初期化します。

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)

パラメーター

family
FontFamily

新しい FontFontFamily

emSize
Single

unit パラメーターで指定された単位での新しいフォントの em サイズ。

style
FontStyle

新しいフォントの FontStyle

unit
GraphicsUnit

新しいフォントの GraphicsUnit

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

familynullです。

適用対象

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

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズ、スタイル、単位、および文字セットを使用して、新しい Font を初期化します。

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)

パラメーター

familyName
String

新しい FontFontFamily の文字列形式。

emSize
Single

unit パラメーターで指定された単位での新しいフォントの em サイズ。

style
FontStyle

新しいフォントの FontStyle

unit
GraphicsUnit

新しいフォントの GraphicsUnit

gdiCharSet
Byte

このフォントに使用する GDI 文字セットを指定する Byte

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

注釈

gdiCharSet パラメーターは、Windows SDK ヘッダー ファイル WinGDI.h で定義されているリストから値を受け取ります。 Windows フォーム アプリケーションは TrueType フォントをサポートしており、OpenType フォントのサポートは限られています。 familyName パラメーターで、アプリケーションを実行しているコンピューターにインストールされていないフォントまたはサポートされていないフォントが指定されている場合は、Microsoft Sans Serif が置き換えられます。

こちらもご覧ください

適用対象

Font(String, Single, FontStyle)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズとスタイルを使用して、新しい Font を初期化します。

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)

パラメーター

familyName
String

新しい FontFontFamily の文字列形式。

emSize
Single

新しいフォントの em サイズ (ポイント単位)。

style
FontStyle

新しいフォントの FontStyle

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

注釈

結果のフォントには、Unit プロパティが Pointに設定されています。 Windows フォーム アプリケーションは TrueType フォントをサポートしており、OpenType フォントのサポートは限られています。 familyName パラメーターで、アプリケーションを実行しているコンピューターにインストールされていないフォントまたはサポートされていないフォントが指定されている場合は、Microsoft Sans Serif が置き換えられます。

適用対象

Font(FontFamily, Single, GraphicsUnit)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズと単位を使用して、新しい Font を初期化します。 スタイルを 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)

パラメーター

family
FontFamily

新しい FontFontFamily

emSize
Single

unit パラメーターで指定された単位での新しいフォントの em サイズ。

unit
GraphicsUnit

新しいフォントの GraphicsUnit

例外

familynullです。

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

注釈

結果のフォントには、Style プロパティが FontStyle.Regularに設定されています。

適用対象

Font(FontFamily, Single, FontStyle)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズとスタイルを使用して、新しい Font を初期化します。

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)

パラメーター

family
FontFamily

新しい FontFontFamily

emSize
Single

新しいフォントの em サイズ (ポイント単位)。

style
FontStyle

新しいフォントの FontStyle

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

familynullです。

次のコード例では、ボタンの Font プロパティを新しい太字スタイルの Fontに設定する方法を示します。 この例は、Button1という名前のボタンを含む Windows フォームで使用するように設計されています。 次のコードをフォームに貼り付け、Button1_Click メソッドをボタンの Click イベントに関連付けます。

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

注釈

結果のフォントには、Unit プロパティが Pointに設定されています。

適用対象

Font(String, Single)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズを使用して新しい Font を初期化します。

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)

パラメーター

familyName
String

新しい FontFontFamily の文字列形式。

emSize
Single

新しいフォントの em サイズ (ポイント単位)。

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

次のコード例は、Font コンストラクターの使用方法を示しています。 この例は、Windows フォームで使用するように設計されており、Paint イベントのパラメーターである PaintEventArgseが必要です。

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

注釈

結果のフォントの Style プロパティは FontStyle.Regular に設定され、その Unit プロパティは GraphicsUnit.Pointに設定されます。 Windows フォーム アプリケーションは TrueType フォントをサポートしており、OpenType フォントのサポートは限られています。 familyName パラメーターで、アプリケーションを実行しているコンピューターにインストールされていないフォントまたはサポートされていないフォントが指定されている場合は、Microsoft Sans Serif が置き換えられます。

適用対象

Font(FontFamily, Single)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズを使用して新しい Font を初期化します。

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)

パラメーター

family
FontFamily

新しい FontFontFamily

emSize
Single

新しいフォントの em サイズ (ポイント単位)。

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

注釈

結果のフォントの Style プロパティは Regular に設定され、その Unit プロパティは Pointに設定されます。

適用対象

Font(String, Single, GraphicsUnit)

ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs
ソース:
Font.cs

指定したサイズと単位を使用して、新しい Font を初期化します。 スタイルは 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)

パラメーター

familyName
String

新しい FontFontFamily の文字列形式。

emSize
Single

unit パラメーターで指定された単位での新しいフォントの em サイズ。

unit
GraphicsUnit

新しいフォントの GraphicsUnit

例外

emSize が 0 以下であるか、無限大に評価されるか、有効な数値ではありません。

注釈

結果のフォントには、Style プロパティが FontStyle.Regularに設定されています。

適用対象