chengyin / WhatFont-Bookmarklet

The core of WhatFont Tool
http://chengyinliu.com/whatfont.html
University of Illinois/NCSA Open Source License
488 stars 74 forks source link

Fix: correctly identifying when the default font is used #2

Closed bennettmcelwee closed 13 years ago

bennettmcelwee commented 13 years ago

WhatFont is awesome -- I have been looking for something like this for ages. Here's a patch to fix an issue I have found.

If the font family contains only fonts that aren't installed, then WhatFont reports that the rendered font is the first one in the list. It should report that the default font is used. I made a test page at http://www.thunderguy.com/public/whatfont-test.html that shows the issue.

My change does the following: If a single font matches the font stack, then check whether the rendered font is really installed. This is necessary because if none of the fonts in the stack are installed then the rendered font will always be the browser's default font, so it will match the font stack even though the font is not installed.

chengyin commented 13 years ago

Thank you very much Bennett, The test is comprehensive and I could see what the problem is. I will merge it tomorrow (GMT -6) since now I'm just busy with a final paper. Detecting fallback has always been a problem for us. There is no universal, easy workaround to it. Your code will be a great help.

chengyin commented 13 years ago

Merged.