Skip to content

Support for using font not system installed - #22

Merged
attakei merged 6 commits into
mainfrom
feature/font-settings
Jul 18, 2026
Merged

Support for using font not system installed#22
attakei merged 6 commits into
mainfrom
feature/font-settings

Conversation

@attakei

@attakei attakei commented Jul 17, 2026

Copy link
Copy Markdown
Member

For #20

Summary by CodeRabbit

  • New Features

    • Added a --font-paths option to specify directories containing custom fonts when generating PDFs.
    • Custom font paths can also be provided through the TYPST_FONT_PATHS environment variable.
    • Font paths from command-line settings and the environment are combined when both are provided.
  • Documentation

    • Documented the new option, accepted format, default value, and usage for PDF font support.
  • Tests

    • Added coverage for default, command-line, environment-based, and combined font path configurations.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba434e15-04b3-4161-a14a-74657abfac0f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Adds a --font-paths PDF writer option and documents it. Writer.translate() combines configured paths with paths from TYPST_FONT_PATHS, split using the platform path separator, then passes them to typst.compile. Tests cover default, configured, environment-only, and combined font path resolution.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Issue 21 — This change implements custom font support through TYPST_FONT_PATHS and Typst compilation font paths.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change of allowing custom font paths for fonts not installed on the system.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/rst2typst/pdf.py (1)

50-51: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Ignore empty environment variable values.

If TYPST_FONT_PATHS is defined but empty (e.g., TYPST_FONT_PATHS=""), split(os.pathsep) will return [""], passing an empty string as a font path to Typst. Using os.environ.get(...) prevents this.

♻️ Proposed refactor
-        if "TYPST_FONT_PATHS" in os.environ:
-            font_paths += os.environ["TYPST_FONT_PATHS"].split(os.pathsep)
+        if env_paths := os.environ.get("TYPST_FONT_PATHS"):
+            font_paths += env_paths.split(os.pathsep)

(Note: If you need to support Python 3.7 or earlier where the walrus operator is not available, you can assign it first and then check if it's truthy).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/rst2typst/pdf.py` around lines 50 - 51, Update the TYPST_FONT_PATHS
handling to retrieve the environment value and only split and append its entries
when the value is non-empty, ensuring an empty variable does not add an empty
font path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cli.rst`:
- Around line 77-85: Refine the prose in the --font-paths documentation for
grammatical correctness and readability, including the description of custom
font directories and the explanation of when to provide a folder path. Preserve
the option name, type, default value, and intended behavior.

In `@src/rst2typst/pdf.py`:
- Around line 29-37: Update the --font-paths argument definition to parse
multiple paths as a list instead of storing one raw string, using the existing
downstream font_paths handling with an append action or equivalent
comma-separated-list validation. Preserve the default empty-list behavior.

---

Nitpick comments:
In `@src/rst2typst/pdf.py`:
- Around line 50-51: Update the TYPST_FONT_PATHS handling to retrieve the
environment value and only split and append its entries when the value is
non-empty, ensuring an empty variable does not add an empty font path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a8f98dc1-c301-4e7d-9641-132315b2e050

📥 Commits

Reviewing files that changed from the base of the PR and between 029023e and b4e7201.

📒 Files selected for processing (3)
  • docs/cli.rst
  • src/rst2typst/pdf.py
  • tests/test_pdf.py

Comment thread docs/cli.rst
Comment thread src/rst2typst/pdf.py
@attakei
attakei force-pushed the main branch 4 times, most recently from c595a29 to 7a0e867 Compare July 17, 2026 19:16
@attakei
attakei merged commit 15f84a2 into main Jul 18, 2026
25 checks passed
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