summaryrefslogtreecommitdiff
path: root/lisp/composite.el
diff options
context:
space:
mode:
authorKenichi Handa <handa@gnu.org>2013-09-12 23:45:28 +0900
committerKenichi Handa <handa@gnu.org>2013-09-12 23:45:28 +0900
commitb5623270b6047528786d4550cebe0b228ecadb6b (patch)
tree82fcf676e96970342851e6f62b9699e719cb073e /lisp/composite.el
parent3aff2f57cc348b90c0f8b5926027cd0f0f378070 (diff)
downloademacs-b5623270b6047528786d4550cebe0b228ecadb6b.tar.gz
composite.el (compose-gstring-for-graphic): Handle enclosing mark.
Diffstat (limited to 'lisp/composite.el')
-rw-r--r--lisp/composite.el40
1 files changed, 39 insertions, 1 deletions
diff --git a/lisp/composite.el b/lisp/composite.el
index 3c25b8b60af..e0585f80880 100644
--- a/lisp/composite.el
+++ b/lisp/composite.el
@@ -555,7 +555,11 @@ All non-spacing characters have this function in
(rbearing (lglyph-rbearing glyph))
(lbearing (lglyph-lbearing glyph))
(center (/ (+ lbearing rbearing) 2))
+ ;; Artificial vertical gap between the glyphs.
(gap (round (* (font-get (lgstring-font gstring) :size) 0.1))))
+ (if (= gap 0)
+ ;; Assure at least 1 pixel vertical gap.
+ (setq gap 1))
(dotimes (i nchars)
(setq glyph (lgstring-glyph gstring i))
(when (> i 0)
@@ -566,8 +570,10 @@ All non-spacing characters have this function in
(as (lglyph-ascent glyph))
(de (lglyph-descent glyph))
(ce (/ (+ lb rb) 2))
+ (w (lglyph-width glyph))
xoff yoff)
- (when (and class (>= class 200) (<= class 240))
+ (cond
+ ((and class (>= class 200) (<= class 240))
(setq xoff 0 yoff 0)
(cond
((= class 200)
@@ -621,6 +627,38 @@ All non-spacing characters have this function in
rb (+ lb xoff)
as (- as yoff)
de (+ de yoff)))
+ ((and (= class 0)
+ (eq (get-char-code-property (lglyph-char glyph)
+ 'general-category) 'Me))
+ ;; Artificially layouting glyphs in an enclosing
+ ;; mark is difficult. All we can do is to adjust
+ ;; the x-offset and width of the base glyph to
+ ;; align it at the center of the glyph of the
+ ;; enclosing mark hoping that the enclosing mark
+ ;; is big enough. We also have to adjust the
+ ;; x-offset and width of the mark ifself properly
+ ;; depending on how the glyph is designed
+
+ ;; (non-spacing or not). For instance, when we
+ ;; have these glyphs:
+ ;; X position |
+ ;; base: <-*-> lbearing=0 rbearing=5 width=5
+ ;; mark: <----------.> lb=-11 rb=2 w=0
+ ;; we get a correct layout by moving them as this:
+ ;; base: <-*-> XOFF=4 WAD=9
+ ;; mark: <----------.> xoff=2 wad=4
+ ;; we have moved the base to the left by 4-pixel
+ ;; and make its width 9-pixel, then move the mark
+ ;; to the left 2-pixel and make its width 4-pixel.
+ (let* (;; Adjustment for the base glyph
+ (XOFF (/ (- rb lb width) 2))
+ (WAD (+ width XOFF))
+ ;; Adjustment for the enclosing mark glyph
+ (xoff (- (+ lb WAD)))
+ (wad (- rb lb WAD)))
+ (lglyph-set-adjustment glyph xoff 0 wad)
+ (setq glyph (lgstring-glyph gstring 0))
+ (lglyph-set-adjustment glyph XOFF 0 WAD))))
(if (< ascent as)
(setq ascent as))
(if (< descent de)