From f5c49b210a8b9d19f56a6a79a93ad7a8458d632e Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Sat, 22 Mar 2008 20:11:25 +0100
Subject: [PATCH] tools/sfnt2fnt: Merge the fnt2fon code into sfnt2fnt to allow
 generating fonts in a single step.

---
 fonts/.gitignore  |  56 --------
 fonts/Makefile.in | 326 ++++++++++++----------------------------------
 tools/sfnt2fnt.c  | 228 +++++++++++++++++++++++++++-----
 3 files changed, 279 insertions(+), 331 deletions(-)

diff --git a/fonts/.gitignore b/fonts/.gitignore
index c9d59404dfb..978a367a857 100644
--- a/fonts/.gitignore
+++ b/fonts/.gitignore
@@ -6,59 +6,16 @@
 /coureg.fon
 /courer.fon
 /couret.fon
-/courier-1250-96-13.fnt
-/courier-1251-96-13.fnt
-/courier-1252-96-13.fnt
-/courier-1253-96-13.fnt
-/courier-1254-96-13.fnt
-/courier-1255-96-13.fnt
-/courier-1256-96-13.fnt
-/courier-1257-96-13.fnt
 /courier.ttf
 /cvgasys.fon
 /hvgasys.fon
 /jsmalle.fon
 /jvgasys.fon
 /marlett.ttf
-/ms_sans_serif-1250-96-13.fnt
-/ms_sans_serif-1250-96-16.fnt
-/ms_sans_serif-1251-96-13.fnt
-/ms_sans_serif-1251-96-16.fnt
-/ms_sans_serif-1251-96-20.fnt
-/ms_sans_serif-1252-96-13.fnt
-/ms_sans_serif-1252-96-16.fnt
-/ms_sans_serif-1252-96-20.fnt
-/ms_sans_serif-1253-96-13.fnt
-/ms_sans_serif-1253-96-16.fnt
-/ms_sans_serif-1253-96-20.fnt
-/ms_sans_serif-1254-96-13.fnt
-/ms_sans_serif-1254-96-16.fnt
-/ms_sans_serif-1254-96-20.fnt
-/ms_sans_serif-1255-96-13.fnt
-/ms_sans_serif-1255-96-16.fnt
-/ms_sans_serif-1255-96-20.fnt
-/ms_sans_serif-1256-96-13.fnt
-/ms_sans_serif-1256-96-16.fnt
-/ms_sans_serif-1256-96-20.fnt
-/ms_sans_serif-1257-96-13.fnt
-/ms_sans_serif-1257-96-16.fnt
-/ms_sans_serif-1257-96-20.fnt
-/ms_sans_serif-874-96-13.fnt
-/ms_sans_serif-874-96-16.fnt
-/ms_sans_serif-874-96-20.fnt
 /ms_sans_serif.ttf
 /smae1255.fon
 /smae1256.fon
 /smae1257.fon
-/small_fonts-1250-96-11.fnt
-/small_fonts-1251-96-11.fnt
-/small_fonts-1252-96-11.fnt
-/small_fonts-1253-96-11.fnt
-/small_fonts-1254-96-11.fnt
-/small_fonts-1255-96-11.fnt
-/small_fonts-1256-96-11.fnt
-/small_fonts-1257-96-11.fnt
-/small_fonts-932-96-11.fnt
 /small_fonts.ttf
 /small_fonts_jp.ttf
 /smalle.fon
@@ -76,19 +33,6 @@
 /sserifer.fon
 /sserifet.fon
 /svgasys.fon
-/system-1250-96-16.fnt
-/system-1251-96-16.fnt
-/system-1252-96-16.fnt
-/system-1253-96-16.fnt
-/system-1254-96-16.fnt
-/system-1255-96-16.fnt
-/system-1256-96-16.fnt
-/system-1257-96-16.fnt
-/system-874-96-16.fnt
-/system-932-96-18.fnt
-/system-936-96-16.fnt
-/system-949-96-16.fnt
-/system-950-96-16.fnt
 /system.ttf
 /tahoma.ttf
 /tahomabd.ttf
diff --git a/fonts/Makefile.in b/fonts/Makefile.in
index a6732db7330..bb904ba65f5 100644
--- a/fonts/Makefile.in
+++ b/fonts/Makefile.in
@@ -60,290 +60,124 @@ all: $(FONTS)
 
 @MAKE_RULES@
 
-courier-1252-96-13.fnt: courier.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) courier.ttf 13 1252 96 128 8
+coure.fon: courier.ttf
+	$(LDPATH) $(SFNT2FNT) courier.ttf $@ 13,1252,96,128,8
 
-courier-1250-96-13.fnt: courier.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) courier.ttf 13 1250 96 128 8
+couree.fon: courier.ttf
+	$(LDPATH) $(SFNT2FNT) courier.ttf $@ 13,1250,96,128,8
 
-courier-1251-96-13.fnt: courier.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) courier.ttf 13 1251 96 128 8
+courer.fon: courier.ttf
+	$(LDPATH) $(SFNT2FNT) courier.ttf $@ 13,1251,96,128,8
 
-courier-1253-96-13.fnt: courier.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) courier.ttf 13 1253 96 128 8
+coureg.fon: courier.ttf
+	$(LDPATH) $(SFNT2FNT) courier.ttf $@ 13,1253,96,128,8
 
-courier-1254-96-13.fnt: courier.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) courier.ttf 13 1254 96 128 8
+couret.fon: courier.ttf
+	$(LDPATH) $(SFNT2FNT) courier.ttf $@ 13,1254,96,128,8
 
-courier-1255-96-13.fnt: courier.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) courier.ttf 13 1255 96 128 8
+coue1255.fon: courier.ttf
+	$(LDPATH) $(SFNT2FNT) courier.ttf $@ 13,1255,96,128,8
 
-courier-1256-96-13.fnt: courier.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) courier.ttf 13 1256 96 128 8
+coue1256.fon: courier.ttf
+	$(LDPATH) $(SFNT2FNT) courier.ttf $@ 13,1256,96,128,8
 
-courier-1257-96-13.fnt: courier.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) courier.ttf 13 1257 96 128 8
+coue1257.fon: courier.ttf
+	$(LDPATH) $(SFNT2FNT) courier.ttf $@ 13,1257,96,128,8
 
-ms_sans_serif-1252-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 1252 96 129 5
+sserife.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,1252,96,129,5 16,1252,96,129,7 20,1252,96,129,8
 
-ms_sans_serif-1252-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 1252 96 129 7
+sserifee.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,1250,96,129,5 16,1250,96,129,7
 
-ms_sans_serif-1252-96-20.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 20 1252 96 129 8
+sserifer.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,1251,96,129,5 16,1251,96,129,7 20,1251,96,129,8
 
-ms_sans_serif-1250-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 1250 96 129 5
+sserifeg.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,1253,96,129,5 16,1253,96,129,7 20,1253,96,129,8
 
-ms_sans_serif-1250-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 1250 96 129 7
+sserifet.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,1254,96,129,5 16,1254,96,129,7 20,1254,96,129,8
 
-ms_sans_serif-1251-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 1251 96 129 5
+ssee1255.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,1255,96,129,5 16,1255,96,129,7 20,1255,96,129,8
 
-ms_sans_serif-1251-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 1251 96 129 7
+ssee1256.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,1256,96,129,5 16,1256,96,129,7 20,1256,96,129,8
 
-ms_sans_serif-1251-96-20.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 20 1251 96 129 8
+ssee1257.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,1257,96,129,5 16,1257,96,129,7 20,1257,96,129,8
 
-ms_sans_serif-1253-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 1253 96 129 5
+ssee874.fon: ms_sans_serif.ttf
+	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf $@ 13,874,96,129,5 16,874,96,129,7 20,874,96,129,8
 
-ms_sans_serif-1253-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 1253 96 129 7
+smalle.fon: small_fonts.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts.ttf $@ 11,1252,96,128,5
 
-ms_sans_serif-1253-96-20.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 20 1253 96 129 8
+smallee.fon: small_fonts.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts.ttf $@ 11,1250,96,128,5
 
-ms_sans_serif-1254-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 1254 96 129 5
+smaller.fon: small_fonts.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts.ttf $@ 11,1251,96,128,5
 
-ms_sans_serif-1254-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 1254 96 129 7
+smalleg.fon: small_fonts.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts.ttf $@ 11,1253,96,128,5
 
-ms_sans_serif-1254-96-20.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 20 1254 96 129 8
+smallet.fon: small_fonts.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts.ttf $@ 11,1254,96,128,5
 
-ms_sans_serif-1255-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 1255 96 129 5
+smae1255.fon: small_fonts.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts.ttf $@ 11,1255,96,128,5
 
-ms_sans_serif-1255-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 1255 96 129 7
+smae1256.fon: small_fonts.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts.ttf $@ 11,1256,96,128,5
 
-ms_sans_serif-1255-96-20.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 20 1255 96 129 8
+smae1257.fon: small_fonts.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts.ttf $@ 11,1257,96,128,5
 
-ms_sans_serif-1256-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 1256 96 129 5
+jsmalle.fon: small_fonts_jp.ttf
+	$(LDPATH) $(SFNT2FNT) small_fonts_jp.ttf $@ 11,932,96,128,7
 
-ms_sans_serif-1256-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 1256 96 129 7
+vgasys.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,1252,96,128,7
 
-ms_sans_serif-1256-96-20.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 20 1256 96 129 8
+vgasyse.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,1250,96,128,7
 
-ms_sans_serif-1257-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 1257 96 129 5
+vgasysr.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,1251,96,128,7
 
-ms_sans_serif-1257-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 1257 96 129 7
+vgasysg.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,1253,96,128,7
 
-ms_sans_serif-1257-96-20.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 20 1257 96 129 8
+vgasyst.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,1254,96,128,7
 
-ms_sans_serif-874-96-13.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 13 874 96 129 5
+vgas1255.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,1255,96,128,7
 
-ms_sans_serif-874-96-16.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 16 874 96 129 7
+vgas1256.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,1256,96,128,7
 
-ms_sans_serif-874-96-20.fnt: ms_sans_serif.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) ms_sans_serif.ttf 20 874 96 129 8
+vgas1257.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,1257,96,128,7
 
-small_fonts-1252-96-11.fnt: small_fonts.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts.ttf 11 1252 96 128 5
+vgas874.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,874,96,128,7
 
-small_fonts-1250-96-11.fnt: small_fonts.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts.ttf 11 1250 96 128 5
+jvgasys.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 18,932,96,128,8
 
-small_fonts-1251-96-11.fnt: small_fonts.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts.ttf 11 1251 96 128 5
+svgasys.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,936,96,128,7 16,1252,96,128,7
 
-small_fonts-1253-96-11.fnt: small_fonts.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts.ttf 11 1253 96 128 5
+hvgasys.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,949,96,128,7
 
-small_fonts-1254-96-11.fnt: small_fonts.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts.ttf 11 1254 96 128 5
+cvgasys.fon: system.ttf
+	$(LDPATH) $(SFNT2FNT) system.ttf $@ 16,950,96,128,7 16,1252,96,128,7
 
-small_fonts-1255-96-11.fnt: small_fonts.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts.ttf 11 1255 96 128 5
-
-small_fonts-1256-96-11.fnt: small_fonts.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts.ttf 11 1256 96 128 5
-
-small_fonts-1257-96-11.fnt: small_fonts.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts.ttf 11 1257 96 128 5
-
-small_fonts-932-96-11.fnt: small_fonts_jp.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) small_fonts_jp.ttf 11 932 96 128 7
-
-system-1252-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 1252 96 128 7
-
-system-1250-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 1250 96 128 7
-
-system-1251-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 1251 96 128 7
-
-system-1253-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 1253 96 128 7
-
-system-1254-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 1254 96 128 7
-
-system-1255-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 1255 96 128 7
-
-system-1256-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 1256 96 128 7
-
-system-1257-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 1257 96 128 7
-
-system-874-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 874 96 128 7
-
-system-932-96-18.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 18 932 96 128 8
-
-system-936-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 936 96 128 7
-
-system-949-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 949 96 128 7
-
-system-950-96-16.fnt: system.ttf $(SFNT2FNT)
-	$(LDPATH) $(SFNT2FNT) system.ttf 16 950 96 128 7
-
-coure.fon: courier-1252-96-13.fnt $(FNT2FON)
-	$(FNT2FON) courier-1252-96-13.fnt $@
-
-couree.fon: courier-1250-96-13.fnt $(FNT2FON)
-	$(FNT2FON) courier-1250-96-13.fnt $@
-
-courer.fon: courier-1251-96-13.fnt $(FNT2FON)
-	$(FNT2FON) courier-1251-96-13.fnt $@
-
-coureg.fon: courier-1253-96-13.fnt $(FNT2FON)
-	$(FNT2FON) courier-1253-96-13.fnt $@
-
-couret.fon: courier-1254-96-13.fnt $(FNT2FON)
-	$(FNT2FON) courier-1254-96-13.fnt $@
-
-coue1255.fon: courier-1255-96-13.fnt $(FNT2FON)
-	$(FNT2FON) courier-1255-96-13.fnt $@
-
-coue1256.fon: courier-1256-96-13.fnt $(FNT2FON)
-	$(FNT2FON) courier-1256-96-13.fnt $@
-
-coue1257.fon: courier-1257-96-13.fnt $(FNT2FON)
-	$(FNT2FON) courier-1257-96-13.fnt $@
-
-sserife.fon: ms_sans_serif-1252-96-13.fnt ms_sans_serif-1252-96-16.fnt ms_sans_serif-1252-96-20.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-1252-96-13.fnt ms_sans_serif-1252-96-16.fnt ms_sans_serif-1252-96-20.fnt $@
-
-sserifee.fon: ms_sans_serif-1250-96-13.fnt ms_sans_serif-1250-96-16.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-1250-96-13.fnt ms_sans_serif-1250-96-16.fnt $@
-
-sserifer.fon: ms_sans_serif-1251-96-13.fnt ms_sans_serif-1251-96-16.fnt ms_sans_serif-1251-96-20.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-1251-96-13.fnt ms_sans_serif-1251-96-16.fnt ms_sans_serif-1251-96-20.fnt $@
-
-sserifeg.fon: ms_sans_serif-1253-96-13.fnt ms_sans_serif-1253-96-16.fnt ms_sans_serif-1253-96-20.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-1253-96-13.fnt ms_sans_serif-1253-96-16.fnt ms_sans_serif-1253-96-20.fnt $@
-
-sserifet.fon: ms_sans_serif-1254-96-13.fnt ms_sans_serif-1254-96-16.fnt ms_sans_serif-1254-96-20.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-1254-96-13.fnt ms_sans_serif-1254-96-16.fnt ms_sans_serif-1254-96-20.fnt $@
-
-ssee1255.fon: ms_sans_serif-1255-96-13.fnt ms_sans_serif-1255-96-16.fnt ms_sans_serif-1255-96-20.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-1255-96-13.fnt ms_sans_serif-1255-96-16.fnt ms_sans_serif-1255-96-20.fnt $@
-
-ssee1256.fon: ms_sans_serif-1256-96-13.fnt ms_sans_serif-1256-96-16.fnt ms_sans_serif-1256-96-20.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-1256-96-13.fnt ms_sans_serif-1256-96-16.fnt ms_sans_serif-1256-96-20.fnt $@
-
-ssee1257.fon: ms_sans_serif-1257-96-13.fnt ms_sans_serif-1257-96-16.fnt ms_sans_serif-1257-96-20.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-1257-96-13.fnt ms_sans_serif-1257-96-16.fnt ms_sans_serif-1257-96-20.fnt $@
-
-ssee874.fon: ms_sans_serif-874-96-13.fnt ms_sans_serif-874-96-16.fnt ms_sans_serif-874-96-20.fnt $(FNT2FON)
-	$(FNT2FON) ms_sans_serif-874-96-13.fnt ms_sans_serif-874-96-16.fnt ms_sans_serif-874-96-20.fnt $@
-
-smalle.fon: small_fonts-1252-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-1252-96-11.fnt $@
-
-smallee.fon: small_fonts-1250-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-1250-96-11.fnt $@
-
-smaller.fon: small_fonts-1251-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-1251-96-11.fnt $@
-
-smalleg.fon: small_fonts-1253-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-1253-96-11.fnt $@
-
-smallet.fon: small_fonts-1254-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-1254-96-11.fnt $@
-
-smae1255.fon: small_fonts-1255-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-1255-96-11.fnt $@
-
-smae1256.fon: small_fonts-1256-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-1256-96-11.fnt $@
-
-smae1257.fon: small_fonts-1257-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-1257-96-11.fnt $@
-
-jsmalle.fon: small_fonts-932-96-11.fnt $(FNT2FON)
-	$(FNT2FON) small_fonts-932-96-11.fnt $@
-
-vgasys.fon: system-1252-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-1252-96-16.fnt $@
-
-vgasyse.fon: system-1250-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-1250-96-16.fnt $@
-
-vgasysr.fon: system-1251-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-1251-96-16.fnt $@
-
-vgasysg.fon: system-1253-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-1253-96-16.fnt $@
-
-vgasyst.fon: system-1254-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-1254-96-16.fnt $@
-
-vgas1255.fon: system-1255-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-1255-96-16.fnt $@
-
-vgas1256.fon: system-1256-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-1256-96-16.fnt $@
-
-vgas1257.fon: system-1257-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-1257-96-16.fnt $@
-
-vgas874.fon: system-874-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-874-96-16.fnt $@
-
-jvgasys.fon: system-932-96-18.fnt $(FNT2FON)
-	$(FNT2FON) system-932-96-18.fnt $@
-
-svgasys.fon: system-936-96-16.fnt system-1252-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-936-96-16.fnt system-1252-96-16.fnt $@
-
-hvgasys.fon: system-949-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-949-96-16.fnt $@
-
-cvgasys.fon: system-950-96-16.fnt system-1252-96-16.fnt $(FNT2FON)
-	$(FNT2FON) system-950-96-16.fnt system-1252-96-16.fnt $@
+$(BITMAP_FONTS): $(SFNT2FNT)
 
 install:: $(FONTS) $(INSTALLDIRS)
 	for i in $(FONTS); do $(INSTALL_DATA) $$i $(DESTDIR)$(fontdir)/$$i || exit 1; done
@@ -353,4 +187,4 @@ uninstall::
 	-rmdir $(DESTDIR)$(fontdir)
 
 clean::
-	$(RM) *.fon *.fnt *.ttf
+	$(RM) *.fon *.ttf
diff --git a/tools/sfnt2fnt.c b/tools/sfnt2fnt.c
index b01f7db8bf3..5e1f555bab3 100644
--- a/tools/sfnt2fnt.c
+++ b/tools/sfnt2fnt.c
@@ -23,6 +23,7 @@
 
 #include <assert.h>
 #include <ctype.h>
+#include <errno.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -115,6 +116,18 @@ struct fontinfo
     BYTE *data;
 };
 
+static const BYTE MZ_hdr[] =
+{
+    'M',  'Z',  0x0d, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
+    0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+    0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 'T',  'h',
+    'i',  's',  ' ',  'P',  'r',  'o',  'g',  'r',  'a',  'm',  ' ',  'c',  'a',  'n',  'n',  'o',
+    't',  ' ',  'b',  'e',  ' ',  'r',  'u',  'n',  ' ',  'i',  'n',  ' ',  'D',  'O',  'S',  ' ',
+    'm',  'o',  'd',  'e',  0x0d, 0x0a, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
 static const char *output_name;
 
 static FT_Library ft_library;
@@ -502,43 +515,94 @@ static void write_fontinfo( const struct fontinfo *info, FILE *fp )
 
 int main(int argc, char **argv)
 {
-    int ppem, enc;
-    int dpi, avg_width;
-    unsigned int def_char;
-    FILE *fp;
-    char output[256];
-    char name[256];
-    char *cp;
-    struct fontinfo *info;
+    int i, j;
+    FILE *ofp;
+    short align, num_files;
+    int resource_table_len, non_resident_name_len, resident_name_len;
+    unsigned short resource_table_off, resident_name_off, module_ref_off, non_resident_name_off, fontdir_off, font_off;
+    char resident_name[200];
+    int fontdir_len = 2;
+    char non_resident_name[200];
+    unsigned short first_res = 0x0050, pad, res;
+    IMAGE_OS2_HEADER NE_hdr;
+    NE_TYPEINFO rc_type;
+    NE_NAMEINFO rc_name;
+    struct fontinfo **info;
+    char *p;
 
-    if(argc != 7) {
+    if(argc <= 3) {
         usage(argv);
-        exit(0);
+        exit(1);
     }
 
-    ppem = atoi(argv[2]);
-    enc = atoi(argv[3]);
-    dpi = atoi(argv[4]);
-    def_char = atoi(argv[5]);
-    avg_width = atoi(argv[6]);
-
     if(FT_Init_FreeType(&ft_library))
         error("ft init failure\n");
 
     FT_Version.major=FT_Version.minor=FT_Version.patch=-1;
     FT_Library_Version(ft_library,&FT_Version.major,&FT_Version.minor,&FT_Version.patch);
 
-    if (!(info = fill_fontinfo( argv[1], ppem, enc, dpi, def_char, avg_width ))) exit(1);
-
-    strcpy(name, get_face_name(info));
-    /* FIXME: should add a -o option instead */
-    for(cp = name; *cp; cp++)
+    num_files = argc - 3;
+    info = malloc( num_files * sizeof(*info) );
+    for (i = 0; i < num_files; i++)
     {
-        if(*cp == ' ') *cp = '_';
-        else if (*cp >= 'A' && *cp <= 'Z') *cp += 'a' - 'A';
+        int ppem, enc, dpi, def_char, avg_width;
+        const char *name;
+
+        if (sscanf( argv[i+3], "%d,%d,%d,%d,%d", &ppem, &enc, &dpi, &def_char, &avg_width ) != 5)
+        {
+            usage(argv);
+            exit(1);
+        }
+        if (!(info[i] = fill_fontinfo( argv[1], ppem, enc, dpi, def_char, avg_width ))) exit(1);
+
+        name = get_face_name( info[i] );
+        fontdir_len += 0x74 + strlen(name) + 1;
+        if(i == 0) {
+            sprintf(non_resident_name, "FONTRES 100,%d,%d : %s %d",
+                    info[i]->hdr.fi.dfVertRes, info[i]->hdr.fi.dfHorizRes,
+                    name, info[i]->hdr.fi.dfPoints );
+            strcpy(resident_name, name);
+        } else {
+            sprintf(non_resident_name + strlen(non_resident_name), ",%d", info[i]->hdr.fi.dfPoints );
+        }
     }
 
-    sprintf(output, "%s-%d-%d-%d.fnt", name, enc, dpi, ppem);
+    if(info[0]->hdr.fi.dfVertRes <= 108)
+        strcat(non_resident_name, " (VGA res)");
+    else
+        strcat(non_resident_name, " (8514 res)");
+    non_resident_name_len = strlen(non_resident_name) + 4;
+
+    /* shift count + fontdir entry + num_files of font + nul type + \007FONTDIR */
+    resource_table_len = sizeof(align) + sizeof("FONTDIR") +
+                         sizeof(NE_TYPEINFO) + sizeof(NE_NAMEINFO) +
+                         sizeof(NE_TYPEINFO) + sizeof(NE_NAMEINFO) * num_files +
+                         sizeof(NE_TYPEINFO);
+    resource_table_off = sizeof(NE_hdr);
+    resident_name_off = resource_table_off + resource_table_len;
+    resident_name_len = strlen(resident_name) + 4;
+    module_ref_off = resident_name_off + resident_name_len;
+    non_resident_name_off = sizeof(MZ_hdr) + module_ref_off + sizeof(align);
+
+    memset(&NE_hdr, 0, sizeof(NE_hdr));
+    NE_hdr.ne_magic = 0x454e;
+    NE_hdr.ne_ver = 5;
+    NE_hdr.ne_rev = 1;
+    NE_hdr.ne_flags = NE_FFLAGS_LIBMODULE | NE_FFLAGS_GUI;
+    NE_hdr.ne_cbnrestab = non_resident_name_len;
+    NE_hdr.ne_segtab = sizeof(NE_hdr);
+    NE_hdr.ne_rsrctab = sizeof(NE_hdr);
+    NE_hdr.ne_restab = resident_name_off;
+    NE_hdr.ne_modtab = module_ref_off;
+    NE_hdr.ne_imptab = module_ref_off;
+    NE_hdr.ne_enttab = NE_hdr.ne_modtab;
+    NE_hdr.ne_nrestab = non_resident_name_off;
+    NE_hdr.ne_align = 4;
+    NE_hdr.ne_exetyp = NE_OSFLAGS_WINDOWS;
+    NE_hdr.ne_expver = 0x400;
+
+    fontdir_off = (non_resident_name_off + non_resident_name_len + 15) & ~0xf;
+    font_off = (fontdir_off + fontdir_len + 15) & ~0x0f;
 
     atexit( cleanup );
     signal( SIGTERM, exit_on_signal );
@@ -547,14 +611,120 @@ int main(int argc, char **argv)
     signal( SIGHUP, exit_on_signal );
 #endif
 
-    if (!(fp = fopen(output, "w")))
+    /* check for .fnt extension on output file (FIXME: should be a cmdline option instead) */
+    if ((p = strrchr( argv[2], '.' )) && !strcmp( p, ".fnt" ))
     {
-        perror( output );
+        if (num_files > 1) error( ".fnt generation mode can only contain one font\n" );
+        output_name = argv[2];
+        if (!(ofp = fopen(output_name, "wb")))
+        {
+            perror( output_name );
+            exit(1);
+        }
+        write_fontinfo( info[0], ofp );
+        fclose( ofp );
+        output_name = NULL;
+        exit(0);
+    }
+
+    output_name = argv[2];
+    if (!(ofp = fopen(output_name, "wb")))
+    {
+        perror( output_name );
         exit(1);
     }
-    output_name = output;
-    write_fontinfo( info, fp );
-    fclose(fp);
+
+    fwrite(MZ_hdr, sizeof(MZ_hdr), 1, ofp);
+    fwrite(&NE_hdr, sizeof(NE_hdr), 1, ofp);
+
+    align = 4;
+    fwrite(&align, sizeof(align), 1, ofp);
+
+    rc_type.type_id = NE_RSCTYPE_FONTDIR;
+    rc_type.count = 1;
+    rc_type.resloader = 0;
+    fwrite(&rc_type, sizeof(rc_type), 1, ofp);
+
+    rc_name.offset = fontdir_off >> 4;
+    rc_name.length = (fontdir_len + 15) >> 4;
+    rc_name.flags = NE_SEGFLAGS_MOVEABLE | NE_SEGFLAGS_PRELOAD;
+    rc_name.id = resident_name_off - sizeof("FONTDIR") - NE_hdr.ne_rsrctab;
+    rc_name.handle = 0;
+    rc_name.usage = 0;
+    fwrite(&rc_name, sizeof(rc_name), 1, ofp);
+
+    rc_type.type_id = NE_RSCTYPE_FONT;
+    rc_type.count = num_files;
+    rc_type.resloader = 0;
+    fwrite(&rc_type, sizeof(rc_type), 1, ofp);
+
+    for(res = first_res | 0x8000, i = 0; i < num_files; i++, res++) {
+        int len = (info[i]->hdr.dfSize + 15) & ~0xf;
+
+        rc_name.offset = font_off >> 4;
+        rc_name.length = len >> 4;
+        rc_name.flags = NE_SEGFLAGS_MOVEABLE | NE_SEGFLAGS_SHAREABLE | NE_SEGFLAGS_DISCARDABLE;
+        rc_name.id = res;
+        rc_name.handle = 0;
+        rc_name.usage = 0;
+        fwrite(&rc_name, sizeof(rc_name), 1, ofp);
+
+        font_off += len;
+    }
+
+    /* empty type info */
+    memset(&rc_type, 0, sizeof(rc_type));
+    fwrite(&rc_type, sizeof(rc_type), 1, ofp);
+
+    fputc(strlen("FONTDIR"), ofp);
+    fwrite("FONTDIR", strlen("FONTDIR"), 1, ofp);
+    fputc(strlen(resident_name), ofp);
+    fwrite(resident_name, strlen(resident_name), 1, ofp);
+
+    fputc(0x00, ofp);    fputc(0x00, ofp);
+    fputc(0x00, ofp);
+    fputc(0x00, ofp);    fputc(0x00, ofp);
+
+    fputc(strlen(non_resident_name), ofp);
+    fwrite(non_resident_name, strlen(non_resident_name), 1, ofp);
+    fputc(0x00, ofp); /* terminator */
+
+    /* empty ne_modtab and ne_imptab */
+    fputc(0x00, ofp);
+    fputc(0x00, ofp);
+
+    pad = ftell(ofp) & 0xf;
+    if(pad != 0)
+        pad = 0x10 - pad;
+    for(i = 0; i < pad; i++)
+        fputc(0x00, ofp);
+
+    /* FONTDIR resource */
+    fwrite(&num_files, sizeof(num_files), 1, ofp);
+
+    for(res = first_res, i = 0; i < num_files; i++, res++) {
+        const char *name = get_face_name( info[i] );
+        fwrite(&res, sizeof(res), 1, ofp);
+        fwrite(&info[i]->hdr, FIELD_OFFSET(FNT_HEADER,fi.dfBitsOffset), 1, ofp);
+        fputc(0x00, ofp);
+        fwrite(name, strlen(name) + 1, 1, ofp);
+    }
+
+    pad = ftell(ofp) & 0xf;
+    if(pad != 0)
+        pad = 0x10 - pad;
+    for(i = 0; i < pad; i++)
+        fputc(0x00, ofp);
+
+    for(res = first_res, i = 0; i < num_files; i++, res++) {
+        write_fontinfo( info[i], ofp );
+        pad = info[i]->hdr.dfSize & 0xf;
+        if(pad != 0)
+            pad = 0x10 - pad;
+        for(j = 0; j < pad; j++)
+            fputc(0x00, ofp);
+    }
+    fclose(ofp);
     output_name = NULL;
     exit(0);
 }