kernel32/tests: Don't test functions directly when reporting GetLastError().
[wine.git] / tools / winedump / font.c
blob3257fce9d801adf5d3dd9346ec8c80f95bd1929c
1 /*
2 * Dump a font file
4 * Copyright 2009 Dmitry Timoshkov
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.
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.
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
21 #include "config.h"
22 #include "wine/port.h"
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>
38 #include "windef.h"
39 #include "winbase.h"
40 #include "winnt.h"
42 #include "winedump.h"
44 #include <pshpack1.h>
45 typedef struct
47 INT16 dfType;
48 INT16 dfPoints;
49 INT16 dfVertRes;
50 INT16 dfHorizRes;
51 INT16 dfAscent;
52 INT16 dfInternalLeading;
53 INT16 dfExternalLeading;
54 BYTE dfItalic;
55 BYTE dfUnderline;
56 BYTE dfStrikeOut;
57 INT16 dfWeight;
58 BYTE dfCharSet;
59 INT16 dfPixWidth;
60 INT16 dfPixHeight;
61 BYTE dfPitchAndFamily;
62 INT16 dfAvgWidth;
63 INT16 dfMaxWidth;
64 BYTE dfFirstChar;
65 BYTE dfLastChar;
66 BYTE dfDefaultChar;
67 BYTE dfBreakChar;
68 INT16 dfWidthBytes;
69 LONG dfDevice;
70 LONG dfFace;
71 LONG dfBitsPointer;
72 LONG dfBitsOffset;
73 BYTE dfReserved;
74 /* Fields, introduced for Windows 3.x fonts */
75 LONG dfFlags;
76 INT16 dfAspace;
77 INT16 dfBspace;
78 INT16 dfCspace;
79 LONG dfColorPointer;
80 LONG dfReserved1[4];
81 } FONTINFO16;
83 typedef struct
85 SHORT dfVersion; /* Version */
86 LONG dfSize; /* Total File Size */
87 char dfCopyright[60]; /* Copyright notice */
88 FONTINFO16 fi; /* FONTINFO structure */
89 } WINFNT;
90 #include <poppack.h>
92 /* FIXME: recognize and dump also NE/PE wrapped fonts */
94 enum FileSig get_kind_fnt(void)
96 const WINFNT *fnt = PRD(0, sizeof(WINFNT));
97 if (fnt && (fnt->dfVersion == 0x200 || fnt->dfVersion == 0x300) &&
98 PRD(0, fnt->dfSize) != NULL)
99 return SIG_FNT;
100 return SIG_UNKNOWN;
103 void fnt_dump(void)
105 const WINFNT *fnt = PRD(0, sizeof(WINFNT));
107 printf("dfVersion %#x, dfSize %d bytes, dfCopyright %.60s\n",
108 fnt->dfVersion, fnt->dfSize, fnt->dfCopyright);
109 printf("dfType %d\n"
110 "dfPoints %d\n"
111 "dfVertRes %d\n"
112 "dfHorizRes %d\n"
113 "dfAscent %d\n"
114 "dfInternalLeading %d\n"
115 "dfExternalLeading %d\n"
116 "dfItalic %d\n"
117 "dfUnderline %d\n"
118 "dfStrikeOut %d\n"
119 "dfWeight %d\n"
120 "dfCharSet %d\n"
121 "dfPixWidth %d\n"
122 "dfPixHeight %d\n"
123 "dfPitchAndFamily %#x\n"
124 "dfAvgWidth %d\n"
125 "dfMaxWidth %d\n"
126 "dfFirstChar %#x\n"
127 "dfLastChar %#x\n"
128 "dfDefaultChar %#x\n"
129 "dfBreakChar %#x\n"
130 "dfWidthBytes %d\n",
131 fnt->fi.dfType, fnt->fi.dfPoints, fnt->fi.dfVertRes, fnt->fi.dfHorizRes,
132 fnt->fi.dfAscent, fnt->fi.dfInternalLeading, fnt->fi.dfExternalLeading,
133 fnt->fi.dfItalic, fnt->fi.dfUnderline, fnt->fi.dfStrikeOut, fnt->fi.dfWeight,
134 fnt->fi.dfCharSet, fnt->fi.dfPixWidth, fnt->fi.dfPixHeight, fnt->fi.dfPitchAndFamily,
135 fnt->fi.dfAvgWidth, fnt->fi.dfMaxWidth, fnt->fi.dfFirstChar, fnt->fi.dfLastChar,
136 fnt->fi.dfDefaultChar, fnt->fi.dfBreakChar, fnt->fi.dfWidthBytes);