Exemplo n.º 1
0
        public void DrawText(Font font, SolidBrush brush, float x, float y, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            StartDrawing();
#if OSX
            var nsfont = FontHandler.GetControl(font);
            var str    = new NSString(text);
            var dic    = new NSMutableDictionary();
            dic.Add(NSAttributedString.ForegroundColorAttributeName, brush.Color.ToNS());
            dic.Add(NSAttributedString.FontAttributeName, nsfont);
            //context.SetShouldAntialias(true);
            if (!Flipped)
            {
                var size = str.StringSize(dic);
                Control.ConcatCTM(new CGAffineTransform(1, 0, 0, -1, 0, ViewHeight));
                y = ViewHeight - y - size.Height;
            }
            str.DrawString(TranslateView(new SD.PointF(x, y)), dic);
            //context.SetShouldAntialias(antialias);
#elif IOS
            var uifont = font.ToUI();
            var str    = new NSString(text);
            var size   = str.StringSize(uifont);
            //context.SetShouldAntialias(true);
            Control.SetFillColor(brush.Color.ToCGColor());
            str.DrawString(TranslateView(new SD.PointF(x, y), elementHeight: size.Height), uifont);
#endif

            EndDrawing();
        }
Exemplo n.º 2
0
 public static ag.Typeface ToAndroid(this Font font)
 {
     return(FontHandler.GetControl(font));
 }