Skip to content

Plugins: a plugin may ask for "fonts" and load font files in its windows - #1378

Closed
hoangvu12 wants to merge 1 commit into
zeronsh:zeron/zgxfrom
hoangvu12:plugin-fonts
Closed

hoangvu12 wants to merge 1 commit into
zeronsh:zeron/zgxfrom
hoangvu12:plugin-fonts

Conversation

@hoangvu12

@hoangvu12 hoangvu12 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

No plugin can use ui.load_font (zeronsh/zgx#2074). zgx asks the host to grant Capability::Fonts, and no manifest permission maps to it, so every call is refused with "a plugin does this only if the host grants it". A plugin's service can already load a font file with zeron.load_font (#1367), and its window can't load the same file to measure and draw alike.

Now a manifest can ask for "fonts", which grants Capability::Fonts to the plugin's windows.

  • A loaded font goes into every window's text, Zeron's own included. A plugin that loads its own Geist Bold Italic changes how Zeron's bold italic Geist draws, so the consent sheet asks: "Add fonts of its own", with a line saying Zeron's text may draw in the plugin's version of a font. English and Simplified Chinese are in place.
  • The service's zeron.load_font still needs no permission, because those fonts stay in that plugin's own service.
  • Documented in apps/zgx/docs/plugins.md.

This needs a zgx with #2074: Capability::Fonts doesn't exist at the rev apps/zgx pins today (06c6d56). Merge it with the bump that brings #2074 in.

Testing

  • grants.rs fonts_lets_its_windows_load_font_files: "fonts" grants Capability::Fonts, and other permissions don't. I ran it with the other grants tests against zgx-script at 06c6d56 with #2074's commit on top: 3 passed. I couldn't build the whole app on this Windows machine because mimalloc's C build fails here, independent of this change, so the app's i18n and consent tests didn't run.
  • manifest.rs a_plugin_may_ask_for_fonts: a manifest asking for "fonts" isn't broken. cargo test -p zeron-engine --lib manifest: 8 passed.
  • Both locale files parse and have the new keys.

Open question

I didn't mark the permission as risky in the consent sheet. Changing how Zeron's own text looks could be used to make text look different from what it is. Should it be flagged risky?


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

No manifest permission granted zgx's Capability::Fonts, so every plugin
window's ui.load_font was refused, and a window couldn't measure in the
fonts its service loads with zeron.load_font. A loaded font reaches
every window's text, Zeron's own included, so the person is asked.
@hoangvu12

Copy link
Copy Markdown
Contributor Author

Folded into #1392, which combines our plugin pull requests into one for review. This change is its commit 629abf0.

@hoangvu12 hoangvu12 closed this Nov 12, 2026
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.

1 participant