Skip to content
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

market-sans: fix font spacing issues across components #2583

Open
ArtBlue opened this issue Feb 25, 2025 · 2 comments
Open

market-sans: fix font spacing issues across components #2583

ArtBlue opened this issue Feb 25, 2025 · 2 comments
Assignees
Milestone

Comments

@ArtBlue
Copy link
Contributor

ArtBlue commented Feb 25, 2025

After the recent implementation of Market Sans v2, there was some fallout of vertical font spacing across numerous components. These tend to be related to line-height' and vertical margin/padding`.

It looks like in most (all?) places line-height is not explicitly set, possibly because with the additional vertical spacing of the old v1 font, it looked visually consistent with the specs. However, since Market Sans v2 has equal vertical spacing within the glyphs, visually there is no more "assumed" line-height. This means that a lot of layouts will no longer look visually acceptable.

Without an explicitly set line-height, the value of normal is used, which defaults to what normal is set to in each browser's user agent. In Chrome, normal is ~ 1.2em, but other browsers may have other defaults.

Explicit line-height Seems Necessary

Here's one example of a component with Market Sans v2 without line-height (normal) vs v2 with the explicit line-height set.

Market Sans v2 without line-height (normal)

Image

Market Sans v2 with the explicit line-height set

Image

Relative line-height Seems Necessary

Currently, in Skin we have line height tokens in px and in Playbook defined in rem values. Neither seem scalable since px is an absolute value and rem refers to an absolute value of the user agent style on body.

When the font-size is set to something larger, in this case, 200%, the way things are set currently would create badly spaced text. It would create roughly the opposite problem where the default normal line-height would yield something acceptable, but the explicitly set absolute line-height would be problematic.

Implicit normal line-height

Image

Explicit line-height: 14px (per Playbook)

Image

Using em Seems Necessary

By using em as the relative line-height of a font, ties the line-height with the relative font-size creating a fully scalable solution. Since our baseline line height is 20px and our font size is 14px, we can get the line height by 20/14 = line-height: 1.4285714286em, which looks rather good automatically on smaller fonts and larger.

Image

Future Flexible Responsive Font Scalability

Using em also provides more flexibility for creating fine-grained responsive line heights based on responsive fonts. This means that depending on the breakpoint, we would be able to create different font-size/line-height scaling that does not have to retain the same em ratio as 1.4285714286.

@github-project-automation github-project-automation bot moved this to Todo in eBayUI Feb 25, 2025
@ArtBlue ArtBlue self-assigned this Feb 25, 2025
@ArtBlue ArtBlue added this to the 19.2.0 milestone Feb 25, 2025
@ArtBlue
Copy link
Contributor Author

ArtBlue commented Feb 25, 2025

Blocking this until we have a scalable path forward (meeting on this soon) for using relative spacing tokens. We may also have to create separate line-height tokens.

@ArtBlue
Copy link
Contributor Author

ArtBlue commented Feb 25, 2025

The most apparent fixes can be seen in the diffs from Percy build 293.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant