Skip to content

Commit

Permalink
RTL recognition fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Myst authored and Myst committed Oct 26, 2014
1 parent 7b48c9f commit d40d09d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

Change log v.0.1.6

**Fix**: added Mutex to font library (which was shared by all PDFWriter objects) - now fonts are thread safe (PDF objects are NOT thread safe by design).
**fix**: added Mutex to font library (which was shared by all PDFWriter objects) - now fonts are thread safe (PDF objects are NOT thread safe by design).

**fix**: RTL recognition did not reverse brackets, it should now correctly perform brackets reversal for any of the following: (,),[,],{,},<,>.

**update**: updated license to MIT.

Expand Down
7 changes: 7 additions & 0 deletions lib/combine_pdf/combine_pdf_basic_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ def encode text, fonts
# ...still, it works (I think).
def reorder_rtl_content text
rtl_characters = "\u05d0-\u05ea\u05f0-\u05f4\u0600-\u06ff\u0750-\u077f"
rtl_replaces = { '(' => ')', ')' => '(',
'[' => ']', ']'=>'[',
'{' => '}', '}'=>'{',
'<' => '>', '>'=>'<',
}
return text unless text =~ /[#{rtl_characters}]/

out = []
Expand All @@ -415,6 +420,8 @@ def reorder_rtl_content text
white_space_to_move = scanner.matched.match(/[\s]+$/).to_s
out.unshift scanner.matched[0..-1-white_space_to_move.length]
out.unshift white_space_to_move
elsif scanner.matched.match /^[\(\)\[\]\{\}\<\>]$/
out.unshift rtl_replaces[scanner.matched]
else
out.unshift scanner.matched
end
Expand Down

0 comments on commit d40d09d

Please sign in to comment.