SVG
SVG copied to clipboard
Private font incorrectly displays italic style
Description
I am using SVG.NET to convert SVG to PNG images, while some parts of the text need to use our private font file: Jyeoohai.ttf and jyeoohai-italic.ttf. I use svgfontManager.privateFontPathList.add (fonts) to load the above two font files, the resulting image text of normal form is correct, but the italic text is invalid. If I install the font file on Windows, the font styles are correct even without calling svgfontManager.privateFontPathList.add. However, software is going to be deployed to dozens of servers , so I don't want to install fonts on each one. Can SVG.NET dynamically load these character files?
Example data
<svg xmlns="http://www.w3.org/2000/svg">
<text y="20" x="5" font-size="32px"
font-style="normal" style="font-family: Jyeoohai">
Normal font style
</text>
<text y="55" x="5" font-size="32px"
font-style="italic" style="font-family: Jyeoohai">
Italic font style
</text>
</svg>
Used Versions
SVG version 3.3.0.0
Can you show what do you mean by "the italic text is invalid"? I guess it is not possible to upload your private font...
I used Open Sans to check how PrivateFontCollection behaves.
If font name is the same, font added earlier will be applied.
- OpenSans-Regular.ttf <- Applies as
Open Sans
- OpenSans-Italic.ttf
@huigy I have never created font files, is it possible to combine all styles into one file ? What is structure of your font files ?
Also what I didn't understand was that when I added only OpenSans-Regular.ttf
, all styles became true
in the code below.
foreach (var family in privateFontCollection.Families)
{
System.Diagnostics.Debug.WriteLine(family.Name); // "Open Sans"
System.Diagnostics.Debug.WriteLine(" Bold is " + family.IsStyleAvailable(FontStyle.Bold)); // true
System.Diagnostics.Debug.WriteLine(" Italic is " + family.IsStyleAvailable(FontStyle.Italic)); // true
System.Diagnostics.Debug.WriteLine(" Underline is " + family.IsStyleAvailable(FontStyle.Underline)); // true
}