I'm working on a website, on which fonts are much larger on Mac's Safari than on the other browsers,
The website is using the 'Open Sans' font from Google Fonts.
Example, this a CSS snippet for titles:
h2.protitlesnbm{
color: #404040;
font-size: 22px;
text-transform: uppercase;
float: none;
}
This shows up like below on Chrome, Firefox and IE:
But on Mac's Safari, it is shown like this:
Somehow, Safari seems to add 1px for all fonts.
Can anyone help me to fix this issue?
A web page in Safari using the 24-point minimum font size. If you change your mind later and want the smaller font sizes back, click “Safari” in the menu bar and navigate to Preferences > Advanced, and then uncheck the “Never Use Font Sizes Smaller Than” option. Alternately, you can simply select a smaller font size from the menu.
Safari will remember your settings until you clear your History. Or you can go to the View menu and hold down the Option key while you select Make Text Bigger or Make Text Smaller. You can increase or decrease the zoom level – both text and images – of pages that you view in Safari on macOS Sierra.
To get started, open the Safari browser on your Mac. Click “Safari” in the top menu bar and choose “Preferences” from the drop-down menu. In the “Advanced” tab, locate the “Accessibility” section and click the check mark next to “Never Use Font Sizes Smaller Than.” In the drop-down menu, choose between “14,” “18,” or “24” -point font sizes.
You can increase or decrease the zoom level – both text and images – of pages that you view in Safari on macOS Sierra. Safari will remember your settings until you clear your History. Or go to the View menu and select Zoom in or Zoom out. If you clear your Safari history, websites will go back to their default font size or zoom level.
You could try using
-webkit-font-smoothing: subpixel-antialiased;
or
-webkit-font-smoothing: antialiased;
You can always use JavaScript check if the browser is Safari, and if it is, just minimize the font sizes by 1px
. I know that this is not a conventional way of doing things, but as long as it works:
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) {
return p.toString() === "[object SafariRemoteNotification]";
})(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
This method was taken from Javascript - How To Detect Browsers
And its explanation:
Safari: A unique naming pattern in its naming of constructors. This is the least durable method of all listed properties and guess what? In Safari 9.1.3 it was fixed. So we are checking against SafariRemoteNotification
, which was introduced after version 7.1, to cover all Safaris from 3.0 and upwards.
In order to change font sizes, there is a deprecated method that could still work:
document.body.fontSize(-1);
If not, try CSS Relative Font Sizes:
document.body.style.fontSize = ""; //Either Enter Percentages (90%) or EM
//EM Will Automatically Change Font-Size According To Browser
//%-ages Will Change Values Through Math (110% of 16px)
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With