■ 외곽선 텍스트를 그리는 방법을 보여준다.
▶ 외곽선 텍스트 그리기 예제 (C#)
1 2 3 4 5 6 7 8 9 10 11 |
using System.Drawing; ... Graphics graphics; ... DrawOutlineText(graphics, new Point(50, 200), Color.DarkGray, 4, Color.Red, new FontFamily("나눔고딕코딩"), FontStyle.Bold, 24, "테스트 문자열 입니다."); |
▶ 외곽선 텍스트 그리기 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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 |