Skip to content

Commit d40d09d

Browse files
MystMyst
authored andcommitted
RTL recognition fixed
1 parent 7b48c9f commit d40d09d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
Change log v.0.1.6
66

7-
**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).
7+
**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).
8+
9+
**fix**: RTL recognition did not reverse brackets, it should now correctly perform brackets reversal for any of the following: (,),[,],{,},<,>.
810

911
**update**: updated license to MIT.
1012

lib/combine_pdf/combine_pdf_basic_writer.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ def encode text, fonts
403403
# ...still, it works (I think).
404404
def reorder_rtl_content text
405405
rtl_characters = "\u05d0-\u05ea\u05f0-\u05f4\u0600-\u06ff\u0750-\u077f"
406+
rtl_replaces = { '(' => ')', ')' => '(',
407+
'[' => ']', ']'=>'[',
408+
'{' => '}', '}'=>'{',
409+
'<' => '>', '>'=>'<',
410+
}
406411
return text unless text =~ /[#{rtl_characters}]/
407412

408413
out = []
@@ -415,6 +420,8 @@ def reorder_rtl_content text
415420
white_space_to_move = scanner.matched.match(/[\s]+$/).to_s
416421
out.unshift scanner.matched[0..-1-white_space_to_move.length]
417422
out.unshift white_space_to_move
423+
elsif scanner.matched.match /^[\(\)\[\]\{\}\<\>]$/
424+
out.unshift rtl_replaces[scanner.matched]
418425
else
419426
out.unshift scanner.matched
420427
end

0 commit comments

Comments
 (0)