font.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. #include "config.h"
  21. #include "wine/port.h"
  22. #include <stdarg.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #ifdef HAVE_UNISTD_H
  26. # include <unistd.h>
  27. #endif
  28. #ifdef HAVE_SYS_TYPES_H
  29. # include <sys/types.h>
  30. #endif
  31. #ifdef HAVE_SYS_MMAN_H
  32. #include <sys/mman.h>
  33. #endif
  34. #include <fcntl.h>
  35. #include "windef.h"
  36. #include "winbase.h"
  37. #include "winnt.h"
  38. #include "winedump.h"
  39. #include <pshpack1.h>
  40. typedef struct
  41. {
  42. INT16 dfType;
  43. INT16 dfPoints;
  44. INT16 dfVertRes;
  45. INT16 dfHorizRes;
  46. INT16 dfAscent;
  47. INT16 dfInternalLeading;
  48. INT16 dfExternalLeading;
  49. BYTE dfItalic;
  50. BYTE dfUnderline;
  51. BYTE dfStrikeOut;
  52. INT16 dfWeight;
  53. BYTE dfCharSet;
  54. INT16 dfPixWidth;
  55. INT16 dfPixHeight;
  56. BYTE dfPitchAndFamily;
  57. INT16 dfAvgWidth;
  58. INT16 dfMaxWidth;
  59. BYTE dfFirstChar;
  60. BYTE dfLastChar;
  61. BYTE dfDefaultChar;
  62. BYTE dfBreakChar;
  63. INT16 dfWidthBytes;
  64. LONG dfDevice;
  65. LONG dfFace;
  66. LONG dfBitsPointer;
  67. LONG dfBitsOffset;
  68. BYTE dfReserved;
  69. /* Fields, introduced for Windows 3.x fonts */
  70. LONG dfFlags;
  71. INT16 dfAspace;
  72. INT16 dfBspace;
  73. INT16 dfCspace;
  74. LONG dfColorPointer;
  75. LONG dfReserved1[4];
  76. } FONTINFO16;
  77. typedef struct
  78. {
  79. SHORT dfVersion; /* Version */
  80. LONG dfSize; /* Total File Size */
  81. char dfCopyright[60]; /* Copyright notice */
  82. FONTINFO16 fi; /* FONTINFO structure */
  83. } WINFNT;
  84. #include <poppack.h>
  85. /* FIXME: recognize and dump also NE/PE wrapped fonts */
  86. enum FileSig get_kind_fnt(void)
  87. {
  88. const WINFNT *fnt = PRD(0, sizeof(WINFNT));
  89. if (fnt && (fnt->dfVersion == 0x200 || fnt->dfVersion == 0x300) &&
  90. PRD(0, fnt->dfSize) != NULL)
  91. return SIG_FNT;
  92. return SIG_UNKNOWN;
  93. }
  94. void fnt_dump(void)
  95. {
  96. const WINFNT *fnt = PRD(0, sizeof(WINFNT));
  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. }