本文整理汇总了C#中IRenderer.DrawSingleLineText方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderer.DrawSingleLineText方法的具体用法?C# IRenderer.DrawSingleLineText怎么用?C# IRenderer.DrawSingleLineText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderer
的用法示例。
在下文中一共展示了IRenderer.DrawSingleLineText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderSingleLineText
// Render some text with the given font inside the given rectangle. Either center or left flush.
// If the rectange doesn't intersect the clip rectangle, do nothing. Render a single line of text
private void RenderSingleLineText(IRenderer renderer, int fontNumber, StringAlignment alignment, string s, float left, float top, float right, float bottom, RectangleF clipRect)
{
if (s == null || s == "")
return;
RectangleF rect = new RectangleF(left, top, right - left, bottom - top);
if (!rect.IntersectsWith(clipRect))
return;
// Measure to make sure that the text fits.
float width = renderer.MeasureSingleLineText(fonts[fontNumber], s, rect, alignment);
if (width <= rect.Width) {
// Text fits OK.
renderer.DrawSingleLineText(fonts[fontNumber], s, rect, alignment);
}
else {
// Text is too big with normal font. Scale it down.
float scaleFactor = (rect.Width / width) * 0.95F; // scale factor so that it fits.
object scaledFont = renderer.CreateFont(fontDescs[fontNumber].Name, fontDescs[fontNumber].EmHeight * scaleFactor, fontDescs[fontNumber].Bold, fontDescs[fontNumber].Italic, fontAlignments[fontNumber]);
renderer.DrawSingleLineText(scaledFont, s, rect, alignment);
DisposeObject(scaledFont);
}
}