本文整理匯總了C#中fyiReporting.RDL.StyleInfo.GetFontFamily方法的典型用法代碼示例。如果您正苦於以下問題:C# StyleInfo.GetFontFamily方法的具體用法?C# StyleInfo.GetFontFamily怎麽用?C# StyleInfo.GetFontFamily使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fyiReporting.RDL.StyleInfo
的用法示例。
在下文中一共展示了StyleInfo.GetFontFamily方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MeasureString
private SizeF MeasureString(string s, StyleInfo si, Graphics g, out float descent)
{
Font drawFont=null;
StringFormat drawFormat=null;
SizeF ms = SizeF.Empty;
descent = 0;
if (s == null || s.Length == 0)
return ms;
try
{
// STYLE
System.Drawing.FontStyle fs = 0;
if (si.FontStyle == FontStyleEnum.Italic)
fs |= System.Drawing.FontStyle.Italic;
// WEIGHT
switch (si.FontWeight)
{
case FontWeightEnum.Bold:
case FontWeightEnum.Bolder:
case FontWeightEnum.W500:
case FontWeightEnum.W600:
case FontWeightEnum.W700:
case FontWeightEnum.W800:
case FontWeightEnum.W900:
fs |= System.Drawing.FontStyle.Bold;
break;
default:
break;
}
try
{
FontFamily ff = si.GetFontFamily();
drawFont = new Font(ff, si.FontSize, fs);
// following algorithm comes from the C# Font Metrics documentation
float descentPixel = si.FontSize * ff.GetCellDescent(fs) / ff.GetEmHeight(fs);
descent = RSize.PointsFromPixels(g, descentPixel);
}
catch
{
drawFont = new Font("Arial", si.FontSize, fs); // usually because font not found
descent = 0;
}
drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Near;
CharacterRange[] cr = {new CharacterRange(0, s.Length)};
drawFormat.SetMeasurableCharacterRanges(cr);
Region[] rs = new Region[1];
rs = g.MeasureCharacterRanges(s, drawFont, new RectangleF(0,0,float.MaxValue,float.MaxValue),
drawFormat);
RectangleF mr = rs[0].GetBounds(g);
ms.Height = RSize.PointsFromPixels(g, mr.Height); // convert to points from pixels
ms.Width = RSize.PointsFromPixels(g, mr.Width); // convert to points from pixels
return ms;
}
finally
{
if (drawFont != null)
drawFont.Dispose();
if (drawFormat != null)
drawFont.Dispose();
}
}