ReactOS 0.4.17-dev-243-g1369312
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 (PTEXTOBJ, PFONTGDI, BOOL)
 
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 164 of file text.h.

◆ IntUnLockProcessPrivateFonts

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

Definition at line 167 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 5376 of file freetype.c.

5382{
5384 FT_Face Face = FontGdi->SharedFace->Face;
5385
5387
5388 if (FT_IS_SFNT(Face))
5389 {
5390 if (Table)
5391 Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
5392 (Table << 8 & 0xFF0000);
5393
5394 if (!Buffer) Size = 0;
5395
5396 if (Buffer && Size)
5397 {
5399 FT_ULong Needed = 0;
5400
5401 Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
5402
5403 if ( !Error && Needed < Size) Size = Needed;
5404 }
5405 if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
5406 Result = Size;
5407 }
5408
5410
5411 return Result;
5412}
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 4443 of file freetype.c.

4452{
4453 PDC_ATTR pdcattr;
4454 PTEXTOBJ TextObj;
4455 PFONTGDI FontGDI;
4456 HFONT hFont = 0;
4457 GLYPHMETRICS gm;
4458 ULONG Size;
4459 FT_Face ft_face;
4460 FT_UInt glyph_index;
4461 DWORD width, height, pitch, needed = 0;
4462 FT_Bitmap ft_bitmap;
4464 INT left, right, top = 0, bottom = 0;
4466 FLOATOBJ eM11, widthRatio, eTemp;
4467 FT_Matrix mat, transMat = identityMat;
4468 BOOL needsTransform = FALSE;
4469 INT orientation;
4470 LONG aveWidth;
4471 INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
4472 OUTLINETEXTMETRICW *potm;
4473 XFORMOBJ xo;
4474 XFORML xform;
4475 LOGFONTW *plf;
4476
4477 DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
4478 cjBuf, pvBuf, pmat2);
4479
4480 pdcattr = dc->pdcattr;
4481
4482 XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
4483 XFORMOBJ_iGetXform(&xo, &xform);
4484 FLOATOBJ_SetFloat(&eM11, xform.eM11);
4485
4486 hFont = pdcattr->hlfntNew;
4487 TextObj = RealizeFontInit(hFont);
4488
4489 if (!TextObj)
4490 {
4492 return GDI_ERROR;
4493 }
4494 FontGDI = ObjToGDI(TextObj->Font, FONT);
4495 ft_face = FontGDI->SharedFace->Face;
4496
4497 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4498 aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
4499 orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
4500
4502 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL, FALSE);
4503 if (!Size)
4504 {
4505 TEXTOBJ_UnlockText(TextObj);
4507 return GDI_ERROR;
4508 }
4510 if (!potm)
4511 {
4512 TEXTOBJ_UnlockText(TextObj);
4514 return GDI_ERROR;
4515 }
4517 Size = IntGetOutlineTextMetrics(FontGDI, Size, potm, FALSE);
4518 if (!Size)
4519 {
4521 TEXTOBJ_UnlockText(TextObj);
4523 return GDI_ERROR;
4524 }
4525
4527 TextIntUpdateSize(TextObj, FontGDI, FALSE);
4529 FT_Set_Transform(ft_face, &mat, NULL);
4530
4531 TEXTOBJ_UnlockText(TextObj);
4532
4533 glyph_index = get_glyph_index_flagged(ft_face, wch, (iFormat & GGO_GLYPH_INDEX));
4534 iFormat &= ~GGO_GLYPH_INDEX;
4535
4536 if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
4537 load_flags |= FT_LOAD_NO_BITMAP;
4538
4539 if (iFormat & GGO_UNHINTED)
4540 {
4541 load_flags |= FT_LOAD_NO_HINTING;
4542 iFormat &= ~GGO_UNHINTED;
4543 }
4544
4545 error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
4546 if (error)
4547 {
4548 DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
4550 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
4551 return GDI_ERROR;
4552 }
4554
4555 FLOATOBJ_Set1(&widthRatio);
4556 if (aveWidth && potm)
4557 {
4558 // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
4559 FLOATOBJ_SetLong(&widthRatio, aveWidth);
4560 FLOATOBJ_Mul(&widthRatio, &eM11);
4562 }
4563
4564 //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
4565 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
4566 FLOATOBJ_Mul(&eTemp, &widthRatio);
4567 left = FLOATOBJ_GetLong(&eTemp) & -64;
4568
4569 //right = (INT)((ft_face->glyph->metrics.horiBearingX +
4570 // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
4571 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
4572 FLOATOBJ_Mul(&eTemp, &widthRatio);
4573 FLOATOBJ_AddLong(&eTemp, 63);
4574 right = FLOATOBJ_GetLong(&eTemp) & -64;
4575
4576 //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
4577 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
4578 FLOATOBJ_Mul(&eTemp, &widthRatio);
4579 FLOATOBJ_AddLong(&eTemp, 63);
4580 adv = FLOATOBJ_GetLong(&eTemp) >> 6;
4581
4582 lsb = left >> 6;
4583 bbx = (right - left) >> 6;
4584
4585 DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
4586
4588
4589 /* Width scaling transform */
4590 if (!FLOATOBJ_Equal1(&widthRatio))
4591 {
4592 FT_Matrix scaleMat;
4593
4594 eTemp = widthRatio;
4595 FLOATOBJ_MulLong(&eTemp, 1 << 16);
4596
4597 scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
4598 scaleMat.xy = 0;
4599 scaleMat.yx = 0;
4600 scaleMat.yy = INT_TO_FIXED(1);
4601 FT_Matrix_Multiply(&scaleMat, &transMat);
4602 needsTransform = TRUE;
4603 }
4604
4605 /* World transform */
4606 {
4607 FT_Matrix ftmatrix;
4609
4610 /* Create a freetype matrix, by converting to 16.16 fixpoint format */
4611 IntMatrixFromMx(&ftmatrix, pmx);
4612
4613 if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
4614 {
4615 FT_Matrix_Multiply(&ftmatrix, &transMat);
4616 needsTransform = TRUE;
4617 }
4618 }
4619
4620 /* Rotation transform */
4621 if (orientation)
4622 {
4623 FT_Matrix rotationMat;
4624 DPRINT("Rotation Trans!\n");
4625 IntEscapeMatrix(&rotationMat, orientation);
4626 FT_Matrix_Multiply(&rotationMat, &transMat);
4627 needsTransform = TRUE;
4628 }
4629
4630 /* Extra transformation specified by caller */
4631 if (pmat2)
4632 {
4633 FT_Matrix extraMat;
4634 DPRINT("MAT2 Matrix Trans!\n");
4635 extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
4636 extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
4637 extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
4638 extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
4639 FT_Matrix_Multiply(&extraMat, &transMat);
4640 needsTransform = TRUE;
4641 }
4642
4643 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
4644
4645 if (!needsTransform)
4646 {
4647 DPRINT("No Need to be Transformed!\n");
4648 top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
4649 bottom = (ft_face->glyph->metrics.horiBearingY -
4650 ft_face->glyph->metrics.height) & -64;
4651 gm.gmCellIncX = adv;
4652 gm.gmCellIncY = 0;
4653 }
4654 else
4655 {
4656 INT xc, yc;
4657 FT_Vector vec;
4658 for (xc = 0; xc < 2; xc++)
4659 {
4660 for (yc = 0; yc < 2; yc++)
4661 {
4662 vec.x = (ft_face->glyph->metrics.horiBearingX +
4663 xc * ft_face->glyph->metrics.width);
4664 vec.y = ft_face->glyph->metrics.horiBearingY -
4665 yc * ft_face->glyph->metrics.height;
4666 DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
4667 FT_Vector_Transform(&vec, &transMat);
4668 if (xc == 0 && yc == 0)
4669 {
4670 left = right = vec.x;
4671 top = bottom = vec.y;
4672 }
4673 else
4674 {
4675 if (vec.x < left) left = vec.x;
4676 else if (vec.x > right) right = vec.x;
4677 if (vec.y < bottom) bottom = vec.y;
4678 else if (vec.y > top) top = vec.y;
4679 }
4680 }
4681 }
4682 left = left & -64;
4683 right = (right + 63) & -64;
4684 bottom = bottom & -64;
4685 top = (top + 63) & -64;
4686
4687 DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
4688 vec.x = ft_face->glyph->metrics.horiAdvance;
4689 vec.y = 0;
4690 FT_Vector_Transform(&vec, &transMat);
4691 gm.gmCellIncX = (vec.x+63) >> 6;
4692 gm.gmCellIncY = -((vec.y+63) >> 6);
4693 }
4694 gm.gmBlackBoxX = (right - left) >> 6;
4695 gm.gmBlackBoxY = (top - bottom) >> 6;
4696 gm.gmptGlyphOrigin.x = left >> 6;
4697 gm.gmptGlyphOrigin.y = top >> 6;
4698
4699 DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
4700 gm.gmCellIncX, gm.gmCellIncY,
4701 gm.gmBlackBoxX, gm.gmBlackBoxY,
4703
4705
4706 if (iFormat == GGO_METRICS)
4707 {
4708 DPRINT("GGO_METRICS Exit!\n");
4709 *pgm = gm;
4710 return 1; /* FIXME */
4711 }
4712
4713 if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
4714 {
4715 DPRINT1("Loaded a bitmap\n");
4716 return GDI_ERROR;
4717 }
4718
4719 switch (iFormat)
4720 {
4721 case GGO_BITMAP:
4722 {
4723 width = gm.gmBlackBoxX;
4724 height = gm.gmBlackBoxY;
4725 pitch = ((width + 31) >> 5) << 2;
4726 needed = pitch * height;
4727
4728 if (!pvBuf || !cjBuf) break;
4729 if (!needed) return GDI_ERROR; /* empty glyph */
4730 if (needed > cjBuf)
4731 return GDI_ERROR;
4732
4733 switch (ft_face->glyph->format)
4734 {
4736 {
4737 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4738 INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4739 INT h = min( height, ft_face->glyph->bitmap.rows );
4740 while (h--)
4741 {
4743 src += ft_face->glyph->bitmap.pitch;
4744 dst += pitch;
4745 }
4746 break;
4747 }
4748
4750 {
4751 ft_bitmap.width = width;
4752 ft_bitmap.rows = height;
4753 ft_bitmap.pitch = pitch;
4754 ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4755 ft_bitmap.buffer = pvBuf;
4756
4758 if (needsTransform)
4759 {
4760 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4761 }
4762 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4763 /* Note: FreeType will only set 'black' bits for us. */
4764 RtlZeroMemory(pvBuf, needed);
4765 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4767 break;
4768 }
4769
4770 default:
4771 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4772 return GDI_ERROR;
4773 }
4774
4775 break;
4776 }
4777
4778 case GGO_GRAY2_BITMAP:
4779 case GGO_GRAY4_BITMAP:
4780 case GGO_GRAY8_BITMAP:
4781 {
4782 unsigned int mult, row, col;
4783 BYTE *start, *ptr;
4784
4785 width = gm.gmBlackBoxX;
4786 height = gm.gmBlackBoxY;
4787 pitch = (width + 3) / 4 * 4;
4788 needed = pitch * height;
4789
4790 if (!pvBuf || !cjBuf) break;
4791 if (!needed) return GDI_ERROR; /* empty glyph */
4792 if (needed > cjBuf)
4793 return GDI_ERROR;
4794
4795 switch (ft_face->glyph->format)
4796 {
4798 {
4799 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4800 INT h = min( height, ft_face->glyph->bitmap.rows );
4801 INT x;
4802 while (h--)
4803 {
4804 for (x = 0; (UINT)x < pitch; x++)
4805 {
4806 if (x < ft_face->glyph->bitmap.width)
4807 dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4808 else
4809 dst[x] = 0;
4810 }
4811 src += ft_face->glyph->bitmap.pitch;
4812 dst += pitch;
4813 }
4814 break;
4815 }
4817 {
4818 ft_bitmap.width = width;
4819 ft_bitmap.rows = height;
4820 ft_bitmap.pitch = pitch;
4821 ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4822 ft_bitmap.buffer = pvBuf;
4823
4825 if (needsTransform)
4826 {
4827 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4828 }
4829 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4830 RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4831 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4833
4835 mult = 4;
4836 else if (iFormat == GGO_GRAY4_BITMAP)
4837 mult = 16;
4838 else if (iFormat == GGO_GRAY8_BITMAP)
4839 mult = 64;
4840 else
4841 {
4842 return GDI_ERROR;
4843 }
4844
4845 start = pvBuf;
4846 for (row = 0; row < height; row++)
4847 {
4848 ptr = start;
4849 for (col = 0; col < width; col++, ptr++)
4850 {
4851 *ptr = (((int)*ptr) * mult + 128) / 256;
4852 }
4853 start += pitch;
4854 }
4855
4856 break;
4857 }
4858 default:
4859 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4860 return GDI_ERROR;
4861 }
4862
4863 break;
4864 }
4865
4866 case GGO_NATIVE:
4867 {
4868 FT_Outline *outline = &ft_face->glyph->outline;
4869
4870 if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4871
4873 if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4874
4876
4877 if (!pvBuf || !cjBuf)
4878 {
4880 break;
4881 }
4882 if (needed > cjBuf)
4883 {
4885 return GDI_ERROR;
4886 }
4889 break;
4890 }
4891
4892 case GGO_BEZIER:
4893 {
4894 FT_Outline *outline = &ft_face->glyph->outline;
4895 if (cjBuf == 0) pvBuf = NULL;
4896
4897 if (needsTransform && pvBuf)
4898 {
4900 FT_Outline_Transform(outline, &transMat);
4902 }
4904
4905 if (!pvBuf || !cjBuf)
4906 break;
4907 if (needed > cjBuf)
4908 return GDI_ERROR;
4909
4911 break;
4912 }
4913
4914 default:
4915 DPRINT1("Unsupported format %u\n", iFormat);
4916 return GDI_ERROR;
4917 }
4918
4919 DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4920
4921 if (gm.gmBlackBoxX == 0)
4922 gm.gmBlackBoxX = 1;
4923 if (gm.gmBlackBoxY == 0)
4924 gm.gmBlackBoxY = 1;
4925
4926 *pgm = gm;
4927 return needed;
4928}
#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:2802
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:4331
#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:3834
static unsigned int get_native_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3761
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
BOOL FASTCALL TextIntUpdateSize(PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:4212
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm, BOOL bLocked)
Definition: freetype.c:3018
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
#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
unsigned int UINT
Definition: ndis.h:50
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 6394 of file freetype.c.

