diff options
author | Jan Nieuwenhuizen <janneke@gnu.org> | 2002-10-19 11:15:51 +0000 |
---|---|---|
committer | Jan Nieuwenhuizen <janneke@gnu.org> | 2002-10-19 11:15:51 +0000 |
commit | b0433c68f62daa6f07a48de98df2f9922b547c3f (patch) | |
tree | 934715d0a00fadac574b5614c97c3189a1278038 | |
parent | f5f85052774f4767ef2f38df4a139e1a0ea7c0e2 (diff) |
* 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.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | buildscripts/make-font-dir.py | 246 | ||||
-rw-r--r-- | buildscripts/mf-to-table.py | 11 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | mf/GNUmakefile | 73 | ||||
-rw-r--r-- | mf/feta-autometric.mf | 2 | ||||
-rw-r--r-- | scm/sketch.scm | 9 | ||||
-rw-r--r-- | stepmake/stepmake/metafont-rules.make | 8 |
8 files changed, 326 insertions, 39 deletions
@@ -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. diff --git a/buildscripts/make-font-dir.py b/buildscripts/make-font-dir.py index bacceab664..5248380d06 100644 --- a/buildscripts/make-font-dir.py +++ b/buildscripts/make-font-dir.py @@ -1,24 +1,242 @@ #!@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 diff --git a/buildscripts/mf-to-table.py b/buildscripts/mf-to-table.py index af1e1cb944..30c07a1514 100644 --- a/buildscripts/mf-to-table.py +++ b/buildscripts/mf-to-table.py @@ -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' diff --git a/configure.in b/configure.in index 10300587a1..c4f1a06d85 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/mf/GNUmakefile b/mf/GNUmakefile index 8d1574848d..907788a775 100644 --- a/mf/GNUmakefile +++ b/mf/GNUmakefile @@ -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 diff --git a/mf/feta-autometric.mf b/mf/feta-autometric.mf index 2484a23b4a..08b30d0b58 100644 --- a/mf/feta-autometric.mf +++ b/mf/feta-autometric.mf @@ -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; diff --git a/scm/sketch.scm b/scm/sketch.scm index eff52c0c59..afd94cbb03 100644 --- a/scm/sketch.scm +++ b/scm/sketch.scm @@ -151,8 +151,13 @@ ;; 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)) diff --git a/stepmake/stepmake/metafont-rules.make b/stepmake/stepmake/metafont-rules.make index a04fdf158c..94b7194915 100644 --- a/stepmake/stepmake/metafont-rules.make +++ b/stepmake/stepmake/metafont-rules.make @@ -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: |