]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/regression/font-postscript.ly: new file.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 15 Jul 2004 23:19:22 +0000 (23:19 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 15 Jul 2004 23:19:22 +0000 (23:19 +0000)
* scm/framework-ps.scm (load-fonts): load pfb files too.

* lily/pfb.cc (pfb2pfa): new file.

ChangeLog
input/regression/font-postscript.ly [new file with mode: 0644]
lily/pfb.cc [new file with mode: 0644]
lily/text-item.cc
scm/font.scm
scm/framework-ps.scm

index 154e346970c683b22000fa438d9e8ed5219d6333..14df3554fe98cb0b0ab3a8926e7577aee73c6580 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-07-16  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * input/regression/font-postscript.ly: new file. 
+
+       * scm/framework-ps.scm (load-fonts): load pfb files too.
+
+       * lily/pfb.cc (pfb2pfa): new file.
+
 2004-07-15  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * scripts/lilypond-book.py (PREAMBLE_LY): set
diff --git a/input/regression/font-postscript.ly b/input/regression/font-postscript.ly
new file mode 100644 (file)
index 0000000..795d360
--- /dev/null
@@ -0,0 +1,32 @@
+\header {
+
+    texidoc = "This file demonstrates how to load different
+    (postscript) fonts. The file @file{font.scm} shows how to define
+    the scheme-function called."
+
+}
+
+\bookpaper
+{
+
+    #(define text-font-defaults
+      '((font-encoding . latin1)
+       (baseline-skip . 2)
+       (word-space . 0.6)))
+
+    #(set! fonts (make-century-schoolbook-tree 1.0))
+}
+
+\paper {
+    linewidth = 160 \mm - 2.0 * 9.0 \mm
+
+    
+    indent = 0.0\mm
+    raggedright = ##t
+}
+
+    {
+        \key a \major
+\time 6/8
+cis''8. d''16 cis''8 e''4 e''8
+    }
diff --git a/lily/pfb.cc b/lily/pfb.cc
new file mode 100644 (file)
index 0000000..60dde35
--- /dev/null
@@ -0,0 +1,90 @@
+/* 
+  pfb.cc --  implement pfb conversion.
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  
+*/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "string.hh"
+#include "lily-guile.hh"
+#include "source-file.hh"
+
+char *
+pfb2pfa (Byte const * pfb, int length)
+{
+  char * out = new char[1];
+  int olen = 0;
+  
+  Byte const * p = pfb;
+  while (p  < pfb + length)  
+    {
+      if (*p++ != 128)
+       break;
+
+      Byte type = *p++;
+      if (type == 3)
+       break ;
+
+      unsigned seglen =
+       p[0] | (p[1] << 8)
+       | (p[2] << 16) | (p[3] << 24);
+
+      p += 4;
+      if (type == 1)
+       {
+         out = (char*)realloc (out, olen + seglen + 1);
+         char* outp = out + olen ;
+         memcpy (outp, p, seglen);
+         olen += seglen; 
+         p += seglen;
+       }
+      else if (type == 2)
+       {
+         unsigned outlength =  (seglen * 2) + (seglen / 32) + 2;
+
+         out = (char*)realloc (out, olen + outlength + 1);
+
+         char * outp = out + olen;
+         for (int i = seglen; i--;)
+           {
+             sprintf (outp, "%02x", *p++);
+             outp += 2;
+             if (!(i % 32))
+               {
+                 *outp ++ = '\n';
+               }
+           }
+
+         olen = outp - out;
+       }
+      
+    }
+  out[olen] = 0;
+
+  return out;
+}
+
+LY_DEFINE(ly_pfb_to_pfa, "ly:pfb->pfa",
+         1,0,0, (SCM pfb_path),
+         "Convert the contents of a PFB file to PFA."
+         )
+{
+  SCM_ASSERT_TYPE(ly_c_string_p (pfb_path), pfb_path,
+                 SCM_ARG1, __FUNCTION__, "string");
+
+  String path = ly_scm2string (pfb_path);
+  int len ; 
+  char *str = gulp_file (path, &len);
+  char *pfa = pfb2pfa ((Byte*)str, len);
+  
+  SCM pfa_scm = scm_makfrom0str(pfa);
+  free (pfa);
+  delete str;
+  return pfa_scm;
+}
+         
index b03027b965ea9304bdc755dc5468d2aa8eb539db..d472c1798066ea84cfffde4a42f126bf40384235 100644 (file)
@@ -44,6 +44,7 @@ Text_item::interpret_string (SCM paper, SCM props, SCM encoding, SCM markup)
     {
       /* ARGH. */
       programming_error ("Must have Modified_font_metric for text.");
+      scm_display (fm->description_, scm_current_error_port ());
     }
       
   return Stencil (b, lst).smobbed_copy ();
index 6af657f20579754818ab047a63aee4ad0bb37f42..a17dc3be6921e37010b23ff827f2907956c1fe0e 100644 (file)
              (font-shape . upright)
              (font-series . medium)
              (font-encoding . latin1))
-           `(10.0 . #(,(delay (ly:font-load "c059013l")))))
+           `(10.0 . #(,(delay (ly:font-load "uncr8a")))))
   
   (add-font node
            '((font-family . roman)
              (font-shape . italic)
              (font-series . medium)
              (font-encoding . latin1))
-           `(10.0 . #(,(delay (ly:font-load "c059033l")))))
+           `(10.0 . #(,(delay (ly:font-load "uncri8a")))))
   
   (add-font node
            '((font-family . roman)
              (font-shape . upright)
              (font-series . bold)
              (font-encoding . latin1))
-           `(10.0 . #(,(delay (ly:font-load "c059016l")))))
+           `(10.0 . #(,(delay (ly:font-load "uncb8a")))))
   
   (add-font node
            '((font-family . roman)
              (font-shape . italic)
              (font-series . bold)
              (font-encoding . latin1))
-           `(10.0 . #(,(delay (ly:font-load "c059036l")))))
+           `(10.0 . #(,(delay (ly:font-load "uncbi8a")))))
   )
 
 
 (define-public (make-cmr-tree factor)
-
   (let
       ((n (make-font-tree-node 'font-encoding 'fetaMusic)))
 
   ))
 
 
-
 (define-public (magstep x)
   (exp (* (/ x 6) (log 2))))
index 3f72f590491c7cfc8686934fedab0feb5fdf08ae..50070674f6b05fb8dcc79a19d544133ec19aff39 100644 (file)
                    ((aname (string-append x ".pfa"))
                     (apath (ly:kpathsea-expand-path aname))
 
-;                   (bpath (if (not apath)
-;                              (ly:kpathsea-expand-path (string-append x ".pfb"))
-;                              #f)))
-
-                    )
+                    (bpath (if (not apath)
+                               (ly:kpathsea-expand-path (string-append x ".pfb"))
+                               #f)))
+                    
                            
                  (cond
                   (apath (ly:gulp-file apath))
-
-                  ; oops , can't plonk PFB in, must convert to ASCII.
-                  ;(bpath (ly:gulp-file bpath))
+                  (bpath (ly:pfb->pfa bpath))
                   (else
                    (ly:warn "Can't find PFA font ~S" x)
                    ""))))