• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Drawing.Font类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Drawing.Font的典型用法代码示例。如果您正苦于以下问题:C# Font类的具体用法?C# Font怎么用?C# Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Font类属于System.Drawing命名空间,在下文中一共展示了Font类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Text

 public void Text(string text, Font font, uint argb, Rectangle rect, StringFormat format)
 {
     graphics.DrawString(
         text, font,
         new SolidBrush(argb.ToColor()),
         rect, format);
 }
开发者ID:matheus2984,项目名称:SoulEngine,代码行数:7,代码来源:GraphicsHelper.cs


示例2: PaintJunk

        public void PaintJunk(Graphics g)
        {
            g.FillRectangle(Brushes.Transparent, 0, 0, 1000, 1000);

            using (Font font = new Font("Courier New", 20, FontStyle.Bold))
            {
                if (bounceCounter == -1) return;
                const string str = "DEVELOPER BUILD";
                float x = 0;
                int timefactor = bounceCounter;
                for (int i = 0; i < str.Length; i++)
                {
                    string slice = str.Substring(i, 1);
                    g.PageUnit = GraphicsUnit.Pixel;
                    x += g.MeasureString(slice, font).Width - 1;

                    int offset = -i * 3 + timefactor*3;
                    int yofs = 0;
                    if (offset < 0)
                    { continue; }
                    else
                        if (offset < DigitTable.Length)
                            yofs = DigitTable[offset];
                    g.DrawString(slice, font, Brushes.Black, 5 + x, 15 - yofs);
                }
            }
        }
开发者ID:cas1993per,项目名称:bizhawk,代码行数:27,代码来源:AboutBox.cs


示例3: GetCharacterSize

        public virtual Size GetCharacterSize( Graphics g, Font font, CharacterCasing casing )
        {
            const int MeasureCharCount = 10;

             Size charSize = new Size( 0, 0 );

             for ( char c = '0'; c <= '9'; ++c )
             {
            Size newSize = TextRenderer.MeasureText( g, new string( c, MeasureCharCount ), font, new Size( 0, 0 ),
               _textFormatFlags );

            newSize.Width = (int)Math.Ceiling( (double)newSize.Width / (double)MeasureCharCount );

            if ( newSize.Width > charSize.Width )
            {
               charSize.Width = newSize.Width;
            }

            if ( newSize.Height > charSize.Height )
            {
               charSize.Height = newSize.Height;
            }
             }

             return charSize;
        }
开发者ID:EddyBeaupre,项目名称:WinCDP-GUI,代码行数:26,代码来源:DecimalValue.cs


示例4: EDSToolTip_Draw

        void EDSToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            if (e.ToolTipText.Trim() != "")
            {
                //e.DrawBackground();
                Graphics g = e.Graphics;

                //draw background
                LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(Point.Empty, e.Bounds.Size), Color.FromArgb(250, 252, 253), Color.FromArgb(206, 220, 240), LinearGradientMode.Vertical);
                g.FillRectangle(lgb, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
                lgb.Dispose();

                //Console.WriteLine(e.ToolTipText);

                //draw border
                ControlPaint.DrawBorder(g, e.Bounds, SystemColors.GrayText, ButtonBorderStyle.Dashed);
                //draw Image
                g.DrawImage(image, new Point(5, 5));

                // Draw the custom text.
                // The using block will dispose the StringFormat automatically.
                using (StringFormat sf = new StringFormat())
                {
                    using (Font f = new Font("Tahoma", 8))
                    {
                        e.Graphics.DrawString(e.ToolTipText, f,
                            Brushes.Black, e.Bounds.X + 25, e.Bounds.Y + 30, StringFormat.GenericTypographic);
                    }
                }
            }
        }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:31,代码来源:EDSToolTip.cs


示例5: DrawStringML

 private static void DrawStringML(this Graphics G, string Text, Font font, Brush brush, float x, ref float y, float mX)
 {
     string[] words = Text.Split(' ');
     float tempX = x;
     float totalSpace = mX - x;
     SizeF measureWord = new SizeF(0, font.GetHeight());
     float tempWordWidth = 0;
     foreach (string word in words)
     {
         //measure word width (based in font size)
         tempWordWidth = G.MeasureString(word + " ", font).Width;
         measureWord.Width += tempWordWidth;
         //check if the word fits in free line space
         //if not then change line
         if (measureWord.Width > totalSpace)
         {
             y += font.GetHeight();
             tempX = x;
             measureWord.Width = tempWordWidth;
         }
         G.DrawString(word + " ", font, brush, tempX, y);
         tempX += tempWordWidth;
     }
     y += font.GetHeight();
 }
开发者ID:Hli4S,项目名称:TestMeApp,代码行数:25,代码来源:Print.cs


示例6: ctlMCXY

        //int mCircsize;
        public ctlMCXY()
        {
            InitializeComponent();
            mArches = new Image[4];
            mArchesSel = new Image[4];
            mOffsets = new Rectangle[4];
            mArchTxtPos = new PointF[4];
            mLevelVals = new float[] { 0.1f, 1, 10, 100 };
            DoubleBuffered = true;
            mSelAxis = 0;
            mSelLevel = 0;
            mCircWidth = 256;
            Height = mCircWidth;
            Width = mCircWidth;
            mInRad = 35;
            mButtRad = mCircWidth / 2;
            mArchWidth = 20;
            mCenter = mCircWidth / 2;
            mButMin = mCenter - 60;
            mButMax = mCenter - 10;
            mButHomePos = 25;
            mArrowPos = (int)(mCenter + mInRad) / 2;

            Font = new Font("Arial", (float)(mArchWidth * 0.75), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel, ((byte)(0)));
            UpdateOffsets(mCircWidth);
            FrameColor = Color.RoyalBlue;
            mUnit = "mm";
            //UpdateBitmaps();
        }
开发者ID:RFranta,项目名称:UVDLPSlicerController,代码行数:30,代码来源:ctlMCXY.cs


示例7: settings4_4_language_DrawItem

        private void settings4_4_language_DrawItem(object sender, DrawItemEventArgs e)
        {
            Font objFonts = new Font(this.Font.Name, 14, FontStyle.Bold);
            e.DrawBackground();

            e.Graphics.DrawString(settings4_4_language.Items[e.Index].ToString(), objFonts, new SolidBrush(e.ForeColor), new Point(e.Bounds.Left, e.Bounds.Top));
        }
开发者ID:henryxrl,项目名称:SimpleEpub2,代码行数:7,代码来源:Settings_Page4.cs


示例8: SetReactions

        protected void SetReactions(HXReaction curReaction, HXReaction newReaction)
        {
            ChangeGeneric(true);
            Font BoldFont = new Font(txtCurReactants.Font, FontStyle.Bold);

            txtCurGeneric.Text = curReaction.ToString();
            txtNewGeneric.Text = newReaction.ToString();

            Match curMatch = HXReaction.s_HXRegex.Match(txtCurGeneric.Text);
            Match newMatch = HXReaction.s_HXRegex.Match(txtNewGeneric.Text);
            string[] groups = new string[] { "Type", "Value", "Value2" };
            foreach (string s in groups)
            {
                Group curGroup = curMatch.Groups[s];
                Group newGroup = newMatch.Groups[s];
                if (curGroup.Value != newGroup.Value)
                {
                    if (curGroup.Success)
                    {
                        txtCurGeneric.Select(curGroup.Index, curGroup.Length);
                        HighlightText(txtCurGeneric);
                    }
                    if (newGroup.Success)
                    {
                        txtNewGeneric.Select(newGroup.Index, newGroup.Length);
                        HighlightText(txtNewGeneric);
                    }
                }
            }
        }
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:30,代码来源:FrmChangeDialogue.cs


示例9: QFont

        public QFont(string fileName, float size, FontStyle style, QFontBuilderConfiguration config)
        {
            PrivateFontCollection pfc = new PrivateFontCollection();
            pfc.AddFontFile(fileName);
            var fontFamily = pfc.Families[0];

            if (!fontFamily.IsStyleAvailable(style))
                throw new ArgumentException("Font file: " + fileName + " does not support style: " +  style );

            if (config == null)
                config = new QFontBuilderConfiguration();

            TransformViewport? transToVp = null;
            float fontScale = 1f;
            if (config.TransformToCurrentOrthogProjection)
                transToVp = OrthogonalTransform(out fontScale);

            using(var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style)){
                fontData = BuildFont(font, config, null);
            }

            if (config.ShadowConfig != null)
                Options.DropShadowActive = true;
            if (transToVp != null)
                Options.TransformToViewport = transToVp;

            if(config.UseVertexBuffer)
                InitVBOs();
        }
开发者ID:swax,项目名称:QuickFont,代码行数:29,代码来源:QFont.cs


示例10: LoadSystemFonts

        /// <summary>
        /// Load system fonts and create previews of them
        /// </summary>
        /// <returns>Total number of fonts loaded</returns>
        public int LoadSystemFonts()
        {
            FontCollection fc = new InstalledFontCollection();
            int fontCount = 0;

            foreach (FontFamily f in fc.Families)
            {
                fontCount++;

                try
                {
                    FontStyle fs = FontStyle.Strikeout;
                    foreach (FontStyle fos in Enum.GetValues(typeof(FontStyle)))
                    {

                        if (fs == FontStyle.Strikeout && fos != FontStyle.Strikeout)
                        {
                            if (f.IsStyleAvailable(fos))
                            {
                                fs = fos;
                            }
                        }
                    }
                    Font fo = new Font(f, 38f, fs);
                    FamilyViewer fv = new FamilyViewer();
                    fv.PreviewFont = fo;
                    this.AddItem(fv);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("Problem displaying " + f.Name);
                }
            }
            return fontCount;
        }
开发者ID:vdtdev,项目名称:FontFish,代码行数:39,代码来源:FamilyGrid.cs


示例11: OnPaint

        protected override void OnPaint(PaintEventArgs pea)
        {
            base.OnPaint(pea);

            Graphics grfx = pea.Graphics;

            LinearGradientBrush lgbrush = null;
            Font font = new Font(this.Font.FontFamily, this.Font.Size, this.Font.Style);
            SolidBrush brush = new SolidBrush(this.ForeColor);

            int cw = (this.Width - 20)/7;
            int ch = this.Height - 20;

            for(int i = 0 ; i < 7; i++)
            {
                Rectangle temp = new Rectangle(10+(i*cw), 10, cw, ch );

                if(i < 6)
                    lgbrush = new LinearGradientBrush(temp, colors[i], colors[i+1], LinearGradientMode.Horizontal);
                else
                    lgbrush = new LinearGradientBrush(temp, colors[i], colors[0], LinearGradientMode.Horizontal);

                lgbrush.WrapMode = WrapMode.Tile;
                grfx.FillRectangle(lgbrush, 10+(i*cw), 10, cw, ch );
            }

            grfx.DrawString(this.Text, font, brush, this.Width/3, this.Height/2);
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:28,代码来源:RainbowButton3.cs


示例12: UpdateMeasures

		/// <summary>
		/// Updates the width of the word as it would be
		/// when drawn with the specified font in the specified graphics.
		/// </summary>
		public virtual void UpdateMeasures(Graphics graphics, Font font)
		{
			string word = _value;
			int rangePos = 0;
			int rangeLen = word.Length;

			if (IsWhitespace)
			{
				// Enclose the word in printable characters for
				// Graphics.MeasureText to work correctly.
				// Furthermore tabs are not measured, so replace
				// tabs with, say, 4 spaces
				word = "W" + word + "W";
				word = word.Replace("\t", "    ");
				rangePos = 1;
				rangeLen = word.Length - 2;
			}

			_sformat.SetMeasurableCharacterRanges(new CharacterRange[]
				{
					new CharacterRange(rangePos, rangeLen)
				});
			Region[] r = graphics.MeasureCharacterRanges(
				word, font, _srect, _sformat);
			RectangleF bounds = r[0].GetBounds(graphics);
			r[0].Dispose();

			_width = bounds.Width;
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:33,代码来源:Text.cs


示例13: FileSubMenu_DropDownOpened

		private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
		{
			SaveStateSubMenu.Enabled =
				LoadStateSubMenu.Enabled =
				SaveSlotSubMenu.Enabled =
				Global.Emulator.HasSavestates();

			OpenRomMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Open ROM"].Bindings;
			CloseRomMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Close ROM"].Bindings;

			MovieSubMenu.Enabled =
				CloseRomMenuItem.Enabled =
				!Global.Emulator.IsNull();

			var hasSaveRam = Global.Emulator.HasSaveRam();
			bool needBold = hasSaveRam && Global.Emulator.AsSaveRam().SaveRamModified;

			SaveRAMSubMenu.Enabled = hasSaveRam;
			if (SaveRAMSubMenu.Font.Bold != needBold)
			{
				var font = new System.Drawing.Font(SaveRAMSubMenu.Font, needBold ? FontStyle.Bold : FontStyle.Regular);
				SaveRAMSubMenu.Font.Dispose();
				SaveRAMSubMenu.Font = font;
			}
		}
开发者ID:pgrimsrud,项目名称:BizHawk,代码行数:25,代码来源:MainForm.Events.cs


示例14: FontCollection

        private void FontCollection()
        {
            // Create the byte array and get its length

            byte[] fontArray = Resources.gill_sans_ultra_bold_condensed;
            int dataLength = Resources.gill_sans_ultra_bold_condensed.Length;

            // ASSIGN MEMORY AND COPY  BYTE[] ON THAT MEMORY ADDRESS
            IntPtr ptrData = Marshal.AllocCoTaskMem(dataLength);
            Marshal.Copy(fontArray, 0, ptrData, dataLength);

            uint cFonts = 0;
            AddFontMemResourceEx(ptrData, (uint)fontArray.Length, IntPtr.Zero, ref cFonts);

            PrivateFontCollection pfc = new PrivateFontCollection();
            //PASS THE FONT TO THE  PRIVATEFONTCOLLECTION OBJECT
            pfc.AddMemoryFont(ptrData, dataLength);

            //FREE THE  "UNSAFE" MEMORY
            Marshal.FreeCoTaskMem(ptrData);

            ff = pfc.Families[0];
            font = new Font(ff, 15f, FontStyle.Bold);
            fontButtonRegular = new Font(ff, 25f, FontStyle.Bold);
            fontButtonSelected = new Font(ff, 30f, FontStyle.Bold);
            fontRankings = new Font(ff, 25f, FontStyle.Bold);

            MyButton._normalFont = fontButtonRegular;
            MyButton._hoverFont = fontButtonSelected;
        }
开发者ID:Gago993,项目名称:TriGame,代码行数:30,代码来源:StartScreen.cs


示例15: Main

		public static void Main( string[] args ) {
			Font f = new Font( "Tahoma", 70 );
			Point drawPos;
			string saveDir = AppDomain.CurrentDomain.BaseDirectory + @"\Minimap\";

			System.IO.Directory.CreateDirectory( saveDir );
			for( int i = 0; i < 200; i++ ) {
				Console.WriteLine( "build Image " + i + ".." );
				using( Bitmap bmp = new Bitmap( 512, 512 ) ) {
					using( Graphics g = Graphics.FromImage( bmp ) ) {
						SizeF stringSize = g.MeasureString( i.ToString(), f );

						drawPos = new Point( 256 - (int)stringSize.Width / 2, 256 - (int)stringSize.Height / 2 );
						g.DrawString( i.ToString(), f, Brushes.White, drawPos );

					}

					DevIL.DevIL.SaveBitmap( saveDir + i + ".tga", bmp );
				}
			}


			Console.WriteLine( "\nfinished" );
			Console.ReadKey();
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:25,代码来源:Program.cs


示例16: ChatPreview

        static unsafe ChatPreview()
        {
            Fonts = new PrivateFontCollection();
            fixed( byte* fontPointer = Resources.MinecraftFont ) {
                Fonts.AddMemoryFont( (IntPtr)fontPointer, Resources.MinecraftFont.Length );
            }
            MinecraftFont = new Font( Fonts.Families[0], 12, FontStyle.Regular );
            ColorPairs = new[]{
                new ColorPair(0,0,0,0,0,0),
                new ColorPair(0,0,191,0,0,47),
                new ColorPair(0,191,0,0,47,0),
                new ColorPair(0,191,191,0,47,47),
                new ColorPair(191,0,0,47,0,0),
                new ColorPair(191,0,191,47,0,47),
                new ColorPair(191,191,0,47,47,0),
                new ColorPair(191,191,191,47,47,47),

                new ColorPair(64,64,64,16,16,16),
                new ColorPair(64,64,255,16,16,63),
                new ColorPair(64,255,64,16,63,16),
                new ColorPair(64,255,255,16,63,63),
                new ColorPair(255,64,64,63,16,16),
                new ColorPair(255,64,255,63,16,63),
                new ColorPair(255,255,64,63,63,16),
                new ColorPair(255,255,255,63,63,63)
            };
        }
开发者ID:Bedrok,项目名称:800craft,代码行数:27,代码来源:ChatPreview.cs


示例17: Get_StringWidth

 /// <summary>
 /// Gets a width of the string with specified font and font-size.
 /// </summary>
 /// <param name="text">Input string.</param>
 /// <param name="fontName">Font name.</param>
 /// <param name="fontSize">Font size.</param>
 /// <param name="styleFlags">Integer value representing System.Drawing.FontStyle instance.</param>
 /// <returns>Returns a width of specified string in pixels.</returns>
 public static float Get_StringWidth(string text, string fontName, float fontSize, int styleFlags)
 {
     var bitmap	= Graphics.FromImage(new Bitmap(1, 1));
     var font	= new Font(fontName, fontSize / 2, (FontStyle)styleFlags);
     var stringSize	= bitmap.MeasureString(text, font);
     return stringSize.Width;
 }
开发者ID:ZeroByte1987,项目名称:ConsoleGames,代码行数:15,代码来源:ZDrawing.cs


示例18: AddString

 public void AddString(string s,	FontFamily family,	int style, float emSize, PointF origin, StringFormat format)
 {
     var font = new Font (family.Name, emSize, (FontStyle)style);
     var layoutRect = RectangleF.Empty;
     layoutRect.Location = origin;
     NativeDrawString (s, font, Color.Red, layoutRect, format);
 }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:7,代码来源:GraphicsPath-AddString.cs


示例19: ConsoleLog

        public ConsoleLog()
        {
            InitializeComponent();

            _textBox = textBox;

            ConsoleBackColor = Color.FromArgb(51, 51, 51);
            ConsoleFont = new Font("Consolas", 12F, FontStyle.Regular, GraphicsUnit.Point, 0);
            StandardForeColor = Color.FromArgb(225, 213, 112);
            StandardBackColor = Color.FromArgb(51, 51, 51);
            InfoForeColor = Color.FromArgb(99, 211, 234);
            InfoBackColor = Color.FromArgb(51, 51, 51);
            WarningForeColor = Color.FromArgb(51, 51, 51);
            WarningBackColor = Color.FromArgb(255, 252, 0);
            ErrorForeColor = Color.White;
            ErrorBackColor = Color.Tomato;
            SuccessForeColor = Color.FromArgb(163, 233, 45);
            SuccessBackColor = Color.FromArgb(51, 51, 51);
            StandoutForeColor = Color.FromArgb(250, 1, 194);
            StandoutBackColor = Color.FromArgb(51, 51, 51);
            SubtleForeColor = Color.FromArgb(156, 156, 156);
            SubtleBackColor = Color.FromArgb(51, 51, 51);
            EventForeColor = Color.FromArgb(78, 201, 176);
            EventBackColor = Color.FromArgb(51, 51, 51);
            EventWarningForeColor = Color.White;
            EventWarningBackColor = Color.FromArgb(78, 201, 176);

        }
开发者ID:sidesoftware,项目名称:Side.Log,代码行数:28,代码来源:ConsoleLog.cs


示例20: italicToolStripButton_CheckedChanged

    private void italicToolStripButton_CheckedChanged(object sender, EventArgs e)
    {
      Font oldFont, newFont;

      bool checkState = ((ToolStripButton)sender).Checked;
      oldFont = this.richTextBoxText.SelectionFont;

      if (!checkState)
        newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Italic);
      else
        newFont = new Font(oldFont, oldFont.Style | FontStyle.Italic);

      richTextBoxText.SelectionFont = newFont;
      richTextBoxText.Focus();

      italicToolStripMenuItem.CheckedChanged -= new
EventHandler(italicToolStripMenuItem_CheckedChanged);
      italicToolStripMenuItem.Checked = checkState;
      italicToolStripMenuItem.CheckedChanged += new
EventHandler(italicToolStripMenuItem_CheckedChanged);
//StatusBar
         if (!checkState)
            toolStripStatusLabelItalic.Font = new Font(toolStripStatusLabelItalic.Font, toolStripStatusLabelItalic.Font.Style & ~FontStyle.Italic);
         else
            toolStripStatusLabelItalic.Font = new Font(toolStripStatusLabelItalic.Font, toolStripStatusLabelItalic.Font.Style | FontStyle.Italic);

    }
开发者ID:niuniuliu,项目名称:CSharp,代码行数:27,代码来源:Form1.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Drawing.FontFamily类代码示例发布时间:2022-05-26
下一篇:
C# Drawing.FastBitmap类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap