/// <summary> /// Initializes the <see cref="SvgText"/> class. /// </summary> static SvgText() { Bitmap bitmap = new Bitmap(1, 1); var graphics = Graphics.FromImage(bitmap); graphics.TextRenderingHint = TextRenderingHint.AntiAlias; _stringMeasure = SvgRenderer.FromGraphics(graphics); }
/// <summary> /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>. /// </summary> /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param> /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception> public void Draw(Graphics graphics) { if (graphics == null) { throw new ArgumentNullException("graphics"); } this.Render(SvgRenderer.FromGraphics(graphics)); }
/// <summary> /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>. /// </summary> /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param> /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception> public void Draw(Graphics graphics) { if (graphics == null) { throw new ArgumentNullException("graphics"); } var renderer = SvgRenderer.FromGraphics(graphics); renderer.SetBoundable(this); this.Render(renderer); }
/// <summary> /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>. /// </summary> /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param> /// <param name="size">The <see cref="SizeF"/> to render the document. If <c>null</c> document is rendered at the default document size.</param> /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception> public void Draw(Graphics graphics, SizeF?size) { if (graphics is null) { throw new ArgumentNullException("graphics"); } using (var renderer = SvgRenderer.FromGraphics(graphics)) { var boundable = size.HasValue ? (ISvgBoundable) new GenericBoundable(0, 0, size.Value.Width, size.Value.Height) : this; this.Draw(renderer, boundable); } }
/// <summary> /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>. /// </summary> /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param> /// <param name="size">The <see cref="SizeF"/> to render the document. If <c>null</c> document is rendered at the default document size.</param> /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception> public void Draw(Graphics graphics, SizeF?size) { if (graphics == null) { throw new ArgumentNullException("graphics"); } var renderer = SvgRenderer.FromGraphics(graphics); if (size.HasValue) { renderer.SetBoundable(new GenericBoundable(0, 0, size.Value.Width, size.Value.Height)); } else { renderer.SetBoundable(this); } this.Render(renderer); }