Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Drawing.FontFamily.GenericSansSerif - What affects the underlying font it selects?

I am reviewing image generation code that uses FontFamily.GenericSansSerif from the system.drawing namespace. I typically see code like that at the tail end of xhtml/css font selection statements as a fall back / last resort if a more desireable (specific) font is not discovered. In the .net framework, what are the environmental parameters that will affect which font this actually selects? Is there some sort of chart out there that states how the .net framework selects the font when you specify GenericSansSerif?

like image 200
user1082202 Avatar asked Oct 10 '22 07:10

user1082202


1 Answers

In terms of GenericSansSerif, it will try to return the family from the following fonts by name "Microsoft San Serif", "Arial", "Tahoma" in that order. If none of those fonts are installed, it appears it picks the family of the first installed font, ordered by name.

In terms of GenericSerif, it tries to return the family from the font named "Times New Roman". If that isn't installed the same rules as GenericSanSerif are used. i.e. if you remove the "Times New Roman" font, it's the same as calling GenericSanSerif.

like image 187
Peter Ritchie Avatar answered Oct 13 '22 10:10

Peter Ritchie