]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/font.scm
Merge with master
[lilypond.git] / scm / font.scm
index 90cfcceeef6e0a97e60635200f6c75f9c8f7592d..4d5a4bcef367f8c3ca93b4fb6086283bf0884204 100644 (file)
@@ -2,27 +2,16 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
-;;;; (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
-;; As an excercise, do it with records.
-;; Should use GOOPS, really.
+;;;; (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
 ;; TODO:
 ;;
 ;; lookup-font should be written in  C.
 ;;
-;; should dump tree to .texi as internal documentation
-;; 
-;; * should extract design sizes from fonts: fonts should 
-;; be read off the disk, on demand, something like:
-;;  
-;; cmr -> ((font-load "cmr6") (font-load "cmr8")  .. )
-;;
 
 (define-class <Font-tree-element>
   ())
 
-
 (define-class <Font-tree-leaf> (<Font-tree-element>)
   (default-size #:init-keyword #:default-size)
   (size-vector  #:init-keyword #:size-vector))
 (define-method (display (leaf <Font-tree-leaf>) port)
   (map (lambda (x) (display x port))
        (list
-       "Font-size-family: \n"
+       "#<Font-size-family: \n"
        (slot-ref leaf 'default-size) 
-       (slot-ref leaf 'size-vector))))
+       (slot-ref leaf 'size-vector)
+       "#>"
+       )))
 
 (define-method (display (node <Font-tree-node>) port)
 
@@ -77,6 +68,7 @@
 (define-method (add-font (node <Font-tree-node>) fprops size-family)
   (define (assoc-delete key alist)
     (assoc-remove! (list-copy alist) key))
+  
   (define (make-node fprops size-family)
     (if (null? fprops)
        (make-font-tree-leaf (car size-family) (cdr size-family))
 (define (lookup-font node alist-chain)
   (g-lookup-font node alist-chain))
 
-                                       ;
-                                       ; Each size family is a vector of fonts, loaded with a delay.
-                                       ; The vector should be sorted according to ascending design size.
-                                       ;
+;; Each size family is a vector of fonts, loaded with a delay.  The
+;; vector should be sorted according to ascending design size.
 (define feta-alphabet-size-vector
   (if (defined? 'ly:kpathsea-find-file)
       `#(,(delay  (ly:font-load "feta-alphabet11"))
                       (ly:pt 12)))))))
 
   (add-node 'upright 'normal) 
+  (add-node 'caps 'normal) 
   (add-node 'upright 'bold) 
   (add-node 'italic 'normal)
-  (add-node 'italic 'bold)
-  )
+  (add-node 'italic 'bold))
 
 (define-public (make-cmr-tree factor)
-  (let ((n (make-font-tree-node 'font-encoding 'fetaMusic)))
+  (let*
+      ((n (make-font-tree-node 'font-encoding 'fetaMusic))
+       (module (resolve-module '(scm kpathsea)))
+       (find (eval 'ly:kpathsea-find-file module))
+       )
     (add-music-fonts n factor)
     (add-cmr-fonts n factor)
-    (if (defined? 'ly:kpathsea-find-file)
-       (begin
-         (if (ly:kpathsea-find-file "lmr10.pfb")
-             (add-cork-lm-fonts n factor))
-         (if (ly:kpathsea-find-file "ecrm10.pfa")
-             (add-ec-fonts n factor))))
+    
+    (if (find "lmr10.pfb")
+       (add-cork-lm-fonts n factor))
+    (if (find "ecrm10.pfa")
+       (add-ec-fonts n factor))
     n))
 
-(define-public (make-century-schoolbook-tree factor)
+
+
+
+(define-public (make-pango-font-tree roman-str sans-str typewrite-str factor)
   (let ((n (make-font-tree-node 'font-encoding 'fetaMusic)))
     (add-music-fonts n factor)
-    (add-pango-fonts n 'roman "Century Schoolbook L" factor)
-    (add-pango-fonts n 'sans "Luxi Sans" factor)
+    (add-pango-fonts n 'roman roman-str factor)
+    (add-pango-fonts n 'sans sans-str factor)
+    (add-pango-fonts n 'typewriter typewrite-str factor)
     n))
 
-(define-public (magstep x)
-  (exp (* (/ x 6) (log 2))))
+
+(define-public (make-century-schoolbook-tree factor)
+  (make-pango-font-tree
+    "Century Schoolbook L" 
+    "Sans" "Mono" factor))
+
+(define-public (magstep s)
+  (exp (* (/ s 6) (log 2))))
+
+(define-public (magnification->font-size m)
+  (* 6 (/ (log m) (log 2))))