Pierre
Septembre 26, 2012, 12:50
1
Cher Tous,
J'utilise souvent SmallCaps pour mes titres.
Pour ajouter les accents, je me sert d'un code (de Nicolas Sceaux si ma mémoire est bonne).
À la base, ce code ne comportait pas tous les accents.
Comme il m'arrive fréquemment de coder des partitions d'origine slave ou espagnole j'ai ajouter un grand nombre d'accents.
Or, il m'arrive de temps à autre de tomber sur des accents qui, combinés, provoque des erreurs.
Trêve de blabla voici un exemple que j'ai limité à trois accents, êẽñ, pour faire plus simple :
\version "2.16.0"
#(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)))
\markup \smallCaps " Tête Tẽte Española"
Résultat : ê apparaît normalement ẽ n'apparaît pas et ñ reste en minuscule.
Si je supprime ẽ du code, tout rentre dans l'ordre :
\version "2.16.0"
#(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)))
\markup \smallCaps " Tête Española"
ê et ñ apparaissent bien en majuscules accentués.
Quelqu'un sait-il pourquoi certains accents produisent ce bug ?
Pierre Perol-Schneider wrote
... ê et ñ...
Bonsoir,
Une table des lettre accentuées n'a-t-elle pas été ajoutée dans la dernière
version ?
Jean-Christophe
···
--
View this message in context: http://lilypond-french-users.1298960.n2.nabble.com/Snippet-Accents-et-SmallCaps-tous-les-accents-tp7578489p7578490.html
Sent from the LilyPond French Users mailing list archive at Nabble.com.
Pierre
Septembre 27, 2012, 9:51
3
Désolé Jean-Christophe je ne comprends pas à quelle table tu fais référence.
Pour v2.16 et v2.17 :
"Note: \smallCaps does not support accented characters."
cf : http://lilypond.org/doc/v2.16/Documentation/notation/font
···
Le 26 septembre 2012 20:18, Jean-Christophe D <****@**** > a écrit :
Pierre Perol-Schneider wrote
... ê et ñ...
Bonsoir,
Une table des lettre accentuées n'a-t-elle pas été ajoutée dans la dernière
version ?
Jean-Christophe
--
View this message in context: http://lilypond-french-users.1298960.n2.nabble.com/Snippet-Accents-et-SmallCaps-tous-les-accents-tp7578489p7578490.html
Sent from the LilyPond French Users mailing list archive at Nabble.com .
liste de diffusion lilypond-user-fr
lilypond-user-fr@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user-fr
Pierre
Septembre 27, 2012, 10:31
4
Voici une liste (exhaustive je l'espère) des caractères dispo et accentués pour le fonte smallCaps :
\version "2.16.0"
#(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)))
\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 Ź ź Ž ž"
Tous les autres caractères posent problèmes.
A priori, tous les caractères majuscules avec un seul point au dessus ou en dessous s'affichent mal et/ou dérangent l'affichage d'autres caractères.
···
Le 27 septembre 2012 11:51, Pierre Perol-Schneider <****@**** > a écrit :
Désolé Jean-Christophe je ne comprends pas à quelle table tu fais référence.
Pour v2.16 et v2.17 :
"Note: \smallCaps does not support accented characters."
cf : http://lilypond.org/doc/v2.16/Documentation/notation/font
Le 26 septembre 2012 20:18, Jean-Christophe D <****@**** > a écrit :
Pierre Perol-Schneider wrote
... ê et ñ...
Bonsoir,
Une table des lettre accentuées n'a-t-elle pas été ajoutée dans la dernière
version ?
Jean-Christophe
--
View this message in context: http://lilypond-french-users.1298960.n2.nabble.com/Snippet-Accents-et-SmallCaps-tous-les-accents-tp7578489p7578490.html
Sent from the LilyPond French Users mailing list archive at Nabble.com .
liste de diffusion lilypond-user-fr
lilypond-user-fr@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user-fr
Pierre Perol-Schneider wrote
Désolé Jean-Christophe je ne comprends pas à quelle table tu fais
référence.
C'est par ici :
Il suffirait peut-être d'y d'ajouter quelques caractères ?
Bonne soirée,
Jean-Christophe
···
--
View this message in context: http://lilypond-french-users.1298960.n2.nabble.com/Snippet-Accents-et-SmallCaps-tous-les-accents-tp7578489p7578493.html
Sent from the LilyPond French Users mailing list archive at Nabble.com.
Pierre
Septembre 28, 2012, 7:23
6
Hélas, je doute que cela soit efficace.
···
Le 27 septembre 2012 19:01, Jean-Christophe D <****@**** > a écrit :
Pierre Perol-Schneider wrote
Désolé Jean-Christophe je ne comprends pas à quelle table tu fais
référence.
C'est par ici :
http://lilypond.org/doc/v2.16/Documentation/notation/list-of-special-characters
Il suffirait peut-être d'y d'ajouter quelques caractères ?
Bonne soirée,
Jean-Christophe
--
View this message in context: http://lilypond-french-users.1298960.n2.nabble.com/Snippet-Accents-et-SmallCaps-tous-les-accents-tp7578489p7578493.html
Sent from the LilyPond French Users mailing list archive at Nabble.com .
liste de diffusion lilypond-user-fr
lilypond-user-fr@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user-fr