code (encode-char char charset)))
(setq code char))
(cond
- ;; Append a PDF character to directional embeddings and
- ;; overrides, to prevent potential messup of the following
- ;; text.
- ((memq char '(?\x202a ?\x202b ?\x202d ?\x202e))
+ ;; Append a PDF character to left-to-right directional
+ ;; embeddings and overrides, to prevent potential messup of the
+ ;; following text.
+ ((memq char '(?\x202a ?\x202d))
(setq char-description
(concat char-description
(propertize (string ?\x202c) 'invisible t))))
+ ;; Append a PDF character followed by LRM to right-to-left
+ ;; directional embeddings and overrides, to prevent potential
+ ;; messup of the following numerical text.
+ ((memq char '(?\x202b ?\x202e))
+ (setq char-description
+ (concat char-description
+ (propertize (string ?\x202c ?\x200e) 'invisible t))))
;; Append a LRM character to any strong character to avoid
;; messing up the numerical codepoint.
((memq (get-char-code-property char 'bidi-class) '(R AL))
(interactive "P")
(let* ((char (following-char))
(bidi-fixer
- (cond ((memq char '(?\x202a ?\x202b ?\x202d ?\x202e))
- ;; If the character is one of LRE, LRO, RLE, RLO, it
- ;; will start a directional embedding, which could
- ;; completely disrupt the rest of the line (e.g., RLO
- ;; will display the rest of the line right-to-left).
- ;; So we put an invisible PDF character after these
- ;; characters, to end the embedding, which eliminates
- ;; any effects on the rest of the line.
+ ;; If the character is one of LRE, LRO, RLE, RLO, it will
+ ;; start a directional embedding, which could completely
+ ;; disrupt the rest of the line (e.g., RLO will display the
+ ;; rest of the line right-to-left). So we put an invisible
+ ;; PDF character after these characters, to end the
+ ;; embedding, which eliminates any effects on the rest of
+ ;; the line. For RLE and RLO we also append an invisible
+ ;; LRM, to avoid reordering the following numerical
+ ;; characters.
+ (cond ((memq char '(?\x202a ?\x202d))
(propertize (string ?\x202c) 'invisible t))
+ ((memq char '(?\x202b ?\x202e))
+ (propertize (string ?\x202c ?\x200e) 'invisible t))
;; Strong right-to-left characters cause reordering of
;; the following numerical characters which show the
;; codepoint, so append LRM to countermand that.
}
else
{
- /* LRI, RLI, and FSI increment, and PDF decrements, the
- embedding level of the _following_ characters, so we must
- first look at the type of the previous character to support
- that. */
+ /* LRI, RLI, and FSI increment, and PDF decrements, the
+ embedding level of the _following_ characters, so we must
+ first look at the type of the previous character to support
+ that. */
switch (prev_type)
{
case RLI: /* X5a */
{
int bob = ((bidi_it->string.s || STRINGP (bidi_it->string.lstring))
? 0 : 1);
- bidi_type_t prev_type = bidi_it->prev.type;
+ bidi_type_t prev_type = bidi_it->type;
bidi_type_t type_for_neutral = bidi_it->next_for_neutral.type;
ptrdiff_t pos_for_neutral = bidi_it->next_for_neutral.charpos;
&& bidi_explicit_dir_char (bidi_it->ch)
&& type_for_neutral != UNKNOWN_BT
&& bidi_it->charpos < pos_for_neutral)
- type = prev_type;
+ {
+ type = prev_type;
+ eassert (type != UNKNOWN_BT);
+ }
}
else
type = UNKNOWN_BT;