Skip to content

fix: #5327 render music notation with bundled font fallbacks - #5722

Merged
Jocs merged 5 commits into
developfrom
fix/5327-music-notation-fonts
Oct 12, 2026
Merged

Jocs merged 5 commits into
developfrom
fix/5327-music-notation-fonts

Conversation

@Jocs

@Jocs Jocs commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Closes #5327

Summary

Music notation in the reporter's Notes - Definitions.md remains intact in the DOM and Markdown round-trip, but some glyphs appear blank in preview. The bundled Open Sans font lacks those symbols and its .notdef glyph has no contours, so unsuccessful system font fallback produces invisible placeholders.

Add Noto Music and Noto Sans Math WOFF2 assets using the existing local @font-face pattern. Their Unicode ranges cover music notation and technical brackets: Noto Music covers 𝅗𝅥 and 𝅘𝅥𝅯, while Noto Sans Math covers ⏜ and ⏝.

Declare the fonts directly in the editor's default stack, the default export stylesheet, both built-in export themes, header/footer styles and application-generated export font overrides. Built-in export stacks prioritize the range-limited symbol faces to prevent system missing-glyph placeholders from taking precedence; ordinary text keeps its existing fonts. External custom CSS is preserved unchanged.

All styled HTML exports embed the fonts by extending the existing KaTeX font embedding utility, renamed embedExportFonts. PDF/print waits for font loading before submitting the print request, including when the print container is hidden on screen. Font copyright metadata is preserved, with the complete OFL license stored inside each font's metadata; no separate license files or HTML license comments are added.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • Eight Chromium regression tests: preview with default/custom fonts; unconditional embedding without notation; preservation of external CSS; offline HTML/PDF with default fonts, an explicit fallback chain and both built-in themes. Verify actual glyph fonts through CDP and embedded PDF fonts.
  • Targeted desktop unit tests for print direction, code wrapping, PDF options and styled HTML export pass, including regressions for font-loading waits and application-generated fallback chains. PDF options and HTML export suites: 38 tests pass.
  • Muya font embedding tests: four tests pass. HTML export parity tests: six tests pass.
  • Manually tested on: macOS ARM64 / Chromium / Electron 42. Built and launched an unsigned packaged .app with the reporter's document; verified that app.asar font assets load and actual notation glyphs render. macOS ARM64 packaging also succeeds after removal of the standalone font license resources.
  • Generated a PDF through Electron's webContents.printToPDF using exported HTML. Both Noto fonts are embedded; PDF text extraction and visual inspection confirm the notation. The packaged app's native save dialog was not exercised.
  • pnpm run lint — passes with existing warnings.
  • pnpm run typecheck — passes.
  • pnpm run build:unpack — passes.
  • git diff --check, targeted font/export CSS Stylelint and font-helper ESLint — pass.

Notes for reviewers

Windows and Linux were not available for local verification. The complete fonts add approximately 413 KiB to the application; styled HTML exports always embed them (approximately 550 KiB of base64 data). PDF embeds the glyphs actually used.

The full Muya CSS lint command still reports seven pre-existing no-descending-specificity errors elsewhere in the existing stylesheets; the modified font and export stylesheets pass targeted Stylelint.


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license. The bundled Noto fonts retain their SIL Open Font License 1.1 metadata.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Build artifacts for PR #5722:

Run: https://github.com/marktext/marktext/actions/runs/38265523197

Artifact Size Link
marktext-windows-arm64 291.0 MB Download
marktext-linux 667.3 MB Download
marktext-windows-x64 299.1 MB Download
marktext-macos-x64 313.5 MB Download
marktext-macos-arm64 300.2 MB Download

@Jocs
Jocs merged commit b7e0124 into develop Oct 12, 2026
18 checks passed
@Zacchino

Copy link
Copy Markdown

Yay!

🙏🏻Thanks again for taking the time fix it.
Hope this makes it to Main soon!

Zane-0x5a added a commit to Zane-0x5a/marktext that referenced this pull request Oct 15, 2026
Upstream reworked the old print path (marktext#5722 makes MarkdownPrint wait for
the notation fonts; marktext#5716 resolves URL-encoded Windows image paths). The
fork replaced that path with the paged preview, so printService and its
two specs keep the fork's side. Both fixes still reach the preview: the
image fix lives in resolveLocalImageSrc, which exportHtml uses, and the
notation fonts arrive through the muya export styles, the export themes
and getCssForOptions. Main already waits for fonts.ready under print
media before printToPDF.

marktext#5746 drops the Info tab and explains that a table of contents needs a
[TOC] line. The HTML export dialog takes both changes. The print preview
panel shows the same explanation under its contents settings.

The preload keeps the fork's visual zoom limit next to upstream's
platform path import, and the editor store keeps isSameList.

marktext#5691 was merged earlier from its PR head; upstream's squash differs from
it only by commits that came in alongside it.

Verified on Windows 11: typecheck, desktop and muya lint, and the desktop
unit suite pass. In the muya unit suite, only the tableChessboard
entrypoint import timed out, and only on cold runs (it passes alone). The
print, export, sidebar, theme and title bar e2e specs plus upstream's new
3510, 5394, 5683 and 5710 specs pass in background windows, except 5394's
exact `toBe(400)` width check. At this machine's 1.75 device pixel ratio
the restored width reads 400.0000305, with or without the camera
transform; with `toBeCloseTo(400, 3)` all three scenarios pass.
@Jocs
Jocs deleted the fix/5327-music-notation-fonts branch October 23, 2026 08:32
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.

[Bug] Music notes and symbols (notation) don't render in markdown preview

2 participants