News for hackers. Stuff that matters.
Re:System Font Stack by kevin_thibedeau on Saturday May 28, 2022 @05:18PM (#31543961)
Stop trying to enforce pixel perfect control. This is equivalent to old school Win32, VB6 GUIs with hardcoded pixel positioning of all controls designed to work on a 640x480 screen. Web technologies are designed to accommodate flexible layout. Accepting font rendering differences is part of that.
Re:System Font Stack by jsjohnst on Saturday May 28, 2022 @05:25PM (#31544006)
> Stop trying to enforce pixel perfect control.

Not the least of which because of text size zooming for accessibility. The web is not print!

Re:System Font Stack by tshaddox on Saturday May 28, 2022 @07:29PM (#31544788)
It’s not as petty as you make it sound. You don’t have to pixel peep to spot the differences. Switching to a different font can break basic stuff like text in a button being vertically centered, which can look broken or amateurish to normal site visitors.
Re:System Font Stack by blep_ on Saturday May 28, 2022 @09:09PM (#31545287)
Only if you're doing centering by hardcoded pixel offsets. Stop doing that.
Re:System Font Stack by thundermuffin on Saturday May 28, 2022 @09:30PM (#31545406)
You can still have this problem apply even if you are using flex and aligning items to the center.

If a font has some weird characteristic about it (for instance, the font itself has built in whitespace at the bottom or top of letters), you will not be able to center it vertically no matter what CSS magic you try to do except for doing some kind of translation on it; that translation doesn't have to be pixel-based either, but it will 100% have to happen until hopefully when the leading-trim property that saadat mentioned is widely available.

Re:System Font Stack by bufferoverflow on Saturday May 28, 2022 @11:14PM (#31546006)
I don't think you understand the problem.

Here, try to align these without changing individual p's CSS:

https://jsfiddle.net/a3q87ucs/

You see how the second text is lower. That has to do with internal font settings that CSS has no control of. Not yet at least.

Re:System Font Stack by Hello71 on Saturday May 28, 2022 @11:48PM (#31546209)
this only looks terrible because you've forced a specific height in rem. https://jsfiddle.net/vbd3fok5/ looks fine to me. there is some extra space, but I assume that if the font designer added extra space on top of the text, they did it on purpose. if you insist on ignoring that, https://jsfiddle.net/qpb0d45n/ makes the text "visually continuous", at least for a non-Korean reader like myself. I would speculate that a Korean user might look at this and ask why the site designer ignored their font's preference for space above the text.
Re:System Font Stack by bufferoverflow on Sunday May 29, 2022 @12:41AM (#31546451)
> https://jsfiddle.net/vbd3fok5/ looks fine to me

No, it doesn't. Here's the screenshot with a line I added:

https://i.imgur.com/6pLiasn.png

> if you insist on ignoring that, https://jsfiddle.net/qpb0d45n/

And now you have blocks of different heights. Which cause other issues.

Re:System Font Stack by bufferoverflow on Saturday May 28, 2022 @05:23PM (#31543990)
It's not even about being pixel perfect. I can't vertically align text with an image. If I align it with one font, the other one is misaligned. I need something like media query for fonts.
Re:System Font Stack by kevin_thibedeau on Saturday May 28, 2022 @05:38PM (#31544103)
You just need flexbox or construct an SVG. Let the divs size themselves to the font and allow the browser to put them where they're told to go.
Re:System Font Stack by bufferoverflow on Saturday May 28, 2022 @07:20PM (#31544723)
I don't see how flexbox solves this problem. Just because you vertically center text, doesn't mean that the visible text is actually centered. It depends on the font.
Re:System Font Stack by bufferoverflow on Saturday May 28, 2022 @11:23PM (#31546075)
Re:System Font Stack by saadat on Saturday May 28, 2022 @09:03PM (#31545252)
The CSS property leading-trim [1][2] is designed to solve this alignment problem (among others). However, it's still at the Working Draft stage, so it's going to take a while before browsers start supporting it.

[1]: https://www.w3.org/TR/css-inline-3/#leading-trim [2]: https://medium.com/microsoft-design/leading-trim-the-future-...