/// <summary> /// Renders the glyph to the given surface. /// </summary> /// <param name="surface">The target surface.</param> /// <remarks> /// If the surface is not large enough, the glyph will be clipped to fit. /// </remarks> public void RenderTo(Surface surface) { // check for an empty outline, which obviously results in an empty render if (points.Length <= 0 || contours.Length <= 0) { return; } // clip against the bounds of the target surface var width = Math.Min(RenderWidth, surface.Width); var height = Math.Min(RenderHeight, surface.Height); if (width <= 0 || height <= 0) { return; } // walk each contour of the outline and render it var firstIndex = 0; renderer.Start(width, height); for (int i = 0; i < contours.Length; i++) { // decompose the contour into drawing commands var lastIndex = contours[i]; Geometry.DecomposeContour(renderer, firstIndex, lastIndex, points); // next contour starts where this one left off firstIndex = lastIndex + 1; } // blit the result to the target surface renderer.BlitTo(surface); }