ReactOS 0.4.17-dev-806-gffa4164
text.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _STRGDI
 
struct  _LFONT
 

Macros

#define TAG_FINF   'FNIF'
 
#define TO_MEM_ALLOCATED   0x0001
 
#define TO_ALL_PTRS_VALID   0x0002
 
#define TO_VALID   0x0004
 
#define TO_ESC_NOT_ORIENT   0x0008
 
#define TO_PWSZ_ALLOCATED   0x0010
 
#define TSIM_UNDERLINE1   0x0020
 
#define TSIM_UNDERLINE2   0x0040
 
#define TSIM_STRIKEOUT   0x0080
 
#define TO_HIGHRESTEXT   0x0100
 
#define TO_BITMAPS   0x0200
 
#define TO_PARTITION_INIT   0x0400
 
#define TO_ALLOC_FACENAME   0x0800
 
#define TO_SYS_PARTITION   0x1000
 
#define TEXTOBJECT_INIT   0x00010000
 
#define LFONT_AllocFontWithHandle()   ((PLFONT)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ)))
 
#define LFONT_ShareLockFont(hfont)   (PLFONT)GDIOBJ_ReferenceObjectByHandle(hfont, GDIObjType_LFONT_TYPE)
 
#define LFONT_ShareUnlockFont(plfnt)   GDIOBJ_vDereferenceObject((POBJ)plfnt)
 
#define LFONT_UnlockFont(plfnt)   GDIOBJ_vUnlockObject((POBJ)plfnt)
 
#define AFRX_WRITE_REGISTRY   0x1
 
#define AFRX_ALTERNATIVE_PATH   0x2
 
#define AFRX_DOS_DEVICE_PATH   0x4
 
#define IntLockProcessPrivateFonts(W32Process)    ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&W32Process->PrivateFontListLock)
 
#define IntUnLockProcessPrivateFonts(W32Process)    ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&W32Process->PrivateFontListLock)
 

Typedefs

typedef struct _STRGDI STRGDI
 
typedef struct _STRGDIPSTRGDI
 
typedef struct _LFONT TEXTOBJ
 
typedef struct _LFONTPTEXTOBJ
 
typedef struct _LFONT LFONT
 
typedef struct _LFONTPLFONT
 

Functions

FORCEINLINE PTEXTOBJ TEXTOBJ_LockText (HFONT hfont)
 
FORCEINLINE VOID TEXTOBJ_UnlockText (PLFONT plfnt)
 
PTEXTOBJ FASTCALL RealizeFontInit (HFONT)
 
NTSTATUS FASTCALL TextIntRealizeFont (HFONT, PTEXTOBJ)
 
NTSTATUS FASTCALL TextIntCreateFontIndirect (CONST LPLOGFONTW lf, HFONT *NewFont)
 
BYTE FASTCALL IntCharSetFromCodePage (UINT uCodePage)
 
BOOL FASTCALL InitFontSupport (VOID)
 
VOID FASTCALL FreeFontSupport (VOID)
 
BOOL FASTCALL IntIsFontRenderingEnabled (VOID)
 
VOID FASTCALL IntEnableFontRendering (BOOL Enable)
 
ULONG FASTCALL FontGetObject (PTEXTOBJ TextObj, ULONG Count, PVOID Buffer)
 
VOID FASTCALL IntLoadSystemFonts (VOID)
 
BOOL FASTCALL IntLoadFontsInRegistry (VOID)
 
VOID FASTCALL IntGdiCleanupPrivateFontsForProcess (VOID)
 
