当前位置: 首页>>代码示例>>C#>>正文


C# Font类代码示例

本文整理汇总了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;
 }
开发者ID:nolimet,项目名称:RandomStuff,代码行数:7,代码来源:ExitButton.cs

示例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();
    }
开发者ID:vtmer,项目名称:NewStudent,代码行数:32,代码来源:checkCode.aspx.cs

示例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;
 }
开发者ID:freemaul,项目名称:SFML,代码行数:15,代码来源:String2D.cs

示例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;
                }
开发者ID:nolimet,项目名称:RandomStuff,代码行数:7,代码来源:LoadLevelButton.cs

示例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;
 }
开发者ID:WeiChou,项目名称:alphaTab,代码行数:7,代码来源:MeasureUtil.cs

示例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();
    }
开发者ID:CaesaRBur,项目名称:WebProject,代码行数:28,代码来源:ImageValidation.aspx.cs

示例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;
    }
开发者ID:rid50,项目名称:PSCBioOffice,代码行数:28,代码来源:Helper.cs

示例8: Bitmap

    internal Action syncBitmap; //this.SyncBitmap() call

    public Bitmap(string filename)
    {
        syncBitmap = this.SyncBitmap;

        font = Font.default_font;
        LoadTexture(filename);
    }
开发者ID:strelokhalfer,项目名称:OpenGame.exe,代码行数:9,代码来源:Bitmap.cs

示例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();
 }
开发者ID:kooyou,项目名称:TrafficFinesSystem,代码行数:28,代码来源:CreateImg.aspx.cs

示例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;
                }
            }
        }
开发者ID:piwi1263,项目名称:Vecc.Netduino.Drivers.Ili9341,代码行数:28,代码来源:Driver.DrawString.cs

示例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);
			}
		}
    }
开发者ID:hristo11111,项目名称:TelerikAcademy-HristoBratanov,代码行数:27,代码来源:ImageGenerator.aspx.cs

示例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;
        }
开发者ID:kolan72,项目名称:QuickZip.IO.PIDL.UserControls,代码行数:34,代码来源:ExToIconConverter.cs

示例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;
    }
开发者ID:AlexStopar,项目名称:TypingMockUp,代码行数:33,代码来源:TypeWindow.cs

示例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;
                }
开发者ID:nolimet,项目名称:GameJam2014,代码行数:7,代码来源:ResetHighScoreButton.cs

示例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;
        }
开发者ID:amilasurendra,项目名称:pdf-generator,代码行数:29,代码来源:TextFormatter.cs


注:本文中的Font类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。