Skip to content

feat: add support for Ideographic Variation Sequences (IVS) in TrueTy…#1482

Merged
andreasrosdal merged 2 commits intoLibrePDF:masterfrom
wang0331:master
Feb 16, 2026
Merged

feat: add support for Ideographic Variation Sequences (IVS) in TrueTy…#1482
andreasrosdal merged 2 commits intoLibrePDF:masterfrom
wang0331:master

Conversation

@wang0331
Copy link
Contributor

  1. I have fixed the issues identified by SonarQube for the newly added code, and did not refactor the unchanged code. Please inform me whether I need to fix any reported errors (if any).
  2. Only errors in the DecryptAES256R6Test and FontTest classes occurred during the unit test execution. These errors are related to environmental configurations/information and not caused by code changes.

Description
This PR implements support for Ideographic Variation Sequences (IVS) in TrueType font rendering. IVS allows proper display of variant glyphs for CJK (Chinese, Japanese, Korean) characters, which is essential for correct typography in East Asian languages.

Key Changes
Added IVS lookup tables parsing in TrueType font processor
Implemented Unicode Variation Selector matching logic
Enhanced glyph substitution mechanism to handle IVS variants
Added fallback mechanisms for fonts without IVS support
Updated font metrics calculation for variant glyphs

Technical Details
Supports Unicode Variation Selectors
Implements gsub table lookup for uvs and non-default UVS features
Maintains backward compatibility with existing font rendering

Testing
✅ use template text and font export for IVS sequence detection
✅ Tested with known IVS-enabled fonts (e.g., Source Hei_MSCS)
✅ Verified rendering of CJK variant characters
✅ Confirmed backward compatibility with standard TrueType fonts

Impact
Enables correct display of CJK typographic variants
Improves PDF generation quality for East Asian documents
No breaking changes to existing API
Minimal performance impact (only activates when IVS sequences are present)
Related Issues
Closes #[issue-number-here]

Compatibility
✅ Fully backward compatible
✅ No changes to public API signatures
✅ Works with existing TrueType/OpenType fonts

Additional Notes
This implementation follows the Unicode Standard Annex #44 and OpenType specification for IVS handling. The feature only activates when both the font supports IVS and the text contains variation selector characters, ensuring minimal overhead for regular documents.

Your Name: oBo
Testing Instructions:
Use a font with IVS support (e.g., Source Han Sans)
Create PDF with CJK text containing variation selectors
Verify variant glyphs render correctly
Test with fonts without IVS support to confirm fallback behavior

@andreasrosdal Please review this merge. Let me know if you have any questions. Thank you.

@andreasrosdal
Copy link
Collaborator

Can you please provide evidence that this change is correct?
For your use case and for normal use cases of OpenPDF.

@andreasrosdal
Copy link
Collaborator

Please make some unit tests.

@wang0331
Copy link
Contributor Author

wang0331 commented Feb 16, 2026

Can you please provide evidence that this change is correct? For your use case and for normal use cases of OpenPDF.

I have the IVS font files and the exported PDF effect; the preview result in the browser is consistent with the exported one. I can send the font files to your email address, and I can attach a test file here – I have fully tested all the text content in it.

I will complete additional unit tests to verify that my newly added code does not affect the processing of plain text.
testFont.html

image

@sonarqubecloud
Copy link

@andreasrosdal andreasrosdal merged commit 85161e6 into LibrePDF:master Feb 16, 2026
10 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