Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudlevy committed Sep 24, 2021
1 parent 76932c8 commit 5c3d4e0
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 8 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.4'


gem 'ttfunk', '1.5.1' # https://github.com/prawnpdf/prawn/issues/1144
gem 'prawn'
gem 'prawn-svg'
gem 'front_matter_parser'
11 changes: 5 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ GEM
css_parser (1.10.0)
addressable
front_matter_parser (1.0.1)
pdf-core (0.7.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
pdf-core (0.9.0)
prawn (2.4.0)
pdf-core (~> 0.9.0)
ttfunk (~> 1.7)
prawn-svg (0.32.0)
css_parser (~> 1.6)
prawn (>= 0.11.1, < 3)
rexml (~> 3.2)
public_suffix (4.0.6)
rexml (3.2.5)
ttfunk (1.5.0)
ttfunk (1.7.0)

PLATFORMS
ruby
Expand All @@ -25,7 +25,6 @@ DEPENDENCIES
front_matter_parser
prawn
prawn-svg
ttfunk (= 1.5)

RUBY VERSION
ruby 2.7.4p191
Expand Down
1 change: 1 addition & 0 deletions build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'prawn-svg'
require 'prawn/measurement_extensions'
require 'front_matter_parser'
require './fix.rb'

serif = 'fonts/Signifier-Regular.otf'
sans = 'fonts/Söhne-Buch.otf'
Expand Down
43 changes: 43 additions & 0 deletions fix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# https://github.com/prawnpdf/prawn/issues/1203
module TTFunk
class Table
class Cff < TTFunk::Table
class Charset < TTFunk::SubTable
def encode(mapping)
# no offset means no charset was specified (i.e. we're supposed to
# use a predefined charset) so there's nothing to encode
return '' unless offset

sids = mapping.keys.sort.map { |new_gid| sid_for(mapping[new_gid]) }
sids.delete(0) #.notdef should not be encoded
ranges = TTFunk::BinUtils.rangify(sids)
range_max = ranges.map(&:last).max

range_bytes =
if range_max.positive?
(Math.log2(range_max) / 8).floor + 1
else
# for cases when there are no sequences at all
Float::INFINITY
end

# calculate whether storing the charset as a series of ranges is
# more efficient (i.e. takes up less space) vs storing it as an
# array of SID values
total_range_size = (2 * ranges.size) + (range_bytes * ranges.size)
total_array_size = sids.size * element_width(:array_format)

#if total_array_size <= total_range_size
([format_int(:array_format)] + sids).pack('Cn*')
#else
# fmt = range_bytes == 1 ? :range_format8 : :range_format16
# element_fmt = element_format(fmt)
# result = [format_int(fmt)].pack('C')
# ranges.each { |range| result << range.pack(element_fmt) }
# result
#end
end
end
end
end
end
Binary file modified pdfs/noesya-aup-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-cgv-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-dcp-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-ep-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-gisi-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-ofp-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-onp-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-ppdp-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-ppp-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-rap-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-rmp-1.0.pdf
Binary file not shown.
Binary file modified pdfs/noesya-wcp-1.0.pdf
Binary file not shown.

0 comments on commit 5c3d4e0

Please sign in to comment.