ReactOS 0.4.16-dev-1453-g06343fa
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)
 

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

1064{
1065 PLIST_ENTRY pHead, pEntry;
1066 PFONT_CACHE_ENTRY pFontCache;
1067 PFONTSUBST_ENTRY pSubstEntry;
1068 PFONT_ENTRY pFontEntry;
1069
1070 // Cleanup the FontLink cache
1072
1073 // Free font cache list
1074 pHead = &g_FontCacheListHead;
1075 while (!IsListEmpty(pHead))
1076 {
1077 pEntry = RemoveHeadList(pHead);
1078 pFontCache = CONTAINING_RECORD(pEntry, FONT_CACHE_ENTRY, ListEntry);
1079 RemoveCachedEntry(pFontCache);
1080 }
1081
1082 // Free font subst list
1083 pHead = &g_FontSubstListHead;
1084 while (!IsListEmpty(pHead))
1085 {
1086 pEntry = RemoveHeadList(pHead);
1087 pSubstEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
1088 ExFreePoolWithTag(pSubstEntry, TAG_FONT);
1089 }
1090
1091 // Free font list
1092 pHead = &g_FontListHead;
1093 while (!IsListEmpty(pHead))
1094 {
1095 pEntry = RemoveHeadList(pHead);
1096 pFontEntry = CONTAINING_RECORD(pEntry, FONT_ENTRY, ListEntry);
1097 CleanupFontEntry(pFontEntry);
1098 }
1099
1101 {
1104 }
1105
1108}
#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:369
FT_Library g_FreeTypeLibrary
Definition: freetype.c:360
static VOID FontLink_CleanupCache(VOID)
Definition: freetype.c:312
static __inline VOID FASTCALL CleanupFontEntry(PFONT_ENTRY FontEntry)
Definition: freetype.c:722
static void RemoveCachedEntry(PFONT_CACHE_ENTRY Entry)
Definition: freetype.c:617
FT_Done_Library(FT_Library library)
Definition: ftobjs.c:5333
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 5562 of file freetype.c.

5568{
5570 FT_Face Face = FontGdi->SharedFace->Face;
5571
5573
5574 if (FT_IS_SFNT(Face))
5575 {
5576 if (Table)
5577 Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
5578 (Table << 8 & 0xFF0000);
5579
5580 if (!Buffer) Size = 0;
5581
5582 if (Buffer && Size)
5583 {
5585 FT_ULong Needed = 0;
5586
5587 Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
5588
5589 if ( !Error && Needed < Size) Size = Needed;
5590 }
5591 if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
5592 Result = Size;
5593 }
5594
5596
5597 return Result;
5598}
BOOL Error
Definition: chkdsk.c:66
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IntUnLockFreeType()
Definition: freetype.c:386
#define IntLockFreeType()
Definition: freetype.c:380
#define FT_IS_SFNT(face)
Definition: freetype.h:1303
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:4177
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#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 4626 of file freetype.c.

