* feat: Extended fonts support
* Refactor fonts + improve picker
* Move font logic into AppFonts
* Consolidate the font metrics fallback
* chore: refresh history snapshot after rebase onto master
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* feat(editor): font provider search and hover-preview revert in the font picker
- optional `FontProvider.search` hook: matches and suggestions shared fairly
across providers, "+N more" footer, "Did you mean" suggestions
- font preview text helpers
- revert a hover preview when the picker closes from outside (canvas click,
compact mode); restore by cached id rather than selection
* fix(editor): font picker scene groups, search announcements and preview revert
- keep a hover preview out of the "In this scene" group while fonts register
- announce a searched family only from the search rows, not when it's listed
already
- leave elements deleted meanwhile deleted when reverting a hover preview
- keep the focus in the picker after a selection that keeps it open while
editing text
- skip the scene font reflow once the editor unmounted
- memoize the top picks, so hovering doesn't re-run their effects
* fix(editor): load fonts even when `document.fonts.check()` passes
Chrome's `check()` reports any family whose name matches an installed
system font as loaded, even while its web faces are unloaded (e.g. anyone
with Excalifont installed). Scene fonts then never got loaded explicitly,
so the first paint used the fallback font, and a font change measured text
with the fallback and never repaired it once the faces arrived (a wrong
bbox for good).
- scene font loading always calls `load()`, which settles right away
(~0.1ms) when the faces are loaded already
- font family changes still redraw synchronously when `check()` passes,
but load the faces regardless and re-measure when the load brought in
faces that weren't loaded at measure time
Claude Opus 5.5 (xhigh)
* feat(fonts): custom fonts rework after the design review
Format and loading:
- a custom font id is `<provider>:<family>`. The provider key is `google`
or a reverse-DNS name (`isValidFontProviderKey`,
`GOOGLE_FONT_PROVIDER_KEY`)
- a custom font is registered under a generated CSS name
(`xf-<slug>-<hash>`), so its id never reaches CSS
- restore keeps font families it doesn't know, instead of resetting them
- loading a font no longer rewrites elements. It invalidates caches, and
only text measured before the font's metrics arrived gets repaired
- under collab, a scene with custom fonts no longer runs a font pass every
second: only a family nothing of which has arrived yet schedules one
- a StrictMode remount no longer leaves the editor on a `Fonts` instance
without its undo-safety hooks
Exports:
- `registerFontResolvers(resolvers)` registers resolvers for every image
export of a page or worker, also exported from `@excalidraw/utils`. A
per-call `config.fontResolvers` wins for the providers it names
- an export warns once per family it has no resolver for
Google Fonts, as a new entry `@excalidraw/excalidraw/fonts/google`:
- a catalog of the families with their vertical metrics, generated by
`yarn gen:google-fonts` and append-only
- `createGoogleFontResolver()`: resolves a family through `css2`, retries
transient failures, shares in-flight requests, and takes a `fetch` for
servers
- `searchGoogleFonts`, `getGoogleFontPreviewText` and a list of default
picks
Font picker and provider API:
- `availableFonts` and `search()` take `{ id, label }` entries besides
plain names (`ProvidedFont`); search results are `{ kind, fonts }`
- typing a name no longer resolves it as a font id: the picker only offers
what a provider lists or finds
- `fontPickerTip` replaces the picker's tip, i.e. to point at where a host
manages its fonts
- `onNewFontUsed` is gone from `FontProvider`
Claude Opus 5.5 and Claude Fable 5.2 (effort 40 to 80)
* feat(fonts): Google catalog of text fonts only, with a browse list
- catalog: 1,895 families. Out are the 33 non-text families (symbols,
emoji, knitting charts, SignWriting), Libertinus Math, which draws
relation signs over the preceding letter, and the 28 families which
take over 10 ms to draw a line of text in Chromium (median: 1.5 ms).
Added since the first run: Agrave Pro, Firjar; kept: STIX Two Math and
Noto Sans Math
- generator: the exclusion rules above, by classification and by name
with the reason; a family new to Google's list whose font file looks
slow to draw (huge outlines, colour layers) is held back until it's
measured, `--allow` lets it in; output in prettier's format
- `loadMoreGoogleFonts` pages through the `GOOGLE_FONT_BROWSE_LIMIT` (100)
most popular families, for a provider's `loadMore`; search still covers
the whole catalog
- default picks are provisional, to be hand-picked before release
Claude Fable 5.2 (effort 30 to 80)
* feat(editor): font picker favorites, "Browse more fonts", faster list
- `fontFavorites={{ fonts, onChange }}`: the user's favorite fonts, kept
by the host. A font is dragged onto a zone over the search to add it,
and a favorite onto the same zone to remove it. Without the prop the
picker has no favorites
- list order: fonts in the scene, favorites, then the available ones with
the editor's own fonts first. A font only counts as in the scene once an
element uses it
- `FontProvider.loadMore({ offset, limit, signal })`: a "Browse more
fonts" row which pages through the provider's further fonts, and loads
on by itself once clicked. What it loaded stays for when the picker
reopens, and a font picked from it keeps its place. At the end, a
provider with `search` gets a "Use search for more" note
- rows are memoized and skip rendering while off screen
(`content-visibility`), so a list of a few hundred fonts stays
responsive
Claude Fable 5.2 (effort 30 to 80)
* feat(app): resolve Google fonts on excalidraw.com, without the picker
What the app ships of the custom fonts: the package's Google Fonts
resolver alone. Nothing changes in the font picker, but a text in a Google
font - from a file, a shared link or a paste from another app such as
Excalidraw+ - renders in that font, and is listed among the scene's fonts.
- `fontProviders` with the resolver and no fonts on offer, no search
- the resolver is registered for image exports made outside of the editor
(the frame snapshot for diagram-to-code), which otherwise draw such text
in the fallback font
Claude Fable 5.2 (effort 30)
* fix(fonts): font repairs and retries found in review
- A font repair no longer lands during a text edit, where it took what
had been typed out of undo's reach. It waits for the edit to be
submitted, as it does for a drag.
- One loaded face no longer counts as the font being in for text which
needs another `unicode-range` subset: such text is measured again once
its subset arrives.
- A font file which failed to download is retried when the family is
asked for again, i.e. by picking the font.
- New provider callbacks under the same key are used without rebuilding
the `Fonts` instance.
- SVG export keeps a face whose `unicodeRange` is lowercase or uses
wildcards.
Claude Fable 5.2, effort 80
* feat(fonts): drop 43 Google families the editor can't lay out reliably
The catalog goes from 1,895 to 1,852 families. Nothing has shipped, so
the entries are removed rather than kept.
- 12 whose text jumps when the text editor opens, as browsers don't
agree on their vertical metrics, or whose line height is unusable.
- 29 whose lines the canvas and the text editor lay out at different
widths in Chrome or Safari, with no setting to bring them together.
- 2 which don't draw as text fonts (Vibur, Libertinus Keyboard).
The generator names each with what was measured, and holds back a new
family whose font file shows the first kind. Provisional: the catalog
gets another pass before release.
Claude Fable 5.2, effort 80
* fix(editor): kern text the same on canvas, in the text editor and in SVG
Left on the default (`font-kerning: auto`), browsers skip the kerning
between a letter and a space in places: Chrome on canvas but not in the
DOM, Firefox everywhere. So a line was measured and drawn wider on canvas
than Chrome's text editor laid it out (6 px for "A V A T A R" in
Liberation Sans at 20 px), and wider in Firefox than in Chrome's editor.
Kerning is now `normal` wherever text is measured or drawn: the measuring
canvas, the element canvas, the text editor and exported SVG.
Claude Fable 5.2, effort 30
* fix(editor): wrap text and place the caret by the same kerning
Review follow-ups to the kerning change:
- Wrapping added up the widths of single-character tokens (and of the
characters of a word too long for a line) one by one, which leaves out
the kerning between them. "A V A T A R A V A T A R" in a 105 px box
wrapped to three lines where the text editor shows two. Before a line
breaks on such a sum, it's now measured as a whole.
- The hidden element which finds the caret for a click was still kerned
with `auto`, so in Firefox the caret could land a character early.
Claude Fable 5.2, effort 80
* fix(editor): shape canvas text as a whole line, as the text editor does
Chrome's canvas shapes a line word by word by default. A font which picks
a letter's shape by what's around it, across spaces too (Caveat, Itim,
Sriracha), then measures and draws several px a line wider or narrower on
canvas than in the text editor, which the DOM lays out as a whole.
`textRendering = "optimizeLegibility"` has the canvas shape the whole
line. It changes nothing for a font without such rules, the built-in ones
included, and is set on the canvas only: the DOM, Firefox's canvas and
skia-canvas shape whole lines as it is.
Claude Fable 5.2, effort 80
* fix(editor): leave font-kerning on the browser's default
Kerning was set to `normal` wherever text is measured or drawn, so that
Firefox would kern a letter against a space as Chrome does. Set on the text,
it also has Firefox close up Japanese and Chinese: full-width punctuation
and kana lose their side space, by 7 to 22% on a line, in 17 Google
families and in system fonts such as Yu Gothic and Hiragino.
`font-kerning` is no longer set on the canvas, in the text editor or in
exported SVG. `textRendering = "optimizeLegibility"` stays on the canvas,
which is what brings Chrome's canvas to its text editor, the kerning next to
a space included.
The price: Firefox doesn't kern a letter against a space, so a line with
such pairs is a little wider there than in Chrome ("A V A T A R To WA" in
Liberation Sans at 20 px: 285 px against 273).
Claude Fable 5.2, effort 30
* feat(fonts): offer 9 Google families, not Google's whole list
The catalog held every family that passed the generator's checks (1,852).
It now holds the ones we offer: 9, picked by hand, each looked at on the
canvas and in the text editor at 16 to 36 px in Chrome and Firefox, on a
low and a high pixel density display. Safari 15.5 has seen all but Open
Sans and Bevan.
- handwriting: Kalam, Patrick Hand, Pacifico
- sans: Open Sans
- serif: Literata
- monospace: Fira Mono
- display: Bevan
- Japanese: Zen Maru Gothic
- Korean: Gowun Dodum
No Chinese family yet: none of Google's fits Simplified Chinese (LXGW
WenKai TC has the characters, in older forms than mainland's and with
Taiwan's punctuation), and a Traditional one alone would leave the larger
group out. Zen Maru Gothic has every kana and JIS X 0208 kanji, Gowun
Dodum every Hangul syllable, read from the font files.
All are under the SIL Open Font License with no reserved font name. All
but Zen Maru Gothic have the letters of Czech, Slovak, Polish, Hungarian,
Turkish and Romanian, also read from the font files: Google's "latin-ext"
label doesn't tell.
The generator works from that list (`OFFERED_FAMILIES`) and writes the
catalog in its order, so the order no longer follows Google's popularity
figures. A catalog can grow later; it can't shrink once a release has had
a name. `GOOGLE_FONT_DEFAULT_PICKS` is the same list.
Claude Fable 5.2, effort 30
* feat(fonts): list a family by a glyph of its own script
A Japanese or Korean family has a Latin name, and its row in the font
list looked like any other of its provider: the provider's icon, then the
name. Nothing said which script it writes.
The row now takes the family's preview text for its icon, written in the
family ("あ", "한"), where the provider's `getPreviewText` gives one. It
is the sample the top picks already show for a pinned family. A family
without one keeps the provider's icon.
`getPreviewText` is asked for every listed family, not only the pinned
ones; the answer is still kept for the session.
Claude Fable 5.2, effort 30
* feat(fonts): a provider's families get the icons our own fonts have
In the font list every family of a provider had the provider's icon. The
icon column said where a font comes from, the same on every row, and
nothing about the font. Our own fonts say what they're for there:
handwriting, text, code, headings.
A provider can now tell a family's kind: `getKind`, answering one of
`FontKind` ("hand-drawn", "normal", "code", "heading"). The row gets the
icon our own fonts of that kind have, so a host imports no icon of ours.
A row's icon is, in this order: the family's preview text (a glyph of its
script), the icon of its kind, the provider's `icon`, a normal font's.
`FontProvider.icon` is optional with that: it's what a family gets which
its provider says nothing about.
The Google catalog has a kind per family (`getGoogleFontKind`), set by
hand next to the name in the generator's `OFFERED_FAMILIES`: Google's own
categories file Bevan, a display face, as a serif. An entry is now
[name, unitsPerEm, ascender, descender, lineGap, kind, script?].
excalidraw.com's provider drops Google's icon, and passes the kind and
the preview text for the fonts it lists (the ones a scene uses).
fontPreviewText.ts is fontProviderInfo.ts now: one cache for what a
provider says about a family, the preview text and the kind.
Claude Fable 5.2, effort 30
* feat(fonts): offer "Browse more fonts" only when there are more
A provider able to page (`loadMore`) turned "Browse more fonts" on,
whether or not it had a font beyond the ones listed. One offering all of
its fonts up front, as the Google catalog's 9 are, got a button which
brought nothing and then went away.
The picker now asks for the first page as it opens, once per editor and
set of providers, and offers the button only if that brings a font it
doesn't list yet. Those fonts are what the first click lists; later pages
load as before.
Claude Fable 5.2, effort 30
* fix(fonts): findings of Astra's review
- Closing the font picker restored every selected element from the copy
taken when it opened, as a newer version: whatever a collaborator had
changed meanwhile was lost for everyone, and opening and closing the
picker alone gave each element a new version. Now only a live preview
is taken back, to the scene as it was when that preview started, and
only what a preview changes: the font of a text and the layout that
follows (its wrapping, size and position, on a sticky note its fitted
font size; its container's size). A text edited during the preview
gets its font back and is laid out anew. Whatever else is selected
along with a text is never touched. A hover resets a container's size
the same way, not the whole element.
- A headless export (no `document.fonts`, no `FontFace`) threw: on plain
Helvetica text, on a font of a provider nobody configured, and on any
custom font once a resolver was configured. A font face built its
`FontFace` as it was created, and so did the registry for every
built-in font. It's built when first asked for now, which such an
export never does: nothing is installed or retried without a font set.
Telling that a font is local, or registered, doesn't build the registry
either (the font metadata, as on master; `hasCustomFamily`).
- Beyond what master could do: an SVG export embeds its fonts where
there is no `window`, `document` or `FontFace` at all (i.e. Node, given
a document to build in). A font face read `window.EXCALIDRAW_ASSET_PATH`
unguarded, and asked its `FontFace` for the unicode range it covers
when its descriptors named none; it covers everything then, as in CSS.
- `Fonts.loadElementsFonts(elements, ownerDocument)`, master's signature,
threw: the second argument had become a `Fonts`. It takes either.
- The font picker called React 18's `useSyncExternalStore`, with React 17
among the peer dependencies. `hooks/useSyncExternalStore` falls back to
a subscription in an effect there, like `hooks/useTransition`.
- An export resolved the fonts of deleted elements, before it dropped
them.
- An export loaded its fonts into the global document, whatever document
it was given to draw in (`environment.document`): an editor in a popout
window got them in its opener's, where its canvas can't use them. As on
master, where it's an omission too. They go into the given document if
it has a font set.
- "Browse more fonts" went missing with its group: when the scene uses
every available font, the group is empty and wasn't rendered. A group
with a footer is.
Left as they are, as rare: a collaborator moving or resizing a text or
its container within the seconds of someone's hover preview of it, a family picked in
a popout which another document registered, a provider added in the
middle of a gesture, a failing resolver asked three times by one export,
a slow pinned font overtaking a later pick, and the look-ahead's five
page limit.
Claude Fable 5.2, effort 30
* feat(fonts): favorites are pinned fonts
The font picker's "Favorites" are "Pinned" now, and so is everything
that names them:
- the prop: `fontFavorites` -> `pinnedFonts` (same shape, `fonts` and
`onChange`)
- the list's section "Pinned", the drop zone's "Pin" and "Unpin"
- the locale keys `fontList.pinnedFonts`, `pinFont`, `unpinFont`
The tip at the bottom of the picker reads "Drag a font to pin". It spoke
of the top picks alone, while a drag also offers the pin zone, which only
shows up once the drag starts.
Claude Fable 5.2, effort 30
* feat(fonts): createGoogleFontProvider
A host had to put the Google provider together from the parts: the
resolver, the offered families, the search, the paging, the preview text
and, since this week, the kind. Each new part meant a change in every
host.
`createGoogleFontProvider()` in `fonts/google` returns the whole
`FontProvider`. `offerInPicker: false` leaves the fonts out of the font
picker (none listed, found by search or browsed to), while a scene's
Google fonts still render: what excalidraw.com ships, in one call now.
`resolve` takes a resolver of the host's own.
Claude Fable 5.2, effort 30
* feat(fonts): Escape closes the font picker; "Drop to pin" and a hint icon
- Escape closes the font picker, from its search too. It never did: the
key took a hover preview back and left the popup open, as a focus
moving out does. A live preview is still taken back, and the focus goes
to the canvas, or back to the text being edited.
- The pin drop zone reads "Drop to pin" and "Drop to unpin".
- The hint "Drag a font to pin" has a drag-and-drop icon. A host's own
`fontPickerTip` is shown as given.
Claude Fable 5.2, effort 30
* feat(app): keep Google's font stylesheets for offline use
Resolving a `google:` font asks Google for the family's stylesheet, which
lists its files. The service worker kept the files (the `.woff2` rule)
and not the stylesheet, so offline such a font resolved only for as long
as the browser's HTTP cache held it: a day, by Google's headers. After
that the text fell back to another font, its files in the cache or not.
A runtime caching rule for `fonts.googleapis.com/css2` keeps it for 90
days, served from the cache and refreshed in the background. Nothing is
fetched ahead: a stylesheet is stored when its family is first resolved.
Tried in a production build with the network cut for everything but
localhost: with the HTTP cache cleared, a text in Kalam is drawn in Kalam
with the rule and in the fallback font without it.
Claude Fable 5.2, effort 30
* docs: changelog for custom fonts
Claude Fable 5.2, effort 30
* fix(fonts): a font picked after its hover preview settled can be undone
Hovering a font in the picker previews it on the selected text without
capturing it. A font repair landing meanwhile (the hovered font itself
finishing to load, or any other) was committed as never-to-be-captured,
which took the previewed font into the store's snapshot along with it.
Picking that font then changed nothing against the snapshot: no undo
entry, and undo left the new font in place.
A live hover preview now counts among the changes yet to be captured, as
a drag and a text edit do, so repairs wait for it to end. The preview's
own redraw, once its font has loaded, runs as part of the preview.
Found by mtolmacs in review.
Claude Fable 5.2, effort 30
* fix(editor): load the custom fonts of a dropped scene
Dropping an `.excalidraw` file applied its scene without asking for its
fonts, and nothing else resolves a scene's custom fonts on that path, so
its text stayed in a fallback font until a reload. The "Open" action
asked already.
Found by mtolmacs in review.
Claude Fable 5.2, effort 30
* fix(build): keep the Google font catalog out of the package's fonts folder
The package build names a code-split chunk by its source folder, so the
catalog, imported from `fonts/google/`, was emitted as
`dist/prod/fonts/google/catalog-<hash>.js`: a script inside the folder of
font files which hosts copy over to serve them themselves (Excalidraw+,
and `examples/with-nextjs` here).
It's an entry point of its own now, emitted next to `fonts-google.js` as
`fonts-google-catalog.js`.
Claude Fable 5.2, effort 30
* feat(fonts): pinned fonts are favorites again
"Pin" already names what a drag onto the top picks does, so a second
kind of pinning in the same picker was easy to confuse with it. The
naming goes back:
- the prop: `pinnedFonts` -> `fontFavorites` (same shape, `fonts` and
`onChange`)
- the list's section "Favorites", the drop zone's "Drag to favorite" and
"Remove favorite"
- the locale keys `fontList.favoriteFonts`, `addToFavorites`,
`removeFromFavorites`
The tip stays "Drag a font to pin".
Claude Fable 5.2, effort 10
---------
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
GitHub's hosted runners differ from run to run (region, CPU), so a commit's
timings only compare with timings from the same runner.
- The perf job builds the commit and master before the push and loads both
alternately (`yarn stats:compare --base <commit> --iterations 6`), instead of
waiting for staging; without staging there's nothing to cancel, so every merge
gets its run.
- `perf.mjs --base` takes a commit: checked out into a temporary worktree with its
own dependencies, built and served like this checkout. `--out *.json` writes both
builds' loads; `--wait-for` is gone. One unrecorded warm-up load per build, and
the runner's CPU in the environment.
- `post.mjs` sends the commit time (the admin orders runs by it) and the base
build; perf runs need one.
Claude Opus 5.5 (xhigh)
- `Stats` workflow on master: posts the production build's file sizes (raw, gzip, Brotli; initial load vs. lazy; bytes per source package) and, once staging serves the commit, its page-load and pan/zoom measurements to the Excalidraw+ backend; OSS_STATS_TOKEN lives in the master-only `stats` environment
- `scripts/stats/`: bundle-stats Vite plugin and wrapper config (`yarn stats:bundle`), the Playwright runner (`yarn stats:perf`) and the poster
- `yarn stats:compare`: builds the checkout, serves it with `vite preview` and compares it with staging (alternating loads, Mann-Whitney U test); prints a table or writes CSV with `--out`
- `excalidraw:app-start` mark in the app's entry, ending the runs' "HTML + JS" phase
- `playwright` 1.58.2 dev dependency (installs no browsers by itself)
Claude Opus 5.5 (xhigh)
- Vendored fractional-indexing and converted to TypeScript
- Stricter index format validation in fractional-indexing
- Added format validation to fractional index validation
---
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
* move the existing example to with-script-in-browser
* Add example with next js app router
* disable ssr for excalidraw client comp
* typo
* update output dir
* don't include nextjs example in tsconfig
* remove meta.json
* lint
* remove example.ts
* port
* move the examples outside packages and use the deps as workspaces in examples
* update gitignore
* fix example
* update path of build dir
* fix
* fix scripts
* try local path
* fix
* update commands
* fix
* fix
* fix script
* skip ts
* disable ts
* add vercel.json
* install
* update tsconfig
* fix lint
* remove console.log
* lets see if this works
* revert
* remove ts nocheck
* add types and some utils in nextjs example
* fix types
* updatw example and remove nextjs dynamic syntax so we don't import excal twice
* move both examples to workspaces and create generic example to be used by browser and next js both
* copy the static assets to nextjs
* fix ts config
* render custom menu items
* fix custom footer
* fix types in browser example
* use regular imports for importing excal and import it using dynamic next js in app router instead
* Add example for pages router
* fix css discrepancies
* fix css
* configure output dir
* fix
* fix css
* rename to with-nextjs
* move components to examples/excalidraw/components
* build: Welcome ESM and Bye Bye UMD
* remove package
* create unbundled esm build
* update script for example
* fix typo
* dummy commit
* update autorelease script to build esm
* revert dummy commit
* move react, react-dom and testing library to dev dependencies
* remove entry.js, publicPath and yarn install:deps script
* fix
* upgrade esbuild to fix glob import error for locales
* remove webpack chunk names as thats not needed anymore
* marking the code sideeffects free
* make the library tree-shakeable and move fonts to fonts directory
* allow side effects for css, scss files
* remove tree-shaking
* comment code for tree shaking
* move to vite for example
* bye bye webpack
* ignore ts
* separate build and output dir
* use esbuild for creating bundle for example
* update output dir
* lint
* create browser dev build with source maps and prod with minification
* add dev and prod builds for bundler
* lint
* update script
* remove await
* load prod build
* create minified build in dist
* prod and dev builds using export field
* remove import.meta
* dummy
* define import.meta prod and dev
* fix
* export types
* add types field
* typo
* lint
* Update scripts/buildPackage.js
* move types inside export
* newline
* feat:Integrate docusaraus for docs
* Update docs for Excalidraw
Co-authored-by: David Luzar <luzar.david@gmail.com>
* remove blogs
* remove blog authors
* get started docs
* typo
* add static assets
* change port number
* Add script to build docs only if docs updated
* dummy
* update script to be compatible with ignoreBuild in vercel
* remove script and dummy log
Co-authored-by: David Luzar <luzar.david@gmail.com>
* build: use next and preview tags instead of separate packages for next and preview release
* add tag
* dummy diff
* revert dummy tweak
* don't use readme_next
* add note for latest release readme
* Add warning emoji for note
* move note to top
* remove readme next
* fix
* dummy change for release
* remove double note
* Revert "dummy change for release"
This reverts commit d3655cdee4.