Skip to content

Commit b498a80

Browse files
Correct Bidi Arabic Text (#219)
1 parent 79d6a11 commit b498a80

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

trdg/run.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import argparse
2-
import os, errno
2+
import errno
3+
import os
34
import sys
45

56
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
67

78
import random as rnd
89
import string
910
import sys
11+
from multiprocessing import Pool
1012

1113
from tqdm import tqdm
12-
from trdg.string_generator import (
13-
create_strings_from_dict,
14-
create_strings_from_file,
15-
create_strings_from_wikipedia,
16-
create_strings_randomly,
17-
)
18-
from trdg.utils import load_dict, load_fonts
14+
1915
from trdg.data_generator import FakeTextDataGenerator
20-
from multiprocessing import Pool
16+
from trdg.string_generator import (create_strings_from_dict,
17+
create_strings_from_file,
18+
create_strings_from_wikipedia,
19+
create_strings_randomly)
20+
from trdg.utils import load_dict, load_fonts
2121

2222

2323
def margins(margin):
@@ -407,10 +407,11 @@ def main():
407407

408408
if args.language == "ar":
409409
from arabic_reshaper import ArabicReshaper
410+
from bidi.algorithm import get_display
410411

411412
arabic_reshaper = ArabicReshaper()
412413
strings = [
413-
" ".join([arabic_reshaper.reshape(w) for w in s.split(" ")[::-1]])
414+
" ".join([get_display(arabic_reshaper.reshape(w)) for w in s.split(" ")[::-1]])
414415
for s in strings
415416
]
416417
if args.case == "upper":

0 commit comments

Comments
 (0)