2 ms·
In the past I found slight width differences between Windows and Mac that made a text take up a second line. Also, Google Fonts sometimes are updated and this c
by elondaits 4y ago
In the past I found slight width differences between Windows and Mac that made a text take up a second line. Also, Google Fonts sometimes are updated and this can cause letter widths to change.
… My recommendation is not to implement any design that can’t handle the difference. This will be more robust and better for you in the future (e.g. i18n, zoomed fonts for a11y, etc.). Whenever I worked implementing a design by someone else and there were overly strict assumptions about text size I let them know this was a problem and suggested an alternative.
The problem with your proposed solution is that if you’re using a webfont and measure before it loads, it won’t match the width once it’s replaced. Also, back in the day browsers came with a command to increase char size instead of zooming the whole page… I no don’t know if some still do, or if it happens under certain contexts (a11y extensions?) but that would also break.
- bufferoverflow 4y ago> My recommendation is not to implement any design that can’t handle the difference I'm not going to tell my employer I'm not implementing the design, when I can solve the problem, though in an ugly way. > if you’re using a webfont and measure before it loads That's not a problem. You can check if the font has loaded. https://stackoverflow.com/questions/5680013/how-to-be-notified-once-a-web-font-has-loaded https://stackoverflow.com/questions/5680013/how-to-be-notifi...
- onli 4y agoYou can not solve that problem. You can not even guarantee font size, it's useless to worry about a font's width. Part of your job as a web developer is to make your employer understand the realities of the web platform.
- dotancohen 4y ago> I'm not going to tell my employer I'm not implementing the design, when I can solve the problem, though in an ugly way. Though you might make the site pixel-perfect on _your_ device with _your_ fonts (all the combinatorics you can think of to test), you are likely breaking something for a screen reader, or user with 200% zoom, or a braille user, or a user with hardcoded fonts for disability reasons, or a user using a Windows phone browser, or a user on IE 8, or a user viewing the site through a corporate proxy that blocks some requests, or a user with CSS styles disabled, or a user who hasn't updated his Mac in six years, or a miriad of other cases. When you're reimplementing basing browser functionality, you're breaking your site for a lot of users.
- elondaits 4y ago> I'm not going to tell my employer I'm not implementing the design, when I can solve the problem, though in an ugly way. Sometimes graphic designers don't understand all the implications of their design choices in a dynamic medium. It is my job, as an experienced professional, to steer them away from the problems and do the best to capture their intention. Almost every time designers (who many times were my employers) understood the issue when pointed out and agreed with my solution. Their designs normally only consider the "ideal" cases (e.g. every title / item description fits nicely) because they have to make it look good for the client, but they know reality requires compromise.