Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * A small utility to fix the letter kerning on macOS Chrome and Firefox when using the system font
- * (San Francisco). It is now fixed in the text rendering engine in FF 58 and Chrome 64.
- */
- ;(() => {
- const ua = navigator.userAgent
- // macOS 10.11 (El Capitan) came with San Francisco. Previous versions used Helvetica
- const isRelevantMacOS =
- /Mac/.test(navigator.platform) &&
- (ua.match(/OS X 10[._](\d{1,2})/) || [])[1] >= 11
- // Chrome v64 and FF v58 fix the issue
- const isAffectedBrowser =
- (ua.match(/Chrome\/(\d+)\./) || [])[1] < 64 ||
- (ua.match(/Firefox\/(\d+)\./) || [])[1] < 58
- if (isRelevantMacOS && isAffectedBrowser) {
- document.documentElement.style.letterSpacing = '-0.3px'
- for (const el of document.all) {
- const fontSize = parseFloat(getComputedStyle(el).fontSize)
- if (fontSize >= 20) el.style.letterSpacing = '0.3px'
- }
- }
- })()
Add Comment
Please, Sign In to add comment