lilypond-user
[Top][All Lists]
Advanced

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

Re: \caps with Umlaut


From: Pierre Perol-Schneider
Subject: Re: \caps with Umlaut
Date: Thu, 21 Jul 2016 10:10:11 +0200

Hi Jonathan,

As a workaround you can use :

\version "2.19.22"

\markup\concat{ B \fontsize #-2 ARTHOLOMÄUS }

However, in the past I used a fairly old code, slightly adapted here :

 \version "2.19.45"

%% original code by N. Sceaux
#(use-modules (ice-9 regex))
#(define-public string-upper-case #f)
#(define accented-char-upper-case? #f)
#(define accented-char-lower-case? #f)
#(let ((lower-case-accented-string "áàâäǎăāãåąæǣćĉčçďđðéèêëěĕēęəĝğģĥħíìîïǐĭīĩįĵķĺŀľļłńňñóòôöǒŏōõǫőøœŕřśŝšşťţþúùûüǔŭūųǘǜǚŵýŷÿȳźž") 
       (upper-case-accented-string "ÁÀÂÄǍĂĀÃÅĄÆǢĆĈČÇĎĐÐÉÈÊËĚĔĒĘƏĜĞĢĤĦÍÌÎÏǏĬĪĨĮĴĶĹĿĽĻŁŃŇÑÓÒÔÖǑŎŌÕǪŐØŒŔŘŚŜŠŞŤŢÞÚÙÛÜǓŬŪŲǗǛǙŴÝŶŸȲŹŽ"))
   (define (group-by-2 chars result) 
      (if (or (null? chars) (null? (cdr chars)))
          (reverse! result)
          (group-by-2 (cddr chars)
                      (cons (string (car chars) (cadr chars))
                            result))))
   (let ((lower-case-accented-chars
          (group-by-2 (string->list lower-case-accented-string) (list)))
         (upper-case-accented-chars
          (group-by-2 (string->list upper-case-accented-string) (list))))
     (set! string-upper-case
           (lambda (str)
             (define (replace-chars str froms tos)
               (if (null? froms)
                   str
                   (replace-chars (regexp-substitute/global #f (car froms) str
                                                            'pre (car tos) 'post)
                                  (cdr froms)
                                  (cdr tos))))
             (string-upcase (replace-chars str
                                           lower-case-accented-chars
                                           upper-case-accented-chars))))
     (set! accented-char-upper-case?
           (lambda (char1 char2)
             (member (string char1 char2) upper-case-accented-chars string=?)))
     (set! accented-char-lower-case?
           (lambda (char1 char2)
             (member (string char1 char2) lower-case-accented-chars string=?)))))
#(define-markup-command (caps layout props text) (markup?)
  (define (string-list->markup strings lower)
    (let ((final-string (string-upper-case
                         (apply string-append (reverse strings)))))
      (if lower
          (markup #:fontsize -2 final-string)
          final-string)))
  (define (make-small-caps rest-chars currents current-is-lower prev-result)
    (if (null? rest-chars)
        (make-concat-markup (reverse! (cons (string-list->markup
                                              currents current-is-lower)
                                            prev-result)))
        (let* ((ch1 (car rest-chars))
               (ch2 (and (not (null? (cdr rest-chars))) (cadr rest-chars)))
               (this-char-string (string ch1))
               (is-lower (char-lower-case? ch1))
               (next-rest-chars (cdr rest-chars)))
          (cond ((and ch2 (accented-char-lower-case? ch1 ch2))
                 (set! this-char-string (string ch1 ch2))
                 (set! is-lower #t)
                 (set! next-rest-chars (cddr rest-chars)))
                ((and ch2 (accented-char-upper-case? ch1 ch2))
                 (set! this-char-string (string ch1 ch2))
                 (set! is-lower #f)
                 (set! next-rest-chars (cddr rest-chars))))
          (if (or (and current-is-lower is-lower)
                  (and (not current-is-lower) (not is-lower)))
              (make-small-caps next-rest-chars
                               (cons this-char-string currents)
                               is-lower
                               prev-result)
              (make-small-caps next-rest-chars
                               (list this-char-string)
                               is-lower
                               (if (null? currents)
                                   prev-result
                                   (cons (string-list->markup
                                            currents current-is-lower)
                                         prev-result)))))))
  (interpret-markup layout props
    (if (string? text)
        (make-small-caps (string->list text) (list) #f (list))
        text)))

%%Tests:       
\markup \caps "A a Á á À à Â â Ä ä Ǎ ǎ Ă ă Ā ā Ã ã Å å Ą ą Æ æ Ǣ ǣ"  
\markup \caps "B b"
\markup \caps "C c Ć ć Ĉ ĉ Č č Ç ç" 
\markup \caps "D d Ď ď Đ đ Ð ð"
\markup \caps "E e É é È è Ê ê Ë ë Ě ě Ĕ ĕ Ē ē Ę ę Ə ə"
\markup \caps "F f"
\markup \caps "G g Ĝ ĝ Ğ ğ Ģ ģ"
\markup \caps "H h Ĥ ĥ Ħ ħ"
\markup \caps "I i Í í Ì ì Î î Ï ï Ǐ ǐ Ĭ ĭ Ī ī Ĩ ĩ Į į"
\markup \caps "J j Ĵ ĵ"  
\markup \caps "K k Ķ ķ"
\markup \caps "L l Ĺ ĺ Ŀ ŀ Ľ ľ Ł ł"
\markup \caps "M m"
\markup \caps "N n Ń ń Ň ň Ñ ñ"  
\markup \caps "O o Ó ó Ò ò Ô ô Ö ö Ǒ ǒ Ŏ ŏ Ō ō Õ õ Ǫ ǫ Ő ő Ø ø Œ œ"
\markup \caps "P p"
\markup \caps "Q q"
\markup \caps "R r Ŕ ŕ Ř ř" 
\markup \caps "S s Ś ś Ŝ ŝ Š š Ş ş ß"
\markup \caps "T t Ť ť Ţ ţ Þ þ"
\markup \caps "U u Ú ú Ù ù Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ų ų Ǘ ǘ Ǜ ǜ Ǚ ǚ"  
\markup \caps "V v"  
\markup \caps "W w Ŵ ŵ"
\markup \caps "X x"
\markup \caps "Y y Ý ý Ŷ ŷ Ÿ ÿ Ȳ ȳ"
\markup \caps "Z z Ź ź Ž ž"

HTH,
Pierre

2016-07-20 23:01 GMT+02:00 Jonathan Scholbach <address@hidden>:
Dear ponders,

I am using \caps in a \markup which prints the name of the composer.
After having set a couple of pieces today it's the first time the
composer's name contains an umlaut (in this case an ä). And that was
when I found out, that \caps, as well as \smallCaps, "does not support
accented character" (quoted from
http://lilypond.org/doc/v2.19/Documentation/notation/font) - the ä - is
printed as a lowercase letter.

The ME is:

\version "2.19.22"

\markup{ \caps Bartholomäus }

How can I solve this problem? I mean, how can I achieve that \caps works
properly with umlauts and uses the uppercase umlaut?

Your advice is very much appreciated,

Jonathan



_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user


reply via email to

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