unidoc / unipdf

Golang PDF library for creating and processing PDF files (pure go)
https://unidoc.io
Other
2.54k stars 250 forks source link

Support for subsetting fonts #335

Closed gunnsth closed 4 years ago

gunnsth commented 4 years ago

Addresses #17.

Reduces test generated PDF files 2_p_nihao.pdf from 6.2MB to 45kB
2_p_multi.pdf from 287kB to 55kB


This change is Reviewable

codecov[bot] commented 4 years ago

Codecov Report

Merging #335 into development will decrease coverage by 5.79%. The diff coverage is 63.30%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #335      +/-   ##
===============================================
- Coverage        62.29%   56.49%   -5.80%     
===============================================
  Files              236      236              
  Lines            45607    45705      +98     
===============================================
- Hits             28412    25823    -2589     
- Misses           16542    16558      +16     
- Partials           653     3324    +2671     
Impacted Files Coverage Δ
model/font_composite.go 61.40% <54.92%> (-8.81%) :arrow_down:
model/font.go 57.43% <71.42%> (-6.99%) :arrow_down:
internal/textencoding/truetype.go 40.00% <83.33%> (+20.00%) :arrow_up:
internal/e2etest/utils.go 60.00% <0.00%> (-20.00%) :arrow_down:
ps/exec.go 62.96% <0.00%> (-18.52%) :arrow_down:
model/optimize/image_ppi.go 58.46% <0.00%> (-16.93%) :arrow_down:
core/security/handlers.go 33.33% <0.00%> (-16.67%) :arrow_down:
internal/jbig2/document/segments/region.go 63.38% <0.00%> (-15.50%) :arrow_down:
internal/endian/endianness.go 38.46% <0.00%> (-15.39%) :arrow_down:
model/signature_handler.go 55.85% <0.00%> (-15.32%) :arrow_down:
... and 148 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f445a10...5583b4b. Read the comment docs.

gunnsth commented 4 years ago

@adrg Thanks for the comments. I updated slightly adding a method on the creator to mark the font for subsetting. This way is easier for the user, higher level method and does not need to worry about calling it right before writing. Can just do it right after loading.