Function: arabic-shape-gstring
arabic-shape-gstring is a byte-compiled function defined in
misc-lang.el.gz.
Signature
(arabic-shape-gstring GSTRING DIRECTION)
Source Code
;; Defined in /usr/src/emacs/lisp/language/misc-lang.el.gz
(defun arabic-shape-gstring (gstring direction)
(setq gstring (font-shape-gstring gstring direction))
(condition-case err
(when arabic-shaper-ZWNJ-handling
(let ((font (lgstring-font gstring))
(i 1)
(len (lgstring-glyph-len gstring))
(modified nil))
(while (< i len)
(let ((glyph (lgstring-glyph gstring i)))
(when (eq (lglyph-char glyph) #x200c)
(cond
((eq arabic-shaper-ZWNJ-handling 'as-space)
(if (> (- (lglyph-rbearing glyph) (lglyph-lbearing glyph)) 0)
(let ((space-glyph (aref (font-get-glyphs font 0 1 " ") 0)))
(when space-glyph
(lglyph-set-code glyph (aref space-glyph 3))
(lglyph-set-width glyph (aref space-glyph 4)))))
(lglyph-set-adjustment glyph 0 0 1)
(setq modified t))
((eq arabic-shaper-ZWNJ-handling 'absorb)
(let ((prev (lgstring-glyph gstring (1- i))))
(lglyph-set-from-to prev (lglyph-from prev) (lglyph-to glyph))
(setq gstring (lgstring-remove-glyph gstring i))
(setq len (1- len)))
(setq modified t)))))
(setq i (1+ i)))
(if modified
(lgstring-set-id gstring nil))))
(error (push err arabic-shape-log)))
gstring)