本文整理汇总了C#中Pango.Layout.GetExtents方法的典型用法代码示例。如果您正苦于以下问题:C# Pango.Layout.GetExtents方法的具体用法?C# Pango.Layout.GetExtents怎么用?C# Pango.Layout.GetExtents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pango.Layout
的用法示例。
在下文中一共展示了Pango.Layout.GetExtents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawString
//.........这里部分代码省略.........
// break;
// case TextAlignEnum.Center:
// drawFormat.Alignment = StringAlignment.Center;
// break;
// case TextAlignEnum.Left:
// default:
// drawFormat.Alignment = StringAlignment.Near;
// break;
// }
switch (si.TextAlign)
{
case TextAlignEnum.Right:
layout.Alignment = Pango.Alignment.Right;
break;
case TextAlignEnum.Center:
layout.Alignment = Pango.Alignment.Center;
break;
case TextAlignEnum.Left:
default:
layout.Alignment = Pango.Alignment.Left;
break;
}
layout.Width = Pango.Units.FromPixels((int)(r.Width - si.PaddingLeft - si.PaddingRight - 2));
// layout.Width = (int)Pango.Units.FromPixels((int)r.Width);
layout.SetText(s);
// if (pt.SI.WritingMode == WritingModeEnum.tb_rl)
// {
// drawFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
// drawFormat.FormatFlags |= StringFormatFlags.DirectionVertical;
// }
// switch (si.VerticalAlign)
// {
// case VerticalAlignEnum.Bottom:
// drawFormat.LineAlignment = StringAlignment.Far;
// break;
// case VerticalAlignEnum.Middle:
// drawFormat.LineAlignment = StringAlignment.Center;
// break;
// case VerticalAlignEnum.Top:
// default:
// drawFormat.LineAlignment = StringAlignment.Near;
// break;
// }
//
Pango.Rectangle logical;
Pango.Rectangle ink;
layout.GetExtents(out ink, out logical);
double height = logical.Height / Pango.Scale.PangoScale;
double y = 0;
switch (si.VerticalAlign)
{
case VerticalAlignEnum.Top:
y = r.Y + si.PaddingTop;
break;
case VerticalAlignEnum.Middle:
y = r.Y + (r.Height - height) / 2;
break;
case VerticalAlignEnum.Bottom:
y = r.Y + (r.Height - height) - si.PaddingBottom;
break;
}
// draw the background
DrawBackground(g, r, si);
// adjust drawing rectangle based on padding
// Cairo.Rectangle r2 = new Cairo.Rectangle(r.X + si.PaddingLeft,
// r.Y + si.PaddingTop,
// r.Width - si.PaddingLeft - si.PaddingRight,
// r.Height - si.PaddingTop - si.PaddingBottom);
Cairo.Rectangle box = new Cairo.Rectangle(
r.X + si.PaddingLeft + 1,
y,
r.Width,
r.Height);
//drawBrush = new SolidBrush(si.Color);
g.Color = si.Color.ToCairoColor();
// if (pt.NoClip) // request not to clip text
// {
// g.DrawString(pt.Text, drawFont, drawBrush, new PointF(r.Left, r.Top), drawFormat);
// //HighlightString(g, pt, new RectangleF(r.Left, r.Top, float.MaxValue, float.MaxValue),drawFont, drawFormat);
// }
// else
// {
// g.DrawString(pt.Text, drawFont, drawBrush, r2, drawFormat);
// //HighlightString(g, pt, r2, drawFont, drawFormat);
// }
g.MoveTo(box.X, box.Y);
Pango.CairoHelper.ShowLayout(g, layout);
layout.FontDescription = oldfont;
g.Restore();
}