@@ -238,6 +238,60 @@ def X3(self, idx):
238238 elif self .overflow_isolate_count == 0 :
239239 self .overflow_embedding_count += 1
240240
241+ def X4 (self , idx ):
242+ """X4_ implementation:
243+
244+ With each RLO, perform the following steps:
245+
246+ * Compute the least odd embedding level greater than the embedding
247+ level of the last entry on the directional status stack.
248+ * If this new level would be valid, and the overflow isolate count and
249+ overflow embedding count are both zero, then this RLO is valid. Push
250+ an entry consisting of the new embedding level, right-to-left
251+ directional override status, and false directional isolate status
252+ onto the directional status stack.
253+ * Otherwise, this is an overflow RLO. If the overflow isolate count is
254+ zero, increment the overflow embedding count by one. Leave all other
255+ variables unchanged.
256+
257+ .. _X4: http://www.unicode.org/reports/tr9/#X4
258+ """
259+ level = least_greater_odd (self .last_level_entry .embedding_level )
260+
261+ if (level <= MAX_DEPTH and self .overflow_isolate_count == 0
262+ and self .overflow_embedding_count == 0 ):
263+ self .last_level_entry = LevelEntry (level , 'R' , False )
264+ self .levels_stack .append (self .last_level_entry )
265+ elif self .overflow_isolate_count == 0 :
266+ self .overflow_embedding_count += 1
267+
268+ def X5 (self , idx ):
269+ """X5_ implementation:
270+
271+ With each LRO, perform the following steps:
272+
273+ * Compute the least even embedding level greater than the embedding
274+ level of the last entry on the directional status stack.
275+ * If this new level would be valid, and the overflow isolate count and
276+ overflow embedding count are both zero, then this LRO is valid. Push
277+ an entry consisting of the new embedding level, left-to-right
278+ directional override status, and false directional isolate status
279+ onto the directional status stack.
280+ * Otherwise, this is an overflow LRO. If the overflow isolate count is
281+ zero, increment the overflow embedding count by one. Leave all other
282+ variables unchanged.
283+
284+ .. _X5: http://www.unicode.org/reports/tr9/#X5
285+ """
286+ level = least_greater_even (self .last_level_entry .embedding_level )
287+
288+ if (level <= MAX_DEPTH and self .overflow_isolate_count == 0
289+ and self .overflow_embedding_count == 0 ):
290+ self .last_level_entry = LevelEntry (level , 'L' , False )
291+ self .levels_stack .append (self .last_level_entry )
292+ elif self .overflow_isolate_count == 0 :
293+ self .overflow_embedding_count += 1
294+
241295 def explicit_levels_and_directions (self ):
242296
243297 MAPPINGS = {
0 commit comments