On Tuesday, 28 September 1999, Matthew Hiller writes:
> On Tue, 28 Sep 1999, Jan Nieuwenhuizen wrote:
>
> > Btw, I also asked Derek at the time: why don't you use Lily's font?
> > Check out ./buildscripts/mf-to-xpms.sh.
make -C mf all xpms XPM_FONTS=feta20
should have worked, but it failed here for three reasons:
* The accordeon symbols are not robust: comment-out
input feta-accordion;
in feta-schrift.mf
* The fetaxx.afm files have changed: widths were added, and spaces
were added before ';'
You can use the new script below or wait for .12, or
you can use lilypond-1.0.11 - 1.0.19
* Pktopbm from libgr-2.0.13 is broken, you need to get
libgr-2.0.13-17 if you use RedHat, or apply the patch
below (same thing).
That's all there's to it!
Jan.
> I can't get mf-to-xpms to work. For example, I try
> entering:
>
> lilypond-1.2.9/mf% ../buildscripts/out/mf-to-xpms feta20
>
> And it produces a gf files and a pk file in the out directory, but
> doesn't get past that on its own.
>
> From a debugging echo I put into the script, it seems that $PBMS
> isn't getting set to anything at all, so pktopbm ends up getting invoked
> without any output files.
>
> Does anyone who knows more about this stuff than I do know how to
> fix the script, or at least how to invoke pktopbm so that it produces
> something useful (i.e., something other than a black rectangle?)
#!@SHELL@
# mf-to-xpms.sh
set -x;
if [ $# -ne 1 ]; then
echo Usage: mf-to-xpms feta20
exit 2
fi
font=`basename $1 .mf`
mf=$font.mf
afm=out/$font.afm
PKTOPBM=pktopbm
MODE=ibmvga
RESOLUTION=110
named=yes
set +x;
if [ ! -e out/$font.${RESOLUTION}pk ]; then
mf "\\mode=${MODE}; \\input $mf"
mv $font.${RESOLUTION}gf out
rm -f $font.log $font.tfm
gftopk out/$font.${RESOLUTION}gf out/$font.${RESOLUTION}pk
fi
# num=`grep "^C *[0-9]*;" $afm | tail -1 | sed "s!^C *\([^;]*\).*!\\1!"`
# num=66
# tex=out/$font.tex
# cat > $tex <<EOF
# \font\fetatwenty=feta20
# \fetatwenty
# \nopagenumbers
# \newcount\c\c64
# \char\c
# \loop\ifnum\c<$num\advance\c by1
# \vfill\eject
# \char\c
# \repeat
# \vfill\eject
# \end
# EOF
# for i in $NUMS; do
# $PKTOPBM out/$font.${RESOLUTION}pk -c $i out/$font-$i.pbm
# done
# numbered files
if [ "x$named" = "x" ]; then
NUMS=`grep "^C *[0-9]* *;" $afm | sed "s!^C *\([^ ;]*\).*!\\1!"`
PBMS=`grep "^C *[0-9]* *;" $afm | sed "s!^C *\([^ ;]*\).*!out/$font-\\1.pbm!"`
else
NUMS=`grep "^C *[0-9]* *;" $afm | sed "s!^C *.*; *N *\([^ ;]*\).*!\\1!"`
PBMS=`grep "^C *[0-9]* *;" $afm | sed "s!^C *.*; *N *\([^
;]*\).*!out/$font-\\1.pbm!"`
fi
# $PKTOPBM out/$font.${RESOLUTION}pk -x 100 -y 100 $PBMS
$PKTOPBM out/$font.${RESOLUTION}pk $PBMS
for i in $NUMS; do
ppmtoxpm out/$font-$i.pbm > out/$font-$i.xpm
done
rm -f $PBMS
diff -urN ../libgr-2.0.13/ChangeLog ./ChangeLog
--- ../libgr-2.0.13/ChangeLog Wed Oct 30 05:55:28 1996
+++ ./ChangeLog Tue Sep 22 15:37:36 1998
@@ -1,3 +1,7 @@
+Tue Sep 22 15:34:12 1998 <[EMAIL PROTECTED]>
+
+ * fixed pktopbm
+
Tue Oct 29 23:33:18 1996 <[EMAIL PROTECTED]>
* libgr-2.0.11 released.
diff -urN ../libgr-2.0.13/pbm/pktopbm.c ./pbm/pktopbm.c
--- ../libgr-2.0.13/pbm/pktopbm.c Sat Apr 5 15:23:08 1997
+++ ./pbm/pktopbm.c Tue Sep 22 16:50:14 1998
@@ -1,5 +1,12 @@
/*
pktopbm, adapted from "pktopx in C by Tomas Rokicki" by AJCD 1/8/90
+ 1998-09-22: jcn <[EMAIL PROTECTED]>
+ - lots of bugfixes:
+ * always read x/y offset bytes (3x)
+ * reset bmx, bmy to defaults for each char
+ * fix bitmap y placement of dynamically packed char
+ * skip char early if no output file allocated
+ - added debug output
compile with: cc -lpbm -o pktopbm pktopbm.c
*/
@@ -26,6 +33,9 @@
static eightbits bitweight ;
static integer repeatcount ;
static integer flagbyte ;
+static integer debug=0;
+
+#define dprintf(s,d) if (debug) printf(s,d)
/* add a suffix to a filename in an allocated space */
static void
@@ -165,18 +175,20 @@
int argc ;
char *argv[] ;
{
+ integer x;
integer endofpacket ;
boolean turnon ;
integer i, j;
integer car ;
integer bmx=0, bmy=0;
+ integer set_bmx=0, set_bmy=0;
bit row[MAXROWWIDTH+1] ;
- char *usage = "pkfile[.pk] [[-x width] [-y height] [-c num] pbmfile]...";
+ char *usage = "pkfile[.pk] [-d] [[-x width] [-y height] [-c num] pbmfile]...";
pbm_init(&argc, argv);
for (i = 0 ; i < MAXPKCHAR ; i ++) filename[i] = NULL ;
- pm_message("This is PKtoPBM, version 2.4") ;
+ pm_message("This is PKtoPBM, version 2.5") ;
if (--argc < 1) pm_usage(usage) ;
@@ -184,19 +196,20 @@
pktopbm_add_suffix(pkname, ".pk") ;
car = 0 ;
+ /* urg: use getopt */
while (++argv, --argc) {
if (argv[0][0] == '-' && argv[0][1])
switch (argv[0][1]) {
case 'X':
case 'x':
if (argv[0][2]) bmx = atoi(*argv+2) ;
- else if (++argv, --argc) bmx = atoi(*argv) ;
+ else if (++argv, --argc) set_bmx = atoi(*argv) ;
else pm_usage(usage) ;
continue ;
case 'Y':
case 'y':
if (argv[0][2]) bmy = atoi(*argv+2) ;
- else if (++argv, --argc) bmy = atoi(*argv) ;
+ else if (++argv, --argc) set_bmy = atoi(*argv) ;
else pm_usage(usage) ;
continue ;
case 'C':
@@ -205,6 +218,9 @@
else if (++argv, --argc) car = atoi(*argv) ;
else pm_usage(usage) ;
break ;
+ case 'd':
+ debug=1;
+ break ;
default:
pm_usage(usage) ;
} else if (car < 0 || car >= MAXPKCHAR) {
@@ -229,6 +245,8 @@
integer xoffs=0, yoffs=0;
FILE *ofp;
+ bmx=set_bmx;
+ bmy=set_bmy;
dynf = (flagbyte>>4) ; /* get dynamic packing value */
flagbyte &= 15 ;
turnon = (flagbyte >= 8) ; /* black or white initially? */
@@ -237,61 +255,82 @@
integer packetlength = get32() ; /* character packet length */
car = get32() ; /* character number */
endofpacket = packetlength + pktopbm_pkloc ; /* calculate end of packet */
- if (car >= MAXPKCHAR || car < 0) {
+ if ((car >= MAXPKCHAR) || !filename[car]) {
ignorechar(car, endofpacket);
continue;
}
+ dprintf ("flagbyte7\n", 0);
+ dprintf ("car: %d\n", car);
get32() ; /* ignore tfmwidth */
- get32() ; /* ignore horiz escapement */
- get32() ; /* ignore vert escapement */
+ x=get32() ; /* ignore horiz escapement */
+ x=get32() ; /* ignore vert escapement */
+ dprintf ("horiz esc %d\n", x);
+ dprintf ("vert esc %d\n", x);
cwidth = get32() ; /* bounding box width */
cheight = get32() ; /* bounding box height */
+ dprintf ("cwidth %d\n", cwidth);
+ dprintf ("cheight %d\n", cheight);
if (cwidth < 0 || cheight < 0 || cwidth > 65535 || cheight > 65535) {
ignorechar(car, endofpacket);
continue;
}
- if (bmx) xoffs= get32() ; /* horiz offset */
- if (bmy) yoffs= get32() ; /* vert offset */
+ xoffs= get32() ; /* horiz offset */
+ yoffs= get32() ; /* vert offset */
+ dprintf ("xoffs %d\n", xoffs);
+ dprintf ("yoffs %d\n", yoffs);
} else if (flagbyte > 3) { /* extended short form */
integer packetlength = ((flagbyte - 4)<<16) + get16() ;
/* packet length */
car = pktopbm_pkbyte() ; /* char number */
endofpacket = packetlength + pktopbm_pkloc ; /* calculate end of packet */
- if (car >= MAXPKCHAR) {
+ if ((car >= MAXPKCHAR) || !filename[car]) {
ignorechar(car, endofpacket);
continue;
}
+ dprintf ("flagbyte>3\n", 0);
+ dprintf ("car: %d\n", car);
pktopbm_pkbyte() ; /* ignore tfmwidth (3 bytes) */
get16() ; /* ignore tfmwidth (3 bytes) */
get16() ; /* ignore horiz escapement */
cwidth = get16() ; /* bounding box width */
cheight = get16() ; /* bounding box height */
- if (bmx) /* horiz offset */
- if ((xoffs=get16()) >= 32768)
- xoffs-= 65536;
- if (bmy) /* vert offset */
- if ((yoffs=get16()) >= 32768)
- yoffs-= 65536;
+ dprintf ("cwidth %d\n", cwidth);
+ dprintf ("cheight %d\n", cheight);
+ xoffs=get16(); /* horiz offset */
+ if (xoffs >= 32768)
+ xoffs-= 65536;
+ yoffs=get16(); /* vert offset */
+ if (yoffs >= 32768)
+ yoffs-= 65536;
+ dprintf ("xoffs %d\n", xoffs);
+ dprintf ("yoffs %d\n", yoffs);
} else { /* short form preamble */
integer packetlength = (flagbyte<<8) + pktopbm_pkbyte() ;
/* packet length */
car = pktopbm_pkbyte() ; /* char number */
endofpacket = packetlength + pktopbm_pkloc ; /* calculate end of packet */
- if (car >= MAXPKCHAR) {
+ if ((car >= MAXPKCHAR) || !filename[car]) {
ignorechar(car, endofpacket);
continue;
}
+ dprintf ("flagbyte<=3\n", 0);
+ dprintf ("car: %d\n", car);
pktopbm_pkbyte() ; /* ignore tfmwidth (3 bytes) */
get16() ; /* ignore tfmwidth (3 bytes) */
- pktopbm_pkbyte() ; /* ignore horiz escapement */
+ x = pktopbm_pkbyte() ; /* ignore horiz escapement */
+ dprintf ("horiz esc %d\n", x);
cwidth = pktopbm_pkbyte() ; /* bounding box width */
cheight = pktopbm_pkbyte() ; /* bounding box height */
- if (bmx) /* horiz offset */
- if ((xoffs=pktopbm_pkbyte()) >= 128)
- xoffs-= 256;;
- if (bmy) /* vert offset */
- if ((yoffs=pktopbm_pkbyte()) >= 128)
- yoffs-= 256;;
+ dprintf ("cwidth %d\n", cwidth);
+ dprintf ("cheight %d\n", cheight);
+ xoffs=pktopbm_pkbyte (); /* horiz offset */
+ if (xoffs >= 128)
+ xoffs-=256;
+ yoffs=pktopbm_pkbyte (); /* vert offset */
+ if (yoffs >= 128)
+ yoffs-=256;
+ dprintf ("xoffs %d\n", xoffs);
+ dprintf ("yoffs %d\n", yoffs);
}
if (filename[car]) {
if (!bmx) bmx= cwidth;
@@ -304,10 +343,12 @@
continue;
}
bitweight = 0 ;
+ for (i = 0 ; i < bmy ; i ++) /* make it blank */
+ for (j = 0 ; j < bmx ; j ++)
+ bitmap[i][j]= PBM_WHITE;
if (dynf == 14) { /* bitmapped character */
- for (i = 0 ; i < bmy ; i ++) /* make it blank */
- for (j = 0 ; j < bmx ; j ++)
- bitmap[i][j]= PBM_WHITE;
+ dprintf ("bmy: %d\n ", bmy);
+ dprintf ("y: %d\n ", bmy-yoffs-1);
for (i = 0 ; i < cheight ; i ++) {
int yi= i+(bmy-yoffs-1);
for (j = 0 ; j < cwidth ; j ++) {
@@ -321,6 +362,8 @@
integer hbit = cwidth ;
integer rp = 0;
repeatcount = 0 ;
+ dprintf ("bmy: %d\n ", bmy);
+ dprintf ("y: %d\n", cheight-rowsleft+(bmy-2*yoffs-1));
while (rowsleft > 0) {
integer count = pkpackednum() ; /* get current colour count */
while (count > 0) {
@@ -333,7 +376,7 @@
while (hbit--)
row[rp++] = turnon ? PBM_BLACK : PBM_WHITE;
for (i = 0; i <= repeatcount; i++) { /* fill row */
- int yi= i+cheight-rowsleft+(bmy-yoffs-1);
+ int yi= i+cheight-rowsleft-1;
if (0<=yi && yi < bmy)
for (j = 0; j < cwidth; j++) {
int xj= j-xoffs;
--
Jan Nieuwenhuizen <[EMAIL PROTECTED]> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien/ | http://www.lilypond.org/