jscript: Better handling of to_integer result in String.lastIndexOf.
[wine] / tools / winedump / font.c
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 #include "wine/port.h"
23
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #ifdef HAVE_UNISTD_H
28 # include <unistd.h>
29 #endif
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
32 #endif
33 #ifdef HAVE_SYS_MMAN_H
34 #include <sys/mman.h>
35 #endif
36 #include <fcntl.h>
37
38 #define NONAMELESSUNION
39 #define NONAMELESSSTRUCT
40 #include "windef.h"
41 #include "winbase.h"
42 #include "winnt.h"
43
44 #include "winedump.h"
45
46 #include <pshpack1.h>
47 typedef struct
48 {
49     INT16 dfType;
50     INT16 dfPoints;
51     INT16 dfVertRes;
52     INT16 dfHorizRes;
53     INT16 dfAscent;
54     INT16 dfInternalLeading;
55     INT16 dfExternalLeading;
56     BYTE  dfItalic;
57     BYTE  dfUnderline;
58     BYTE  dfStrikeOut;
59     INT16 dfWeight;
60     BYTE  dfCharSet;
61     INT16 dfPixWidth;
62     INT16 dfPixHeight;
63     BYTE  dfPitchAndFamily;
64     INT16 dfAvgWidth;
65     INT16 dfMaxWidth;
66     BYTE  dfFirstChar;
67     BYTE  dfLastChar;
68     BYTE  dfDefaultChar;
69     BYTE  dfBreakChar;
70     INT16 dfWidthBytes;
71     LONG  dfDevice;
72     LONG  dfFace;
73     LONG  dfBitsPointer;
74     LONG  dfBitsOffset;
75     BYTE  dfReserved;
76     /* Fields, introduced for Windows 3.x fonts */
77     LONG  dfFlags;
78     INT16 dfAspace;
79     INT16 dfBspace;
80     INT16 dfCspace;
81     LONG  dfColorPointer;
82     LONG  dfReserved1[4];
83 } FONTINFO16;
84
85 typedef struct
86 {
87     SHORT dfVersion;            /* Version */
88     LONG dfSize;                /* Total File Size */
89     char dfCopyright[60];       /* Copyright notice */
90     FONTINFO16 fi;              /* FONTINFO structure */
91 } WINFNT;
92 #include <poppack.h>
93
94 /* FIXME: recognize and dump also NE/PE wrapped fonts */
95
96 enum FileSig get_kind_fnt(void)
97 {
98     const WINFNT *fnt = PRD(0, sizeof(WINFNT));
99     if (fnt && (fnt->dfVersion == 0x200 || fnt->dfVersion == 0x300) &&
100         PRD(0, fnt->dfSize) != NULL)
101         return SIG_FNT;
102     return SIG_UNKNOWN;
103 }
104
105 void fnt_dump(void)
106 {
107     const WINFNT *fnt = PRD(0, sizeof(WINFNT));
108
109     printf("dfVersion %#x, dfSize %d bytes, dfCopyright %.60s\n",
110         fnt->dfVersion, fnt->dfSize, fnt->dfCopyright);
111     printf("dfType %d\n"
112         "dfPoints %d\n"
113         "dfVertRes %d\n"
114         "dfHorizRes %d\n"
115         "dfAscent %d\n"
116         "dfInternalLeading %d\n"
117         "dfExternalLeading %d\n"
118         "dfItalic %d\n"
119         "dfUnderline %d\n"
120         "dfStrikeOut %d\n"
121         "dfWeight %d\n"
122         "dfCharSet %d\n"
123         "dfPixWidth %d\n"
124         "dfPixHeight %d\n"
125         "dfPitchAndFamily %#x\n"
126         "dfAvgWidth %d\n"
127         "dfMaxWidth %d\n"
128         "dfFirstChar %#x\n"
129         "dfLastChar %#x\n"
130         "dfDefaultChar %#x\n"
131         "dfBreakChar %#x\n"
132         "dfWidthBytes %d\n",
133         fnt->fi.dfType, fnt->fi.dfPoints, fnt->fi.dfVertRes, fnt->fi.dfHorizRes,
134         fnt->fi.dfAscent, fnt->fi.dfInternalLeading, fnt->fi.dfExternalLeading,
135         fnt->fi.dfItalic, fnt->fi.dfUnderline, fnt->fi.dfStrikeOut, fnt->fi.dfWeight,
136         fnt->fi.dfCharSet, fnt->fi.dfPixWidth, fnt->fi.dfPixHeight, fnt->fi.dfPitchAndFamily,
137         fnt->fi.dfAvgWidth, fnt->fi.dfMaxWidth, fnt->fi.dfFirstChar, fnt->fi.dfLastChar,
138         fnt->fi.dfDefaultChar, fnt->fi.dfBreakChar, fnt->fi.dfWidthBytes);
139 }