public void Text(SKCanvas canvas, string text, SKRect frame, SKTypeface typeface, float size, TextDecoration decorations)
        {
            using (var paint = new SKPaint()
            {
                IsAntialias = true,
                Color = Color,
                Style = SKPaintStyle.Fill,
                TextAlign = SKTextAlign.Left,
                Typeface = typeface,
                FakeBoldText = decorations.HasFlag(TextDecoration.Bold),
                TextSize = size * Density.Global,
            })
            {
                if (decorations.HasFlag(TextDecoration.Italic))
                {
                    paint.TextSkewX = 0.5f;
                }

                canvas.DrawText(text, frame.Left, frame.Bottom, paint);
            }
        }
示例#2
0
        public void Text(SKCanvas canvas, string text, SKRect frame, SKTypeface typeface, float size, TextDecoration decorations)
        {
            var path = new SKPath();

            path.AddRect(frame);
            using (var paint = this.CreatePaint(path))
            {
                paint.IsAntialias  = true;
                paint.Style        = SKPaintStyle.Fill;
                paint.TextAlign    = SKTextAlign.Left;
                paint.Typeface     = typeface;
                paint.FakeBoldText = decorations.HasFlag(TextDecoration.Bold);
                paint.TextSize     = size * Density.Global;

                if (decorations.HasFlag(TextDecoration.Italic))
                {
                    paint.TextSkewX = 0.5f;
                }

                canvas.DrawText(text, frame.Left, frame.Bottom, paint);
            }
        }