CVSROOT:        /cvsroot/lilypond
Module name:    lilypond
Branch:         
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/05/02 23:49:18

Modified files:
        .              : ChangeLog 
        buildscripts   : gen-emmentaler-scripts.py 
        lily           : open-type-font-scheme.cc open-type-font.cc 
                         pango-font.cc 
        mf             : GNUmakefile 
        scm            : framework-ps.scm 

Log message:
        * scm/framework-ps.scm (write-preamble): extract CFF from OTF
        fonts directly.
        
        * buildscripts/gen-emmentaler-scripts.py (i): idem.
        
        * mf/GNUmakefile: remove all CFF rules.
        
        * scm/framework-ps.scm (ps-embed-cff): reinstate.
        
        * lily/open-type-font-scheme.cc (LY_DEFINE):
        new function ly:otf-font-table-data.
        (LY_DEFINE): new function otf-font?

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3528&tr2=1.3529&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/buildscripts/gen-emmentaler-scripts.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/open-type-font-scheme.cc.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/open-type-font.cc.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/pango-font.cc.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/mf/GNUmakefile.diff?tr1=1.158&tr2=1.159&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-ps.scm.diff?tr1=1.93&tr2=1.94&r1=text&r2=text

Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3528 lilypond/ChangeLog:1.3529
--- lilypond/ChangeLog:1.3528   Mon May  2 22:27:25 2005
+++ lilypond/ChangeLog  Mon May  2 23:49:17 2005
@@ -1,7 +1,17 @@
 2005-05-03  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
+       * scm/framework-ps.scm (write-preamble): extract CFF from OTF
+       fonts directly.
+
+       * buildscripts/gen-emmentaler-scripts.py (i): idem.
+
+       * mf/GNUmakefile: remove all CFF rules.
+
+       * scm/framework-ps.scm (ps-embed-cff): reinstate.
+
        * lily/open-type-font-scheme.cc (LY_DEFINE):
        new function ly:otf-font-table-data.
+       (LY_DEFINE): new function otf-font?
 
 2005-05-02  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
Index: lilypond/buildscripts/gen-emmentaler-scripts.py
diff -u lilypond/buildscripts/gen-emmentaler-scripts.py:1.11 
lilypond/buildscripts/gen-emmentaler-scripts.py:1.12
--- lilypond/buildscripts/gen-emmentaler-scripts.py:1.11        Mon May  2 
19:15:13 2005
+++ lilypond/buildscripts/gen-emmentaler-scripts.py     Mon May  2 23:49:18 2005
@@ -66,7 +66,6 @@
 LoadTableFromFile("LILY", "feta%(design_size)d.otf-gtable")
 
 Generate("%(filename)s-%(design_size)d.otf");
-Generate("%(filename)s-%(design_size)d.cff");
 Generate("%(filename)s-%(design_size)d.svg");
 SetFontNames("PFA%(name)s-%(design_size)d", "PFA%(name)s", "PFA%(name)s 
%(design_size)d", "%(design_size)d", "GNU GPL", "@TOPLEVEL_VERSION@");
 
Index: lilypond/lily/open-type-font-scheme.cc
diff -u lilypond/lily/open-type-font-scheme.cc:1.4 
lilypond/lily/open-type-font-scheme.cc:1.5
--- lilypond/lily/open-type-font-scheme.cc:1.4  Mon May  2 22:27:25 2005
+++ lilypond/lily/open-type-font-scheme.cc      Mon May  2 23:49:18 2005
@@ -35,10 +35,10 @@
   return scm_hashq_ref (otf->get_char_table (), sym, SCM_EOL);
 }
 
