-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Font Library: Fix font preview vertical alignment and respect reduce motion preference #58451
Conversation
Size Change: +83 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this enhancement.
I tested the changes, and they look good, improving the vertical alignment of the font previews. I also left a small comment about the convenience of adding the transition to the image previews. However, that can be added in a follow-up because that addition was not the original purpose of this PR, so I'm approving it.
flex-shrink: 0; | ||
font-size: 18px; | ||
transition: opacity 0.3s ease-in-out; | ||
@include reduce-motion("transition"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need to include the transition into the demo-image class, too, to apply the same transition when the font has and lacks an image preview.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep consistency would be nice. Unrelated to the scope of this PR though.
32af97a
to
7c12155
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core SVNIf you're a Core Committer, use this list when committing to
GitHub Merge commitsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Fixes #58439
What?
Why?
How?
display: block
on the preview image to remove native descender space.reduce-motion
scss mixin.Note:
A pixel-perfect vertical alignment isn't really possible because the font preview image isn't consistent. even after improving the CSS and removing the native image descender space, the actual font preview within the image has a different size and, more importantly, it may be not vertically centered within the image. A couple images to better illustrate:
Even though the two images have the same height, the actual preview is placed differently within the image 'canvas', which is actually the viewport of the SVG image. See for example https://s.w.org/images/fonts/17.6/previews/aldrich/aldrich.svg
Maybe, the SVG metrics could be improved but this is out of the scope of this PR.
Also, trying to adjust the image size to a 'magic number' doesn't make much sense as the font previews will render fonts with different metrics anyways. See for example the screenshot below: all the font preview images do have the same height but the actual visible height of the previewed font is always different because the font metrics are different:
Testing Instructions
Before:
After:
Testing Instructions for Keyboard
Screenshots or screencast