2 ;;; font.scm -- implement Font stuff
4 ;;; source file of the GNU LilyPond music typesetter
6 ;;; (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
9 (define (font-field name font-descr)
13 ((eq? name 'font-relative-size) 0)
14 ((eq? name 'font-series) 1)
15 ((eq? name 'font-shape) 2)
16 ((eq? name 'font-family) 3)
17 ((eq? name 'font-design-size) 4)
18 (else (ly:warning "unknown font field name"))
23 (define size-independent-fonts
25 ((* * * braces *) . ("feta-braces00"
35 ;; FIXME: what about this comment?:
37 ;; font-lookup seems a little inefficient -- walking this entire list
40 ;; should really have name/pt size at the front of the list.
41 ;; (also tried to vary the order of this list, with little effect)
43 ;; (font-relative-size font-series font-shape font-family
46 (define paper20-style-sheet-alist
48 ;; why are font file names strings, not symbols?
49 ((3 medium upright number 13) . "feta-nummer13")
50 ((2 medium upright number 13) . "feta-nummer13")
51 ((1 medium upright number 11) . "feta-nummer11")
52 ((0 medium upright number 10) . "feta-nummer10")
53 ((-1 medium upright number 8) . "feta-nummer8")
54 ((-2 medium upright number 7) . "feta-nummer7")
55 ((-3 medium upright number 6) . "feta-nummer6")
56 ((-4 medium upright number 5) . "feta-nummer5")
57 ((-5 medium upright number 4) . "feta-nummer4")
59 ((4 medium upright roman 17) . "cmr17")
60 ((3 medium upright roman 17) . "cmr17")
61 ((2 medium upright roman 12) . "cmr12")
62 ((1 medium upright roman 12) . "cmr12")
63 ((0 medium upright roman 10) . "cmr10")
64 ((-1 medium upright roman 8) . "cmr8" )
65 ((-2 medium upright roman 7) . "cmr7" )
66 ((-3 medium upright roman 6) . "cmr6" )
67 ((-4 medium upright roman 5) . "cmr5" )
68 ((-5 medium upright roman 5) . "cmr5" )
70 ((3 medium italic roman 12) . "cmti12")
71 ((2 medium italic roman 12) . "cmti12")
72 ((1 medium italic roman 12) . "cmti12") ;;; ugh. Should add magnification here!
73 ((0 medium italic roman 10) . "cmti10")
74 ((-1 medium italic roman 8) . "cmti8")
75 ((-2 medium italic roman 7) . "cmti7")
76 ((-3 medium italic roman 6) . "cmti6")
77 ((-4 medium italic roman 5) . "cmti5")
78 ((-5 medium italic roman 5) . "cmti5")
80 ;;; cmbx17 is sauter, not commonly available as Type1.
81 ((4 bold upright roman 17) . "cmbx17")
82 ((3 bold upright roman 17) . "cmbx17")
84 ((2 bold upright roman 14) . "cmbx14")
85 ((1 bold upright roman 12) . "cmbx12")
86 ((0 bold upright roman 10) . "cmbx10")
87 ((-1 bold upright roman 8) . "cmbx8")
88 ((-2 bold upright roman 7) . "cmbx7")
89 ((-3 bold upright roman 6) . "cmbx6")
90 ((-4 bold upright roman 5) . "cmbx5")
91 ((-5 bold upright roman 5) . "cmbx5")
94 ((2 bold italic roman 12) . "cmbxti12")
95 ((1 bold italic roman 12) . "cmbxti12")
96 ((0 bold italic roman 10) . "cmbxti10")
98 ((-1 bold italic roman 8) . "cmbxti8")
99 ((-2 bold italic roman 7) . "cmbxti7")
100 ((-3 bold italic roman 6) . "cmbxti6")
101 ((-4 bold italic roman 5) . "cmbxti5")
102 ((-5 bold italic roman 5) . "cmbxti5")
104 ((4 medium upright typewriter 17) . "cmtt17")
105 ((3 medium upright typewriter 17) . "cmtt17")
106 ((2 medium upright typewriter 12) . "cmtt12")
107 ((1 medium upright typewriter 12) . "cmtt12")
108 ((0 medium upright typewriter 10) . "cmtt10")
109 ((-1 medium upright typewriter 8) . "cmtt8" )
110 ((-2 medium upright typewriter 7) . "cmtt7" )
111 ((-3 medium upright typewriter 6) . "cmtt6" )
112 ((-4 medium upright typewriter 5) . "cmtt5" )
113 ((-5 medium upright typewriter 5) . "cmtt5" )
115 ((3 medium caps roman 12) . "cmcsc12")
116 ((2 medium caps roman 12) . "cmcsc12")
117 ((1 medium caps roman 12) . "cmcsc12")
118 ((0 medium caps roman 10) . "cmcsc10")
119 ((-1 medium caps roman 8) . "cmcsc8")
120 ((-2 medium caps roman 7) . "cmcsc7")
121 ((-3 medium caps roman 7) . "cmcsc7")
123 ((3 * * dynamic 19) . "feta-din19")
124 ((2 * * dynamic 19) . "feta-din19")
125 ((1 * * dynamic 17) . "feta-din17")
126 ((0 * * dynamic 14) . "feta-din14")
127 ((-1 * * dynamic 12) . "feta-din12")
128 ((-2 * * dynamic 9) . "feta-din9")
129 ((-3 * * dynamic 8) . "feta-din8")
130 ((-4 * * dynamic 7) . "feta-din7")
131 ((-5 * * dynamic 6) . "feta-din6")
133 ((2 * * music 26) . ("feta26" "parmesan26"))
134 ((1 * * music 23) . ("feta23" "parmesan23"))
135 ((0 * * music 20) . ("feta20" "parmesan20"))
136 ((-1 * * music 16) . ("feta16" "parmesan16"))
137 ((-2 * * music 13) . ("feta13" "parmesan13"))
138 ((-3 * * music 11) . ("feta11" "parmesan11"))
139 ((-4 * * music 11) . ("feta11" "parmesan11"))
141 ((2 * * ancient 26) . ("feta26" "parmesan26"))
142 ((1 * * ancient 23) . ("feta23" "parmesan23"))
143 ((0 * * ancient 20) . ("feta20" "parmesan20"))
144 ((-1 * * ancient 16) . ("feta16" "parmesan16"))
145 ((-2 * * ancient 13) . ("feta13" "parmesan13"))
146 ((-3 * * ancient 11) . ("feta11" "parmesan11"))
147 ((-4 * * ancient 11) . ("feta11" "parmesan11"))
149 ((0 * * math 10) . "msam10")
150 ((-1 * * math 10) . "msam10")
151 ((-2 * * math 10) . "msam10")
152 ((-3 * * math 10) . "msam10")
156 (define (change-relative-size font-desc decrement)
157 "return a FONT-DESCR with relative size decremented by DECREMENT"
159 (if (number? (car font-desc))
160 (cons (- (car font-desc) decrement) (cdr font-desc))
164 (define (change-rhs-size font-desc from to )
165 (cons (car font-desc)
166 (regexp-substitute/global #f from (cdr font-desc) 'pre to 'post)))
169 (define (change-style-sheet-relative-size sheet x)
170 (map-alist-keys (lambda (descr) (change-relative-size descr x)) sheet))
173 ;; make style sheet for each paper version.
174 (define font-list-alist
175 (map-alist-vals (lambda (x) (change-style-sheet-relative-size
176 paper20-style-sheet-alist x))
186 ;; make a kludged up paper-19 style sheet. Broken by virtual fonts.
189 (set! font-list-alist
193 (map (lambda (x) (change-rhs-size x "20" "19"))
194 paper20-style-sheet-alist))
197 (define-public (make-font-list sym)
198 (append size-independent-fonts
199 (cdr (assoc sym font-list-alist))))
202 ;;; ascii-script font init
203 (define as-font-sheet-alist
204 '((as5 . (((* * * braces *) . ("as-braces9"))
205 ((* * * number *) . "as-number1")
206 ((0 * * music *) . ("as5"))
207 ((0 * * roman *) . "as-dummy")))
208 (as9 . (((* * * braces *) . ("as-braces9"))
209 ((0 medium upright number 10) . "as-number4")
210 ((* * * number 5) . "as-number1")
211 ((0 * * music *) . ("as9"))
212 ((0 * * roman *) . "as-dummy")))))
214 (define-public (as-make-font-list sym)
215 (set! font-list-alist
216 (append font-list-alist as-font-sheet-alist))
217 (make-font-list sym))