Skip to content

Add Vazirmatn (v33.003) support for Farsi - #331

Open
sepehr-rs wants to merge 12 commits into
python:mainfrom
sepehr-rs:add-vazirmatn
Open

sepehr-rs wants to merge 12 commits into
python:mainfrom
sepehr-rs:add-vazirmatn

Conversation

@sepehr-rs

Copy link
Copy Markdown
Contributor

Adds Vazirmatn for Farsi builds. Vazirmatn is an open-source font licensed under the SIL Open Font License. Adding this to Farsi builds improves the readability and quality of the documentation.
I didn't touch the broader RTL fonts and kept it scoped to Farsi with :lang(fa). The font is bundled as a single variable WOFF2 file in static/fonts/, with its OFL.txt alongside.

With Vazirmatn:
image
image

Before:
image
image

Please let me know if any changes or additions are needed. Thanks in advance!

@read-the-docs-community

read-the-docs-community Bot commented Sep 20, 2026

Copy link
Copy Markdown

Comment thread python_docs_theme/static/pydoctheme.css Outdated
Comment thread python_docs_theme/static/pydoctheme.css Outdated
Comment thread python_docs_theme/static/pydoctheme.css
sepehr-rs and others added 2 commits September 21, 2026 06:58
@sepehr-rs

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

Sidenote: I found an issue with the sidebar while investigating this; The sidebar button's direction is reversed in RTL mode:

When closed:
image
When open:
image

I think it'd be a very small fix, but should I make a separate PR for it, or fix it here if the scope creep is acceptable?

@hugovk

hugovk commented Sep 21, 2026

Copy link
Copy Markdown
Member

Vazirmatn is unmaintained following the death of its creator:

Vazirharf is a maintained fork, is that suitable?

In either case, the current .woff isn't too large at 109 KB, so bundling should be fine so we don't need to use a CDN. But Vazirmatn says:

For Latin glyphs, Vazirmatn is combined with Roboto font by a build script, however there is also a version without Latin glyphs (Non-Latin).

Can we use the Non-Latin version? That'd reduce it by around half:

@sepehr-rs

Copy link
Copy Markdown
Contributor Author

I don't oppose using a fork, but the font and its glyph coverage are stable, and the fork doesn't offer a benefit that matters for documentation (its only difference is how Lam-Alef is handled, which is aimed at typing sites). There's also no visible difference between the two, so I'd slightly lean towards staying with the original upstream release. That said, I'm happy to switch if the project prefers a maintained font, so I'll leave the decision to you.

Good point on the Non-Latin build. Vazirmatn also has a variable-weight Non-Latin version, and it's slightly smaller than Vazirharf's:

Please let me know what you think is best going forward, and thanks for the review!

@hugovk

hugovk commented Sep 21, 2026

Copy link
Copy Markdown
Member

Let's stick with the original then, and go with that Non-Latin version.

We can switch to a fork later if there's a concrete need to do so. Thanks!

@hugovk hugovk changed the title Add Vazirmatn support for Farsi Add Vazirmatn (v33.003) support for Farsi Sep 21, 2026

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I added the version number in the title, so it'll go into the commit message, so we can easily check the version.

I think it'd be a very small fix, but should I make a separate PR for it, or fix it here if the scope creep is acceptable?

Let's do a new PR.

@sepehr-rs

Copy link
Copy Markdown
Contributor Author

Thanks a lot for the review! I'll open a separate PR for that change.

Comment thread python_docs_theme/static/fonts/OFL.txt
@sepehr-rs

Copy link
Copy Markdown
Contributor Author

The CI is failing with W002: Wheel contains duplicate files. Should we ignore the warning or exclude the package copy from the wheel with build.targets.wheel.exclude?

@StanFromIreland

Copy link
Copy Markdown
Member

I think we can just ignore the warning?

@hugovk

hugovk commented Sep 21, 2026

Copy link
Copy Markdown
Member

Let's rather exclude, so we only have one copy in the expected place? Something this:

build.targets.wheel.exclude = [ "python_docs_theme/locale/**/*.po", "python_docs_theme/static/fonts/OFL.txt" ]

Ignoring W002 means we could easily end up with other duplicates in the future without realising.

@sepehr-rs

Copy link
Copy Markdown
Contributor Author

Makes sense. Excluded OFL.txt in pyproject.toml. One question though: doesn't this mean the license won't appear next to the font in the package? I thought the license should be bundled alongside the font.

@hugovk

hugovk commented Sep 21, 2026

Copy link
Copy Markdown
Member

We can see the contents of the sdist at https://github.com/python/python-docs-theme/actions/runs/35627886765

It has the licence next to the font:

│   ├── [2026-09-21T16:48:06Z]  static
│   │   ├── [2026-09-21T16:47:48Z]  copybutton.js
│   │   ├── [2026-09-21T16:48:06Z]  fonts
│   │   │   ├── [2026-09-21T16:47:48Z]  OFL.txt
│   │   │   └── [2026-09-21T16:47:48Z]  Vazirmatn-NL-VF.woff2

And it also shows the wheel, with the licence in the designated licenses metadata subdir:

└── python_docs_theme-2026.9.dist-info
    ├── METADATA
    ├── RECORD
    ├── WHEEL
    ├── entry_points.txt
    └── licenses
        ├── LICENSE
        └── python_docs_theme
            └── static
                └── fonts
                    └── OFL.txt

But it doesn't need to be directly next to the font. The licence says:

  1. Original or Modified Versions of the Font Software may be bundled,
    redistributed and/or sold with any software, provided that each copy
    contains the above copyright notice and this license. These can be
    included either as stand-alone text files, human-readable headers or
    in the appropriate machine-readable metadata fields within text or
    binary files as long as those fields can be easily viewed by the user.
  • "... provided that each copy contains the above copyright" -> "Copyright 2015 The Vazirmatn Project Authors (https://github.com/rastikerdar/vazirmatn)"

  • "and this license" -> check

  • "These can be included ... in the appropriate machine-readable metadata fields within text or binary files" -> using the wheel metadata for licences in the Core Metadata Spec defined by PEP 639.

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.

3 participants