I know you can get the font-family
value by window.getComputedStyle()
but that's not always exactly the font that is used by a browser to render. For example, if the given text contains the (multi-lingual) text the font family does not carry, the browser renders the text partially with the system font.
If you take a look at the built-in web developer tool, either in Chrome or Firefox, they both have a little area to display (Rendered Fonts
pane on Chrome or Fonts
tab on Firefox) the exact fonts that are used. For the Firefox, I guess this code is used and it seems to be calling the internal API.
I'm looking for any DOM-compliant (or vendor-specific) way to get the exact font from the JavaScript land or else. If that means writing a browser extension/add-on to provide API/inject info/whatever for the in-page code to access, that's the worst case, but acceptable.