font.c 3.6 KB

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