첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ 외곽선 텍스트 그리기 예제

using System.Drawing;

...

Graphics graphics;

...

DrawOutlineText(graphics, new Point(50, 200), Color.DarkGray, 4, Color.Red, new FontFamily("나눔고딕코딩"), FontStyle.Bold, 24, "테스트 문자열 입니다.");

 

728x90

 

▶ 외곽선 텍스트 그리기

using System.Drawing;
using System.Drawing.Drawing2D;

#region 외곽선 텍스트 그리기 - DrawOutlineText(graphics, location, borderColor, borderWidth, fillColor, fontFamily, fontStyle, fontSize, text)

/// <summary>
/// 텍스트 그리기
/// </summary>
/// <param name="graphics">그래픽스 객체</param>
/// <param name="location">위치</param>
/// <param name="borderColor">테두리 색상</param>
/// <param name="borderWidth">테두리 두께</param>
/// <param name="fillColor">칠하기 색상</param>
/// <param name="fontFamily">폰트 패밀리</param>
/// <param name="fontStyle">폰트 스타일</param>
/// <param name="fontSize">폰트 크기</param>
/// <param name="text">텍스트</param>
public void DrawOutlineText(Graphics graphics, Point location, Color borderColor, int borderWidth, Color fillColor, FontFamily fontFamily, FontStyle fontStyle, float fontSize, string text)
{
    using(Pen pen = new Pen(borderColor, borderWidth))
    {
        using(GraphicsPath graphicsPath = new GraphicsPath())
        {
            using(Brush fillBrush = new SolidBrush(fillColor))
            {
                graphicsPath.AddString(text, fontFamily, (int)fontStyle, fontSize, location, StringFormat.GenericTypographic);

                graphics.DrawPath(pen, graphicsPath);

                graphics.FillPath(fillBrush, graphicsPath);
            }
        }
    }
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요