Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/tools/winedump/font.c
4389 views
1
/*
2
* Dump a font file
3
*
4
* Copyright 2009 Dmitry Timoshkov
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19
*/
20
21
#include "config.h"
22
23
#include <stdarg.h>
24
#include <stdio.h>
25
#include <stdlib.h>
26
#include <fcntl.h>
27
28
#include "windef.h"
29
#include "winbase.h"
30
#include "winnt.h"
31
32
#include "winedump.h"
33
34
#pragma pack(push,1)
35
typedef struct
36
{
37
INT16 dfType;
38
INT16 dfPoints;
39
INT16 dfVertRes;
40
INT16 dfHorizRes;
41
INT16 dfAscent;
42
INT16 dfInternalLeading;
43
INT16 dfExternalLeading;
44
BYTE dfItalic;
45
BYTE dfUnderline;
46
BYTE dfStrikeOut;
47
INT16 dfWeight;
48
BYTE dfCharSet;
49
INT16 dfPixWidth;
50
INT16 dfPixHeight;
51
BYTE dfPitchAndFamily;
52
INT16 dfAvgWidth;
53
INT16 dfMaxWidth;
54
BYTE dfFirstChar;
55
BYTE dfLastChar;
56
BYTE dfDefaultChar;
57
BYTE dfBreakChar;
58
INT16 dfWidthBytes;
59
LONG dfDevice;
60
LONG dfFace;
61
LONG dfBitsPointer;
62
LONG dfBitsOffset;
63
BYTE dfReserved;
64
/* Fields, introduced for Windows 3.x fonts */
65
LONG dfFlags;
66
INT16 dfAspace;
67
INT16 dfBspace;
68
INT16 dfCspace;
69
LONG dfColorPointer;
70
LONG dfReserved1[4];
71
} FONTINFO16;
72
73
typedef struct
74
{
75
SHORT dfVersion; /* Version */
76
int dfSize; /* Total File Size */
77
char dfCopyright[60]; /* Copyright notice */
78
FONTINFO16 fi; /* FONTINFO structure */
79
} WINFNT;
80
#pragma pack(pop)
81
82
/* FIXME: recognize and dump also NE/PE wrapped fonts */
83
84
enum FileSig get_kind_fnt(void)
85
{
86
const WINFNT *fnt = PRD(0, sizeof(WINFNT));
87
if (fnt && (fnt->dfVersion == 0x200 || fnt->dfVersion == 0x300) &&
88
PRD(0, fnt->dfSize) != NULL)
89
return SIG_FNT;
90
return SIG_UNKNOWN;
91
}
92
93
void fnt_dump(void)
94
{
95
const WINFNT *fnt = PRD(0, sizeof(WINFNT));
96
97
printf("dfVersion %#x, dfSize %d bytes, dfCopyright %.60s\n",
98
fnt->dfVersion, fnt->dfSize, fnt->dfCopyright);
99
printf("dfType %d\n"
100
"dfPoints %d\n"
101
"dfVertRes %d\n"
102
"dfHorizRes %d\n"
103
"dfAscent %d\n"
104
"dfInternalLeading %d\n"
105
"dfExternalLeading %d\n"
106
"dfItalic %d\n"
107
"dfUnderline %d\n"
108
"dfStrikeOut %d\n"
109
"dfWeight %d\n"
110
"dfCharSet %d\n"
111
"dfPixWidth %d\n"
112
"dfPixHeight %d\n"
113
"dfPitchAndFamily %#x\n"
114
"dfAvgWidth %d\n"
115
"dfMaxWidth %d\n"
116
"dfFirstChar %#x\n"
117
"dfLastChar %#x\n"
118
"dfDefaultChar %#x\n"
119
"dfBreakChar %#x\n"
120
"dfWidthBytes %d\n",
121
fnt->fi.dfType, fnt->fi.dfPoints, fnt->fi.dfVertRes, fnt->fi.dfHorizRes,
122
fnt->fi.dfAscent, fnt->fi.dfInternalLeading, fnt->fi.dfExternalLeading,
123
fnt->fi.dfItalic, fnt->fi.dfUnderline, fnt->fi.dfStrikeOut, fnt->fi.dfWeight,
124
fnt->fi.dfCharSet, fnt->fi.dfPixWidth, fnt->fi.dfPixHeight, fnt->fi.dfPitchAndFamily,
125
fnt->fi.dfAvgWidth, fnt->fi.dfMaxWidth, fnt->fi.dfFirstChar, fnt->fi.dfLastChar,
126
fnt->fi.dfDefaultChar, fnt->fi.dfBreakChar, fnt->fi.dfWidthBytes);
127
}
128
129