Hi David,
Here is the .ly file that generates the png file in previous email. This file
is UTF-8 encoded.
Thank for looking the solution,
Ming.
>________________________________
> From: David Nalesnik <david.nales...@gmail.com>
>To: MING TSANG <tsan...@rogers.com>
>Cc: "lilypond-user@gnu.org" <lilypond-user@gnu.org>
>Sent: Thursday, May 2, 2013 7:43:09 PM
>Subject: Re: Lyrics and Punctuations Alignment Issue?
>
>
>
>Hi Ming,
>
>
>
>On Thu, May 2, 2013 at 6:04 PM, MING TSANG <tsan...@rogers.com> wrote:
>
>Hi David:
>>
>>
>>Thank you for the align grob.
>>
>>
>>The chinese character is double byte. Please refer to lyric d & f :
>>correspondent Chinese character to d is ok but the Chinese character at f is
>>off a bit. Is it possible to make f the same as d? The difference at d the
>>'," is single byte while at f the "o" is double byte.
>>
>>
>>Thank you for your help.
>>Ming.
>
>
>I've worked with multiple byte characters before (with difficulty), and I
>think I could help. The way I dealt with them was to create a list of
>characters to recognize. (For reference:
>http://www.mail-archive.com/lilypond-user@gnu.org/msg68583/example_%284%29.ly)
> The method isn't pretty**
>
>
>In order for me to help, though, I'll need to see the file that created your
>image. What are the UTF-8 encodings of the special punctuation characters?
>
>
>**At one point, I was referred to the functions documented at
>http://www.gnu.org/software/guile-gnome/docs/glib/html/Unicode-Manipulation.html#Unicode-Manipulation,
> which look like they would ease working with such characters. However, I was
>never able to figure out how to get these functions available to LilyPond.
>Does anyone reading this know how it would be done?
>
>
>Thanks,
>David
>
>
>
>
\version "2.16"
#(define (align grob)
(let* ((stil (ly:grob-property grob 'stencil))
(stil-X (ly:stencil-extent stil X))
(text (ly:grob-property grob 'text))
(punct-R (char-set #\, #\" #\; #\! #\. #\space))
(punct-L (char-set #\"))
; determine X-extent of text stencil without punctuation at end
(text-L (string-trim-right text punct-R))
(text-L-stil (grob-interpret-markup grob text-L))
(text-L-stil-X (ly:stencil-extent text-L-stil X))
(displacement (/ (- (cdr text-L-stil-X) (cdr stil-X)) 2))
; determine X-extent of text stencil without punctuation at start
(text-R (string-trim text punct-L))
(text-R-stil (grob-interpret-markup grob text-R))
(text-R-stil-X (ly:stencil-extent text-R-stil X))
(displacement (+ displacement
(/ (- (cdr stil-X) (cdr text-R-stil-X)) 2))))
(- (ly:self-alignment-interface::aligned-on-x-parent grob)
displacement)))
\paper {
ragged-right = ##f
}
\relative c' {
\time 3/4 e4 e4. e8
d4 e d c2.
}
\addlyrics {
\override LyricText #'X-offset = #align
"\"I" am so lone -- "ly,\"" said she
}
\addlyrics {
\override LyricText #'X-offset = #align
æ¨ç¡ 極! 寶 å, è² åã å?
}
\addlyrics {
\override LyricText #'X-offset = #align
a b c d e f g
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user