- Home
- Plugins
- UI Enhancements
- dsh-persian-font
dsh-persian-font
alifirozjaei/dsh-persian-font
Renders Persian and Arabic script with a font chosen in Settings while Latin text keeps the app's own font.
Install
dsh plugin --profile web add github:alifirozjaei/dsh-persian-fontREADME
dsh-persian-font
Persian and English text in the same answer can use different fonts: this plugin draws every Persian/Arabic-script run with the font you choose in Settings — Vazirmatn when it is installed, otherwise the best Persian face the machine has — while Latin text keeps the font the app already uses.
Installed as a DSH bundle, it adds one stylesheet and one row in Settings → General. Nothing else in the interface changes: no new panel, no colors.
What it does
The app's text stack lives in one variable, --dsw-font-family, and the design
tokens build every typography variant from it. The plugin declares an
additional font family — DSH Persian Text — whose unicode-range covers only
the Arabic-script blocks (U+0600–06FF, U+0750–077F, U+08A0–08FF,
U+FB50–FDFF, U+FE70–FEFF), and puts that family first in the stack:
body {
--dsw-font-family: "DSH Persian Text",
var(--dsh-font-family-text, var(--dsh-font-family-text-default)),
var(--dsh-font-family-text-default);
}
Because the browser resolves font-family per character, Persian letters
match the alias first and Latin letters skip it and land on the next family —
the app's own stack. Mixed lines therefore need no markup, no language
attribute, and no configuration.
Code blocks and the sidebar terminal keep their own variables and stay unchanged.
Requirements
None. The plugin uses whichever Persian face the machine already has, and the
Settings row lets you point it at a different one. Vazirmatn is the first name
in the built-in preference list, so installing it — ~/Library/Fonts on macOS,
%LOCALAPPDATA%\\Microsoft\\Windows\\Fonts on Windows, ~/.local/share/fonts on
Linux — simply makes it the automatic choice.
A variable font gives real weights instead of synthetic bold; local() tries
the family name, the full name and the PostScript name, and the first match
wins. If nothing in the list exists, the alias resolves to nothing for Arabic
characters and Persian falls through to the app's normal stack — readable, just
not your chosen face, and the Settings row says so.
Why the local() names are expanded
Chromium resolves local() against the installed face's full name and PostScript
name, not its family name — and for a variable font only the PostScript name
matches. local("Vazirmatn") therefore fails on macOS while
local("Vazirmatn-Regular") loads, and a chain that omits the PostScript form
silently falls through to the next family. That is exactly what 2.1.0 did: the
alias resolved to Nazanin while font-family: Vazirmatn kept working, so the
settings row and the detection both looked right while the chat text used the
wrong face.
Every name now expands to Name, Name-Regular and Name Regular. A spelling
that does not exist simply does not match, so the expansion costs nothing and
covers static installs (where the family name matches) and variable installs
alike.
Persian half-spaces
Persian writes compounds with U+200C (نیمفاصله), not with a space: میشود، برنامهنویسی، راستبهچپ. A font can only draw the half-space the text contains — when the character is missing, the shaper joins the letters and no font or CSS can separate them. Vazirmatn draws it at about 0.25em, the macOS system Persian font at about 0.37em.

Settings
Settings → General → Persian font carries the picker:
| Control | Meaning |
|---|---|
| Automatic | The built-in preference list — the best Persian face this machine has |
| name | One family detected on this machine, used for Persian and Arabic only |
| Custom… | Any family name, for fonts the probe cannot see (variable builds, aliases, per-user installs) |
The choice is stored with the rest of the profile through the Settings service
(family in this plugin's entry), so it survives restarts and applies on the
next page load before the first paint — the Host half injects the stylesheet into
the page shell using the saved value.
Text size and the Latin font stay where they were: Settings → General → Font size, and More font settings → Text font. Those apply to both scripts; this row only decides which face draws Persian and Arabic letters.
# what gets written, if you want to inspect it
grep -A3 'id: persian-font' ~/.dsh/profiles/<profile>/cordis.patch.yml
Works on any machine
The plugin never assumes a particular font is installed, because a published plugin runs on machines its author never sees:
- Detection, not a fixed list. The picker measures candidate families
against the generic families with canvas
measureText; a family whose metrics differ exists.document.fonts.check()cannot do this — it reports unknown families as loaded. - A cross-platform fallback chain for
Automatic: Vazirmatn and the other Persian families first, then the Arabic-capable faces each platform ships — Geeza Pro and SF Arabic on macOS, Segoe UI and Tahoma on Windows, Noto Naskh Arabic on Linux — then generic fallbacks. - No font bundled. Package assets cannot serve font files, and shipping a webfont would drag a licence and a megabyte into every install. Using the machine's own faces keeps the download tiny and matches how the rest of the interface is drawn.
- Graceful degradation. Without the Settings service the font still applies with the built-in preference; without the web-server index hook the stylesheet arrives with the client module instead of the shell. The Host half imports its schema package defensively for the same reason.
From GitHub
dsh plugin add github:alifirozjaei/dsh-persian-font
Then reload the app. The bundle patch inserts the plugin row; nothing else in the profile changes.
Install
Drop this directory into a DSH profile with Plugins → Add plugin, or let the
plugin manager install the local directory. The patch inserts the persian-font
row; the Host half is an empty plugin because everything happens in the page.
How it is verified

- Rendered in Chromium against a replica of the app's
base.css: the Persian string measures 285.5 px inside the alias against 261.6 px for a generic sans-serif, while the Latin string measures 292.89 px in both cases — the alias engages for Persian only. - The icon renders at 24, 32, and 64 px on light and dark backgrounds.
- JavaScript syntax and the manifest are checked before installation.
- Rendering of the actual page is confirmed in the running app by a mixed Persian/English message; the stylesheet is injected when the row mounts.
How the Settings row is verified
The client bundle was exercised in Chromium against stubbed slots /
configForms services and a minimal hooks runtime, checking: the stylesheet is
written with the alias and the cross-platform fallback list; the row registers
into settings.general.item as persian-font at order 12; the picker lists the
Automatic entry, the detected families, and Custom; choosing a family calls
form.set('family', …) and rewrites the stylesheet; a snapshot change from the
Host re-applies the font; the preview renders the sample; and detection returns
the machine's real faces while rejecting a made-up family name.
On a machine with Vazirmatn installed, the probe reports ten Persian/Arabic families, Vazirmatn among them.
The Host half was probed inside the running app: its schema package resolves
there, so the Settings form exists for the persian-font namespace.
One contract worth knowing if you fork this: a dynamic client package gets a
narrowed context. It exposes effect / on / once / provide and the timer
helpers, plus the services the returned plugin declares in inject — calling
ctx.inject(...) there is refused, so the row declares
inject: ['slots', 'configForms'] and reads ctx.slots / ctx.configForms
directly. Getting that wrong fails the whole apply, which is why the font
stopped applying in 2.0.0 and why 2.1.0 exists.
Licenses
Plugin code: MIT (see LICENSE).
icon.svg contains the outline of the Persian letter ف extracted from
Vazirmatn, which is licensed under
the SIL Open Font License 1.1. The glyph is used as an icon mark, not
redistributed as font software.
Related plugins
dsh-web (dsh-task-board)
zhu1090093659/dsh-web
dsh-web (dsh-web-all)
zhu1090093659/dsh-web
dsh-TUI
ccch1mneyyy/dsh-tui
dsh-web-ui (dsh-task-board)
zhu1090093659/dsh-web-ui