I am using SVG-Net for creating PNG,JPG files from SVG.
Problem I am facing is, fonts are not rendering in PNG,JPG from SVG, although when I view my SVG, font shows. Following is my code:
var svgContent = svgDocument.ToString();
var mySvg = SvgDocument.FromSvg<SvgDocument>(svgContent);
mySvg.Height = new SvgUnit(SvgUnitType.Pixel, pixelHeight);
mySvg.Width = new SvgUnit(SvgUnitType.Pixel, pixelWidth);
mySvg.ViewBox = new SvgViewBox(0, 0, viewBoxWidth, viewBoxHeight);
Bitmap bmpSquare = mySvg.Draw(pixelWidth, pixelHeight);
bmpSquare.Save(FilePathJPG, jgpEncoder,myEncoderParameters);
bmpSquare.Save(FilePathPNG, pngEncoder,myEncoderParameters);
I have ttf files, it works on my local when I install the fonts on my machine locally in C:/Windows/Fonts. But same is not feasible when my Azure Function App is deployed. Can there be a way to install font on PaaS on Azure?
For SVG in added font-face and adding ttf file in base64 format. or is there a way I can render the fonts in SVG-Net library I am using. Following is the code I used in SVG:
<defs>
<style>
@font-face {
font-family:Segoe Pro Bold;
src: url("data:font/truetype;charset=utf-8;base64, bas64 conversion of my font TTF file") format('truetype');
}
</style>
</defs>
Using the above code shows the font on my SVG, but it renders default font when I convert Bitmap & save to PNG & JPG.
I am so close to my deadlines, I have completed the hardest of things but stuck with this critical issue. Thanks in advance.