From b5623270b6047528786d4550cebe0b228ecadb6b Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Thu, 12 Sep 2013 23:45:28 +0900 Subject: [PATCH] composite.el (compose-gstring-for-graphic): Handle enclosing mark. --- lisp/ChangeLog | 5 +++++ lisp/composite.el | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e919a8407ec..324cefe7ed6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-09-12 Kenichi Handa + + * composite.el (compose-gstring-for-graphic): Handle enclosing + mark. + 2013-09-08 Kenichi Handa * international/characters.el: Set category "^" (Combining) for 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) -- 2.39.2