ReactOS  0.4.14-dev-342-gdc047f9
font.c File Reference
#include "ftfd.h"
Include dependency graph for font.c:

Go to the source code of this file.

Functions

PVOID HackFixup (PVOID pvView, ULONG cjView)
 
ULONG_PTR APIENTRY FtfdLoadFontFile (ULONG cFiles, ULONG_PTR *piFile, PVOID *ppvView, ULONG *pcjView, DESIGNVECTOR *pdv, ULONG ulLangID, ULONG ulFastCheckSum)
 
BOOL APIENTRY FtfdUnloadFontFile (IN ULONG_PTR iFile)
 
LONG APIENTRY FtfdQueryFontFile (ULONG_PTR iFile, ULONG ulMode, ULONG cjBuf, ULONG *pulBuf)
 
PIFIMETRICS APIENTRY FtfdQueryFont (IN DHPDEV dhpdev, IN ULONG_PTR iFile, IN ULONG iFace, IN ULONG_PTR *pid)
 
LONG APIENTRY FtfdQueryFontCaps (ULONG culCaps, ULONG *pulCaps)
 
PVOID APIENTRY FtfdQueryFontTree (DHPDEV dhpdev, ULONG_PTR iFile, ULONG iFace, ULONG iMode, ULONG_PTR *pid)
 
VOID APIENTRY FtfdFree (PVOID pv, ULONG_PTR id)
 

Function Documentation

◆ FtfdFree()

VOID APIENTRY FtfdFree ( PVOID  pv,
ULONG_PTR  id 
)

Definition at line 480 of file font.c.

483 {
484  DbgPrint("FtfdFree()\n");
485  if (id)
486  {
487  EngFreeMem((PVOID)id);
488  }
489 }
#define DbgPrint
Definition: loader.c:25
#define EngFreeMem
Definition: polytest.cpp:56

◆ FtfdLoadFontFile()

ULONG_PTR APIENTRY FtfdLoadFontFile ( ULONG  cFiles,
ULONG_PTR piFile,
PVOID ppvView,
ULONG pcjView,
DESIGNVECTOR pdv,
ULONG  ulLangID,
ULONG  ulFastCheckSum 
)

Public Interface

Definition at line 29 of file font.c.

37 {
38  PVOID pvView;
39  ULONG cjView, i;
40  FT_Error fterror;
41  FT_Face ftface;
42  PFTFD_FILE pfile;
43  ULONG cjSize, cNumFaces;
44 
45  DbgPrint("FtfdLoadFontFile()\n");
46 
47  /* Check parameters */
48  if (cFiles != 1)
49  {
50  DbgPrint("Only 1 File is allowed, got %ld!\n", cFiles);
51  return HFF_INVALID;
52  }
53 
54  /* Map the font file */
55  if (!EngMapFontFileFD(*piFile, (PULONG*)&pvView, &cjView))
56  {
57  DbgPrint("Could not map font file!\n");
58  return HFF_INVALID;
59  }
60 
61  // HACK!!!
62  pvView = HackFixup(pvView, cjView);
63 
64  fterror = FT_New_Memory_Face(gftlibrary, pvView, cjView, 0, &ftface);
65  if (fterror)
66  {
67  DbgPrint("No faces found in file\n");
68 
69  /* Unmap the file */
71 
72  /* Failure! */
73  return HFF_INVALID;
74  }
75 
76  /* Get number of faces from the first face */
77  cNumFaces = ftface->num_faces;
78 
79  cjSize = sizeof(FTFD_FILE) + cNumFaces * sizeof(FT_Face);
80  pfile = EngAllocMem(0, cjSize, 'dftF');
81  if (!pfile)
82  {
83  DbgPrint("EngAllocMem() failed.\n");
84 
85  /* Unmap the file */
87 
88  /* Failure! */
89  return HFF_INVALID;
90  }
91 
92  pfile->cNumFaces = cNumFaces;
93  pfile->iFile = *piFile;
94  pfile->pvView = pvView;
95  pfile->cjView = cjView;
96 
97  for (i = 0; i < pfile->cNumFaces; i++)
98  {
99  pfile->aftface[i] = ftface;
100  FT_Select_Charmap(ftface, FT_ENCODING_UNICODE);
101  }
102 
103  DbgPrint("Success! Returning %ld faces\n", cNumFaces);
104 
105  return (ULONG_PTR)pfile;
106 }
int FT_Error
Definition: fttypes.h:300
ULONG_PTR iFile
Definition: ftfd.h:36
#define HFF_INVALID
Definition: winddi.h:156
#define DbgPrint
Definition: loader.c:25
Definition: ftfd.h:32
FT_New_Memory_Face(FT_Library library, const FT_Byte *file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface)
Definition: ftobjs.c:1431
uint32_t ULONG_PTR
Definition: typedefs.h:63
FT_Long num_faces
Definition: freetype.h:1070
ULONG cjView
Definition: ftfd.h:35
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG cNumFaces
Definition: ftfd.h:37
_In_ ULONG_PTR * piFile
Definition: winddi.h:3720
ENGAPI VOID APIENTRY EngUnmapFontFileFD(_In_ ULONG_PTR iFile)
Definition: mapping.c:564
FT_Library gftlibrary
Definition: enable.c:26
FT_Select_Charmap(FT_Face face, FT_Encoding encoding)
Definition: ftobjs.c:3457
FT_Face aftface[1]
Definition: ftfd.h:38
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
PVOID pvView
Definition: ftfd.h:34
unsigned int * PULONG
Definition: retypes.h:1
PVOID HackFixup(PVOID pvView, ULONG cjView)
Definition: font.c:11
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG cjSize
Definition: winddi.h:3634

◆ FtfdQueryFont()

PIFIMETRICS APIENTRY FtfdQueryFont ( IN DHPDEV  dhpdev,
IN ULONG_PTR  iFile,
IN ULONG  iFace,
IN ULONG_PTR pid 
)

Definition at line 169 of file font.c.

