Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/prawn/fonts/to_unicode_cmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def mapping_spans(mapping)
discontinuous_slices
.flatten(1) # Join together
.slice_when { |a, b| (b[0] - a[0]) != 1 } # Slice at key discontinuity, again
.map { |span| span.length > 1 ? [:index_sorted, span] : [:short, slice] } +
.map { |span| span.length > 1 ? [:index_sorted, span] : [:short, span] } +
continuous_slices.map { |span| [:fully_sorted, span] }
end
} # rubocop: disable Style/MultilineBlockChain
Expand Down
9 changes: 8 additions & 1 deletion spec/prawn/fonts/to_unicode_cmap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
expect(cmap).to include("beginbfrange\n<20><22><0030>\n")
end

it 'uses ranges for continuous code rnages with non-continuous mappings' do
it 'uses ranges for continuous code ranges with non-continuous mappings' do
cmap = described_class.new(0x20 => 0x32, 0x21 => 0x31, 0x22 => 0x30).generate

expect(cmap).to include("beginbfrange\n<20><22>[<0032><0031><0030>]\n")
Expand All @@ -82,6 +82,13 @@
expect(cmap).to include("beginbfchar\n<30><0040>\n")
end

it 'splits mappings to continuous and non-coninuous code ranges' do
cmap = described_class.new(0x20 => 0x30, 0x21 => 0x31, 0x22 => 0x33).generate

expect(cmap).to include("beginbfrange\n<20><21><0030>\n")
expect(cmap).to include("beginbfchar\n<22><0033>\n")
end

it 'splits continuous mappings into groups of 100' do
mapping = (1..142).flat_map { |n| Array.new(3) { |i| [(n * 10) + i, (n * 10) + i] } }.to_h
cmap = described_class.new(mapping).generate
Expand Down
Loading