6397{
6398 DWORD Count = 0;
6399 INT i = 0;
6400 FT_Face face = Font->SharedFace->Face;
6401
6402 if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
6403 {
6404 FT_UInt previous_index = 0, glyph_index = 0;
6405 FT_ULong char_code, char_previous;
6406 FT_Vector delta;
6407
6408 char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
6409
6411
6412 while (glyph_index)
6413 {
6414 if (previous_index && glyph_index)
6415 {
6416 FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
6417
6418 if (pKerningPair && cPairs)
6419 {
6420 pKerningPair[i].wFirst = char_previous;
6421 pKerningPair[i].wSecond = char_code;
6422 pKerningPair[i].iKernAmount = delta.x;
6423 i++;
6424 if (i == cPairs) break;
6425 }
6426 Count++;
6427 }
6428 previous_index = glyph_index;
6429 char_previous = char_code;
6430 char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
6431 }
6433 }
6434 return Count;
6435}
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 3630 of file freetype.c.

3631{
3632 if ( lprs )
3633 {
3634 lprs->nSize = sizeof(RASTERIZER_STATUS);
3635 lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3636 lprs->nLanguageID = gusLanguageID;
3637 return TRUE;
3638 }
3640 return FALSE;
3641}
#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 5091 of file freetype.c.

