Skip to content

Conversation

@Mrazator
Copy link
Member

@Mrazator Mrazator commented Jul 26, 2024

Adds the possibility to specify an array of base URLs in EXCALIDRAW_ASSET_PATH, so that we could register font faces for our bundled fonts with multiple fallbacks, in case of unreachable resources due to:

  • network restrictions (vpns, corporate policies, firewalls etc.)
  • ad blocker Fonts no longer load #8290 (only solves first-party if an appropriate filter is set to allow such fonts)
  • offline mode
  • unknowns

Excalidraw-app now has three font URLs for our bundled fonts:

  • DO CDN
  • Root domain excalidraw.com [fallback]
  • UNPKG CDN [fallback]

Fonts are fetched in the order specified above (with automatic fallbacks), for both:

  1. window.document.fonts.load API
    • out-of-the-box fallbacks due to multiple sources specified as part of the FontFace object in a CSS familiar @font-face#source manner
  2. fetch for SVG fonts inlining
    • added custom fallback mechanism
    • in case none of the URLs is reached (i.e. when working offline), we will just inline the last specified URL (unpkg for our bundled fonts or whatever URL we have for other fonts)

Additional improvements:

  • setting CORS for excalidraw.com as the only origin for all the new fonts
  • treating DO CDN as SSOT with a build-step

@vercel
Copy link

vercel bot commented Jul 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
excalidraw ✅ Ready (Inspect) Visit Preview Jul 30, 2024 8:15am
excalidraw-package-example ✅ Ready (Inspect) Visit Preview Jul 30, 2024 8:15am
excalidraw-package-example-with-nextjs ✅ Ready (Inspect) Visit Preview Jul 30, 2024 8:15am
1 Skipped Deployment
Name Status Preview Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 8:15am

@github-actions
Copy link

github-actions bot commented Jul 26, 2024

Coverage Report

Status Category Percentage Covered / Total
🔴 Lines 65.82% (🎯 70%) 54562 / 82890
🔴 Statements 65.82% (🎯 70%) 54562 / 82890
🔴 Functions 67.24% (🎯 68%) 1628 / 2421
🟢 Branches 80.6% (🎯 70%) 6604 / 8193
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/excalidraw/components/FontPicker/FontPickerList.tsx 18.28% 100% 100% 18.28% 48-264, 266-267
packages/excalidraw/fonts/ExcalidrawFont.ts 75.47% 61.9% 100% 75.47% 11, 48-50, 68-88, 114-118, 132-133, 137-138, 148-152
packages/excalidraw/fonts/index.ts 82.73% 86.36% 91.66% 82.73% 57-58, 66-67, 91-96, 101-119, 134-156, 288
packages/excalidraw/fonts/metadata.ts 100% 100% 100% 100%
packages/excalidraw/scene/export.ts 86.82% 76.27% 77.77% 86.82% 53-78, 98-99, 108, 160-161, 185-189, 322-323, 374, 380-385, 388-390, 444-448, 469-478
scripts/woff2/woff2-vite-plugins.js 0% 0% 0% 0% 1-132
Generated in workflow #2906

@dwelle
Copy link
Member

dwelle commented Jul 29, 2024

👍

@zsviczian
Copy link
Collaborator

If Helvetica is used in the scene I get this error
image

@Mrazator
Copy link
Member Author

It's probably because I've let it register Helvetica font face (line changed below), since I did not observe any impact. Is this thrown for some reason just in Electron? I cannot repro on the PR deployment.

https://github.com/excalidraw/excalidraw/pull/8286/files#diff-f5ccf5aca114071dcadadf871453d462f106971c70d3face46b3a855664e13bfL127

@Mrazator
Copy link
Member Author

@zsviczian could you perhaps confirm #8303 solves this?

@zsviczian
Copy link
Collaborator

I confirm #8303 solves the issue.

The screenshot above is from Excalidraw web: https://excalidraw-7vmwury8n-excalidraw.vercel.app/#json=t11M0HM6UHAPuCgd97kcC,BjJyC9R4u_fj73hS_U5QJQ

I used the preview from the most recently merged PR: #8302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants