forked from hagronnestad/nextion-font-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.linq
43 lines (34 loc) · 1.35 KB
/
test2.linq
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
39
40
41
42
43
<Query Kind="Statements">
<Reference><RuntimeDirectory>\System.Windows.Forms.dll</Reference>
<Reference><RuntimeDirectory>\System.Security.dll</Reference>
<Reference><RuntimeDirectory>\System.Configuration.dll</Reference>
<Reference><RuntimeDirectory>\Accessibility.dll</Reference>
<Reference><RuntimeDirectory>\System.Deployment.dll</Reference>
<Reference><RuntimeDirectory>\System.Runtime.Serialization.Formatters.Soap.dll</Reference>
<Namespace>System.Windows.Forms</Namespace>
<Namespace>System.Drawing</Namespace>
</Query>
var f = new Form();
f.Width = 500;
f.Show();
var p1 = new PictureBox()
{
Location = new Point(10, 10),
//BackColor = Color.Red,
Size = new Size(200, 200),
//SizeMode = PictureBoxSizeMode.StretchImage
};
f.Controls.Add(p1);
var c = "w";
var font1 = new Font("Arial Black", 48, GraphicsUnit.Pixel);
var b1 = new Bitmap(200, 200);
var p1g = Graphics.FromImage(b1);
var size = p1g.MeasureString(c, font1, default(PointF), StringFormat.GenericTypographic);
//var size = TextRenderer.MeasureText(c, font1, new Size(1, 1), TextFormatFlags.Default);
p1g.DrawRectangle(new Pen(Color.DarkRed), new Rectangle(0, 0, (int)size.Width + 2, (int)size.Height + 2));
p1g.DrawString(
c,
font1,
new SolidBrush(Color.Black), 1, 1, StringFormat.GenericTypographic);
f.Text = size.ToString();
p1.Image = b1;