MultiSelect for WinForms
Font コンストラクタ(Font,Single)
使用例 

C1.Win.Input.6 アセンブリ > C1.Framework.Drawing.Gdi 名前空間 > Font クラス > Font コンストラクタ : Font コンストラクタ(Font,Single)
Special Font from which is used to create new font
The size of the new Font object.
Initializes a new Font object from the specified Font object and special style
シンタックス
'宣言
 
Public Function New( _
   ByVal font As Font, _
   ByVal size As System.Single _
)
public Font( 
   Font font,
   System.float size
)

パラメータ

font
Special Font from which is used to create new font
size
The size of the new Font object.
解説

this is used to create a new Font from template font which is given by parameter Font, the parameter size show you a chance to redefine the Font.Size.

if you want to zoom Font.Size, you can get the size from your template font, and multiply it with the zoom factor you expected, which a new size you will got, for example named new size variable newSize, then use this constructor to create new Font: Font newFont = new Font(templateFont, newSize);

This is a simple WinForm program which draw two line text on special position of form. The first line, a string was drawed with winForm default font: Microsoft Sans Serif, 8.25pt, The second line, a sting was drawed with Font whic size is as twice as fiest line public class TestForm : Form { protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); IntPtr hDc = e.Graphics.GetHdc(); // create a font from default Form.Font (Microsoft Sans Serif, 8.25pt), size = 8.25 Gdi.Font font = new Gdi.Font(this.Font); IntPtr oldFont = SelectObject(hDc, font.Handle); string test1 = "1. This is drawing by GDI with GdiFont"; TextOut(hDc, 50, 50, test1, test1.Length); SelectObject(hDc, oldFont); // here I want to a font which size is as twice as current's Drawing.Gdi.Font font2 = new Drawing.Gdi.Font(font, 2 * font.Size); oldFont = SelectObject(hDc, font2.Handle); string test2 = "2. This is drawing by GDI with GdiFont"; TextOut(hDc, 50, 100, test2, test2.Length); font.Dispose(); font2.Dispose(); SelectObject(hDc, oldFont); e.Graphics.ReleaseHdc(hDc); } [DllImport("gdi32.dll", EntryPoint = "SelectObject")] public static extern IntPtr SelectObject( IntPtr hdc, IntPtr hObject ); [DllImport("gdi32.dll", EntryPoint = "TextOut")] public static extern int TextOut( IntPtr hdc, int x, int y, string lpString, int nCount ); }
使用例
This is a simple WinForm program which draw two line text on special position of form. The first line, a string was drawed with winForm default font: Microsoft Sans Serif, 8.25pt, The second line, a sting was drawed with Font whic size is as twice as fiest line
public class TestForm : Form
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

IntPtr hDc = e.Graphics.GetHdc();
// create a font from default Form.Font (Microsoft Sans Serif, 8.25pt), size = 8.25
Gdi.Font font = new Gdi.Font(this.Font);
IntPtr oldFont = SelectObject(hDc, font.Handle);
string test1 = "1. This is drawing by GDI with GdiFont";
TextOut(hDc, 50, 50, test1, test1.Length);
SelectObject(hDc, oldFont);

// here I want to a font which size is as twice as current's
Drawing.Gdi.Font font2 = new Drawing.Gdi.Font(font, 2 * font.Size);
oldFont = SelectObject(hDc, font2.Handle);
string test2 = "2. This is drawing by GDI with GdiFont";
TextOut(hDc, 50, 100, test2, test2.Length);
font.Dispose();
font2.Dispose();
SelectObject(hDc, oldFont);
e.Graphics.ReleaseHdc(hDc);
}

[DllImport("gdi32.dll", EntryPoint = "SelectObject")]
public static extern IntPtr SelectObject(
IntPtr hdc,
IntPtr hObject
);

[DllImport("gdi32.dll", EntryPoint = "TextOut")]
public static extern int TextOut(
IntPtr hdc,
int x,
int y,
string lpString,
int nCount
);
}
参照

Font クラス
Font メンバ
オーバーロード一覧