Wouldn't it be simpler to simply use a font that has old style figures? Shane
On Wed, Mar 14, 2012 at 4:32 AM, Jan-Peter Voigt <[email protected]> wrote: > Hi Ben, > > the problem is, that these markup-command allow a markup as argument, but > they are expecting strings to process. > So if you redefine the markup-command: > --snip-- > #(define-markup-command (oldStyleNum layout props str) (string-or-symbol?) > "Old-style numerals" > (if (symbol? str)(set! str (chain-assoc-get str props ""))) > (interpret-markup layout props (to-old-style str))) > --snip-- > and then use > --snip-- > \oldStyleNum #'page:page-number-string > --snip-- > in your header/footer-markup, it will process either the string or what is > in the named property, #'page:page-number-string in this case. > This redefined markup-command expects a string or a string in the named > property. So this won't work for e.g. line-width, which is a number. > > If you only want to make old-style page-numbers, this might do the trick. If > you need more, there has to be done a bit more. > > HTH > cheers, > Jan-Peter > > > > On 13.03.2012 15:34, Benjamin Bloomfield wrote: >> >> I am trying to figure out how I can get Old Style numerals to be used for >> the >> page numbers. I found some scheme code here >> (http://www.mrlauer.org/music/) >> that defines a markup command oldStyleNum that will replace any digit with >> the >> unicode string for the appropriate old style numeral. However, I don't >> know how >> to make this work with the page number, because when I try to put >> \oldStyleNum\fromproperty #'page:page-number-string the oldStyleNum >> command >> isn't getting the numeric string to process, but something else, and I >> don't >> really know scheme at all, and haven't been able to figure this out after >> looking at it for a few hours, and I thought someone else might know. >> >> What follows is sample code that shows old style numerals in the title and >> (unfortunately) regular numerals for the page number. >> >> Thanks, >> >> Ben >> --------------------- >> \version "2.14.2" >> % Michael's utilities >> %% UTF-8 utilities >> #(define (utf-8->list str) >> (define (numBytes leader) >> (cond ((< leader #x80) 1) >> ((< leader #xc0) (begin (stderr "programming-error: bad >> utf- >> 8:~x\n" leader) 1)) >> ((< leader #xe0) 2) >> ((< leader #xf0) 3) >> ((< leader #xf8) 4) >> (else (begin (stderr "programming-error: utf-8 too >> big:~x\n" >> leader) 1)))) >> (define (helper start l n) >> (if (= n 0) start >> (helper (+ (* start #x40) (modulo (car l) #x40)) (cdr l) >> (- n >> 1)))) >> (define (utf-8->int l) >> (let* ((leader (car l)) >> (n (- (numBytes leader) 1)) >> (fac (/ #x80 (expt 2 n))) >> (rest (cdr l)) >> (result (helper (modulo leader fac) rest n))) >> result)) >> (define (toListHelper lst chars) >> (if (null? lst) (reverse chars) >> (let* ((c (utf-8->int lst)) >> (n (numBytes (car lst))) >> (t (list-tail lst n)) >> (newC (cons c chars))) >> (toListHelper t newC)))) >> (toListHelper (map char->integer (string->list str)) '() )) >> >> %These are appropriate for Junicode, and other fonts. Override as >> necessary >> oldStyleZeroCode = ##xF730 >> smallCapsACode = ##xF761 >> >> %For Linux Libertine >> oldStyleZeroCodeLL = ##xE01A >> smallCapsACodeLL = ##xE051 >> >> #(define (change-char-helper aa test? offset) >> (if (string? aa) >> (let* ((chars (utf-8->list aa)) >> (tosc (map (lambda (c) >> (if (and (<= c 127) (test? (integer->char >> c))) >> (ly:wide-char->utf-8 (+ c offset)) >> (if (and (<= c 255) (>= c 224)) >> (ly:wide-char->utf-8 (+ c offset)) >> (if (= c #x0153) >> (ly:wide-char->utf-8 #xF6FA) >> (ly:wide-char->utf-8 c) ) ) ) ) >> chars)) >> (newStr (apply string-append tosc))) >> newStr) >> aa) >> ) >> >> #(define (to-old-style str) (change-char-helper str char-numeric? >> (- oldStyleZeroCode (char->integer #\0)))) >> >> #(define (to-small-caps str) (change-char-helper str char-lower-case? >> (- smallCapsACode (char->integer #\a)))) >> >> #(define-markup-command (realCaps layout props str) (markup?) >> "Real small capitals" >> (interpret-markup layout props (to-small-caps str))) >> >> #(define-markup-command (oldStyleNum layout props str) (markup?) >> "Old-style numerals" >> (interpret-markup layout props (to-old-style str))) >> >> #(define-markup-command (smallCapsOldStyle layout props str) (markup?) >> "Real small caps and old-style numerals" >> (interpret-markup layout props (to-old-style (to-small-caps str)))) >> >> %%% >> #(define-public (bar-number-print grob) >> "Print function for making oldStyle numbers. Useful for BarNumber, for >> example" >> (let* >> ((text (ly:grob-property grob 'text)) >> (layout (ly:grob-layout grob)) >> (defs (ly:output-def-lookup layout 'text-font-defaults)) >> (props (ly:grob-alist-chain grob defs))) >> >> (ly:text-interface::interpret-markup layout >> props >> (if (string? text) >> (markup #:oldStyleNum text) >> text)))) >> \header { >> title = \markup{\oldStyleNum"1234567890" "1234567890"} >> } >> \paper { >> two-sided = ##t >> print-first-page-number = ##t >> oddHeaderMarkup = \markup\fill-line{ >> \combine >> \fill-line{"" \on-the-fly #print-page-number-check-first >> \oldStyleNum\fromproperty #'page:page-number-string >> } >> "" >> } >> evenHeaderMarkup = \markup { >> \combine >> \on-the-fly #print-page-number-check-first >> \oldStyleNum\fromproperty #'page:page-number-string >> "" >> } >> } >> >> {c'4} >> >> >> _______________________________________________ >> lilypond-user mailing list >> [email protected] >> https://lists.gnu.org/mailman/listinfo/lilypond-user >> > > > _______________________________________________ > lilypond-user mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/lilypond-user _______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