5095{
5096 PDC_ATTR pdcattr;
5097 UINT Ret = DEFAULT_CHARSET;
5098 INT i;
5099 HFONT hFont;
5100 PTEXTOBJ TextObj;
5101 PFONTGDI FontGdi;
5103 TT_OS2 *pOS2;
5104 FT_Face Face;
5105 CHARSETINFO csi;
5106 DWORD cp, fs0;
5107 USHORT usACP, usOEM;
5108
5109 pdcattr = Dc->pdcattr;
5110 hFont = pdcattr->hlfntNew;
5111 TextObj = RealizeFontInit(hFont);
5112
5113 if (!TextObj)
5114 {
5116 return Ret;
5117 }
5118 FontGdi = ObjToGDI(TextObj->Font, FONT);
5119 Face = FontGdi->SharedFace->Face;
5120 TEXTOBJ_UnlockText(TextObj);
5121
5122 memset(&fs, 0, sizeof(FONTSIGNATURE));
5124 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
5125 if (NULL != pOS2)
5126 {
5127 fs.fsCsb[0] = pOS2->ulCodePageRange1;
5128 fs.fsCsb[1] = pOS2->ulCodePageRange2;
5129 fs.fsUsb[0] = pOS2->ulUnicodeRange1;
5130 fs.fsUsb[1] = pOS2->ulUnicodeRange2;
5131 fs.fsUsb[2] = pOS2->ulUnicodeRange3;
5132 fs.fsUsb[3] = pOS2->ulUnicodeRange4;
5133 if (pOS2->version == 0)
5134 {
5135 FT_UInt dummy;
5136
5137 if (FT_Get_First_Char( Face, &dummy ) < 0x100)
5138 fs.fsCsb[0] |= FS_LATIN1;
5139 else
5140 fs.fsCsb[0] |= FS_SYMBOL;
5141 }
5142 }
5143 pOS2 = NULL;
5145 DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
5146 if (fs.fsCsb[0] == 0)
5147 { /* Let's see if we can find any interesting cmaps */
5148 for (i = 0; i < Face->num_charmaps; i++)
5149 {
5150 switch (Face->charmaps[i]->encoding)
5151 {
5152 case FT_ENCODING_UNICODE:
5153 case FT_ENCODING_APPLE_ROMAN:
5154 fs.fsCsb[0] |= FS_LATIN1;
5155 break;
5156 case FT_ENCODING_MS_SYMBOL:
5157 fs.fsCsb[0] |= FS_SYMBOL;
5158 break;
5159 default:
5160 break;
5161 }
5162 }
5163 }
5164 if (lpSig)
5165 {
5166 RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
5167 }
5168
5169 RtlGetDefaultCodePage(&usACP, &usOEM);
5170 cp = usACP;
5171
5173 if (csi.fs.fsCsb[0] & fs.fsCsb[0])
5174 {
5175 DPRINT("Hit 1\n");
5176 Ret = csi.ciCharset;
5177 goto Exit;
5178 }
5179
5180 for (i = 0; i < MAXTCIINDEX; i++)
5181 {
5182 fs0 = 1L << i;
5183 if (fs.fsCsb[0] & fs0)
5184 {
5185 if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
5186 {
5187 // *cp = csi.ciACP;
5188 DPRINT("Hit 2\n");
5189 Ret = csi.ciCharset;
5190 goto Exit;
5191 }
5192 else
5193 DPRINT1("TCI failing on %x\n", fs0);
5194 }
5195 }
5196Exit:
5197 DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
5198 return (MAKELONG(csi.ciACP, csi.ciCharset));
5199}
#define MAXTCIINDEX
Definition: freetype.c:269
static BOOLEAN IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2654
#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 5278 of file freetype.c.

