@@ -170,9 +170,16 @@ def reshape(self, text):
170170 shift_harakat_position = self .configuration .getboolean (
171171 'shift_harakat_position'
172172 )
173+ use_unshaped_instead_of_isolated = self .configuration .getboolean (
174+ 'use_unshaped_instead_of_isolated'
175+ )
173176
174177 positions_harakat = {}
175178
179+ isolated_form = (
180+ use_unshaped_instead_of_isolated and UNSHAPED or ISOLATED
181+ )
182+
176183 for letter in text :
177184 if HARAKAT_RE .match (letter ):
178185 if not delete_harakat :
@@ -192,23 +199,23 @@ def reshape(self, text):
192199 elif letter not in LETTERS :
193200 output .append ((letter , NOT_SUPPORTED ))
194201 elif not output : # first letter
195- output .append ((letter , ISOLATED ))
202+ output .append ((letter , isolated_form ))
196203 else :
197204 previous_letter = output [- 1 ]
198205 if previous_letter [FORM ] == NOT_SUPPORTED :
199- output .append ((letter , ISOLATED ))
206+ output .append ((letter , isolated_form ))
200207 elif not connects_with_letter_before (letter ):
201- output .append ((letter , ISOLATED ))
208+ output .append ((letter , isolated_form ))
202209 elif not connects_with_letter_after (
203210 previous_letter [LETTER ]
204211 ):
205- output .append ((letter , ISOLATED ))
212+ output .append ((letter , isolated_form ))
206213 elif (previous_letter [FORM ] == FINAL and not
207214 connects_with_letters_before_and_after (
208215 previous_letter [LETTER ]
209216 )):
210- output .append ((letter , ISOLATED ))
211- elif previous_letter [FORM ] == ISOLATED :
217+ output .append ((letter , isolated_form ))
218+ elif previous_letter [FORM ] == isolated_form :
212219 output [- 1 ] = (
213220 previous_letter [LETTER ],
214221 INITIAL
@@ -259,13 +266,13 @@ def reshape(self, text):
259266 # | FINAL | FINAL | MEDIAL | MEDIAL | FINAL |
260267 # +-----------+----------+---------+---------+----------+
261268
262- if a_form in (ISOLATED , INITIAL ):
263- if b_form in (ISOLATED , FINAL ):
269+ if a_form in (isolated_form , INITIAL ):
270+ if b_form in (isolated_form , FINAL ):
264271 ligature_form = ISOLATED
265272 else :
266273 ligature_form = INITIAL
267274 else :
268- if b_form in (ISOLATED , FINAL ):
275+ if b_form in (isolated_form , FINAL ):
269276 ligature_form = FINAL
270277 else :
271278 ligature_form = MEDIAL
@@ -279,7 +286,7 @@ def reshape(self, text):
279286 result .extend (positions_harakat [- 1 ])
280287 for i , o in enumerate (output ):
281288 if o [LETTER ]:
282- if o [FORM ] == NOT_SUPPORTED :
289+ if o [FORM ] == NOT_SUPPORTED or o [ FORM ] == UNSHAPED :
283290 result .append (o [LETTER ])
284291 else :
285292 result .append (LETTERS [o [LETTER ]][o [FORM ]])
0 commit comments