public void DrawString( string s , Font font , Brush brush , PointF point ); public void DrawString( string s , Font font , Brush brush , RectangleF layoutRectangle ); public void DrawString( string s , Font font , Brush brush , PointF point , StringFormat format ); public void DrawString( string s , Font font , Brush brush , RectangleF layoutRectangle , StringFormat format ); public void DrawString( string s , Font font , Brush brush , float x , float y ); public void DrawString( string s , Font font , Brush brush , float x , float y , StringFormat format );s には描画する文字列を、font には描画に使う Font オブジェクトを指定します
Object
MarshalByRefObject
Font
public sealed class Font : MarshalByRefObject,
ICloneable, ISerializable, IDisposable
このクラスのコンストラクタは、次のようなものが定義されていますpublic Font(Font prototype , FontStyle newStyle); public Font(FontFamily family , float emSize); public Font(string familyName , float emSize); public Font(FontFamily family , float emSize , FontStyle style); public Font(FontFamily family , float emSize , GraphicsUnit unit); public Font(string familyName , float emSize , FontStyle style); public Font(string familyName , float emSize , GraphicsUnit unit); public Font( FontFamily family , float emSize , FontStyle style , GraphicsUnit unit ); public Font( string familyName , float emSize , FontStyle style , GraphicsUnit unit );prototype には元となる既存のフォントを、newStyle には新しい FontStyle を指定します
Object
MarshalByRefObject
StringFormat
public sealed class StringFormat :
MarshalByRefObject, ICloneable, IDisposable
このクラスは、文字列操作情報や言語特有の性質をカバーするために用います| メンバ | 解説 |
|---|---|
| DirectionRightToLeft | 文字列は右から左へ向かうことを示す |
| DirectionVertical | 文字列は垂直に表示されることを示す |
| DisplayFormatControl | 文字列は左から右へ向かうことを示す |
| FitBlackBox | 制御用長方形から標識がはみ出さないことを示す デフォルトでは、必要に応じて長方形からはみ出ることがある |
| LineLimit | 完全な行だけは、長方形の外に配置されることを示す 長方形は、少なくとも1行分以上の高さを指定しなければならない |
| MeasureTrailingSpaces | デフォルトでは、制御用長方形を返すと MeasureString() メソッドによって各行の終わりのスペースが除外される そのスペースを測定値に含めるためにこのフラグを指定する |
| NoClip | 制御用長方形からはみ出た標識を表示することを許可する |
| NoFontFallback | 要求されたフォントがサポートされていない場合 代理フォントに頼るものを使用不能にする |
| NoWrap | 長方形の範囲内でフォーマットするならば 行の間を包むことを使用不能にする |
using System.Windows.Forms;
using System.Drawing;
class WinMain : Form {
public static void Main(string[] args) {
Application.Run(new WinMain());
}
override protected void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
Font ft = new Font("Mural Script" , 40);
PointF pt = new PointF(0 , 0);
g.DrawString("Kitty on your lap" , ft , Brushes.Black , pt);
}
}

using System.Windows.Forms;
using System.Drawing;
class WinMain : Form {
public static void Main(string[] args) {
Application.Run(new WinMain());
}
override protected void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
Font ft = new Font("MS Serif" , 20);
PointF pt = new PointF(0 , 0);
g.DrawString("猫耳LOVE" , ft , Brushes.Black , pt ,
new StringFormat(StringFormatFlags.DirectionVertical));
}
}

| メンバ | 解説 |
|---|---|
| Bold | 太字 |
| Italic | 斜体 |
| Regular | デフォルトの標準スタイル |
| Strikeout | 打消し文字 |
| Underline | アンダーライン |
using System.Windows.Forms;
using System.Drawing;
class WinMain : Form {
public static void Main(string[] args) {
Application.Run(new WinMain());
}
override protected void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
Font ftBold = new Font("MS Serif" , 20 , FontStyle.Strikeout);
Font ftItalic = new Font(ftBold , FontStyle.Italic | FontStyle.Underline);
PointF pt = new PointF(0 , 0);
g.DrawString("Kitty on your lap" , ftBold , Brushes.Black , pt);
pt.Y += 25;
g.DrawString("Maiden Breeder" , ftItalic , Brushes.Black , pt);
}
}

| メンバ | 解説 |
|---|---|
| Display | 1/75 インチ単位 |
| Document | 文書単位(1/300インチ) |
| Inch | インチ単位 |
| Millimeter | ミリメートル単位 |
| Pixel | デバイスピクセル単位 |
| Point | プリンタのポイント単位(1/72インチ) |
| World | ワールド単位 |
using System.Windows.Forms;
using System.Drawing;
class WinMain : Form {
public static void Main(string[] args) {
Application.Run(new WinMain());
}
override protected void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
Font ft = new Font("MS Serif" , 1 , GraphicsUnit.Inch);
PointF pt = new PointF(0 , 0);
g.DrawString("Kitty on your lap" , ft , Brushes.Black , pt);
}
}
このプログラムは、計測単位をインチ単位の設定しています