Skip to content

Commit

Permalink
handle Unicode grapheme clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
JINMAZUER committed Jul 4, 2024
1 parent c531f87 commit f95df43
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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 @@ -78,7 +78,7 @@ def generate
"<%0#{code_space_size * 2}X><%0#{code_space_size * 2}X>[%s]",
span.first[0],
span.last[0],
span.map { |_, cid| "<#{cid.chr(::Encoding::UTF_16BE).unpack1('H*')}>" }.join(''),
span.map { |_, cid| "<#{cid.map {|c| "#{c.chr(::Encoding::UTF_16BE).unpack1('H*')}"}.join(',')}>" }.join(''),
)
end
# rubocop: enable Lint/FormatParameterMismatch
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/fonts/ttf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def encode_text(text, options = {})
end
end
else
@subsets.encode(text.unpack('U*'))
@subsets.encode(text.each_grapheme_cluster.map(&:codepoints))
end
end

Expand Down

0 comments on commit f95df43

Please sign in to comment.