GraphicsPath.AddString メソッド

定義

パスに文字列を追加します。Adds a text string to this path.

オーバーロード

AddString(String, FontFamily, Int32, Single, RectangleF, StringFormat)

パスに文字列を追加します。Adds a text string to this path.

AddString(String, FontFamily, Int32, Single, Rectangle, StringFormat)

パスに文字列を追加します。Adds a text string to this path.

AddString(String, FontFamily, Int32, Single, PointF, StringFormat)

パスに文字列を追加します。Adds a text string to this path.

AddString(String, FontFamily, Int32, Single, Point, StringFormat)

パスに文字列を追加します。Adds a text string to this path.

AddString(String, FontFamily, Int32, Single, RectangleF, StringFormat)

パスに文字列を追加します。Adds a text string to this path.

public:
 void AddString(System::String ^ s, System::Drawing::FontFamily ^ family, int style, float emSize, System::Drawing::RectangleF layoutRect, System::Drawing::StringFormat ^ format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat? format);
member this.AddString : string * System.Drawing.FontFamily * int * single * System.Drawing.RectangleF * System.Drawing.StringFormat -> unit
Public Sub AddString (s As String, family As FontFamily, style As Integer, emSize As Single, layoutRect As RectangleF, format As StringFormat)

パラメーター

s
String

追加する StringThe String to add.

family
FontFamily

テスト描画を行うときに使用するフォントの名前を表す FontFamilyA FontFamily that represents the name of the font with which the test is drawn.

style
Int32

テキストに関するスタイル情報 (太字、斜体など) を表す FontStyle 列挙体。A FontStyle enumeration that represents style information about the text (bold, italic, and so on). この値は、整数としてキャストする必要があります (後のコード例を参照)。This must be cast as an integer (see the example code later in this section).

emSize
Single

文字の境界を決める em 正方形ボックスの高さ。The height of the em square box that bounds the character.

layoutRect
RectangleF

テキストに外接する四角形を表す RectangleFA RectangleF that represents the rectangle that bounds the text.

format
StringFormat

行間や配置など、テキストの書式設定情報を指定する StringFormatA StringFormat that specifies text formatting information, such as line spacing and alignment.

例については、「AddString(String, FontFamily, Int32, Single, Point, StringFormat)」を参照してください。For an example, see AddString(String, FontFamily, Int32, Single, Point, StringFormat).

適用対象

AddString(String, FontFamily, Int32, Single, Rectangle, StringFormat)

パスに文字列を追加します。Adds a text string to this path.

public:
 void AddString(System::String ^ s, System::Drawing::FontFamily ^ family, int style, float emSize, System::Drawing::Rectangle layoutRect, System::Drawing::StringFormat ^ format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Rectangle layoutRect, System.Drawing.StringFormat format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Rectangle layoutRect, System.Drawing.StringFormat? format);
member this.AddString : string * System.Drawing.FontFamily * int * single * System.Drawing.Rectangle * System.Drawing.StringFormat -> unit
Public Sub AddString (s As String, family As FontFamily, style As Integer, emSize As Single, layoutRect As Rectangle, format As StringFormat)

パラメーター

s
String

追加する StringThe String to add.

family
FontFamily

テスト描画を行うときに使用するフォントの名前を表す FontFamilyA FontFamily that represents the name of the font with which the test is drawn.

style
Int32

テキストに関するスタイル情報 (太字、斜体など) を表す FontStyle 列挙体。A FontStyle enumeration that represents style information about the text (bold, italic, and so on). この値は、整数としてキャストする必要があります (後のコード例を参照)。This must be cast as an integer (see the example code later in this section).

emSize
Single

文字の境界を決める em 正方形ボックスの高さ。The height of the em square box that bounds the character.

layoutRect
Rectangle

テキストに外接する四角形を表す RectangleA Rectangle that represents the rectangle that bounds the text.

format
StringFormat

行間や配置など、テキストの書式設定情報を指定する StringFormatA StringFormat that specifies text formatting information, such as line spacing and alignment.

例については、「AddString(String, FontFamily, Int32, Single, Point, StringFormat)」を参照してください。For an example, see AddString(String, FontFamily, Int32, Single, Point, StringFormat).

適用対象

AddString(String, FontFamily, Int32, Single, PointF, StringFormat)

パスに文字列を追加します。Adds a text string to this path.

public:
 void AddString(System::String ^ s, System::Drawing::FontFamily ^ family, int style, float emSize, System::Drawing::PointF origin, System::Drawing::StringFormat ^ format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.PointF origin, System.Drawing.StringFormat format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.PointF origin, System.Drawing.StringFormat? format);
member this.AddString : string * System.Drawing.FontFamily * int * single * System.Drawing.PointF * System.Drawing.StringFormat -> unit
Public Sub AddString (s As String, family As FontFamily, style As Integer, emSize As Single, origin As PointF, format As StringFormat)

パラメーター

s
String

追加する StringThe String to add.

family
FontFamily

テスト描画を行うときに使用するフォントの名前を表す FontFamilyA FontFamily that represents the name of the font with which the test is drawn.

style
Int32

テキストに関するスタイル情報 (太字、斜体など) を表す FontStyle 列挙体。A FontStyle enumeration that represents style information about the text (bold, italic, and so on). この値は、整数としてキャストする必要があります (後のコード例を参照)。This must be cast as an integer (see the example code later in this section).

emSize
Single

文字の境界を決める em 正方形ボックスの高さ。The height of the em square box that bounds the character.

