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


C# Font.Clone方法代码示例

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


在下文中一共展示了Font.Clone方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCharWidthABC

		public static ABC GetCharWidthABC(char ch, Font font, System.Drawing.Graphics gr)
		{
			ABC[] _temp = new ABC[1];
			IntPtr hDC = gr.GetHdc();
			Font ft = (Font)font.Clone();
			IntPtr hFt = ft.ToHfont();
			SelectObject(hDC, hFt);
			GetCharABCWidthsW(hDC, ch, ch, _temp);
			DeleteObject(hFt);
			gr.ReleaseHdc();

			return _temp[0];
		}
开发者ID:Boerlam001,项目名称:MonoGame,代码行数:13,代码来源:FontHelper.cs

示例2: TestClone

		public void TestClone()
		{		
			Font f = new Font("Arial",12);	
			Font f2 = (Font) f.Clone();
			
			Assert.AreEqual (f.Bold, f2.Bold, "Bold");
			Assert.AreEqual (f.FontFamily, f2.FontFamily, "FontFamily");
			Assert.AreEqual (f.GdiCharSet, f2.GdiCharSet, "GdiCharSet");
			Assert.AreEqual (f.GdiVerticalFont, f2.GdiVerticalFont, "GdiVerticalFont");
			Assert.AreEqual (f.Height, f2.Height, "Height");
			Assert.AreEqual (f.Italic, f2.Italic, "Italic");
			Assert.AreEqual (f.Name, f2.Name, "Name");
			Assert.AreEqual (f.Size, f2.Size, "Size");
			Assert.AreEqual (f.SizeInPoints, f2.SizeInPoints, "SizeInPoints");
			Assert.AreEqual (f.Strikeout, f2.Strikeout, "Strikeout");
			Assert.AreEqual (f.Style, f2.Style, "Style");
			Assert.AreEqual (f.Underline, f2.Underline, "Underline");
			Assert.AreEqual (f.Unit, f2.Unit, "Unit");
		}
开发者ID:frje,项目名称:SharpLang,代码行数:19,代码来源:TestFont.cs

示例3: GetKerningPairs

        // This isn't used anymore. It's left here as reference for how to get kerning data in C#.
        public static KerningPair[] GetKerningPairs( Font font, Graphics graphics )
        {
            // Select the HFONT into the HDC.
            IntPtr hDC = graphics.GetHdc();
            Font fontClone = (Font)font.Clone();
            IntPtr hFont = fontClone.ToHfont();
            SelectObject( hDC, hFont );

            // Find out how many pairs there are and allocate them.
            int numKerningPairs = GetKerningPairs( hDC.ToInt32(), 0, null );
            KerningPair[] kerningPairs = new KerningPair[ numKerningPairs ];

            // Get the pairs.
            GetKerningPairs( hDC.ToInt32(), kerningPairs.Length, kerningPairs );

            DeleteObject( hFont );
            graphics.ReleaseHdc();

            return kerningPairs;
        }
开发者ID:SudoMike,项目名称:SudoFont,代码行数:21,代码来源:FontServices.cs

示例4: updateSelectedFont

        // update input font
        private void updateSelectedFont(Font fnt)
        {
            // set text name in the text box
            txtInputFont.Text = fnt.Name;

            // add to text
            txtInputFont.Text += " " + Math.Round(fnt.Size) + "pts";

            // check if bold
            if (fnt.Bold)
            {
                // add to text
                txtInputFont.Text += " / Bold";
            }

            // check if italic
            if (fnt.Italic)
            {
                // add to text
                txtInputFont.Text += " / Italic";
            }

            // set the font in the text box
            txtInputText.Font = (Font)fnt.Clone();

            // save into settings
            Properties.Settings.Default.InputFont = fnt;
            Properties.Settings.Default.Save();
        }
开发者ID:rzva,项目名称:the-dot-factory,代码行数:30,代码来源:MainForm.cs

