本文整理汇总了C#中System.Drawing.FontFamily.GetLineSpacing方法的典型用法代码示例。如果您正苦于以下问题:C# FontFamily.GetLineSpacing方法的具体用法?C# FontFamily.GetLineSpacing怎么用?C# FontFamily.GetLineSpacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.FontFamily
的用法示例。
在下文中一共展示了FontFamily.GetLineSpacing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObtainFontMetrics
void ObtainFontMetrics(Graphics g)
{
string infoString = ""; // enough space for one line of output
int ascent; // font family ascent in design units
float ascentPixel; // ascent converted to pixels
int descent; // font family descent in design units
float descentPixel; // descent converted to pixels
int lineSpacing; // font family line spacing in design units
float lineSpacingPixel; // line spacing converted to pixels
FontStyle fontStyle = FontStyle.Regular;
//fontStyle = FontStyle.Italic | FontStyle.Bold;
FontFamily fontFamily = new FontFamily("arial");
//fontFamily = FontFamily.GenericSansSerif;
Font font = new Font(
fontFamily,
16, fontStyle,
GraphicsUnit.Pixel);
PointF pointF = new PointF(10, 10);
SolidBrush solidBrush = new SolidBrush(Color.Black);
// Display the font size in pixels.
infoString = "font family : " + font.FontFamily.Name + " " + fontStyle + ".";
g.DrawString(infoString, font, solidBrush, pointF);
// Move down one line.
pointF.Y += font.Height;
// Display the font size in pixels.
infoString = "font.Size returns " + font.Size + ".";
g.DrawString(infoString, font, solidBrush, pointF);
// Move down one line.
pointF.Y += font.Height;
// Display the font family em height in design units.
infoString = "fontFamily.GetEmHeight() returns " +
fontFamily.GetEmHeight(fontStyle) + ".";
g.DrawString(infoString, font, solidBrush, pointF);
// Move down two lines.
pointF.Y += 2 * font.Height;
// Display the ascent in design units and pixels.
ascent = fontFamily.GetCellAscent(fontStyle);
// 14.484375 = 16.0 * 1854 / 2048
ascentPixel =
font.Size * ascent / fontFamily.GetEmHeight(fontStyle);
infoString = "The ascent is " + ascent + " design units, " + ascentPixel +
" pixels.";
g.DrawString(infoString, font, solidBrush, pointF);
// Move down one line.
pointF.Y += font.Height;
// Display the descent in design units and pixels.
descent = fontFamily.GetCellDescent(fontStyle);
// 3.390625 = 16.0 * 434 / 2048
descentPixel =
font.Size * descent / fontFamily.GetEmHeight(fontStyle);
infoString = "The descent is " + descent + " design units, " +
descentPixel + " pixels.";
g.DrawString(infoString, font, solidBrush, pointF);
// Move down one line.
pointF.Y += font.Height;
// Display the line spacing in design units and pixels.
lineSpacing = fontFamily.GetLineSpacing(fontStyle);
// 18.398438 = 16.0 * 2355 / 2048
lineSpacingPixel =
font.Size * lineSpacing / fontFamily.GetEmHeight(fontStyle);
infoString = "The line spacing is " + lineSpacing + " design units, " +
lineSpacingPixel + " pixels.";
g.DrawString(infoString, font, solidBrush, pointF);
title = "ObtainFontMetrics";
}
示例2: FontFamily_String
public void FontFamily_String ()
{
HostIgnoreList.CheckTest ("MonoTests.System.Drawing.FontFamilyTest.FontFamily_String");
FontFamily ff = new FontFamily (name);
CheckMono (ff);
FontStyle style = FontStyle.Bold;
Assert.AreEqual (ff.Name, ff.GetName (0), "GetName");
Assert.IsTrue ((ff.GetCellAscent (style) > 0), "GetCellAscent");
Assert.IsTrue ((ff.GetCellDescent (style) > 0), "GetCellDescent");
Assert.IsTrue ((ff.GetEmHeight (style) > 0), "GetEmHeight");
Assert.IsTrue ((ff.GetLineSpacing (style) > 0), "GetLineSpacing");
Assert.IsTrue (ff.IsStyleAvailable (style), "IsStyleAvailable");
}
示例3: PdfFont
/// <summary>
/// Font object
/// </summary>
/// <param name="graphics">GDI+ drawing surface</param>
/// <param name="fontFamilly">Font familly</param>
/// <param name="style">Font style</param>
/// <param name="name">Font name</param>
public PdfFont(Graphics graphics, FontFamily fontFamilly, FontStyle style, string name) {
this.CodeName = "/F" + id++;
this.Name = name;
this.HeightTs = (short)((fontFamilly.GetLineSpacing(style) * 1000) / fontFamilly.GetEmHeight(style));
this.WidthsTs = GetCharsWidth(graphics, fontFamilly, style);
}
示例4: InitializeSizes
private void InitializeSizes()
{
_fretWidth = 4 * _size;
_nutHeight = _fretWidth / 2f;
_lineWidth = (int)Math.Ceiling(_size * 0.31);
_dotWidth = (int)Math.Ceiling(0.9 * _fretWidth);
_markerWidth = 0.7f * _fretWidth;
_boxWidth = 5 * _fretWidth + 6 * _lineWidth;
_boxHeight = FRET_COUNT * (_fretWidth + _lineWidth) + _lineWidth;
//Find out font sizes
FontFamily family = new FontFamily(FONT_NAME);
float perc = family.GetCellAscent(FontStyle.Regular) / (float)family.GetLineSpacing(FontStyle.Regular);
_fretFontSize = _fretWidth / perc;
_fingerFontSize = _fretWidth * 0.8f;
_nameFontSize = _fretWidth * 2f / perc;
_superScriptFontSize = 0.7f * _nameFontSize;
if (_size == 1) {
_nameFontSize += 2;
_fingerFontSize += 2;
_fretFontSize += 2;
_superScriptFontSize += 2;
}
_xstart = _fretWidth;
_ystart = (float) Math.Round(0.2f * _superScriptFontSize + _nameFontSize + _nutHeight + 1.7f * _markerWidth);
_imageWidth = (int)(_boxWidth + 5 * _fretWidth);
_imageHeight = (int)(_boxHeight + _ystart + _fretWidth + _fretWidth);
_signWidth = (int)(_fretWidth * 0.75);
_signRadius = _signWidth / 2;
}