5281{
5282 PDC dc;
5283 PDC_ATTR pdcattr;
5284 PTEXTOBJ TextObj;
5285 PFONTGDI FontGDI;
5286 FT_Face Face;
5287 TT_OS2 *pOS2;
5288 TT_HoriHeader *pHori;
5290 ULONG Error;
5292 LOGFONTW *plf;
5293
5294 if (!ptmwi)
5295 {
5297 return FALSE;
5298 }
5299 RtlZeroMemory(ptmwi, sizeof(TMW_INTERNAL));
5300
5301 if (!(dc = DC_LockDc(hDC)))
5302 {
5304 return FALSE;
5305 }
5306 pdcattr = dc->pdcattr;
5307 TextObj = RealizeFontInit(pdcattr->hlfntNew);
5308 if (NULL != TextObj)
5309 {
5310 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
5311 FontGDI = ObjToGDI(TextObj->Font, FONT);
5312
5313 Face = FontGDI->SharedFace->Face;
5314
5315 // NOTE: GetTextMetrics simply ignores lfEscapement and XFORM.
5317 Error = IntRequestFontSize(FontGDI, plf->lfWidth, plf->lfHeight);
5318 FT_Set_Transform(Face, NULL, NULL);
5319
5321
5322 if (0 != Error)
5323 {
5324 DPRINT1("Error in setting pixel sizes: %u\n", Error);
5326 }
5327 else
5328 {
5330
5332
5333 Error = FT_Get_WinFNT_Header(Face, &Win);
5334 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
5335 pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
5336
5337 if (!pOS2 && Error)
5338 {
5339 DPRINT1("Can't find OS/2 table - not TT font?\n");
5341 }
5342
5343 if (!pHori && Error)
5344 {
5345 DPRINT1("Can't find HHEA table - not TT font?\n");
5347 }
5348
5349 if (NT_SUCCESS(Status))
5350 {
5351 FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, (Error ? NULL : &Win));
5352
5353 /* FIXME: Fill Diff member */
5354 }
5355
5357 }
5358 TEXTOBJ_UnlockText(TextObj);
5359 }
5360 else
5361 {
5363 }
5364 DC_UnlockDc(dc);
5365
5366 if (!NT_SUCCESS(Status))
5367 {
5369 return FALSE;
5370 }
5371 return TRUE;
5372}
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 FT_Error IntRequestFontSize(PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3959
static void FASTCALL FillTM(TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT)
Definition: freetype.c:2716
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
LONG lfHeight
Definition: dimm.idl:59
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 6375 of file freetype.c.

6376{
6377 if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
6378 Info->iTechnology = RI_TECH_BITMAP;
6379 else
6380 {
6381 if (FT_IS_SCALABLE(Font->SharedFace->Face))
6382 Info->iTechnology = RI_TECH_SCALABLE;
6383 else
6384 Info->iTechnology = RI_TECH_FIXED;
6385 }
6386 Info->iUniq = Font->FontObj.iUniq;
6387 Info->dwUnknown = -1;
6388 return TRUE;
6389}
#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 5204 of file freetype.c.

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

7228{
7229 BOOL bResult;
7230 DC *dc;
7231
7232 // TODO: Write test-cases to exactly match real Windows in different
7233 // bad parameters (e.g. does Windows check the DC or the RECT first?).
7234 dc = DC_LockDc(hDC);
7235 if (!dc)
7236 {
7238 return FALSE;
7239 }
7240
7241 bResult = IntExtTextOutW( dc,
7242 XStart,
7243 YStart,
7244 fuOptions,
7245 lprc,
7246 String,
7247 Count,
7248 Dx,
7249 dwCodePage );
7250
7251 DC_UnlockDc(dc);
7252
7253 return bResult;
7254}
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:6672
_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 7415 of file freetype.c.

7422{
7423 PABC SafeBuffI;
7424 PABCFLOAT SafeBuffF;
7425 PDC dc;
7426 PDC_ATTR pdcattr;
7427 PTEXTOBJ TextObj;
7428 PFONTGDI FontGDI;
7429 FT_Face face;
7430 UINT i, glyph_index;
7431 HFONT hFont = NULL;
7432 PLOGFONTW plf;
7433
7434 dc = DC_LockDc(hDC);
7435 if (dc == NULL)
7436 {
7438 return FALSE;
7439 }
7440
7441 pdcattr = dc->pdcattr;
7442 hFont = pdcattr->hlfntNew;
7443 TextObj = RealizeFontInit(hFont);
7444
7445 DC_UnlockDc(dc);
7446
7447 if (TextObj == NULL)
7448 {
7450 return FALSE;
7451 }
7452
7453 FontGDI = ObjToGDI(TextObj->Font, FONT);
7454
7455 face = FontGDI->SharedFace->Face;
7457 {
7458 TEXTOBJ_UnlockText(TextObj);
7460 return FALSE;
7461 }
7462
7463 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
7464
7465 // NOTE: GetCharABCWidths simply ignores lfEscapement and XFORM.
7467 IntRequestFontSize(FontGDI, plf->lfWidth, plf->lfHeight);
7469
7470 if (!fl)
7471 SafeBuffF = SafeBuffer;
7472 else
7473 SafeBuffI = SafeBuffer;
7474
7475 for (i = FirstChar; i < FirstChar+Count; i++)
7476 {
7477 int adv, lsb, bbx, left, right;
7478
7479 if (Safepwch)
7480 glyph_index = get_glyph_index_flagged(face, Safepwch[i - FirstChar], (fl & GCABCW_INDICES));
7481 else
7482 glyph_index = get_glyph_index_flagged(face, i, (fl & GCABCW_INDICES));
7483
7484 FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
7485
7486 left = (INT)face->glyph->metrics.horiBearingX & -64;
7487 right = (INT)((face->glyph->metrics.horiBearingX + face->glyph->metrics.width) + 63) & -64;
7488 adv = (face->glyph->advance.x + 32) >> 6;
7489
7490// int test = (INT)(face->glyph->metrics.horiAdvance + 63) >> 6;
7491// DPRINT1("Advance Wine %d and Advance Ros %d\n",test, adv ); /* It's the same! */
7492
7493 lsb = left >> 6;
7494 bbx = (right - left) >> 6;
7495 /*
7496 DPRINT1("lsb %d and bbx %d\n", lsb, bbx );
7497 */
7498 if (!fl)
7499 {
7500 SafeBuffF[i - FirstChar].abcfA = (FLOAT) lsb;
7501 SafeBuffF[i - FirstChar].abcfB = (FLOAT) bbx;
7502 SafeBuffF[i - FirstChar].abcfC = (FLOAT) (adv - lsb - bbx);
7503 }
7504 else
7505 {
7506 SafeBuffI[i - FirstChar].abcA = lsb;
7507 SafeBuffI[i - FirstChar].abcB = bbx;
7508 SafeBuffI[i - FirstChar].abcC = adv - lsb - bbx;
7509 }
7510 }
7511
7513 TEXTOBJ_UnlockText(TextObj);
7514
7515 return TRUE;
7516}
WORD face[3]
Definition: mesh.c:4747
static BOOL FASTCALL IntSelectFaceCharmap(FT_Face face)
Definition: freetype.c:7379
#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
LONG lfWidth
Definition: wingdi.h:2344
LONG lfHeight
Definition: wingdi.h:2343
_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 7522 of file freetype.c.

7529{
7530 PDC dc;
7531 PDC_ATTR pdcattr;
7532 PTEXTOBJ TextObj;
7533 PFONTGDI FontGDI;
7534 FT_Face face;
7535 UINT i, glyph_index;
7536 HFONT hFont = 0;
7537 LOGFONTW *plf;
7538 PINT SafeBuffI;
7539 PFLOAT SafeBuffF;
7540
7541 dc = DC_LockDc(hDC);
7542 if (dc == NULL)
7543 {
7545 return FALSE;
7546 }
7547
7548 pdcattr = dc->pdcattr;
7549 hFont = pdcattr->hlfntNew;
7550 TextObj = RealizeFontInit(hFont);
7551 DC_UnlockDc(dc);
7552
7553 if (TextObj == NULL)
7554 {
7556 return FALSE;
7557 }
7558
7559 FontGDI = ObjToGDI(TextObj->Font, FONT);
7560
7561 face = FontGDI->SharedFace->Face;
7563 {
7564 TEXTOBJ_UnlockText(TextObj);
7566 return FALSE;
7567 }
7568
7569 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
7570
7571 // NOTE: GetCharWidth simply ignores lfEscapement and XFORM.
7573 IntRequestFontSize(FontGDI, plf->lfWidth, plf->lfHeight);
7575
7576 if (!fl)
7577 SafeBuffF = (PFLOAT)Buffer;
7578 else
7579 SafeBuffI = (PINT)Buffer;
7580
7581 for (i = FirstChar; i < FirstChar+Count; i++)
7582 {
7583 if (Safepwc)
7584 glyph_index = get_glyph_index_flagged(face, Safepwc[i - FirstChar], (fl & GCW_INDICES));
7585 else
7586 glyph_index = get_glyph_index_flagged(face, i, (fl & GCW_INDICES));
7587
7588 FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
7589
7590 if (!fl)
7591 SafeBuffF[i - FirstChar] = (FLOAT) ((face->glyph->advance.x + 32) >> 6);
7592 else
7593 SafeBuffI[i - FirstChar] = (face->glyph->advance.x + 32) >> 6;
7594 }
7595
7597 TEXTOBJ_UnlockText(TextObj);
7598
7599 return TRUE;
7600}
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 7635 of file freetype.c.

7642{
7643 // FIXME: bSubset
7644 PDC dc = DC_LockDc(hdc);
7645 if (!dc)
7646 return GDI_ERROR;
7647
7648 PDC_ATTR pdcattr = dc->pdcattr;
7649 HFONT hFont = pdcattr->hlfntNew;
7650 PTEXTOBJ TextObj = RealizeFontInit(hFont);
7651 DC_UnlockDc(dc);
7652
7653 if (!TextObj)
7654 {
7655 DPRINT1("!TextObj\n");
7656 return GDI_ERROR;
7657 }
7658
7659 PFONTGDI FontGDI = ObjToGDI(TextObj->Font, FONT);
7660 FT_Face Face = FontGDI->SharedFace->Face;
7661 TEXTOBJ_UnlockText(TextObj);
7662
7663 if (cwc == 0)
7664 {
7665 // Only the exceptional query case (pwc == NULL && pgi == NULL && iMode == 0)
7666 // should return the number of glyphs. All other cwc == 0 cases must fail.
7667 if (!pwc && !pgi && !iMode)
7668 return Face->num_glyphs; // Returns number of glyphs
7669
7670 return GDI_ERROR;
7671 }
7672
7673 // Get default character
7674 WCHAR DefChar = 0xFFFF;
7675 if (!(iMode & GGI_MARK_NONEXISTING_GLYPHS) && IntGetFontDefaultChar(Face, &DefChar))
7676 {
7678 DefChar = get_glyph_index(Face, DefChar); // Convert to glyph index
7680 }
7681
7682 // Get glyph indices
7683 // NOTE: Windows GetGlyphIndices doesn't support Surrogate Pairs.
7685 for (INT i = 0; i < cwc; i++)
7686 {
7687 pgi[i] = get_glyph_index(Face, pwc[i]);
7688 if (pgi[i] == 0)
7689 pgi[i] = DefChar;
7690 }
7692
7693 return cwc;
7694}
static BOOL IntGetFontDefaultChar(_In_ FT_Face Face, _Out_ PWCHAR pDefChar)
Definition: freetype.c:7602
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:4316
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:5278
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:2255
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 2585 of file freetype.c.

2586{
2588}
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 2407 of file freetype.c.

2408{
2409 HANDLE Ret = NULL;
2411 PFONT_ENTRY_COLL_MEM EntryCollection;
2412 INT FaceCount;
2413
2415 if (!BufferCopy)
2416 {
2417 *pNumAdded = 0;
2418 return NULL;
2419 }
2420 RtlCopyMemory(BufferCopy, Buffer, dwSize);
2421
2422 RtlZeroMemory(&LoadFont, sizeof(LoadFont));
2423 LoadFont.Memory = SharedMem_Create(BufferCopy, dwSize, FALSE);
2424 LoadFont.Characteristics = FR_PRIVATE | FR_NOT_ENUM;
2425 RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
2427
2428 RtlFreeUnicodeString(&LoadFont.RegValueName);
2429
2430 /* Release our copy */
2434
2435 if (FaceCount > 0)
2436 {
2437 EntryCollection = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_ENTRY_COLL_MEM), TAG_FONT);
2438 if (EntryCollection)
2439 {
2441 EntryCollection->Entry = LoadFont.PrivateEntry;
2443 IntLockProcessPrivateFonts(Win32Process);
2444 EntryCollection->Handle = ULongToHandle(++Win32Process->PrivateMemFontHandleCount);
2445 InsertTailList(&Win32Process->PrivateMemFontListHead, &EntryCollection->ListEntry);
2446 IntUnLockProcessPrivateFonts(Win32Process);
2448 Ret = EntryCollection->Handle;
2449 }
2450 }
2451 *pNumAdded = FaceCount;
2452
2453 return Ret;
2454}
#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:1823
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:1183
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:286
UINT PrivateMemFontHandleCount
Definition: win32.h:287
#define IntLockProcessPrivateFonts(W32Process)
Definition: text.h:164
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:167