-
 LY_DEFINE(ly_otf_font_table_data, "ly:otf-font-table-data", 2, 0, 0,
          (SCM font, SCM tag),
-         "Extract a table @var{tag} from @var{font}.")
+         "Extract a table @var{tag} from @var{font}. Return empty string for "
+         "non-existent @var{tag}.")
 {
   Modified_font_metric *fm
     = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
@@ -46,7 +46,6 @@
   Open_type_font *otf = fm ? dynamic_cast<Open_type_font *> (fm->original_font 
())
     : dynamic_cast<Open_type_font *> (unsmob_metrics (font));
 
-
   SCM_ASSERT_TYPE (otf, font, SCM_ARG1,  __FUNCTION__, "Open type font");
   SCM_ASSERT_TYPE (scm_is_string (tag), tag, SCM_ARG1,  __FUNCTION__, "Open 
type font");
 
@@ -59,3 +58,16 @@
 
   return scm_from_locale_stringn ((char const*) tab.to_bytes (), tab.length 
());
 }
+
+LY_DEFINE(ly_otf_font_p, "ly:otf-font?", 1, 0, 0,
+         (SCM font),
+         "Is @var{font} an OpenType font?")
+{
+  Modified_font_metric *fm
+    = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
+  
+  Open_type_font *otf = fm ? dynamic_cast<Open_type_font *> (fm->original_font 
())
+    : dynamic_cast<Open_type_font *> (unsmob_metrics (font));
+
+  return scm_from_bool (otf);
+}
Index: lilypond/lily/open-type-font.cc
diff -u lilypond/lily/open-type-font.cc:1.36 
lilypond/lily/open-type-font.cc:1.37
--- lilypond/lily/open-type-font.cc:1.36        Mon May  2 22:27:25 2005
+++ lilypond/lily/open-type-font.cc     Mon May  2 23:49:18 2005
@@ -18,6 +18,7 @@
 FT_Byte *
 load_table (char const *tag_str, FT_Face face, FT_ULong *length)
 {
+  *length = 0;
   FT_ULong tag = FT_MAKE_TAG (tag_str[0], tag_str[1], tag_str[2], tag_str[3]);
 
   int error_code = FT_Load_Sfnt_Table (face, tag, 0, NULL, length);
@@ -33,7 +34,11 @@
 
       return buffer;
     }
-
+  else
+    {
+      programming_error ("Cannot find OpenType table.");
+    }
+  
   return 0;
 }
 
@@ -42,7 +47,7 @@
 {
   FT_ULong len;
   FT_Byte *tab = load_table (tag.to_str0 (), face_,  &len);
-  
+
   return String (tab, len);
 }
 
Index: lilypond/lily/pango-font.cc
diff -u lilypond/lily/pango-font.cc:1.28 lilypond/lily/pango-font.cc:1.29
--- lilypond/lily/pango-font.cc:1.28    Tue Apr 12 22:49:28 2005
+++ lilypond/lily/pango-font.cc Mon May  2 23:49:18 2005
@@ -164,7 +164,7 @@
     {
       ((Pango_font *) this)->register_font_file (filename, ps_name);
       pango_fc_font_unlock_face (fcfont);
-
+       
       SCM expr = scm_list_4 (ly_symbol2scm ("glyph-string"),
                             scm_makfrom0str (ps_name.to_str0 ()),
                             scm_from_double (size),
Index: lilypond/mf/GNUmakefile
diff -u lilypond/mf/GNUmakefile:1.158 lilypond/mf/GNUmakefile:1.159
--- lilypond/mf/GNUmakefile:1.158       Mon May  2 19:15:13 2005
+++ lilypond/mf/GNUmakefile     Mon May  2 23:49:18 2005
@@ -29,8 +29,6 @@
  $(BRACES:%=$(outdir)/feta-braces-%.otf-table)
 FETA_FONTS = $(FETA_MF_FILES:.mf=)
 SVG_FILES = $(OTF_FILES:%.otf=%.svg) $(ALL_FONTS:%=$(outdir)/%.svg)
-CFF_FILES = $(OTF_FILES:%.otf=%.cff)
-CFF_PS_FILES = $(OTF_FILES:%.otf=%.cff.ps)
 
 
 $(outdir)/aybabtu.otf-table: $(BRACES:%=$(outdir)/feta-braces-%.otf-table)
@@ -58,15 +56,14 @@
 # 2. are not included with teTeX
 #
 
-$(outdir)/%.cff.ps $(outdir)/$(PFA_PREFIX)%.pfa $(outdir)/%.cff 
$(outdir)/%.otf $(outdir)/%.svg: $(outdir)/%.pe
+$(outdir)/$(PFA_PREFIX)%.pfa $(outdir)/%.otf $(outdir)/%.svg: $(outdir)/%.pe
        (cd $(outdir) && $(FONTFORGE) -script $(notdir $<))
-       $(PYTHON) $(buildscript-dir)/ps-embed-cff.py $(basename $<).cff `cat 
$(basename $<).fontname` $(basename $<).cff.ps
        -rm $(outdir)/*.scale.pfa
 
 # ugh, this does not work
 $(outdir)/%.pfa: $(outdir)/%.log
 $(outdir)/feta-alphabet%.pfa: $(outdir)/feta-alphabet%.log
-$(outdir)/emmentaler-%.otf $(outdir)/$(PFA_PREFIX)emmentaler-%.pfa 
$(outdir)/emmentaler%.cff $(outdir)/emmentaler%.svg: $(outdir)/feta%.pfa 
$(outdir)/feta-alphabet%.pfa $(outdir)/parmesan%.pfa
+$(outdir)/emmentaler-%.otf $(outdir)/$(PFA_PREFIX)emmentaler-%.pfa 
$(outdir)/emmentaler%.svg: $(outdir)/feta%.pfa $(outdir)/feta-alphabet%.pfa 
$(outdir)/parmesan%.pfa
 
 # AARGH?
 
@@ -114,7 +111,7 @@
 
 $(outdir)/aybabtu.otf $(outdir)/$(PFA_PREFIX)aybabtu.pfa: 
$(outdir)/aybabtu.subfonts $(outdir)/aybabtu.fontname 
$(outdir)/aybabtu.otf-table $(outdir)/aybabtu.otf-gtable $(outdir)/aybabtu.pe
 
-$(outdir)/aybabtu.otf $(outdir)/$(PFA_PREFIX)aybabtu.pfa $(outdir)/aybabtu.cff 
$(outdir)/aybabtu.svg: $(BRACES:%=$(outdir)/feta-braces-%.pfa)
+$(outdir)/aybabtu.otf $(outdir)/$(PFA_PREFIX)aybabtu.pfa 
$(outdir)/aybabtu.svg: $(BRACES:%=$(outdir)/feta-braces-%.pfa)
 
 $(outdir)/aybabtu.fontname:
        echo -n 'aybabtu' > $@ 
@@ -130,7 +127,7 @@
 
 # Make tfm files first, log files last, 
 # so that normally log files aren't made twice
-ALL_GEN_FILES= $(TFM_FILES) $(TEXTABLES) $(TFM_FILES) $(LOG_FILES) 
$(ENC_FILES) $(LISP_FILES) $(FETA_LIST_FILES)  $(OTF_TABLES) $(PFA_FILES) 
$(outdir)/lilypond.map $(OTF_FILES) $(SVG_FILES) $(CFF_PS_FILES) $(CFF_FILES)
+ALL_GEN_FILES= $(TFM_FILES) $(TEXTABLES) $(TFM_FILES) $(LOG_FILES) 
$(ENC_FILES) $(LISP_FILES) $(FETA_LIST_FILES)  $(OTF_TABLES) $(PFA_FILES) 
$(outdir)/lilypond.map $(OTF_FILES) $(SVG_FILES)
 
 #PRE_INSTALL=$(MAKE) "$(ALL_GEN_FILES)"
 INSTALLATION_DIR=$(local_lilypond_datadir)/fonts/source
Index: lilypond/scm/framework-ps.scm
diff -u lilypond/scm/framework-ps.scm:1.93 lilypond/scm/framework-ps.scm:1.94
--- lilypond/scm/framework-ps.scm:1.93  Sat Apr 30 19:47:14 2005
+++ lilypond/scm/framework-ps.scm       Mon May  2 23:49:18 2005
@@ -193,14 +193,50 @@
   (regexp-substitute/global #f "([eE]mmentaler|[aA]ybabtu)"
                            name 'pre "PFA" 1 'post))
 
+(define (cff-font? font)
+  (let*
+      ((cff-string  (ly:otf-font-table-data font "CFF ")))
+    (> (string-length cff-string) 0)))
+
+(define-public (ps-embed-cff body font-set-name version)
+  (let* ((binary-data
+         (string-append
+          (format "/~a ~s StartData " font-set-name (string-length body))
+          body))
+
+        (header
+         (format
+          "%%BeginResource: font ~a
+%!PS-Adobe-3.0 Resource-FontSet
+%%DocumentNeededResources: ProcSet (FontSetInit)
+%%Title: (FontSet/~a)
+%%Version: ~s
+%%EndComments
+%%IncludeResource: ProcSet (FontSetInit)
+%%BeginResource: FontSet (~a)
+/FontSetInit /ProcSet findresource begin
+%%BeginData: ~s Binary Bytes
+"
+          font-set-name font-set-name version font-set-name
+          (string-length binary-data)))
+        (footer "\n%%EndData
+%%EndResource
+%%EOF
+%%EndResource\n"))
+
+    (string-append
+     header
+     binary-data
+     footer)))
+
+
 (define (write-preamble paper load-fonts? port)
-  (define (load-font font-pair)
-    (let* ((name (car font-pair))
-          (file-name (cdr font-pair))
-                
-          (bare-file-name (ly:find-file file-name))
-          (cffname (string-append file-name ".cff.ps"))
-          (cff-file-name (ly:find-file cffname)))
+  
+  (define (load-font font-name-filename)
+    (let* ((font (car font-name-filename))
+          (name (cadr font-name-filename))
+          (file-name (caddr font-name-filename))
+          (bare-file-name (ly:find-file file-name)))
 
       (cons 
        (munge-lily-font-name name)
@@ -213,20 +249,11 @@
        ((string-match "([eE]mmentaler|[Aa]ybabtu)" file-name)
         (cached-file-contents
          (format "~a.pfa" (munge-lily-font-name file-name))))
-
-       ((and bare-file-name
-             (string-match "\\.(otf|cff)" bare-file-name))
-
-                                       ; replace with the CFF.ps, which lives 
in a
-                                       ; separate subdir.
-        (for-each (lambda (tup)
-                    (set! bare-file-name
-                          (string-regexp-substitute
-                           (car tup) (cdr tup) bare-file-name)))
-                  '(("/fonts/otf/" . "/ps/")
-                    ("/fonts/cff/" . "/ps/")
-                    ("\\.(otf|cff)" . ".cff.ps")))
-
+       
+       ((cff-font? font)
+        (ps-embed-cff (ly:otf-font-table-data font "CFF ")
+                      name
+                      0))
         (cached-file-contents bare-file-name))
        ((and bare-file-name (string-match "\\.ttf" bare-file-name))
         (ly:ttf->pfa bare-file-name))
@@ -235,6 +262,7 @@
        (else
         (ly:warning (_ "can't find CFF/PFA/PFB font ~S=~S" name file-name))
         (cons font-name ""))))))
+
   
   (define (load-fonts paper)
     (let* ((fonts (ly:paper-fonts paper))
@@ -244,10 +272,17 @@
             (lambda (font)
               (cond
                ((string? (ly:font-file-name font))
-                (list (cons (ly:font-name font)
-                            (ly:font-file-name font))))
+                (list (list
+                       font
+                       (ly:font-name font)
+                       (ly:font-file-name font))))
                ((ly:pango-font? font)
-                (ly:pango-font-physical-fonts font))
+                (map
+                 (lambda (name-psname-pair)
+                   (list #f
+                         (car name-psname-pair)
+                         (cdr name-psname-pair)))
+                  (ly:pango-font-physical-fonts font)))
                (else
                 (ly:font-sub-fonts font))))
                   
@@ -255,7 +290,7 @@
           (font-names
            (uniq-list
             (sort (apply append all-font-names)
-                  (lambda (x y) (string<? (car x) (car y))))))
+                  (lambda (x y) (string<? (cadr x) (cadr y))))))
           
           (pfas (map load-font font-names)))
       pfas))


_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to