示例5: TextItem

 public TextItem(Font ft)
 {
   m_Type = InnerType.Empty;
   m_Text = "";
   m_Font = (null == ft) ? null : (Font)ft.Clone();
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:6,代码来源:TextGraphic.cs

示例6: ColorizationStyle

 /// <summary>
 /// Initializes a new instance of the ColorizationStyle class.
 /// </summary>
 /// <param name="newFixationPen">The new fixation pen to set.</param>
 /// <param name="newConnectionPen">The new fixation connection pen to set.</param>
 /// <param name="newFont">The new font to set.</param>
 /// <param name="newFontColor">The new font color to set.</param>
 public ColorizationStyle(Pen newFixationPen, Pen newConnectionPen, Font newFont, Color newFontColor)
 {
   this.fixationPen = (Pen)newFixationPen.Clone();
   this.connectionPen = (Pen)newConnectionPen.Clone();
   this.font = (Font)newFont.Clone();
   this.fontColor = newFontColor;
 }
开发者ID:DeSciL,项目名称:Ogama,代码行数:14,代码来源:ColorizationStyle.cs

示例7: VGElement

 /// <summary>
 /// Initializes a new instance of the VGElement class.
 /// </summary>
 /// <param name="newShapeDrawAction">Drawing action: Edge, Fill, Both</param>
 /// <param name="newBrush">Brush for text and fills</param>
 /// <param name="newFont">Font for text</param>
 /// <param name="newFontColor">Color for text</param>
 /// <param name="newBounds">Bounds of element</param>
 /// <param name="newStyleGroup">Group Enumeration, <see cref="VGStyleGroup"/></param>
 /// <param name="newName">Name of Element</param>
 /// <param name="newElementGroup">Element group description</param>
 public VGElement(
   ShapeDrawAction newShapeDrawAction,
   Brush newBrush,
   Font newFont,
   Color newFontColor,
   RectangleF newBounds,
   VGStyleGroup newStyleGroup,
   string newName,
   string newElementGroup)
 {
   this.InitStandards();
   this.styleGroup = newStyleGroup;
   this.name = newName;
   this.elementGroup = newElementGroup;
   this.shapeDrawAction = newShapeDrawAction;
   this.Brush = newBrush == null ? null : (Brush)newBrush.Clone();
   this.Font = newFont == null ? null : (Font)newFont.Clone();
   this.FontColor = newFontColor;
   this.Bounds = newBounds;
 }
开发者ID:DeSciL,项目名称:Ogama,代码行数:31,代码来源:VGElement.cs

示例8: GetMeasuredItems

    public override IMeasuredLabelItem[] GetMeasuredItems(Graphics g, Font font, StringFormat strfmt, Altaxo.Data.AltaxoVariant[] items)
    {
      

      MeasuredLabelItem[] litems = new MeasuredLabelItem[items.Length];

      Font localfont1 = (Font)font.Clone();
      Font localfont2 = new Font(font.FontFamily, font.Size * 2 / 3, font.Style, GraphicsUnit.World);
     
      StringFormat localstrfmt = (StringFormat)strfmt.Clone();

      string[] firstp = new string[items.Length];
      string[] expos = new string[items.Length];

      float maxexposize=0;
      for (int i = 0; i < items.Length; ++i)
      {
        string firstpart, exponent;
        if (items[i].IsType(Altaxo.Data.AltaxoVariant.Content.VDouble))
        {
          SplitInFirstPartAndExponent((double)items[i], out firstpart, out exponent);
        }
        else
        {
          firstpart = items[i].ToString(); exponent = string.Empty;
        }
        firstp[i] = firstpart;
        expos[i] = exponent;
        maxexposize = Math.Max(maxexposize,g.MeasureString(exponent,localfont2,new PointF(0,0),strfmt).Width);
      }


      for (int i = 0; i < items.Length; ++i)
      {
        litems[i] = new MeasuredLabelItem(g, localfont1, localfont2, localstrfmt, firstp[i],expos[i],maxexposize);
      }

      return litems;
      
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:40,代码来源:NumericLabelFormattingScientific.cs

示例9: DrawFitString

		private float DrawFitString(Graphics g, string value, Font font, Brush brush, RectangleF rect, StringFormat sf)
		{
			SizeF size = g.MeasureString(value, font);
			Font measureFont = font;
			smallFont = font;

			while ((size.Width > rect.Width) && measureFont.Size >= 1)
			{
				float shrinkFactor = (float)Math.Sqrt(rect.Height / size.Height);
				using (measureFont = new Font(font.FontFamily, (int)Math.Min(measureFont.Size - 1, measureFont.Size * shrinkFactor)))
				{
					size = g.MeasureString(value, measureFont);
					smallFont = (Font)(measureFont.Clone());
				}
			}

			g.DrawString(value, smallFont, brush, rect, sf);
			return size.Height;
		}
开发者ID:enildne,项目名称:zest,代码行数:19,代码来源:HeatMap.cs


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