]> git.donarmstrong.com Git - lilypond.git/commitdiff
* mf/feta-autometric.mf: Write foundry and family to log.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 19 Oct 2002 11:15:51 +0000 (11:15 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 19 Oct 2002 11:15:51 +0000 (11:15 +0000)
* mf/GNUmakefile: Fixes for pfx builds.  Also write sketch
font translation table.

* buildscripts/mf-to-table.py: Better font info into afm.

* buildscripts/make-font-dir.py: Use font info from afm.  Mftrace
1.0.9 required.

* configure.in: Whine for mftrace 1.0.9.

ChangeLog
buildscripts/make-font-dir.py
buildscripts/mf-to-table.py
configure.in
mf/GNUmakefile
mf/feta-autometric.mf
scm/sketch.scm
stepmake/stepmake/metafont-rules.make

index a00fe5298f567e496233d3ba17b45ff7718b5f0e..2c4b5fc389c50b4418804212398f2a35fa3bcb13 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-10-19  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * mf/feta-autometric.mf: Write foundry and family to log.
+
+       * mf/GNUmakefile: Fixes for pfx builds.  Also write sketch
+       font translation table.
+
+       * buildscripts/mf-to-table.py: Better font info into afm.
+
+       * buildscripts/make-font-dir.py: Use font info from afm.  Mftrace
+       1.0.9 required.
+
+       * configure.in: Whine for mftrace 1.0.9.
+
 2002-10-19  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * lily/parser.yy (chord_body): allow <<c e>>4 notation.
index bacceab6648d360b4864fdef75cdbedc2a8695fe..5248380d06d5451b061067fc448d6e0efb4a33c9 100644 (file)
 #!@PYTHON
 
 
+
 ## make a fonts.scale file.
 
+
 import re
 import sys
 import string
+import os
+
+
+### mftrace/afm.py
+
+# Read some global vars 
+class Afm_reader:
+       def __init__ (self, filename):
+               self.filename = filename
+               self.lines = open (self.filename).readlines ()
+
+       def get_afm (self):
+               afm = Afm_font_metric (self.filename)
+               for i in self.lines[:20]:
+                       m = re.match ('([^ \t\n]*)[ \t]*(.*[^ \t\n])', i)
+                       if m and m.group (1):
+                               key = m.group (1)
+                               value = m.group (2)
+                               if key != 'Comment':
+                                       afm.__dict__[key] = value
+               return afm
+
+class Afm_font_metric:
+       def __init__ (self, filename):
+               m = re.match ('.*/(.+)', filename)
+               self.filename = m.group (1)
+               m = re.match ('([-_A-Za-z]*)([0-9]*)', self.filename)
+               self.name = m.group (1) + m.group (2)
+               self.basename = m.group (1)
+               self.designsize = m.group (2)
+       
+def read_afm_file (filename):
+       reader = Afm_reader (filename)
+       return reader.get_afm ()
+
+#if __name__ == '__main__':
+#      i = read_afm_file  (sys.argv[1])
+#      print i, i.FullName, i.FontName
+
+### mftrace
+
+class Font_info:
+       cm = {
+               'bx': ('bold', 'roman'),
+               'bxti' : ('bold', 'italic'),
+               'csc' : ('smallcaps', 'roman'),
+               'r' : ('regular', 'roman'),
+               'tt' : ('regular', 'typewriter'),
+               'ti' : ('regular', 'italic'),
+               }
+             
+       def set_defaults (self, name):
+               self.FontName = name
+               self.FullName = name
+               self.EncodingScheme = 'AdobeStandard'
+               
+               self.foundry = 'GNU'
+               self.family = 'LilyPond'
+               self.weight = 'Feta'
+               self.slant = 'r'
+               self.setwidth = 'normal'
+               self.style = ''
+               self.pixelsize = '' # '0'
+               self.pointsize = '0'
+               self.xresolution = '0'
+               self.yresolution = '0'
+               self.spacing = 'p'
+               self.averagewidth = '0'
+               self.registry = 'GNU'
+               self.encoding = 'FontSpecific'
+
+               split = string.split (name, '-')
+               if len (split) >= 4:
+                       # Assume
+                       #   Adobe FontName = X11 foundry-family-weight-style
+                       self.foundry, self.family = split[:2]
+                       self.weight = string.join (split[2:-1], ' ')
+                       self.style = split[-1:][0]
+                       self.FamilyName = '%s %s' % (self.family, self.weight)
+                       self.designsize = self.style
+               elif name[:2] == 'cm':
+                       self.foundry = 'TeX' # Knuth?
+                       self.FamilyName = 'Computer Modern'
+                       self.family = self.FamilyName
+                       m = re.match ('^cm([a-z]*)([0-9]*)', name)
+                       self.weight = string.join (self.cm[m.group (1)], ' ')
+                       self.designsize = m.group (2)
+                       self.style = self.designsize
+               else:
+                       self.FamilyName = name
+
+       def __init__ (self, x):
+               if type (x) == type ("hallo"):
+                       m = re.match ('([-_A-Za-z]*)([0-9]*)', x)
+                       self.name = x
+                       self.basename = m.group (1)
+                       self.designsize = m.group (2)
+                       self.set_defaults (x)
+               elif type (x) == type ({}):
+                       self.set_defaults (x['FontName'])
+                       for k in x.keys ():
+                               self.__dict__[k] = x[k]
+
+       def __getitem__ (self, key):
+               return self.__dict__[key]
+
+       def get_X11 (self):
+               return (self.foundry, self.family, self.weight,
+                       self.slant, self.setwidth, self.style,
+                       self.pixelsize, self.pointsize,
+                       self.xresolution, self.yresolution,
+                       self.spacing, self.averagewidth,
+                       self.registry, self.encoding)
+
+fontinfo = {}
+
+# wat een intervaas...
 ls =  sys.stdin.readline ()
 ls = string.split (ls)
-print len(ls)
-for fn in ls:
-    name = re.sub ('\.pf[ab]', '',fn)    
-    name = re.sub ('-', ' ',name)
-
-    m = re.search ("([0-9]+)$", name)
-    designsize = 'normal'
-    if m:
-        designsize =  m.group (1)
-        name = re.sub ("([0-9]+)$", "", name)
-        
-    print '%s -lilypond-%s-regular-r-%s--0-0-0-0-p-0-adobe-fontspecific' % (fn, name, designsize)
-    
-    
+
+sketch_p = 0
+if len (ls) and ls[0] == 'sketch':
+       ls = ls[1:]
+       sketch_p = 1
+
+if not sketch_p:
+       print len(ls)
+       
+for filename in ls:
+       basename = re.sub ('\.pf[ab]', '',filename)     
+       fontname = re.sub ('-', ' ',basename)
+
+       m = re.search ("([0-9]+)$", fontname)
+       designsize = 'normal'
+
+       
+       if m:
+               designsize =  m.group (1)
+               fontbase = re.sub ("([0-9]+)$", "", fontname)
+               
+
+       # FIXME: Font naming  -- what a mess
+       # Check sane naming with xfontsel and gtkfontsel
+
+       # Adobe's font naming scheme and X11's seem to be conflicting.
+       # Adobe's FontFamily seems to be X11's family + weight
+       # Also, text selection applets like gtkfontsel, gfontview and
+       # GNOME-applications specific ones, display X11's `family'
+       # parameter as `Font', and X11's `Weight' parameter as `Style'.
+
+       # Using X11 description/convention -- good for xfontsel:
+       # foundry: GNU
+       # family: LilyPond <basename>
+       # weight: <designsize>
+       # slant: r(oman) =upright
+       # setwidth: normal
+       # style:
+       # pixelsize: 0
+       # pointsize: 0 (20 crashes xfs, moved to style)
+       # xresolution: 0
+       # yresolution: 0
+       # spacing: p(roportional)
+       # averagewidth: 0
+       # registry: GNU
+       # encoding: fonstpecific
+
+       # gives:
+       # feta20.pfa -GNU-LilyPond feta-20-r-normal--0-0-0-0-p-0-gnu-fontspecific
+
+       # However, GNOME (gtkfontsel, gnome apps) seems to want:
+
+       # foundry: GNU
+       # family: LilyPond
+       # weight:  <basename>
+       # slant: r(oman) =upright
+       # setwidth: normal
+       # style: <designsize>
+       # pixelsize: 0
+       # pointsize: 0 (20 crashes xfs, moved to style)
+       # xresolution: 0
+       # yresolution: 0
+       # spacing: p(roportional)
+       # averagewidth: 0
+       # registry: GNU
+       # encoding: fonstpecific
+
+       # which gives:
+       # feta20.pfa -GNU-LilyPond-feta-r-normal--20-0-0-0-p-0-gnu-fontspecific
+       # foundry: GNU
+       
+       ## ouch, pointsize 20 crashes xfs
+       ## XXXfeta20.pfa -GNU-LilyPond Feta-regular-r-normal--0-20-0-0-p-0-gnu-fontspecific
+
+       ## feta20.pfa -GNU-LilyPond feta-regular-r-normal-20-0-0-0-0-p-0-gnu-fontspecific
+
+       afmfile = ''
+       if not afmfile:
+               #afmfile = find_file (basename + '.afm')
+               afmfile = basename + '.afm'
+               
+       if afmfile:
+               afmfile = os.path.abspath (afmfile)
+       if os.path.exists (afmfile):    
+               afm = read_afm_file (afmfile)
+               fontinfo = Font_info (afm.__dict__)
+       else:
+               fontinfo = Font_info (basename)
+               
+       family_name = string.join (string.split (fontinfo['FamilyName'],
+                                                       '-'), ' ')
+       if not sketch_p:
+               print filename + ' -' + string.join (fontinfo.get_X11 (), '-')
+               
+       else:
+               # Sketch's lilypond.sfd map:
+               s = string.join ([fontinfo.FontName,
+                                 fontinfo.family,
+                                 '%s %s' % (fontinfo.weight, fontinfo.style),
+                                 string.join (fontinfo.get_X11 ()[:5], '-'),
+                                 string.join (fontinfo.get_X11 ()[:-2], '-'),
+                                 fontinfo.name],
+                                ',')
+               print s
+
+               s = string.join ([fontinfo.FamilyName,
+                                 fontinfo.family,
+                                 '%s %s' % (fontinfo.weight, fontinfo.style),
+                                 string.join (fontinfo.get_X11 ()[:5], '-'),
+                                 string.join (fontinfo.get_X11 ()[:-2], '-'),
+                                 fontinfo.name],
+                                ',')
+               print s
index af1e1cb9440dbdb2818d3572db1d8977d86d1fb4..30c07a151499077ffc74f7d3a84693f7205b1fdb 100644 (file)
@@ -83,9 +83,14 @@ def parse_logfile (fn):
                        charmetrics.append (m)
                elif tags[0] == 'font':
                        global font_family
-                       font_family = (tags[1])
-                       global_info['FontName'] = string.join (tags[1:],'')
-                       global_info['FullName'] = string.join (tags[1:],'')
+                       font_family = (tags[3])
+                       # To omit 'GNU' (foundry) from font name proper:
+                       # name = tags[2:]
+                       name = tags[1:]
+                       global_info['FontName'] = string.join (name,'-')
+                       global_info['FullName'] = string.join (name,' ')
+                       global_info['FamilyName'] = string.join (name[1:-1],
+                       global_info['Weight'] = tags[4]
                        global_info['FontBBox'] = '0 0 1000 1000'
                        global_info['Ascender'] = '0'
                        global_info['Descender'] = '0'
index 10300587a156338723c27e5d3ca6e1c96978f8a8..c4f1a06d85d54c04a8ae40051dd7e0c238722aee 100644 (file)
@@ -50,7 +50,7 @@ STEPMAKE_GUILE(OPTIONAL)
 # perl for help2man.
 STEPMAKE_PERL(OPTIONAL)
 # mftrace for generating pfa's, pfb's
-STEPMAKE_PROGS(MFTRACE, pktrace mftrace, OPTIONAL, 1.0.3)
+STEPMAKE_PROGS(MFTRACE, pktrace mftrace, OPTIONAL, 1.0.9)
 # new makeinfo for multi-page website docs
 STEPMAKE_PROGS(MAKEINFO, makeinfo, OPTIONAL, 4.1)
 
index 8d1574848d5698bd83d3cbd23c7cc50d9c0d0ff6..907788a7752a509b19c682240f021b9d94a92fee 100644 (file)
@@ -12,12 +12,20 @@ EXTRA_DIST_FILES += README feta.tex
 
 # don't try to make fonts from test files
 TEST_FILES = $(wildcard *test*.mf)
+
+# What are these?
 FET_FILES = $(filter-out $(TEST_FILES),\
-       $(wildcard feta[0-9]*.mf) $(wildcard parmesan[0-9]*.mf))\
-       $(wildcard feta-braces*[0-9].mf)
+       $(wildcard feta[0-9]*.mf)\
+       $(wildcard feta-braces*[0-9].mf)\
+       $(wildcard feta-din*[0-9].mf)\
+       $(wildcard parmesan[0-9]*.mf))\
 
+# No braces?
 FONT_FILES = $(filter-out $(TEST_FILES),\
-       $(wildcard feta*[0-9].mf) $(wildcard parmesan*[0-9].mf)) \
+       $(wildcard feta[0-9]*.mf)\
+       $(wildcard feta-braces*[0-9].mf)\
+       $(wildcard feta-din*[0-9].mf)\
+       $(wildcard parmesan[0-9]*.mf))\
 
 XPM_FONTS = feta20 feta-nummer10 feta-braces20
 #CM_AFM_FILES = cmr10
@@ -32,6 +40,8 @@ AFM_FILES = $(addprefix $(outdir)/, $(FET_FILES:.mf=.afm) $(PARMESAN_FILES:.mf=.
 ENC_FILES=$(TEXTABLES:.tex=.enc)
 TFM_FILES = $(addprefix $(outdir)/, $(FONT_FILES:.mf=.tfm))
 
+fet:
+       echo $(FET_FILES)
 
 # Make tfm files first, log files last, 
 # so that normally log files aren't made twice
@@ -55,10 +65,24 @@ INSTALLATION_OUT_FILES3=$(TFM_FILES)
 # comment this out if you don't want pfa's to be generated
 # making pfas takes a lot of CPU time. Let's skip it for now.
 #MAKE_PFA_FILES=1
+#MAKE_PFB_FILES=1
 
 
 SAUTER_FONT_FILES=cmbxti7 cmbxti8 cmbxti12  cmbxti14 cmcsc7 cmcsc12 cmtt17 cmbx14 cmbx17
-PFA_FILES= $(addprefix $(outdir)/, $(addsuffix .pfa, $(SAUTER_FONT_FILES)) $(FONT_FILES:.mf=.pfa)) 
+#PFA_FILES= $(addprefix $(outdir)/, $(addsuffix .pfa, $(SAUTER_FONT_FILES)) $(FONT_FILES:.mf=.pfa)) 
+#PFA_FILES= $(addprefix $(outdir)/, $(addsuffix .pfa, $(SAUTER_FONT_FILES)))
+#PFB_FILES= $(addprefix $(outdir)/, $(addsuffix .pfb, $(SAUTER_FONT_FILES)) $(FONT_FILES:.mf=.pfb)) 
+#PFB_FILES= $(addprefix $(outdir)/, $(addsuffix .pfb, $(SAUTER_FONT_FILES)) $(FONT_FILES:.mf=.pfb)) 
+
+PFA_FILES=$(SAUTER_FONT_FILES:%=$(outdir)/%.pfa)
+PFA_FILES+=$(FONT_FILES:%.mf=$(outdir)/%.pfa)
+
+PFB_FILES=$(PFA_FILES:%.pfa=%.pfb)
+
+ifdef MAKE_PFB_FILES
+MAKE_PFA_FILES = 1
+ALL_GEN_FILES += $(PFB_FILES)
+endif
 
 ifdef MAKE_PFA_FILES
 ALL_GEN_FILES += $(PFA_FILES) $(outdir)/lilypond.map $(outdir)/fonts.scale
@@ -67,16 +91,11 @@ INSTALLATION_OUT_FILES4=$(PFA_FILES) $(outdir)/fonts.scale
 
 INSTALLATION_OUT_DIR5=$(local_lilypond_datadir)/dvips/
 INSTALLATION_OUT_FILES5=$(outdir)/lilypond.map
-
 endif
 
-$(outdir)/lilypond.map: 
-       echo $(notdir $(PFA_FILES:.pfa=)) | tr ' ' '\n' | \
-               sed 's/\(.*\)/\1 \1 <\1.pfa/' > $@
-
-$(outdir)/fonts.scale:
-       echo $(FONT_FILES:.mf=.pfa) | $(PYTHON) $(topdir)/buildscripts/make-font-dir.py  > $@
-
+ifdef MAKE_PFB_FILES
+INSTALLATION_OUT_FILES4 +=$(PFB_FILES)
+endif
 
 export MFINPUTS:=.:$(MFINPUTS)
 
@@ -84,16 +103,40 @@ default: $(ALL_GEN_FILES)
 
 ##
 ## todo: this also depends on .tfm, FIXME.
-$(outdir)/%.afm  $(outdir)/%.enc  $(outdir)/%.tex $(outdir)/%.dep: $(outdir)/%.log 
+$(outdir)/%.afm  $(outdir)/%.enc  $(outdir)/%.tex $(outdir)/%.dep: $(outdir)/%.log $(outdir)/%.tfm
        $(PYTHON) $(buildscript-dir)/mf-to-table.py --package=$(topdir) --outdir=$(outdir) --dep $(outdir)/$(<F:.log=.dep)  --afm $(outdir)/$(<F:.log=.afm)  --enc $(outdir)/$(<F:.log=.enc) --tex $(outdir)/$(<F:.log=.tex) --ly $(outdir)/$(<F:.log=list.ly) $<
 
+fontdir: $(addprefix $(outdir)/, lilypond.map lilypond.sfd fonts.scale fonts.dir)
+
+$(outdir)/lilypond.map: 
+       echo $(notdir $(PFA_FILES:.pfa=)) | tr ' ' '\n' | \
+               sed 's/\(.*\)/\1 \1 <\1.pfa/' > $@
+
+$(outdir)/fonts.scale: $(PFA_FILES)
+#      cd $(outdir) && echo $(FONT_FILES:.mf=.pfa) $(FONT_FILES:.mf=.pfb) | $(PYTHON) $(topdir)/buildscripts/make-font-dir.py  > $(@F)
+       cd $(outdir) && echo *.pfa *.pfb | $(PYTHON) $(topdir)/buildscripts/make-font-dir.py  > $(@F)
+
+$(outdir)/fonts.dir: $(outdir)/fonts.scale
+       cd $(outdir) && mkfontdir
+
+# Sketch map file
+$(outdir)/lilypond.sfd:
+#      cd $(outdir) && echo sketch $(FONT_FILES:.mf=.pfa) | $(PYTHON) $(topdir)/buildscripts/make-font-dir.py  > $(@F)
+       cd $(outdir) && echo sketch *.pfa | $(PYTHON) $(topdir)/buildscripts/make-font-dir.py  > $(@F)
+
+
 local-clean:
        rm -f mfplain.mem mfplain.log 
        rm -f *.tfm *.log
 
-pfa: $(PFA_FILES)   $(outdir)/lilypond.map $(outdir)/fonts.scale
+afm: $(AFM_FILES)
+pfa: afm $(PFA_FILES) fontdir
+pfb: afm $(PFB_FILES) fontdir
 
 # needed for web documentation
-$(addprefix $(outdir)/, $(SAUTER_FONT_FILES:=.pfa)):
+$(SAUTER_FONT_FILES:%=$(outdir)/%.pfa):
        $(foreach i, $(SAUTER_FONT_FILES), \
                $(MFTRACE) -I $(outdir)/ --pfa --simplify --keep-trying $(i) && mv $(i).pfa $(outdir)/ && ) true
+$(SAUTER_FONT_FILES:%=$(outdir)/%.pfb):
+       $(foreach i, $(SAUTER_FONT_FILES), \
+               $(MFTRACE) -I $(outdir)/ --pfa --pfb --simplify --keep-trying $(i) && mv $(i).pfb $(i).pfa $(outdir)/ && ) true
index 2484a23b4a42f190bbd6ad49bf9cf36746f4b030..08b30d0b587b6b77a2ce2440123e2234026a9821 100644 (file)
@@ -20,7 +20,7 @@ message "******************************************************";
 def fet_beginfont(expr name,size) =
        font_identifier:=name&decimal size;
        font_size size;
-       message "@{font@:"&name&"@:"&decimal size&"@}";
+       message "@{font@:GNU@:LilyPond@:"&name&"@:"&decimal size&"@}";
        message "";
        enddef;
 
index eff52c0c59f1313f766ab2ec4ca9a7ac85cbc47d..afd94cbb03b5b90813fb894e8a9524103a38eee1 100644 (file)
         
 
 ;; alist containing fontname -> fontcommand assoc (both strings)
-(define font-alist '(("feta13" . ("feta13" . "13"))
-                    ("feta20" . ("LilyPond-Feta-20" . "20"))))
+;; old scheme
+;;(define font-alist '(("feta13" . ("feta13" . "13"))
+;;                  ("feta20" . ("feta20" . "20"))))
+(define font-alist '(("feta13" . ("LilyPond-Feta-13" . "13"))
+;;                  ("feta20" . ("LilyPond-Feta-20" . "20")
+                    ("feta20" . ("GNU-LilyPond-feta-20" . "20")
+                     )))
 
 ;;(define font "")
 (define font (cdar font-alist))
