First stab at Wine versions of Courier, System and MS Sans Serif
fonts.
This commit is contained in:
parent
2e9436c038
commit
00acb5f719
|
@ -51,6 +51,7 @@ RM = rm -f
|
|||
MV = mv
|
||||
LINT = @LINT@
|
||||
LINTFLAGS = @LINTFLAGS@
|
||||
FONTFORGE = @FONTFORGE@
|
||||
INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
|
||||
EXTRACFLAGS = @EXTRACFLAGS@
|
||||
ALLCFLAGS = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||
|
@ -68,6 +69,8 @@ BIN2RES = $(TOOLSDIR)/tools/bin2res
|
|||
WMC = $(TOOLSDIR)/tools/wmc/wmc
|
||||
WIDL = $(TOOLSDIR)/tools/widl/widl
|
||||
WINEGCC = $(TOOLSDIR)/tools/winegcc/winegcc
|
||||
SFNT2FNT = $(TOOLSDIR)/tools/sfnt2fnt
|
||||
FNT2FON = $(TOOLSDIR)/tools/fnt2fon
|
||||
RC = $(WRC)
|
||||
RC16 = $(WRC)
|
||||
RCFLAGS = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
|
||||
|
@ -110,7 +113,7 @@ LINTS = $(C_SRCS:.c=.ln)
|
|||
|
||||
# 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:
|
||||
$(CC) -c $(ALLCFLAGS) -o $@ $<
|
||||
|
@ -139,6 +142,9 @@ LINTS = $(C_SRCS:.c=.ln)
|
|||
.c.ok:
|
||||
$(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: Makefile
|
||||
|
|
11
Makefile.in
11
Makefile.in
|
@ -26,10 +26,13 @@ LDCONFIG = @LDCONFIG@
|
|||
LDD = @LDD@
|
||||
MODULE = none
|
||||
|
||||
FONTSSUBDIRS = @FONTSSUBDIRS@
|
||||
|
||||
# Sub-directories to run make depend/clean into
|
||||
SUBDIRS = \
|
||||
dlls \
|
||||
documentation \
|
||||
fonts \
|
||||
include \
|
||||
libs \
|
||||
loader \
|
||||
|
@ -40,6 +43,7 @@ SUBDIRS = \
|
|||
# Sub-directories to install for install-lib
|
||||
INSTALLLIBSUBDIRS = \
|
||||
documentation \
|
||||
$(FONTSSUBDIRS) \
|
||||
loader \
|
||||
programs \
|
||||
server
|
||||
|
@ -103,15 +107,14 @@ uninstall:: $(INSTALLBOTHSUBDIRS:%=%/__uninstall__)
|
|||
|
||||
# Dependencies between directories
|
||||
|
||||
all: $(SUBDIRS)
|
||||
dlls: libs tools
|
||||
loader server: libs tools
|
||||
all: $(INSTALLSUBDIRS) $(INSTALLBOTHSUBDIRS)
|
||||
dlls fonts loader server: libs tools
|
||||
programs: dlls libs tools
|
||||
tools: libs
|
||||
|
||||
dlls/__install-lib__ dlls/__install-dev__: libs tools
|
||||
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__
|
||||
tools/__install__: tools
|
||||
|
||||
|
|
25
configure.ac
25
configure.ac
|
@ -107,21 +107,12 @@ fi
|
|||
AC_SUBST(LINT)
|
||||
AC_SUBST(LINTFLAGS)
|
||||
|
||||
dnl Check for db2html
|
||||
dnl Check for various programs
|
||||
AC_CHECK_PROGS(DB2HTML, docbook2html db2html, false)
|
||||
AC_SUBST(DB2HTML)
|
||||
|
||||
dnl Check for db2pdf
|
||||
AC_CHECK_PROGS(DB2PDF, docbook2pdf db2pdf, false)
|
||||
AC_SUBST(DB2PDF)
|
||||
|
||||
dnl Check for db2ps
|
||||
AC_CHECK_PROGS(DB2PS, docbook2ps db2ps, false)
|
||||
AC_SUBST(DB2PS)
|
||||
|
||||
dnl Check for db2txt
|
||||
AC_CHECK_PROGS(DB2TXT, docbook2txt db2txt, false)
|
||||
AC_SUBST(DB2TXT)
|
||||
AC_CHECK_PROGS(FONTFORGE, fontforge, false)
|
||||
|
||||
dnl **** Check for some libraries ****
|
||||
|
||||
|
@ -418,6 +409,7 @@ dnl **** Check for FreeType 2 ****
|
|||
AC_CHECK_LIB(freetype,FT_Init_FreeType,ft_lib=yes,ft_lib=no,$X_LIBS)
|
||||
if test "$ft_lib" = "no"
|
||||
then
|
||||
FREETYPELIBS=""
|
||||
FREETYPEINCL=""
|
||||
wine_cv_msg_freetype=no
|
||||
else
|
||||
|
@ -432,9 +424,11 @@ else
|
|||
fi
|
||||
if test "$ft_devel" = "no"
|
||||
then
|
||||
FREETYPELIBS=""
|
||||
FREETYPEINCL=""
|
||||
wine_cv_msg_freetype=yes
|
||||
else
|
||||
FREETYPELIBS=`$ft_devel --libs`
|
||||
FREETYPEINCL=`$ft_devel --cflags`
|
||||
ac_save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$FREETYPEINCL $CPPFLAGS"
|
||||
|
@ -464,13 +458,21 @@ else
|
|||
AC_DEFINE(HAVE_FREETYPE, 1, [Define if FreeType 2 is installed])
|
||||
wine_cv_msg_freetype=no
|
||||
else
|
||||
FREETYPELIBS=""
|
||||
FREETYPEINCL=""
|
||||
wine_cv_msg_freetype=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(FREETYPELIBS)
|
||||
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) ****
|
||||
AC_CACHE_CHECK([for parport header/ppdev.h], ac_cv_c_ppdev,
|
||||
AC_TRY_COMPILE(
|
||||
|
@ -1693,6 +1695,7 @@ dlls/wow32/Makefile
|
|||
dlls/wsock32/Makefile
|
||||
dlls/x11drv/Makefile
|
||||
documentation/Makefile
|
||||
fonts/Makefile
|
||||
include/Makefile
|
||||
libs/Makefile
|
||||
libs/port/Makefile
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
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
|
|
@ -0,0 +1,65 @@
|
|||
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:
|
|
@ -0,0 +1,3 @@
|
|||
Open($1)
|
||||
ttfname = $1:r + ".ttf"
|
||||
Generate(ttfname, "ttf", 0);
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,7 @@
|
|||
Makefile
|
||||
bin2res
|
||||
fnt2bdf
|
||||
fnt2fon
|
||||
makedep
|
||||
sfnt2fnt
|
||||
wineprefixcreate
|
||||
|
|
|
@ -4,17 +4,23 @@ TOPOBJDIR = ..
|
|||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
MODULE = none
|
||||
EXTRAINCL = @FREETYPEINCL@
|
||||
FREETYPELIBS = @FREETYPELIBS@
|
||||
|
||||
PROGRAMS = \
|
||||
bin2res \
|
||||
fnt2bdf \
|
||||
fnt2fon \
|
||||
makedep \
|
||||
sfnt2fnt \
|
||||
wineprefixcreate
|
||||
|
||||
C_SRCS = \
|
||||
bin2res.c \
|
||||
fnt2bdf.c \
|
||||
makedep.c
|
||||
fnt2fon.c \
|
||||
makedep.c \
|
||||
sfnt2fnt.c \
|
||||
|
||||
SUBDIRS = \
|
||||
widl \
|
||||
|
@ -40,6 +46,12 @@ makedep: makedep.o
|
|||
fnt2bdf: fnt2bdf.o
|
||||
$(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
|
||||
$(CC) $(CFLAGS) -o bin2res bin2res.o $(LIBPORT)
|
||||
|
||||
|
|
|
@ -0,0 +1,243 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
|
@ -0,0 +1,420 @@
|
|||
/*
|
||||
* sfnttofnt. Bitmap only ttf to Window fnt file converter
|
||||
*
|
||||
* 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 "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_FREETYPE
|
||||
|
||||
#ifdef HAVE_FT2BUILD_H
|
||||
#include <ft2build.h>
|
||||
#endif
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_SFNT_NAMES_H
|
||||
#include FT_TRUETYPE_TABLES_H
|
||||
|
||||
#include "wine/unicode.h"
|
||||
#include "wingdi.h"
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD dfVersion;
|
||||
DWORD dfSize;
|
||||
char dfCopyright[60];
|
||||
} FNT_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT16 dfType;
|
||||
INT16 dfPoints;
|
||||
INT16 dfVertRes;
|
||||
INT16 dfHorizRes;
|
||||
INT16 dfAscent;
|
||||
INT16 dfInternalLeading;
|
||||
INT16 dfExternalLeading;
|
||||
CHAR dfItalic;
|
||||
CHAR dfUnderline;
|
||||
CHAR dfStrikeOut;
|
||||
INT16 dfWeight;
|
||||
BYTE dfCharSet;
|
||||
INT16 dfPixWidth;
|
||||
INT16 dfPixHeight;
|
||||
CHAR dfPitchAndFamily;
|
||||
INT16 dfAvgWidth;
|
||||
INT16 dfMaxWidth;
|
||||
CHAR dfFirstChar;
|
||||
CHAR dfLastChar;
|
||||
CHAR dfDefaultChar;
|
||||
CHAR dfBreakChar;
|
||||
INT16 dfWidthBytes;
|
||||
LONG dfDevice;
|
||||
LONG dfFace;
|
||||
LONG dfBitsPointer;
|
||||
LONG dfBitsOffset;
|
||||
CHAR dfReserved;
|
||||
/* Fields, introduced for Windows 3.x fonts */
|
||||
LONG dfFlags;
|
||||
INT16 dfAspace;
|
||||
INT16 dfBspace;
|
||||
INT16 dfCspace;
|
||||
LONG dfColorPointer;
|
||||
LONG dfReserved1[4];
|
||||
} FONTINFO16, *LPFONTINFO16;
|
||||
|
||||
typedef struct {
|
||||
WORD width;
|
||||
DWORD offset;
|
||||
} CHAR_TABLE_ENTRY;
|
||||
|
||||
|
||||
void usage(char **argv)
|
||||
{
|
||||
fprintf(stderr, "%s foo.ttf ppem enc dpi def_char\n", argv[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
int lookup_charset(int enc)
|
||||
{
|
||||
/* FIXME: make winelib app and use TranslateCharsetInfo */
|
||||
switch(enc) {
|
||||
case 1250:
|
||||
return EE_CHARSET;
|
||||
case 1251:
|
||||
return RUSSIAN_CHARSET;
|
||||
case 1252:
|
||||
return ANSI_CHARSET;
|
||||
case 1253:
|
||||
return GREEK_CHARSET;
|
||||
case 1254:
|
||||
return TURKISH_CHARSET;
|
||||
case 1255:
|
||||
return HEBREW_CHARSET;
|
||||
case 1256:
|
||||
return ARABIC_CHARSET;
|
||||
case 1257:
|
||||
return BALTIC_CHARSET;
|
||||
case 1258:
|
||||
return VIETNAMESE_CHARSET;
|
||||
case 437:
|
||||
case 737:
|
||||
case 775:
|
||||
case 850:
|
||||
case 852:
|
||||
case 855:
|
||||
case 857:
|
||||
case 860:
|
||||
case 861:
|
||||
case 862:
|
||||
case 863:
|
||||
case 864:
|
||||
case 865:
|
||||
case 866:
|
||||
case 869:
|
||||
return OEM_CHARSET;
|
||||
case 874:
|
||||
return THAI_CHARSET;
|
||||
case 932:
|
||||
return SHIFTJIS_CHARSET;
|
||||
case 936:
|
||||
return GB2312_CHARSET;
|
||||
case 949:
|
||||
return HANGUL_CHARSET;
|
||||
case 950:
|
||||
return CHINESEBIG5_CHARSET;
|
||||
}
|
||||
fprintf(stderr, "Unknown encoding %d - using OEM_CHARSET\n", enc);
|
||||
|
||||
return OEM_CHARSET;
|
||||
}
|
||||
|
||||
static void fill_fontinfo(FT_Face face, int enc, FILE *fp, int dpi, unsigned char def_char)
|
||||
{
|
||||
int ascent, il, ppem, descent, avg_width, width_bytes = 0, space_size, max_width = 0;
|
||||
FNT_HEADER hdr;
|
||||
FONTINFO16 fi;
|
||||
BYTE left_byte, right_byte, byte;
|
||||
DWORD start;
|
||||
CHAR_TABLE_ENTRY *dfCharTable;
|
||||
int i, x, y, x_off, x_end, first_char;
|
||||
FT_Int gi;
|
||||
int num_names;
|
||||
const union cptable *cptable;
|
||||
FT_SfntName sfntname;
|
||||
char namebuf[4096];
|
||||
TT_OS2 *os2;
|
||||
cptable = wine_cp_get_table(enc);
|
||||
if(!cptable) {
|
||||
fprintf(stderr, "Can't find codepage %d\n", enc);
|
||||
exit(0);
|
||||
}
|
||||
if(cptable->info.char_size != 1) {
|
||||
fprintf(stderr, "Can't cope with double byte codepages\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
ppem = face->size->metrics.y_ppem;
|
||||
start = sizeof(FNT_HEADER) + sizeof(FONTINFO16);
|
||||
|
||||
if(FT_Load_Char(face, 0xc5, FT_LOAD_DEFAULT)) {
|
||||
fprintf(stderr, "Can't find Aring\n");
|
||||
exit(0);
|
||||
}
|
||||
ascent = face->glyph->metrics.height >> 6;
|
||||
descent = ppem - ascent;
|
||||
if(FT_Load_Char(face, 'M', FT_LOAD_DEFAULT)) {
|
||||
fprintf(stderr, "Can't find M\n");
|
||||
exit(0);
|
||||
}
|
||||
il = ascent - (face->glyph->metrics.height >> 6);
|
||||
|
||||
/* Hack: Courier has no internal leading, so we do likewise */
|
||||
if(!strcmp(face->family_name, "Wine Courier"))
|
||||
il = 0;
|
||||
|
||||
if(FT_Load_Char(face, 'X', FT_LOAD_DEFAULT)) {
|
||||
fprintf(stderr, "Can't find X\n");
|
||||
exit(0);
|
||||
}
|
||||
avg_width = face->glyph->metrics.horiAdvance >> 6;
|
||||
|
||||
first_char = FT_Get_First_Char(face, &gi);
|
||||
if(first_char == 0xd) /* fontforge's first glyph is 0xd, we'll catch this and skip it */
|
||||
first_char = FT_Get_Next_Char(face, first_char, &gi);
|
||||
|
||||
dfCharTable = malloc((255 + 3) * sizeof(*dfCharTable));
|
||||
memset(&fi, 0, sizeof(fi));
|
||||
fi.dfFirstChar = first_char;
|
||||
fi.dfLastChar = 0xff;
|
||||
start += ((unsigned char)fi.dfLastChar - (unsigned char)fi.dfFirstChar + 3 ) * sizeof(*dfCharTable);
|
||||
|
||||
num_names = FT_Get_Sfnt_Name_Count(face);
|
||||
for(i = 0; i <num_names; i++) {
|
||||
FT_Get_Sfnt_Name(face, i, &sfntname);
|
||||
strncpy(namebuf, sfntname.string, sfntname.string_len);
|
||||
namebuf[sfntname.string_len] = '\0';
|
||||
if(sfntname.platform_id == 1 && sfntname.encoding_id == 0 && sfntname.language_id == 0 && sfntname.name_id == 0) {
|
||||
strncpy(hdr.dfCopyright, namebuf, 60);
|
||||
hdr.dfCopyright[59] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
|
||||
for(i = first_char; i < 0x100; i++) {
|
||||
gi = FT_Get_Char_Index(face, cptable->sbcs.cp2uni[i]);
|
||||
if(gi == 0)
|
||||
fprintf(stderr, "Missing glyph for char %04x\n", cptable->sbcs.cp2uni[i]);
|
||||
if(FT_Load_Char(face, cptable->sbcs.cp2uni[i], FT_LOAD_DEFAULT)) {
|
||||
fprintf(stderr, "error loading char %d - bad news!\n", i);
|
||||
continue;
|
||||
}
|
||||
dfCharTable[i].width = face->glyph->metrics.horiAdvance >> 6;
|
||||
dfCharTable[i].offset = start + (width_bytes * ppem);
|
||||
width_bytes += ((face->glyph->metrics.horiAdvance >> 6) + 7) >> 3;
|
||||
if(max_width < (face->glyph->metrics.horiAdvance >> 6))
|
||||
max_width = face->glyph->metrics.horiAdvance >> 6;
|
||||
}
|
||||
/* space */
|
||||
space_size = (ppem + 3) / 4;
|
||||
dfCharTable[i].width = space_size;
|
||||
dfCharTable[i].offset = start + (width_bytes * ppem);
|
||||
width_bytes += (space_size + 7) >> 3;
|
||||
/* sentinel */
|
||||
dfCharTable[++i].width = 0;
|
||||
dfCharTable[i].offset = start + (width_bytes * ppem);
|
||||
|
||||
fi.dfType = 0;
|
||||
fi.dfPoints = ((ppem - il) * 72 + dpi/2) / dpi;
|
||||
fi.dfVertRes = dpi;
|
||||
fi.dfHorizRes = dpi;
|
||||
fi.dfAscent = ascent;
|
||||
fi.dfInternalLeading = il;
|
||||
fi.dfExternalLeading = 0;
|
||||
fi.dfItalic = (face->style_flags & FT_STYLE_FLAG_ITALIC) ? 1 : 0;
|
||||
fi.dfUnderline = 0;
|
||||
fi.dfStrikeOut = 0;
|
||||
fi.dfWeight = os2->usWeightClass;
|
||||
fi.dfCharSet = lookup_charset(enc);
|
||||
fi.dfPixWidth = (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) ?
|
||||
avg_width : 0;
|
||||
fi.dfPixHeight = ppem;
|
||||
fi.dfPitchAndFamily = FT_IS_FIXED_WIDTH(face) ? 0 : TMPF_FIXED_PITCH;
|
||||
switch(os2->panose[PAN_FAMILYTYPE_INDEX]) {
|
||||
case PAN_FAMILY_SCRIPT:
|
||||
fi.dfPitchAndFamily |= FF_SCRIPT;
|
||||
break;
|
||||
case PAN_FAMILY_DECORATIVE:
|
||||
case PAN_FAMILY_PICTORIAL:
|
||||
fi.dfPitchAndFamily |= FF_DECORATIVE;
|
||||
break;
|
||||
case PAN_FAMILY_TEXT_DISPLAY:
|
||||
if(fi.dfPitchAndFamily == 0) /* fixed */
|
||||
fi.dfPitchAndFamily = FF_MODERN;
|
||||
else {
|
||||
switch(os2->panose[PAN_SERIFSTYLE_INDEX]) {
|
||||
case PAN_SERIF_NORMAL_SANS:
|
||||
case PAN_SERIF_OBTUSE_SANS:
|
||||
case PAN_SERIF_PERP_SANS:
|
||||
fi.dfPitchAndFamily |= FF_SWISS;
|
||||
break;
|
||||
default:
|
||||
fi.dfPitchAndFamily |= FF_ROMAN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fi.dfPitchAndFamily |= FF_DONTCARE;
|
||||
}
|
||||
|
||||
fi.dfAvgWidth = avg_width;
|
||||
fi.dfMaxWidth = max_width;
|
||||
fi.dfDefaultChar = def_char - fi.dfFirstChar;
|
||||
fi.dfBreakChar = ' ' - fi.dfFirstChar;
|
||||
fi.dfWidthBytes = (width_bytes + 1) & ~1;
|
||||
|
||||
fi.dfFace = start + fi.dfWidthBytes * ppem;
|
||||
fi.dfBitsOffset = start;
|
||||
fi.dfFlags = 0x10; /* DFF_1COLOR */
|
||||
fi.dfFlags |= FT_IS_FIXED_WIDTH(face) ? 1 : 2; /* DFF_FIXED : DFF_PROPORTIONAL */
|
||||
|
||||
hdr.dfVersion = 0x300;
|
||||
hdr.dfSize = start + fi.dfWidthBytes * ppem + strlen(face->family_name) + 1;
|
||||
fwrite(&hdr, sizeof(hdr), 1, fp);
|
||||
fwrite(&fi, sizeof(fi), 1, fp);
|
||||
fwrite(dfCharTable + fi.dfFirstChar, sizeof(*dfCharTable), ((unsigned char)fi.dfLastChar - (unsigned char)fi.dfFirstChar) + 3, fp);
|
||||
|
||||
for(i = first_char; i < 0x100; i++) {
|
||||
if(FT_Load_Char(face, cptable->sbcs.cp2uni[i], FT_LOAD_DEFAULT)) {
|
||||
continue;
|
||||
}
|
||||
assert(dfCharTable[i].width == face->glyph->metrics.horiAdvance >> 6);
|
||||
|
||||
for(x = 0; x < ((dfCharTable[i].width + 7) / 8); x++) {
|
||||
for(y = 0; y < ppem; y++) {
|
||||
if(y < ascent - face->glyph->bitmap_top ||
|
||||
y >= face->glyph->bitmap.rows + ascent - face->glyph->bitmap_top) {
|
||||
fputc('\0', fp);
|
||||
continue;
|
||||
}
|
||||
x_off = face->glyph->bitmap_left / 8;
|
||||
x_end = (face->glyph->bitmap_left + face->glyph->bitmap.width - 1) / 8;
|
||||
if(x < x_off || x > x_end) {
|
||||
fputc('\0', fp);
|
||||
continue;
|
||||
}
|
||||
if(x == x_off)
|
||||
left_byte = 0;
|
||||
else
|
||||
left_byte = face->glyph->bitmap.buffer[(y - (ascent - face->glyph->bitmap_top)) * face->glyph->bitmap.pitch + x - x_off - 1];
|
||||
|
||||
/* On the last non-trival output byte (x == x_end) have we got one or two input bytes */
|
||||
if(x == x_end && (face->glyph->bitmap_left % 8 != 0) && ((face->glyph->bitmap.width % 8 == 0) || (x != (((face->glyph->bitmap.width) & ~0x7) + face->glyph->bitmap_left) / 8)))
|
||||
right_byte = 0;
|
||||
else
|
||||
right_byte = face->glyph->bitmap.buffer[(y - (ascent - face->glyph->bitmap_top)) * face->glyph->bitmap.pitch + x - x_off];
|
||||
|
||||
byte = (left_byte << (8 - (face->glyph->bitmap_left & 7))) & 0xff;
|
||||
byte |= ((right_byte >> (face->glyph->bitmap_left & 7)) & 0xff);
|
||||
fputc(byte, fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(x = 0; x < (space_size + 7) / 8; x++) {
|
||||
for(y = 0; y < ppem; y++)
|
||||
fputc('\0', fp);
|
||||
}
|
||||
|
||||
if(width_bytes & 1) {
|
||||
for(y = 0; y < ppem; y++)
|
||||
fputc('\0', fp);
|
||||
}
|
||||
fprintf(fp, "%s", face->family_name);
|
||||
fputc('\0', fp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ppem, enc;
|
||||
FT_Face face;
|
||||
FT_Library lib;
|
||||
int dpi;
|
||||
unsigned int def_char;
|
||||
FILE *fp;
|
||||
char output[256];
|
||||
char name[256];
|
||||
char *cp;
|
||||
if(argc != 6) {
|
||||
usage(argv);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
ppem = atoi(argv[2]);
|
||||
enc = atoi(argv[3]);
|
||||
dpi = atoi(argv[4]);
|
||||
def_char = atoi(argv[5]);
|
||||
if(FT_Init_FreeType(&lib)) {
|
||||
fprintf(stderr, "ft init failure\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(FT_New_Face(lib, argv[1], 0, &face)) {
|
||||
fprintf(stderr, "Can't open face\n");
|
||||
usage(argv);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(FT_Set_Pixel_Sizes(face, ppem, ppem)) {
|
||||
fprintf(stderr, "Can't set size\n");
|
||||
usage(argv);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
strcpy(name, face->family_name);
|
||||
/* FIXME: should add a -o option instead */
|
||||
for(cp = name; *cp; cp++)
|
||||
{
|
||||
if(*cp == ' ') *cp = '_';
|
||||
else if (*cp >= 'A' && *cp <= 'Z') *cp += 'a' - 'A';
|
||||
}
|
||||
|
||||
sprintf(output, "%s-%d-%d-%d.fnt", name, enc, dpi, ppem);
|
||||
|
||||
fp = fopen(output, "w");
|
||||
|
||||
fill_fontinfo(face, enc, fp, dpi, def_char);
|
||||
fclose(fp);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#else /* HAVE_FREETYPE */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
fprintf( stderr, "%s needs to be built with Freetype support\n", argv[0] );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#endif /* HAVE_FREETYPE */
|
Loading…
Reference in New Issue