Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

Created Unassigned: Exception when 'FontStyle not AvailAble' in 'FontsUtils.cs', l. 317 [9043]

$
0
0
I ran the demo and got an exception - see above.

This function should fix the 'fonstyle availability' issue:

private static Font CreateFont(string family, float size, FontStyle style)
{
FontFamily fontFamily;
if (_existingFontFamilies.TryGetValue(family, out fontFamily))
{ return new Font(fontFamily.Name , size, EnsureStyleAvailable(fontFamily , style)); }
{
var f=new Font(family,size,GraphicsUnit.Point );
return new Font( f.Name,size, EnsureStyleAvailable(f.FontFamily , style));
{

}

}
}


private static FontStyle EnsureStyleAvailable(FontFamily family, FontStyle style)
{
if (family.IsStyleAvailable(style))
return style;
var stl = (FontStyle[])Enum.GetValues(typeof(FontStyle));
foreach ( FontStyle st in stl) {
if ((style & st) == 0) {
if (family.IsStyleAvailable(style | st))
return st | style;
}
}
return Array.Find(stl, s => (family.IsStyleAvailable(s)));
}

Viewing all articles
Browse latest Browse all 693


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>