Font コンストラクタ (String, Single)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Dim familyName As String Dim emSize As Single Dim instance As New Font(familyName, emSize)
解説
結果として得られたフォントの Style プロパティは FontStyle.Regular に設定され、Unit プロパティは GraphicsUnit.Point に設定されます。Windows フォーム アプリケーションでは、TrueType フォントをサポートしています。また、OpenType フォントも制限付きでサポートしています。familyName パラメータが、アプリケーションを実行するコンピュータにインストールされていないフォントやサポートされていないフォントを指定した場合は、代わりに Microsoft Sans Serif が使用されます。
Font コンストラクタと Size、SizeInPoints、および Unit の各プロパティを使用する方法を次のコード例に示します。この例は、ComboBox1 という名前の ComboBox に "Bigger" と "Smaller" という文字列が設定された Windows フォームでの使用を意図してデザインされています。そして、次のコードをそのフォームに貼り付け、ComboBox1_SelectedIndexChanged メソッドに、ComboBox コントロールの SelectedIndexChanged イベントを関連付けます。
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged ' Cast the sender object back to a ComboBox. Dim ComboBox1 As ComboBox = CType(sender, ComboBox) ' Retrieve the selected item. Dim selectedString As String = CType(ComboBox1.SelectedItem, String) ' Convert it to lowercase. selectedString = selectedString.ToLower() ' Declare the current size. Dim currentSize As Single ' Switch on the selected item. Select Case selectedString ' If Bigger is selected, get the current size from the ' Size property and increase it. Reset the font to the ' new size, using the current unit. Case "bigger" currentSize = Label1.Font.Size currentSize += 2.0F Label1.Font = New Font(Label1.Font.Name, currentSize, _ Label1.Font.Style, Label1.Font.Unit) ' If Smaller is selected, get the current size, in points , ' and decrease it by 1. Reset the font with the new size ' in points. Case "smaller" currentSize = Label1.Font.SizeInPoints currentSize -= 1 Label1.Font = New Font(Label1.Font.Name, currentSize, _ Label1.Font.Style) End Select End Sub
private void ComboBox1_SelectedIndexChanged(System.Object sender, System.EventArgs e) { // Cast the sender object back to a ComboBox. ComboBox ComboBox1 = (ComboBox) sender; // Retrieve the selected item. string selectedString = (string) ComboBox1.SelectedItem; // Convert it to lowercase. selectedString = selectedString.ToLower(); // Declare the current size. float currentSize; // Switch on the selected item. switch(selectedString) { // If Bigger is selected, get the current size from the // Size property and increase it. Reset the font to the // new size, using the current unit. case "bigger": currentSize = Label1.Font.Size; currentSize += 2.0F; Label1.Font = new Font(Label1.Font.Name, currentSize, Label1.Font.Style, Label1.Font.Unit); // If Smaller is selected, get the current size, in points , // and decrease it by 1. Reset the font with the new size // in points. break; case "smaller": currentSize = Label1.Font.SizeInPoints; currentSize -= 1; Label1.Font = new Font(Label1.Font.Name, currentSize, Label1.Font.Style); break; } }
private: void ComboBox1_SelectedIndexChanged(System::Object^ sender , System::EventArgs^ e) { // Cast the sender object back to a ComboBox. ComboBox^ ComboBox1 = (ComboBox^) sender; // Retrieve the selected item. String^ selectedString = (String^) ComboBox1->SelectedItem; // Convert it to lowercase. selectedString = selectedString->ToLower(); // Declare the current size. float currentSize; // If Bigger is selected, get the current size from the // Size property and increase it. Reset the font to the // new size, using the current unit. if (selectedString == "bigger") { currentSize = Label1->Font->Size; currentSize += 2.0F; Label1->Font =gcnew System::Drawing::Font(Label1->Font->Name, currentSize, Label1->Font->Style, Label1->Font->Unit); } // If Smaller is selected, get the current size, in // points, and decrease it by 2. Reset the font with // the new size in points. if (selectedString == "smaller") { currentSize = Label1->Font->Size; currentSize -= 2.0F; Label1->Font = gcnew System::Drawing::Font(Label1->Font->Name, currentSize, Label1->Font->Style); } }
private void comboBox1_SelectedIndexChanged(Object sender, System.EventArgs e) { // Cast the sender object back to a ComboBox. ComboBox comboBox1 = (ComboBox)sender; // Retrieve the selected item. String selectedString = (String)comboBox1.get_SelectedItem(); // Convert it to lowercase. selectedString = selectedString.ToLower(); // Declare the current size. float currentSize; // Switch on the selected item. // If Bigger is selected, get the current size from the // Size property and increase it. Reset the font to the // new size, using the current unit. if (selectedString.Equals("bigger")) { currentSize = label1.get_Font().get_Size(); currentSize += 2; label1.set_Font(new Font(label1.get_Font().get_Name(), currentSize, label1.get_Font().get_Style(), label1.get_Font().get_Unit())); } else { // If Smaller is selected, get the current size, in points, // and decrease it by 1. Reset the font with the new size // in points. if (selectedString.Equals("smaller")) { currentSize = label1.get_Font().get_SizeInPoints(); currentSize -= 1; label1.set_Font(new Font(label1.get_Font().get_Name(), currentSize, label1.get_Font().get_Style())); } } } //comboBox1_SelectedIndexChanged
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (Device, Font)
アセンブリ: Microsoft.WindowsMobile.DirectX (microsoft.windowsmobile.directx.dll 内)
構文
.NET Framework のセキュリティ
プラットフォーム
Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (Device, FontDescription)
アセンブリ: Microsoft.WindowsMobile.DirectX (microsoft.windowsmobile.directx.dll 内)
構文
Dim device As Device Dim description As FontDescription Dim instance As New Font(device, description)
- description
FontDescription 構造体。
プラットフォーム
Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (FontFamily, Single, FontStyle)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Dim family As FontFamily Dim emSize As Single Dim style As FontStyle Dim instance As New Font(family, emSize, style)
使用例
ボタンの Font プロパティを新しい太字スタイルの Font に設定する方法を次のコード例に示します。この例は、Button1 という名前のボタンを含んだ Windows フォームでの使用を意図してデザインされています。次のコードをフォームに貼り付け、Button1_Click メソッドをボタンの Click イベントに関連付けます。
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
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); }
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (FontFamily, Single, GraphicsUnit)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Dim family As FontFamily Dim emSize As Single Dim unit As GraphicsUnit Dim instance As New Font(family, emSize, unit)
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (FontFamily, Single, FontStyle, GraphicsUnit)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Public Sub New ( _ family As FontFamily, _ emSize As Single, _ style As FontStyle, _ unit As GraphicsUnit _ )
Dim family As FontFamily Dim emSize As Single Dim style As FontStyle Dim unit As GraphicsUnit Dim instance As New Font(family, emSize, style, unit)
public function Font ( family : FontFamily, emSize : float, style : FontStyle, unit : GraphicsUnit )
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (FontFamily, Single, FontStyle, GraphicsUnit, Byte)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Public Sub New ( _ family As FontFamily, _ emSize As Single, _ style As FontStyle, _ unit As GraphicsUnit, _ gdiCharSet As Byte _ )
Dim family As FontFamily Dim emSize As Single Dim style As FontStyle Dim unit As GraphicsUnit Dim gdiCharSet As Byte Dim instance As New Font(family, emSize, style, unit, gdiCharSet)
public Font ( FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet )
public: Font ( FontFamily^ family, float emSize, FontStyle style, GraphicsUnit unit, unsigned char gdiCharSet )
public Font ( FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet )
public function Font ( family : FontFamily, emSize : float, style : FontStyle, unit : GraphicsUnit, gdiCharSet : byte )
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (FontFamily, Single, FontStyle, GraphicsUnit, Byte, Boolean)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Public Sub New ( _ family As FontFamily, _ emSize As Single, _ style As FontStyle, _ unit As GraphicsUnit, _ gdiCharSet As Byte, _ gdiVerticalFont As Boolean _ )
Dim family As FontFamily Dim emSize As Single Dim style As FontStyle Dim unit As GraphicsUnit Dim gdiCharSet As Byte Dim gdiVerticalFont As Boolean Dim instance As New Font(family, emSize, style, unit, gdiCharSet, gdiVerticalFont)
public Font ( FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont )
public: Font ( FontFamily^ family, float emSize, FontStyle style, GraphicsUnit unit, unsigned char gdiCharSet, bool gdiVerticalFont )
public Font ( FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, boolean gdiVerticalFont )
public function Font ( family : FontFamily, emSize : float, style : FontStyle, unit : GraphicsUnit, gdiCharSet : byte, gdiVerticalFont : boolean )
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ
オーバーロードの一覧
Font コンストラクタ (String, Single, FontStyle)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Dim familyName As String Dim emSize As Single Dim style As FontStyle Dim instance As New Font(familyName, emSize, style)
解説
結果として得られたフォントの Unit プロパティは Point に設定されます。Windows フォーム アプリケーションでは、TrueType フォントをサポートしています。また、OpenType フォントも制限付きでサポートしています。familyName パラメータが、アプリケーションを実行するコンピュータにインストールされていないフォントやサポートされていないフォントを指定した場合は、代わりに Microsoft Sans Serif が使用されます。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (IntPtr)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (FontFamily, Single)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
例外
解説
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (String, Single, FontStyle, GraphicsUnit, Byte, Boolean)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Public Sub New ( _ familyName As String, _ emSize As Single, _ style As FontStyle, _ unit As GraphicsUnit, _ gdiCharSet As Byte, _ gdiVerticalFont As Boolean _ )
Dim familyName As String Dim emSize As Single Dim style As FontStyle Dim unit As GraphicsUnit Dim gdiCharSet As Byte Dim gdiVerticalFont As Boolean Dim instance As New Font(familyName, emSize, style, unit, gdiCharSet, gdiVerticalFont)
public Font ( string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont )
public: Font ( String^ familyName, float emSize, FontStyle style, GraphicsUnit unit, unsigned char gdiCharSet, bool gdiVerticalFont )
public Font ( String familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, boolean gdiVerticalFont )
public function Font ( familyName : String, emSize : float, style : FontStyle, unit : GraphicsUnit, gdiCharSet : byte, gdiVerticalFont : boolean )
解説
gdiCharSet パラメータは、プラットフォーム SDK のヘッダー ファイル WinGDI.h で定義されたリストから値を取得します。familyName パラメータが、アプリケーションを実行するコンピュータにインストールされていないフォントやサポートされていないフォントを指定した場合は、代わりに Microsoft Sans Serif が使用されます。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (Font, FontStyle)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
使用例
op_Inequality 演算子、Font コンストラクタ、および Bold プロパティを使用するコード例を次に示します。この例は、Button2 という名前のボタンを含んだ Windows フォームでの使用を意図してデザインされています。次のコードをフォームに貼り付け、Button2_Click メソッドをボタンの Click イベントに関連付けます。
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
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); } }
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.get_BackColor().Equals(SystemColors.get_ControlDark()))) { this.set_BackColor(SystemColors.get_ControlDark()); } if (!(this.get_Font().get_Bold())) { this.set_Font(new Font(this.get_Font(), FontStyle.Bold)); } } //button2_Click
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (String, Single, FontStyle, GraphicsUnit)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Public Sub New ( _ familyName As String, _ emSize As Single, _ style As FontStyle, _ unit As GraphicsUnit _ )
Dim familyName As String Dim emSize As Single Dim style As FontStyle Dim unit As GraphicsUnit Dim instance As New Font(familyName, emSize, style, unit)
public function Font ( familyName : String, emSize : float, style : FontStyle, unit : GraphicsUnit )
解説
Windows フォーム アプリケーションでは、TrueType フォントをサポートしています。また、OpenType フォントも制限付きでサポートしています。familyName パラメータが、アプリケーションを実行するコンピュータにインストールされていないフォントやサポートされていないフォントを指定した場合は、代わりに Microsoft Sans Serif が使用されます。
Font コンストラクタを使用する方法を次のコード例に示します。この例は、Windows フォームでの使用を意図してデザインされています。この例を実行するには、このコードを Button2 という名前のボタンが配置されているフォームに貼り付け、Button2_Click メソッドをボタンの Click イベントに関連付けます。
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
private void Button2_Click(System.Object sender, System.EventArgs e) { Button2.Font = new Font(FontFamily.GenericMonospace, 12.0F, FontStyle.Italic, GraphicsUnit.Pixel); }
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (String, Single, GraphicsUnit)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Dim familyName As String Dim emSize As Single Dim unit As GraphicsUnit Dim instance As New Font(familyName, emSize, unit)
解説
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ (String, Single, FontStyle, GraphicsUnit, Byte)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Public Sub New ( _ familyName As String, _ emSize As Single, _ style As FontStyle, _ unit As GraphicsUnit, _ gdiCharSet As Byte _ )
Dim familyName As String Dim emSize As Single Dim style As FontStyle Dim unit As GraphicsUnit Dim gdiCharSet As Byte Dim instance As New Font(familyName, emSize, style, unit, gdiCharSet)
public Font ( string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet )
public: Font ( String^ familyName, float emSize, FontStyle style, GraphicsUnit unit, unsigned char gdiCharSet )
public Font ( String familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet )
public function Font ( familyName : String, emSize : float, style : FontStyle, unit : GraphicsUnit, gdiCharSet : byte )
解説
gdiCharSet パラメータは、プラットフォーム SDK のヘッダー ファイル WinGDI.h で定義されたリストから値を取得します。Windows フォーム アプリケーションでは、TrueType フォントをサポートしています。また、OpenType フォントも制限付きでサポートしています。familyName パラメータが、アプリケーションを実行するコンピュータにインストールされていないフォントやサポートされていないフォントを指定した場合は、代わりに Microsoft Sans Serif が使用されます。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Font コンストラクタ
- Font コンストラクタのページへのリンク