本文整理匯總了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);
}