INT FASTCALL IntGdiAddFontResourceEx (_In_ PCUNICODE_STRING FileName, _In_ DWORD cFiles, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
 
BOOL FASTCALL IntGdiRemoveFontResource (_In_ PCUNICODE_STRING FileName, _In_ DWORD cFiles, _In_ DWORD dwFlags)
 
HANDLE FASTCALL IntGdiAddFontMemResource (PVOID Buffer, DWORD dwSize, PDWORD pNumAdded)
 
BOOL FASTCALL IntGdiRemoveFontMemResource (HANDLE hMMFont)
 
ULONG FASTCALL ftGdiGetGlyphOutline (PDC, WCHAR, UINT, LPGLYPHMETRICS, ULONG, PVOID, const MAT2 *, BOOL)
 
INT FASTCALL IntGetOutlineTextMetrics (PFONTGDI, UINT, OUTLINETEXTMETRICW *, BOOL)
 
BOOL FASTCALL TextIntUpdateSize (_In_ PTEXTOBJ TextObj, _In_ PFONTGDI FontGDI, _In_ BOOL bDoLock)
 
BOOL FASTCALL ftGdiGetRasterizerCaps (LPRASTERIZER_STATUS)
 
BOOL FASTCALL TextIntGetTextExtentPoint (PDC, PTEXTOBJ, PCWCH, INT, ULONG, PINT, PINT, PSIZE, FLONG)
 
BOOL FASTCALL ftGdiGetTextMetricsW (HDC, PTMW_INTERNAL)
 
DWORD FASTCALL IntGetFontLanguageInfo (PDC)
 
INT FASTCALL ftGdiGetTextCharsetInfo (PDC, PFONTSIGNATURE, DWORD)
 
DWORD FASTCALL ftGetFontUnicodeRanges (PFONTGDI, PGLYPHSET)
 
DWORD FASTCALL ftGdiGetFontData (PFONTGDI, DWORD, DWORD, PVOID, DWORD)
 
BOOL FASTCALL IntGdiGetFontResourceInfo (PUNICODE_STRING, PVOID, DWORD *, DWORD)
 
BOOL FASTCALL ftGdiRealizationInfo (PFONTGDI, PREALIZATION_INFO)
 
DWORD FASTCALL ftGdiGetKerningPairs (PFONTGDI, DWORD, LPKERNINGPAIR)
 
BOOL APIENTRY GreExtTextOutW (_In_ HDC hDC, _In_ INT XStart, _In_ INT YStart, _In_ UINT fuOptions, _In_opt_ PRECTL lprc, _In_reads_opt_(Count) PCWCH String, _In_ INT Count, _In_opt_ const INT *Dx, _In_ DWORD dwCodePage)
 
DWORD FASTCALL IntGetCharDimensions (HDC, PTEXTMETRICW, PDWORD)
 
BOOL FASTCALL GreGetTextExtentW (HDC, PCWCH, INT, PSIZE, UINT)
 
BOOL FASTCALL GreGetTextExtentExW (HDC, PCWCH, ULONG, ULONG, PULONG, PULONG, PSIZE, FLONG)
 
BOOL FASTCALL GreTextOutW (HDC, INT, INT, PCWCH, INT)
 
HFONT FASTCALL GreCreateFontIndirectW (_In_ const LOGFONTW *lplf)
 
BOOL WINAPI GreGetTextMetricsW (_In_ HDC hdc, _Out_ LPTEXTMETRICW lptm)
 
BOOL APIENTRY GreGetCharWidthW (_In_ HDC hDC, _In_ UINT FirstChar, _In_ UINT Count, _In_reads_opt_(Count) PCWCH Safepwc, _In_ FLONG fl, _Out_writes_bytes_(Count *sizeof(INT)) PVOID pTmpBuffer)
 
BOOL APIENTRY GreGetCharABCWidthsW (_In_ HDC hDC, _In_ UINT FirstChar, _In_ UINT Count, _In_reads_opt_(Count) PCWCH Safepwch, _In_ FLONG fl, _Out_writes_bytes_(Count *sizeof(ABC)) PVOID SafeBuffer)
 
DWORD APIENTRY GreGetGlyphIndicesW (_In_ HDC hdc, _In_reads_opt_(cwc) PCWCH pwc, _In_ INT cwc, _Out_writes_opt_(cwc) PWORD pgi, _In_ DWORD iMode, _In_ BOOL bSubset)
 

Macro Definition Documentation

◆ AFRX_ALTERNATIVE_PATH

#define AFRX_ALTERNATIVE_PATH   0x2

Definition at line 105 of file text.h.

◆ AFRX_DOS_DEVICE_PATH

#define AFRX_DOS_DEVICE_PATH   0x4

Definition at line 106 of file text.h.

◆ AFRX_WRITE_REGISTRY

#define AFRX_WRITE_REGISTRY   0x1

Definition at line 104 of file text.h.

◆ IntLockProcessPrivateFonts

#define IntLockProcessPrivateFonts (   W32Process)     ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&W32Process->PrivateFontListLock)

Definition at line 171 of file text.h.

◆ IntUnLockProcessPrivateFonts

#define IntUnLockProcessPrivateFonts (   W32Process)     ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&W32Process->PrivateFontListLock)

Definition at line 174 of file text.h.

◆ LFONT_AllocFontWithHandle

#define LFONT_AllocFontWithHandle ( )    ((PLFONT)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ)))

Definition at line 76 of file text.h.

◆ LFONT_ShareLockFont

Definition at line 77 of file text.h.

◆ LFONT_ShareUnlockFont

#define LFONT_ShareUnlockFont (   plfnt)    GDIOBJ_vDereferenceObject((POBJ)plfnt)

Definition at line 78 of file text.h.

◆ LFONT_UnlockFont

#define LFONT_UnlockFont (   plfnt)    GDIOBJ_vUnlockObject((POBJ)plfnt)

Definition at line 79 of file text.h.

◆ TAG_FINF

#define TAG_FINF   'FNIF'

Definition at line 3 of file text.h.

◆ TEXTOBJECT_INIT

#define TEXTOBJECT_INIT   0x00010000

Definition at line 56 of file text.h.

◆ TO_ALL_PTRS_VALID

#define TO_ALL_PTRS_VALID   0x0002

Definition at line 8 of file text.h.

◆ TO_ALLOC_FACENAME

#define TO_ALLOC_FACENAME   0x0800

Definition at line 18 of file text.h.

◆ TO_BITMAPS

#define TO_BITMAPS   0x0200

Definition at line 16 of file text.h.

◆ TO_ESC_NOT_ORIENT

#define TO_ESC_NOT_ORIENT   0x0008

Definition at line 10 of file text.h.

◆ TO_HIGHRESTEXT

#define TO_HIGHRESTEXT   0x0100

Definition at line 15 of file text.h.

◆ TO_MEM_ALLOCATED

#define TO_MEM_ALLOCATED   0x0001

Definition at line 7 of file text.h.

◆ TO_PARTITION_INIT

#define TO_PARTITION_INIT   0x0400

Definition at line 17 of file text.h.

◆ TO_PWSZ_ALLOCATED

#define TO_PWSZ_ALLOCATED   0x0010

Definition at line 11 of file text.h.

◆ TO_SYS_PARTITION

#define TO_SYS_PARTITION   0x1000

Definition at line 19 of file text.h.

◆ TO_VALID

#define TO_VALID   0x0004

Definition at line 9 of file text.h.

◆ TSIM_STRIKEOUT

#define TSIM_STRIKEOUT   0x0080

Definition at line 14 of file text.h.

◆ TSIM_UNDERLINE1

#define TSIM_UNDERLINE1   0x0020

Definition at line 12 of file text.h.

◆ TSIM_UNDERLINE2

#define TSIM_UNDERLINE2   0x0040

Definition at line 13 of file text.h.

Typedef Documentation

◆ LFONT

typedef struct _LFONT LFONT

◆ PLFONT

typedef struct _LFONT * PLFONT

◆ PSTRGDI

typedef struct _STRGDI * PSTRGDI

◆ PTEXTOBJ

typedef struct _LFONT * PTEXTOBJ

◆ STRGDI

◆ TEXTOBJ

Function Documentation

◆ FontGetObject()

ULONG FASTCALL FontGetObject ( PTEXTOBJ  TextObj,
ULONG  Count,
PVOID  Buffer 
)

◆ FreeFontSupport()

VOID FASTCALL FreeFontSupport ( VOID  )

Definition at line 991 of file freetype.c.

992{
993 PLIST_ENTRY pHead, pEntry;
994 PFONT_CACHE_ENTRY pFontCache;
995 PFONTSUBST_ENTRY pSubstEntry;
996 PFONT_ENTRY pFontEntry;
997
998 // Free font cache list
999 pHead = &g_FontCacheListHead;
1000 while (!IsListEmpty(pHead))
1001 {
1002 pEntry = RemoveHeadList(pHead);
1003 pFontCache = CONTAINING_RECORD(pEntry, FONT_CACHE_ENTRY, ListEntry);
1004 RemoveCachedEntry(pFontCache);
1005 }
1006
1007 // Free font subst list
1008 pHead = &g_FontSubstListHead;
1009 while (!IsListEmpty(pHead))
1010 {
1011 pEntry = RemoveHeadList(pHead);
1012 pSubstEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
1013 ExFreePoolWithTag(pSubstEntry, TAG_FONT);
1014 }
1015
1016 // Free font list
1017 pHead = &g_FontListHead;
1018 while (!IsListEmpty(pHead))
1019 {
1020 pEntry = RemoveHeadList(pHead);
1021 pFontEntry = CONTAINING_RECORD(pEntry, FONT_ENTRY, ListEntry);
1022 CleanupFontEntry(pFontEntry);
1023 }
1024
1026
1028 {
1031 }
1032
1035}
#define NULL
Definition: types.h:112
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
static PFAST_MUTEX g_FreeTypeLock
Definition: freetype.c:214
FT_Library g_FreeTypeLibrary
Definition: freetype.c:206
static void FontLink_DeleteEntries(VOID)
Definition: freetype.c:896
static __inline VOID FASTCALL CleanupFontEntry(PFONT_ENTRY FontEntry)
Definition: freetype.c:573
static void RemoveCachedEntry(PFONT_CACHE_ENTRY Entry)
Definition: freetype.c:462
FT_Done_Library(FT_Library library)
Definition: ftobjs.c:5353
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
Definition: font.h:77
Definition: font.h:56
Definition: font.h:5
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define TAG_INTERNAL_SYNC
Definition: tags.h:18
#define TAG_FONT
Definition: tags.h:12

Referenced by _Function_class_().

◆ ftGdiGetFontData()

DWORD FASTCALL ftGdiGetFontData ( PFONTGDI  FontGdi,
DWORD  Table,
DWORD  Offset,
PVOID  Buffer,
DWORD  Size 
)

Definition at line 5373 of file freetype.c.

5379{
5381 FT_Face Face = FontGdi->SharedFace->Face;
5382
5384
5385 if (FT_IS_SFNT(Face))
5386 {
5387 if (Table)
5388 Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
5389 (Table << 8 & 0xFF0000);
5390
5391 if (!Buffer) Size = 0;
5392
5393 if (Buffer && Size)
5394 {
5396 FT_ULong Needed = 0;
5397
5398 Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
5399
5400 if ( !Error && Needed < Size) Size = Needed;
5401 }
5402 if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
5403 Result = Size;
5404 }
5405
5407
5408 return Result;
5409}
BOOL Error
Definition: chkdsk.c:66
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IntUnLockFreeType()
Definition: freetype.c:231
#define IntLockFreeType()
Definition: freetype.c:225
#define FT_IS_SFNT(face)
Definition: freetype.h:1290
unsigned long FT_ULong
Definition: fttypes.h:253
int FT_Error
Definition: fttypes.h:299
ASMGENDATA Table[]
Definition: genincdata.c:61
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PSHARED_FACE SharedFace
Definition: engobjects.h:145
FT_Face Face
Definition: engobjects.h:132
FT_Load_Sfnt_Table(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte *buffer, FT_ULong *length)
Definition: ftobjs.c:4197
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
#define GDI_ERROR
Definition: wingdi.h:1309
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by NtGdiGetFontData().

◆ ftGdiGetGlyphOutline()

ULONG FASTCALL ftGdiGetGlyphOutline ( PDC  dc,
WCHAR  wch,
UINT  iFormat,
LPGLYPHMETRICS  pgm,
ULONG  cjBuf,
PVOID  pvBuf,
const MAT2 pmat2,
BOOL  bIgnoreRotation 
)

Definition at line 4434 of file freetype.c.

4443{
4444 PDC_ATTR pdcattr;
4445 PTEXTOBJ TextObj;
4446 PFONTGDI FontGDI;
4447 HFONT hFont = 0;
4448 GLYPHMETRICS gm;
4449 ULONG Size;
4450 FT_Face ft_face;
4451 FT_UInt glyph_index;
4452 DWORD width, height, pitch, needed = 0;
4453 FT_Bitmap ft_bitmap;
4455 INT left, right, top = 0, bottom = 0;
4457 FLOATOBJ eM11, widthRatio, eTemp;
4458 FT_Matrix mat, transMat = identityMat;
4459 BOOL needsTransform = FALSE;
4460 INT orientation;
4461 LONG aveWidth;
4462 INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
4463 OUTLINETEXTMETRICW *potm;
4464 XFORMOBJ xo;
4465 XFORML xform;
4466 LOGFONTW *plf;
4467
4468 DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
4469 cjBuf, pvBuf, pmat2);
4470
4471 pdcattr = dc->pdcattr;
4472
4473 XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
4474 XFORMOBJ_iGetXform(&xo, &xform);
4475 FLOATOBJ_SetFloat(&eM11, xform.eM11);
4476
4477 hFont = pdcattr->hlfntNew;
4478 TextObj = RealizeFontInit(hFont);
4479
4480 if (!TextObj)
4481 {
4483 return GDI_ERROR;
4484 }
4485 FontGDI = ObjToGDI(TextObj->Font, FONT);
4486 ft_face = FontGDI->SharedFace->Face;
4487
4488 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4489 aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
4490 orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
4491
4493 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL, FALSE);
4494 if (!Size)
4495 {
4496 TEXTOBJ_UnlockText(TextObj);
4498 return GDI_ERROR;
4499 }
4501 if (!potm)
4502 {
4503 TEXTOBJ_UnlockText(TextObj);
4505 return GDI_ERROR;
4506 }
4508 Size = IntGetOutlineTextMetrics(FontGDI, Size, potm, FALSE);
4509 if (!Size)
4510 {
4512 TEXTOBJ_UnlockText(TextObj);
4514 return GDI_ERROR;
4515 }
4516
4518 if (!TextIntUpdateSize(TextObj, FontGDI, FALSE))
4519 {
4522 TEXTOBJ_UnlockText(TextObj);
4524 return GDI_ERROR;
4525 }
4527 FT_Set_Transform(ft_face, &mat, NULL);
4528
4529 TEXTOBJ_UnlockText(TextObj);
4530
4531 glyph_index = get_glyph_index_flagged(ft_face, wch, (iFormat & GGO_GLYPH_INDEX));
4532 iFormat &= ~GGO_GLYPH_INDEX;
4533
4534 if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
4535 load_flags |= FT_LOAD_NO_BITMAP;
4536
4537 if (iFormat & GGO_UNHINTED)
4538 {
4539 load_flags |= FT_LOAD_NO_HINTING;
4540 iFormat &= ~GGO_UNHINTED;
4541 }
4542
4543 error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
4545
4546 if (error)
4547 {
4548 DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
4550 return GDI_ERROR;
4551 }
4552
4553 FLOATOBJ_Set1(&widthRatio);
4554 if (aveWidth && potm)
4555 {
4556 // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
4557 FLOATOBJ_SetLong(&widthRatio, aveWidth);
4558 FLOATOBJ_Mul(&widthRatio, &eM11);
4560 }
4561
4562 //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
4563 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
4564 FLOATOBJ_Mul(&eTemp, &widthRatio);
4565 left = FLOATOBJ_GetLong(&eTemp) & -64;
4566
4567 //right = (INT)((ft_face->glyph->metrics.horiBearingX +
4568 // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
4569 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
4570 FLOATOBJ_Mul(&eTemp, &widthRatio);
4571 FLOATOBJ_AddLong(&eTemp, 63);
4572 right = FLOATOBJ_GetLong(&eTemp) & -64;
4573
4574 //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
4575 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
4576 FLOATOBJ_Mul(&eTemp, &widthRatio);
4577 FLOATOBJ_AddLong(&eTemp, 63);
4578 adv = FLOATOBJ_GetLong(&eTemp) >> 6;
4579
4580 lsb = left >> 6;
4581 bbx = (right - left) >> 6;
4582
4583 DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
4584
4586
4587 /* Width scaling transform */
4588 if (!FLOATOBJ_Equal1(&widthRatio))
4589 {
4590 FT_Matrix scaleMat;
4591
4592 eTemp = widthRatio;
4593 FLOATOBJ_MulLong(&eTemp, 1 << 16);
4594
4595 scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
4596 scaleMat.xy = 0;
4597 scaleMat.yx = 0;
4598 scaleMat.yy = INT_TO_FIXED(1);
4599 FT_Matrix_Multiply(&scaleMat, &transMat);
4600 needsTransform = TRUE;
4601 }
4602
4603 /* World transform */
4604 {
4605 FT_Matrix ftmatrix;
4607
4608 /* Create a freetype matrix, by converting to 16.16 fixpoint format */
4609 IntMatrixFromMx(&ftmatrix, pmx);
4610
4611 if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
4612 {
4613 FT_Matrix_Multiply(&ftmatrix, &transMat);
4614 needsTransform = TRUE;
4615 }
4616 }
4617
4618 /* Rotation transform */
4619 if (orientation)
4620 {
4621 FT_Matrix rotationMat;
4622 DPRINT("Rotation Trans!\n");
4623 IntEscapeMatrix(&rotationMat, orientation);
4624 FT_Matrix_Multiply(&rotationMat, &transMat);
4625 needsTransform = TRUE;
4626 }
4627
4628 /* Extra transformation specified by caller */
4629 if (pmat2)
4630 {
4631 FT_Matrix extraMat;
4632 DPRINT("MAT2 Matrix Trans!\n");
4633 extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
4634 extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
4635 extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
4636 extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
4637 FT_Matrix_Multiply(&extraMat, &transMat);
4638 needsTransform = TRUE;
4639 }
4640
4641 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
4642
4643 if (!needsTransform)
4644 {
4645 DPRINT("No Need to be Transformed!\n");
4646 top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
4647 bottom = (ft_face->glyph->metrics.horiBearingY -
4648 ft_face->glyph->metrics.height) & -64;
4649 gm.gmCellIncX = adv;
4650 gm.gmCellIncY = 0;
4651 }
4652 else
4653 {
4654 INT xc, yc;
4655 FT_Vector vec;
4656 for (xc = 0; xc < 2; xc++)
4657 {
4658 for (yc = 0; yc < 2; yc++)
4659 {
4660 vec.x = (ft_face->glyph->metrics.horiBearingX +
4661 xc * ft_face->glyph->metrics.width);
4662 vec.y = ft_face->glyph->metrics.horiBearingY -
4663 yc * ft_face->glyph->metrics.height;
4664 DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
4665 FT_Vector_Transform(&vec, &transMat);
4666 if (xc == 0 && yc == 0)
4667 {
4668 left = right = vec.x;
4669 top = bottom = vec.y;
4670 }
4671 else
4672 {
4673 if (vec.x < left) left = vec.x;
4674 else if (vec.x > right) right = vec.x;
4675 if (vec.y < bottom) bottom = vec.y;
4676 else if (vec.y > top) top = vec.y;
4677 }
4678 }
4679 }
4680 left = left & -64;
4681 right = (right + 63) & -64;
4682 bottom = bottom & -64;
4683 top = (top + 63) & -64;
4684
4685 DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
4686 vec.x = ft_face->glyph->metrics.horiAdvance;
4687 vec.y = 0;
4688 FT_Vector_Transform(&vec, &transMat);
4689 gm.gmCellIncX = (vec.x+63) >> 6;
4690 gm.gmCellIncY = -((vec.y+63) >> 6);
4691 }
4692 gm.gmBlackBoxX = (right - left) >> 6;
4693 gm.gmBlackBoxY = (top - bottom) >> 6;
4694 gm.gmptGlyphOrigin.x = left >> 6;
4695 gm.gmptGlyphOrigin.y = top >> 6;
4696
4697 DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
4698 gm.gmCellIncX, gm.gmCellIncY,
4699 gm.gmBlackBoxX, gm.gmBlackBoxY,
4701
4703
4704 if (iFormat == GGO_METRICS)
4705 {
4706 DPRINT("GGO_METRICS Exit!\n");
4707 *pgm = gm;
4708 return 1; /* FIXME */
4709 }
4710
4711 if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
4712 {
4713 DPRINT1("Loaded a bitmap\n");
4714 return GDI_ERROR;
4715 }
4716
4717 switch (iFormat)
4718 {
4719 case GGO_BITMAP:
4720 {
4721 width = gm.gmBlackBoxX;
4722 height = gm.gmBlackBoxY;
4723 pitch = ((width + 31) >> 5) << 2;
4724 needed = pitch * height;
4725
4726 if (!pvBuf || !cjBuf) break;
4727 if (!needed) return GDI_ERROR; /* empty glyph */
4728 if (needed > cjBuf)
4729 return GDI_ERROR;
4730
4731 switch (ft_face->glyph->format)
4732 {
4734 {
4735 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4736 INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4737 INT h = min( height, ft_face->glyph->bitmap.rows );
4738 while (h--)
4739 {
4741 src += ft_face->glyph->bitmap.pitch;
4742 dst += pitch;
4743 }
4744 break;
4745 }
4746
4748 {
4749 ft_bitmap.width = width;
4750 ft_bitmap.rows = height;
4751 ft_bitmap.pitch = pitch;
4752 ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4753 ft_bitmap.buffer = pvBuf;
4754
4756 if (needsTransform)
4757 {
4758 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4759 }
4760 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4761 /* Note: FreeType will only set 'black' bits for us. */
4762 RtlZeroMemory(pvBuf, needed);
4763 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4765 break;
4766 }
4767
4768 default:
4769 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4770 return GDI_ERROR;
4771 }
4772
4773 break;
4774 }
4775
4776 case GGO_GRAY2_BITMAP:
4777 case GGO_GRAY4_BITMAP:
4778 case GGO_GRAY8_BITMAP:
4779 {
4780 unsigned int mult, row, col;
4781 BYTE *start, *ptr;
4782
4783 width = gm.gmBlackBoxX;
4784 height = gm.gmBlackBoxY;
4785 pitch = (width + 3) / 4 * 4;
4786 needed = pitch * height;
4787
4788 if (!pvBuf || !cjBuf) break;
4789 if (!needed) return GDI_ERROR; /* empty glyph */
4790 if (needed > cjBuf)
4791 return GDI_ERROR;
4792
4793 switch (ft_face->glyph->format)
4794 {
4796 {
4797 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4798 INT h = min( height, ft_face->glyph->bitmap.rows );
4799 INT x;
4800 while (h--)
4801 {
4802 for (x = 0; (UINT)x < pitch; x++)
4803 {
4804 if (x < ft_face->glyph->bitmap.width)
4805 dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4806 else
4807 dst[x] = 0;
4808 }
4809 src += ft_face->glyph->bitmap.pitch;
4810 dst += pitch;
4811 }
4812 break;
4813 }
4815 {
4816 ft_bitmap.width = width;
4817 ft_bitmap.rows = height;
4818 ft_bitmap.pitch = pitch;
4819 ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4820 ft_bitmap.buffer = pvBuf;
4821
4823 if (needsTransform)
4824 {
4825 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4826 }
4827 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4828 RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4829 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4831
4833 mult = 4;
4834 else if (iFormat == GGO_GRAY4_BITMAP)
4835 mult = 16;
4836 else if (iFormat == GGO_GRAY8_BITMAP)
4837 mult = 64;
4838 else
4839 {
4840 return GDI_ERROR;
4841 }
4842
4843 start = pvBuf;
4844 for (row = 0; row < height; row++)
4845 {
4846 ptr = start;
4847 for (col = 0; col < width; col++, ptr++)
4848 {
4849 *ptr = (((int)*ptr) * mult + 128) / 256;
4850 }
4851 start += pitch;
4852 }
4853
4854 break;
4855 }
4856 default:
4857 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4858 return GDI_ERROR;
4859 }
4860
4861 break;
4862 }
4863
4864 case GGO_NATIVE:
4865 {
4866 FT_Outline *outline = &ft_face->glyph->outline;
4867
4868 if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4869
4871 if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4872
4874
4875 if (!pvBuf || !cjBuf)
4876 {
4878 break;
4879 }
4880 if (needed > cjBuf)
4881 {
4883 return GDI_ERROR;
4884 }
4887 break;
4888 }
4889
4890 case GGO_BEZIER:
4891 {
4892 FT_Outline *outline = &ft_face->glyph->outline;
4893 if (cjBuf == 0) pvBuf = NULL;
4894
4895 if (needsTransform && pvBuf)
4896 {
4898 FT_Outline_Transform(outline, &transMat);
4900 }
4902
4903 if (!pvBuf || !cjBuf)
4904 break;
4905 if (needed > cjBuf)
4906 return GDI_ERROR;
4907
4909 break;
4910 }
4911
4912 default:
4913 DPRINT1("Unsupported format %u\n", iFormat);
4914 return GDI_ERROR;
4915 }
4916
4917 DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4918
4919 if (gm.gmBlackBoxX == 0)
4920 gm.gmBlackBoxX = 1;
4921 if (gm.gmBlackBoxY == 0)
4922 gm.gmBlackBoxY = 1;
4923
4924 *pgm = gm;
4925 return needed;
4926}
#define DPRINT1
Definition: precomp.h:8
HFONT hFont
Definition: main.c:53
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:135
HDC dc
Definition: cylfrac.c:34
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:184
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FLOATOBJ_Set1(fo)
Definition: floatobj.h:119
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:105
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, BOOL fCodeAsIndex)
Definition: freetype.c:4317
#define ASSERT_FREETYPE_LOCK_NOT_HELD()
Definition: freetype.c:222
static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3956
BOOL FASTCALL TextIntUpdateSize(_In_ PTEXTOBJ TextObj, _In_ PFONTGDI FontGDI, _In_ BOOL bDoLock)
Definition: freetype.c:4261
static unsigned int get_native_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3883
static VOID FASTCALL IntMatrixFromMx(FT_Matrix *pmat, const MATRIX *pmx)
Definition: freetype.c:1050
static VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
Definition: freetype.c:1037
static const FT_Matrix identityMat
Definition: freetype.c:201
static __inline FT_Fixed FT_FixedFromFIXED(FIXED f)
Definition: freetype.c:592
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm, BOOL bLocked)
Definition: freetype.c:3140
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:796
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3025
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:689
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3023
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1271
#define FT_LOAD_DEFAULT
Definition: freetype.h:3021
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
Definition: freetype.h:3030
FT_Vector_Transform(FT_Vector *vector, const FT_Matrix *matrix)
Definition: ftoutln.c:683
FT_Vector * vec
Definition: ftbbox.c:469
#define INT_TO_FIXED(x)
Definition: ftcalc.h:448
FT_Matrix_Multiply(const FT_Matrix *a, FT_Matrix *b)
Definition: ftcalc.c:660
#define ft_glyph_format_bitmap
Definition: ftimage.h:759
@ FT_PIXEL_MODE_MONO
Definition: ftimage.h:183
@ FT_PIXEL_MODE_GRAY
Definition: ftimage.h:184
#define ft_glyph_format_outline
Definition: ftimage.h:760
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:507
FT_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap *abitmap)
Definition: ftoutln.c:656
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:706
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
GLuint start
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint bottom
Definition: glext.h:7726
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
unsigned int UINT
Definition: sysinfo.c:13
#define error(str)
Definition: mkdosfs.c:1605
static PVOID ptr
Definition: dispmode.c:27
static const MAT2 mat
Definition: font.c:51
#define min(a, b)
Definition: monoChain.cc:55
long LONG
Definition: pedump.c:60
#define DPRINT
Definition: sndvol32.h:73
unsigned int width
Definition: ftimage.h:263
unsigned char * buffer
Definition: ftimage.h:265
unsigned char pixel_mode
Definition: ftimage.h:267
unsigned int rows
Definition: ftimage.h:262
int pitch
Definition: ftimage.h:264
FT_GlyphSlot glyph
Definition: freetype.h:1065
FT_Bitmap bitmap
Definition: freetype.h:1886
FT_Outline outline
Definition: freetype.h:1890
FT_Glyph_Metrics metrics
Definition: freetype.h:1879
FT_Glyph_Format format
Definition: freetype.h:1884
FT_Fixed xx
Definition: fttypes.h:392
FT_Fixed yx
Definition: fttypes.h:393
FT_Fixed yy
Definition: fttypes.h:393
FT_Fixed xy
Definition: fttypes.h:392
FT_Pos x
Definition: ftimage.h:77
FT_Pos y
Definition: ftimage.h:78
LONG lfOrientation
Definition: dimm.idl:62
LONG lfWidth
Definition: dimm.idl:60
HANDLE hlfntNew
Definition: ntgdihdl.h:330
short gmCellIncX
Definition: wingdi.h:2891
UINT gmBlackBoxY
Definition: wingdi.h:2889
UINT gmBlackBoxX
Definition: wingdi.h:2888
short gmCellIncY
Definition: wingdi.h:2892
POINT gmptGlyphOrigin
Definition: wingdi.h:2890
Definition: text.h:60
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
FONTOBJ * Font
Definition: text.h:66
FIXED eM22
Definition: wingdi.h:2922
FIXED eM21
Definition: wingdi.h:2921
FIXED eM11
Definition: wingdi.h:2919
FIXED eM12
Definition: wingdi.h:2920
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2960
FLOATL eM11
Definition: winddi.h:1234
Definition: mesh.c:5330
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:3225
LOGFONTW elfLogFont
Definition: wingdi.h:3148
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG tmAveCharWidth
Definition: wingdi.h:2834
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
PTEXTOBJ FASTCALL RealizeFontInit(_In_ HFONT hFont)
Definition: font.c:433
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define GDITAG_TEXT
Definition: tags.h:172
#define FLOATOBJ_DivLong(pf, l)
Definition: winddi.h:2829
_In_ DWORD cjBuf
Definition: winddi.h:3827
FLOAT FLOATOBJ
Definition: winddi.h:677
#define FLOATOBJ_Mul(pf, pf1)
Definition: winddi.h:2824
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
#define FLOATOBJ_GetLong(pf)
Definition: winddi.h:2817
#define FLOATOBJ_SetFloat(pf, f)
Definition: winddi.h:2814
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:21
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3468
#define FLOATOBJ_AddLong(pf, l)
Definition: winddi.h:2820
#define ERROR_GEN_FAILURE
Definition: winerror.h:256
#define GGO_GRAY2_BITMAP
Definition: wingdi.h:852
#define GGO_GLYPH_INDEX
Definition: wingdi.h:855
#define GGO_UNHINTED
Definition: wingdi.h:856
#define GGO_GRAY8_BITMAP
Definition: wingdi.h:854
#define GGO_BITMAP
Definition: wingdi.h:849
#define GGO_GRAY4_BITMAP
Definition: wingdi.h:853
#define GGO_NATIVE
Definition: wingdi.h:850
#define GGO_METRICS
Definition: wingdi.h:848
#define GGO_BEZIER
Definition: wingdi.h:851
#define XFORMOBJ_vInit
Definition: xformobj.h:12
#define XFORMOBJ_iGetXform
Definition: xformobj.h:9
unsigned char BYTE
Definition: xxhash.c:193