origin
PointF

テキストを開始する点を表す PointFA PointF that represents the point where the text starts.

format
StringFormat

行間や配置など、テキストの書式設定情報を指定する StringFormatA StringFormat that specifies text formatting information, such as line spacing and alignment.

例については、「AddString(String, FontFamily, Int32, Single, Point, StringFormat)」を参照してください。For an example, see AddString(String, FontFamily, Int32, Single, Point, StringFormat).

適用対象

AddString(String, FontFamily, Int32, Single, Point, StringFormat)

パスに文字列を追加します。Adds a text string to this path.

public:
 void AddString(System::String ^ s, System::Drawing::FontFamily ^ family, int style, float emSize, System::Drawing::Point origin, System::Drawing::StringFormat ^ format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Point origin, System.Drawing.StringFormat format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Point origin, System.Drawing.StringFormat? format);
member this.AddString : string * System.Drawing.FontFamily * int * single * System.Drawing.Point * System.Drawing.StringFormat -> unit
Public Sub AddString (s As String, family As FontFamily, style As Integer, emSize As Single, origin As Point, format As StringFormat)

パラメーター

s
String

追加する StringThe String to add.

family
FontFamily

テスト描画を行うときに使用するフォントの名前を表す FontFamilyA FontFamily that represents the name of the font with which the test is drawn.

style
Int32

テキストに関するスタイル情報 (太字、斜体など) を表す FontStyle 列挙体。A FontStyle enumeration that represents style information about the text (bold, italic, and so on). この値は、整数としてキャストする必要があります (後のコード例を参照)。This must be cast as an integer (see the example code later in this section).

emSize
Single

文字の境界を決める em 正方形ボックスの高さ。The height of the em square box that bounds the character.

origin
Point

テキストを開始する点を表す PointA Point that represents the point where the text starts.

format
StringFormat

行間や配置など、テキストの書式設定情報を指定する StringFormatA StringFormat that specifies text formatting information, such as line spacing and alignment.

次のコード例は、Windows フォームで使用するように設計されており、イベントオブジェクトを必要とし PaintEventArgs e OnPaint ます。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. コードは、次のアクションを実行します。The code performs the following actions:

  • パスを作成します。Creates a path.

  • 文字列とフォントの引数を設定します。Sets up string and font arguments.

  • パスに文字列を追加します。Adds the string to the path.

  • 文字列を画面に描画します。Draws the string to the screen.

重要な点が2つあります。最初に、 fontStyle 引数が整数としてキャストされていることに注意してください。There are two important things to be pointed out. First, notice that the fontStyle argument is cast as an integer. AddStringこのメソッドでは、2つ以上の FontStyle メンバーを組み合わせて目的のフォントスタイル (この場合はと) を作成できるようにする必要があり Italic Underline ます。The AddString method requires this so that two or more FontStyle members can be combined to create the desired font style (in this case, Italic and Underline). 2番目の方法として、メソッドでは FillPath なく、メソッドが使用されていることに注意して DrawPath ください。Secondly, notice that the FillPath method is used rather than the DrawPath method. が使用されている場合は、 FillPath 純色がレンダリングされ DrawPath ます。一方、を使用すると、テキストはアウトラインスタイルになります。If FillPath is used, solid text is rendered, whereas if DrawPath is used, the text will be an outline style.

private:
   void AddStringExample( PaintEventArgs^ e )
   {
      // Create a GraphicsPath object.
      GraphicsPath^ myPath = gcnew GraphicsPath;

      // Set up all the string parameters.
      String^ stringText = "Sample Text";
      FontFamily^ family = gcnew FontFamily( "Arial" );
      int fontStyle = (int)FontStyle::Italic;
      int emSize = 26;
      Point origin = Point(20,20);
      StringFormat^ format = StringFormat::GenericDefault;

      // Add the string to the path.
      myPath->AddString( stringText, family, fontStyle, (float)emSize, origin, format );

      //Draw the path to the screen.
      e->Graphics->FillPath( Brushes::Black, myPath );
   }
private void AddStringExample(PaintEventArgs e)
{
             
    // Create a GraphicsPath object.
    GraphicsPath myPath = new GraphicsPath();
             
    // Set up all the string parameters.
    string stringText = "Sample Text";
    FontFamily family = new FontFamily("Arial");
    int fontStyle = (int)FontStyle.Italic;
    int emSize = 26;
    Point origin = new Point(20, 20);
    StringFormat format = StringFormat.GenericDefault;
             
    // Add the string to the path.
    myPath.AddString(stringText,
        family,
        fontStyle,
        emSize,
        origin,
        format);
             
    //Draw the path to the screen.
    e.Graphics.FillPath(Brushes.Black, myPath);
}
Public Sub AddStringExample(ByVal e As PaintEventArgs)

    ' Create a GraphicsPath object.
    Dim myPath As New GraphicsPath

    ' Set up all the string parameters.
    Dim stringText As String = "Sample Text"
    Dim family As New FontFamily("Arial")
    Dim myfontStyle As Integer = CInt(FontStyle.Italic)
    Dim emSize As Integer = 26
    Dim origin As New Point(20, 20)
    Dim format As StringFormat = StringFormat.GenericDefault

    ' Add the string to the path.
    myPath.AddString(stringText, family, myfontStyle, emSize, _
    origin, format)

    'Draw the path to the screen.
    e.Graphics.FillPath(Brushes.Black, myPath)
End Sub

適用対象