SVG icon indicating copy to clipboard operation
SVG copied to clipboard

Could not render emojis

Open yuliazarkh opened this issue 4 years ago • 1 comments

Description

When trying to render SVG file that includes an emoji inside text attribute, to PNG, it renders an invalid symbol. Does the library support it?

Example data

testEmoji.txt

Used Versions

NET Core 3.1, Windows 10 Nuget version : Svg.Core Version: 3.0.49.2

yuliazarkh avatar Feb 29 '20 12:02 yuliazarkh

@mrbean-bremen

strings are drawn using Graphics in this library. (GDI +) emoji are drawn using TextRenderer. (GDI)

Sample Code

var text = "😀";

var location = new Point(100, 75);
var family = FontFamily.GenericSansSerif;
var fontSize = 60;
var fontStyle = FontStyle.Regular;
using (var font = new Font(family, fontSize, fontStyle, GraphicsUnit.Pixel))
{
    // Graphics -> GDI+
    g.DrawString(text, font, new SolidBrush(Color.Red), location);
}

Result

Graphics

Sample Code

var text = "😀";

var location = new Point(100, 75);
var family = FontFamily.GenericSansSerif;
var fontSize = 60;
var fontStyle = FontStyle.Regular;
using (var font = new Font(family, fontSize, fontStyle, GraphicsUnit.Pixel))
{
    // TextRenderer -> GDI
    TextRenderer.DrawText(g, text, font, location, Color.Red);
}

Result

TextRenderer

TextRenderer is included in System.Windows.Forms, so it may not be desirable to refer to it. (Can't support various runtimes ?? :worried:)

H1Gdev avatar Mar 04 '20 04:03 H1Gdev