Repository navigation
fix(website): re-anchor PP Formula so its caps sit where they are centred #17843
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
Merged
+190
−52
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
76c406b
fix(website): re-anchor PP Formula so its caps sit where they are cen…
mariana953 de578ae
fix(website): drop the nudges the old font metrics needed
mariana953 d9930de
[automated] Update website screenshot expectations
invalid-email-address 044f8b0
[automated] Apply ESLint and Oxfmt fixes
actions-user ff4e913
refactor(website): retire ppformula-text-center
mariana953 0c583f7
[automated] Update website screenshot expectations
invalid-email-address 62fbf9a
fix(website): give each PP Formula family its own metric overrides
mariana953 8431cb2
[automated] Update website screenshot expectations
invalid-email-address 53b624c
fix(website): preserve PP Formula centring in Safari
benjcooley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import { test } from './fixtures/blockExternalMedia' | ||
|
|
||
| // Rows that put an icon, a count or a control beside an uppercase word centre | ||
| // the boxes, not the ink. So a face whose caps sit high inside their line box | ||
| // misaligns every one of those rows at once, and no component can fix it. The | ||
| // faces are measured from their own @font-face rules rather than from the page, | ||
| // because `font-display: optional` leaves the weights this page never renders | ||
| // unusable for measurement. | ||
| const SIZE = 1000 | ||
|
|
||
| test('every PP Formula face centres its caps inside the line box', async ({ | ||
| page | ||
| }) => { | ||
| await page.goto('/') | ||
| await expect(page.locator('html')).not.toHaveClass( | ||
| /(?:^|\s)ppformula-metric-fallback(?:\s|$)/ | ||
| ) | ||
|
|
||
| const faces = await page.evaluate(async (size) => { | ||
| const rulesOf = (sheet: CSSStyleSheet) => { | ||
| try { | ||
| return [...sheet.cssRules] | ||
| } catch { | ||
| return [] | ||
| } | ||
| } | ||
|
|
||
| const declarations = [...document.styleSheets] | ||
| .flatMap(rulesOf) | ||
| .filter( | ||
| (rule): rule is CSSFontFaceRule => rule instanceof CSSFontFaceRule | ||
| ) | ||
| .map((rule) => ({ | ||
| family: rule.style | ||
| .getPropertyValue('font-family') | ||
| .replaceAll(/['"]/g, ''), | ||
| weight: rule.style.getPropertyValue('font-weight'), | ||
| source: rule.style.getPropertyValue('src'), | ||
| ascentOverride: rule.style.getPropertyValue('ascent-override'), | ||
| descentOverride: rule.style.getPropertyValue('descent-override') | ||
| })) | ||
| .filter((declaration) => declaration.family.startsWith('PP Formula')) | ||
|
|
||
| return Promise.all( | ||
| declarations.map(async (declaration, index) => { | ||
| const url = /url\(["']?([^"')]+)/.exec(declaration.source)?.[1] | ||
| if (!url) { | ||
| throw new Error(`no source for ${declaration.family}`) | ||
| } | ||
|
|
||
| const probe = `probe-${index}` | ||
| document.fonts.add( | ||
| await new FontFace(probe, `url("${url}")`, { | ||
| ascentOverride: declaration.ascentOverride, | ||
| descentOverride: declaration.descentOverride | ||
| }).load() | ||
| ) | ||
|
|
||
| const context = document.createElement('canvas').getContext('2d') | ||
| if (!context) throw new Error('no canvas context') | ||
| context.font = `${size}px "${probe}"` | ||
| const caps = context.measureText('H') | ||
| return { | ||
| family: declaration.family, | ||
| name: `${declaration.family} ${declaration.weight}`, | ||
| ascent: caps.fontBoundingBoxAscent, | ||
| descent: caps.fontBoundingBoxDescent, | ||
| capHeight: caps.actualBoundingBoxAscent | ||
| } | ||
| }) | ||
| ) | ||
| }, SIZE) | ||
|
|
||
| expect([...new Set(faces.map((face) => face.family))].sort()).toEqual([ | ||
| 'PP Formula', | ||
| 'PP Formula Narrow' | ||
| ]) | ||
|
|
||
| for (const face of faces) { | ||
| const aboveTheCaps = face.ascent - face.capHeight | ||
| expect( | ||
| Math.abs(aboveTheCaps - face.descent), | ||
| face.name | ||
| ).toBeLessThanOrEqual(SIZE / 100) | ||
| } | ||
| }) | ||
|
|
||
| test('keeps the component fallback when metric overrides are unsupported', async ({ | ||
| page | ||
| }) => { | ||
| await page.addInitScript(() => { | ||
| Object.defineProperty(FontFace.prototype, 'ascentOverride', { | ||
| configurable: true, | ||
| get: () => '' | ||
| }) | ||
| }) | ||
| await page.goto('/') | ||
|
|
||
| await expect(page.locator('html')).toHaveClass( | ||
| /(?:^|\s)ppformula-metric-fallback(?:\s|$)/ | ||
| ) | ||
| const marker = page.locator('.ppformula-text-center').first() | ||
| await expect(marker).toBeVisible() | ||
| expect( | ||
| await marker.evaluate((element) => getComputedStyle(element).top) | ||
| ).not.toBe('auto') | ||
| }) | ||
Binary file modified
BIN
+9 Bytes
(100%)
...ebsite/e2e/visual-responsive.spec.ts-snapshots/about-hero-1-sm-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-59 Bytes
(100%)
...ebsite/e2e/visual-responsive.spec.ts-snapshots/about-hero-2-md-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...site/e2e/visual-responsive.spec.ts-snapshots/contact-form-1-sm-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...site/e2e/visual-responsive.spec.ts-snapshots/contact-form-2-md-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-14 Bytes
(100%)
...te/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-1-sm-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+655 Bytes
(100%)
...te/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-2-md-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+506 Bytes
(100%)
...te/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-3-lg-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+727 Bytes
(100%)
...te/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-4-xl-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4 Bytes
(100%)
...site/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-1-sm-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3 Bytes
(100%)
...site/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-2-md-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4 Bytes
(100%)
.../e2e/visual-responsive.spec.ts-snapshots/home-get-started-1-sm-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6 Bytes
(100%)
.../e2e/visual-responsive.spec.ts-snapshots/home-get-started-2-md-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+154 Bytes
(100%)
.../e2e/visual-responsive.spec.ts-snapshots/home-get-started-3-lg-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+223 Bytes
(100%)
.../e2e/visual-responsive.spec.ts-snapshots/home-get-started-4-xl-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+225 Bytes
(100%)
...2e/visual-responsive.spec.ts-snapshots/home-product-cards-1-sm-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+233 Bytes
(100%)
...2e/visual-responsive.spec.ts-snapshots/home-product-cards-2-md-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+134 Bytes
(100%)
...2e/visual-responsive.spec.ts-snapshots/home-product-cards-3-lg-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+150 Bytes
(100%)
...2e/visual-responsive.spec.ts-snapshots/home-product-cards-4-xl-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-17 Bytes
(100%)
...bsite/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-1-sm-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+148 Bytes
(100%)
...bsite/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-2-md-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+278 Bytes
(100%)
...bsite/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-3-lg-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+265 Bytes
(100%)
...bsite/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-4-xl-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2 Bytes
(100%)
...ite/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-1-sm-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-17 Bytes
(100%)
...ite/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-2-md-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-14 Bytes
(100%)
...ite/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-3-lg-visual-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+23 Bytes
(100%)
...ite/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-4-xl-visual-linux.png
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.