174 {
175  PFTFD_FILE pfile = (PFTFD_FILE)iFile;
176  PFTFD_IFIMETRICS pifiX;
177  PIFIMETRICS pifi;
178  FT_Face ftface;
179  FT_Error fterror;
180  ULONG i;
181 
182  DbgPrint("FtfdQueryFont()\n");
183 
184  /* Validate parameters */
185  if (iFace > pfile->cNumFaces || !pid)
186  {
187  DbgPrint("iFace > pfile->cNumFaces || !pid\n");
188  return NULL;
189  }
190 
191  fterror = FT_New_Memory_Face(gftlibrary,
192  pfile->pvView,
193  pfile->cjView,
194  iFace - 1,
195  &ftface);
196  if (fterror)
197  {
198  DbgPrint("FT_New_Memory_Face failed\n");
199  return NULL;
200  }
201 
202  /* Allocate the ifi metrics structure */
204  if (!pifiX)
205  {
206  DbgPrint("EngAllocMem() failed.\n");
207  FT_Done_Face(ftface);
208  return NULL;
209  }
210 
211  /* Fill IFIMETRICS */
212  pifi = &pifiX->ifim;
213  pifi->cjThis = sizeof(FTFD_IFIMETRICS);
214  pifi->cjIfiExtra = 0;
215 
216  /* Relative offsets */
217  pifi->dpwszFamilyName = FIELD_OFFSET(FTFD_IFIMETRICS, wszFamilyName);
218  pifi->dpwszStyleName = FIELD_OFFSET(FTFD_IFIMETRICS, wszStyleName);
219  pifi->dpwszFaceName = FIELD_OFFSET(FTFD_IFIMETRICS, wszFaceName);
220  pifi->dpwszUniqueName = FIELD_OFFSET(FTFD_IFIMETRICS, wszFaceName);
221  pifi->dpCharSets = FIELD_OFFSET(FTFD_IFIMETRICS, ajCharSet);
222  pifi->dpFontSim = 0;
223 
224  /* Charsets */
225  pifi->jWinCharSet = ANSI_CHARSET;
226  pifiX->ajCharSet[0] = pifi->jWinCharSet;
227  for (i = 1; i < 16; i++)
228  {
229  pifiX->ajCharSet[i] = DEFAULT_CHARSET;
230  }
231 
232  pifi->lEmbedId = 0;
233  pifi->lItalicAngle = 0;
234  pifi->lCharBias = 0;
235  pifi->jWinPitchAndFamily = VARIABLE_PITCH | FF_DONTCARE; // FIXME
236  pifi->usWinWeight = FW_MEDIUM; // FIXME
242  pifi->fsSelection = 0;
243  pifi->fsType = 0;
244 
245  /* Font resolution */
246  pifi->fwdUnitsPerEm = ftface->units_per_EM;
247  pifi->fwdLowestPPEm = 8; // FIXME
248 
249  /* Font metrics */
250  pifi->fwdWinAscender = ftface->ascender;
251  pifi->fwdWinDescender = - ftface->descender;
252  pifi->fwdMacAscender = pifi->fwdWinAscender;
253  pifi->fwdMacDescender = - pifi->fwdWinDescender;
254  pifi->fwdMacLineGap = 0;
255  pifi->fwdTypoAscender = pifi->fwdWinAscender;
256  pifi->fwdTypoDescender = 0; // FIXME!!! - pifi->fwdWinDescender;
257  pifi->fwdTypoLineGap = 0;
258  pifi->fwdAveCharWidth = 1085; // FIXME
259  pifi->fwdMaxCharInc = ftface->max_advance_width;
260  pifi->fwdCapHeight = pifi->fwdUnitsPerEm / 2;
261  pifi->fwdXHeight = pifi->fwdUnitsPerEm / 4;
262  pifi->fwdSubscriptXSize = 0;
263  pifi->fwdSubscriptYSize = 0;
264  pifi->fwdSubscriptXOffset = 0;
265  pifi->fwdSubscriptYOffset = 0;
266  pifi->fwdSuperscriptXSize = 0;
267  pifi->fwdSuperscriptYSize = 0;
268  pifi->fwdSuperscriptXOffset = 0;
269  pifi->fwdSuperscriptYOffset = 0;
270  pifi->fwdUnderscoreSize = 1;
271  pifi->fwdUnderscorePosition = -1;
272  pifi->fwdStrikeoutSize = 1;
273  pifi->fwdStrikeoutPosition = pifi->fwdXHeight + 1;
274 
275  pifi->ptlBaseline.x = 1;
276  pifi->ptlBaseline.y = 0;
277  pifi->ptlAspect.x = 1;
278  pifi->ptlAspect.y = 1;
279  pifi->ptlCaret.x = 0;
280  pifi->ptlCaret.y = 1;
281 
282  /* Set the biggest characters bounding box */
283  pifi->rclFontBox.left = ftface->bbox.xMin;
284  pifi->rclFontBox.right = ftface->bbox.xMax;
285  pifi->rclFontBox.top = ftface->bbox.yMax;
286  pifi->rclFontBox.bottom = ftface->bbox.yMin;
287 
288  /* Special characters */
289  pifi->chFirstChar = 0x1c; // FIXME
290  pifi->chLastChar = 0x79;
291  pifi->chDefaultChar = 0x1d;
292  pifi->chBreakChar = 0x1e;
293  pifi->wcFirstChar = 0x1e;
294  pifi->wcLastChar = 0x79;
295  pifi->wcDefaultChar = 0x1d;
296  pifi->wcBreakChar = 0x1e;
297 
298 
299  *(DWORD*)&pifi->achVendId = 0x30303030; // FIXME
300  pifi->cKerningPairs = 0;
302 // pifi->panose = panose;
303 
305  LF_FACESIZE,
306  NULL,
307  ftface->family_name,
308  strnlen(ftface->family_name, MAX_PATH));
309 
311  LF_FACESIZE,
312  NULL,
313  ftface->style_name,
314  strnlen(ftface->style_name, MAX_PATH));
315 
317  LF_FACESIZE,
318  NULL,
319  ftface->family_name,
320  strnlen(ftface->family_name, MAX_PATH));
321 
322  FT_Done_Face(ftface);
323 
324  DbgPrint("Finished with the ifi: %p\n", pifiX);
325  __debugbreak();
326 
327  return pifi;
328 }
WCHAR wcFirstChar
Definition: winddi.h:1094
int FT_Error
Definition: fttypes.h:300
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
IFIMETRICS ifim
Definition: ftfd.h:45
BYTE achVendId[4]
Definition: winddi.h:1102
#define FM_INFO_TECH_TRUETYPE
Definition: winddi.h:1008
WCHAR wcBreakChar
Definition: winddi.h:1097
#define LF_FACESIZE
Definition: dimm.idl:39
#define VARIABLE_PITCH
Definition: wingdi.h:444
#define FF_DONTCARE
Definition: wingdi.h:447
#define DbgPrint
Definition: loader.c:25
BYTE ajCharSet[16]
Definition: ftfd.h:46
POINTL ptlAspect
Definition: winddi.h:1099
WCHAR wszFamilyName[LF_FACESIZE]
Definition: ftfd.h:48
#define FM_INFO_RIGHT_HANDED
Definition: winddi.h:1027
long bottom
Definition: polytest.cpp:53
WCHAR wszStyleName[MAX_STYLESIZE]
Definition: ftfd.h:50
WCHAR wcDefaultChar
Definition: winddi.h:1096
ENGAPI VOID APIENTRY EngMultiByteToUnicodeN(_Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) LPWSTR UnicodeString, _In_ ULONG MaxBytesInUnicodeString, _Out_opt_ PULONG BytesInUnicodeString, _In_reads_bytes_(BytesInMultiByteString) PCHAR MultiByteString, _In_ ULONG BytesInMultiByteString)
PTRDIFF dpwszStyleName
Definition: winddi.h:1050
#define DEFAULT_CHARSET
Definition: wingdi.h:383
FWORD fwdTypoLineGap
Definition: winddi.h:1073
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
FWORD fwdSubscriptYOffset
Definition: winddi.h:1081
LONG lItalicAngle
Definition: winddi.h:1055
Definition: ftfd.h:32
FWORD fwdSubscriptXOffset
Definition: winddi.h:1080
FT_New_Memory_Face(FT_Library library, const FT_Byte *file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface)
Definition: ftobjs.c:1431
ULONG ulPanoseCulture
Definition: winddi.h:1104
LONG y
Definition: windef.h:315
FT_UShort units_per_EM
Definition: freetype.h:1094
long right
Definition: polytest.cpp:53
ULONG cjView
Definition: ftfd.h:35
FWORD fwdSuperscriptYSize
Definition: winddi.h:1083
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FM_INFO_4BPP
Definition: winddi.h:1014
USHORT fsType
Definition: winddi.h:1063
ULONG cNumFaces
Definition: ftfd.h:37
#define FM_PANOSE_CULTURE_LATIN
Definition: winddi.h:1044
PTRDIFF dpCharSets
Definition: winddi.h:1057
FT_String * family_name
Definition: freetype.h:1078
long top
Definition: polytest.cpp:53
PTRDIFF dpwszFamilyName
Definition: winddi.h:1049
WCHAR wszFaceName[LF_FACESIZE]
Definition: ftfd.h:49
smooth NULL
Definition: ftsmooth.c:416
FWORD fwdSuperscriptXSize
Definition: winddi.h:1082
FT_Pos yMax
Definition: ftimage.h:118
RECTL rclFontBox
Definition: winddi.h:1101
PTRDIFF dpFontSim
Definition: winddi.h:1053
FWORD fwdSuperscriptXOffset
Definition: winddi.h:1084
long left
Definition: polytest.cpp:53
struct FTFD_FILE * PFTFD_FILE
ULONG cjThis
Definition: winddi.h:1047
FWORD fwdWinAscender
Definition: winddi.h:1066
PTRDIFF dpwszUniqueName
Definition: winddi.h:1052
#define FM_INFO_1BPP
Definition: winddi.h:1013
FT_Library gftlibrary
Definition: enable.c:26
#define FW_MEDIUM
Definition: wingdi.h:374
FWORD fwdAveCharWidth
Definition: winddi.h:1074
FWORD fwdCapHeight
Definition: winddi.h:1076
FWORD fwdUnderscoreSize
Definition: winddi.h:1086
FT_Pos xMin
Definition: ftimage.h:117
FT_Short descender
Definition: freetype.h:1096
BYTE jWinCharSet
Definition: winddi.h:1058
#define MAX_PATH
Definition: compat.h:26
FT_Pos xMax
Definition: ftimage.h:118
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG x
Definition: windef.h:314
POINTL ptlBaseline
Definition: winddi.h:1098
_In_ ULONG_PTR _In_ ULONG iFace
Definition: winddi.h:3835
FWORD fwdMacDescender
Definition: winddi.h:1069
BYTE chLastChar
Definition: winddi.h:1091
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
BYTE chDefaultChar
Definition: winddi.h:1092
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
POINTL ptlCaret
Definition: winddi.h:1100
FWORD fwdWinDescender
Definition: winddi.h:1067
FWORD fwdMaxCharInc
Definition: winddi.h:1075
FWORD fwdMacAscender
Definition: winddi.h:1068
FWORD fwdLowestPPEm
Definition: winddi.h:1065
PVOID pvView
Definition: ftfd.h:34
FT_Short max_advance_width
Definition: freetype.h:1099
#define FM_INFO_RETURNS_OUTLINES
Definition: winddi.h:1023
BYTE jWinPitchAndFamily
Definition: winddi.h:1059
USHORT usWinWeight
Definition: winddi.h:1060
FWORD fwdSuperscriptYOffset
Definition: winddi.h:1085
FT_Pos yMin
Definition: ftimage.h:117
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
FWORD fwdXHeight
Definition: winddi.h:1077
#define TAG_IFIMETRICS
Definition: bmfd.h:43
FWORD fwdSubscriptYSize
Definition: winddi.h:1079
BYTE chBreakChar
Definition: winddi.h:1093
FWORD fwdMacLineGap
Definition: winddi.h:1070
LONG lEmbedId
Definition: winddi.h:1054
FWORD fwdTypoDescender
Definition: winddi.h:1072
ULONG flInfo
Definition: winddi.h:1061
FWORD fwdStrikeoutPosition
Definition: winddi.h:1089
FT_String * style_name
Definition: freetype.h:1079
USHORT fsSelection
Definition: winddi.h:1062
ULONG cjIfiExtra
Definition: winddi.h:1048
ULONG cKerningPairs
Definition: winddi.h:1103
BYTE chFirstChar
Definition: winddi.h:1090
_In_ ULONG_PTR iFile
Definition: winddi.h:3835
FWORD fwdTypoAscender
Definition: winddi.h:1071
FWORD fwdUnderscorePosition
Definition: winddi.h:1087
FWORD fwdSubscriptXSize
Definition: winddi.h:1078
unsigned int ULONG
Definition: retypes.h:1
FT_Done_Face(FT_Face face)
Definition: ftobjs.c:2721
#define FM_INFO_ARB_XFORMS
Definition: winddi.h:1012
WCHAR wcLastChar
Definition: winddi.h:1095
FT_Short ascender
Definition: freetype.h:1095
#define ANSI_CHARSET
Definition: wingdi.h:382
LONG lCharBias
Definition: winddi.h:1056
FWORD fwdStrikeoutSize
Definition: winddi.h:1088
PTRDIFF dpwszFaceName
Definition: winddi.h:1051
FT_BBox bbox
Definition: freetype.h:1092
FWORD fwdUnitsPerEm
Definition: winddi.h:1064
#define FM_INFO_RETURNS_BITMAPS
Definition: winddi.h:1025

