* scm/sodipodi.scm: New file.
* lily/afm.cc (read_afm_file): Read TfmCheckSum from comment.
* buildscripts/mf-to-table.py (base): Write TfmChecksum in
comment, after header.
(parse_logfile): Remove invalid key FontFamily. Add mandatory key
FullName. Fix FontName key.
+2002-10-14 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * scm/lily.scm: Register sodipodi output module.
+
+ * scm/sodipodi.scm: New file.
+
+ * lily/afm.cc (read_afm_file): Read TfmCheckSum from comment.
+
+ * buildscripts/mf-to-table.py (base): Write TfmChecksum in
+ comment, after header.
+ (parse_logfile): Remove invalid key FontFamily. Add mandatory key
+ FullName. Fix FontName key.
+
2002-10-14 Rune Zedeler <rune@zedeler.dk>
* lily/rest.cc (after_line_breaking): bugfix: dots after half
shift = shift - 8
return cs
-
+
+## ugh. What's font_family supposed to be? It's not an afm thing.
+font_family = 'feta'
def parse_logfile (fn):
(autolines, deps) = read_log_file (fn)
charmetrics = []
}
charmetrics.append (m)
elif tags[0] == 'font':
- global_info['FontName'] = string.join (tags[1:])
- global_info['FontFamily']=tags[1]
+ global font_family
+ font_family = (tags[1])
+ global_info['FontName'] = string.join (tags[1:],'')
+ global_info['FullName'] = string.join (tags[1:],'')
global_info['FontBBox'] = '0 0 1000 1000'
global_info['Ascender'] = '0'
global_info['Descender'] = '0'
file.write ('C %d ; WX %d ; N %s ; B %d %d %d %d ;\n'% tup)
-
+
+def write_afm_header (file):
+ file.write ("StartFontMetrics 2.0\n")
+ file.write ("Comment Automatically generated by mf-to-table.py\n")
+
def write_afm_metric (file, global_info, charmetrics):
- file.write (r"""
-StartFontMetrics 2.0
-Comment Automatically generated by mf-to-table.py
-""")
for (k,v) in global_info.items():
file.write ("%s %s\n" % (k,v))
file.write ('StartCharMetrics %d\n' % len(charmetrics ))
def write_tex_defs (file, global_info, charmetrics):
- nm = global_info['FontFamily']
+ ##nm = global_info['FontFamily']
+ nm = font_family
for m in charmetrics:
file.write (r'''\def\%s%s{\char%d}%%%s''' % (nm, m['tex'], m['code'],'\n'))
file.write ('\\endinput\n')
file.write ('] def\n')
def write_fontlist (file, global_info, charmetrics):
- nm = global_info['FontFamily']
+ ##nm = global_info['FontFamily']
+ nm = font_family
file.write (r"""
% Lilypond file to list all font symbols and the corresponding names
% Automatically generated by mf-to-table.py
cs = tfm_checksum (re.sub ('.log$', '.tfm', filenm))
afm = open (afmfile_nm, 'w')
- afm.write ("TfmCheckSum %u\n" % cs)
+ write_afm_header (afm)
+ afm.write ("Comment TfmCheckSum %u\n" % cs)
+ write_afm_metric (afm, g, m)
- write_afm_metric (afm, g,m)
write_tex_defs (open (texfile_nm, 'w'), g, m)
write_ps_encoding (open (enc_nm, 'w'), g, m)
(c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+
+#ifndef _GNU_SOURCE // we want memmem
+#define _GNU_SOURCE
+#endif
+#include <string.h>
+#include "libc-extension.hh"
#include "afm.hh"
#include "warn.hh"
#include "molecule.hh"
{
FILE *f = fopen (nm.to_str0 () , "r");
char s[2048];
- char *check_key = "TfmCheckSum";
- fgets (s, sizeof (s), f);
-
- unsigned int cs = 0;
- if (strncmp (s, check_key, strlen (check_key)) == 0)
- {
- sscanf (s + strlen (check_key), "%ud", &cs);
- }
- else
+ char *check_key = "Comment TfmCheckSum";
+
+ unsigned int cs = 0;
+
+#if 0
+ fread (s, sizeof (s), sizeof (*s), f);
+ if (char const* p = (char const *)
+ memmem (s, sizeof (s), check_key, strlen (check_key)))
+ sscanf (p + strlen (check_key), "%ud", &cs);
+#else
+ s[0] = 0;
+ /* Assume check_key in first 10 lines */
+ for (int i = 0; i < 10; i++)
{
- rewind (f);
+ fgets (s, sizeof (s), f);
+ if (strncmp (s, check_key, strlen (check_key)) == 0)
+ {
+ sscanf (s + strlen (check_key), "%ud", &cs);
+ break;
+ }
}
-
+#endif
+
+ rewind (f);
AFM_Font_info * fi;
int ok = AFM_parseFile (f, &fi, ~1);
(scm pysk)
(scm ascii-script)
(scm sketch)
+ (scm sodipodi)
(scm pdftex)
)
("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
("scm" . ("Scheme dump: debug scheme molecule expressions" ,write))
("as" . ("Asci-script. Postprocess with as2txt to get ascii art" ,as-output-expression))
- ("sketch" . ("Bare bones Sketch output. Requires sketch 0.7" ,sketch-output-expression))
+ ("sketch" . ("Bare bones Sketch output." ,sketch-output-expression))
+ ("sodipodi" . ("Bare bones Sodipodi output." ,sodipodi-output-expression))
("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
))
--- /dev/null
+;;;; sodipodi.scm -- implement Scheme output routines for PostScript
+;;;;
+;;;; source file of the GNU LilyPond music typesetter
+;;;;
+;;;; (c) 1998--2002 Jan Nieuwenhuizen <janneke@gnu.org>
+
+;;;; NOTE that Sodipodi
+;;;;
+;;;; * dumps core on displaying feta characters
+;;;; * needs PFBs (ie, not PFAs like sketch)
+;;;; * must have (LilyPond/feta) fonts registered through GNOME's
+;;;; gnome-font-install (ie, not through X11, like sketch and xfontsel),
+;;;; which in turn is very picky about afm files
+;;;; * has it's own svg-like language: possibly this file should be
+;;;; moved to svg.scm
+
+
+(debug-enable 'backtrace)
+
+
+(define-module (scm sodipodi))
+(define this-module (current-module))
+
+(use-modules
+ (guile)
+ (lily))
+
+
+
+
+;;; Lily output interface --- cleanup and docme
+
+;;; Bare minimum interface for \score { \notes c } }
+;;; should implement:
+;;;
+;;; xx-output-expression
+;;; char
+;;; filledbox
+;;; placebox
+
+;;; and should intercept:
+;;;
+;;; fontify
+;;; lily-def
+;;; header-end
+;;; define-fonts
+;;; no-origin
+;;; start-system
+;;; end-output
+;;; header
+;;; comment
+;;; stop-last-system
+
+
+
+;; Module entry
+;;(define-public (sodipodi-output-expression expr port)
+;; (display (eval expr this-module) port))
+
+(define-public (sodipodi-output-expression expr port)
+ (display (dispatch expr) port))
+
+
+(define (dispatch expr)
+ (let ((keyword (car expr)))
+ (cond
+ ((eq? keyword 'some-func) "")
+ ;;((eq? keyword 'placebox) (dispatch (cadddr expr)))
+ ;;((eq? keyword 'fontify) (dispatch (caddr expr)))
+ (else
+ (if (module-defined? this-module keyword)
+ (apply (eval keyword this-module) (cdr expr))
+ (begin
+ (display
+ (string-append "undefined: " (symbol->string keyword) "\n"))
+ ""))))))
+
+
+;; Global vars
+
+;; alist containing fontname -> fontcommand assoc (both strings)
+;;(define font-name-alist '())
+
+;; Helper functions
+(define (tagify tag string . attribute-alist)
+ (string-append
+ "<" tag
+ (apply string-append (map (lambda (x) (string-append
+ " "
+ (symbol->string (car x))
+ "='"
+ (cdr x)
+ "'"))
+ attribute-alist))
+ ">\n"
+ string "\n</" tag ">\n"))
+
+
+;; Interface functions
+
+(define (char i)
+ (tagify "tspan" (make-string 1 (integer->char i))))
+
+(define (end-output)
+ "</svg>")
+
+
+(define (filledbox breapth width depth height)
+ (tagify "rect" ""
+
+ '(style . "fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;")
+;; `(x . "50.0")
+;; `(y . "400.0")
+ `(x . ,(number->string (* 5.5 breapth)))
+ `(y . ,(number->string (* 5.5 (- 0 depth))))
+ `(width . ,(number->string (* 5.5 (+ breapth width))))
+ `(height . ,(number->string (* 5.5 (+ depth height))))))
+
+
+(define (fontify name-mag-pair expr)
+;; (dispatch expr))
+;; (tagify "text" (dispatch expr) '(style . "font-family:LilyPond;font-style:feta20;font-size:200;")))
+;; (tagify "text" (dispatch expr) '(style . "fill:black;stroke:none;font-family:feta20;font-style:normal;font-weight:normal;font-size:200;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;text-anchor:start;writing-mode:lr;"))
+ (tagify "text" (dispatch expr) '(style . "fill:black;stroke:none;font-family:futa20;font-style:normal;font-weight:normal;font-size:20;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;text-anchor:start;writing-mode:lr;"))
+
+ )
+
+
+(define (header creator generate)
+"<?xml version='1.0' standalone='no'?>
+<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN'
+'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'
+[
+ <!ATTLIST svg
+ xmlns:xlink CDATA #FIXED 'http://www.w3.org/1999/xlink'>
+]>
+<!-- Created with Sodipodi ('http://www.sodipodi.com/') -->
+<svg
+ id='svg1'
+ sodipodi:version='0.26'
+ xmlns='http://www.w3.org/2000/svg'
+ xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'
+ xmlns:xlink='http://www.w3.org/1999/xlink'
+ width='210mm'
+ height='297mm'
+ sodipodi:docbase='/tmp/'
+ sodipodi:docname='/tmp/x'>
+ <defs
+ id='defs3' />
+ <sodipodi:namedview
+ id='base' />")
+
+
+(define (placebox x y expr)
+;; (dispatch expr))
+ (tagify "g" (dispatch expr) `(transform .
+ ,(string-append
+ "translate(" (number->string
+ (* 5.5 x))
+ ","
+ (number->string (- 700 (* 5.5 y)))
+ ")"))))
+