本文整理汇总了C#中Font类的典型用法代码示例。如果您正苦于以下问题:C# Font类的具体用法?C# Font怎么用?C# Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Font类属于命名空间,在下文中一共展示了Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: exitButton
public static GameObject exitButton(Material m,Font ft , int Size)
{
GameObject b = MakeBase(m,ft,"Exit",Size);
b.AddComponent<ExitGame>();
b.name = "Exit";
return b;
}
示例2: CreateImage
/// <summary>
/// ����ͼƬ
/// </summary>
/// <param name="checkCode">�����</param>
private void CreateImage(string checkCode)
{
int iwidth = (int)(checkCode.Length * 11.5);//����������趨ͼƬ���
Bitmap image = new Bitmap(iwidth, 20);//����һ������
Graphics g = Graphics.FromImage(image);//�ڻ����϶����ͼ��ʵ��
Font f = new Font("Arial",10,FontStyle.Bold);//���壬��С����ʽ
Brush b = new SolidBrush(Color.Black);//������ɫ
//g.FillRectangle(new System.Drawing.SolidBrush(Color.Blue),0,0,image.Width, image.Height);
g.Clear(Color.White);//������ɫ
g.DrawString(checkCode, f, b, 3, 3);
Pen blackPen = new Pen(Color.Black, 0);
Random rand = new Random();
/*�����
for (int i = 0; i < 5; i++)
{
int y = rand.Next(image.Height);
g.DrawLine(blackPen, 0, y, image.Width, y);
}
*/
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.ClearContent();
Response.ContentType = "image/Jpeg";
Response.BinaryWrite(ms.ToArray());
g.Dispose();
image.Dispose();
}
示例3: String2D
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the string from a text, font and size
/// </summary>
/// <param name="text">Text to display</param>
/// <param name="font">Font to use</param>
/// <param name="size">Base characters size</param>
////////////////////////////////////////////////////////////
public String2D(string text, Font font, uint size)
: base(sfString_Create())
{
Text = text;
Font = font;
Size = size;
}
示例4: loadLevelButton
public static GameObject loadLevelButton(Material m, Font ft, int Size, string text, string url)
{
GameObject b = MakeBase(m, ft, text, Size);
b.AddComponent<LoadLevel>().init(url);
return b;
}
示例5: MeasureText
public static double MeasureText(string text, Font font)
{
return MeasureText(text, new FontFamily(font.getFamily()),
font.isItalic() ? FontStyles.Italic : FontStyles.Normal,
font.isBold() ? FontWeights.Bold : FontWeights.Normal,
FontStretches.Normal, font.getSize()).Width;
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
int x, y;
string strValidation = null;
rnd = new Random();
Response.ContentType = "image/jpeg";
Response.Clear();
Response.BufferOutput = true;
strValidation = GenerateString();
Session["strValidation"] = strValidation;
Font font = new Font("Arial", (float)rnd.Next(17, 20));
Bitmap bitmap = new Bitmap(200, 50);
Graphics gr = Graphics.FromImage(bitmap);
gr.FillRectangle(Brushes.LightGreen, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
gr.DrawString(strValidation, font, Brushes.Black, (float)rnd.Next(70), (float)rnd.Next(20));
// gr.DrawLine(new Pen(Color.White), new Point(0, rnd.Next(50)), new Point(200, rnd.Next(50)));
// gr.DrawLine(new Pen(Color.White), new Point(0, rnd.Next(50)), new Point(200, rnd.Next(50)));
// gr.DrawLine(new Pen(Color.White), new Point(0, rnd.Next(50)), new Point(200, rnd.Next(50)));
for (x = 0; x < bitmap.Width; x++)
for (y = 0; y < bitmap.Height; y++)
if (rnd.Next(4) == 1)
bitmap.SetPixel(x, y, Color.LightGreen);
font.Dispose();
gr.Dispose();
bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
bitmap.Dispose();
}
示例7: GenerateBarcodeImage
public Bitmap GenerateBarcodeImage(string text, FontFamily fontFamily, int fontSizeInPoints)
{
StringBuilder sb = new StringBuilder();
sb.Append("*");
sb.Append(text);
sb.Append("*");
Bitmap bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
Font font = new Font(fontFamily, fontSizeInPoints, FontStyle.Regular, GraphicsUnit.Point);
Graphics graphics = Graphics.FromImage(bmp);
SizeF textSize = graphics.MeasureString(sb.ToString(), font);
bmp = new Bitmap(bmp, textSize.ToSize());
graphics = Graphics.FromImage(bmp);
graphics.Clear(Color.White);
graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
graphics.DrawString(sb.ToString(), font, new SolidBrush(Color.Black), 0, 0);
graphics.Flush();
font.Dispose();
graphics.Dispose();
return bmp;
}
示例8: Bitmap
internal Action syncBitmap; //this.SyncBitmap() call
public Bitmap(string filename)
{
syncBitmap = this.SyncBitmap;
font = Font.default_font;
LoadTexture(filename);
}
示例9: getImageValidate
//生成图像
private void getImageValidate(string strValue)
{
//string str = "OO00"; //前两个为字母O,后两个为数字0
int width = Convert.ToInt32(strValue.Length * 12); //计算图像宽度
Bitmap img = new Bitmap(width, 23);
Graphics gfc = Graphics.FromImage(img); //产生Graphics对象,进行画图
gfc.Clear(Color.White);
drawLine(gfc, img);
//写验证码,需要定义Font
Font font = new Font("arial", 12, FontStyle.Bold);
System.Drawing.Drawing2D.LinearGradientBrush brush =
new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.DarkOrchid, Color.Blue, 1.5f, true);
gfc.DrawString(strValue, font, brush, 3, 2);
drawPoint(img);
gfc.DrawRectangle(new Pen(Color.DarkBlue), 0, 0, img.Width - 1, img.Height - 1);
//将图像添加到页面
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
//更改Http头
Response.ClearContent();
Response.ContentType = "image/gif";
Response.BinaryWrite(ms.ToArray());
//Dispose
gfc.Dispose();
img.Dispose();
Response.End();
}
示例10: DrawString
public void DrawString(int x, int y, string s, int color, Font font)
{
var currentX = x;
foreach (var c in s)
{
var character = font.GetFontData(c);
if (c == '\n') //line feed
{
y += character.Height;
}
else if (c == '\r') //carriage return
{
currentX = x;
}
else
{
if (currentX + character.Width > Width)
{
currentX = x; //start over at the left and go to a new line.
y += character.Height;
}
DrawChar(currentX, y, color, character);
currentX += character.Width + character.Space;
}
}
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
int num = 4;
Bitmap generatedImage = new Bitmap(200, 200);
using (generatedImage)
{
Graphics gr = Graphics.FromImage(generatedImage);
using (gr)
{
var fonttt = new Font("Arial", 14, FontStyle.Bold);
gr.FillRectangle(Brushes.MediumSeaGreen, 0, 0, 200, 200);
gr.FillPie(Brushes.Yellow, 25, 25, 150, 150, 0, 45);
gr.FillPie(Brushes.Green, 25, 25, 150, 150, 45, 315);
gr.DrawString(num.ToString(), fonttt, SystemBrushes.WindowText, new PointF(10, 40));
// Set response header and write the image into response stream
Response.ContentType = "image/gif";
//Response.AppendHeader("Content-Disposition",
// "attachment; filename=\"Financial-Report-April-2013.gif\"");
generatedImage.Save(Response.OutputStream, ImageFormat.Gif);
}
}
}
示例12: GetFileBasedFSBitmap
protected Bitmap GetFileBasedFSBitmap(string ext, IconSize size)
{
string lookup = tempPath;
Bitmap folderBitmap = KeyToBitmap(lookup, size);
if (ext != "")
{
ext = ext.Substring(0, 1).ToUpper() + ext.Substring(1).ToLower();
using (Graphics g = Graphics.FromImage(folderBitmap))
{
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
Font font = new Font("Comic Sans MS", folderBitmap.Width / 5, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);
float height = g.MeasureString(ext, font).Height;
float rightOffset = folderBitmap.Width / 5;
if (size == IconSize.small)
{
font = new Font("Arial", 5, System.Drawing.FontStyle.Bold);
height = g.MeasureString(ext, font).Height;
rightOffset = 0;
}
g.DrawString(ext, font,
System.Drawing.Brushes.Black,
new RectangleF(0, folderBitmap.Height - height, folderBitmap.Width - rightOffset, height),
new StringFormat(StringFormatFlags.DirectionRightToLeft));
}
}
return folderBitmap;
}
示例13: CreateWord
public void CreateWord(string targetWord, int fontSize, Font typeFont)
{
typeTarget = new GameObject ("textWords");
typeTarget.AddComponent<TextMesh>();
MeshRenderer meshRender = typeTarget.GetComponent<MeshRenderer>();
meshRender.material = Resources.Load<Material>("Fonts/unispace");
TextMesh mesh = typeTarget.GetComponent<TextMesh>();
mesh.text = targetWord;
mesh.font = typeFont;
mesh.fontSize = fontSize;
mesh.color = Color.green;
typeTarget.transform.parent = this.transform;
mesh.anchor = TextAnchor.MiddleCenter;
if (meshRender.bounds.size.y > wordHeight)
this.transform.localScale *= wordHeight/meshRender.bounds.size.y;
meshRender.material.color = new Color (meshRender.material.color.r, meshRender.material.color.g, meshRender.material.color.b, 0.0f);
//Add sound source on typeTarget
//Make background fit word
typeBackground = new GameObject ("background");
typeBackground.AddComponent<SpriteRenderer> ();
SpriteRenderer spriteRender = typeBackground.GetComponent<SpriteRenderer> ();
spriteRender.sprite = (Sprite)Resources.Load<Sprite> ("Sprites/TypeBackground");
spriteRender.color = new Color (spriteRender.color.r, spriteRender.color.g, spriteRender.color.b, 0.0f);
typeBackground.transform.parent = this.transform;
typeBackground.transform.localPosition = Vector3.forward;
typeBackground.transform.localScale = new Vector3 ((meshRender.bounds.size.x + (padding * 2.0f)) /
typeBackground.GetComponent<SpriteRenderer> ().bounds.size.x * typeBackground.transform.localScale.x,
typeBackground.transform.localScale.y * verticalSizeReduction, typeBackground.transform.localScale.z);
originalWordScale = typeBackground.transform.localScale;
}
示例14: resetHighScoreButton
public static GameObject resetHighScoreButton(Material m, Font ft, int Size, TextAnchor txmach = TextAnchor.UpperLeft)
{
GameObject b = MakeBase(m, ft, "Reset HighScore", Size, txmach);
b.AddComponent<ResetHighScore>();
return b;
}
示例15: GetFormattedFont
private static IT.Font GetFormattedFont(Font font)
{
IT.Font iTextFont = new IT.Font();
//Return default font if font style is not available.
if (font == null)
{
return new IT.Font();
}
foreach (var format in font.Formats)
{
switch (format)
{
case FontFormats.Bold:
iTextFont.SetStyle(IT.Font.BOLD);
break;
case FontFormats.Italic:
iTextFont.SetStyle(IT.Font.ITALIC);
break;
case FontFormats.Underlined:
iTextFont.SetStyle(IT.Font.UNDERLINE);
break;
default:
break;
}
}
return iTextFont;
}