4635{
4636 PDC_ATTR pdcattr;
4637 PTEXTOBJ TextObj;
4638 PFONTGDI FontGDI;
4639 HFONT hFont = 0;
4640 GLYPHMETRICS gm;
4641 ULONG Size;
4642 FT_Face ft_face;
4643 FT_UInt glyph_index;
4644 DWORD width, height, pitch, needed = 0;
4645 FT_Bitmap ft_bitmap;
4647 INT left, right, top = 0, bottom = 0;
4649 FLOATOBJ eM11, widthRatio, eTemp;
4650 FT_Matrix mat, transMat = identityMat;
4651 BOOL needsTransform = FALSE;
4652 INT orientation;
4653 LONG aveWidth;
4654 INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
4655 OUTLINETEXTMETRICW *potm;
4656 XFORMOBJ xo;
4657 XFORML xform;
4658 LOGFONTW *plf;
4659
4660 DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
4661 cjBuf, pvBuf, pmat2);
4662
4663 pdcattr = dc->pdcattr;
4664
4665 XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
4666 XFORMOBJ_iGetXform(&xo, &xform);
4667 FLOATOBJ_SetFloat(&eM11, xform.eM11);
4668
4669 hFont = pdcattr->hlfntNew;
4670 TextObj = RealizeFontInit(hFont);
4671
4672 if (!TextObj)
4673 {
4675 return GDI_ERROR;
4676 }
4677 FontGDI = ObjToGDI(TextObj->Font, FONT);
4678 ft_face = FontGDI->SharedFace->Face;
4679
4680 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4681 aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
4682 orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
4683
4685 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL, FALSE);
4686 if (!Size)
4687 {
4688 TEXTOBJ_UnlockText(TextObj);
4690 return GDI_ERROR;
4691 }
4693 if (!potm)
4694 {
4695 TEXTOBJ_UnlockText(TextObj);
4697 return GDI_ERROR;
4698 }
4700 Size = IntGetOutlineTextMetrics(FontGDI, Size, potm, FALSE);
4701 if (!Size)
4702 {
4704 TEXTOBJ_UnlockText(TextObj);
4706 return GDI_ERROR;
4707 }
4708
4710 TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
4712 FT_Set_Transform(ft_face, &mat, NULL);
4713
4714 TEXTOBJ_UnlockText(TextObj);
4715
4716 glyph_index = get_glyph_index_flagged(ft_face, wch, (iFormat & GGO_GLYPH_INDEX));
4717 iFormat &= ~GGO_GLYPH_INDEX;
4718
4719 if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
4720 load_flags |= FT_LOAD_NO_BITMAP;
4721
4722 if (iFormat & GGO_UNHINTED)
4723 {
4724 load_flags |= FT_LOAD_NO_HINTING;
4725 iFormat &= ~GGO_UNHINTED;
4726 }
4727
4728 error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
4729 if (error)
4730 {
4731 DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
4733 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
4734 return GDI_ERROR;
4735 }
4737
4738 FLOATOBJ_Set1(&widthRatio);
4739 if (aveWidth && potm)
4740 {
4741 // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
4742 FLOATOBJ_SetLong(&widthRatio, aveWidth);
4743 FLOATOBJ_Mul(&widthRatio, &eM11);
4745 }
4746
4747 //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
4748 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
4749 FLOATOBJ_Mul(&eTemp, &widthRatio);
4750 left = FLOATOBJ_GetLong(&eTemp) & -64;
4751
4752 //right = (INT)((ft_face->glyph->metrics.horiBearingX +
4753 // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
4754 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
4755 FLOATOBJ_Mul(&eTemp, &widthRatio);
4756 FLOATOBJ_AddLong(&eTemp, 63);
4757 right = FLOATOBJ_GetLong(&eTemp) & -64;
4758
4759 //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
4760 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
4761 FLOATOBJ_Mul(&eTemp, &widthRatio);
4762 FLOATOBJ_AddLong(&eTemp, 63);
4763 adv = FLOATOBJ_GetLong(&eTemp) >> 6;
4764
4765 lsb = left >> 6;
4766 bbx = (right - left) >> 6;
4767
4768 DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
4769
4771
4772 /* Width scaling transform */
4773 if (!FLOATOBJ_Equal1(&widthRatio))
4774 {
4775 FT_Matrix scaleMat;
4776
4777 eTemp = widthRatio;
4778 FLOATOBJ_MulLong(&eTemp, 1 << 16);
4779
4780 scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
4781 scaleMat.xy = 0;
4782 scaleMat.yx = 0;
4783 scaleMat.yy = INT_TO_FIXED(1);
4784 FT_Matrix_Multiply(&scaleMat, &transMat);
4785 needsTransform = TRUE;
4786 }
4787
4788 /* World transform */
4789 {
4790 FT_Matrix ftmatrix;
4792
4793 /* Create a freetype matrix, by converting to 16.16 fixpoint format */
4794 IntMatrixFromMx(&ftmatrix, pmx);
4795
4796 if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
4797 {
4798 FT_Matrix_Multiply(&ftmatrix, &transMat);
4799 needsTransform = TRUE;
4800 }
4801 }
4802
4803 /* Rotation transform */
4804 if (orientation)
4805 {
4806 FT_Matrix rotationMat;
4807 DPRINT("Rotation Trans!\n");
4808 IntEscapeMatrix(&rotationMat, orientation);
4809 FT_Matrix_Multiply(&rotationMat, &transMat);
4810 needsTransform = TRUE;
4811 }
4812
4813 /* Extra transformation specified by caller */
4814 if (pmat2)
4815 {
4816 FT_Matrix extraMat;
4817 DPRINT("MAT2 Matrix Trans!\n");
4818 extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
4819 extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
4820 extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
4821 extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
4822 FT_Matrix_Multiply(&extraMat, &transMat);
4823 needsTransform = TRUE;
4824 }
4825
4826 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
4827
4828 if (!needsTransform)
4829 {
4830 DPRINT("No Need to be Transformed!\n");
4831 top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
4832 bottom = (ft_face->glyph->metrics.horiBearingY -
4833 ft_face->glyph->metrics.height) & -64;
4834 gm.gmCellIncX = adv;
4835 gm.gmCellIncY = 0;
4836 }
4837 else
4838 {
4839 INT xc, yc;
4840 FT_Vector vec;
4841 for (xc = 0; xc < 2; xc++)
4842 {
4843 for (yc = 0; yc < 2; yc++)
4844 {
4845 vec.x = (ft_face->glyph->metrics.horiBearingX +
4846 xc * ft_face->glyph->metrics.width);
4847 vec.y = ft_face->glyph->metrics.horiBearingY -
4848 yc * ft_face->glyph->metrics.height;
4849 DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
4850 FT_Vector_Transform(&vec, &transMat);
4851 if (xc == 0 && yc == 0)
4852 {
4853 left = right = vec.x;
4854 top = bottom = vec.y;
4855 }
4856 else
4857 {
4858 if (vec.x < left) left = vec.x;
4859 else if (vec.x > right) right = vec.x;
4860 if (vec.y < bottom) bottom = vec.y;
4861 else if (vec.y > top) top = vec.y;
4862 }
4863 }
4864 }
4865 left = left & -64;
4866 right = (right + 63) & -64;
4867 bottom = bottom & -64;
4868 top = (top + 63) & -64;
4869
4870 DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
4871 vec.x = ft_face->glyph->metrics.horiAdvance;
4872 vec.y = 0;
4873 FT_Vector_Transform(&vec, &transMat);
4874 gm.gmCellIncX = (vec.x+63) >> 6;
4875 gm.gmCellIncY = -((vec.y+63) >> 6);
4876 }
4877 gm.gmBlackBoxX = (right - left) >> 6;
4878 gm.gmBlackBoxY = (top - bottom) >> 6;
4879 gm.gmptGlyphOrigin.x = left >> 6;
4880 gm.gmptGlyphOrigin.y = top >> 6;
4881
4882 DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
4883 gm.gmCellIncX, gm.gmCellIncY,
4884 gm.gmBlackBoxX, gm.gmBlackBoxY,
4886
4888
4889 if (iFormat == GGO_METRICS)
4890 {
4891 DPRINT("GGO_METRICS Exit!\n");
4892 *pgm = gm;
4893 return 1; /* FIXME */
4894 }
4895
4896 if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
4897 {
4898 DPRINT1("Loaded a bitmap\n");
4899 return GDI_ERROR;
4900 }
4901
4902 switch (iFormat)
4903 {
4904 case GGO_BITMAP:
4905 {
4906 width = gm.gmBlackBoxX;
4907 height = gm.gmBlackBoxY;
4908 pitch = ((width + 31) >> 5) << 2;
4909 needed = pitch * height;
4910
4911 if (!pvBuf || !cjBuf) break;
4912 if (!needed) return GDI_ERROR; /* empty glyph */
4913 if (needed > cjBuf)
4914 return GDI_ERROR;
4915
4916 switch (ft_face->glyph->format)
4917 {
4919 {
4920 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4921 INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4922 INT h = min( height, ft_face->glyph->bitmap.rows );
4923 while (h--)
4924 {
4926 src += ft_face->glyph->bitmap.pitch;
4927 dst += pitch;
4928 }
4929 break;
4930 }
4931
4933 {
4934 ft_bitmap.width = width;
4935 ft_bitmap.rows = height;
4936 ft_bitmap.pitch = pitch;
4937 ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4938 ft_bitmap.buffer = pvBuf;
4939
4941 if (needsTransform)
4942 {
4943 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4944 }
4945 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4946 /* Note: FreeType will only set 'black' bits for us. */
4947 RtlZeroMemory(pvBuf, needed);
4948 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4950 break;
4951 }
4952
4953 default:
4954 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4955 return GDI_ERROR;
4956 }
4957
4958 break;
4959 }
4960
4961 case GGO_GRAY2_BITMAP:
4962 case GGO_GRAY4_BITMAP:
4963 case GGO_GRAY8_BITMAP:
4964 {
4965 unsigned int mult, row, col;
4966 BYTE *start, *ptr;
4967
4968 width = gm.gmBlackBoxX;
4969 height = gm.gmBlackBoxY;
4970 pitch = (width + 3) / 4 * 4;
4971 needed = pitch * height;
4972
4973 if (!pvBuf || !cjBuf) break;
4974 if (!needed) return GDI_ERROR; /* empty glyph */
4975 if (needed > cjBuf)
4976 return GDI_ERROR;
4977
4978 switch (ft_face->glyph->format)
4979 {
4981 {
4982 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4983 INT h = min( height, ft_face->glyph->bitmap.rows );
4984 INT x;
4985 while (h--)
4986 {
4987 for (x = 0; (UINT)x < pitch; x++)
4988 {
4989 if (x < ft_face->glyph->bitmap.width)
4990 dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4991 else
4992 dst[x] = 0;
4993 }
4994 src += ft_face->glyph->bitmap.pitch;
4995 dst += pitch;
4996 }
4997 break;
4998 }
5000 {
5001 ft_bitmap.width = width;
5002 ft_bitmap.rows = height;
5003 ft_bitmap.pitch = pitch;
5004 ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
5005 ft_bitmap.buffer = pvBuf;
5006
5008 if (needsTransform)
5009 {
5010 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
5011 }
5012 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
5013 RtlZeroMemory(ft_bitmap.buffer, cjBuf);
5014 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
5016
5018 mult = 4;
5019 else if (iFormat == GGO_GRAY4_BITMAP)
5020 mult = 16;
5021 else if (iFormat == GGO_GRAY8_BITMAP)
5022 mult = 64;
5023 else
5024 {
5025 return GDI_ERROR;
5026 }
5027
5028 start = pvBuf;
5029 for (row = 0; row < height; row++)
5030 {
5031 ptr = start;
5032 for (col = 0; col < width; col++, ptr++)
5033 {
5034 *ptr = (((int)*ptr) * mult + 128) / 256;
5035 }
5036 start += pitch;
5037 }
5038
5039 break;
5040 }
5041 default:
5042 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
5043 return GDI_ERROR;
5044 }
5045
5046 break;
5047 }
5048
5049 case GGO_NATIVE:
5050 {
5051 FT_Outline *outline = &ft_face->glyph->outline;
5052
5053 if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
5054
5056 if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
5057
5059
5060 if (!pvBuf || !cjBuf)
5061 {
5063 break;
5064 }
5065 if (needed > cjBuf)
5066 {
5068 return GDI_ERROR;
5069 }
5072 break;
5073 }
5074
5075 case GGO_BEZIER:
5076 {
5077 FT_Outline *outline = &ft_face->glyph->outline;
5078 if (cjBuf == 0) pvBuf = NULL;
5079
5080 if (needsTransform && pvBuf)
5081 {
5083 FT_Outline_Transform(outline, &transMat);
5085 }
5087
5088 if (!pvBuf || !cjBuf)
5089 break;
5090 if (needed > cjBuf)
5091 return GDI_ERROR;
5092
5094 break;
5095 }
5096
5097 default:
5098 DPRINT1("Unsupported format %u\n", iFormat);
5099 return GDI_ERROR;
5100 }
5101
5102 DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
5103
5104 if (gm.gmBlackBoxX == 0)
5105 gm.gmBlackBoxX = 1;
5106 if (gm.gmBlackBoxY == 0)
5107 gm.gmBlackBoxY = 1;
5108
5109 *pgm = gm;
5110 return needed;
5111}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#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
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:4417
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, BOOL fCodeAsIndex)
Definition: freetype.c:4535
#define ASSERT_FREETYPE_LOCK_NOT_HELD()
Definition: freetype.c:377
static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:4152
static unsigned int get_native_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:4079
static VOID FASTCALL IntMatrixFromMx(FT_Matrix *pmat, const MATRIX *pmx)
Definition: freetype.c:1131
static VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
Definition: freetype.c:1118
static const FT_Matrix identityMat
Definition: freetype.c:354
static __inline FT_Fixed FT_FixedFromFIXED(FIXED f)
Definition: freetype.c:742
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm, BOOL bLocked)
Definition: freetype.c:3264
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:797
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3030
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:690
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3028
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1284
#define FT_LOAD_DEFAULT
Definition: freetype.h:3026
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
Definition: freetype.h:3035
FT_Vector_Transform(FT_Vector *vector, const FT_Matrix *matrix)
Definition: ftoutln.c:675
FT_Vector * vec
Definition: ftbbox.c:470
#define INT_TO_FIXED(x)
Definition: ftcalc.h:448
FT_Matrix_Multiply(const FT_Matrix *a, FT_Matrix *b)
Definition: ftcalc.c:661
#define ft_glyph_format_bitmap
Definition: ftimage.h:752
@ FT_PIXEL_MODE_MONO
Definition: ftimage.h:184
@ FT_PIXEL_MODE_GRAY
Definition: ftimage.h:185
#define ft_glyph_format_outline
Definition: ftimage.h:753
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:509
FT_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap *abitmap)
Definition: ftoutln.c:648
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:698
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:264
unsigned char * buffer
Definition: ftimage.h:266
unsigned char pixel_mode
Definition: ftimage.h:268
unsigned int rows
Definition: ftimage.h:263
int pitch
Definition: ftimage.h:265
FT_GlyphSlot glyph
Definition: freetype.h:1078
FT_Bitmap bitmap
Definition: freetype.h:1892
FT_Outline outline
Definition: freetype.h:1896
FT_Glyph_Metrics metrics
Definition: freetype.h:1885
FT_Glyph_Format format
Definition: freetype.h:1890
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:78
FT_Pos y
Definition: ftimage.h:79
LONG lfOrientation
Definition: dimm.idl:62
LONG lfWidth
Definition: dimm.idl:60
HANDLE hlfntNew
Definition: ntgdihdl.h:330
short gmCellIncX
Definition: wingdi.h:2445
UINT gmBlackBoxY
Definition: wingdi.h:2443
UINT gmBlackBoxX
Definition: wingdi.h:2442
short gmCellIncY
Definition: wingdi.h:2446
POINT gmptGlyphOrigin
Definition: wingdi.h:2444
Definition: text.h:60
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
FONTOBJ * Font
Definition: text.h:66
FIXED eM22
Definition: wingdi.h:2476
FIXED eM21
Definition: wingdi.h:2475
FIXED eM11
Definition: wingdi.h:2473
FIXED eM12
Definition: wingdi.h:2474
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2514
FLOATL eM11
Definition: winddi.h:1234
Definition: mesh.c:5330
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2779
LOGFONTW elfLogFont
Definition: wingdi.h:2702
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG tmAveCharWidth
Definition: wingdi.h:2388
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:431
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:134
#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 6581 of file freetype.c.

