Skip to content

feat: support font variants (bold/italic) from ~/.termux#5106

Open
sghoshm wants to merge 8 commits intotermux:masterfrom
sghoshm:feat/font-variants
Open

feat: support font variants (bold/italic) from ~/.termux#5106
sghoshm wants to merge 8 commits intotermux:masterfrom
sghoshm:feat/font-variants

Conversation

@sghoshm
Copy link
Copy Markdown

@sghoshm sghoshm commented May 4, 2026

Summary

This PR adds support for loading font variants (font-bold.ttf, font-italic.ttf, font-bold-italic.ttf) from ~/.termux/.

When present, these files are used for rendering bold and italic text instead of synthesized styles.

Motivation

Currently, Termux renders bold and italic using:

  • setFakeBoldText
  • setTextSkewX

This causes:

  • italic text to appear as a geometric slant
  • loss of intended font design for fonts like VictorMono or MapleMono

Changes Made

  • Added support for optional font variant files:

    • ~/.termux/font-bold.ttf
    • ~/.termux/font-italic.ttf
    • ~/.termux/font-bold-italic.ttf
  • Updated TerminalRenderer to select the appropriate typeface based on style flags

  • Preserved fallback behavior:

    • If a variant file is not present, existing synthesized styling is used

Implementation Notes

  • Changes are limited to TerminalRenderer
  • Font paths are resolved locally within the renderer to avoid additional dependencies
  • No changes to existing configuration or settings

How to Use

  1. Place font files in:

    ~/.termux/
    
  2. Example:

    font.ttf
    font-bold.ttf
    font-italic.ttf
    
  3. Reload settings:

    termux-reload-settings
    

Testing

  • Verified fallback behavior when variant files are absent
  • Verified correct rendering when variant files are present
  • Tested using VictorMono font

Compatibility

  • Fully backward compatible
  • No behavior change for users without custom font variants

Challenges Faced

  • terminal-view module does not have access to shared constants, so paths are resolved locally
  • Ensured minimal and localized changes to avoid regressions in rendering

Related Issue

Addresses the issue raised by @MapleMocha


Thanks to @MapleMocha for the original idea 🙏

@MapleMocha
Copy link
Copy Markdown

Thank you for your contribution! I really like this❤️❤️❤️

@synthyst
Copy link
Copy Markdown

The PR for this feature already exists here.

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