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)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
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 Forms 사용하도록 설계되었으며 이벤트 개체인 가 OnPaint 필요합니다PaintEventArgse. 코드는 다음 작업을 수행합니다.

  • 경로를 만듭니다.

  • 문자열 및 글꼴 인수를 설정합니다.

  • 경로에 문자열을 추가합니다.

  • 화면에 문자열을 그립니다.

지적해야 할 두 가지 중요한 사항이 있습니다. 먼저 인수가 fontStyle 정수로 캐스팅됩니다. 메서드를 AddString 사용하려면 둘 이상의 FontStyle 멤버를 결합하여 원하는 글꼴 스타일(이 경우 ItalicUnderline)을 만들 수 있어야 합니다. 둘째, 메서드가 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)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
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)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
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)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
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)를 참조하세요.

적용 대상