6584{
6585 DWORD Count = 0;
6586 INT i = 0;
6587 FT_Face face = Font->SharedFace->Face;
6588
6589 if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
6590 {
6591 FT_UInt previous_index = 0, glyph_index = 0;
6592 FT_ULong char_code, char_previous;
6593 FT_Vector delta;
6594
6595 char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
6596
6598
6599 while (glyph_index)
6600 {
6601 if (previous_index && glyph_index)
6602 {
6603 FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
6604
6605 if (pKerningPair && cPairs)
6606 {
6607 pKerningPair[i].wFirst = char_previous;
6608 pKerningPair[i].wSecond = char_code;
6609 pKerningPair[i].iKernAmount = delta.x;
6610 i++;
6611 if (i == cPairs) break;
6612 }
6613 Count++;
6614 }
6615 previous_index = glyph_index;
6616 char_previous = char_code;
6617 char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
6618 }
6620 }
6621 return Count;
6622}
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3740
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3765
FT_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning)
Definition: ftobjs.c:3391
@ FT_KERNING_DEFAULT
Definition: freetype.h:3413
#define FT_HAS_KERNING(face)
Definition: freetype.h:1269
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:2465
int iKernAmount
Definition: wingdi.h:2466

Referenced by GreGetKerningPairs(), and NtGdiGetKerningPairs().

◆ ftGdiGetRasterizerCaps()

BOOL FASTCALL ftGdiGetRasterizerCaps ( LPRASTERIZER_STATUS  lprs)

Definition at line 3948 of file freetype.c.

3949{
3950 if ( lprs )
3951 {
3952 lprs->nSize = sizeof(RASTERIZER_STATUS);
3953 lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3954 lprs->nLanguageID = gusLanguageID;
3955 return TRUE;
3956 }
3958 return FALSE;
3959}
#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 5277 of file freetype.c.

5281{
5282 PDC_ATTR pdcattr;
5283 UINT Ret = DEFAULT_CHARSET;
5284 INT i;
5285 HFONT hFont;
5286 PTEXTOBJ TextObj;
5287 PFONTGDI FontGdi;
5289 TT_OS2 *pOS2;
5290 FT_Face Face;
5291 CHARSETINFO csi;
5292 DWORD cp, fs0;
5293 USHORT usACP, usOEM;
5294
5295 pdcattr = Dc->pdcattr;
5296 hFont = pdcattr->hlfntNew;
5297 TextObj = RealizeFontInit(hFont);
5298
5299 if (!TextObj)
5300 {
5302 return Ret;
5303 }
5304 FontGdi = ObjToGDI(TextObj->Font, FONT);
5305 Face = FontGdi->SharedFace->Face;
5306 TEXTOBJ_UnlockText(TextObj);
5307
5308 memset(&fs, 0, sizeof(FONTSIGNATURE));
5310 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
5311 if (NULL != pOS2)
5312 {
5313 fs.fsCsb[0] = pOS2->ulCodePageRange1;
5314 fs.fsCsb[1] = pOS2->ulCodePageRange2;
5315 fs.fsUsb[0] = pOS2->ulUnicodeRange1;
5316 fs.fsUsb[1] = pOS2->ulUnicodeRange2;
5317 fs.fsUsb[2] = pOS2->ulUnicodeRange3;
5318 fs.fsUsb[3] = pOS2->ulUnicodeRange4;
5319 if (pOS2->version == 0)
5320 {
5321 FT_UInt dummy;
5322
5323 if (FT_Get_First_Char( Face, &dummy ) < 0x100)
5324 fs.fsCsb[0] |= FS_LATIN1;
5325 else
5326 fs.fsCsb[0] |= FS_SYMBOL;
5327 }
5328 }
5329 pOS2 = NULL;
5331 DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
5332 if (fs.fsCsb[0] == 0)
5333 { /* Let's see if we can find any interesting cmaps */
5334 for (i = 0; i < Face->num_charmaps; i++)
5335 {
5336 switch (Face->charmaps[i]->encoding)
5337 {
5338 case FT_ENCODING_UNICODE:
5339 case FT_ENCODING_APPLE_ROMAN:
5340 fs.fsCsb[0] |= FS_LATIN1;
5341 break;
5342 case FT_ENCODING_MS_SYMBOL:
5343 fs.fsCsb[0] |= FS_SYMBOL;
5344 break;
5345 default:
5346 break;
5347 }
5348 }
5349 }
5350 if (lpSig)
5351 {
5352 RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
5353 }
5354
5355 RtlGetDefaultCodePage(&usACP, &usOEM);
5356 cp = usACP;
5357
5359 if (csi.fs.fsCsb[0] & fs.fsCsb[0])
5360 {
5361 DPRINT("Hit 1\n");
5362 Ret = csi.ciCharset;
5363 goto Exit;
5364 }
5365
5366 for (i = 0; i < MAXTCIINDEX; i++)
5367 {
5368 fs0 = 1L << i;
5369 if (fs.fsCsb[0] & fs0)
5370 {
5371 if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
5372 {
5373 // *cp = csi.ciACP;
5374 DPRINT("Hit 2\n");
5375 Ret = csi.ciCharset;
5376 goto Exit;
5377 }
5378 else
5379 DPRINT1("TCI failing on %x\n", fs0);
5380 }
5381 }
5382Exit:
5383 DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
5384 return (MAKELONG(csi.ciACP, csi.ciCharset));
5385}
#define MAXTCIINDEX
Definition: freetype.c:424
static BOOLEAN IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2899
#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:836
FT_Int num_charmaps
Definition: freetype.h:1057
FT_CharMap * charmaps
Definition: freetype.h:1058
FT_UShort version
Definition: tttables.h:378
FT_ULong ulUnicodeRange1
Definition: tttables.h:397
FT_ULong ulCodePageRange1
Definition: tttables.h:415
FT_ULong ulUnicodeRange3
Definition: tttables.h:399
FT_ULong ulUnicodeRange2
Definition: tttables.h:398
FT_ULong ulCodePageRange2
Definition: tttables.h:416
FT_ULong ulUnicodeRange4
Definition: tttables.h:400
Definition: ffs.h:70
FONTSIGNATURE fs
Definition: wingdi.h:1548
UINT ciCharset
Definition: wingdi.h:1546
DWORD fsCsb[2]
Definition: wingdi.h:1543
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4156
#define ft_sfnt_os2
Definition: tttables.h:639
#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 5464 of file freetype.c.

5467{
5468 PDC dc;
5469 PDC_ATTR pdcattr;
5470 PTEXTOBJ TextObj;
5471 PFONTGDI FontGDI;
5472 FT_Face Face;
5473 TT_OS2 *pOS2;
5474 TT_HoriHeader *pHori;
5476 ULONG Error;
5478 LOGFONTW *plf;
5479
5480 if (!ptmwi)
5481 {
5483 return FALSE;
5484 }
5485 RtlZeroMemory(ptmwi, sizeof(TMW_INTERNAL));
5486
5487 if (!(dc = DC_LockDc(hDC)))
5488 {
5490 return FALSE;
5491 }
5492 pdcattr = dc->pdcattr;
5493 TextObj = RealizeFontInit(pdcattr->hlfntNew);
5494 if (NULL != TextObj)
5495 {
5496 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
5497 FontGDI = ObjToGDI(TextObj->Font, FONT);
5498
5499 Face = FontGDI->SharedFace->Face;
5500
5501 // NOTE: GetTextMetrics simply ignores lfEscapement and XFORM.
5503 Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
5504 FT_Set_Transform(Face, NULL, NULL);
5505
5507
5508 if (0 != Error)
5509 {
5510 DPRINT1("Error in setting pixel sizes: %u\n", Error);
5512 }
5513 else
5514 {
5516
5518
5519 Error = FT_Get_WinFNT_Header(Face, &Win);
5520 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
5521 pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
5522
5523 if (!pOS2 && Error)
5524 {
5525 DPRINT1("Can't find OS/2 table - not TT font?\n");
5527 }
5528
5529 if (!pHori && Error)
5530 {
5531 DPRINT1("Can't find HHEA table - not TT font?\n");
5533 }
5534
5535 if (NT_SUCCESS(Status))
5536 {
5537 FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, (Error ? NULL : &Win));
5538
5539 /* FIXME: Fill Diff member */
5540 }
5541
5543 }
5544 TEXTOBJ_UnlockText(TextObj);
5545 }
5546 else
5547 {
5549 }
5550 DC_UnlockDc(dc);
5551
5552 if (!NT_SUCCESS(Status))
5553 {
5555 return FALSE;
5556 }
5557 return TRUE;
5558}
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:4277
static void FASTCALL FillTM(TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT)
Definition: freetype.c:2962
FT_Get_WinFNT_Header(FT_Face face, FT_WinFNT_HeaderRec *aheader)
Definition: ftwinfnt.c:29
Status
Definition: gdiplustypes.h:25
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#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:640
#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 6562 of file freetype.c.

6563{
6564 if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
6565 Info->iTechnology = RI_TECH_BITMAP;
6566 else
6567 {
6568 if (FT_IS_SCALABLE(Font->SharedFace->Face))
6569 Info->iTechnology = RI_TECH_SCALABLE;
6570 else
6571 Info->iTechnology = RI_TECH_FIXED;
6572 }
6573 Info->iUniq = Font->FontObj.iUniq;
6574 Info->dwUnknown = -1;
6575 return TRUE;
6576}
#define FT_HAS_FIXED_SIZES(face)
Definition: freetype.h:1333
#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 5390 of file freetype.c.

5391{
5392 DWORD size = 0;
5393 DWORD num_ranges = 0;
5394 FT_Face face = Font->SharedFace->Face;
5395
5396 if (face->charmap == NULL)
5397 {
5398 DPRINT1("FIXME: No charmap selected! This is a BUG!\n");
5399 return 0;
5400 }
5401
5402 if (face->charmap->encoding == FT_ENCODING_UNICODE)
5403 {
5404 FT_UInt glyph_code = 0;
5405 FT_ULong char_code, char_code_prev;
5406
5407 char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
5408
5409 DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
5410 face->num_glyphs, glyph_code, char_code);
5411
5412 if (!glyph_code) return 0;
5413
5414 if (glyphset)
5415 {
5416 glyphset->ranges[0].wcLow = (USHORT)char_code;
5417 glyphset->ranges[0].cGlyphs = 0;
5418 glyphset->cGlyphsSupported = 0;
5419 }
5420
5421 num_ranges = 1;
5422 while (glyph_code)
5423 {
5424 if (char_code < char_code_prev)
5425 {
5426 DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
5427 return 0;
5428 }
5429 if (char_code - char_code_prev > 1)
5430 {
5431 num_ranges++;
5432 if (glyphset)
5433 {
5434 glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
5435 glyphset->ranges[num_ranges - 1].cGlyphs = 1;
5436 glyphset->cGlyphsSupported++;
5437 }
5438 }
5439 else if (glyphset)
5440 {
5441 glyphset->ranges[num_ranges - 1].cGlyphs++;
5442 glyphset->cGlyphsSupported++;
5443 }
5444 char_code_prev = char_code;
5445 char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
5446 }
5447 }
5448 else
5449 DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
5450
5451 size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
5452 if (glyphset)
5453 {
5454 glyphset->cbThis = size;
5455 glyphset->cRanges = num_ranges;
5456 glyphset->flAccel = 0;
5457 }
5458 return size;
5459}
GLsizeiptr size
Definition: glext.h:5919

Referenced by NtGdiGetFontUnicodeRanges().

◆ GreCreateFontIndirectW()

HFONT FASTCALL GreCreateFontIndirectW ( _In_ const LOGFONTW lplf)

Internal

Definition at line 28 of file font.c.

29{
30 if (lplf)
31 {
32 ENUMLOGFONTEXDVW Logfont;
33
34 RtlCopyMemory( &Logfont.elfEnumLogfontEx.elfLogFont, lplf, sizeof(LOGFONTW));
36 sizeof(Logfont.elfEnumLogfontEx.elfFullName));
38 sizeof(Logfont.elfEnumLogfontEx.elfStyle));
40 sizeof(Logfont.elfEnumLogfontEx.elfScript));
41
42 Logfont.elfDesignVector.dvNumAxes = 0;
43
44 RtlZeroMemory( &Logfont.elfDesignVector, sizeof(DESIGNVECTOR));
45
46 return HfontCreate(&Logfont, 0, 0, 0, NULL);
47 }
48 else return NULL;
49}
DWORD dvNumAxes
Definition: wingdi.h:2769
DESIGNVECTOR elfDesignVector
Definition: wingdi.h:2780
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:2704
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2703
WCHAR elfScript[LF_FACESIZE]
Definition: wingdi.h:2705
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 7504 of file freetype.c.

7514{
7515 BOOL bResult;
7516 DC *dc;
7517
7518 // TODO: Write test-cases to exactly match real Windows in different
7519 // bad parameters (e.g. does Windows check the DC or the RECT first?).
7520 dc = DC_LockDc(hDC);
7521 if (!dc)
7522 {
7524 return FALSE;
7525 }
7526
7527 bResult = IntExtTextOutW( dc,
7528 XStart,
7529 YStart,
7530 fuOptions,
7531 lprc,
7532 String,
7533 Count,
7534 Dx,
7535 dwCodePage );
7536
7537 DC_UnlockDc(dc);
7538
7539 return bResult;
7540}
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:6958
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4542

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

◆ 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:5464
HDC hdc
Definition: main.c:9
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 1021 of file freetype.c.

1022{
1023 ULONG ulError;
1024
1026
1028 if (g_FreeTypeLock == NULL)
1029 {
1030 return FALSE;
1031 }
1033
1035 if (ulError)
1036 {
1037 DPRINT1("FT_Init_FreeType failed with error code 0x%x\n", ulError);
1038 return FALSE;
1039 }
1040
1042 {
1043 DPRINT1("Fonts registry is empty.\n");
1044
1045 /* Load font(s) with writing registry */
1047 }
1048
1049 IntLoadFontSubstList(&g_FontSubstListHead);
1050
1051#if 0
1052 DumpFontInfo(TRUE);
1053#endif
1054
1058
1059 return TRUE;
1060}
#define NonPagedPool
Definition: env_spec_w32.h:307
BOOL FASTCALL IntLoadFontSubstList(PLIST_ENTRY pHead)
Definition: freetype.c:874
static UINT g_FontCacheNumEntries
Definition: freetype.c:395
VOID FASTCALL IntLoadSystemFonts(VOID)
Definition: freetype.c:1564
static NTSTATUS FontLink_LoadDefaultCharset(VOID)
Definition: freetype.c:156
static NTSTATUS FontLink_LoadSettings(VOID)
Definition: freetype.c:92
static NTSTATUS FontLink_LoadDefaultFonts(VOID)
Definition: freetype.c:118
BOOL FASTCALL IntLoadFontsInRegistry(VOID)
Definition: freetype.c:2499
FT_Init_FreeType(FT_Library *alibrary)
Definition: ftinit.c:196
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 473 of file freetype.c.

474{
475 UINT i;
476
477 if (uCodePage == CP_OEMCP)
478 return OEM_CHARSET;
479
480 if (uCodePage == CP_MACCP)
481 return MAC_CHARSET;
482
483 for (i = 0; i < MAXTCIINDEX; ++i)
484 {
485 if (g_FontTci[i].ciACP == 0)
486 continue;
487
488 if (g_FontTci[i].ciACP == uCodePage)
489 return g_FontTci[i].ciCharset;
490 }
491
492 return DEFAULT_CHARSET;
493}
#define CP_OEMCP
Definition: freetype.c:467
static const CHARSETINFO g_FontTci[MAXTCIINDEX]
Definition: freetype.c:425
#define CP_MACCP
Definition: freetype.c:468
#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 2829 of file freetype.c.

2830{
2832}
static BOOL g_RenderingEnabled
Definition: freetype.c:372
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142

◆ IntGdiAddFontMemResource()

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

Definition at line 2651 of file freetype.c.

2652{
2653 HANDLE Ret = NULL;
2655 PFONT_ENTRY_COLL_MEM EntryCollection;
2656 INT FaceCount;
2657
2659 if (!BufferCopy)
2660 {
2661 *pNumAdded = 0;
2662 return NULL;
2663 }
2664 RtlCopyMemory(BufferCopy, Buffer, dwSize);
2665
2666 RtlZeroMemory(&LoadFont, sizeof(LoadFont));
2667 LoadFont.Memory = SharedMem_Create(BufferCopy, dwSize, FALSE);
2668 LoadFont.Characteristics = FR_PRIVATE | FR_NOT_ENUM;
2669 RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
2671
2672 RtlFreeUnicodeString(&LoadFont.RegValueName);
2673
2674 /* Release our copy */
2678
2679 if (FaceCount > 0)
2680 {
2681 EntryCollection = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_ENTRY_COLL_MEM), TAG_FONT);
2682 if (EntryCollection)
2683 {
2685 EntryCollection->Entry = LoadFont.PrivateEntry;
2687 IntLockProcessPrivateFonts(Win32Process);
2688 EntryCollection->Handle = ULongToHandle(++Win32Process->PrivateMemFontHandleCount);
2689 InsertTailList(&Win32Process->PrivateMemFontListHead, &EntryCollection->ListEntry);
2690 IntUnLockProcessPrivateFonts(Win32Process);
2692 Ret = EntryCollection->Handle;
2693 }
2694 }
2695 *pNumAdded = FaceCount;
2696
2697 return Ret;
2698}
#define ULongToHandle(h)
Definition: basetsd.h:81
#define InsertTailList(ListHead, Entry)
BOOL LoadFont(LPWSTR lpCmdLine)
static INT FASTCALL IntGdiLoadFontByIndexFromMemory(PGDI_LOAD_FONT pLoadFont, FT_Long FontIndex)
Definition: freetype.c:2011
static PSHARED_MEM SharedMem_Create(PBYTE Buffer, ULONG BufferSize, BOOL IsMapping)
Definition: freetype.c:593
static void SharedMem_Release(PSHARED_MEM Ptr)
Definition: freetype.c:650
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 2292 of file freetype.c.

2297{
2298 PWSTR pchFile = FileName->Buffer;
2299 SIZE_T cchFile;
2300 INT ret = 0;
2301
2302 while (cFiles--)
2303 {
2304 _SEH2_TRY
2305 {
2306 cchFile = wcslen(pchFile);
2307 }
2309 {
2310 _SEH2_YIELD(return FALSE);
2311 }
2312 _SEH2_END;
2313
2314 UNICODE_STRING ustrPathName;
2315 ustrPathName.Length = (USHORT)(cchFile * sizeof(WCHAR));
2316 ustrPathName.MaximumLength = ustrPathName.Length + sizeof(WCHAR);
2317 ustrPathName.Buffer = pchFile;
2318
2319 INT count = IntGdiAddFontResourceSingle(&ustrPathName, Characteristics, dwFlags);
2320 if (!count)
2321 return 0;
2322 ret += count;
2323
2324 pchFile += cchFile + 1;
2325 }
2326
2327 return ret;
2328}
return ret
Definition: mutex.c:146
static INT FASTCALL IntGdiAddFontResourceSingle(_In_ PCUNICODE_STRING FileName, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
Definition: freetype.c:2093
GLuint GLuint GLsizei count
Definition: gl.h:1545
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

◆ IntGdiCleanupPrivateFontsForProcess()

VOID FASTCALL IntGdiCleanupPrivateFontsForProcess ( VOID  )

Definition at line 2773 of file freetype.c.

2774{
2777 PFONT_ENTRY_COLL_MEM EntryCollection;
2778
2779 DPRINT("IntGdiCleanupPrivateFontsForProcess()\n");
2780 do {
2781 Entry = NULL;
2782 EntryCollection = NULL;
2783
2785 IntLockProcessPrivateFonts(Win32Process);
2786 if (!IsListEmpty(&Win32Process->PrivateMemFontListHead))
2787 {
2788 Entry = Win32Process->PrivateMemFontListHead.Flink;
2789 EntryCollection = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
2790 UnlinkFontMemCollection(EntryCollection);
2791 }
2792 IntUnLockProcessPrivateFonts(Win32Process);
2794
2795 if (EntryCollection)
2796 {
2797 IntGdiCleanupMemEntry(EntryCollection->Entry);
2798 ExFreePoolWithTag(EntryCollection, TAG_FONT);
2799 }
2800 else
2801 {
2802 /* No Mem fonts anymore, see if we have any other private fonts left */
2803 Entry = NULL;
2805 IntLockProcessPrivateFonts(Win32Process);
2806 if (!IsListEmpty(&Win32Process->PrivateFontListHead))
2807 {
2808 Entry = RemoveHeadList(&Win32Process->PrivateFontListHead);
2809 }
2810 IntUnLockProcessPrivateFonts(Win32Process);
2812
2813 if (Entry)
2814 {
2816 }
2817 }
2818
2819 } while (Entry);
2820}
VOID FASTCALL IntGdiCleanupMemEntry(PFONT_ENTRY_MEM Head)
Definition: freetype.c:2701
static VOID FASTCALL UnlinkFontMemCollection(PFONT_ENTRY_COLL_MEM Collection)
Definition: freetype.c:2720
base of all file and directory entries
Definition: entries.h:83
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 6294 of file freetype.c.

6299{
6300 UNICODE_STRING EntryFileName;
6301 POBJECT_NAME_INFORMATION NameInfo1 = NULL, NameInfo2 = NULL;
6302 PLIST_ENTRY ListEntry;
6303 PFONT_ENTRY FontEntry;
6304 ULONG Size, i, Count;
6305 LPBYTE pbBuffer;
6306 BOOL IsEqual;
6307 FONTFAMILYINFO *FamInfo;
6308 const ULONG MaxFamInfo = 64;
6309 const ULONG MAX_FAM_INFO_BYTES = sizeof(FONTFAMILYINFO) * MaxFamInfo;
6310 BOOL bSuccess;
6311 const ULONG NAMEINFO_SIZE = sizeof(OBJECT_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR);
6312
6313 DPRINT("IntGdiGetFontResourceInfo: dwType == %lu\n", dwType);
6314
6315 do
6316 {
6317 /* Create buffer for full path name */
6318 NameInfo1 = ExAllocatePoolWithTag(PagedPool, NAMEINFO_SIZE, TAG_FINF);
6319 if (!NameInfo1)
6320 break;
6321
6322 /* Get the full path name */
6323 if (!IntGetFullFileName(NameInfo1, NAMEINFO_SIZE, FileName))
6324 break;
6325
6326 /* Create a buffer for the entries' names */
6327 NameInfo2 = ExAllocatePoolWithTag(PagedPool, NAMEINFO_SIZE, TAG_FINF);
6328 if (!NameInfo2)
6329 break;
6330
6331 FamInfo = ExAllocatePoolWithTag(PagedPool, MAX_FAM_INFO_BYTES, TAG_FINF);
6332 } while (0);
6333
6334 if (!NameInfo1 || !NameInfo2 || !FamInfo)
6335 {
6336 if (NameInfo2)
6337 ExFreePoolWithTag(NameInfo2, TAG_FINF);
6338
6339 if (NameInfo1)
6340 ExFreePoolWithTag(NameInfo1, TAG_FINF);
6341
6343 return FALSE;
6344 }
6345
6346 Count = 0;
6347
6348 /* Try to find the pathname in the global font list */
6350 for (ListEntry = g_FontListHead.Flink; ListEntry != &g_FontListHead;
6351 ListEntry = ListEntry->Flink)
6352 {
6353 FontEntry = CONTAINING_RECORD(ListEntry, FONT_ENTRY, ListEntry);
6354 if (FontEntry->Font->Filename == NULL)
6355 continue;
6356
6357 RtlInitUnicodeString(&EntryFileName , FontEntry->Font->Filename);
6358 if (!IntGetFullFileName(NameInfo2, NAMEINFO_SIZE, &EntryFileName))
6359 continue;
6360
6361 if (!RtlEqualUnicodeString(&NameInfo1->Name, &NameInfo2->Name, FALSE))
6362 continue;
6363
6364 IsEqual = FALSE;
6365 FontFamilyFillInfo(&FamInfo[Count], FontEntry->FaceName.Buffer,
6366 NULL, FontEntry->Font);
6367 for (i = 0; i < Count; ++i)
6368 {
6369 if (EqualFamilyInfo(&FamInfo[i], &FamInfo[Count]))
6370 {
6371 IsEqual = TRUE;
6372 break;
6373 }
6374 }
6375 if (!IsEqual)
6376 {
6377 /* Found */
6378 ++Count;
6379 if (Count >= MaxFamInfo)
6380 break;
6381 }
6382 }
6384
6385 /* Free the buffers */
6386 ExFreePoolWithTag(NameInfo1, TAG_FINF);
6387 ExFreePoolWithTag(NameInfo2, TAG_FINF);
6388
6389 if (Count == 0 && dwType != 5)
6390 {
6391 /* Font could not be found in system table
6392 dwType == 5 will still handle this */
6393 ExFreePoolWithTag(FamInfo, TAG_FINF);
6394 return FALSE;
6395 }
6396
6397 bSuccess = FALSE;
6398 switch (dwType)
6399 {
6400 case 0: /* FIXME: Returns 1 or 2, don't know what this is atm */
6401 Size = sizeof(DWORD);
6402 if (*pdwBytes == 0)
6403 {
6404 *pdwBytes = Size;
6405 bSuccess = TRUE;
6406 }
6407 else if (pBuffer)
6408 {
6409 if (*pdwBytes >= Size)
6410 {
6411 *(DWORD*)pBuffer = Count;
6412 }
6413 *pdwBytes = Size;
6414 bSuccess = TRUE;
6415 }
6416 break;
6417
6418 case 1: /* copy the font title */
6419 /* calculate the required size */
6420 Size = 0;
6421 for (i = 0; i < Count; ++i)
6422 {
6423 if (i > 0)
6424 Size += 3; /* " & " */
6425 Size += wcslen(FamInfo[i].EnumLogFontEx.elfLogFont.lfFaceName);
6426 if (FamInfo[i].EnumLogFontEx.elfStyle[0] &&
6427 _wcsicmp(FamInfo[i].EnumLogFontEx.elfStyle, L"Regular") != 0)
6428 {
6429 Size += 1 + wcslen(FamInfo[i].EnumLogFontEx.elfStyle);
6430 }
6431 }
6432 Size += 2; /* "\0\0" */
6433 Size *= sizeof(WCHAR);
6434
6435 if (*pdwBytes == 0)
6436 {
6437 *pdwBytes = Size;
6438 bSuccess = TRUE;
6439 }
6440 else if (pBuffer)
6441 {
6442 if (*pdwBytes >= Size)
6443 {
6444 /* store font title to buffer */
6445 WCHAR *psz = pBuffer;
6446 *psz = 0;
6447 for (i = 0; i < Count; ++i)
6448 {
6449 if (i > 0)
6450 wcscat(psz, L" & ");
6451 IntAddNameFromFamInfo(psz, &FamInfo[i]);
6452 }
6453 psz[wcslen(psz) + 1] = UNICODE_NULL;
6454 *pdwBytes = Size;
6455 bSuccess = TRUE;
6456 }
6457 else
6458 {
6459 *pdwBytes = 1024; /* this is confirmed value */
6460 }
6461 }
6462 break;
6463
6464 case 2: /* Copy an array of LOGFONTW */
6465 Size = Count * sizeof(LOGFONTW);
6466 if (*pdwBytes == 0)
6467 {
6468 *pdwBytes = Size;
6469 bSuccess = TRUE;
6470 }
6471 else if (pBuffer)
6472 {
6473 if (*pdwBytes >= Size)
6474 {
6475 pbBuffer = (LPBYTE)pBuffer;
6476 for (i = 0; i < Count; ++i)
6477 {
6478 FamInfo[i].EnumLogFontEx.elfLogFont.lfWidth = 0;
6479 RtlCopyMemory(pbBuffer, &FamInfo[i].EnumLogFontEx.elfLogFont, sizeof(LOGFONTW));
6480 pbBuffer += sizeof(LOGFONTW);
6481 }
6482 }
6483 *pdwBytes = Size;
6484 bSuccess = TRUE;
6485 }
6486 else
6487 {
6488 *pdwBytes = 1024; /* this is confirmed value */
6489 }
6490 break;
6491
6492 case 3:
6493 Size = sizeof(DWORD);
6494 if (*pdwBytes == 0)
6495 {
6496 *pdwBytes = Size;
6497 bSuccess = TRUE;
6498 }
6499 else if (pBuffer)
6500 {
6501 if (*pdwBytes >= Size)
6502 {
6503 /* FIXME: What exactly is copied here? */
6504 *(DWORD*)pBuffer = 1;
6505 }
6506 *pdwBytes = Size;
6507 bSuccess = TRUE;
6508 }
6509 break;
6510
6511 case 4: /* full file path */
6512 if (FileName->Length >= 4 * sizeof(WCHAR))
6513 {
6514 /* The beginning of FileName is \??\ */
6515 LPWSTR pch = FileName->Buffer + 4;
6516 DWORD Length = FileName->Length - 4 * sizeof(WCHAR);
6517
6518 Size = Length + sizeof(WCHAR);
6519 if (*pdwBytes == 0)
6520 {
6521 *pdwBytes = Size;
6522 bSuccess = TRUE;
6523 }
6524 else if (pBuffer)
6525 {
6526 if (*pdwBytes >= Size)
6527 {
6529 }
6530 *pdwBytes = Size;
6531 bSuccess = TRUE;
6532 }
6533 }
6534 break;
6535
6536 case 5: /* Looks like a BOOL that is copied, TRUE, if the font was not found */
6537 Size = sizeof(BOOL);
6538 if (*pdwBytes == 0)
6539 {
6540 *pdwBytes = Size;
6541 bSuccess = TRUE;
6542 }
6543 else if (pBuffer)
6544 {
6545 if (*pdwBytes >= Size)
6546 {
6547 *(BOOL*)pBuffer = Count == 0;
6548 }
6549 *pdwBytes = Size;
6550 bSuccess = TRUE;
6551 }
6552 break;
6553 }
6554 ExFreePoolWithTag(FamInfo, TAG_FINF);
6555
6556 return bSuccess;
6557}
wcscat
#define MAX_PATH
Definition: compat.h:34
#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:6217
static BOOL EqualFamilyInfo(const FONTFAMILYINFO *pInfo1, const FONTFAMILYINFO *pInfo2)
Definition: freetype.c:6260
static void FASTCALL FontFamilyFillInfo(PFONTFAMILYINFO Info, LPCWSTR FaceName, LPCWSTR FullName, PFONTGDI FontGDI)
Definition: freetype.c:3639
static VOID IntAddNameFromFamInfo(LPWSTR psz, FONTFAMILYINFO *FamInfo)
Definition: freetype.c:6281
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
#define pch(ap)
Definition: match.c:418
#define BOOL
Definition: nt_native.h:43
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
#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
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
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:1270
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
LONG lfWidth
Definition: wingdi.h:1898
unsigned char * LPBYTE
Definition: typedefs.h:53
#define TAG_FINF
Definition: text.h:3
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by NtGdiGetFontResourceInfoInternalW().

◆ IntGdiRemoveFontMemResource()

BOOL FASTCALL IntGdiRemoveFontMemResource ( HANDLE  hMMFont)

Definition at line 2737 of file freetype.c.

2738{
2740 PFONT_ENTRY_COLL_MEM CurrentEntry;
2741 PFONT_ENTRY_COLL_MEM EntryCollection = NULL;
2743
2745 IntLockProcessPrivateFonts(Win32Process);
2746 for (Entry = Win32Process->PrivateMemFontListHead.Flink;
2747 Entry != &Win32Process->PrivateMemFontListHead;
2748 Entry = Entry->Flink)
2749 {
2750 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
2751
2752 if (CurrentEntry->Handle == hMMFont)
2753 {
2754 EntryCollection = CurrentEntry;
2755 UnlinkFontMemCollection(CurrentEntry);
2756 break;
2757 }
2758 }
2759 IntUnLockProcessPrivateFonts(Win32Process);
2761
2762 if (EntryCollection)
2763 {
2764 IntGdiCleanupMemEntry(EntryCollection->Entry);
2765 ExFreePoolWithTag(EntryCollection, TAG_FONT);
2766 return TRUE;
2767 }
2768 return FALSE;
2769}

Referenced by NtGdiRemoveFontMemResourceEx().

◆ IntGdiRemoveFontResource()

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

Definition at line 2453 of file freetype.c.

2457{
2458 PWSTR pchFile = FileName->Buffer;
2459 SIZE_T cchFile;
2460
2461 while (cFiles--)
2462 {
2463 _SEH2_TRY
2464 {
2465 cchFile = wcslen(pchFile);
2466 }
2468 {
2469 _SEH2_YIELD(return FALSE);
2470 }
2471 _SEH2_END;
2472
2473 UNICODE_STRING ustrPathName;
2474 ustrPathName.Length = (USHORT)(cchFile * sizeof(WCHAR));
2475 ustrPathName.MaximumLength = ustrPathName.Length + sizeof(WCHAR);
2476 ustrPathName.Buffer = pchFile;
2477
2479 if (!ret)
2480 return FALSE;
2481
2482 pchFile += cchFile + 1;
2483 }
2484
2485 return TRUE;
2486}
static BOOL FASTCALL IntGdiRemoveFontResourceSingle(_In_ PCUNICODE_STRING FileName, _In_ DWORD dwFlags)
Definition: freetype.c:2384

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

3268{
3269 TT_OS2 *pOS2;
3270 TT_HoriHeader *pHori;
3271 TT_Postscript *pPost;
3272 FT_Fixed XScale, YScale;
3273 FT_WinFNT_HeaderRec WinFNT;
3275 BYTE *pb;
3276 FONT_NAMES FontNames;
3277 PSHARED_FACE SharedFace = FontGDI->SharedFace;
3279 FT_Face Face = SharedFace->Face;
3280
3281 if (bLocked)
3283 else
3285
3287 {
3288 Cache = &SharedFace->EnglishUS;
3289 }
3290 else
3291 {
3292 Cache = &SharedFace->UserLanguage;
3293 }
3294
3295 if (Size == 0 && Cache->OutlineRequiredSize > 0)
3296 {
3297 ASSERT(Otm == NULL);
3298 return Cache->OutlineRequiredSize;
3299 }
3300
3301 if (!bLocked)
3303
3304 IntInitFontNames(&FontNames, SharedFace);
3305 Cache->OutlineRequiredSize = FontNames.OtmSize;
3306
3307 if (Size == 0)
3308 {
3309 ASSERT(Otm == NULL);
3310 IntFreeFontNames(&FontNames);
3311 if (!bLocked)
3313 return Cache->OutlineRequiredSize;
3314 }
3315
3316 ASSERT(Otm != NULL);
3317
3318 if (Size < Cache->OutlineRequiredSize)
3319 {
3320 DPRINT1("Size %u < OutlineRequiredSize %u\n", Size,
3321 Cache->OutlineRequiredSize);
3322 IntFreeFontNames(&FontNames);
3323 if (!bLocked)
3325 return 0; /* failure */
3326 }
3327
3328 XScale = Face->size->metrics.x_scale;
3329 YScale = Face->size->metrics.y_scale;
3330
3331 pOS2 = FT_Get_Sfnt_Table(Face, FT_SFNT_OS2);
3332 pHori = FT_Get_Sfnt_Table(Face, FT_SFNT_HHEA);
3333 pPost = FT_Get_Sfnt_Table(Face, FT_SFNT_POST); /* We can live with this failing */
3334 Error = FT_Get_WinFNT_Header(Face, &WinFNT);
3335
3336 if (pOS2 == NULL && Error)
3337 {
3338 if (!bLocked)
3340 DPRINT1("Can't find OS/2 table - not TT font?\n");
3341 IntFreeFontNames(&FontNames);
3342 return 0;
3343 }
3344
3345 if (pHori == NULL && Error)
3346 {
3347 if (!bLocked)
3349 DPRINT1("Can't find HHEA table - not TT font?\n");
3350 IntFreeFontNames(&FontNames);
3351 return 0;
3352 }
3353
3354 Otm->otmSize = Cache->OutlineRequiredSize;
3355
3356 FillTM(&Otm->otmTextMetrics, FontGDI, pOS2, pHori, (Error ? NULL : &WinFNT));
3357
3358 if (!pOS2)
3359 goto skip_os2;
3360
3361 Otm->otmFiller = 0;
3363 Otm->otmfsSelection = pOS2->fsSelection;
3364 Otm->otmfsType = pOS2->fsType;
3365 Otm->otmsCharSlopeRise = pHori->caret_Slope_Rise;
3366 Otm->otmsCharSlopeRun = pHori->caret_Slope_Run;
3367 Otm->otmItalicAngle = 0; /* POST table */
3368 Otm->otmEMSquare = Face->units_per_EM;
3369
3370#define SCALE_X(value) ((FT_MulFix((value), XScale) + 32) >> 6)
3371#define SCALE_Y(value) ((FT_MulFix((value), YScale) + 32) >> 6)
3372
3373 Otm->otmAscent = SCALE_Y(pOS2->sTypoAscender);
3374 Otm->otmDescent = SCALE_Y(pOS2->sTypoDescender);
3375 Otm->otmLineGap = SCALE_Y(pOS2->sTypoLineGap);
3376 Otm->otmsCapEmHeight = SCALE_Y(pOS2->sCapHeight);
3377 Otm->otmsXHeight = SCALE_Y(pOS2->sxHeight);
3378 Otm->otmrcFontBox.left = SCALE_X(Face->bbox.xMin);
3379 Otm->otmrcFontBox.right = SCALE_X(Face->bbox.xMax);
3380 Otm->otmrcFontBox.top = SCALE_Y(Face->bbox.yMax);
3381 Otm->otmrcFontBox.bottom = SCALE_Y(Face->bbox.yMin);
3384 Otm->otmMacLineGap = Otm->otmLineGap;
3385 Otm->otmusMinimumPPEM = 0; /* TT Header */
3396
3397 if (!pPost)
3398 {
3399 Otm->otmsUnderscoreSize = 0;
3400 Otm->otmsUnderscorePosition = 0;
3401 }
3402 else
3403 {
3406 }
3407
3408#undef SCALE_X
3409#undef SCALE_Y
3410
3411skip_os2:
3412 if (!bLocked)
3414
3415 pb = IntStoreFontNames(&FontNames, Otm);
3416 ASSERT(pb - (BYTE*)Otm == Cache->OutlineRequiredSize);
3417
3418 IntFreeFontNames(&FontNames);
3419
3420 return Cache->OutlineRequiredSize;
3421}
BOOLEAN bLocked
Definition: Mke2fs.c:19
#define SCALE_Y(value)
static __inline void FASTCALL IntInitFontNames(FONT_NAMES *Names, PSHARED_FACE SharedFace)
Definition: freetype.c:3191
static __inline BYTE *FASTCALL IntStoreFontNames(const FONT_NAMES *Names, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:3227
#define SCALE_X(value)
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:374
static __inline void FASTCALL IntFreeFontNames(FONT_NAMES *Names)
Definition: freetype.c:3251
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
Definition: fatfs.h:173
ULONG OtmSize
Definition: freetype.c:3187
FT_Pos xMin
Definition: ftimage.h:121
FT_Pos yMax
Definition: ftimage.h:122
FT_Pos yMin
Definition: ftimage.h:121
FT_Pos xMax
Definition: ftimage.h:122
FT_Size size
Definition: freetype.h:1079
FT_BBox bbox
Definition: freetype.h:1065
FT_UShort units_per_EM
Definition: freetype.h:1067
FT_Size_Metrics metrics
Definition: freetype.h:1649
FT_Fixed y_scale
Definition: freetype.h:1614
FT_Fixed x_scale
Definition: freetype.h:1613
FT_Short caret_Slope_Run
Definition: tttables.h:214
FT_Short caret_Slope_Rise
Definition: tttables.h:213
FT_Short sTypoDescender
Definition: tttables.h:408
FT_UShort fsSelection
Definition: tttables.h:404
FT_Short ySuperscriptYSize
Definition: tttables.h:388
FT_Short sxHeight
Definition: tttables.h:420
FT_Short yStrikeoutSize
Definition: tttables.h:391
FT_Byte panose[10]
Definition: tttables.h:395
FT_Short ySubscriptXSize
Definition: tttables.h:383
FT_Short sTypoLineGap
Definition: tttables.h:409
FT_Short sTypoAscender
Definition: tttables.h:407
FT_Short ySuperscriptXSize
Definition: tttables.h:387
FT_Short ySubscriptYOffset
Definition: tttables.h:386
FT_Short ySuperscriptYOffset
Definition: tttables.h:390
FT_Short ySubscriptXOffset
Definition: tttables.h:385
FT_Short yStrikeoutPosition
Definition: tttables.h:392
FT_Short sCapHeight
Definition: tttables.h:421
FT_UShort fsType
Definition: tttables.h:382
FT_Short ySuperscriptXOffset
Definition: tttables.h:389
FT_Short ySubscriptYSize
Definition: tttables.h:384
FT_Short underlineThickness
Definition: tttables.h:456
FT_Short underlinePosition
Definition: tttables.h:455
PANOSE otmPanoseNumber
Definition: wingdi.h:2516
POINT otmptSuperscriptOffset
Definition: wingdi.h:2536
POINT otmptSuperscriptSize
Definition: wingdi.h:2535
POINT otmptSubscriptSize
Definition: wingdi.h:2533
int otmsStrikeoutPosition
Definition: wingdi.h:2538
int otmsUnderscorePosition
Definition: wingdi.h:2540
POINT otmptSubscriptOffset
Definition: wingdi.h:2534
UINT otmsStrikeoutSize
Definition: wingdi.h:2537
SHARED_FACE_CACHE UserLanguage
Definition: engobjects.h:136
SHARED_FACE_CACHE EnglishUS
Definition: engobjects.h:135
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG tmAscent
Definition: wingdi.h:2384
LONG tmDescent
Definition: wingdi.h:2385
@ FT_SFNT_HHEA
Definition: tttables.h:626
@ FT_SFNT_POST
Definition: tttables.h:628
@ FT_SFNT_OS2
Definition: tttables.h:625
#define PANOSE_COUNT
Definition: wingdi.h:453

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

◆ IntIsFontRenderingEnabled()

BOOL FASTCALL IntIsFontRenderingEnabled ( VOID  )

Definition at line 2823 of file freetype.c.

2824{
2825 return (gpsi->BitsPixel > 8) && g_RenderingEnabled;
2826}
PSERVERINFO gpsi
Definition: imm.c:18

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ IntLoadFontsInRegistry()

BOOL FASTCALL IntLoadFontsInRegistry ( VOID  )

Definition at line 2499 of file freetype.c.

2500{
2504 KEY_FULL_INFORMATION KeyFullInfo;
2505 ULONG i, Length;
2506 UNICODE_STRING FontTitleW, FileNameW;
2507 SIZE_T InfoSize;
2508 LPBYTE InfoBuffer;
2510 LPWSTR pchPath;
2512 INT nFontCount = 0;
2513 DWORD dwFlags;
2514
2515 /* open registry key */
2518 NULL, NULL);
2519 Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
2520 if (!NT_SUCCESS(Status))
2521 {
2522 DPRINT1("ZwOpenKey failed: 0x%08X\n", Status);
2523 return FALSE; /* failure */
2524 }
2525
2526 /* query count of values */
2527 Status = ZwQueryKey(KeyHandle, KeyFullInformation,
2528 &KeyFullInfo, sizeof(KeyFullInfo), &Length);
2529 if (!NT_SUCCESS(Status))
2530 {
2531 DPRINT1("ZwQueryKey failed: 0x%08X\n", Status);
2533 return FALSE; /* failure */
2534 }
2535
2536 /* allocate buffer */
2537 InfoSize = (MAX_PATH + 256) * sizeof(WCHAR);
2538 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2539 if (!InfoBuffer)
2540 {
2541 DPRINT1("ExAllocatePoolWithTag failed\n");
2543 return FALSE;
2544 }
2545
2546 /* for each value */
2547 for (i = 0; i < KeyFullInfo.Values; ++i)
2548 {
2549 /* get value name */
2550 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
2551 InfoBuffer, InfoSize, &Length);
2553 {
2554 /* too short buffer */
2555 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2556 InfoSize *= 2;
2557 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2558 if (!InfoBuffer)
2559 {
2560 DPRINT1("ExAllocatePoolWithTag failed\n");
2561 break;
2562 }
2563 /* try again */
2564 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
2565 InfoBuffer, InfoSize, &Length);
2566 }
2567 if (!NT_SUCCESS(Status))
2568 {
2569 DPRINT1("ZwEnumerateValueKey failed: 0x%08X\n", Status);
2570 break; /* failure */
2571 }
2572
2573 /* create FontTitleW string */
2574 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
2575 Length = pInfo->NameLength / sizeof(WCHAR);
2576 pInfo->Name[Length] = UNICODE_NULL; /* truncate */
2577 if (!RtlCreateUnicodeString(&FontTitleW, pInfo->Name))
2578 {
2580 DPRINT1("RtlCreateUnicodeString failed\n");
2581 break; /* failure */
2582 }
2583
2584 /* query value */
2585 Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation,
2586 InfoBuffer, InfoSize, &Length);
2588 {
2589 /* too short buffer */
2590 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2591 InfoSize *= 2;
2592 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
2593 if (!InfoBuffer)
2594 {
2595 DPRINT1("ExAllocatePoolWithTag failed\n");
2596 break;
2597 }
2598 /* try again */
2599 Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation,
2600 InfoBuffer, InfoSize, &Length);
2601 }
2602 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
2603 if (!NT_SUCCESS(Status) || !pInfo->DataLength)
2604 {
2605 DPRINT1("ZwQueryValueKey failed: 0x%08X\n", Status);
2606 RtlFreeUnicodeString(&FontTitleW);
2607 break; /* failure */
2608 }
2609
2610 /* Build pchPath */
2611 pchPath = (LPWSTR)((PUCHAR)pInfo + pInfo->DataOffset);
2612 Length = pInfo->DataLength / sizeof(WCHAR);
2613 pchPath[Length] = UNICODE_NULL; /* truncate */
2614
2615 /* Load font(s) without writing registry */
2616 if (PathIsRelativeW(pchPath))
2617 {
2618 dwFlags = 0;
2620 L"\\SystemRoot\\Fonts\\%s", pchPath);
2621 }
2622 else
2623 {
2625 Status = RtlStringCbCopyW(szPath, sizeof(szPath), pchPath);
2626 }
2627
2628 if (NT_SUCCESS(Status))
2629 {
2630 RtlCreateUnicodeString(&FileNameW, szPath);
2631 nFontCount += IntGdiAddFontResourceEx(&FileNameW, 1, 0, dwFlags);
2632 RtlFreeUnicodeString(&FileNameW);
2633 }
2634
2635 RtlFreeUnicodeString(&FontTitleW);
2636 }
2637
2638 /* close now */
2640
2641 /* free memory block */
2642 if (InfoBuffer)
2643 {
2644 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
2645 }
2646
2647 return (KeyFullInfo.Values != 0 && nFontCount != 0);
2648}
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
static UNICODE_STRING g_FontRegPath
Definition: freetype.c:363
INT FASTCALL IntGdiAddFontResourceEx(_In_ PCUNICODE_STRING FileName, _In_ DWORD cFiles, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
Definition: freetype.c:2292
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: freetype.c:2489
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
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:1133
@ KeyValueFullInformation
Definition: nt_native.h:1181
#define KEY_READ
Definition: nt_native.h:1023
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 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 1564 of file freetype.c.

1565{
1567 UNICODE_STRING Directory, FileName, TempString;
1569 HANDLE hDirectory;
1570 BYTE *DirInfoBuffer;
1572 BOOLEAN bRestartScan = TRUE;
1574 INT i;
1575 static UNICODE_STRING SearchPatterns[] =
1576 {
1577 RTL_CONSTANT_STRING(L"*.ttf"),
1578 RTL_CONSTANT_STRING(L"*.ttc"),
1579 RTL_CONSTANT_STRING(L"*.otf"),
1580 RTL_CONSTANT_STRING(L"*.otc"),
1581 RTL_CONSTANT_STRING(L"*.fon"),
1582 RTL_CONSTANT_STRING(L"*.fnt")
1583 };
1584 static UNICODE_STRING IgnoreFiles[] =
1585 {
1588 };
1589
1590 RtlInitUnicodeString(&Directory, L"\\SystemRoot\\Fonts\\");
1591
1594 &Directory,
1596 NULL,
1597 NULL);
1598
1600 &hDirectory,
1603 &Iosb,
1606
1607 if (NT_SUCCESS(Status))
1608 {
1609 for (i = 0; i < _countof(SearchPatterns); ++i)
1610 {
1611 DirInfoBuffer = ExAllocatePoolWithTag(PagedPool, 0x4000, TAG_FONT);
1612 if (DirInfoBuffer == NULL)
1613 {
1614 ZwClose(hDirectory);
1615 return;
1616 }
1617
1619 if (FileName.Buffer == NULL)
1620 {
1621 ExFreePoolWithTag(DirInfoBuffer, TAG_FONT);
1622 ZwClose(hDirectory);
1623 return;
1624 }
1625 FileName.Length = 0;
1626 FileName.MaximumLength = MAX_PATH * sizeof(WCHAR);
1627
1628 while (1)
1629 {
1630 Status = ZwQueryDirectoryFile(
1631 hDirectory,
1632 NULL,
1633 NULL,
1634 NULL,
1635 &Iosb,
1636 DirInfoBuffer,
1637 0x4000,
1639 FALSE,
1640 &SearchPatterns[i],
1641 bRestartScan);
1642
1644 {
1645 break;
1646 }
1647
1648 DirInfo = (PFILE_DIRECTORY_INFORMATION)DirInfoBuffer;
1649 while (1)
1650 {
1651 SIZE_T ign;
1652
1653 TempString.Buffer = DirInfo->FileName;
1654 TempString.Length = TempString.MaximumLength = DirInfo->FileNameLength;
1655
1656 /* Should we ignore this file? */
1657 for (ign = 0; ign < _countof(IgnoreFiles); ++ign)
1658 {
1659 /* Yes.. */
1660 if (RtlEqualUnicodeString(IgnoreFiles + ign, &TempString, FALSE))
1661 break;
1662 }
1663
1664 /* If we tried all Ignore patterns and there was no match, try to create a font */
1665 if (ign == _countof(IgnoreFiles))
1666 {
1670 DPRINT1("ERR: Failed to load %wZ\n", &FileName);
1671 }
1672
1673 if (DirInfo->NextEntryOffset == 0)
1674 break;
1675
1676 DirInfo = (PFILE_DIRECTORY_INFORMATION)((ULONG_PTR)DirInfo + DirInfo->NextEntryOffset);
1677 }
1678
1679 bRestartScan = FALSE;
1680 }
1681
1683 ExFreePoolWithTag(DirInfoBuffer, TAG_FONT);
1684 }
1685 ZwClose(hDirectory);
1686 }
1687}
@ IgnoreFiles
Definition: ACListISF.cpp:75
unsigned char BOOLEAN
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#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
struct _FILE_DIRECTORY_INFORMATION * PFILE_DIRECTORY_INFORMATION
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)
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
base for all directory entries
Definition: entries.h:138
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:524
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
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

Referenced by InitFontSupport().

◆ RealizeFontInit()

PTEXTOBJ FASTCALL RealizeFontInit ( HFONT  )

◆ TextIntCreateFontIndirect()

NTSTATUS FASTCALL TextIntCreateFontIndirect ( CONST LPLOGFONTW  lf,
HFONT NewFont 
)

Definition at line 2857 of file freetype.c.

2858{
2859 PLFONT plfont;
2860 LOGFONTW *plf;
2861
2862 ASSERT(lf);
2863 plfont = LFONT_AllocFontWithHandle();
2864 if (!plfont)
2865 {
2866 return STATUS_NO_MEMORY;
2867 }
2868
2869 ExInitializePushLock(&plfont->lock);
2870 *NewFont = plfont->BaseObject.hHmgr;
2871 plf = &plfont->logfont.elfEnumLogfontEx.elfLogFont;
2872 RtlCopyMemory(plf, lf, sizeof(LOGFONTW));
2873 if (lf->lfEscapement != lf->lfOrientation)
2874 {
2875 /* This should really depend on whether GM_ADVANCED is set */
2876 plf->lfOrientation = plf->lfEscapement;
2877 }
2878 LFONT_UnlockFont(plfont);
2879
2880 return STATUS_SUCCESS;
2881}
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 6104 of file freetype.c.

