GraphicsPath.AddString メソッド

定義

パスに文字列を追加します。

オーバーロード

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

パスに文字列を追加します。

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

パスに文字列を追加します。

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

パスに文字列を追加します。

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

パスに文字列を追加します。

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

ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs

パスに文字列を追加します。

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

追加する String

family
FontFamily

テスト描画を行うときに使用するフォントの名前を表す FontFamily

style
Int32

テキストに関するスタイル情報 (太字、斜体など) を表す FontStyle 列挙体。 この値は、整数としてキャストする必要があります (後のコード例を参照)。

emSize
Single

文字の境界を決める em 正方形ボックスの高さ。

origin
Point

テキストを開始する点を表す Point

format
StringFormat

行間や配置など、テキストの書式設定情報を指定する StringFormat

次のコード例は、Windows フォームで使用するように設計されており、イベント オブジェクトがOnPaint必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • パスを作成します。

  • 文字列とフォントの引数を設定します。

  • パスに文字列を追加します。

  • 文字列を画面に描画します。

重要な点は 2 つあります。まず、引数が fontStyle 整数としてキャストされていることに注意してください。 メソッドはAddString、2 つ以上FontStyleのメンバーを組み合わせて目的のフォント スタイル (この場合は とUnderline) を作成できるようにするために、Italicこれを必要とします。 次に、 メソッドではなく メソッド FillPath が使用されていることに DrawPath 注意してください。 を使用すると FillPath 、ソリッド テキストがレンダリングされます。一方、 が使用されている場合 DrawPath 、テキストはアウトライン スタイルになります。

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

適用対象

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

ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs

パスに文字列を追加します。

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

追加する String

family
FontFamily

テスト描画を行うときに使用するフォントの名前を表す FontFamily

style
Int32

テキストに関するスタイル情報 (太字、斜体など) を表す FontStyle 列挙体。 この値は、整数としてキャストする必要があります (後のコード例を参照)。

emSize
Single

文字の境界を決める em 正方形ボックスの高さ。

origin
PointF

テキストを開始する点を表す PointF

format
StringFormat

行間や配置など、テキストの書式設定情報を指定する StringFormat

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

適用対象

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

ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs

パスに文字列を追加します。

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

追加する String

family
FontFamily

テスト描画を行うときに使用するフォントの名前を表す FontFamily

style
Int32

テキストに関するスタイル情報 (太字、斜体など) を表す FontStyle 列挙体。 この値は、整数としてキャストする必要があります (後のコード例を参照)。

emSize
Single

文字の境界を決める em 正方形ボックスの高さ。

layoutRect
Rectangle

テキストに外接する四角形を表す Rectangle

format
StringFormat

行間や配置など、テキストの書式設定情報を指定する StringFormat

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

適用対象

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

ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs

パスに文字列を追加します。

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

追加する String

family
FontFamily

テスト描画を行うときに使用するフォントの名前を表す FontFamily

style
Int32

テキストに関するスタイル情報 (太字、斜体など) を表す FontStyle 列挙体。 この値は、整数としてキャストする必要があります (後のコード例を参照)。

emSize
Single

文字の境界を決める em 正方形ボックスの高さ。

layoutRect
RectangleF

テキストに外接する四角形を表す RectangleF

format
StringFormat

行間や配置など、テキストの書式設定情報を指定する StringFormat

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

適用対象