index a04fdf158c5772bcfbf6d9a7072125e1af8528e9..94b719491542a5b7cd8181eb52db167902902958 100644 (file)
@@ -8,6 +8,7 @@ $(outdir)/%.dvi: %.mf
        mv $(basename $<).dvi $(outdir)
        rm $(basename $<).*gf
 
+# This is not metafont, this is feta-specific
 $(outdir)/%.log: %.mf
        $(METAFONT) $<
        mv $(@F) $@
@@ -28,12 +29,13 @@ $(outdir)/%.$(XPM_RESOLUTION)pk: $(outdir)/%.$(XPM_RESOLUTION)gf
        gftopk $< $@
 
 
-$(outdir)/%.pfa: %.mf
+$(outdir)/%.pfa: %.mf $(outdir)/%.afm
        $(MFTRACE) -I $(outdir)/ --pfa --simplify --keep-trying $(basename $(@F))
        mv $(basename $(@F)).pfa $(outdir)
 
-$(outdir)/%.pfb: %.mf
-       $(MFTRACE) -I $(outdir)/ --pfb --simplify --keep-trying  $(basename $(@F))
+$(outdir)/%.pfb: %.mf $(outdir)/%.afm
+       $(MFTRACE) -I $(outdir)/ --pfa --pfb --simplify --keep-trying  $(basename $(@F))
+       -mv $(basename $(@F)).pfa $(outdir)
        mv $(basename $(@F)).pfb $(outdir)
 
 #%.afm: