AngleSharp.CSS to extract fontfamily does not work
ghisbo opened this issue · comments
ghislain borremans commented
I try to extract the font family name of a css source.
When looking in debug mode, the font family name is present.
Also when i modify it by a SetFontFamily, in debug mode i can see the font-family value.
The GetFontFamiliy however does not return anything.
example code:
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());
}
}
Florian Rappl commented
I tried your code. It all works.
Maybe you just forgot to print it, e.g.:
foreach (ICssStyleRule rule in sheet.Rules)
{
Debug.Print(rule.CssText);
rule.Style.SetFontFamily("Verdana Bold");
Debug.Print("fontfamily {0}", rule.Style.GetFontFamily());
Debug.Print("fontSize {0}", rule.Style.GetFontSize());
}
ghislain borremans commented
Thank you, i am ashamed to have overlooked this.