sz5000 opened a new pull request, #446:
URL: https://github.com/apache/pdfbox/pull/446

   ## Summary
   
   Extends `TTFSubsetter` with two new public methods that allow callers to 
inject custom cmap
   subtables into the subset TTF. This enables correct re-subsetting of 
TrueType fonts that use
   non-Unicode cmap encodings — in particular fonts produced by Ghostscript 
with `TT_BIAS=0xF000`,
   where the Mac Roman cmap (platform 1, encoding 0) is the primary rendering 
cmap used by viewers.
   
   Fixes PDFBOX-XXXXX.
   
   ---
   
   ## Changes
   
   **`TTFSubsetter.java`**
   
   - New field `customCmapEntries` — accumulates entries added via the new API
   - `buildCmapTable()` extended:
     - now produces output even when `uniToGID` is empty (i.e. when only 
`addGlyphIds()` was used)
     - writes one Format 4 subtable per distinct `(platformId, 
platformEncodingId)` pair
     - GIDs are translated to renumbered subset GIDs via the existing 
`getNewGlyphId()` mechanism
   - New private helpers `buildFormat4Subtable()` and 
`buildFormat4SubtableNewGids()` extracted
     from the previous monolithic `buildCmapTable()` implementation
   - New public method `addCustomCmapEntry(platformId, platformEncodingId, 
charCode, gid)`
   - New public method `addCustomCmap(platformId, platformEncodingId, 
Map<Integer,Integer> codeToGid)`
   - Javadoc added for `addGlyphIds()` (previously undocumented)
   
   ---
   
   ## Backwards Compatibility
   
   Fully backwards-compatible. Callers that do not use the new API get 
identical behaviour to
   the previous implementation.
   
   ---
   
   ## Testing
   
   Verified against PDFs produced by Ghostscript 10.x containing Thai and other 
non-Latin scripts
   subsetted with `TT_BIAS=0xF000`. Before this change, re-subsetting such 
fonts produced a TTF
   with a broken or missing Mac Roman cmap, causing viewers to render blank 
glyphs. After this
   change, both the Mac Roman and Windows Symbol subtables are correctly 
preserved in the subset,
   and glyph rendering is identical to the original.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to