lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change color for some symbols in a sylable


From: David Nalesnik
Subject: Re: Change color for some symbols in a sylable
Date: Wed, 11 Jan 2012 20:16:01 -0600

Hi Svetlana,

On Wed, Jan 11, 2012 at 11:04 AM, Christopher R. Maden <address@hidden> wrote:
On 01/11/2012 03:54 AM, Светлана wrote:
> Yeah, this works like I wanted, but there is one problem. The problem
> is called UTF-8. All is fine if you have latin lyrics and symbols to
> color from ANSI encoding. Then if you add cyrillic lyrics - the
> function messes all the letters. If you try to add some cyrillic
> symbols to color - lilypond crashes.
>
> I don't know if Scheme is capable of dealing with Unicode easily and
> if you have any expierience with it, but, please, give it a try. Btw,
> I've checked your first function. It works with cyrillic letters
> correctly (just don't forget to convert the files to UTF-8).

LilyPond is fine with UTF-8 (in fact, requires it), so this piqued my
curiosity.

I think the problem likely lies with the char->integer function; that
seems the most likely to mis-handle UTF-8 characters.

<URL:
http://www.mailinglistarchive.com/address@hidden/msg05363.html >
suggests it may be a Guile bug, or at least a quirk of Guile’s treatment
of strings and characters.


Yes, the problem lies in the fact that the representations of many of the Cyrillic letters are more than one byte in length, and the Guile functions which deal with characters don't appear to accommodate these.

I've come up with a solution to the problem, I think.  (I hope!)

The variable "all-characters" stores every character which can appear in the lyric text.  For testing, I included only those characters which are used in the Russian test of the "Twinkle, twinkle" example.  To work with your chant examples, you will need to extend this list to include all Cyrillic letters, uppercase and lowercase, and any punctuation, numbers, etc. you will need.  This list must include the symbols which will be colored red, too.  It can't include any duplicates, and if something is missing it will also be missing in the transformed text.  I realize this is tedious, but I couldn't think of a better way to "teach" LilyPond the new characters.

The variable "characters-to-color" of course includes your list.

Basically, I scan each unit of text to create a list of position/length data, and use this to break the text into its component strings.  Then I convert these to markups with some characters in red, others in black.  (Of course, you could do other transformations to either of these.)

Let me know if this works as you would like!  If you find any problems, let me know and I'll try to fix them.

If anyone reading this thread knows of a more streamlined approach, please let me know.

Best,
David

   

Attachment: colorize-list-utf02.ly
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]