Skip to content

texttopdf: Remove FC_MONO constraint to allow proportional fonts#140

Merged
tillkamppeter merged 1 commit intoOpenPrinting:masterfrom
shreyanshtiwari4:feature/remove-monospace-lock
Apr 1, 2026
Merged

texttopdf: Remove FC_MONO constraint to allow proportional fonts#140
tillkamppeter merged 1 commit intoOpenPrinting:masterfrom
shreyanshtiwari4:feature/remove-monospace-lock

Conversation

@shreyanshtiwari4
Copy link
Copy Markdown
Contributor

Description

This PR removes the hardcoded FC_SPACING == FC_MONO restriction inside the font_load() function of texttopdf.

Details

Previously, texttopdf forced Fontconfig to restrict candidate filtering exclusively to monospaced fonts. If a user specified a valid proportional font via charset configuration (e.g., NotoSansDevanagari), Fontconfig would reject it and fall back to a monospaced system font (like DejaVuSansMono), resulting in missing glyphs and silent failures during the cmap lookup.

By removing this strict check, Fontconfig can now correctly resolve and load the intended fonts for complex scripts. Monospace behavior is still perfectly preserved for scripts/charsets that explicitly request monospaced fonts (like ASCII).

This is a necessary precursor for adding proper Complex Text Layout (CTL) and shaping engine support to texttopdf.

Currently, texttopdf restricts font selection to monospace fonts by enforcing
(FC_SPACING == FC_MONO) during Fontconfig candidate filtering.

This causes incorrect font selection for scripts that require proportional fonts, such as Devanagari. Even when a suitable font (e.g., NotoSansDevanagari) is
specified via charset configuration, it gets rejected and replaced by a fallback monospace font (e.g., DejaVuSansMono), resulting in missing glyphs.

This patch removes the hardcoded monospace restriction and allows Fontconfig to select appropriate fonts based on the requested pattern.

Monospace behavior is still preserved where explicitly required (e.g., ASCII), but non-monospaced scripts can now correctly load their intended fonts.

This fixes rendering issues for Devanagari(Hindi) and potentially other scripts that depend on proportional fonts like Japanese, Chinese, etc.
@tillkamppeter tillkamppeter merged commit 3ee9507 into OpenPrinting:master Apr 1, 2026
7 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.

2 participants