◆ FtfdQueryFontCaps()

LONG APIENTRY FtfdQueryFontCaps ( ULONG  culCaps,
ULONG pulCaps 
)

Definition at line 333 of file font.c.

336 {
337  DbgPrint("FtfdQueryFontCaps()\n");
338 
339  /* We need room for 2 ULONGs */
340  if (culCaps < 2)
341  {
342  return FD_ERROR;
343  }
344 
345  /* We only support 1 bpp */
346  pulCaps[0] = 2;
347  pulCaps[1] = QC_1BIT;
348 
349  return 2;
350 }
#define DbgPrint
Definition: loader.c:25
#define FD_ERROR
Definition: winddi.h:153
#define QC_1BIT
Definition: winddi.h:3843

◆ FtfdQueryFontFile()

LONG APIENTRY FtfdQueryFontFile ( ULONG_PTR  iFile,
ULONG  ulMode,
ULONG  cjBuf,
ULONG pulBuf 
)

Definition at line 139 of file font.c.

144 {
145  PFTFD_FILE pfile = (PFTFD_FILE)iFile;
146 
147  DbgPrint("FtfdQueryFontFile(ulMode=%ld)\n", ulMode);
148 // __debugbreak();
149 
150  switch (ulMode)
151  {
152  case QFF_DESCRIPTION:
153  {
154  return 0;
155  }
156 
157  case QFF_NUMFACES:
158  /* return the number of faces in the file */
159  return pfile->cNumFaces;
160 
161  }
162 
163  return FD_ERROR;
164 }
#define DbgPrint
Definition: loader.c:25
#define FD_ERROR
Definition: winddi.h:153
Definition: ftfd.h:32
#define QFF_DESCRIPTION
Definition: winddi.h:3879
ULONG cNumFaces
Definition: ftfd.h:37
struct FTFD_FILE * PFTFD_FILE
_In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ TRIVERTEX _In_ ULONG _In_ PVOID _In_ ULONG _In_ RECTL _In_ POINTL _In_ ULONG ulMode
Definition: winddi.h:3649
_In_ ULONG_PTR iFile
Definition: winddi.h:3835
#define QFF_NUMFACES
Definition: winddi.h:3880

