-
Notifications
You must be signed in to change notification settings - Fork 39
add optional font inlining to presentation creator #88
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
Open
shellmayr
wants to merge
1
commit into
main
Choose a base branch
from
shellmayr/add-offline-fonts-to-presentation-creator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
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
59 changes: 59 additions & 0 deletions
59
plugins/sentry-skills/skills/presentation-creator/references/offline-fonts.md
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,59 @@ | ||
| # Offline Font Inlining | ||
|
|
||
| By default, the presentation template loads Rubik and Material Symbols from Google Fonts via `<link>` tags. This works for development and online use, but the fonts will **not** be included in the single-file HTML build — `vite-plugin-singlefile` only inlines local assets. | ||
|
|
||
| If the presentation needs to work fully offline, follow these steps to inline the fonts. | ||
|
|
||
| ## Step 1: Install @fontsource/rubik | ||
|
|
||
| Replace the Google Fonts `<link>` with the npm package: | ||
|
|
||
| ```sh | ||
| npm install @fontsource/rubik | ||
| ``` | ||
|
|
||
| ## Step 2: Import font weights in main.jsx | ||
|
|
||
| ```jsx | ||
| import '@fontsource/rubik/300.css' | ||
| import '@fontsource/rubik/400.css' | ||
| import '@fontsource/rubik/500.css' | ||
| import '@fontsource/rubik/600.css' | ||
| import '@fontsource/rubik/700.css' | ||
| ``` | ||
|
|
||
| ## Step 3: Remove Google Fonts links from index.html | ||
|
|
||
| Replace: | ||
| ```html | ||
| <link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
| <link href="https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap" rel="stylesheet" /> | ||
| ``` | ||
|
|
||
| With: | ||
| ```html | ||
| <!-- Rubik font loaded via @fontsource/rubik (inlined at build time) --> | ||
| ``` | ||
|
|
||
| ## Step 4: Raise the asset inline limit in vite.config.js | ||
|
|
||
| Font files (woff2) are ~50–200KB each. Set a high limit so Vite base64-encodes them into the CSS, which `vite-plugin-singlefile` then embeds in the HTML: | ||
|
|
||
| ```javascript | ||
| export default defineConfig({ | ||
| plugins: [react(), viteSingleFile()], | ||
| build: { assetsInlineLimit: 1024 * 1024 }, | ||
| }) | ||
| ``` | ||
|
|
||
| ## Step 5: Build | ||
|
|
||
| ```sh | ||
| npm run build | ||
| ``` | ||
|
|
||
| The resulting `dist/index.html` will be ~1.5MB (vs ~200KB without fonts) but fully self-contained. | ||
|
|
||
| ## Material Symbols | ||
|
|
||
| The `material-symbols` npm package can be installed similarly, but it is very large. For offline builds, prefer inline SVG or Unicode symbols for icons instead. | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The documentation for creating offline presentations fails to instruct the removal of the
Material Symbolsfont link, resulting in a build that is not fully self-contained.Severity: MEDIUM
Suggested Fix
Update Step 3 in
offline-fonts.mdto explicitly show the removal of both theRubikandMaterial Symbolsfont links. Alternatively, add a note in Step 3 clarifying that theMaterial Symbolslink must also be removed and reference the dedicated section that recommends replacing the font with SVGs or Unicode symbols for a truly offline build.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.