[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: changing the font of moderntab clef
From: |
Thomas Morley |
Subject: |
Re: changing the font of moderntab clef |
Date: |
Tue, 3 Sep 2013 16:04:48 +0200 |
2013/9/3 Rachael Thomas Carlson <address@hidden>:
> Hello All:
>
> I am working on emulating a music publisher and this publisher uses what we
> would consider a moderntab clef but with a serif font not the sans-serif
> that we use. I have tried a bunch of different ways of changing the font
> but I can't seem to get it. Also, I looked in the code to try to find where
> the font was chosen but to no avail.
>
> How can one change the font of the moderntab clef from sans-serif to serif?
>
> Thank you,
> Rachael
Hi Rachael,
I'm in a hurry: For now a first sketch.
\version "2.16.2"
%% -> tablature.scm
%% define tab-Clefs as a markup:
#(define-markup-command (customTabClefII
layout props num-strings staff-space)
(integer? number?)
#:category music
"Draw a tab clef sans-serif style."
(define (square x) (* x x))
(let* ((scale-factor (/ staff-space 1.5))
(font-size (- (* num-strings 1.5 scale-factor) 7))
(base-skip (* (square (+ (* num-strings 0.195) 0.4)) scale-factor)))
;font-name
(interpret-markup layout props
(markup #:vcenter #:bold
;; !!!!!!!!!!!!!!!!!!!!!!!!!!!
;; change 'font-family and/or 'font-name
;; to fit your needs
#:override (cons 'font-family 'roman) ;; default: 'sans
;#:override (cons 'font-name "Purisa")
#:fontsize font-size
#:override (cons 'baseline-skip base-skip)
#:left-align #:center-column ("T" "A" "B")))))
%% this function decides which clef to take
#(define-public (clef::print-modern-custom-tab-if-set grob)
(let ((glyph (ly:grob-property grob 'glyph)))
;; which clef is wanted?
(if (string=? glyph "markup.moderntabII")
;; if it is "moderntabII", we'll draw it
(let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
(line-count (if (ly:grob? staff-symbol)
(ly:grob-property staff-symbol 'line-count)
0))
(staff-space (ly:staff-symbol-staff-space grob)))
(grob-interpret-markup grob (make-customTabClefII-markup line-count
staff-space)))
;; otherwise, we simply use the default printing routine
(ly:clef::print grob))))
%% definitions for the "moderntabII" clef:
%% the "moderntabII" clef will be added to the list of known clefs,
%% so it can be used as any other clef: \clef "moderntabII"
#(add-new-clef "moderntabII" "markup.moderntabII" 0 0 0)
%% DELETE ME
%{
%% Displaying some glyph/lists
displayClefGlyph =
\override Staff.Clef #'before-line-breaking =
#(lambda (grob)
(let* ((glyph (ly:grob-property grob 'glyph)))
(newline)
(display glyph)))
#(use-modules (ice-9 pretty-print))
#(pretty-print supported-clefs)
#(newline)
#(newline)
#(newline)
#(pretty-print (@@ (lily) c0-pitch-alist))
%}
\layout {
\context {
\TabStaff
\override Clef #'stencil = #clef::print-modern-custom-tab-if-set
%% DELETE ME
%\displayClefGlyph
}
}
\new TabStaff {
\clef moderntabII
a1
}
Below the line indicated with
;; !!!!!!!!!!!!!!!!!!!!!!!!!!!
you may want to change the values for font-name and/or font-family
There are some lines introduced with
%% DELETE ME
I let them in for now. If you're interested in some internals you may
want to uncomment them, otherwise delete them.
Disadvantage of this approach:
You can't change back the clef to 'moderntab'
Maybe I find something better this evening...
HTH,
Harm