6105{
6107 PTEXTOBJ TextObj;
6108 PPROCESSINFO Win32Process;
6109 ULONG MatchPenalty;
6110 LOGFONTW *pLogFont;
6111 LOGFONTW SubstitutedLogFont;
6112
6113 if (!pTextObj)
6114 {
6115 TextObj = TEXTOBJ_LockText(FontHandle);
6116 if (NULL == TextObj)
6117 {
6118 return STATUS_INVALID_HANDLE;
6119 }
6120
6121 if (TextObj->fl & TEXTOBJECT_INIT)
6122 {
6123 TEXTOBJ_UnlockText(TextObj);
6124 return STATUS_SUCCESS;
6125 }
6126 }
6127 else
6128 {
6129 TextObj = pTextObj;
6130 }
6131
6132 pLogFont = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
6133
6134 /* substitute */
6135 SubstitutedLogFont = *pLogFont;
6136 SubstituteFontRecurse(&SubstitutedLogFont);
6137 DPRINT("Font '%S,%u' is substituted by '%S,%u'.\n",
6138 pLogFont->lfFaceName, pLogFont->lfCharSet,
6139 SubstitutedLogFont.lfFaceName, SubstitutedLogFont.lfCharSet);
6140
6141 MatchPenalty = 0xFFFFFFFF;
6142 TextObj->Font = NULL;
6143
6144 Win32Process = PsGetCurrentProcessWin32Process();
6145
6146 /* Search private fonts */
6148 IntLockProcessPrivateFonts(Win32Process);
6149 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
6150 &Win32Process->PrivateFontListHead);
6151 IntUnLockProcessPrivateFonts(Win32Process);
6152
6153 /* Search system fonts */
6154 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
6155 &g_FontListHead);
6157
6158 if (NULL == TextObj->Font)
6159 {
6160 DPRINT1("Request font %S not found, no fonts loaded at all\n",
6161 pLogFont->lfFaceName);
6163 }
6164 else
6165 {
6167 PFONTGDI FontGdi = ObjToGDI(TextObj->Font, FONT);
6168 PSHARED_FACE SharedFace = FontGdi->SharedFace;
6169
6170 TextObj->TextFace[0] = UNICODE_NULL;
6172 if (MatchFontNames(SharedFace, SubstitutedLogFont.lfFaceName))
6173 {
6175 RtlStringCchCopyW(TextObj->TextFace, _countof(TextObj->TextFace), pLogFont->lfFaceName);
6176 }
6177 else
6178 {
6182 if (NT_SUCCESS(Status))
6183 {
6184 /* truncated copy */
6185 IntUnicodeStringToBuffer(TextObj->TextFace, sizeof(TextObj->TextFace), &Name);
6187 }
6188 }
6189
6190 // Need hdev, when freetype is loaded need to create DEVOBJ for
6191 // Consumer and Producer.
6192 TextObj->Font->iUniq = 1; // Now it can be cached.
6193 IntFontType(FontGdi);
6194 FontGdi->flType = TextObj->Font->flFontType;
6195 FontGdi->RequestUnderline = pLogFont->lfUnderline ? 0xFF : 0;
6196 FontGdi->RequestStrikeOut = pLogFont->lfStrikeOut ? 0xFF : 0;
6197 FontGdi->RequestItalic = pLogFont->lfItalic ? 0xFF : 0;
6198 if (pLogFont->lfWeight != FW_DONTCARE)
6199 FontGdi->RequestWeight = pLogFont->lfWeight;
6200 else
6201 FontGdi->RequestWeight = FW_NORMAL;
6202
6203 TextObj->fl |= TEXTOBJECT_INIT;
6205 }
6206
6207 if (!pTextObj) TEXTOBJ_UnlockText(TextObj);
6208
6209 ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->Font)) != 0);
6210
6211 return Status;
6212}
LPWSTR Name
Definition: desk.c:124
static VOID FASTCALL IntFontType(PFONTGDI Font)
Definition: freetype.c:6019
static __inline VOID FindBestFontFromList(FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
Definition: freetype.c:5950
static VOID IntUnicodeStringToBuffer(LPWSTR pszBuffer, SIZE_T cbBuffer, const UNICODE_STRING *pString)
Definition: freetype.c:1221
static BOOL MatchFontNames(PSHARED_FACE SharedFace, LPCWSTR lfFaceName)
Definition: freetype.c:6077
static NTSTATUS IntGetFontLocalizedName(PUNICODE_STRING pNameW, PSHARED_FACE SharedFace, FT_UShort NameID, FT_UShort LangID)
Definition: freetype.c:3483
static BOOL SubstituteFontRecurse(PLOGFONTW pLogFont)
Definition: freetype.c:1261
#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
#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 4417 of file freetype.c.

4421{
4422 FT_Face face;
4423 INT error, n;
4424 FT_CharMap charmap, found;
4425 LOGFONTW *plf;
4426
4427 if (bDoLock)
4429
4430 face = FontGDI->SharedFace->Face;
4431 if (face->charmap == NULL)
4432 {
4433 DPRINT("WARNING: No charmap selected!\n");
4434 DPRINT("This font face has %d charmaps\n", face->num_charmaps);
4435
4436 found = NULL;
4437 for (n = 0; n < face->num_charmaps; n++)
4438 {
4439 charmap = face->charmaps[n];
4440 if (charmap->encoding == FT_ENCODING_UNICODE)
4441 {
4442 found = charmap;
4443 break;
4444 }
4445 }
4446 if (!found)
4447 {
4448 for (n = 0; n < face->num_charmaps; n++)
4449 {
4450 charmap = face->charmaps[n];
4451 if (charmap->platform_id == TT_PLATFORM_APPLE_UNICODE)
4452 {
4453 found = charmap;
4454 break;
4455 }
4456 }
4457 }
4458 if (!found)
4459 {
4460 for (n = 0; n < face->num_charmaps; n++)
4461 {
4462 charmap = face->charmaps[n];
4463 if (charmap->encoding == FT_ENCODING_MS_SYMBOL)
4464 {
4465 found = charmap;
4466 break;
4467 }
4468 }
4469 }
4470 if (!found && face->num_charmaps > 0)
4471 {
4472 found = face->charmaps[0];
4473 }
4474 if (!found)
4475 {
4476 DPRINT1("WARNING: Could not find desired charmap!\n");
4477 }
4478 else
4479 {
4480 DPRINT("Found charmap encoding: %i\n", found->encoding);
4481 error = FT_Set_Charmap(face, found);
4482 if (error)
4483 {
4484 DPRINT1("WARNING: Could not set the charmap!\n");
4485 }
4486 }
4487 }
4488
4489 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4490
4491 error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4492
4493 if (bDoLock)
4495
4496 if (error)
4497 {
4498 DPRINT1("Error in setting pixel sizes: %d\n", error);
4499 return FALSE;
4500 }
4501
4502 return TRUE;
4503}
WORD face[3]
Definition: mesh.c:4747
#define TT_PLATFORM_APPLE_UNICODE
Definition: font.c:1172
FT_Set_Charmap(FT_Face face, FT_CharMap charmap)
Definition: ftobjs.c:3544
GLdouble n
Definition: glext.h:7729
FT_UShort platform_id
Definition: freetype.h:837

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()