Referenced by NtGdiGetGlyphOutline(), and PATH_ExtTextOut().

◆ ftGdiGetKerningPairs()

DWORD FASTCALL ftGdiGetKerningPairs ( PFONTGDI  Font,
DWORD  cPairs,
LPKERNINGPAIR  pKerningPair 
)

Definition at line 6391 of file freetype.c.

6394{
6395 DWORD Count = 0;
6396 INT i = 0;
6397 FT_Face face = Font->SharedFace->Face;
6398
6399 if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
6400 {
6401 FT_UInt previous_index = 0, glyph_index = 0;
6402 FT_ULong char_code, char_previous;
6403 FT_Vector delta;
6404
6405 char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
6406
6408
6409 while (glyph_index)
6410 {
6411 if (previous_index && glyph_index)
6412 {
6413 FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
6414
6415 if (pKerningPair && cPairs)
6416 {
6417 pKerningPair[i].wFirst = char_previous;
6418 pKerningPair[i].wSecond = char_code;
6419 pKerningPair[i].iKernAmount = delta.x;
6420 i++;
6421 if (i == cPairs) break;
6422 }
6423 Count++;
6424 }
6425 previous_index = glyph_index;
6426 char_previous = char_code;
6427 char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
6428 }
6430 }
6431 return Count;
6432}
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3760
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3785
FT_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning)
Definition: ftobjs.c:3411
@ FT_KERNING_DEFAULT
Definition: freetype.h:3406
#define FT_HAS_KERNING(face)
Definition: freetype.h:1256
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
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
int Count
Definition: noreturn.cpp:7
WORD wSecond
Definition: wingdi.h:2911
int iKernAmount
Definition: wingdi.h:2912

Referenced by GreGetKerningPairs(), and NtGdiGetKerningPairs().

◆ ftGdiGetRasterizerCaps()

BOOL FASTCALL ftGdiGetRasterizerCaps ( LPRASTERIZER_STATUS  lprs)

Definition at line 3752 of file freetype.c.

3753{
3754 if ( lprs )
3755 {
3756 lprs->nSize = sizeof(RASTERIZER_STATUS);
3757 lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3758 lprs->nLanguageID = gusLanguageID;
3759 return TRUE;
3760 }
3762 return FALSE;
3763}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
USHORT gusLanguageID
Definition: init.c:12
#define TT_ENABLED
Definition: wingdi.h:889
struct _RASTERIZER_STATUS RASTERIZER_STATUS
#define TT_AVAILABLE
Definition: wingdi.h:888

Referenced by NtGdiGetRasterizerCaps().

◆ ftGdiGetTextCharsetInfo()

INT FASTCALL ftGdiGetTextCharsetInfo ( PDC  Dc,
PFONTSIGNATURE  lpSig,
DWORD  dwFlags 
)

Definition at line 5093 of file freetype.c.

5097{
5098 PDC_ATTR pdcattr;
5099 UINT Ret = DEFAULT_CHARSET;
5100 INT i;
5101 HFONT hFont;
5102 PTEXTOBJ TextObj;
5103 PFONTGDI FontGdi;
5105 TT_OS2 *pOS2;
5106 FT_Face Face;
5107 CHARSETINFO csi;
5108 DWORD cp, fs0;
5109 USHORT usACP, usOEM;
5110
5111 pdcattr = Dc->pdcattr;
5112 hFont = pdcattr->hlfntNew;
5113 TextObj = RealizeFontInit(hFont);
5114
5115 if (!TextObj)
5116 {
5118 return Ret;
5119 }
5120 FontGdi = ObjToGDI(TextObj->Font, FONT);
5121 Face = FontGdi->SharedFace->Face;
5122 TEXTOBJ_UnlockText(TextObj);
5123
5124 memset(&fs, 0, sizeof(FONTSIGNATURE));
5126 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
5127 if (NULL != pOS2)
5128 {
5129 fs.fsCsb[0] = pOS2->ulCodePageRange1;
5130 fs.fsCsb[1] = pOS2->ulCodePageRange2;
5131 fs.fsUsb[0] = pOS2->ulUnicodeRange1;
5132 fs.fsUsb[1] = pOS2->ulUnicodeRange2;
5133 fs.fsUsb[2] = pOS2->ulUnicodeRange3;
5134 fs.fsUsb[3] = pOS2->ulUnicodeRange4;
5135 if (pOS2->version == 0)
5136 {
5137 FT_UInt dummy;
5138
5139 if (FT_Get_First_Char( Face, &dummy ) < 0x100)
5140 fs.fsCsb[0] |= FS_LATIN1;
5141 else
5142 fs.fsCsb[0] |= FS_SYMBOL;
5143 }
5144 }
5145 pOS2 = NULL;
5147 DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
5148 if (fs.fsCsb[0] == 0)
5149 { /* Let's see if we can find any interesting cmaps */
5150 for (i = 0; i < Face->num_charmaps; i++)
5151 {
5152 switch (Face->charmaps[i]->encoding)
5153 {
5154 case FT_ENCODING_UNICODE:
5155 case FT_ENCODING_APPLE_ROMAN:
5156 fs.fsCsb[0] |= FS_LATIN1;
5157 break;
5158 case FT_ENCODING_MS_SYMBOL:
5159 fs.fsCsb[0] |= FS_SYMBOL;
5160 break;
5161 default:
5162 break;
5163 }
5164 }
5165 }
5166 if (lpSig)
5167 {
5168 RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
5169 }
5170
5171 RtlGetDefaultCodePage(&usACP, &usOEM);
5172 cp = usACP;
5173
5175 if (csi.fs.fsCsb[0] & fs.fsCsb[0])
5176 {
5177 DPRINT("Hit 1\n");
5178 Ret = csi.ciCharset;
5179 goto Exit;
5180 }
5181
5182 for (i = 0; i < MAXTCIINDEX; i++)
5183 {
5184 fs0 = 1L << i;
5185 if (fs.fsCsb[0] & fs0)
5186 {
5187 if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
5188 {
5189 // *cp = csi.ciACP;
5190 DPRINT("Hit 2\n");
5191 Ret = csi.ciCharset;
5192 goto Exit;
5193 }
5194 else
5195 DPRINT1("TCI failing on %x\n", fs0);
5196 }
5197 }
5198Exit:
5199 DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
5200 return (MAKELONG(csi.ciACP, csi.ciCharset));
5201}
#define MAXTCIINDEX
Definition: freetype.c:269
static BOOLEAN IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2776
#define fs
Definition: i386-dis.c:444
POINT cp
Definition: magnifier.c:59
NTSYSAPI VOID NTAPI RtlGetDefaultCodePage(_Out_ PUSHORT AnsiCodePage, _Out_ PUSHORT OemCodePage)
unsigned short USHORT
Definition: pedump.c:61
#define memset(x, y, z)
Definition: compat.h:39
static void Exit(void)
Definition: sock.c:1330
FT_Encoding encoding
Definition: freetype.h:820
FT_Int num_charmaps
Definition: freetype.h:1044
FT_CharMap * charmaps
Definition: freetype.h:1045
FT_UShort version
Definition: tttables.h:377
FT_ULong ulUnicodeRange1
Definition: tttables.h:396
FT_ULong ulCodePageRange1
Definition: tttables.h:414
FT_ULong ulUnicodeRange3
Definition: tttables.h:398
FT_ULong ulUnicodeRange2
Definition: tttables.h:397
FT_ULong ulCodePageRange2
Definition: tttables.h:415
FT_ULong ulUnicodeRange4
Definition: tttables.h:399
Definition: ffs.h:70
FONTSIGNATURE fs
Definition: wingdi.h:1994
UINT ciCharset
Definition: wingdi.h:1992
DWORD fsCsb[2]
Definition: wingdi.h:1989
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4176
#define ft_sfnt_os2
Definition: tttables.h:638
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define FS_SYMBOL
Definition: wingdi.h:575
#define FS_LATIN1
Definition: wingdi.h:560
#define TCI_SRCFONTSIG
Definition: wingdi.h:963
#define TCI_SRCCODEPAGE
Definition: wingdi.h:962

Referenced by DC_InitHack(), IntGetFontLanguageInfo(), NtGdiGetCharSet(), and NtGdiGetTextCharsetInfo().

◆ ftGdiGetTextMetricsW()

BOOL FASTCALL ftGdiGetTextMetricsW ( HDC  hDC,
PTMW_INTERNAL  ptmwi 
)

Definition at line 5289 of file freetype.c.

