Search code examples
javascriptdomfontscleartypesmoothing

Detecting the change of the font smoothing setting in Javascript


I have a page that uses @font-face and I am playing with the JavaScript code that conditionally sets the text in this typeface depending on whether the font smoothing is enabled. Detection is done along these lines, but a bit more elaborate to allow telling ClearType and Standard smoothing apart.

In any case the smoothing check is done on page load, and I want to understand if there is a way to capture the event of the smoothing preference changing once the page is loaded.

Thanks


Solution

  • I don't see a way to do this that works without a timeout to do the check you show every x seconds - which of course is sub-optimal from a resource point of view.

    I don't think there is any JavaScript event to hook into. The size of an element that contains text might change if the smoothing method changes, but then it also might not.