ReactOS 0.4.16-dev-2613-g9533ad7
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 (PDC, 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 5377 of file freetype.c.

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

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

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

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

5282{
5283 PDC dc;
5284 PDC_ATTR pdcattr;
5285 PTEXTOBJ TextObj;
5286 PFONTGDI FontGDI;
5287 FT_Face Face;
5288 TT_OS2 *pOS2;
5289 TT_HoriHeader *pHori;
5291 ULONG Error;
5293 LOGFONTW *plf;
5294
5295 if (!ptmwi)
5296 {
5298 return FALSE;
5299 }
5300 RtlZeroMemory(ptmwi, sizeof(TMW_INTERNAL));
5301
5302 if (!(dc = DC_LockDc(hDC)))
5303 {
5305 return FALSE;
5306 }
5307 pdcattr = dc->pdcattr;
5308 TextObj = RealizeFontInit(pdcattr->hlfntNew);
5309 if (NULL != TextObj)
5310 {
5311 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
5312 FontGDI = ObjToGDI(TextObj->Font, FONT);
5313
5314 Face = FontGDI->SharedFace->Face;
5315
5316 // NOTE: GetTextMetrics simply ignores lfEscapement and XFORM.
5318 Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
5319 FT_Set_Transform(Face, NULL, NULL);
5320
5322
5323 if (0 != Error)
5324 {
5325 DPRINT1("Error in setting pixel sizes: %u\n", Error);
5327 }
5328 else
5329 {
5331
5333
5334 Error = FT_Get_WinFNT_Header(Face, &Win);
5335 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
5336 pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
5337
5338 if (!pOS2 && Error)
5339 {
5340 DPRINT1("Can't find OS/2 table - not TT font?\n");
5342 }
5343
5344 if (!pHori && Error)
5345 {
5346 DPRINT1("Can't find HHEA table - not TT font?\n");
5348 }
5349
5350 if (NT_SUCCESS(Status))
5351 {
5352 FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, (Error ? NULL : &Win));
5353
5354 /* FIXME: Fill Diff member */
5355 }
5356
5358 }
5359 TEXTOBJ_UnlockText(TextObj);
5360 }
5361 else
5362 {
5364 }
5365 DC_UnlockDc(dc);
5366
5367 if (!NT_SUCCESS(Status))
5368 {
5370 return FALSE;
5371 }
5372 return TRUE;
5373}
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(PDC dc, 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:25
#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:31

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

◆ ftGdiRealizationInfo()

BOOL FASTCALL ftGdiRealizationInfo ( PFONTGDI  Font,
PREALIZATION_INFO  Info 
)

Definition at line 6376 of file freetype.c.

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

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

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

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

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

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

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

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

Definition at line 4212 of file freetype.c.

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