5292{
5293 PDC dc;
5294 PDC_ATTR pdcattr;
5295 PTEXTOBJ TextObj;
5296 TT_OS2 *pOS2;
5297 TT_HoriHeader *pHori;
5300
5301 if (!ptmwi)
5302 {
5304 return FALSE;
5305 }
5306 RtlZeroMemory(ptmwi, sizeof(TMW_INTERNAL));
5307
5308 if (!(dc = DC_LockDc(hDC)))
5309 {
5311 return FALSE;
5312 }
5313 pdcattr = dc->pdcattr;
5314 TextObj = RealizeFontInit(pdcattr->hlfntNew);
5315 if (NULL != TextObj)
5316 {
5317 PFONTGDI FontGDI = ObjToGDI(TextObj->Font, FONT);
5318
5319 // NOTE: GetTextMetrics simply ignores lfEscapement and XFORM.
5321 if (!TextIntUpdateSize(TextObj, FontGDI, FALSE))
5322 {
5324 }
5325 else
5326 {
5327 FT_Face Face = FontGDI->SharedFace->Face;
5329
5331
5332 FT_Set_Transform(Face, NULL, NULL);
5333
5334 Error = FT_Get_WinFNT_Header(Face, &Win);
5335 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
5336 pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
5337
5338 if (!pOS2 && Error)
5339 {
5340 DPRINT1("Can't find OS/2 table - not TT font?\n");
5342 }
5343 if (!pHori && Error)
5344 {
5345 DPRINT1("Can't find HHEA table - not TT font?\n");
5347 }
5348 if (NT_SUCCESS(Status))
5349 {
5350 FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, (Error ? NULL : &Win));
5351 /* FIXME: Fill Diff member */
5352 }
5353 }
5355 TEXTOBJ_UnlockText(TextObj);
5356 }
5357 else
5358 {
5360 }
5361 DC_UnlockDc(dc);
5362
5363 if (!NT_SUCCESS(Status))
5364 {
5366 return FALSE;
5367 }
5368 return TRUE;
5369}
static HDC hDC
Definition: 3dtext.c:33
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static void FASTCALL FillTM(TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT)
Definition: freetype.c:2838
FT_Get_WinFNT_Header(FT_Face face, FT_WinFNT_HeaderRec *aheader)
Definition: ftwinfnt.c:28
Status
Definition: gdiplustypes.h:24
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:559
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: polytest.cpp:41
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
#define ft_sfnt_hhea
Definition: tttables.h:639
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:30

Referenced by GreGetTextMetricsW(), IntGetCharDimensions(), and NtGdiGetTextMetricsW().

◆ ftGdiRealizationInfo()

BOOL FASTCALL ftGdiRealizationInfo ( PFONTGDI  Font,
PREALIZATION_INFO  Info 
)

Definition at line 6372 of file freetype.c.

6373{
6374 if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
6375 Info->iTechnology = RI_TECH_BITMAP;
6376 else
6377 {
6378 if (FT_IS_SCALABLE(Font->SharedFace->Face))
6379 Info->iTechnology = RI_TECH_SCALABLE;
6380 else
6381 Info->iTechnology = RI_TECH_FIXED;
6382 }
6383 Info->iUniq = Font->FontObj.iUniq;
6384 Info->dwUnknown = -1;
6385 return TRUE;
6386}
#define FT_HAS_FIXED_SIZES(face)
Definition: freetype.h:1320
#define RI_TECH_SCALABLE
Definition: ntgdityp.h:273
#define RI_TECH_FIXED
Definition: ntgdityp.h:272
#define RI_TECH_BITMAP
Definition: ntgdityp.h:271
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by NtGdiGetRealizationInfo().

◆ ftGetFontUnicodeRanges()

DWORD FASTCALL ftGetFontUnicodeRanges ( PFONTGDI  Font,
PGLYPHSET  glyphset 
)

Definition at line 5206 of file freetype.c.

5207{
5208 DWORD size = 0;
5209 DWORD num_ranges = 0;
5210 FT_Face face = Font->SharedFace->Face;
5211
5212 if (face->charmap == NULL)
5213 {
5214 DPRINT1("FIXME: No charmap selected! This is a BUG!\n");
5215 return 0;
5216 }
5217
5218 /* Lock FreeType for face lookup */
5220
5221 if (face->charmap->encoding == FT_ENCODING_UNICODE)
5222 {
5223 FT_UInt glyph_code = 0;
5224 FT_ULong char_code, char_code_prev;
5225
5226 char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
5227
5228 DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
5229 face->num_glyphs, glyph_code, char_code);
5230
5231 if (!glyph_code)
5232 goto Quit;
5233
5234 if (glyphset)
5235 {
5236 glyphset->ranges[0].wcLow = (USHORT)char_code;
5237 glyphset->ranges[0].cGlyphs = 0;
5238 glyphset->cGlyphsSupported = 0;
5239 }
5240
5241 num_ranges = 1;
5242 while (glyph_code)
5243 {
5244 if (char_code < char_code_prev)
5245 {
5246 DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
5247 goto Quit;
5248 }
5249 if (char_code - char_code_prev > 1)
5250 {
5251 num_ranges++;
5252 if (glyphset)
5253 {
5254 glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
5255 glyphset->ranges[num_ranges - 1].cGlyphs = 1;
5256 glyphset->cGlyphsSupported++;
5257 }
5258 }
5259 else if (glyphset)
5260 {
5261 glyphset->ranges[num_ranges - 1].cGlyphs++;
5262 glyphset->cGlyphsSupported++;
5263 }
5264 char_code_prev = char_code;
5265 char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
5266 }
5267 }
5268 else
5269 DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
5270
5271 size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
5272 if (glyphset)
5273 {
5274 glyphset->cbThis = size;
5275 glyphset->cRanges = num_ranges;
5276 glyphset->flAccel = 0;
5277 }
5278
5279Quit:
5280 /* Unlock FreeType */
5282
5283 return size;
5284}
GLsizeiptr size
Definition: glext.h:5919

Referenced by NtGdiGetFontUnicodeRanges().

◆ GreCreateFontIndirectW()

HFONT FASTCALL GreCreateFontIndirectW ( _In_ const LOGFONTW lplf)

Internal

Definition at line 30 of file font.c.

31{
32 if (lplf)
33 {
34 ENUMLOGFONTEXDVW Logfont;
35
36 RtlCopyMemory( &Logfont.elfEnumLogfontEx.elfLogFont, lplf, sizeof(LOGFONTW));
38 sizeof(Logfont.elfEnumLogfontEx.elfFullName));
40 sizeof(Logfont.elfEnumLogfontEx.elfStyle));
42 sizeof(Logfont.elfEnumLogfontEx.elfScript));
43
44 Logfont.elfDesignVector.dvNumAxes = 0;
45
46 RtlZeroMemory( &Logfont.elfDesignVector, sizeof(DESIGNVECTOR));
47
48 return HfontCreate(&Logfont, 0, 0, 0, NULL);
49 }
50 else return NULL;
51}
DWORD dvNumAxes
Definition: wingdi.h:3215
DESIGNVECTOR elfDesignVector
Definition: wingdi.h:3226
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:3150
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:3149
WCHAR elfScript[LF_FACESIZE]
Definition: wingdi.h:3151
HFONT APIENTRY HfontCreate(_In_ const ENUMLOGFONTEXDVW *pelfw, _In_ ULONG cjElfw, _In_ LFTYPE lft, _In_ FLONG fl, _In_opt_ PVOID pvCliData)

Referenced by IntPaintDesktop(), MENU_DrawPopupGlyph(), MenuInit(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameMenu(), and UITOOLS95_DrawFrameScroll().

◆ GreExtTextOutW()

BOOL APIENTRY GreExtTextOutW ( _In_ HDC  hDC,
_In_ INT  XStart,
_In_ INT  YStart,
_In_ UINT  fuOptions,
_In_opt_ PRECTL  lprc,
_In_reads_opt_(Count) PCWCH  String,
_In_ INT  Count,
_In_opt_ const INT Dx,
_In_ DWORD  dwCodePage 
)

Definition at line 7215 of file freetype.c.

7225{
7226 BOOL bResult;
7227 DC *dc;
7228
7229 // TODO: Write test-cases to exactly match real Windows in different
7230 // bad parameters (e.g. does Windows check the DC or the RECT first?).
7231 dc = DC_LockDc(hDC);
7232 if (!dc)
7233 {
7235 return FALSE;
7236 }
7237
7238 bResult = IntExtTextOutW( dc,
7239 XStart,
7240 YStart,
7241 fuOptions,
7242 lprc,
7243 String,
7244 Count,
7245 Dx,
7246 dwCodePage );
7247
7248 DC_UnlockDc(dc);
7249
7250 return bResult;
7251}
BOOL APIENTRY IntExtTextOutW(_In_ PDC dc, _In_ INT XStart, _In_ INT YStart, _In_ UINT fuOptions, _In_opt_ PRECTL lprc, _In_reads_opt_(Count) PCWCH String, _In_ INT Count, _In_opt_ const INT *Dx, _In_ DWORD dwCodePage)
Definition: freetype.c:6669
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4620

Referenced by GreTextOutW(), IntPaintDesktop(), and NtGdiExtTextOutW().

◆ GreGetCharABCWidthsW()

BOOL APIENTRY GreGetCharABCWidthsW ( _In_ HDC  hDC,
_In_ UINT  FirstChar,
_In_ UINT  Count,
_In_reads_opt_(Count) PCWCH  Safepwch,
_In_ FLONG  fl,
_Out_writes_bytes_(Count *sizeof(ABC)) PVOID  SafeBuffer 
)

Definition at line 7380 of file freetype.c.

7387{
7388 PABC SafeBuffI;
7389 PABCFLOAT SafeBuffF;
7390 PDC dc;
7391 PDC_ATTR pdcattr;
7392 PTEXTOBJ TextObj;
7393 PFONTGDI FontGDI;
7394 FT_Face face;
7395 UINT i, glyph_index;
7396 HFONT hFont = NULL;
7397
7398 dc = DC_LockDc(hDC);
7399 if (dc == NULL)
7400 {
7402 return FALSE;
7403 }
7404
7405 pdcattr = dc->pdcattr;
7406 hFont = pdcattr->hlfntNew;
7407 TextObj = RealizeFontInit(hFont);
7408
7409 DC_UnlockDc(dc);
7410
7411 if (TextObj == NULL)
7412 {
7414 return FALSE;
7415 }
7416
7417 FontGDI = ObjToGDI(TextObj->Font, FONT);
7418
7419 // NOTE: GetCharABCWidths simply ignores lfEscapement and XFORM.
7421 if (!TextIntUpdateSize(TextObj, FontGDI, FALSE))
7422 {
7424 TEXTOBJ_UnlockText(TextObj);
7426 return FALSE;
7427 }
7428
7429 face = FontGDI->SharedFace->Face;
7431
7432 if (!fl)
7433 SafeBuffF = SafeBuffer;
7434 else
7435 SafeBuffI = SafeBuffer;
7436
7437 for (i = FirstChar; i < FirstChar+Count; i++)
7438 {
7439 int adv, lsb, bbx, left, right;
7440
7441 if (Safepwch)
7442 glyph_index = get_glyph_index_flagged(face, Safepwch[i - FirstChar], (fl & GCABCW_INDICES));
7443 else
7444 glyph_index = get_glyph_index_flagged(face, i, (fl & GCABCW_INDICES));
7445
7446 FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
7447
7448 left = (INT)face->glyph->metrics.horiBearingX & -64;
7449 right = (INT)((face->glyph->metrics.horiBearingX + face->glyph->metrics.width) + 63) & -64;
7450 adv = (face->glyph->advance.x + 32) >> 6;
7451
7452// int test = (INT)(face->glyph->metrics.horiAdvance + 63) >> 6;
7453// DPRINT1("Advance Wine %d and Advance Ros %d\n",test, adv ); /* It's the same! */
7454
7455 lsb = left >> 6;
7456 bbx = (right - left) >> 6;
7457 /*
7458 DPRINT1("lsb %d and bbx %d\n", lsb, bbx );
7459 */
7460 if (!fl)
7461 {
7462 SafeBuffF[i - FirstChar].abcfA = (FLOAT) lsb;
7463 SafeBuffF[i - FirstChar].abcfB = (FLOAT) bbx;
7464 SafeBuffF[i - FirstChar].abcfC = (FLOAT) (adv - lsb - bbx);
7465 }
7466 else
7467 {
7468 SafeBuffI[i - FirstChar].abcA = lsb;
7469 SafeBuffI[i - FirstChar].abcB = bbx;
7470 SafeBuffI[i - FirstChar].abcC = adv - lsb - bbx;
7471 }
7472 }
7473
7475 TEXTOBJ_UnlockText(TextObj);
7476
7477 return TRUE;
7478}
WORD face[3]
Definition: mesh.c:4747
#define FLOAT
Definition: i386-dis.c:525
#define GCABCW_INDICES
Definition: ntgdityp.h:210
#define INT
Definition: polytest.cpp:20
FLOAT abcfA
Definition: wingdi.h:1862
FLOAT abcfC
Definition: wingdi.h:1864
FLOAT abcfB
Definition: wingdi.h:1863
Definition: wingdi.h:1856
int abcA
Definition: wingdi.h:1857
UINT abcB
Definition: wingdi.h:1858
int abcC
Definition: wingdi.h:1859
_In_ FLONG fl
Definition: winddi.h:1279

Referenced by NtGdiGetCharABCWidthsW().

◆ GreGetCharWidthW()

BOOL APIENTRY GreGetCharWidthW ( _In_ HDC  hDC,
_In_ UINT  FirstChar,
_In_ UINT  Count,
_In_reads_opt_(Count) PCWCH  Safepwc,
_In_ FLONG  fl,
_Out_writes_bytes_(Count *sizeof(INT)) PVOID  pTmpBuffer 
)

Definition at line 7484 of file freetype.c.

7491{
7492 PDC dc;
7493 PDC_ATTR pdcattr;
7494 PTEXTOBJ TextObj;
7495 PFONTGDI FontGDI;
7496 FT_Face face;
7497 UINT i, glyph_index;
7498 HFONT hFont = NULL;
7499 PINT SafeBuffI;
7500 PFLOAT SafeBuffF;
7501
7502 dc = DC_LockDc(hDC);
7503 if (dc == NULL)
7504 {
7506 return FALSE;
7507 }
7508
7509 pdcattr = dc->pdcattr;
7510 hFont = pdcattr->hlfntNew;
7511 TextObj = RealizeFontInit(hFont);
7512 DC_UnlockDc(dc);
7513
7514 if (TextObj == NULL)
7515 {
7517 return FALSE;
7518 }
7519
7520 FontGDI = ObjToGDI(TextObj->Font, FONT);
7521
7522 // NOTE: GetCharWidth simply ignores lfEscapement and XFORM.
7524 if (!TextIntUpdateSize(TextObj, FontGDI, FALSE))
7525 {
7527 TEXTOBJ_UnlockText(TextObj);
7529 return FALSE;
7530 }
7531
7532 face = FontGDI->SharedFace->Face;
7534
7535 if (!fl)
7536 SafeBuffF = (PFLOAT)Buffer;
7537 else
7538 SafeBuffI = (PINT)Buffer;
7539
7540 for (i = FirstChar; i < FirstChar+Count; i++)
7541 {
7542 if (Safepwc)
7543 glyph_index = get_glyph_index_flagged(face, Safepwc[i - FirstChar], (fl & GCW_INDICES));
7544 else
7545 glyph_index = get_glyph_index_flagged(face, i, (fl & GCW_INDICES));
7546
7547 FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
7548
7549 if (!fl)
7550 SafeBuffF[i - FirstChar] = (FLOAT) ((face->glyph->advance.x + 32) >> 6);
7551 else
7552 SafeBuffI[i - FirstChar] = (face->glyph->advance.x + 32) >> 6;
7553 }
7554
7556 TEXTOBJ_UnlockText(TextObj);
7557
7558 return TRUE;
7559}
FLOAT * PFLOAT
Definition: minwindef.h:147
int * PINT
Definition: minwindef.h:150
#define GCW_INDICES
Definition: ntgdityp.h:206

Referenced by NtGdiGetCharWidthW().

◆ GreGetGlyphIndicesW()

DWORD APIENTRY GreGetGlyphIndicesW ( _In_ HDC  hdc,
_In_reads_opt_(cwc) PCWCH  pwc,
_In_ INT  cwc,
_Out_writes_opt_(cwc) PWORD  pgi,
_In_ DWORD  iMode,
_In_ BOOL  bSubset 
)

Definition at line 7594 of file freetype.c.

7601{
7602 // FIXME: bSubset
7603 PDC dc = DC_LockDc(hdc);
7604 if (!dc)
7605 return GDI_ERROR;
7606
7607 PDC_ATTR pdcattr = dc->pdcattr;
7608 HFONT hFont = pdcattr->hlfntNew;
7609 PTEXTOBJ TextObj = RealizeFontInit(hFont);
7610 DC_UnlockDc(dc);
7611
7612 if (!TextObj)
7613 {
7614 DPRINT1("!TextObj\n");
7615 return GDI_ERROR;
7616 }
7617
7618 PFONTGDI FontGDI = ObjToGDI(TextObj->Font, FONT);
7619 FT_Face Face = FontGDI->SharedFace->Face;
7620 TEXTOBJ_UnlockText(TextObj);
7621
7622 if (cwc == 0)
7623 {
7624 // Only the exceptional query case (pwc == NULL && pgi == NULL && iMode == 0)
7625 // should return the number of glyphs. All other cwc == 0 cases must fail.
7626 if (!pwc && !pgi && !iMode)
7627 return Face->num_glyphs; // Returns number of glyphs
7628
7629 return GDI_ERROR;
7630 }
7631
7632 // Get default character
7633 WCHAR DefChar = 0xFFFF;
7634 if (!(iMode & GGI_MARK_NONEXISTING_GLYPHS) && IntGetFontDefaultChar(Face, &DefChar))
7635 {
7637 DefChar = get_glyph_index(Face, DefChar); // Convert to glyph index
7639 }
7640
7641 // Get glyph indices
7642 // NOTE: Windows GetGlyphIndices doesn't support Surrogate Pairs.
7644 for (INT i = 0; i < cwc; i++)
7645 {
7646 pgi[i] = get_glyph_index(Face, pwc[i]);
7647 if (pgi[i] == 0)
7648 pgi[i] = DefChar;
7649 }
7651
7652 return cwc;
7653}
static BOOL IntGetFontDefaultChar(_In_ FT_Face Face, _Out_ PWCHAR pDefChar)
Definition: freetype.c:7561
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:4302
HDC hdc
Definition: main.c:9
short WCHAR
Definition: pedump.c:58
FT_Long num_glyphs
Definition: freetype.h:1036
_In_ ULONG iMode
Definition: winddi.h:3520
#define GGI_MARK_NONEXISTING_GLYPHS
Definition: wingdi.h:1085

Referenced by NtGdiGetGlyphIndicesWInternal().

◆ GreGetTextExtentExW()

BOOL FASTCALL GreGetTextExtentExW ( HDC  ,
PCWCH  ,
ULONG  ,
ULONG  ,
PULONG  ,
PULONG  ,
PSIZE  ,
FLONG   
)

◆ GreGetTextExtentW()

BOOL FASTCALL GreGetTextExtentW ( HDC  ,
PCWCH  ,
INT  ,
PSIZE  ,
UINT   
)

◆ GreGetTextMetricsW()

BOOL WINAPI GreGetTextMetricsW ( _In_ HDC  hdc,
_Out_ LPTEXTMETRICW  lptm 
)

Definition at line 191 of file text.c.

194{
195 TMW_INTERNAL tmwi;
196 if (!ftGdiGetTextMetricsW(hdc, &tmwi)) return FALSE;
197 IntTMWFixUp(hdc, &tmwi);
198 *lptm = tmwi.TextMetric;
199 return TRUE;
200}
BOOL FASTCALL ftGdiGetTextMetricsW(HDC hDC, PTMW_INTERNAL ptmwi)
Definition: freetype.c:5289
static LPTEXTMETRICW lptm
Definition: font.c:42
VOID FASTCALL IntTMWFixUp(_In_ HDC hDC, _Inout_ PTMW_INTERNAL ptm)
Definition: text.c:29

Referenced by DrawTextExWorker().

◆ GreTextOutW()

BOOL FASTCALL GreTextOutW ( HDC  ,
INT  ,
INT  ,
PCWCH  ,
INT   
)

◆ InitFontSupport()

BOOL FASTCALL InitFontSupport ( VOID  )

Definition at line 948 of file freetype.c.

949{
950 ULONG ulError;
951
953
955 if (g_FreeTypeLock == NULL)
956 {
957 return FALSE;
958 }
960
962 if (ulError)
963 {
964 DPRINT1("FT_Init_FreeType failed with error code 0x%x\n", ulError);
965 return FALSE;
966 }
967
969 {
970 DPRINT1("Fonts registry is empty.\n");
971
972 /* Load font(s) with writing registry */
974 }
975
976 IntLoadFontSubstList(&g_FontSubstListHead);
977
978#if 0
979 DumpFontInfo(TRUE);
980#endif
981
986
987 return TRUE;
988}
#define NonPagedPool
Definition: env_spec_w32.h:307
BOOL FASTCALL IntLoadFontSubstList(PLIST_ENTRY pHead)
Definition: freetype.c:729
static UINT g_FontCacheNumEntries
Definition: freetype.c:240
VOID FASTCALL IntLoadSystemFonts(VOID)
Definition: freetype.c:1378
static NTSTATUS FontLink_LoadDefaultCharset(VOID)
Definition: freetype.c:133
static NTSTATUS FontLink_PopulateEntries(VOID)
Definition: freetype.c:909
static NTSTATUS FontLink_LoadSettings(VOID)
Definition: freetype.c:69
static NTSTATUS FontLink_LoadDefaultFonts(VOID)
Definition: freetype.c:95
BOOL FASTCALL IntLoadFontsInRegistry(VOID)
Definition: freetype.c:2377
FT_Init_FreeType(FT_Library *alibrary)
Definition: ftinit.c:199
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
FAST_MUTEX
Definition: extypes.h:17

Referenced by InitializeGreCSRSS().

◆ IntCharSetFromCodePage()

BYTE FASTCALL IntCharSetFromCodePage ( UINT  uCodePage)

Definition at line 318 of file freetype.c.

319{
320 UINT i;
321
322 if (uCodePage == CP_OEMCP)
323 return OEM_CHARSET;
324
325 if (uCodePage == CP_MACCP)
326 return MAC_CHARSET;
327
328 for (i = 0; i < MAXTCIINDEX; ++i)
329 {
330 if (g_FontTci[i].ciACP == 0)
331 continue;
332
333 if (g_FontTci[i].ciACP == uCodePage)
334 return g_FontTci[i].ciCharset;
335 }
336
337 return DEFAULT_CHARSET;
338}
#define CP_OEMCP
Definition: freetype.c:312
static const CHARSETINFO g_FontTci[MAXTCIINDEX]
Definition: freetype.c:270
#define CP_MACCP
Definition: freetype.c:313
#define OEM_CHARSET
Definition: wingdi.h:400
#define MAC_CHARSET
Definition: wingdi.h:403

Referenced by CreateStockFonts().

◆ IntEnableFontRendering()

VOID FASTCALL IntEnableFontRendering ( BOOL  Enable)

Definition at line 2707 of file freetype.c.

2708{
2710}
static BOOL g_RenderingEnabled
Definition: freetype.c:217
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142

◆ IntGdiAddFontMemResource()

HANDLE FASTCALL IntGdiAddFontMemResource ( PVOID  Buffer,
DWORD  dwSize,
PDWORD  pNumAdded 
)

Definition at line 2529 of file freetype.c.

2530{
2531 HANDLE Ret = NULL;
2533 PFONT_ENTRY_COLL_MEM EntryCollection;
2534 INT FaceCount;
2535
2537 if (!BufferCopy)
2538 {
2539 *pNumAdded = 0;
2540 return NULL;
2541 }
2542 RtlCopyMemory(BufferCopy, Buffer, dwSize);
2543
2544 RtlZeroMemory(&LoadFont, sizeof(LoadFont));
2545 LoadFont.Memory = SharedMem_Create(BufferCopy, dwSize, FALSE);
2546 LoadFont.Characteristics = FR_PRIVATE | FR_NOT_ENUM;
2547 RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
2549
2550 RtlFreeUnicodeString(&LoadFont.RegValueName);
2551
2552 /* Release our copy */
2556
2557 if (FaceCount > 0)
2558 {
2559 EntryCollection = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_ENTRY_COLL_MEM), TAG_FONT);
2560 if (EntryCollection)
2561 {
2563 EntryCollection->Entry = LoadFont.PrivateEntry;
2565 IntLockProcessPrivateFonts(Win32Process);
2566 EntryCollection->Handle = ULongToHandle(++Win32Process->PrivateMemFontHandleCount);
2567 InsertTailList(&Win32Process->PrivateMemFontListHead, &EntryCollection->ListEntry);
2568 IntUnLockProcessPrivateFonts(Win32Process);
2570 Ret = EntryCollection->Handle;
2571 }
2572 }
2573 *pNumAdded = FaceCount;
2574
2575 return Ret;
2576}
#define ULongToHandle(h)
Definition: basetsd.h:75
#define InsertTailList(ListHead, Entry)
BOOL LoadFont(LPWSTR lpCmdLine)
static INT FASTCALL IntGdiLoadFontByIndexFromMemory(PGDI_LOAD_FONT pLoadFont, FT_Long FontIndex)
Definition: freetype.c:1922
static PSHARED_MEM SharedMem_Create(PBYTE Buffer, ULONG BufferSize, BOOL IsMapping)
Definition: freetype.c:438
static void SharedMem_Release(PSHARED_MEM Ptr)
Definition: freetype.c:495
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1213
Definition: font.h:20
FONT_ENTRY_MEM * Entry
Definition: font.h:23
LIST_ENTRY ListEntry
Definition: font.h:21
HANDLE Handle
Definition: font.h:22
LIST_ENTRY PrivateMemFontListHead
Definition: win32.h:287
UINT PrivateMemFontHandleCount
Definition: win32.h:288
#define IntLockProcessPrivateFonts(W32Process)
Definition: text.h:171
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:174

Referenced by NtGdiAddFontMemResourceEx().

◆ IntGdiAddFontResourceEx()

INT FASTCALL IntGdiAddFontResourceEx ( _In_ PCUNICODE_STRING  FileName,
_In_ DWORD  cFiles,
_In_ DWORD  Characteristics,
_In_ DWORD  dwFlags 
)

Definition at line 2198 of file freetype.c.

2203{
2204 PWSTR pchFile = FileName->Buffer;
2205 SIZE_T cchFile;
2206 INT ret = 0;
2207
2208 while (cFiles--)
2209 {
2210 _SEH2_TRY
2211 {
2212 cchFile = wcslen(pchFile);
2213 }
2215 {
2216 _SEH2_YIELD(return FALSE);
2217 }
2218 _SEH2_END;
2219
2220 UNICODE_STRING ustrPathName;
2221 ustrPathName.Length = (USHORT)(cchFile * sizeof(WCHAR));
2222 ustrPathName.MaximumLength = ustrPathName.Length + sizeof(WCHAR);
2223 ustrPathName.Buffer = pchFile;
2224
2225 INT count = IntGdiAddFontResourceSingle(&ustrPathName, Characteristics, dwFlags);
2226 if (!count)
2227 return 0;
2228 ret += count;
2229
2230 pchFile += cchFile + 1;
2231 }
2232
2233 return ret;
2234}
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
return ret
Definition: mutex.c:147
static INT FASTCALL IntGdiAddFontResourceSingle(_In_ PCUNICODE_STRING FileName, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
Definition: freetype.c:1999
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:207
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by IntLoadFontsInRegistry(), IntLoadSystemFonts(), and NtGdiAddFontResourceW().

◆ IntGdiCleanupPrivateFontsForProcess()

VOID FASTCALL IntGdiCleanupPrivateFontsForProcess ( VOID  )

Definition at line 2651 of file freetype.c.

2652{
2655 PFONT_ENTRY_COLL_MEM EntryCollection;
2656
2657 DPRINT("IntGdiCleanupPrivateFontsForProcess()\n");
2658 do {
2659 Entry = NULL;
2660 EntryCollection = NULL;
2661
2663 IntLockProcessPrivateFonts(Win32Process);
2664 if (!IsListEmpty(&Win32Process->PrivateMemFontListHead))
2665 {
2666 Entry = Win32Process->PrivateMemFontListHead.Flink;
2667 EntryCollection = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
2668 UnlinkFontMemCollection(EntryCollection);
2669 }
2670 IntUnLockProcessPrivateFonts(Win32Process);
2672
2673 if (EntryCollection)
2674 {
2675 IntGdiCleanupMemEntry(EntryCollection->Entry);
2676 ExFreePoolWithTag(EntryCollection, TAG_FONT);
2677 }
2678 else
2679 {
2680 /* No Mem fonts anymore, see if we have any other private fonts left */
2681 Entry = NULL;
2683 IntLockProcessPrivateFonts(Win32Process);
2684 if (!IsListEmpty(&Win32Process->PrivateFontListHead))
2685 {
2686 Entry = RemoveHeadList(&Win32Process->PrivateFontListHead);
2687 }
2688 IntUnLockProcessPrivateFonts(Win32Process);
2690
2691 if (Entry)
2692 {
2694 }
2695 }
2696
2697 } while (Entry);
2698}
VOID FASTCALL IntGdiCleanupMemEntry(PFONT_ENTRY_MEM Head)
Definition: freetype.c:2579
static VOID FASTCALL UnlinkFontMemCollection(PFONT_ENTRY_COLL_MEM Collection)
Definition: freetype.c:2598
Entry
Definition: section.c:5216
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY PrivateFontListHead
Definition: win32.h:286

Referenced by GdiProcessDestroy().

◆ IntGdiGetFontResourceInfo()

BOOL FASTCALL IntGdiGetFontResourceInfo ( PUNICODE_STRING  FileName,
PVOID  pBuffer,
DWORD pdwBytes,
DWORD  dwType 
)

Definition at line 6104 of file freetype.c.

6109{
6110 UNICODE_STRING EntryFileName;
6111 POBJECT_NAME_INFORMATION NameInfo1 = NULL, NameInfo2 = NULL;
6112 PLIST_ENTRY ListEntry;
6113 PFONT_ENTRY FontEntry;
6114 ULONG Size, i, Count;
6115 LPBYTE pbBuffer;
6116 BOOL IsEqual;
6117 FONTFAMILYINFO *FamInfo;
6118 const ULONG MaxFamInfo = 64;
6119 const ULONG MAX_FAM_INFO_BYTES = sizeof(FONTFAMILYINFO) * MaxFamInfo;
6120 BOOL bSuccess;
6121 const ULONG NAMEINFO_SIZE = sizeof(OBJECT_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR);
6122
6123 DPRINT("IntGdiGetFontResourceInfo: dwType == %lu\n", dwType);
6124
6125 do
6126 {
6127 /* Create buffer for full path name */
6128 NameInfo1 = ExAllocatePoolWithTag(PagedPool, NAMEINFO_SIZE, TAG_FINF);
6129 if (!NameInfo1)
6130 break;
6131
6132 /* Get the full path name */
6133 if (!IntGetFullFileName(NameInfo1, NAMEINFO_SIZE, FileName))
6134 break;
6135
6136 /* Create a buffer for the entries' names */
6137 NameInfo2 = ExAllocatePoolWithTag(PagedPool, NAMEINFO_SIZE, TAG_FINF);
6138 if (!NameInfo2)
6139 break;
6140
6141 FamInfo = ExAllocatePoolWithTag(PagedPool, MAX_FAM_INFO_BYTES, TAG_FINF);
6142 } while (0);
6143
6144 if (!NameInfo1 || !NameInfo2 || !FamInfo)
6145 {
6146 if (NameInfo2)
6147 ExFreePoolWithTag(NameInfo2, TAG_FINF);
6148
6149 if (NameInfo1)
6150 ExFreePoolWithTag(NameInfo1, TAG_FINF);
6151
6153 return FALSE;
6154 }
6155
6156 Count = 0;
6157
6158 /* Try to find the pathname in the global font list */
6160 for (ListEntry = g_FontListHead.Flink; ListEntry != &g_FontListHead;
6161 ListEntry = ListEntry->Flink)
6162 {
6163 FontEntry = CONTAINING_RECORD(ListEntry, FONT_ENTRY, ListEntry);
6164 if (FontEntry->Font->Filename == NULL)
6165 continue;
6166
6167 RtlInitUnicodeString(&EntryFileName , FontEntry->Font->Filename);
6168 if (!IntGetFullFileName(NameInfo2, NAMEINFO_SIZE, &EntryFileName))
6169 continue;
6170
6171 if (!RtlEqualUnicodeString(&NameInfo1->Name, &NameInfo2->Name, FALSE))
6172 continue;
6173
6174 IsEqual = FALSE;
6175 FontFamilyFillInfo(&FamInfo[Count], FontEntry->FaceName.Buffer,
6176 NULL, FontEntry->Font);
6177 for (i = 0; i < Count; ++i)
6178 {
6179 if (EqualFamilyInfo(&FamInfo[i], &FamInfo[Count]))
6180 {
6181 IsEqual = TRUE;
6182 break;
6183 }
6184 }
6185 if (!IsEqual)
6186 {
6187 /* Found */
6188 ++Count;
6189 if (Count >= MaxFamInfo)
6190 break;
6191 }
6192 }
6194
6195 /* Free the buffers */
6196 ExFreePoolWithTag(NameInfo1, TAG_FINF);
6197 ExFreePoolWithTag(NameInfo2, TAG_FINF);
6198
6199 if (Count == 0 && dwType != 5)
6200 {
6201 /* Font could not be found in system table
6202 dwType == 5 will still handle this */
6203 ExFreePoolWithTag(FamInfo, TAG_FINF);
6204 return FALSE;
6205 }
6206
6207 bSuccess = FALSE;
6208 switch (dwType)
6209 {
6210 case 0: /* FIXME: Returns 1 or 2, don't know what this is atm */
6211 Size = sizeof(DWORD);
6212 if (*pdwBytes == 0)
6213 {
6214 *pdwBytes = Size;
6215 bSuccess = TRUE;
6216 }
6217 else if (pBuffer)
6218 {
6219 if (*pdwBytes >= Size)
6220 {
6221 *(DWORD*)pBuffer = Count;
6222 }
6223 *pdwBytes = Size;
6224 bSuccess = TRUE;
6225 }
6226 break;
6227
6228 case 1: /* copy the font title */
6229 /* calculate the required size */
6230 Size = 0;
6231 for (i = 0; i < Count; ++i)
6232 {
6233 if (i > 0)
6234 Size += 3; /* " & " */
6235 Size += wcslen(FamInfo[i].EnumLogFontEx.elfLogFont.lfFaceName);
6236 if (FamInfo[i].EnumLogFontEx.elfStyle[0] &&
6237 _wcsicmp(FamInfo[i].EnumLogFontEx.elfStyle, L"Regular") != 0)
6238 {
6239 Size += 1 + wcslen(FamInfo[i].EnumLogFontEx.elfStyle);
6240 }
6241 }
6242 Size += 2; /* "\0\0" */
6243 Size *= sizeof(WCHAR);
6244
6245 if (*pdwBytes == 0)
6246 {
6247 *pdwBytes = Size;
6248 bSuccess = TRUE;
6249 }
6250 else if (pBuffer)
6251 {
6252 if (*pdwBytes >= Size)
6253 {
6254 /* store font title to buffer */
6255 WCHAR *psz = pBuffer;
6256 *psz = 0;
6257 for (i = 0; i < Count; ++i)
6258 {
6259 if (i > 0)
6260 wcscat(psz, L" & ");
6261 IntAddNameFromFamInfo(psz, &FamInfo[i]);
6262 }
6263 psz[wcslen(psz) + 1] = UNICODE_NULL;
6264 *pdwBytes = Size;
6265 bSuccess = TRUE;
6266 }
6267 else
6268 {
6269 *pdwBytes = 1024; /* this is confirmed value */
6270 }
6271 }
6272 break;
6273
6274 case 2: /* Copy an array of LOGFONTW */
6275 Size = Count * sizeof(LOGFONTW);
6276 if (*pdwBytes == 0)
6277 {
6278 *pdwBytes = Size;
6279 bSuccess = TRUE;
6280 }
6281 else if (pBuffer)
6282 {
6283 if (*pdwBytes >= Size)
6284 {
6285 pbBuffer = (LPBYTE)pBuffer;
6286 for (i = 0; i < Count; ++i)
6287 {
6288 FamInfo[i].EnumLogFontEx.elfLogFont.lfWidth = 0;
6289 RtlCopyMemory(pbBuffer, &FamInfo[i].EnumLogFontEx.elfLogFont, sizeof(LOGFONTW));
6290 pbBuffer += sizeof(LOGFONTW);
6291 }
6292 }
6293 *pdwBytes = Size;
6294 bSuccess = TRUE;
6295 }
6296 else
6297 {
6298 *pdwBytes = 1024; /* this is confirmed value */
6299 }
6300 break;
6301
6302 case 3:
6303 Size = sizeof(DWORD);
6304 if (*pdwBytes == 0)
6305 {
6306 *pdwBytes = Size;
6307 bSuccess = TRUE;
6308 }
6309 else if (pBuffer)
6310 {
6311 if (*pdwBytes >= Size)
6312 {
6313 /* FIXME: What exactly is copied here? */
6314 *(DWORD*)pBuffer = 1;
6315 }
6316 *pdwBytes = Size;
6317 bSuccess = TRUE;
6318 }
6319 break;
6320
6321 case 4: /* full file path */
6322 if (FileName->Length >= 4 * sizeof(WCHAR))
6323 {
6324 /* The beginning of FileName is \??\ */
6325 LPWSTR pch = FileName->Buffer + 4;
6326 DWORD Length = FileName->Length - 4 * sizeof(WCHAR);
6327
6328 Size = Length + sizeof(WCHAR);
6329 if (*pdwBytes == 0)
6330 {
6331 *pdwBytes = Size;
6332 bSuccess = TRUE;
6333 }
6334 else if (pBuffer)
6335 {
6336 if (*pdwBytes >= Size)
6337 {
6339 }
6340 *pdwBytes = Size;
6341 bSuccess = TRUE;
6342 }
6343 }
6344 break;
6345
6346 case 5: /* Looks like a BOOL that is copied, TRUE, if the font was not found */
6347 Size = sizeof(BOOL);
6348 if (*pdwBytes == 0)
6349 {
6350 *pdwBytes = Size;
6351 bSuccess = TRUE;
6352 }
6353 else if (pBuffer)
6354 {
6355 if (*pdwBytes >= Size)
6356 {
6357 *(BOOL*)pBuffer = Count == 0;
6358 }
6359 *pdwBytes = Size;
6360 bSuccess = TRUE;
6361 }
6362 break;
6363 }
6364 ExFreePoolWithTag(FamInfo, TAG_FINF);
6365
6366 return bSuccess;
6367}
#define MAX_PATH
Definition: compat.h:34
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
#define L(x)
Definition: resources.c:13
@ IsEqual
Definition: fatprocs.h:1887
static BOOL FASTCALL IntGetFullFileName(POBJECT_NAME_INFORMATION NameInfo, ULONG Size, PUNICODE_STRING FileName)
Definition: freetype.c:5913
static BOOL EqualFamilyInfo(const FONTFAMILYINFO *pInfo1, const FONTFAMILYINFO *pInfo2)
Definition: freetype.c:5956
static void FASTCALL FontFamilyFillInfo(PFONTFAMILYINFO Info, LPCWSTR FaceName, LPCWSTR FullName, PFONTGDI FontGDI)
Definition: freetype.c:3444
static VOID IntAddNameFromFamInfo(LPWSTR psz, FONTFAMILYINFO *FamInfo)
Definition: freetype.c:5977
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
#define pch(ap)
Definition: match.c:418
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
struct tagFONTFAMILYINFO FONTFAMILYINFO
PVOID pBuffer
wcscat
LPWSTR Filename
Definition: engobjects.h:151
FONTGDI * Font
Definition: font.h:7
UNICODE_STRING FaceName
Definition: font.h:8
UNICODE_STRING Name
Definition: nt_native.h:1273
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
LONG lfWidth
Definition: wingdi.h:2344
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
#define TAG_FINF
Definition: text.h:3

Referenced by NtGdiGetFontResourceInfoInternalW().

◆ IntGdiRemoveFontMemResource()

BOOL FASTCALL IntGdiRemoveFontMemResource ( HANDLE  hMMFont)

Definition at line 2615 of file freetype.c.

2616{
2618 PFONT_ENTRY_COLL_MEM CurrentEntry;
2619 PFONT_ENTRY_COLL_MEM EntryCollection = NULL;
2621
2623 IntLockProcessPrivateFonts(Win32Process);
2624 for (Entry = Win32Process->PrivateMemFontListHead.Flink;
2625 Entry != &Win32Process->PrivateMemFontListHead;
2626 Entry = Entry->Flink)
2627 {
2628 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
2629
2630 if (CurrentEntry->Handle == hMMFont)
2631 {
2632 EntryCollection = CurrentEntry;
2633 UnlinkFontMemCollection(CurrentEntry);
2634 break;
2635 }
2636 }
2637 IntUnLockProcessPrivateFonts(Win32Process);
2639
2640 if (EntryCollection)
2641 {
2642 IntGdiCleanupMemEntry(EntryCollection->Entry);
2643 ExFreePoolWithTag(EntryCollection, TAG_FONT);
2644 return TRUE;
2645 }
2646 return FALSE;
2647}

Referenced by NtGdiRemoveFontMemResourceEx().

◆ IntGdiRemoveFontResource()

BOOL FASTCALL IntGdiRemoveFontResource ( _In_ PCUNICODE_STRING  FileName,
_In_ DWORD  cFiles,
_In_ DWORD  dwFlags 
)

Definition at line 2341 of file freetype.c.

2345{
2346 PWSTR pchFile = FileName->Buffer;
2347 SIZE_T cchFile;
2348
2349 while (cFiles--)
2350 {
2351 _SEH2_TRY
2352 {
2353 cchFile = wcslen(pchFile);
2354 }
2356 {
2357 _SEH2_YIELD(return FALSE);
2358 }
2359 _SEH2_END;
2360
2361 UNICODE_STRING ustrPathName;
2362 ustrPathName.Length = (USHORT)(cchFile * sizeof(WCHAR));
2363 ustrPathName.MaximumLength = ustrPathName.Length + sizeof(WCHAR);
2364 ustrPathName.Buffer = pchFile;
2365
2367 if (!ret)
2368 return FALSE;
2369
2370 pchFile += cchFile + 1;
2371 }
2372
2373 return TRUE;
2374}
static BOOL FASTCALL IntGdiRemoveFontResourceSingle(_In_ PCUNICODE_STRING FileName, _In_ DWORD dwFlags)
Definition: freetype.c:2272

Referenced by NtGdiRemoveFontResourceW().

◆ IntGetCharDimensions()

DWORD FASTCALL IntGetCharDimensions ( HDC  ,
PTEXTMETRICW  ,
PDWORD   
)

◆ IntGetFontLanguageInfo()

DWORD FASTCALL IntGetFontLanguageInfo ( PDC  )

◆ IntGetOutlineTextMetrics()

INT FASTCALL IntGetOutlineTextMetrics ( PFONTGDI  FontGDI,
UINT  Size,
OUTLINETEXTMETRICW Otm,
BOOL  bLocked 
)

Definition at line 3140 of file freetype.c.

3144{
3145 TT_OS2 *pOS2;
3146 TT_HoriHeader *pHori;
3147 TT_Postscript *pPost;
3148 FT_Fixed XScale, YScale;
3149 FT_WinFNT_HeaderRec WinFNT;
3151 BYTE *pb;
3152 FONT_NAMES FontNames;
3153 PSHARED_FACE SharedFace = FontGDI->SharedFace;
3154 PSHARED_FACE_CACHE Cache;
3155 FT_Face Face = SharedFace->Face;
3156
3157 if (bLocked)
3159 else
3161
3163 {
3164 Cache = &SharedFace->EnglishUS;
3165 }
3166 else
3167 {
3168 Cache = &SharedFace->UserLanguage;
3169 }
3170
3171 if (Size == 0 && Cache->OutlineRequiredSize > 0)
3172 {
3173 ASSERT(Otm == NULL);
3174 return Cache->OutlineRequiredSize;
3175 }
3176
3177 if (!bLocked)
3179
3180 IntInitFontNames(&FontNames, SharedFace);
3181 Cache->OutlineRequiredSize = FontNames.OtmSize;
3182
3183 if (Size == 0)
3184 {
3185 ASSERT(Otm == NULL);
3186 IntFreeFontNames(&FontNames);
3187 if (!bLocked)
3189 return Cache->OutlineRequiredSize;
3190 }
3191
3192 ASSERT(Otm != NULL);
3193
3194 if (Size < Cache->OutlineRequiredSize)
3195 {
3196 DPRINT1("Size %u < OutlineRequiredSize %u\n", Size,
3197 Cache->OutlineRequiredSize);
3198 IntFreeFontNames(&FontNames);
3199 if (!bLocked)
3201 return 0; /* failure */
3202 }
3203
3204 XScale = Face->size->metrics.x_scale;
3205 YScale = Face->size->metrics.y_scale;
3206
3207 pOS2 = FT_Get_Sfnt_Table(Face, FT_SFNT_OS2);
3208 pHori = FT_Get_Sfnt_Table(Face, FT_SFNT_HHEA);
3209 pPost = FT_Get_Sfnt_Table(Face, FT_SFNT_POST); /* We can live with this failing */
3210 Error = FT_Get_WinFNT_Header(Face, &WinFNT);
3211
3212 if (pOS2 == NULL && Error)
3213 {
3214 if (!bLocked)
3216 DPRINT1("Can't find OS/2 table - not TT font?\n");
3217 IntFreeFontNames(&FontNames);
3218 return 0;
3219 }
3220
3221 if (pHori == NULL && Error)
3222 {
3223 if (!bLocked)
3225 DPRINT1("Can't find HHEA table - not TT font?\n");
3226 IntFreeFontNames(&FontNames);
3227 return 0;
3228 }
3229
3230 Otm->otmSize = Cache->OutlineRequiredSize;
3231
3232 FillTM(&Otm->otmTextMetrics, FontGDI, pOS2, pHori, (Error ? NULL : &WinFNT));
3233
3234 if (!pOS2)
3235 goto skip_os2;
3236
3237 Otm->otmFiller = 0;
3239 Otm->otmfsSelection = pOS2->fsSelection;
3240 Otm->otmfsType = pOS2->fsType;
3241 Otm->otmsCharSlopeRise = pHori->caret_Slope_Rise;
3242 Otm->otmsCharSlopeRun = pHori->caret_Slope_Run;
3243 Otm->otmItalicAngle = 0; /* POST table */
3244 Otm->otmEMSquare = Face->units_per_EM;
3245
3246#define SCALE_X(value) ((FT_MulFix((value), XScale) + 32) >> 6)
3247#define SCALE_Y(value) ((FT_MulFix((value), YScale) + 32) >> 6)
3248
3249 Otm->otmAscent = SCALE_Y(pOS2->sTypoAscender);
3250 Otm->otmDescent = SCALE_Y(pOS2->sTypoDescender);
3251 Otm->otmLineGap = SCALE_Y(pOS2->sTypoLineGap);
3252 Otm->otmsCapEmHeight = SCALE_Y(pOS2->sCapHeight);
3253 Otm->otmsXHeight = SCALE_Y(pOS2->sxHeight);
3254 Otm->otmrcFontBox.left = SCALE_X(Face->bbox.xMin);
3255 Otm->otmrcFontBox.right = SCALE_X(Face->bbox.xMax);
3256 Otm->otmrcFontBox.top = SCALE_Y(Face->bbox.yMax);
3257 Otm->otmrcFontBox.bottom = SCALE_Y(Face->bbox.yMin);
3260 Otm->otmMacLineGap = Otm->otmLineGap;
3261 Otm->otmusMinimumPPEM = 0; /* TT Header */
3272
3273 if (!pPost)
3274 {
3275 Otm->otmsUnderscoreSize = 0;
3276 Otm->otmsUnderscorePosition = 0;
3277 }
3278 else
3279 {
3282 }
3283
3284#undef SCALE_X
3285#undef SCALE_Y
3286
3287skip_os2:
3288 if (!bLocked)
3290
3291 pb = IntStoreFontNames(&FontNames, Otm);
3292 ASSERT(pb - (BYTE*)Otm == Cache->OutlineRequiredSize);
3293
3294 IntFreeFontNames(&FontNames);
3295
3296 return Cache->OutlineRequiredSize;
3297}
BOOLEAN bLocked
Definition: Mke2fs.c:19
#define SCALE_Y(value)
static __inline void FASTCALL IntInitFontNames(FONT_NAMES *Names, PSHARED_FACE SharedFace)
Definition: freetype.c:3067
PBYTE FASTCALL IntStoreFontNames(_In_ const FONT_NAMES *Names, _Out_ OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:3103
#define SCALE_X(value)
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:219
static __inline void FASTCALL IntFreeFontNames(FONT_NAMES *Names)
Definition: freetype.c:3127
signed long FT_Fixed
Definition: fttypes.h:287
#define ASSERT(a)
Definition: mode.c:44
#define LANG_ENGLISH
Definition: nls.h:52
#define PRIMARYLANGID(l)
Definition: nls.h:16
ULONG OtmSize
Definition: freetype.c:3063
FT_Pos xMin
Definition: ftimage.h:120
FT_Pos yMax
Definition: ftimage.h:121
FT_Pos yMin
Definition: ftimage.h:120
FT_Pos xMax
Definition: ftimage.h:121
FT_Size size
Definition: freetype.h:1066
FT_BBox bbox
Definition: freetype.h:1052
FT_UShort units_per_EM
Definition: freetype.h:1054
FT_Size_Metrics metrics
Definition: freetype.h:1636
FT_Fixed y_scale
Definition: freetype.h:1601
FT_Fixed x_scale
Definition: freetype.h:1600
FT_Short caret_Slope_Run
Definition: tttables.h:213
FT_Short caret_Slope_Rise
Definition: tttables.h:212
FT_Short sTypoDescender
Definition: tttables.h:407
FT_UShort fsSelection
Definition: tttables.h:403
FT_Short ySuperscriptYSize
Definition: tttables.h:387
FT_Short sxHeight
Definition: tttables.h:419
FT_Short yStrikeoutSize
Definition: tttables.h:390
FT_Byte panose[10]
Definition: tttables.h:394
FT_Short ySubscriptXSize
Definition: tttables.h:382
FT_Short sTypoLineGap
Definition: tttables.h:408
FT_Short sTypoAscender
Definition: tttables.h:406
FT_Short ySuperscriptXSize
Definition: tttables.h:386
FT_Short ySubscriptYOffset
Definition: tttables.h:385
FT_Short ySuperscriptYOffset
Definition: tttables.h:389
FT_Short ySubscriptXOffset
Definition: tttables.h:384
FT_Short yStrikeoutPosition
Definition: tttables.h:391
FT_Short sCapHeight
Definition: tttables.h:420
FT_UShort fsType
Definition: tttables.h:381
FT_Short ySuperscriptXOffset
Definition: tttables.h:388
FT_Short ySubscriptYSize
Definition: tttables.h:383
FT_Short underlineThickness
Definition: tttables.h:455
FT_Short underlinePosition
Definition: tttables.h:454
PANOSE otmPanoseNumber
Definition: wingdi.h:2962
POINT otmptSuperscriptOffset
Definition: wingdi.h:2982
POINT otmptSuperscriptSize
Definition: wingdi.h:2981
POINT otmptSubscriptSize
Definition: wingdi.h:2979
int otmsStrikeoutPosition
Definition: wingdi.h:2984
int otmsUnderscorePosition
Definition: wingdi.h:2986
POINT otmptSubscriptOffset
Definition: wingdi.h:2980
UINT otmsStrikeoutSize
Definition: wingdi.h:2983
SHARED_FACE_CACHE UserLanguage
Definition: engobjects.h:136
SHARED_FACE_CACHE EnglishUS
Definition: engobjects.h:135
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
LONG tmAscent
Definition: wingdi.h:2830
LONG tmDescent
Definition: wingdi.h:2831
@ FT_SFNT_HHEA
Definition: tttables.h:625
@ FT_SFNT_POST
Definition: tttables.h:627
@ FT_SFNT_OS2
Definition: tttables.h:624
#define PANOSE_COUNT
Definition: wingdi.h:453

Referenced by FindBestFontFromList(), FontFamilyFillInfo(), ftGdiGetGlyphOutline(), and NtGdiGetOutlineTextMetricsInternalW().

◆ IntIsFontRenderingEnabled()

BOOL FASTCALL IntIsFontRenderingEnabled ( VOID  )

Definition at line 2701 of file freetype.c.

2702{
2703 return (gpsi->BitsPixel > 8) && g_RenderingEnabled;
2704}
PSERVERINFO gpsi
Definition: imm.c:18

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ IntLoadFontsInRegistry()

BOOL FASTCALL IntLoadFontsInRegistry ( VOID  )

Definition at line 2377 of file freetype.c.

2378{
2382 KEY_FULL_INFORMATION KeyFullInfo;
2383 ULONG i, Length;
2384 UNICODE_STRING FontTitleW, FileNameW;
2385 SIZE_T InfoSize;
2386 LPBYTE InfoBuffer;
2388 LPWSTR pchPath;
2390 INT nFontCount = 0;
2391 DWORD dwFlags;
2392
2393 /* open registry key */
2396 NULL, NULL);
2397 Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
2398 if (!NT_SUCCESS(Status))
2399 {
2400 DPRINT1("ZwOpenKey failed: 0x%08X\n", Status);
2401 return FALSE; /* failure */
2402 }
2403
2404 /* query count of values */
2405 Status = ZwQueryKey(KeyHandle, KeyFullInformation,
2406 &KeyFullInfo, sizeof(KeyFullInfo), &Length);
2407 if (!NT_SUCCESS(Status))
2408 {
2409 DPRINT1("ZwQueryKey failed: 0x%08X\n", Status);
2411 return FALSE; /* failure */
2412 }
2413
2414 /* allocate buffer */
2415 InfoSize = (MAX_PATH + 256) * sizeof(WCHAR);
2416 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2417 if (!InfoBuffer)
2418 {
2419 DPRINT1("ExAllocatePoolWithTag failed\n");
2421 return FALSE;
2422 }
2423
2424 /* for each value */
2425 for (i = 0; i < KeyFullInfo.Values; ++i)
2426 {
2427 /* get value name */
2428 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
2429 InfoBuffer, InfoSize, &Length);
2431 {
2432 /* too short buffer */
2433 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2434 InfoSize *= 2;
2435 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2436 if (!InfoBuffer)
2437 {
2438 DPRINT1("ExAllocatePoolWithTag failed\n");
2439 break;
2440 }
2441 /* try again */
2442 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
2443 InfoBuffer, InfoSize, &Length);
2444 }
2445 if (!NT_SUCCESS(Status))
2446 {
2447 DPRINT1("ZwEnumerateValueKey failed: 0x%08X\n", Status);
2448 break; /* failure */
2449 }
2450
2451 /* create FontTitleW string */
2452 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
2453 Length = pInfo->NameLength / sizeof(WCHAR);
2454 pInfo->Name[Length] = UNICODE_NULL; /* truncate */
2455 if (!RtlCreateUnicodeString(&FontTitleW, pInfo->Name))
2456 {
2458 DPRINT1("RtlCreateUnicodeString failed\n");
2459 break; /* failure */
2460 }
2461
2462 /* query value */
2463 Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation,
2464 InfoBuffer, InfoSize, &Length);
2466 {
2467 /* too short buffer */
2468 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2469 InfoSize *= 2;
2470 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2471 if (!InfoBuffer)
2472 {
2473 DPRINT1("ExAllocatePoolWithTag failed\n");
2474 break;
2475 }
2476 /* try again */
2477 Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation,
2478 InfoBuffer, InfoSize, &Length);
2479 }
2480 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
2481 if (!NT_SUCCESS(Status) || !pInfo->DataLength)
2482 {
2483 DPRINT1("ZwQueryValueKey failed: 0x%08X\n", Status);
2484 RtlFreeUnicodeString(&FontTitleW);
2485 break; /* failure */
2486 }
2487
2488 /* Build pchPath */
2489 pchPath = (LPWSTR)((PUCHAR)pInfo + pInfo->DataOffset);
2490 Length = pInfo->DataLength / sizeof(WCHAR);
2491 pchPath[Length] = UNICODE_NULL; /* truncate */
2492
2493 /* Load font(s) without writing registry */
2494 if (PathIsRelativeW(pchPath))
2495 {
2496 dwFlags = 0;
2498 L"\\SystemRoot\\Fonts\\%s", pchPath);
2499 }
2500 else
2501 {
2503 Status = RtlStringCbCopyW(szPath, sizeof(szPath), pchPath);
2504 }
2505
2506 if (NT_SUCCESS(Status))
2507 {
2508 RtlCreateUnicodeString(&FileNameW, szPath);
2509 nFontCount += IntGdiAddFontResourceEx(&FileNameW, 1, 0, dwFlags);
2510 RtlFreeUnicodeString(&FileNameW);
2511 }
2512
2513 RtlFreeUnicodeString(&FontTitleW);
2514 }
2515
2516 /* close now */
2518
2519 /* free memory block */
2520 if (InfoBuffer)
2521 {
2522 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2523 }
2524
2525 return (KeyFullInfo.Values != 0 && nFontCount != 0);
2526}
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
BOOL WINAPI PathIsRelativeW(const WCHAR *path)
Definition: path.c:1006
UNICODE_STRING g_FontRegPath
Definition: freetype.c:209
INT FASTCALL IntGdiAddFontResourceEx(_In_ PCUNICODE_STRING FileName, _In_ DWORD cFiles, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
Definition: freetype.c:2198
LPCWSTR szPath
Definition: env.c:37
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyFullInformation
Definition: nt_native.h:1136
@ KeyValueFullInformation
Definition: nt_native.h:1184
#define KEY_READ
Definition: nt_native.h:1026
struct _KEY_VALUE_FULL_INFORMATION * PKEY_VALUE_FULL_INFORMATION
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned char * PUCHAR
Definition: typedefs.h:53
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define AFRX_DOS_DEVICE_PATH
Definition: text.h:106
#define AFRX_ALTERNATIVE_PATH
Definition: text.h:105

Referenced by InitFontSupport().

◆ IntLoadSystemFonts()

VOID FASTCALL IntLoadSystemFonts ( VOID  )

Definition at line 1378 of file freetype.c.

1379{
1381 UNICODE_STRING Directory, FileName, TempString;
1383 HANDLE hDirectory;
1384 BYTE *DirInfoBuffer;
1386 BOOLEAN bRestartScan = TRUE;
1388 INT i;
1389 static UNICODE_STRING SearchPatterns[] =
1390 {
1391 RTL_CONSTANT_STRING(L"*.ttf"),
1392 RTL_CONSTANT_STRING(L"*.ttc"),
1393 RTL_CONSTANT_STRING(L"*.otf"),
1394 RTL_CONSTANT_STRING(L"*.otc"),
1395 RTL_CONSTANT_STRING(L"*.fon"),
1396 RTL_CONSTANT_STRING(L"*.fnt")
1397 };
1398 static UNICODE_STRING IgnoreFiles[] =
1399 {
1402 };
1403
1404 RtlInitUnicodeString(&Directory, L"\\SystemRoot\\Fonts\\");
1405
1408 &Directory,
1410 NULL,
1411 NULL);
1412
1414 &hDirectory,
1417 &Iosb,
1420
1421 if (NT_SUCCESS(Status))
1422 {
1423 for (i = 0; i < _countof(SearchPatterns); ++i)
1424 {
1425 DirInfoBuffer = ExAllocatePoolWithTag(PagedPool, 0x4000, TAG_FONT);
1426 if (DirInfoBuffer == NULL)
1427 {
1428 ZwClose(hDirectory);
1429 return;
1430 }
1431
1433 if (FileName.Buffer == NULL)
1434 {
1435 ExFreePoolWithTag(DirInfoBuffer, TAG_FONT);
1436 ZwClose(hDirectory);
1437 return;
1438 }
1439 FileName.Length = 0;
1440 FileName.MaximumLength = MAX_PATH * sizeof(WCHAR);
1441
1442 while (1)
1443 {
1444 Status = ZwQueryDirectoryFile(
1445 hDirectory,
1446 NULL,
1447 NULL,
1448 NULL,
1449 &Iosb,
1450 DirInfoBuffer,
1451 0x4000,
1453 FALSE,
1454 &SearchPatterns[i],
1455 bRestartScan);
1456
1458 {
1459 break;
1460 }
1461
1462 DirInfo = (PFILE_DIRECTORY_INFORMATION)DirInfoBuffer;
1463 while (1)
1464 {
1465 SIZE_T ign;
1466
1467 TempString.Buffer = DirInfo->FileName;
1468 TempString.Length = TempString.MaximumLength = DirInfo->FileNameLength;
1469
1470 /* Should we ignore this file? */
1471 for (ign = 0; ign < _countof(IgnoreFiles); ++ign)
1472 {
1473 /* Yes.. */
1474 if (RtlEqualUnicodeString(IgnoreFiles + ign, &TempString, FALSE))
1475 break;
1476 }
1477
1478 /* If we tried all Ignore patterns and there was no match, try to create a font */
1479 if (ign == _countof(IgnoreFiles))
1480 {
1484 DPRINT1("ERR: Failed to load %wZ\n", &FileName);
1485 }
1486
1487 if (DirInfo->NextEntryOffset == 0)
1488 break;
1489
1490 DirInfo = (PFILE_DIRECTORY_INFORMATION)((ULONG_PTR)DirInfo + DirInfo->NextEntryOffset);
1491 }
1492
1493 bRestartScan = FALSE;
1494 }
1495
1497 ExFreePoolWithTag(DirInfoBuffer, TAG_FONT);
1498 }
1499 ZwClose(hDirectory);
1500 }
1501}
@ IgnoreFiles
Definition: ACListISF.cpp:75
unsigned char BOOLEAN
Definition: actypes.h:127
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
#define FILE_SHARE_READ
Definition: compat.h:136
return Iosb
Definition: create.c:4403
struct _FileName FileName
Definition: fatprocs.h:897
@ FileDirectoryInformation
Definition: from_kernel.h:62
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
_In_ BOOLEAN _In_ USHORT Directory
Definition: rtlfuncs.h:3962
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define _countof(array)
Definition: sndvol32.h:70
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:1466
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_NO_MORE_FILES
Definition: udferr_usr.h:128
#define AFRX_WRITE_REGISTRY
Definition: text.h:104
struct _FILE_DIRECTORY_INFORMATION * PFILE_DIRECTORY_INFORMATION

Referenced by InitFontSupport().

◆ RealizeFontInit()

PTEXTOBJ FASTCALL RealizeFontInit ( HFONT  )

◆ TextIntCreateFontIndirect()

NTSTATUS FASTCALL TextIntCreateFontIndirect ( CONST LPLOGFONTW  lf,
HFONT *  NewFont 
)

Definition at line 2734 of file freetype.c.

2735{
2736 PLFONT plfont;
2737 LOGFONTW *plf;
2738
2739 ASSERT(lf);
2740 plfont = LFONT_AllocFontWithHandle();
2741 if (!plfont)
2742 {
2743 return STATUS_NO_MEMORY;
2744 }
2745
2746 ExInitializePushLock(&plfont->lock);
2747 *NewFont = plfont->BaseObject.hHmgr;
2748 plf = &plfont->logfont.elfEnumLogfontEx.elfLogFont;
2749 RtlCopyMemory(plf, lf, sizeof(LOGFONTW));
2750 if (lf->lfEscapement != lf->lfOrientation)
2751 {
2752 /* This should really depend on whether GM_ADVANCED is set */
2753 plf->lfOrientation = plf->lfEscapement;
2754 }
2755 LFONT_UnlockFont(plfont);
2756
2757 return STATUS_SUCCESS;
2758}
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define ExInitializePushLock
Definition: ex.h:1016
LONG lfEscapement
Definition: dimm.idl:61
BASEOBJECT BaseObject
Definition: text.h:63
EX_PUSH_LOCK lock
Definition: text.h:71
#define LFONT_UnlockFont(plfnt)
Definition: text.h:79
#define LFONT_AllocFontWithHandle()
Definition: text.h:76

Referenced by CreateStockFonts(), and UserDrawCaptionText().

◆ TextIntGetTextExtentPoint()

BOOL FASTCALL TextIntGetTextExtentPoint ( PDC  ,
PTEXTOBJ  ,
PCWCH  ,
INT  ,
ULONG  ,
PINT  ,
PINT  ,
PSIZE  ,
FLONG   
)

◆ TextIntRealizeFont()

NTSTATUS FASTCALL TextIntRealizeFont ( HFONT  FontHandle,
PTEXTOBJ  pTextObj 
)

Definition at line 5990 of file freetype.c.

5991{
5993 PTEXTOBJ TextObj;
5994 PPROCESSINFO Win32Process;
5995 ULONG MatchPenalty;
5996 LOGFONTW *pLogFont;
5997 LOGFONTW SubstitutedLogFont;
5998
6000
6001 if (!pTextObj)
6002 {
6003 TextObj = TEXTOBJ_LockText(FontHandle);
6004 if (NULL == TextObj)
6005 {
6006 return STATUS_INVALID_HANDLE;
6007 }
6008
6009 if (TextObj->fl & TEXTOBJECT_INIT)
6010 {
6011 TEXTOBJ_UnlockText(TextObj);
6012 return STATUS_SUCCESS;
6013 }
6014 }
6015 else
6016 {
6017 TextObj = pTextObj;
6018 }
6019
6020 pLogFont = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
6021
6022 /* substitute */
6023 SubstitutedLogFont = *pLogFont;
6024 SubstituteFontRecurse(&SubstitutedLogFont);
6025 DPRINT("Font '%S,%u' is substituted by '%S,%u'.\n",
6026 pLogFont->lfFaceName, pLogFont->lfCharSet,
6027 SubstitutedLogFont.lfFaceName, SubstitutedLogFont.lfCharSet);
6028
6029 MatchPenalty = 0xFFFFFFFF;
6030 TextObj->Font = NULL;
6031
6032 Win32Process = PsGetCurrentProcessWin32Process();
6033
6034 /* Search private fonts */
6036 IntLockProcessPrivateFonts(Win32Process);
6037 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
6038 &Win32Process->PrivateFontListHead);
6039 IntUnLockProcessPrivateFonts(Win32Process);
6040
6041 /* Search system fonts */
6042 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
6043 &g_FontListHead);
6045
6046 if (NULL == TextObj->Font)
6047 {
6048 DPRINT1("Request font %S not found, no fonts loaded at all\n",
6049 pLogFont->lfFaceName);
6051 }
6052 else
6053 {
6055 PFONTGDI FontGdi = ObjToGDI(TextObj->Font, FONT);
6056 PSHARED_FACE SharedFace = FontGdi->SharedFace;
6057
6058 TextObj->TextFace[0] = UNICODE_NULL;
6060 if (MatchFontNames(SharedFace, SubstitutedLogFont.lfFaceName))
6061 {
6063 RtlStringCchCopyW(TextObj->TextFace, _countof(TextObj->TextFace), pLogFont->lfFaceName);
6064 }
6065 else
6066 {
6070 if (NT_SUCCESS(Status))
6071 {
6072 /* truncated copy */
6073 IntUnicodeStringToBuffer(TextObj->TextFace, sizeof(TextObj->TextFace), &Name);
6075 }
6076 }
6077
6078 // Need hdev, when freetype is loaded need to create DEVOBJ for
6079 // Consumer and Producer.
6080 TextObj->Font->iUniq = 1; // Now it can be cached.
6081 IntFontType(FontGdi);
6082 FontGdi->flType = TextObj->Font->flFontType;
6083 FontGdi->RequestUnderline = pLogFont->lfUnderline ? 0xFF : 0;
6084 FontGdi->RequestStrikeOut = pLogFont->lfStrikeOut ? 0xFF : 0;
6085 FontGdi->RequestItalic = pLogFont->lfItalic ? 0xFF : 0;
6086 if (pLogFont->lfWeight != FW_DONTCARE)
6087 FontGdi->RequestWeight = pLogFont->lfWeight;
6088 else
6089 FontGdi->RequestWeight = FW_NORMAL;
6090
6091 TextObj->fl |= TEXTOBJECT_INIT;
6093 }
6094
6095 if (!pTextObj) TEXTOBJ_UnlockText(TextObj);
6096
6097 ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->Font)) != 0);
6098
6099 return Status;
6100}
LPWSTR Name
Definition: desk.c:124
static VOID FASTCALL IntFontType(PFONTGDI Font)
Definition: freetype.c:5830
static __inline VOID FindBestFontFromList(FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
Definition: freetype.c:5761
static BOOL MatchFontNames(PSHARED_FACE SharedFace, LPCWSTR lfFaceName)
Definition: freetype.c:5885
static NTSTATUS IntGetFontLocalizedName(PUNICODE_STRING pNameW, PSHARED_FACE SharedFace, FT_UShort NameID, FT_UShort LangID)
Definition: freetype.c:3300
static BOOL SubstituteFontRecurse(PLOGFONTW pLogFont)
Definition: freetype.c:1140
#define TT_NAME_ID_FONT_FAMILY
Definition: font.c:3578
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
#define STATUS_NOT_FOUND
Definition: shellext.h:72
BYTE lfStrikeOut
Definition: dimm.idl:66
BYTE lfItalic
Definition: dimm.idl:64
LONG lfWeight
Definition: dimm.idl:63
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
BYTE lfUnderline
Definition: dimm.idl:65
BYTE lfCharSet
Definition: dimm.idl:67
BYTE RequestItalic
Definition: engobjects.h:154
LONG RequestWeight
Definition: engobjects.h:155
BYTE RequestStrikeOut
Definition: engobjects.h:153
FLONG flType
Definition: engobjects.h:142
BYTE RequestUnderline
Definition: engobjects.h:152
ULONG iUniq
Definition: winddi.h:762
FLONG flFontType
Definition: winddi.h:765
FLONG fl
Definition: text.h:65
WCHAR TextFace[LF_FACESIZE]
Definition: text.h:67
FORCEINLINE PTEXTOBJ TEXTOBJ_LockText(HFONT hfont)
Definition: text.h:83
#define TEXTOBJECT_INIT
Definition: text.h:56
VOID IntUnicodeStringToBuffer(_Out_ LPWSTR pszBuffer, _In_ SIZE_T cbBuffer, _In_ const UNICODE_STRING *pString)
Definition: utils.c:165
#define FW_DONTCARE
Definition: wingdi.h:368
#define FW_NORMAL
Definition: wingdi.h:373

Referenced by DC_hSelectFont(), DC_InitHack(), FontGetObject(), and RealizeFontInit().

◆ TextIntUpdateSize()

BOOL FASTCALL TextIntUpdateSize ( _In_ PTEXTOBJ  TextObj,
_In_ PFONTGDI  FontGDI,
_In_ BOOL  bDoLock 
)

Definition at line 4261 of file freetype.c.

4265{
4266 PLOGFONTW plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4267 FT_Face face = FontGDI->SharedFace->Face;
4269
4270 ASSERT(face->charmap);
4271
4272 if (bDoLock)
4274 else
4276
4277 error = IntRequestFontSize(FontGDI, plf->lfWidth, plf->lfHeight);
4278
4279 if (bDoLock)
4281
4282 if (error != FT_Err_Ok)
4283 DPRINT1("Error in setting pixel sizes: %d\n", error);
4284 return (error == FT_Err_Ok);
4285}
static FT_Error IntRequestFontSize(_Inout_ PFONTGDI FontGDI, _In_ LONG lfWidth, _In_ LONG lfHeight)
Definition: freetype.c:4244
return FT_Err_Ok
Definition: ftbbox.c:526
LONG lfHeight
Definition: wingdi.h:2343

Referenced by ftGdiGetGlyphOutline(), ftGdiGetTextMetricsW(), GreGetCharABCWidthsW(), GreGetCharWidthW(), IntExtTextOutW(), NtGdiGetOutlineTextMetricsInternalW(), and TextIntGetTextExtentPoint().

◆ TEXTOBJ_LockText()

FORCEINLINE PTEXTOBJ TEXTOBJ_LockText ( HFONT  hfont)

Definition at line 83 of file text.h.

84{
86 if (plfnt != 0)
87 {
90 }
91 return plfnt;
92}
static HFONT hfont
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1039
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define LFONT_ShareLockFont(hfont)
Definition: text.h:77

Referenced by RealizeFontInit(), and TextIntRealizeFont().

◆ TEXTOBJ_UnlockText()