public override void DrawTextLayout(object backend, Drawing.TextLayout layout, double x, double y)
        {
            var c = (DroidContext)backend;

            var tl    = (DroidTextLayoutBackend)layout.GetBackend();
            var strw  = c.Paint.StrokeWidth;
            var style = c.Paint.GetStyle();

            tl.SetPaint(c.Paint);
            try {
                c.Paint.StrokeWidth = 0.3f;
                c.Paint.SetStyle(AG.Paint.Style.FillAndStroke);

                var text = layout.Text;
                var fx   = (float)x;
                var fy   = (float)y;

                var wrapper = new TextWrapper();
                wrapper.SingleLine = w =>
                                     c.Canvas.DrawText(text, fx, fy + w.LineY, c.Paint);
                wrapper.MultiLine = w => {
                    var st = text.Substring(w.LineStart, w.CursorPos - w.LineStart);
                    if (w.LineY + w.LineHeight > w.MaxHeight && w.CursorPos < text.Length)
                    {
                        st += ((char)0x2026).ToString();
                    }
                    c.Canvas.DrawText(st, fx, fy + w.LineY, c.Paint);
                };
                wrapper.Wrap(tl, c.Paint);
            } finally {
                c.Paint.StrokeWidth = strw;
                c.Paint.SetStyle(style);
            }
        }
Exemplo n.º 2
0
        public override void DrawTextLayout(object backend, Drawing.TextLayout layout, double x, double y)
        {
            var c = (Html5Context)backend;

            c.Context.CommandLine("fillStyle={0}", c.Color.ToStyle());
            var tl   = (HtmlTextLayoutBackend)layout.GetBackend();
            var font = tl.Font;

            c.Context.CommandLine("font=\"{1}pt {0} {2}\"", font.Family, font.Size.ToHtml(), font.Style.ToHtml());

            var text = layout.Text;

            text = text.Replace("\r", "").Replace("\n", "");
            // NO: text = System.Net.WebUtility.HtmlEncode(text);
            c.Context.CommandLine("fillText(\"{0}\",{1},{2})", text, x.ToHtml(), y.ToHtml());
        }