Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill missing glyph cmap when enableKernLiga to complete pdf/a3-u requirement. #1082

Merged
merged 5 commits into from
Feb 26, 2024

Conversation

forfin
Copy link
Contributor

@forfin forfin commented Feb 24, 2024

Description of the new Feature/Bugfix

When I produce PDF in Thai language and enableKernLiga feature, PDF render text perfectly but it lose the copy text ability.

And also not a PDF-A3U anymore since some glyph is missing in cmap table and violated this rule

The Font dictionary of all fonts shall define the map of all used character codes to Unicode values, either via a ToUnicode entry, or other mechanisms as defined in ISO 19005-2, 6.2.11.7.2.

This PR try to fix PDF-A3U violation only. Since it also a requirement from RD of Thailand.

I fill missing cmap with help of getGlyphCharIndex to determine mapping between glyph to char that produce from GlyphVector and layoutGlyphVector

And determine if cmap missing by check with getCharacterCode(glyphCode) function.

It not a perfect solution, Since original text still cannot copy from pdf and it beyond my knowledge.

Before

Screenshot 2024-02-25 at 02 28 32

After

Screenshot 2024-02-25 at 02 30 45

Related Issue: #

Unit-Tests for the new Feature/Bugfix

  • Unit-Tests added to reproduce the bug
  • Unit-Tests added to the added feature

Compatibilities Issues

Is anything broken because of the new code? Any changes in method signatures?

Testing details

Any other details about how to test the new feature or bugfix?

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@asturio asturio self-assigned this Feb 26, 2024
@asturio asturio self-requested a review February 26, 2024 14:12
@asturio asturio merged commit 6409882 into LibrePDF:master Feb 26, 2024
7 of 8 checks passed
asturio added a commit that referenced this pull request Mar 2, 2024
- fillerCmap is private Map and has getter and "putter"
- simplified getSentenceMissingCmap
- use more modern Java features
- lesser cleanups
asturio added a commit that referenced this pull request Mar 2, 2024
- Remove unused Method convertToBytes
- Add more Tests
- Added Font Awesome to tests
asturio added a commit that referenced this pull request Mar 2, 2024
- force using getter for fillerCmap
- more Tests for FontDetails
- renamed (test) fonts/liberation-serif to fonts/liberation
- added a smoke Test for creating a simple document
asturio added a commit that referenced this pull request Mar 2, 2024
- rename check-Method in assert
asturio added a commit that referenced this pull request Mar 2, 2024
- rename check-Method in assert
- Codacy issues fixed
asturio added a commit that referenced this pull request Mar 2, 2024
- fillerCmap is private Map and has getter and "putter"
- simplified getSentenceMissingCmap
- use more modern Java features
- lesser cleanups
asturio added a commit that referenced this pull request Mar 2, 2024
- Remove unused Method convertToBytes
- Add more Tests
- Added Font Awesome to tests
asturio added a commit that referenced this pull request Mar 2, 2024
- force using getter for fillerCmap
- more Tests for FontDetails
- renamed (test) fonts/liberation-serif to fonts/liberation
- added a smoke Test for creating a simple document
asturio added a commit that referenced this pull request Mar 2, 2024
- rename check-Method in assert
- Codacy issues fixed
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