Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fef71865
Commit
fef71865
authored
Jul 25, 2000
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 25, 2000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make fnt2bdf produce correct fonts.
parent
e58bd1ba
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
92 deletions
+59
-92
wingdi16.h
include/wine/wingdi16.h
+1
-0
fnt2bdf.c
tools/fnt2bdf.c
+49
-47
fnt2bdf.h
tools/fnt2bdf.h
+9
-45
No files found.
include/wine/wingdi16.h
View file @
fef71865
...
...
@@ -112,6 +112,7 @@ typedef struct
LONG
dfBitsPointer
;
LONG
dfBitsOffset
;
CHAR
dfReserved
;
/* Fields, introduced for Windows 3.x fonts */
LONG
dfFlags
;
INT16
dfAspace
;
INT16
dfBspace
;
...
...
tools/fnt2bdf.c
View file @
fef71865
...
...
@@ -14,29 +14,25 @@
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include "windef.h"
#include "wingdi.h"
#include "winuser.h"
#include "fnt2bdf.h"
#include "neexe.h"
#include "module.h"
#define MAP_BEG 118
extern
char
*
g_lpstrFileName
;
extern
char
*
g_lpstrCharSet
;
#define FILE_ERROR 0
#define FILE_DLL 1
#define FILE_FNT 2
/* global options */
int
dump_bdf
(
fnt_fontS
*
cpe_font_struct
,
unsigned
char
*
file_buffer
);
int
dump_bdf_hdr
(
FILE
*
fs
,
fnt_fontS
*
cpe_font_struct
,
unsigned
char
*
file_buffer
);
char
*
g_lpstrFileName
=
NULL
;
char
*
g_lpstrCharSet
=
NULL
;
char
*
g_lpstrInputFile
=
NULL
;
...
...
@@ -63,7 +59,7 @@ void usage(void)
exit
(
-
1
);
}
/* convert
big
-endian value to the local format */
/* convert
little
-endian value to the local format */
int
return_data_value
(
enum
data_types
dtype
,
void
*
pChr
)
{
...
...
@@ -95,13 +91,13 @@ int ret_val = 0;
int
make_bdf_filename
(
char
*
name
,
fnt_fontS
*
cpe_font_struct
,
unsigned
char
*
file_buffer
)
{
int
l_nameoffset
=
return_data_value
(
dfLong
,
cpe_font_struct
->
hdr
.
dfFace
);
long
l_nameoffset
=
return_data_value
(
dfLong
,
&
cpe_font_struct
->
hdr
.
fi
.
dfFace
);
char
*
lpChar
;
if
(
!
g_lpstrFileName
)
{
if
(
!
l_nameoffset
||
l_nameoffset
>
return_data_value
(
dfLong
,
cpe_font_struct
->
hdr
.
dfSize
)
+
1
)
l_nameoffset
>
return_data_value
(
dfLong
,
&
cpe_font_struct
->
hdr
.
dfSize
)
+
1
)
return
ERROR_DATA
;
lpChar
=
(
char
*
)(
file_buffer
+
l_nameoffset
);
}
...
...
@@ -114,13 +110,13 @@ char* lpChar;
/* construct a filename from the font typeface, slant, weight, and size */
if
(
cpe_font_struct
->
hdr
.
dfItalic
[
0
]
)
strcat
(
name
,
"_i"
);
if
(
cpe_font_struct
->
hdr
.
fi
.
dfItalic
)
strcat
(
name
,
"_i"
);
else
strcat
(
name
,
"_r"
);
lpChar
=
name
+
strlen
(
name
);
sprintf
(
lpChar
,
"%d-%d.bdf"
,
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfWeight
),
(
g_outputPoints
)
?
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfPoints
)
:
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfPixHeight
)
);
sprintf
(
lpChar
,
"%d-%d.bdf"
,
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfWeight
),
(
g_outputPoints
)
?
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfPoints
)
:
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfPixHeight
)
);
return
0
;
}
...
...
@@ -135,18 +131,23 @@ int parse_fnt_data(unsigned char* file_buffer, int length)
/* check font header */
t
=
return_data_value
(
dfShort
,
cpe_font_struct
.
hdr
.
dfVersion
);
t
=
return_data_value
(
dfShort
,
&
cpe_font_struct
.
hdr
.
dfVersion
);
if
(
t
!=
0x300
&&
t
!=
0x200
)
return
ERROR_VERSION
;
t
=
return_data_value
(
dfLong
,
cpe_font_struct
.
hdr
.
dfSize
);
t
=
return_data_value
(
dfLong
,
&
cpe_font_struct
.
hdr
.
dfSize
);
if
(
t
>
length
)
return
ERROR_SIZE
;
else
{
/* set up the charWidth/charOffset structure pairs (dfCharTable)... */
int
l_fchar
=
return_data_value
(
dfChar
,
cpe_font_struct
.
hdr
.
dfFirstChar
),
l_lchar
=
return_data_value
(
dfChar
,
cpe_font_struct
.
hdr
.
dfLastChar
);
int
l_len
=
l_lchar
-
l_fchar
+
1
,
l_ptr
=
MAP_BEG
;
int
l_fchar
=
return_data_value
(
dfChar
,
&
cpe_font_struct
.
hdr
.
fi
.
dfFirstChar
),
l_lchar
=
return_data_value
(
dfChar
,
&
cpe_font_struct
.
hdr
.
fi
.
dfLastChar
);
int
l_len
=
l_lchar
-
l_fchar
+
1
;
int
l_ptr
=
sizeof
(
fnt_hdrS
);
/* some fields were introduced for Windows 3.x fonts */
if
(
return_data_value
(
dfShort
,
&
cpe_font_struct
.
hdr
.
dfVersion
)
==
0x200
)
l_ptr
-=
30
;
/* malloc size = (# chars) * sizeof(WinCharS) */
...
...
@@ -160,7 +161,7 @@ int parse_fnt_data(unsigned char* file_buffer, int length)
l_ptr
+=
2
;
/* bump by sizeof(short) */
if
(
return_data_value
(
dfShort
,
cpe_font_struct
.
hdr
.
dfVersion
)
==
0x200
)
{
if
(
return_data_value
(
dfShort
,
&
cpe_font_struct
.
hdr
.
dfVersion
)
==
0x200
)
{
cpe_font_struct
.
dfCharTable
[
ic
].
charOffset
=
return_data_value
(
dfShort
,
&
file_buffer
[
l_ptr
]);
l_ptr
+=
2
;
/* bump by sizeof(long) */
...
...
@@ -181,12 +182,12 @@ int dump_bdf( fnt_fontS* cpe_font_struct, unsigned char* file_buffer)
{
FILE
*
fp
;
int
ic
;
int
l_fchar
=
return_data_value
(
dfChar
,
cpe_font_struct
->
hdr
.
dfFirstChar
),
l_lchar
=
return_data_value
(
dfChar
,
cpe_font_struct
->
hdr
.
dfLastChar
);
int
l_fchar
=
return_data_value
(
dfChar
,
&
cpe_font_struct
->
hdr
.
fi
.
dfFirstChar
),
l_lchar
=
return_data_value
(
dfChar
,
&
cpe_font_struct
->
hdr
.
fi
.
dfLastChar
);
int
l_len
=
l_lchar
-
l_fchar
+
1
,
l_hgt
=
return_data_value
(
dfChar
,
cpe_font_struct
->
hdr
.
dfPixHeight
);
int
l_ascent
=
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfAscent
);
l_hgt
=
return_data_value
(
dfChar
,
&
cpe_font_struct
->
hdr
.
fi
.
dfPixHeight
);
int
l_ascent
=
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfAscent
);
char
l_filename
[
256
];
if
(
(
ic
=
make_bdf_filename
(
l_filename
,
cpe_font_struct
,
file_buffer
))
)
...
...
@@ -288,23 +289,23 @@ return 0;
int
dump_bdf_hdr
(
FILE
*
fs
,
fnt_fontS
*
cpe_font_struct
,
unsigned
char
*
file_buffer
)
{
int
l_fchar
=
return_data_value
(
dfChar
,
cpe_font_struct
->
hdr
.
dfFirstChar
),
l_lchar
=
return_data_value
(
dfChar
,
cpe_font_struct
->
hdr
.
dfLastChar
);
int
l_fchar
=
return_data_value
(
dfChar
,
&
cpe_font_struct
->
hdr
.
fi
.
dfFirstChar
),
l_lchar
=
return_data_value
(
dfChar
,
&
cpe_font_struct
->
hdr
.
fi
.
dfLastChar
);
int
l_len
=
l_lchar
-
l_fchar
+
1
;
int
l_nameoffset
=
return_data_value
(
dfLong
,
cpe_font_struct
->
hdr
.
dfFace
);
int
l_cellheight
=
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfPixHeight
);
int
l_ascent
=
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfAscent
);
long
l_nameoffset
=
return_data_value
(
dfLong
,
&
cpe_font_struct
->
hdr
.
fi
.
dfFace
);
int
l_cellheight
=
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfPixHeight
);
int
l_ascent
=
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfAscent
);
fprintf
(
fs
,
"STARTFONT 2.1
\n
"
);
/* Compose font name */
if
(
l_nameoffset
&&
l_nameoffset
<
return_data_value
(
dfLong
,
cpe_font_struct
->
hdr
.
dfSize
)
)
l_nameoffset
<
return_data_value
(
dfLong
,
&
cpe_font_struct
->
hdr
.
dfSize
)
)
{
int
dpi
,
point_size
;
char
*
lpFace
=
(
char
*
)(
file_buffer
+
l_nameoffset
),
*
lpChar
;
short
tmWeight
=
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfWeight
);
short
tmWeight
=
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfWeight
);
while
((
lpChar
=
strchr
(
lpFace
,
'-'
))
)
*
lpChar
=
' '
;
...
...
@@ -323,19 +324,19 @@ int l_ascent = return_data_value(dfShort, cpe_font_struct->hdr.dfAscent);
fputs
(
"bold-"
,
fs
);
else
fputs
(
"black-"
,
fs
);
if
(
cpe_font_struct
->
hdr
.
dfItalic
[
0
]
)
/* slant */
if
(
cpe_font_struct
->
hdr
.
fi
.
dfItalic
)
/* slant */
fputs
(
"i-"
,
fs
);
else
fputs
(
"r-"
,
fs
);
/* style */
if
(
(
cpe_font_struct
->
hdr
.
dfPitchAndFamily
[
0
]
&
0xF0
)
==
FF_SWISS
)
if
(
(
cpe_font_struct
->
hdr
.
fi
.
dfPitchAndFamily
&
0xF0
)
==
FF_SWISS
)
fputs
(
"normal-sans-"
,
fs
);
else
fputs
(
"normal--"
,
fs
);
/* still can be -sans */
/* y extents */
point_size
=
10
*
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfPoints
);
point_size
=
10
*
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfPoints
);
dpi
=
(
l_cellheight
*
720
)
/
point_size
;
fprintf
(
fs
,
"%d-%d-%d-%d-"
,
l_cellheight
,
10
*
l_cellheight
,
72
,
72
);
...
...
@@ -343,18 +344,18 @@ int l_ascent = return_data_value(dfShort, cpe_font_struct->hdr.dfAscent);
/* spacing */
if
(
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfPixWidth
)
)
fputs
(
"c-"
,
fs
);
if
(
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfPixWidth
)
)
fputs
(
"c-"
,
fs
);
else
fputs
(
"p-"
,
fs
);
/* average width */
fprintf
(
fs
,
"%d-"
,
10
*
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfAvgWidth
)
);
fprintf
(
fs
,
"%d-"
,
10
*
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfAvgWidth
)
);
/* charset */
if
(
g_lpstrCharSet
)
fprintf
(
fs
,
"%s
\n
"
,
g_lpstrCharSet
);
else
switch
(
cpe_font_struct
->
hdr
.
dfCharSet
[
0
]
)
switch
(
cpe_font_struct
->
hdr
.
fi
.
dfCharSet
)
{
/* Microsoft just had to invent its own charsets! */
...
...
@@ -380,12 +381,12 @@ int l_ascent = return_data_value(dfShort, cpe_font_struct->hdr.dfAscent);
fprintf
(
fs
,
"SIZE %d %d %d
\n
"
,
l_cellheight
,
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfHorizRes
),
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfVertRes
));
/* dfVertRes[2] */
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfHorizRes
),
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfVertRes
));
/* dfVertRes[2] */
fprintf
(
fs
,
"FONTBOUNDINGBOX %d %d %d %d
\n
"
,
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfMaxWidth
),
return_data_value
(
dfChar
,
cpe_font_struct
->
hdr
.
dfPixHeight
),
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfMaxWidth
),
return_data_value
(
dfChar
,
&
cpe_font_struct
->
hdr
.
fi
.
dfPixHeight
),
0
,
l_ascent
-
l_cellheight
);
fprintf
(
fs
,
"STARTPROPERTIES 4
\n
"
);
...
...
@@ -393,8 +394,8 @@ int l_ascent = return_data_value(dfShort, cpe_font_struct->hdr.dfAscent);
fprintf
(
fs
,
"FONT_ASCENT %d
\n
"
,
l_ascent
);
/* dfAscent[2] */
fprintf
(
fs
,
"FONT_DESCENT %d
\n
"
,
l_cellheight
-
l_ascent
);
fprintf
(
fs
,
"CAP_HEIGHT %d
\n
"
,
l_ascent
-
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfInternalLeading
));
fprintf
(
fs
,
"DEFAULT_CHAR %d
\n
"
,
return_data_value
(
dfShort
,
cpe_font_struct
->
hdr
.
dfDefaultChar
));
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfInternalLeading
));
fprintf
(
fs
,
"DEFAULT_CHAR %d
\n
"
,
return_data_value
(
dfShort
,
&
cpe_font_struct
->
hdr
.
fi
.
dfDefaultChar
));
fprintf
(
fs
,
"ENDPROPERTIES
\n
"
);
...
...
@@ -457,8 +458,8 @@ int get_resource_table(int fd, unsigned char** lpdata, int fsize)
{
IMAGE_DOS_HEADER
mz_header
;
IMAGE_OS2_HEADER
ne_header
;
short
s
,
offset
,
size
,
retval
;
long
s
,
offset
,
size
;
int
retval
;
lseek
(
fd
,
0
,
SEEK_SET
);
...
...
@@ -497,7 +498,7 @@ int get_resource_table(int fd, unsigned char** lpdata, int fsize)
}
else
if
(
s
==
0x300
||
s
==
0x200
)
/* maybe .fnt ? */
{
size
=
return_data_value
(
dfLong
,
(
char
*
)
&
mz_header
+
2
);
size
=
return_data_value
(
dfLong
,
&
((
fnt_hdrS
*
)
&
mz_header
)
->
dfSize
);
if
(
size
!=
fsize
)
return
FILE_ERROR
;
offset
=
0
;
...
...
@@ -550,6 +551,7 @@ int main(int argc, char **argv)
{
count
=
j
;
pFontStorage
=
(
NE_NAMEINFO
*
)(
pTInfo
+
1
);
break
;
/* found one */
}
pTInfo
=
(
NE_TYPEINFO
*
)((
char
*
)(
pTInfo
+
1
)
+
j
*
sizeof
(
NE_NAMEINFO
));
...
...
tools/fnt2bdf.h
View file @
fef71865
#include <stdio.h>
#include "wine/wingdi16.h"
#include "pshpack1.h"
enum
data_types
{
dfChar
,
dfShort
,
dfLong
,
dfString
};
...
...
@@ -10,48 +12,16 @@ enum data_types {dfChar, dfShort, dfLong, dfString};
typedef
struct
tagFontHeader
{
unsigned
char
dfVersion
[
2
];
/* Version (always 0x3000) */
unsigned
char
dfSize
[
4
];
/* Total File Size */
unsigned
char
dfCopyright
[
60
];
/* Copyright notice */
unsigned
char
dfType
[
2
];
/* Vector or bitmap font */
unsigned
char
dfPoints
[
2
];
/* Nominal point size */
unsigned
char
dfVertRes
[
2
];
/* Vertical Resolution */
unsigned
char
dfHorizRes
[
2
];
/* Horizontal Resolutionchar */
unsigned
char
dfAscent
[
2
];
/* Character ascent in pixels */
unsigned
char
dfInternalLeading
[
2
];
/* Leading included in character defn */
unsigned
char
dfExternalLeading
[
2
];
/* Leading to be added by Windows */
unsigned
char
dfItalic
[
1
];
/* 1=Italic font */
unsigned
char
dfUnderline
[
1
];
/* 1=underlined font */
unsigned
char
dfStrikeOut
[
1
];
/* 1=strike-out font */
unsigned
char
dfWeight
[
2
];
/* Weight: 400=normal */
unsigned
char
dfCharSet
[
1
];
/* Character Set for this font */
unsigned
char
dfPixWidth
[
2
];
/* Character width (0 for proportional) */
unsigned
char
dfPixHeight
[
2
];
/* Character height */
unsigned
char
dfPitchAndFamily
[
1
];
/* Font Pitch and family */
unsigned
char
dfAvgWidth
[
2
];
/* Average character width */
unsigned
char
dfMaxWidth
[
2
];
/* Maximum character width */
unsigned
char
dfFirstChar
[
1
];
/* Firwst character of the font */
unsigned
char
dfLastChar
[
1
];
/* Last character of the font */
unsigned
char
dfDefaultChar
[
1
];
/* Missing character */
unsigned
char
dfBreakChar
[
1
];
/* Character to indicate word breaks */
unsigned
char
dfWidthBytes
[
2
];
/* Number of bytes in each row */
unsigned
char
dfDevice
[
4
];
/* Offset to device name */
unsigned
char
dfFace
[
4
];
/* Offset to type face name */
unsigned
char
dfBitsPointer
[
4
];
unsigned
char
dfBitsOffset
[
4
];
/* Offset to bitmaps */
unsigned
char
dfReserved
[
1
];
unsigned
char
dfFlags
[
4
];
/* Bitmapped flags */
unsigned
char
dfAspace
[
2
];
unsigned
char
dfBspace
[
2
];
unsigned
char
dfCspace
[
2
];
unsigned
char
dfColorTable
[
2
];
/* Offset to Color table */
unsigned
char
dfReserved1
[
4
];
short
dfVersion
;
/* Version */
long
dfSize
;
/* Total File Size */
char
dfCopyright
[
60
];
/* Copyright notice */
FONTINFO16
fi
;
/* FONTINFO structure */
}
fnt_hdrS
;
typedef
struct
WinCharStruct
{
unsigned
int
charWidth
;
unsigned
int
charOffset
;
long
charOffset
;
}
WinCharS
;
typedef
struct
fntFontStruct
...
...
@@ -65,10 +35,4 @@ typedef struct fntFontStruct
short
*
dfColorTableP
;
}
fnt_fontS
;
extern
int
return_data_value
(
enum
data_types
,
void
*
);
extern
int
dump_bdf
(
fnt_fontS
*
,
unsigned
char
*
);
extern
int
dump_bdf_hdr
(
FILE
*
fp
,
fnt_fontS
*
,
unsigned
char
*
);
extern
int
parse_fnt_data
(
unsigned
char
*
file_buffer
,
int
length
);
#include "poppack.h"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment