Skip to content

Add Local Font Access API support with Google/Local font source toggle#26

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/use-local-font-access-api
Draft

Add Local Font Access API support with Google/Local font source toggle#26
Copilot wants to merge 3 commits intomainfrom
copilot/use-local-font-access-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 16, 2025

Implements the Local Font Access API to allow users to browse and load their system fonts alongside Google Fonts.

Changes

New Hook: use-local-font-access.ts

  • useLocalFontAccessSupport() - Detects browser API support via window.queryLocalFonts
  • useLocalFonts() - Fetches local fonts with loading/error states

New Component: font-source-selector.tsx

  • Styled toggle buttons (Google/Local) positioned next to search bar
  • Only renders when Local Font Access API is supported

New Component: local-font-grid.tsx

  • Grid display for local fonts with SVG-based previews
  • Mirrors existing FontGrid keyboard navigation patterns
  • Preloads fonts on hover/focus, loads into main view on click

Updated: no-font-view.tsx

  • Added font source state management
  • Conditional rendering between Google and Local font grids
  • Integrated selector into controls layout

TypeScript Definitions: vite-env.d.ts

interface FontData {
  family: string
  fullName: string
  postscriptName: string
  style: string
  blob(): Promise<Blob>
}

interface Window {
  queryLocalFonts(): Promise<FontData[]>
}

The selector gracefully degrades - it's hidden on browsers without API support.

Original prompt

This section details on the original issue you should resolve

<issue_title>Use local font access api in UI</issue_title>
<issue_description>https://developer.mozilla.org/en-US/docs/Web/API/Local_Font_Access_API

You can list out the user's local fonts and fetch their blobs. This could be used to make a google/local switcher in the fonts grid. We'd have to generate the previews locally but that should be pretty quick.

Still not sure how this will be presented in the ui, let's look at a few different options. Stylized radio buttons seem like the best idea to me, and they could live next to the search bar. If the device doesn't support the API, then the radio buttons should not be shown. </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 16, 2025 03:09
Co-authored-by: bschlenk <1390303+bschlenk@users.noreply.github.com>
Co-authored-by: bschlenk <1390303+bschlenk@users.noreply.github.com>
Copilot AI changed the title [WIP] Add local font access API integration in UI Add Local Font Access API support with Google/Local font source toggle Nov 16, 2025
Copilot AI requested a review from bschlenk November 16, 2025 03:48
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.

Use local font access api in UI

2 participants