AngleSharp.CSS to extract fontfamily does not work

113 views Asked by At

I try to extract the font family name in a css file. When looking in debug, the font family name is present, also when i modify it by a SetFontFamily, but the GetFontFamiliy does not return anything.

 public void CssStyleSheettractFontFamily()
    {
        var parser = new CssParser();
        var source = "<!-- body { font-family: Verdana } div.hidden { display: none } -->";
        ICssStyleSheet sheet = parser.ParseStyleSheet(source);

        Debug.Print( sheet.Rules.Length.ToString());

        foreach (ICssStyleRule rule in sheet.Rules)
        {
            Debug.Print(rule.CssText);
            rule.Style.SetFontFamily("Verdana Bold");
            Debug.Print("fontfamily", rule.Style.GetFontFamily());
            Debug.Print("fontSize", rule.Style.GetFontSize());
        } 
    }

Any advice?

1

There are 1 answers

0
Ghisbo On

So basic, i did not really print it. See solution below.

Debug.Print("fontfamily {0}", rule.Style.GetFontFamily());