internal IFontDefn GetFont(ISvgRenderer renderer)
{
// Get the font-size
float fontSize;
var fontSizeUnit = this.FontSize;
if (fontSizeUnit == SvgUnit.None || fontSizeUnit == SvgUnit.Empty)
{
fontSize = 1.0f;
}
else
{
fontSize = fontSizeUnit.ToDeviceValue(renderer, UnitRenderingType.Vertical, this);
}
var family = ValidateFontFamily(this.FontFamily, this.OwnerDocument);
var sFaces = family as IEnumerable<SvgFontFace>;
if (sFaces == null)
{
var fontStyle = System.Drawing.FontStyle.Regular;
// Get the font-weight
switch (this.FontWeight)
{
//Note: Bold is not listed because it is = W700.
case SvgFontWeight.Bolder:
case SvgFontWeight.W600:
case SvgFontWeight.W700:
case SvgFontWeight.W800:
case SvgFontWeight.W900:
fontStyle |= System.Drawing.FontStyle.Bold;
break;
}
// Get the font-style
switch (this.FontStyle)
{
case SvgFontStyle.Italic:
case SvgFontStyle.Oblique:
fontStyle |= System.Drawing.FontStyle.Italic;
break;
}
// Get the text-decoration
switch (this.TextDecoration)
{
case SvgTextDecoration.LineThrough:
fontStyle |= System.Drawing.FontStyle.Strikeout;
break;
case SvgTextDecoration.Underline:
fontStyle |= System.Drawing.FontStyle.Underline;
break;
}
var ff = family as FontFamily;
if (!ff.IsStyleAvailable(fontStyle))
{
// Do Something
}
// Get the font-family
return new GdiFontDefn(new System.Drawing.Font(ff, fontSize, fontStyle, System.Drawing.GraphicsUnit.Pixel));
}
else
{
var font = sFaces.First().Parent as SvgFont;
if (font == null)
{
var uri = sFaces.First().Descendants().OfType<SvgFontFaceUri>().First().ReferencedElement;
font = OwnerDocument.IdManager.GetElementById(uri) as SvgFont;
}
return new SvgFontDefn(font, fontSize, OwnerDocument.Ppi);
}
}