Referenced by NtGdiAddFontMemResourceEx().

◆ IntGdiAddFontResourceEx()

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

Definition at line 2076 of file freetype.c.

2081{
2082 PWSTR pchFile = FileName->Buffer;
2083 SIZE_T cchFile;
2084 INT ret = 0;
2085
2086 while (cFiles--)
2087 {
2088 _SEH2_TRY
2089 {
2090 cchFile = wcslen(pchFile);
2091 }
2093 {
2094 _SEH2_YIELD(return FALSE);
2095 }
2096 _SEH2_END;
2097
2098 UNICODE_STRING ustrPathName;
2099 ustrPathName.Length = (USHORT)(cchFile * sizeof(WCHAR));
2100 ustrPathName.MaximumLength = ustrPathName.Length + sizeof(WCHAR);
2101 ustrPathName.Buffer = pchFile;
2102
2103 INT count = IntGdiAddFontResourceSingle(&ustrPathName, Characteristics, dwFlags);
2104 if (!count)
2105 return 0;
2106 ret += count;
2107
2108 pchFile += cchFile + 1;
2109 }
2110
2111 return ret;
2112}
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
return ret
Definition: mutex.c:146
static INT FASTCALL IntGdiAddFontResourceSingle(_In_ PCUNICODE_STRING FileName, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
Definition: freetype.c:1877
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 2529 of file freetype.c.

2530{
2533 PFONT_ENTRY_COLL_MEM EntryCollection;
2534
2535 DPRINT("IntGdiCleanupPrivateFontsForProcess()\n");
2536 do {
2537 Entry = NULL;
2538 EntryCollection = NULL;
2539
2541 IntLockProcessPrivateFonts(Win32Process);
2542 if (!IsListEmpty(&Win32Process->PrivateMemFontListHead))
2543 {
2544 Entry = Win32Process->PrivateMemFontListHead.Flink;
2545 EntryCollection = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
2546 UnlinkFontMemCollection(EntryCollection);
2547 }
2548 IntUnLockProcessPrivateFonts(Win32Process);
2550
2551 if (EntryCollection)
2552 {
2553 IntGdiCleanupMemEntry(EntryCollection->Entry);
2554 ExFreePoolWithTag(EntryCollection, TAG_FONT);
2555 }
2556 else
2557 {
2558 /* No Mem fonts anymore, see if we have any other private fonts left */
2559 Entry = NULL;
2561 IntLockProcessPrivateFonts(Win32Process);
2562 if (!IsListEmpty(&Win32Process->PrivateFontListHead))
2563 {
2564 Entry = RemoveHeadList(&Win32Process->PrivateFontListHead);
2565 }
2566 IntUnLockProcessPrivateFonts(Win32Process);
2568
2569 if (Entry)
2570 {
2572 }
2573 }
2574
2575 } while (Entry);
2576}
VOID FASTCALL IntGdiCleanupMemEntry(PFONT_ENTRY_MEM Head)
Definition: freetype.c:2457
static VOID FASTCALL UnlinkFontMemCollection(PFONT_ENTRY_COLL_MEM Collection)
Definition: freetype.c:2476
Entry
Definition: section.c:5216
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY PrivateFontListHead
Definition: win32.h:285

Referenced by GdiProcessDestroy().

◆ IntGdiGetFontResourceInfo()

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

Definition at line 6107 of file freetype.c.

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

2494{
2496 PFONT_ENTRY_COLL_MEM CurrentEntry;
2497 PFONT_ENTRY_COLL_MEM EntryCollection = NULL;
2499
2501 IntLockProcessPrivateFonts(Win32Process);
2502 for (Entry = Win32Process->PrivateMemFontListHead.Flink;
2503 Entry != &Win32Process->PrivateMemFontListHead;
2504 Entry = Entry->Flink)
2505 {
2506 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
2507
2508 if (CurrentEntry->Handle == hMMFont)
2509 {
2510 EntryCollection = CurrentEntry;
2511 UnlinkFontMemCollection(CurrentEntry);
2512 break;
2513 }
2514 }
2515 IntUnLockProcessPrivateFonts(Win32Process);
2517
2518 if (EntryCollection)
2519 {
2520 IntGdiCleanupMemEntry(EntryCollection->Entry);
2521 ExFreePoolWithTag(EntryCollection, TAG_FONT);
2522 return TRUE;
2523 }
2524 return FALSE;
2525}

Referenced by NtGdiRemoveFontMemResourceEx().

◆ IntGdiRemoveFontResource()

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

Definition at line 2219 of file freetype.c.

2223{
2224 PWSTR pchFile = FileName->Buffer;
2225 SIZE_T cchFile;
2226
2227 while (cFiles--)
2228 {
2229 _SEH2_TRY
2230 {
2231 cchFile = wcslen(pchFile);
2232 }
2234 {
2235 _SEH2_YIELD(return FALSE);
2236 }
2237 _SEH2_END;
2238
2239 UNICODE_STRING ustrPathName;
2240 ustrPathName.Length = (USHORT)(cchFile * sizeof(WCHAR));
2241 ustrPathName.MaximumLength = ustrPathName.Length + sizeof(WCHAR);
2242 ustrPathName.Buffer = pchFile;
2243
2245 if (!ret)
2246 return FALSE;
2247
2248 pchFile += cchFile + 1;
2249 }
2250
2251 return TRUE;
2252}
static BOOL FASTCALL IntGdiRemoveFontResourceSingle(_In_ PCUNICODE_STRING FileName, _In_ DWORD dwFlags)
Definition: freetype.c:2150

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 3018 of file freetype.c.

3022{
3023 TT_OS2 *pOS2;
3024 TT_HoriHeader *pHori;
3025 TT_Postscript *pPost;
3026 FT_Fixed XScale, YScale;
3027 FT_WinFNT_HeaderRec WinFNT;
3029 BYTE *pb;
3030 FONT_NAMES FontNames;
3031 PSHARED_FACE SharedFace = FontGDI->SharedFace;
3032 PSHARED_FACE_CACHE Cache;
3033 FT_Face Face = SharedFace->Face;
3034
3035 if (bLocked)
3037 else
3039
3041 {
3042 Cache = &SharedFace->EnglishUS;
3043 }
3044 else
3045 {
3046 Cache = &SharedFace->UserLanguage;
3047 }
3048
3049 if (Size == 0 && Cache->OutlineRequiredSize > 0)
3050 {
3051 ASSERT(Otm == NULL);
3052 return Cache->OutlineRequiredSize;
3053 }
3054
3055 if (!bLocked)
3057
3058 IntInitFontNames(&FontNames, SharedFace);
3059 Cache->OutlineRequiredSize = FontNames.OtmSize;
3060
3061 if (Size == 0)
3062 {
3063 ASSERT(Otm == NULL);
3064 IntFreeFontNames(&FontNames);
3065 if (!bLocked)
3067 return Cache->OutlineRequiredSize;
3068 }
3069
3070 ASSERT(Otm != NULL);
3071
3072 if (Size < Cache->OutlineRequiredSize)
3073 {
3074 DPRINT1("Size %u < OutlineRequiredSize %u\n", Size,
3075 Cache->OutlineRequiredSize);
3076 IntFreeFontNames(&FontNames);
3077 if (!bLocked)
3079 return 0; /* failure */
3080 }
3081
3082 XScale = Face->size->metrics.x_scale;
3083 YScale = Face->size->metrics.y_scale;
3084
3085 pOS2 = FT_Get_Sfnt_Table(Face, FT_SFNT_OS2);
3086 pHori = FT_Get_Sfnt_Table(Face, FT_SFNT_HHEA);
3087 pPost = FT_Get_Sfnt_Table(Face, FT_SFNT_POST); /* We can live with this failing */
3088 Error = FT_Get_WinFNT_Header(Face, &WinFNT);
3089
3090 if (pOS2 == NULL && Error)
3091 {
3092 if (!bLocked)
3094 DPRINT1("Can't find OS/2 table - not TT font?\n");
3095 IntFreeFontNames(&FontNames);
3096 return 0;
3097 }
3098
3099 if (pHori == NULL && Error)
3100 {
3101 if (!bLocked)
3103 DPRINT1("Can't find HHEA table - not TT font?\n");
3104 IntFreeFontNames(&FontNames);
3105 return 0;
3106 }
3107
3108 Otm->otmSize = Cache->OutlineRequiredSize;
3109
3110 FillTM(&Otm->otmTextMetrics, FontGDI, pOS2, pHori, (Error ? NULL : &WinFNT));
3111
3112 if (!pOS2)
3113 goto skip_os2;
3114
3115 Otm->otmFiller = 0;
3117 Otm->otmfsSelection = pOS2->fsSelection;
3118 Otm->otmfsType = pOS2->fsType;
3119 Otm->otmsCharSlopeRise = pHori->caret_Slope_Rise;
3120 Otm->otmsCharSlopeRun = pHori->caret_Slope_Run;
3121 Otm->otmItalicAngle = 0; /* POST table */
3122 Otm->otmEMSquare = Face->units_per_EM;
3123
3124#define SCALE_X(value) ((FT_MulFix((value), XScale) + 32) >> 6)
3125#define SCALE_Y(value) ((FT_MulFix((value), YScale) + 32) >> 6)
3126
3127 Otm->otmAscent = SCALE_Y(pOS2->sTypoAscender);
3128 Otm->otmDescent = SCALE_Y(pOS2->sTypoDescender);
3129 Otm->otmLineGap = SCALE_Y(pOS2->sTypoLineGap);
3130 Otm->otmsCapEmHeight = SCALE_Y(pOS2->sCapHeight);
3131 Otm->otmsXHeight = SCALE_Y(pOS2->sxHeight);
3132 Otm->otmrcFontBox.left = SCALE_X(Face->bbox.xMin);
3133 Otm->otmrcFontBox.right = SCALE_X(Face->bbox.xMax);
3134 Otm->otmrcFontBox.top = SCALE_Y(Face->bbox.yMax);
3135 Otm->otmrcFontBox.bottom = SCALE_Y(Face->bbox.yMin);
3138 Otm->otmMacLineGap = Otm->otmLineGap;
3139 Otm->otmusMinimumPPEM = 0; /* TT Header */
3150
3151 if (!pPost)
3152 {
3153 Otm->otmsUnderscoreSize = 0;
3154 Otm->otmsUnderscorePosition = 0;
3155 }
3156 else
3157 {
3160 }
3161
3162#undef SCALE_X
3163#undef SCALE_Y
3164
3165skip_os2:
3166 if (!bLocked)
3168
3169 pb = IntStoreFontNames(&FontNames, Otm);
3170 ASSERT(pb - (BYTE*)Otm == Cache->OutlineRequiredSize);
3171
3172 IntFreeFontNames(&FontNames);
3173
3174 return Cache->OutlineRequiredSize;
3175}
BOOLEAN bLocked
Definition: Mke2fs.c:19
#define SCALE_Y(value)
static __inline void FASTCALL IntInitFontNames(FONT_NAMES *Names, PSHARED_FACE SharedFace)
Definition: freetype.c:2945
PBYTE FASTCALL IntStoreFontNames(_In_ const FONT_NAMES *Names, _Out_ OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2981
#define SCALE_X(value)
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:219
static __inline void FASTCALL IntFreeFontNames(FONT_NAMES *Names)
Definition: freetype.c:3005
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:2941
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 2579 of file freetype.c.

2580{
2581 return (gpsi->BitsPixel > 8) && g_RenderingEnabled;
2582}
PSERVERINFO gpsi
Definition: imm.c:18

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ IntLoadFontsInRegistry()

BOOL FASTCALL IntLoadFontsInRegistry ( VOID  )

Definition at line 2255 of file freetype.c.

2256{
2260 KEY_FULL_INFORMATION KeyFullInfo;
2261 ULONG i, Length;
2262 UNICODE_STRING FontTitleW, FileNameW;
2263 SIZE_T InfoSize;
2264 LPBYTE InfoBuffer;
2266 LPWSTR pchPath;
2268 INT nFontCount = 0;
2269 DWORD dwFlags;
2270
2271 /* open registry key */
2274 NULL, NULL);
2275 Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
2276 if (!NT_SUCCESS(Status))
2277 {
2278 DPRINT1("ZwOpenKey failed: 0x%08X\n", Status);
2279 return FALSE; /* failure */
2280 }
2281
2282 /* query count of values */
2283 Status = ZwQueryKey(KeyHandle, KeyFullInformation,
2284 &KeyFullInfo, sizeof(KeyFullInfo), &Length);
2285 if (!NT_SUCCESS(Status))
2286 {
2287 DPRINT1("ZwQueryKey failed: 0x%08X\n", Status);
2289 return FALSE; /* failure */
2290 }
2291
2292 /* allocate buffer */
2293 InfoSize = (MAX_PATH + 256) * sizeof(WCHAR);
2294 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2295 if (!InfoBuffer)
2296 {
2297 DPRINT1("ExAllocatePoolWithTag failed\n");
2299 return FALSE;
2300 }
2301
2302 /* for each value */
2303 for (i = 0; i < KeyFullInfo.Values; ++i)
2304 {
2305 /* get value name */
2306 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
2307 InfoBuffer, InfoSize, &Length);
2309 {
2310 /* too short buffer */
2311 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2312 InfoSize *= 2;
2313 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2314 if (!InfoBuffer)
2315 {
2316 DPRINT1("ExAllocatePoolWithTag failed\n");
2317 break;
2318 }
2319 /* try again */
2320 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
2321 InfoBuffer, InfoSize, &Length);
2322 }
2323 if (!NT_SUCCESS(Status))
2324 {
2325 DPRINT1("ZwEnumerateValueKey failed: 0x%08X\n", Status);
2326 break; /* failure */
2327 }
2328
2329 /* create FontTitleW string */
2330 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
2331 Length = pInfo->NameLength / sizeof(WCHAR);
2332 pInfo->Name[Length] = UNICODE_NULL; /* truncate */
2333 if (!RtlCreateUnicodeString(&FontTitleW, pInfo->Name))
2334 {
2336 DPRINT1("RtlCreateUnicodeString failed\n");
2337 break; /* failure */
2338 }
2339
2340 /* query value */
2341 Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation,
2342 InfoBuffer, InfoSize, &Length);
2344 {
2345 /* too short buffer */
2346 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2347 InfoSize *= 2;
2348 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2349 if (!InfoBuffer)
2350 {
2351 DPRINT1("ExAllocatePoolWithTag failed\n");
2352 break;
2353 }
2354 /* try again */
2355 Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation,
2356 InfoBuffer, InfoSize, &Length);
2357 }
2358 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
2359 if (!NT_SUCCESS(Status) || !pInfo->DataLength)
2360 {
2361 DPRINT1("ZwQueryValueKey failed: 0x%08X\n", Status);
2362 RtlFreeUnicodeString(&FontTitleW);
2363 break; /* failure */
2364 }
2365
2366 /* Build pchPath */
2367 pchPath = (LPWSTR)((PUCHAR)pInfo + pInfo->DataOffset);
2368 Length = pInfo->DataLength / sizeof(WCHAR);
2369 pchPath[Length] = UNICODE_NULL; /* truncate */
2370
2371 /* Load font(s) without writing registry */
2372 if (PathIsRelativeW(pchPath))
2373 {
2374 dwFlags = 0;
2376 L"\\SystemRoot\\Fonts\\%s", pchPath);
2377 }
2378 else
2379 {
2381 Status = RtlStringCbCopyW(szPath, sizeof(szPath), pchPath);
2382 }
2383
2384 if (NT_SUCCESS(Status))
2385 {
2386 RtlCreateUnicodeString(&FileNameW, szPath);
2387 nFontCount += IntGdiAddFontResourceEx(&FileNameW, 1, 0, dwFlags);
2388 RtlFreeUnicodeString(&FileNameW);
2389 }
2390
2391 RtlFreeUnicodeString(&FontTitleW);
2392 }
2393
2394 /* close now */
2396
2397 /* free memory block */
2398 if (InfoBuffer)
2399 {
2400 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2401 }
2402
2403 return (KeyFullInfo.Values != 0 && nFontCount != 0);
2404}
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:1030
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:2076
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:3942
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 2612 of file freetype.c.

