Skip to content

Commit

Permalink
fix(fonts): ensure italic looks like italic in Safari (#10828)
Browse files Browse the repository at this point in the history
* Fix: Inter italic bug in Safari

Text marked with <em> element is not slanted. See issue: #7203

* fix(fonts): apply font-variation-settings to all italic elements

* fix(fonts): unset font-variation-settings where font-style is unset

* fix(fonts): set font-variation-settings: normal where font-style: normal

* revert: do not set font-variation-settings for mathml polyfill

---------

Co-authored-by: Claas Augner <[email protected]>
  • Loading branch information
ironnysh and caugner authored May 2, 2024
1 parent d316348 commit a06e429
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/src/about/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
font-family: var(--font-heading);
font-size: 1.313rem;
font-style: normal;
font-variation-settings: normal;
font-weight: normal;
line-height: 175%;
margin: 0;
Expand Down
1 change: 1 addition & 0 deletions client/src/curriculum/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
border-left: 2px solid var(--category-color);
display: inline-block;
font-style: normal;
font-variation-settings: normal;
font-weight: 600;
padding: 0.25rem 0.25rem 0.25rem 0.5rem;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
.bc-legend-tip {
font-size: var(--type-smaller-font-size);
font-style: italic;
font-variation-settings: "slnt" -10;
margin-bottom: 1rem;
margin-top: 0;
}
Expand Down
1 change: 1 addition & 0 deletions client/src/document/organisms/sidebar/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
border-left: 2px solid var(--category-color);
display: inline-block;
font-style: normal;
font-variation-settings: normal;
font-weight: 600;
hyphens: auto;
padding: 0.25rem;
Expand Down
1 change: 1 addition & 0 deletions client/src/homepage/contributor-spotlight/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
border: 0;
display: flex;
font-style: italic;
font-variation-settings: "slnt" -10;
margin: 0;
padding: 0;

Expand Down
1 change: 1 addition & 0 deletions client/src/minimal-prism.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ don't use any of that, we can safely ignore it.

.token.italic {
font-style: italic;
font-variation-settings: "slnt" -10;
}

.token.entity {
Expand Down
2 changes: 2 additions & 0 deletions client/src/plus/ai-help/landing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
em {
color: var(--category-color);
font-style: unset;
font-variation-settings: unset;
}
}

Expand Down Expand Up @@ -140,6 +141,7 @@

em {
font-style: unset;
font-variation-settings: unset;
font-weight: 600;
}
}
Expand Down
3 changes: 3 additions & 0 deletions client/src/plus/collections/collection.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
.breadcrumbs {
font-size: 0.6875rem;
font-style: italic;
font-variation-settings: "slnt" -10;
margin-top: -0.5rem;
}

Expand Down Expand Up @@ -98,6 +99,7 @@
font-size: 0.875rem;

font-style: italic;
font-variation-settings: "slnt" -10;
gap: 1rem;
padding: 1rem;

Expand All @@ -118,6 +120,7 @@
&.code {
font-family: var(--font-code);
font-style: normal;
font-variation-settings: normal;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions client/src/plus/common/login-banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
.plus-link {
color: var(--text-primary);
font-style: normal;
font-variation-settings: normal;
text-decoration: underline;
text-decoration-thickness: 0.15rem;
text-underline-offset: 0.1em;
Expand Down
1 change: 1 addition & 0 deletions client/src/plus/icon-card/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
display: flex;
font-size: 0.75rem;
font-style: italic;
font-variation-settings: "slnt" -10;
height: 3rem;
justify-content: center;
padding: 0.5rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
color: var(--text-primary);
font-size: 24px;
font-style: normal;
font-variation-settings: normal;
font-weight: 650;
line-height: 120%;
margin-bottom: 2rem;
Expand Down Expand Up @@ -103,6 +104,7 @@
.sub-price {
font-size: 36px;
font-style: normal;
font-variation-settings: normal;
font-weight: 650;
grid-column: 1/2;
justify-self: right;
Expand All @@ -117,6 +119,7 @@
.sub-length {
font-size: 0.8rem;
font-style: normal;
font-variation-settings: normal;
grid-column: 2/3;
justify-self: left;
line-height: 120%;
Expand Down Expand Up @@ -178,6 +181,7 @@
color: var(--text-invert);
font-size: 14px;
font-style: italic;
font-variation-settings: "slnt" -10;
margin-top: auto;
text-decoration: underline;

Expand Down
2 changes: 2 additions & 0 deletions client/src/plus/plus-docs/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.main-page-content {
em {
font-style: normal;
font-variation-settings: normal;
text-decoration: underline;
text-decoration-color: var(--text-link);
text-decoration-thickness: 0.15rem;
Expand Down Expand Up @@ -40,6 +41,7 @@

p {
font-style: italic;
font-variation-settings: "slnt" -10;
}
}

Expand Down
1 change: 1 addition & 0 deletions client/src/site-search/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.query-string {
font-style: italic;
font-variation-settings: "slnt" -10;
}

.site-search {
Expand Down
2 changes: 2 additions & 0 deletions client/src/site-search/search-results.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

.highlight {
font-style: italic;
font-variation-settings: "slnt" -10;
}

.nerd-data {
Expand Down Expand Up @@ -83,6 +84,7 @@
border-radius: var(--elem-radius);
color: var(--text-primary);
font-style: italic;
font-variation-settings: "slnt" -10;
}
}

Expand Down
1 change: 1 addition & 0 deletions client/src/ui/base/_prism.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

.token.italic {
font-style: italic;
font-variation-settings: "slnt" -10;
}

.token.entity {
Expand Down
5 changes: 5 additions & 0 deletions client/src/ui/base/_reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ picture {
max-width: 100%;
}

/* Fix Inter font bug: 'em' not slanted in Safari. See issue: https://github.com/mdn/yari/issues/7203 */
em {
font-variation-settings: "slnt" -10;
}

/* Inherit fonts for inputs and buttons */
input,
button,
Expand Down
1 change: 1 addition & 0 deletions client/src/ui/molecules/quote/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ blockquote.quote {
p {
display: flex;
font-style: italic;
font-variation-settings: "slnt" -10;

.icon {
margin-right: 1rem;
Expand Down
1 change: 1 addition & 0 deletions client/src/ui/molecules/search/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@

.nothing-found {
font-style: italic;
font-variation-settings: "slnt" -10;
}

.result-item {
Expand Down

0 comments on commit a06e429

Please sign in to comment.