texttopdf: Remove FC_MONO constraint to allow proportional fonts#140
Merged
tillkamppeter merged 1 commit intoOpenPrinting:masterfrom Apr 1, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR removes the hardcoded
FC_SPACING == FC_MONOrestriction inside thefont_load()function oftexttopdf.Details
Previously,
texttopdfforced 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 (likeDejaVuSansMono), resulting in missing glyphs and silent failures during thecmaplookup.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.