2613{
2614 PLFONT plfont;
2615 LOGFONTW *plf;
2616
2617 ASSERT(lf);
2618 plfont = LFONT_AllocFontWithHandle();
2619 if (!plfont)
2620 {
2621 return STATUS_NO_MEMORY;
2622 }
2623
2624 ExInitializePushLock(&plfont->lock);
2625 *NewFont = plfont->BaseObject.hHmgr;
2626 plf = &plfont->logfont.elfEnumLogfontEx.elfLogFont;
2627 RtlCopyMemory(plf, lf, sizeof(LOGFONTW));
2628 if (lf->lfEscapement != lf->lfOrientation)
2629 {
2630 /* This should really depend on whether GM_ADVANCED is set */
2631 plf->lfOrientation = plf->lfEscapement;
2632 }
2633 LFONT_UnlockFont(plfont);
2634
2635 return STATUS_SUCCESS;
2636}
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 5993 of file freetype.c.

5994{
5996 PTEXTOBJ TextObj;
5997 PPROCESSINFO Win32Process;
5998 ULONG MatchPenalty;
5999 LOGFONTW *pLogFont;
6000 LOGFONTW SubstitutedLogFont;
6001
6003
6004 if (!pTextObj)
6005 {
6006 TextObj = TEXTOBJ_LockText(FontHandle);
6007 if (NULL == TextObj)
6008 {
6009 return STATUS_INVALID_HANDLE;
6010 }
6011
6012 if (TextObj->fl & TEXTOBJECT_INIT)
6013 {
6014 TEXTOBJ_UnlockText(TextObj);
6015 return STATUS_SUCCESS;
6016 }
6017 }
6018 else
6019 {
6020 TextObj = pTextObj;
6021 }
6022
6023 pLogFont = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
6024
6025 /* substitute */
6026 SubstitutedLogFont = *pLogFont;
6027 SubstituteFontRecurse(&SubstitutedLogFont);
6028 DPRINT("Font '%S,%u' is substituted by '%S,%u'.\n",
6029 pLogFont->lfFaceName, pLogFont->lfCharSet,
6030 SubstitutedLogFont.lfFaceName, SubstitutedLogFont.lfCharSet);
6031
6032 MatchPenalty = 0xFFFFFFFF;
6033 TextObj->Font = NULL;
6034
6035 Win32Process = PsGetCurrentProcessWin32Process();
6036
6037 /* Search private fonts */
6039 IntLockProcessPrivateFonts(Win32Process);
6040 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
6041 &Win32Process->PrivateFontListHead);
6042 IntUnLockProcessPrivateFonts(Win32Process);
6043
6044 /* Search system fonts */
6045 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
6046 &g_FontListHead);
6048
6049 if (NULL == TextObj->Font)
6050 {
6051 DPRINT1("Request font %S not found, no fonts loaded at all\n",
6052 pLogFont->lfFaceName);
6054 }
6055 else
6056 {
6058 PFONTGDI FontGdi = ObjToGDI(TextObj->Font, FONT);
6059 PSHARED_FACE SharedFace = FontGdi->SharedFace;
6060
6061 TextObj->TextFace[0] = UNICODE_NULL;
6063 if (MatchFontNames(SharedFace, SubstitutedLogFont.lfFaceName))
6064 {
6066 RtlStringCchCopyW(TextObj->TextFace, _countof(TextObj->TextFace), pLogFont->lfFaceName);
6067 }
6068 else
6069 {
6073 if (NT_SUCCESS(Status))
6074 {
6075 /* truncated copy */
6076 IntUnicodeStringToBuffer(TextObj->TextFace, sizeof(TextObj->TextFace), &Name);
6078 }
6079 }
6080
6081 // Need hdev, when freetype is loaded need to create DEVOBJ for
6082 // Consumer and Producer.
6083 TextObj->Font->iUniq = 1; // Now it can be cached.
6084 IntFontType(FontGdi);
6085 FontGdi->flType = TextObj->Font->flFontType;
6086 FontGdi->RequestUnderline = pLogFont->lfUnderline ? 0xFF : 0;
6087 FontGdi->RequestStrikeOut = pLogFont->lfStrikeOut ? 0xFF : 0;
6088 FontGdi->RequestItalic = pLogFont->lfItalic ? 0xFF : 0;
6089 if (pLogFont->lfWeight != FW_DONTCARE)
6090 FontGdi->RequestWeight = pLogFont->lfWeight;
6091 else
6092 FontGdi->RequestWeight = FW_NORMAL;
6093
6094 TextObj->fl |= TEXTOBJECT_INIT;
6096 }
6097
6098 if (!pTextObj) TEXTOBJ_UnlockText(TextObj);
6099
6100 ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->Font)) != 0);
6101
6102 return Status;
6103}
LPWSTR Name
Definition: desk.c:124
static VOID FASTCALL IntFontType(PFONTGDI Font)
Definition: freetype.c:5833
static __inline VOID FindBestFontFromList(FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
Definition: freetype.c:5764
static BOOL MatchFontNames(PSHARED_FACE SharedFace, LPCWSTR lfFaceName)
Definition: freetype.c:5888
static NTSTATUS IntGetFontLocalizedName(PUNICODE_STRING pNameW, PSHARED_FACE SharedFace, FT_UShort NameID, FT_UShort LangID)
Definition: freetype.c:3178
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 ( PTEXTOBJ  TextObj,
PFONTGDI  FontGDI,
BOOL  bDoLock 
)

Definition at line 4212 of file freetype.c.

4215{
4216 FT_Face face;
4217 INT error, n;
4218 FT_CharMap charmap, found;
4219 LOGFONTW *plf;
4220
4221 if (bDoLock)
4223 else
4225
4226 face = FontGDI->SharedFace->Face;
4227 if (face->charmap == NULL)
4228 {
4229 DPRINT("WARNING: No charmap selected!\n");
4230 DPRINT("This font face has %d charmaps\n", face->num_charmaps);
4231
4232 found = NULL;
4233 for (n = 0; n < face->num_charmaps; n++)
4234 {
4235 charmap = face->charmaps[n];
4236 if (charmap->encoding == FT_ENCODING_UNICODE)
4237 {
4238 found = charmap;
4239 break;
4240 }
4241 }
4242 if (!found)
4243 {
4244 for (n = 0; n < face->num_charmaps; n++)
4245 {
4246 charmap = face->charmaps[n];
4247 if (charmap->platform_id == TT_PLATFORM_APPLE_UNICODE)
4248 {
4249 found = charmap;
4250 break;
4251 }
4252 }
4253 }
4254 if (!found)
4255 {
4256 for (n = 0; n < face->num_charmaps; n++)
4257 {
4258 charmap = face->charmaps[n];
4259 if (charmap->encoding == FT_ENCODING_MS_SYMBOL)
4260 {
4261 found = charmap;
4262 break;
4263 }
4264 }
4265 }
4266 if (!found && face->num_charmaps > 0)
4267 {
4268 found = face->charmaps[0];
4269 }
4270 if (!found)
4271 {
4272 DPRINT1("WARNING: Could not find desired charmap!\n");
4273 }
4274 else
4275 {
4276 DPRINT("Found charmap encoding: %i\n", found->encoding);
4277 error = FT_Set_Charmap(face, found);
4278 if (error)
4279 {
4280 DPRINT1("WARNING: Could not set the charmap!\n");
4281 }
4282 }
4283 }
4284
4285 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4286
4287 error = IntRequestFontSize(FontGDI, plf->lfWidth, plf->lfHeight);
4288
4289 if (bDoLock)
4291
4292 if (error)
4293 {
4294 DPRINT1("Error in setting pixel sizes: %d\n", error);
4295 return FALSE;
4296 }
4297
4298 return TRUE;
4299}
#define TT_PLATFORM_APPLE_UNICODE
Definition: font.c:1130
FT_Set_Charmap(FT_Face face, FT_CharMap charmap)
Definition: ftobjs.c:3564
GLdouble n
Definition: glext.h:7729
FT_UShort platform_id
Definition: freetype.h:821

Referenced by ftGdiGetGlyphOutline(), 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()