◆ FtfdQueryFontTree()

PVOID APIENTRY FtfdQueryFontTree ( DHPDEV  dhpdev,
ULONG_PTR  iFile,
ULONG  iFace,
ULONG  iMode,
ULONG_PTR pid 
)

Definition at line 355 of file font.c.

361 {
362  PFTFD_FILE pfile = (PFTFD_FILE)iFile;
363  FT_Face ftface;
364  FT_Error fterror;
365  FTFD_CHARPAIR *pcp;
366  FD_GLYPHSET *pGlyphSet;
367  FT_ULong charcode;
368  ULONG i, j, cGlyphs, cRuns, cjSize;
369  WCRUN *pwcrun;
370  HGLYPH * phglyphs;
371 
372  DbgPrint("FtfdQueryFontTree()\n");
373 
374  fterror = FT_New_Memory_Face(gftlibrary,
375  pfile->pvView,
376  pfile->cjView,
377  iFace - 1,
378  &ftface);
379  if (fterror)
380  {
381  DbgPrint("FT_New_Memory_Face() failed.\n");
382  return NULL;
383  }
384 
385  /* Get initial value for cGlyphs from ftface */
386  cGlyphs = ftface->num_glyphs + 1;
387 
388  /* Allocate a buffer for the char codes and glyph indexes */
389  pcp = EngAllocMem(0, cGlyphs * sizeof(FTFD_CHARPAIR), 'pcp ');
390  if (!pcp)
391  {
392  DbgPrint("EngAllocMem() failed.\n");
393  return NULL;
394  }
395 
396  /* Gather char codes and indexes and count WCRUNs */
397  pcp[0].code = FT_Get_First_Char(ftface, &pcp[0].index);
398  charcode = pcp[0].code;
399  for (i = 1, cRuns = 1; charcode && i < cGlyphs; i++)
400  {
401  charcode = FT_Get_Next_Char(ftface, charcode, &pcp[i].index);
402  DbgPrint("charcode=0x%lx, index=0x%lx\n", charcode, pcp[i].index);
403  pcp[i].code = charcode;
404  if (charcode != pcp[i - 1].code + 1)
405  {
406  cRuns++;
407  }
408  }
409 
410  /* Update cGlyphs to real value */
411  cGlyphs = i - 1;
412 
413  /* Calculate FD_GLYPHSET size */
414  cjSize = sizeof(FD_GLYPHSET)
415  + (cRuns - 1) * sizeof(WCRUN)
416  + cGlyphs * sizeof(HGLYPH);
417 
418  /* Allocate the FD_GLYPHSET structure */
419  pGlyphSet = EngAllocMem(0, cjSize, TAG_GLYPHSET);
420  if (!pGlyphSet)
421  {
422  DbgPrint("EngAllocMem() failed.\n");
423  EngFreeMem(pcp);
424  return NULL;
425  }
426 
427  /* Initialize FD_GLYPHSET */
428  pGlyphSet->cjThis = cjSize;
429  pGlyphSet->flAccel = 0;
430  pGlyphSet->cGlyphsSupported = cGlyphs;
431  pGlyphSet->cRuns = cRuns;
432 
433  /* Initialize 1st WCRUN */
434  pwcrun = pGlyphSet->awcrun;
435  phglyphs = (PHGLYPH)&pGlyphSet->awcrun[cRuns];
436  pwcrun[0].wcLow = pcp[0].code;
437  pwcrun[0].cGlyphs = 1;
438  pwcrun[0].phg = &phglyphs[0];
439  phglyphs[0] = pcp[0].index;
440 
441 DbgPrint("pcp[0].index = 0x%lx\n", pcp[0].index);
442 
443  /* Walk through all supported chars */
444  for (i = 1, j = 0; i < cGlyphs; i++)
445  {
446  /* Use glyph index as HGLYPH */
447  phglyphs[i] = pcp[i].index;
448 
449  /* Check whether we can append the wchar to a run */
450  if (pcp[i].code == pcp[i - 1].code + 1)
451  {
452  /* Append to current WCRUN */
453  pwcrun[j].cGlyphs++;
454  }
455  else
456  {
457  /* Add a new WCRUN */
458  DbgPrint("adding new run\n");
459  j++;
460  pwcrun[j].wcLow = pcp[i].code;
461  pwcrun[j].cGlyphs = 1;
462  pwcrun[j].phg = &phglyphs[i];
463  }
464  }
465 
466  /* Free the temporary buffer */
467  EngFreeMem(pcp);
468 
469  /* Set *pid to the allocated structure for use in FtfdFree */
470  *pid = (ULONG_PTR)pGlyphSet;
471 
472 DbgPrint("pGlyphSet=%p\n", pGlyphSet);
473 __debugbreak();
474 
475  return pGlyphSet;
476 }
int FT_Error
Definition: fttypes.h:300
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
FT_ULong code
Definition: ftfd.h:29
unsigned long FT_ULong
Definition: fttypes.h:253
struct _FD_GLYPHSET FD_GLYPHSET
#define DbgPrint
Definition: loader.c:25
Definition: winddi.h:634
#define EngFreeMem
Definition: polytest.cpp:56
ULONG cRuns
Definition: winddi.h:644
_In_ FONTOBJ _In_ ULONG _In_ ULONG cGlyphs
Definition: winddi.h:3799
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3722
FT_Long num_glyphs
Definition: freetype.h:1076
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
Definition: ftfd.h:32
FT_New_Memory_Face(FT_Library library, const FT_Byte *file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface)
Definition: ftobjs.c:1431
ULONG cjView
Definition: ftfd.h:35
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
WCHAR wcLow
Definition: winddi.h:635
HGLYPH * phg
Definition: winddi.h:637
smooth NULL
Definition: ftsmooth.c:416
HGLYPH * PHGLYPH
Definition: winddi.h:131
GLuint index
Definition: glext.h:6031
struct FTFD_FILE * PFTFD_FILE
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
USHORT cGlyphs
Definition: winddi.h:636
FT_Library gftlibrary
Definition: enable.c:26
_In_ ULONG_PTR _In_ ULONG iFace
Definition: winddi.h:3835
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
PVOID pvView
Definition: ftfd.h:34
#define TAG_GLYPHSET
Definition: bmfd.h:42
struct _WCRUN WCRUN
FT_UInt index
Definition: ftfd.h:28
_In_ ULONG_PTR iFile
Definition: winddi.h:3835
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG cjSize
Definition: winddi.h:3634
ULONG cjThis
Definition: winddi.h:641
#define ULONG_PTR
Definition: config.h:101
ULONG cGlyphsSupported
Definition: winddi.h:643
FLONG flAccel
Definition: winddi.h:642

