本文整理汇总了C#中MonoMac.CoreGraphics.CGContext.SetTextDrawingMode方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.SetTextDrawingMode方法的具体用法?C# CGContext.SetTextDrawingMode怎么用?C# CGContext.SetTextDrawingMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoMac.CoreGraphics.CGContext
的用法示例。
在下文中一共展示了CGContext.SetTextDrawingMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeasureStringWidth
public static float MeasureStringWidth(CGContext context, string text, string fontName, float fontSize)
{
if (string.IsNullOrEmpty(text))
return 0;
context.SaveState();
PointF pos = context.TextPosition;
context.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);
context.TextMatrix = CGAffineTransform.MakeScale(1.0f, -1.0f);
//context.TranslateCTM(0, 20);
context.ScaleCTM(1, -1);
context.SetTextDrawingMode(CGTextDrawingMode.Invisible);
context.ShowTextAtPoint(pos.X, pos.Y, text);
PointF pos2 = context.TextPosition;
context.RestoreState();
return pos2.X - pos.X;
}
示例2: DrawText
public static void DrawText(CGContext context, string text, string fontName, float fontSize, float translateHeight, float x, float y)
{
context.SaveState();
context.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);
context.SetTextDrawingMode(CGTextDrawingMode.Fill);
context.SetFillColor(new CGColor(1, 1));
context.SetStrokeColor(new CGColor(1.0f, 1.0f));
//context.AddRect(rectText);
//context.Clip();
context.TextMatrix = CGAffineTransform.MakeScale(1.0f, -1.0f);
context.TranslateCTM(0, translateHeight);
context.ScaleCTM(1, -1);
context.ShowTextAtPoint(x, y, text);
context.RestoreState();
}
示例3: MeasureText
public void MeasureText(CGContext c, Font f)
{
// Console.WriteLine ("MEASURE {0}", f);
c.SetTextDrawingMode (CGTextDrawingMode.Invisible);
c.TextPosition = new PointF(0, 0);
c.ShowText ("MM");
var mmWidth = c.TextPosition.X;
_height = f.Size - 5;
Widths = new float[0x80];
for (var i = ' '; i < 127; i++) {
var s = "M" + ((char)i).ToString() + "M";
c.TextPosition = new PointF(0, 0);
c.ShowText (s);
var sz = c.TextPosition.X - mmWidth;
if (sz < 0.1f) {
Widths = null;
return;
}
Widths[i] = sz;
}
c.SetTextDrawingMode (CGTextDrawingMode.Fill);
}