Hacker News new | past | comments | ask | show | jobs | submit login

How does a system know wether a font is sans-serif or not?



It's a browser setting. For example, I'm using Firefox 41 on Windows 7 and in Options->Content->Fonts&Colors/Advanced... it has "Times New Roman", "Arial", and "Courier New" as the defaults for Serif, Sans-serif, and Monospace respectively.

In Chrome, it's under Settings->+Show advanced settings->Web content/Customize fonts... (Times New Roman, Arial, Consolas on mine.)

In IE 11 under Tools (gear icon)->General->Appearance/Fonts it has "Webpage font" and "Plain text font" (Times New Roman and Courier New on mine). It's weird that they don't let you pick the default sans-serif font.


The 'sans-serif' font is an alias for the default sans-serif font, which is simply a system setting just like the default browser or the default whatever. Therefore the system doesn't need to know which fonts are sans-serif and which aren't.


On Windows you can query for information about any font using the Windows API. This call allows you to enumerate fonts based upon their name, etc:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd1...

and the callback function used with it will get you this structure:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd1...

and the lfPitchAndFamily member will tell you what type of font it is.


That's a setting in the browser, not the system.


TTF / OTF fonts have quite a bit of meta data in them. I don't know the details but there are some flags regarding font family.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: