Commit 00acb5f7 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

First stab at Wine versions of Courier, System and MS Sans Serif

fonts.
parent 2e9436c0
...@@ -51,6 +51,7 @@ RM = rm -f ...@@ -51,6 +51,7 @@ RM = rm -f
MV = mv MV = mv
LINT = @LINT@ LINT = @LINT@
LINTFLAGS = @LINTFLAGS@ LINTFLAGS = @LINTFLAGS@
FONTFORGE = @FONTFORGE@
INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL) INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
EXTRACFLAGS = @EXTRACFLAGS@ EXTRACFLAGS = @EXTRACFLAGS@
ALLCFLAGS = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) ALLCFLAGS = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS)
...@@ -68,6 +69,8 @@ BIN2RES = $(TOOLSDIR)/tools/bin2res ...@@ -68,6 +69,8 @@ BIN2RES = $(TOOLSDIR)/tools/bin2res
WMC = $(TOOLSDIR)/tools/wmc/wmc WMC = $(TOOLSDIR)/tools/wmc/wmc
WIDL = $(TOOLSDIR)/tools/widl/widl WIDL = $(TOOLSDIR)/tools/widl/widl
WINEGCC = $(TOOLSDIR)/tools/winegcc/winegcc WINEGCC = $(TOOLSDIR)/tools/winegcc/winegcc
SFNT2FNT = $(TOOLSDIR)/tools/sfnt2fnt
FNT2FON = $(TOOLSDIR)/tools/fnt2fon
RC = $(WRC) RC = $(WRC)
RC16 = $(WRC) RC16 = $(WRC)
RCFLAGS = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS) RCFLAGS = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
...@@ -110,7 +113,7 @@ LINTS = $(C_SRCS:.c=.ln) ...@@ -110,7 +113,7 @@ LINTS = $(C_SRCS:.c=.ln)
# Implicit rules # Implicit rules
.SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .ok .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .ok .sfd .ttf
.c.o: .c.o:
$(CC) -c $(ALLCFLAGS) -o $@ $< $(CC) -c $(ALLCFLAGS) -o $@ $<
...@@ -139,6 +142,9 @@ LINTS = $(C_SRCS:.c=.ln) ...@@ -139,6 +142,9 @@ LINTS = $(C_SRCS:.c=.ln)
.c.ok: .c.ok:
$(RUNTEST) $(RUNTESTFLAGS) $< && touch $@ $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
.sfd.ttf:
$(FONTFORGE) -script $(TOPSRCDIR)/fonts/genttf.ff $<
# 'all' target first in case the enclosing Makefile didn't define any target # 'all' target first in case the enclosing Makefile didn't define any target
all: Makefile all: Makefile
......
...@@ -26,10 +26,13 @@ LDCONFIG = @LDCONFIG@ ...@@ -26,10 +26,13 @@ LDCONFIG = @LDCONFIG@
LDD = @LDD@ LDD = @LDD@
MODULE = none MODULE = none
FONTSSUBDIRS = @FONTSSUBDIRS@
# Sub-directories to run make depend/clean into # Sub-directories to run make depend/clean into
SUBDIRS = \ SUBDIRS = \
dlls \ dlls \
documentation \ documentation \
fonts \
include \ include \
libs \ libs \
loader \ loader \
...@@ -40,6 +43,7 @@ SUBDIRS = \ ...@@ -40,6 +43,7 @@ SUBDIRS = \
# Sub-directories to install for install-lib # Sub-directories to install for install-lib
INSTALLLIBSUBDIRS = \ INSTALLLIBSUBDIRS = \
documentation \ documentation \
$(FONTSSUBDIRS) \
loader \ loader \
programs \ programs \
server server
...@@ -103,15 +107,14 @@ uninstall:: $(INSTALLBOTHSUBDIRS:%=%/__uninstall__) ...@@ -103,15 +107,14 @@ uninstall:: $(INSTALLBOTHSUBDIRS:%=%/__uninstall__)
# Dependencies between directories # Dependencies between directories
all: $(SUBDIRS) all: $(INSTALLSUBDIRS) $(INSTALLBOTHSUBDIRS)
dlls: libs tools dlls fonts loader server: libs tools
loader server: libs tools
programs: dlls libs tools programs: dlls libs tools
tools: libs tools: libs
dlls/__install-lib__ dlls/__install-dev__: libs tools dlls/__install-lib__ dlls/__install-dev__: libs tools
libs/__install-lib__ libs/__install-dev__: libs libs/__install-lib__ libs/__install-dev__: libs
loader/__install__ server/__install__: libs tools fonts/__install__ loader/__install__ server/__install__: libs tools
programs/__install__: libs tools dlls/__install-lib__ programs/__install__: libs tools dlls/__install-lib__
tools/__install__: tools tools/__install__: tools
......
...@@ -107,21 +107,12 @@ fi ...@@ -107,21 +107,12 @@ fi
AC_SUBST(LINT) AC_SUBST(LINT)
AC_SUBST(LINTFLAGS) AC_SUBST(LINTFLAGS)
dnl Check for db2html dnl Check for various programs
AC_CHECK_PROGS(DB2HTML, docbook2html db2html, false) AC_CHECK_PROGS(DB2HTML, docbook2html db2html, false)
AC_SUBST(DB2HTML)
dnl Check for db2pdf
AC_CHECK_PROGS(DB2PDF, docbook2pdf db2pdf, false) AC_CHECK_PROGS(DB2PDF, docbook2pdf db2pdf, false)
AC_SUBST(DB2PDF)
dnl Check for db2ps
AC_CHECK_PROGS(DB2PS, docbook2ps db2ps, false) AC_CHECK_PROGS(DB2PS, docbook2ps db2ps, false)
AC_SUBST(DB2PS)
dnl Check for db2txt
AC_CHECK_PROGS(DB2TXT, docbook2txt db2txt, false) AC_CHECK_PROGS(DB2TXT, docbook2txt db2txt, false)
AC_SUBST(DB2TXT) AC_CHECK_PROGS(FONTFORGE, fontforge, false)
dnl **** Check for some libraries **** dnl **** Check for some libraries ****
...@@ -418,6 +409,7 @@ dnl **** Check for FreeType 2 **** ...@@ -418,6 +409,7 @@ dnl **** Check for FreeType 2 ****
AC_CHECK_LIB(freetype,FT_Init_FreeType,ft_lib=yes,ft_lib=no,$X_LIBS) AC_CHECK_LIB(freetype,FT_Init_FreeType,ft_lib=yes,ft_lib=no,$X_LIBS)
if test "$ft_lib" = "no" if test "$ft_lib" = "no"
then then
FREETYPELIBS=""
FREETYPEINCL="" FREETYPEINCL=""
wine_cv_msg_freetype=no wine_cv_msg_freetype=no
else else
...@@ -432,9 +424,11 @@ else ...@@ -432,9 +424,11 @@ else
fi fi
if test "$ft_devel" = "no" if test "$ft_devel" = "no"
then then
FREETYPELIBS=""
FREETYPEINCL="" FREETYPEINCL=""
wine_cv_msg_freetype=yes wine_cv_msg_freetype=yes
else else
FREETYPELIBS=`$ft_devel --libs`
FREETYPEINCL=`$ft_devel --cflags` FREETYPEINCL=`$ft_devel --cflags`
ac_save_CPPFLAGS="$CPPFLAGS" ac_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$FREETYPEINCL $CPPFLAGS" CPPFLAGS="$FREETYPEINCL $CPPFLAGS"
...@@ -464,13 +458,21 @@ else ...@@ -464,13 +458,21 @@ else
AC_DEFINE(HAVE_FREETYPE, 1, [Define if FreeType 2 is installed]) AC_DEFINE(HAVE_FREETYPE, 1, [Define if FreeType 2 is installed])
wine_cv_msg_freetype=no wine_cv_msg_freetype=no
else else
FREETYPELIBS=""
FREETYPEINCL="" FREETYPEINCL=""
wine_cv_msg_freetype=yes wine_cv_msg_freetype=yes
fi fi
fi fi
fi fi
AC_SUBST(FREETYPELIBS)
AC_SUBST(FREETYPEINCL) AC_SUBST(FREETYPEINCL)
dnl Only build the fonts dir if we have both freetype and fontforge
if test "$FONTFORGE" != "false" -a -n "$FREETYPELIBS"
then
AC_SUBST(FONTSSUBDIRS,"fonts")
fi
dnl **** Check for parport (currently Linux only) **** dnl **** Check for parport (currently Linux only) ****
AC_CACHE_CHECK([for parport header/ppdev.h], ac_cv_c_ppdev, AC_CACHE_CHECK([for parport header/ppdev.h], ac_cv_c_ppdev,
AC_TRY_COMPILE( AC_TRY_COMPILE(
...@@ -1693,6 +1695,7 @@ dlls/wow32/Makefile ...@@ -1693,6 +1695,7 @@ dlls/wow32/Makefile
dlls/wsock32/Makefile dlls/wsock32/Makefile
dlls/x11drv/Makefile dlls/x11drv/Makefile
documentation/Makefile documentation/Makefile
fonts/Makefile
include/Makefile include/Makefile
libs/Makefile libs/Makefile
libs/port/Makefile libs/port/Makefile
......
Makefile
wine_coure.fon
wine_courier-1252-96-13.fnt
wine_courier.ttf
wine_sans_serif-1250-96-13.fnt
wine_sans_serif-1250-96-16.fnt
wine_sans_serif-1252-96-13.fnt
wine_sans_serif-1252-96-16.fnt
wine_sans_serif.ttf
wine_sserife.fon
wine_sserifee.fon
wine_system-1252-96-16.fnt
wine_system.ttf
wine_vgasys.fon
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = none
fontdir = $(datadir)/fonts/wine
BITMAP_FONTS = \
wine_coure.fon \
wine_sserife.fon \
wine_sserifee.fon \
wine_vgasys.fon
TRUETYPE_FONTS =
FONTS = \
$(BITMAP_FONTS) \
$(TRUETYPE_FONTS)
all: $(FONTS)
@MAKE_RULES@
wine_courier-1252-96-13.fnt: wine_courier.ttf $(SFNT2FNT)
$(LDPATH) $(SFNT2FNT) wine_courier.ttf 13 1252 96 128
wine_sans_serif-1252-96-13.fnt: wine_sans_serif.ttf $(SFNT2FNT)
$(LDPATH) $(SFNT2FNT) wine_sans_serif.ttf 13 1252 96 129
wine_sans_serif-1252-96-16.fnt: wine_sans_serif.ttf $(SFNT2FNT)
$(LDPATH) $(SFNT2FNT) wine_sans_serif.ttf 16 1252 96 129
wine_sans_serif-1250-96-13.fnt: wine_sans_serif.ttf $(SFNT2FNT)
$(LDPATH) $(SFNT2FNT) wine_sans_serif.ttf 13 1250 96 129
wine_sans_serif-1250-96-16.fnt: wine_sans_serif.ttf $(SFNT2FNT)
$(LDPATH) $(SFNT2FNT) wine_sans_serif.ttf 16 1250 96 129
wine_system-1252-96-16.fnt: wine_system.ttf $(SFNT2FNT)
$(LDPATH) $(SFNT2FNT) wine_system.ttf 16 1252 96 128
wine_sserife.fon: wine_sans_serif-1252-96-13.fnt wine_sans_serif-1252-96-16.fnt $(FNT2FON)
$(FNT2FON) wine_sans_serif-1252-96-13.fnt wine_sans_serif-1252-96-16.fnt wine_sserife.fon
wine_sserifee.fon: wine_sans_serif-1250-96-13.fnt wine_sans_serif-1250-96-16.fnt $(FNT2FON)
$(FNT2FON) wine_sans_serif-1250-96-13.fnt wine_sans_serif-1250-96-16.fnt wine_sserifee.fon
wine_vgasys.fon: wine_system-1252-96-16.fnt $(FNT2FON)
$(FNT2FON) wine_system-1252-96-16.fnt wine_vgasys.fon
wine_coure.fon: wine_courier-1252-96-13.fnt $(FNT2FON)
$(FNT2FON) wine_courier-1252-96-13.fnt wine_coure.fon
install:: $(FONTS)
$(MKINSTALLDIRS) $(fontdir)
for i in $(FONTS); do $(INSTALL_DATA) $$i $(fontdir)/$$i || exit 1; done
uninstall::
-cd $(fontdir) && $(RM) $(FONTS)
-rmdir $(fontdir)
clean::
$(RM) *.fon *.fnt *.ttf
### Dependencies:
Open($1)
ttfname = $1:r + ".ttf"
Generate(ttfname, "ttf", 0);
Makefile Makefile
bin2res bin2res
fnt2bdf fnt2bdf
fnt2fon
makedep makedep
sfnt2fnt
wineprefixcreate wineprefixcreate
...@@ -4,17 +4,23 @@ TOPOBJDIR = .. ...@@ -4,17 +4,23 @@ TOPOBJDIR = ..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = none MODULE = none
EXTRAINCL = @FREETYPEINCL@
FREETYPELIBS = @FREETYPELIBS@
PROGRAMS = \ PROGRAMS = \
bin2res \ bin2res \
fnt2bdf \ fnt2bdf \
fnt2fon \
makedep \ makedep \
sfnt2fnt \
wineprefixcreate wineprefixcreate
C_SRCS = \ C_SRCS = \
bin2res.c \ bin2res.c \
fnt2bdf.c \ fnt2bdf.c \
makedep.c fnt2fon.c \
makedep.c \
sfnt2fnt.c \
SUBDIRS = \ SUBDIRS = \
widl \ widl \
...@@ -40,6 +46,12 @@ makedep: makedep.o ...@@ -40,6 +46,12 @@ makedep: makedep.o
fnt2bdf: fnt2bdf.o fnt2bdf: fnt2bdf.o
$(CC) $(CFLAGS) -o fnt2bdf fnt2bdf.o $(LIBPORT) $(CC) $(CFLAGS) -o fnt2bdf fnt2bdf.o $(LIBPORT)
fnt2fon: fnt2fon.o
$(CC) $(CFLAGS) -o fnt2fon fnt2fon.o $(LIBPORT)
sfnt2fnt: sfnt2fnt.o
$(CC) $(CFLAGS) -o sfnt2fnt sfnt2fnt.o $(FREETYPELIBS) $(LIBUNICODE) $(LIBPORT)
bin2res: bin2res.o bin2res: bin2res.o
$(CC) $(CFLAGS) -o bin2res bin2res.o $(LIBPORT) $(CC) $(CFLAGS) -o bin2res bin2res.o $(LIBPORT)
......
/*
* fnttofon. Combine several fnt files in one fon file
*
* Copyright 2004 Huw Davies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
unsigned char 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
};
unsigned char NE_hdr[] = {'N', 'E', 0x05, 0x01, 0xff, 0xff, 0x02, 0x00, 0x5c, 0x35, 0xe4, 0x41, 0x00, 0x83, 0x00, 0x00,
/* entry table tbd, 2 bytes long. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x40, 0x00, 0x40, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
/* tbd bytes in non-resident name table, off of seg table 0x40, off of resource table 0x40, off of
resident name table (tbd) etc */
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04
};
static void usage(char **argv)
{
fprintf(stderr, "%s fntfiles output.fon\n", argv[0]);
return;
}
int main(int argc, char **argv)
{
int num_files, i, j;
FILE *fp, *ofp;
long off;
char name[200];
int c;
char *cp;
short pt, ver, dpi[2];
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, fontdir_len_shift;
char non_resident_name[200] = "";
int *file_lens, nread;
int first_res = 0x0050, pad, res;
char fnt_header[0x100];
char buf[0x1000];
if(argc < 3) {
usage(argv);
exit(1);
}
num_files = argc - 2;
file_lens = malloc(num_files * sizeof(int));
for(i = 0; i < num_files; i++) {
fp = fopen(argv[i+1], "r");
if(!fp) {
fprintf(stderr, "Can't open %s\n", argv[i+1]);
usage(argv);
exit(1);
}
fread(&ver, sizeof(short), 1, fp);
if(ver != 0x200 && ver != 0x300) {
fprintf(stderr, "invalid fnt file %s ver %d\n", argv[i+1], ver);
exit(1);
}
fread(file_lens + i, sizeof(int), 1, fp);
fseek(fp, 0x44, SEEK_SET);
fread(&pt, sizeof(short), 1, fp);
fread(dpi, sizeof(short), 2, fp);
fseek(fp, 0x69, SEEK_SET);
fread(&off, sizeof(long), 1, fp);
fseek(fp, off, SEEK_SET);
cp = name;
while((c = fgetc(fp)) != 0 && c != EOF)
*cp++ = c;
*cp = '\0';
fprintf(stderr, "%s %d pts %dx%d dpi\n", name, pt, dpi[0], dpi[1]);
fclose(fp);
fontdir_len += 0x74 + strlen(name) + 1; /* FIXME does the fontdir entry for version 3 fonts differ from 2? */
if(i == 0) {
sprintf(non_resident_name, "FONTRES 100,%d,%d : %s %d", dpi[0], dpi[1], name, pt);
strcpy(resident_name, name);
} else {
sprintf(non_resident_name + strlen(non_resident_name), ",%d", pt);
}
}
if(dpi[0] <= 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 = 2 + 20 + 8 + 12 * num_files + 2 + 8;
resource_table_off = NE_hdr[0x24];
resource_table_off |= (NE_hdr[0x25] << 8);
resident_name_off = resource_table_off + resource_table_len;
NE_hdr[0x20] = non_resident_name_len & 0xff;
NE_hdr[0x21] = (non_resident_name_len >> 8) & 0xff;
NE_hdr[0x26] = resident_name_off & 0xff;
NE_hdr[0x27] = (resident_name_off >> 8) & 0xff;
resident_name_len = strlen(resident_name) + 4;
module_ref_off = resident_name_off + resident_name_len;
NE_hdr[0x28] = module_ref_off & 0xff;
NE_hdr[0x29] = (module_ref_off >> 8) & 0xff;
NE_hdr[0x2a] = NE_hdr[0x28];
NE_hdr[0x2b] = NE_hdr[0x29];
NE_hdr[0x04] = NE_hdr[0x28];
NE_hdr[0x05] = NE_hdr[0x29];
non_resident_name_off = 0x80 + module_ref_off + 2;
NE_hdr[0x2c] = non_resident_name_off & 0xff;
NE_hdr[0x2d] = (non_resident_name_off >> 8) & 0xff;
fontdir_off = (non_resident_name_off + non_resident_name_len + 15) & ~0xf;
font_off = (fontdir_off + fontdir_len + 15) & ~0x0f;
ofp = fopen(argv[argc - 1], "w");
fwrite(MZ_hdr, sizeof(MZ_hdr), 1, ofp);
fwrite(NE_hdr, sizeof(NE_hdr), 1, ofp);
fputc(0x04, ofp);
fputc(0x00, ofp); /* shift of 4 */
fputc(0x07, ofp);
fputc(0x80, ofp); /* type 0x8007 */
fputc(0x01, ofp);
fputc(0x00, ofp); /* 1 off */
fputc(0x00, ofp); fputc(0x00, ofp); fputc(0x00, ofp); fputc(0x00, ofp);
fontdir_off >>= 4;
fputc(fontdir_off & 0xff, ofp);
fputc((fontdir_off >> 8) & 0xff, ofp);
fontdir_len_shift = (fontdir_len + 15) >> 4;
fputc(fontdir_len_shift & 0xff, ofp);
fputc((fontdir_len_shift >> 8) & 0xff, ofp);
fputc(0x50, ofp);
fputc(0x0c, ofp);
fputc(0x7c, ofp);
fputc(0x00, ofp);
fputc(0x00, ofp); fputc(0x00, ofp);
fputc(0x00, ofp); fputc(0x00, ofp);
fputc(0x08, ofp);
fputc(0x80, ofp); /* type 0x8008 */
fputc(num_files & 0xff, ofp);
fputc((num_files >> 8) & 0xff, ofp); /* num_files off */
fputc(0x00, ofp); fputc(0x00, ofp); fputc(0x00, ofp); fputc(0x00, ofp);
for(res = first_res | 0x8000, i = 0; i < num_files; i++, res++) {
int len = (file_lens[i] + 15) & ~0xf;
fputc((font_off >> 4) & 0xff, ofp);
fputc((font_off >> 12) & 0xff, ofp);
fputc((len >> 4) & 0xff, ofp);
fputc((len >> 12) & 0xff, ofp);
font_off += len;
fputc(0x30, ofp);
fputc(0x1c, ofp);
fputc(res & 0xff, ofp);
fputc((res >> 8) & 0xff, ofp);
fputc(0x00, ofp); fputc(0x00, ofp);
fputc(0x00, ofp); fputc(0x00, ofp);
}
fputc(0x00, ofp); fputc(0x00, ofp); /* nul type */
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); fputc(0x00, ofp);
fputc(0x00, ofp);
pad = (non_resident_name_off + non_resident_name_len) & 0xf;
if(pad != 0)
pad = 0x10 - pad;
for(i = 0; i < pad; i++)
fputc(0x00, ofp);
/* FONTDIR resource */
fputc(num_files & 0xff, ofp);
fputc((num_files >> 8) & 0xff, ofp);
for(res = first_res, i = 0; i < num_files; i++, res++) {
fp = fopen(argv[i+1], "r");
fputc(res & 0xff, ofp);
fputc((res >> 8) & 0xff, ofp);
fread(fnt_header, 0x72, 1, fp);
fwrite(fnt_header, 0x72, 1, ofp);
fseek(fp, 0x69, SEEK_SET);
fread(&off, sizeof(long), 1, fp);
fseek(fp, off, SEEK_SET);
cp = name;
while((c = fgetc(fp)) != 0 && c != EOF)
*cp++ = c;
*cp = '\0';
fwrite(name, strlen(name) + 1, 1, ofp);
fclose(fp);
}
pad = fontdir_len & 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++) {
fp = fopen(argv[i+1], "r");
while(1) {
nread = read(fileno(fp), buf, sizeof(buf));
if(!nread) break;
fwrite(buf, nread, 1, ofp);
}
fclose(fp);
pad = file_lens[i] & 0xf;
if(pad != 0)
pad = 0x10 - pad;
for(j = 0; j < pad; j++)
fputc(0x00, ofp);
}
fclose(ofp);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment