Repository navigation
Render text hinted on request: a hinting option of page.pixmap and Document.render (#612) - #623
Merged
Merged
Conversation
…cument.render (#612) hayro 0.9 hints text, which sharpens small text, and pyropdf turns that off so that the fonts it subsets draw as their originals (#18). `hinting=True` renders as hayro does with its default settings. Without the option every render stays as it was, so the change only adds to the public API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 4, 2026
This was referenced Nov 4, 2026
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.
Closes #612
hayro 0.9 hints text, and pyropdf turns that off so that the fonts it subsets draw as their originals (#18).
page.pixmap(hinting=True)andDocument.render(hinting=True)now render hinted on request, as hayro does with its defaultRenderSettings. Without the option every render stays as it was, so the change only adds to the public API.Changes
render::Optionsgainshinting, off inOptions::new, andrender_settingstakes it.render_pageandrender_pagespass it through. The annotation appearance raster inannotations.rsstays unhinted; that line is outside the option but has to name the new field.Page.pixmapandDocument.rendergain a keyword-onlyhinting: bool = False, documented with the note that hinted renders may differ before and aftersubset_fontsor a compacting save.docs/en/api/rendering.md; these methods are generated intopages.mdanddocuments.md.render/tests.rs, which the issue's paths omit, are there because only a Rust test can call hayro directly.Acceptance
hinting, every render is the same, byte for byte, as before the option. Evidence is a one-off comparison, not committed: SHA-256 ofpage.pixmap()andDocument.render()on the 86 pages hashed across the 15 corpus files (at most 40 per file), identical between a build of614fb83and this branch.test_hinting_changes_text_and_is_off_by_defaultkeeps the default equal tohinting=False.hinting=True, text on a corpus page at 72 dpi renders as hayro renders it with its defaultRenderSettings, and differs from the unhinted render (hinting_renders_as_hayro_renders_with_its_default_settings, onpdf20-simple.pdf).Document.render(..., hinting=True)returns whatpage.pixmap(hinting=True).to_bytes(...)returns for each page (test_document_render_hints_as_page_pixmap_does), and a render after one with the other setting, through a sharedRenderCache, equals a fresh one (a_render_cache_keeps_hinted_and_unhinted_glyphs_apart,test_a_render_with_one_hinting_after_the_other_equals_a_fresh_one).hintingthat is not a bool is refused withTypeError(test_hinting_must_be_a_bool).Checks
Run locally on Windows: ruff, ruff format, ty, cargo fmt, clippy, and cargo test pass. Clippy and the hayro comparison test were rerun after the last edit, a one-line clippy fix in that test; cargo test as a whole was not.
pytestended with 6577 passed and 16 failed, the same 16 that failed on the #608 branch, intest_pdfua_corpus,test_structural_check, andtest_structure_page_deletion. They read PDF fixtures that this checkout holds with CRLF line endings (i/lf w/crlf); that cause is inferred from the byte diffs and was not confirmed on an LF checkout, so CI on Linux is the check for them.No claim about rendering speed: a hinted render was not measured, and the default does not change.
Left for the owner to review and merge.
🤖 Generated with Claude Code