.NET Framework クラス ライブラリ
FontFamily.GetEmHeight メソッド

指定のスタイルの em 四角形の高さをフォント デザイン単位で取得します。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)

構文

Visual Basic (宣言)
Public Function GetEmHeight ( _
    style As FontStyle _
) As Integer
Visual Basic (使用法)
Dim instance As FontFamily
Dim style As FontStyle
Dim returnValue As Integer

returnValue = instance.GetEmHeight(style)
C#
public int GetEmHeight (
    FontStyle style
)
C++
public:
int GetEmHeight (
    FontStyle style
)
J#
public int GetEmHeight (
    FontStyle style
)
JScript
public function GetEmHeight (
    style : FontStyle
) : int

パラメータ

style

em 高の取得対象となる FontStyle

戻り値

em 四角形の高さ。
解説

em 四角形とは、そのフォントで最大幅の文字 (通常は "M") が占有する四角形を意味するタイポグラフィ用語です。

使用例

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。

  • FontFamily を作成します。

  • そのフォント ファミリの em 四角形の高さを取得します。

  • em の高さの値をテキストで画面に描画します。

Visual Basic
Public Sub GetEmHeight_Example(ByVal e As PaintEventArgs)

    ' Create a FontFamily object.
    Dim emFontFamily As New FontFamily("arial")

    ' Get the em height of the font family in design units.
    Dim emHeight As Integer = _
    emFontFamily.GetEmHeight(FontStyle.Regular)

    ' Draw the result as a string to the screen.
    e.Graphics.DrawString("emFontFamily.GetEmHeight() returns " & _
    emHeight.ToString() + ".", New Font(emFontFamily, 16), _
    Brushes.Black, New PointF(0, 0))
End Sub
C#
public void GetEmHeight_Example(PaintEventArgs e)
{
    // Create a FontFamily object.
    FontFamily emFontFamily = new FontFamily("arial");
             
    // Get the em height of the font family in design units.
    int emHeight = emFontFamily.GetEmHeight(FontStyle.Regular);
             
    // Draw the result as a string to the screen.
    e.Graphics.DrawString(
        "emFontFamily.GetEmHeight() returns " + emHeight.ToString() + ".",
        new Font(emFontFamily, 16),
        Brushes.Black,
        new PointF(0, 0));
}
C++
public:
   void GetEmHeight_Example( PaintEventArgs^ e )
   {
      // Create a FontFamily object.
      FontFamily^ emFontFamily = gcnew FontFamily( "arial" );

      // Get the em height of the font family in design units.
      int emHeight = emFontFamily->GetEmHeight( FontStyle::Regular );

      // Draw the result as a string to the screen.
      e->Graphics->DrawString( String::Format( "emFontFamily.GetEmHeight() returns {0}.", emHeight ),
            gcnew System::Drawing::Font( emFontFamily,16 ), Brushes::Black, PointF(0,0) );
   }
J#
public void GetEmHeight_Example(PaintEventArgs e)
{
    // Create a FontFamily object.
    FontFamily emFontFamily = new FontFamily("arial");

    // Get the em height of the font family in design units.
    int emHeight = emFontFamily.GetEmHeight(FontStyle.Regular);

    // Draw the result as a string to the screen.
    e.get_Graphics().DrawString("emFontFamily.GetEmHeight() returns "  
        + System.Convert.ToString(emHeight) + ".",  
        new Font(emFontFamily, 16), Brushes.get_Black(), new PointF(0, 0));
} //GetEmHeight_Example
プラットフォーム

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0
参照

タグ :


Page view tracker