本文整理汇总了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];
}
示例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");
}
示例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;
}
示例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();
}
示例5: TextItem
public TextItem(Font ft)
{
m_Type = InnerType.Empty;
m_Text = "";
m_Font = (null == ft) ? null : (Font)ft.Clone();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}