Exemplo n.º 1
0
        /// <summary>
        /// Render outlined characters.
        /// </summary>
        /// <param name="pen"></param>
        /// <param name="range"></param>
        public void Render(Pen pen, Vector2i range)
        {
            if (range.Y < range.X)
            {
                return;
            }
            ValidateRange(range);

            canvas.Begin(CanvasRenderFlags.SoftwarePositionTransform);
            try
            {
                for (int i = range.X; i <= range.Y; i++)
                {
                    RenderGlyphInfo info = glyphs[i];
                    if (glyphs[i].RenderingData == null)
                    {
                        continue;
                    }

                    // We set transform.
                    canvas.Transform =
                        new LinearTransform(
                            Matrix4x4f.CreateTranslate(info.LeftBottom.Vec3) *
                            Matrix4x4f.CreateScale(new Vector3f(fontSize, fontSize, fontSize))
                            );


                    // We finally render.
                    TriangleSoup2f soup =
                        info.RenderingData.AcquireOutline(canvas.CanvasInfo.TesselationResolution,
                                                          pen.ToOutlineTesselationOptions(canvas.CanvasInfo));
                    canvas.FillShape(pen.Fill, soup, info.AttachedMapper);
                }
            }
            finally
            {
                canvas.End();
            }
        }