lilypond-user
[Top][All Lists]
Advanced

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

Re: smallCaps and accented letters


From: Pierre Perol-Schneider
Subject: Re: smallCaps and accented letters
Date: Sat, 21 Dec 2013 11:36:31 +0100

2013/12/20 Yann <address@hidden>

Hello everybody :)

I noticed in a score that I've recently typeset that smallCaps doesn't support accented characters (which is indeed written in the manual).

Is there a plan to extend smallCaps to support accented letters in future versions ?
For now, is there a workaround ?

Hi Yann,

Here's the code I use for years.
As far as I remember, the original code was made by Nicolas Sceaux but it's pretty old now and I could be wrong.

%%%%%%%%%%%%%%%%%%%%%% Snippet %%%%%%%%%%%%%%%%%%%%%%%%
\version "2.17.95"

#(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 (smallCaps 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)))


%%%%%%%%%%%%% %%%%% Examples %%%%%%%%%%%%%%%%%%%%

\markup \smallCaps "A a Á á À à Â â Ä ä Ǎ ǎ Ă ă Ā ā Ã ã Å å Ą ą Æ æ Ǣ ǣ"

\markup \smallCaps "B b"

\markup \smallCaps "C c Ć ć Ĉ ĉ Č č Ç ç"

\markup \smallCaps "D d Ď ď Đ đ Ð ð"

\markup \smallCaps "E e É é È è Ê ê Ë ë Ě ě Ĕ ĕ Ē ē Ę ę Ə ə"

\markup \smallCaps "F f"

\markup \smallCaps "G g Ĝ ĝ Ğ ğ Ģ ģ"

\markup \smallCaps "H h Ĥ ĥ Ħ ħ"

\markup \smallCaps "I i Í í Ì ì Î î Ï ï Ǐ ǐ Ĭ ĭ Ī ī Ĩ ĩ Į į"

\markup \smallCaps "J j Ĵ ĵ"

\markup \smallCaps "K k Ķ ķ"

\markup \smallCaps "L l Ĺ ĺ Ŀ ŀ Ľ ľ Ł ł"

\markup \smallCaps "M m"

\markup \smallCaps "N n Ń ń Ň ň Ñ ñ"

\markup \smallCaps "O o Ó ó Ò ò Ô ô Ö ö Ǒ ǒ Ŏ ŏ Ō ō Õ õ Ǫ ǫ Ő ő Ø ø Œ œ"

\markup \smallCaps "P p"

\markup \smallCaps "Q q"

\markup \smallCaps "R r Ŕ ŕ Ř ř"

\markup \smallCaps "S s Ś ś Ŝ ŝ Š š Ş ş ß"

\markup \smallCaps "T t Ť ť Ţ ţ Þ þ"

\markup \smallCaps "U u Ú ú Ù ù Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ų ų Ǘ ǘ Ǜ ǜ Ǚ ǚ"

\markup \smallCaps "V v"

\markup \smallCaps "W w Ŵ ŵ"

\markup \smallCaps "X x"

\markup \smallCaps "Y y Ý ý Ŷ ŷ Ÿ ÿ Ȳ ȳ"

\markup \smallCaps "Z z Ź ź Ž ž"

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Cheers,

Pierre






reply via email to

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