◆ FtfdUnloadFontFile()

BOOL APIENTRY FtfdUnloadFontFile ( IN ULONG_PTR  iFile)

Definition at line 110 of file font.c.

112 {
113  PFTFD_FILE pfile = (PFTFD_FILE)iFile;
114  ULONG i;
115 
116  DbgPrint("FtfdUnloadFontFile()\n");
117 
118  // HACK!!!
119  EngFreeMem(pfile->pvView);
120 
121  /* Cleanup faces */
122  for (i = 0; i < pfile->cNumFaces; i++)
123  {
124  FT_Done_Face(pfile->aftface[i]);
125  }
126 
127  /* Unmap the font file */
128  EngUnmapFontFileFD(pfile->iFile);
129 
130  /* Free the memory that was allocated for the font */
131  EngFreeMem(pfile);
132 
133  return TRUE;
134 }
#define TRUE
Definition: types.h:120
ULONG_PTR iFile
Definition: ftfd.h:36
#define DbgPrint
Definition: loader.c:25
#define EngFreeMem
Definition: polytest.cpp:56
Definition: ftfd.h:32
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG cNumFaces
Definition: ftfd.h:37
struct FTFD_FILE * PFTFD_FILE
ENGAPI VOID APIENTRY EngUnmapFontFileFD(_In_ ULONG_PTR iFile)
Definition: mapping.c:564
FT_Face aftface[1]
Definition: ftfd.h:38
PVOID pvView
Definition: ftfd.h:34
_In_ ULONG_PTR iFile
Definition: winddi.h:3835
unsigned int ULONG
Definition: retypes.h:1
FT_Done_Face(FT_Face face)
Definition: ftobjs.c:2721

◆ HackFixup()

PVOID HackFixup ( PVOID  pvView,
ULONG  cjView 
)

Definition at line 11 of file font.c.

14 {
15  CHAR *pc;
16 
17  pc = EngAllocMem(0, cjView, 'tmp ');
18  memcpy(pc, pvView, cjView);
19 
20  *pc = 0;
21 
22  return pc;
23 }
char CHAR
Definition: xmlstorage.h:175
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by FtfdLoadFontFile().