ReactOS 0.4.17-dev-769-g1500a35
freetype.c File Reference
#include <win32k.h>
#include <freetype/internal/ftcalc.h>
#include <gdi/eng/floatobj.h>
#include "font.h"
#include "utils.h"
#include <debug.h>
Include dependency graph for freetype.c:

Go to the source code of this file.

Classes

struct  _FONTLINK
 
struct  _FONTLINK_ENTRY
 
struct  _FONTLINK_CHAIN
 
struct  FONT_NAMES
 

Macros

#define NDEBUG
 
#define FONTLINK_DEFAULT_CHAR   0x30FB
 
#define _TMPF_VARIABLE_PITCH   TMPF_FIXED_PITCH
 
#define EMUBOLD_NEEDED(original, request)    (((request) != FW_DONTCARE) && ((request) - (original) >= FW_BOLD - FW_MEDIUM))
 
#define gmxWorldToDeviceDefault   gmxWorldToPageDefault
 
#define ASSERT_FREETYPE_LOCK_HELD()    ASSERT(g_FreeTypeLock->Owner == KeGetCurrentThread())
 
#define ASSERT_FREETYPE_LOCK_NOT_HELD()    ASSERT(g_FreeTypeLock->Owner != KeGetCurrentThread())
 
#define IntLockFreeType()
 
#define IntUnLockFreeType()
 
#define MAX_FONT_CACHE   256
 
#define CP_SYMBOL   42
 
#define MAXTCIINDEX   32
 
#define CP_OEMCP   1
 
#define CP_MACCP   2
 
#define SCALE_X(value)   ((FT_MulFix((value), XScale) + 32) >> 6)
 
#define SCALE_Y(value)   ((FT_MulFix((value), YScale) + 32) >> 6)
 
#define FM_SEL_USE_TYPO_METRICS   0x80
 
#define GOT_PENALTY(name, value)   Penalty += (value)
 
#define VALIGN_MASK   (TA_TOP | TA_BASELINE | TA_BOTTOM)
 
#define STACK_TEXT_BUFFER_SIZE   512
 

Typedefs

typedef struct _FONTLINK FONTLINK
 
typedef struct _FONTLINKPFONTLINK
 
typedef struct _FONTLINK_ENTRY FONTLINK_ENTRY
 
typedef struct _FONTLINK_ENTRYPFONTLINK_ENTRY
 
typedef struct _FONTLINK_CHAIN FONTLINK_CHAIN
 
typedef struct _FONTLINK_CHAINPFONTLINK_CHAIN
 
typedef struct FONT_NAMES FONT_NAMES
 
typedef struct FONT_NAMESLPFONT_NAMES
 

Functions

 DBG_DEFAULT_CHANNEL (GdiFont)
 
static RTL_STATIC_LIST_HEAD (g_FontLinkEntries)
 
static NTSTATUS FontLink_LoadSettings (VOID)
 
static NTSTATUS FontLink_LoadDefaultFonts (VOID)
 
static NTSTATUS FontLink_LoadDefaultCharset (VOID)
 
static VOID FontLink_Destroy (_Inout_ PFONTLINK pLink)
 
static BOOL FontLink_Chain_IsPopulated (const FONTLINK_CHAIN *pChain)
 
static RTL_STATIC_LIST_HEAD (g_FontListHead)
 
static RTL_STATIC_LIST_HEAD (g_FontCacheListHead)
 
BYTE FASTCALL IntCharSetFromCodePage (UINT uCodePage)
 
static __inline VOID FindBestFontFromList (FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
 
static BOOL MatchFontName (PSHARED_FACE SharedFace, PUNICODE_STRING Name1, FT_UShort NameID, FT_UShort LangID)
 
static BOOL FontLink_PrepareFontInfo (_Inout_ PFONTLINK pFontLink)
 
static RTL_STATIC_LIST_HEAD (g_FontSubstListHead)
 
static void SharedMem_AddRef (PSHARED_MEM Ptr)
 
static void SharedFaceCache_Init (PSHARED_FACE_CACHE Cache)
 
static PSHARED_FACE SharedFace_Create (FT_Face Face, PSHARED_MEM Memory)
 
static PSHARED_MEM SharedMem_Create (PBYTE Buffer, ULONG BufferSize, BOOL IsMapping)
 
static void SharedFace_AddRef (PSHARED_FACE Ptr)
 
static void RemoveCachedEntry (PFONT_CACHE_ENTRY Entry)
 
static void RemoveCacheEntries (FT_Face Face)
 
static void SharedMem_Release (PSHARED_MEM Ptr)
 
static void SharedFaceCache_Release (PSHARED_FACE_CACHE Cache)
 
static void SharedFace_Release (PSHARED_FACE Ptr, BOOL bDoLock)
 
static VOID FASTCALL CleanupFontEntryEx (PFONT_ENTRY FontEntry, PFONTGDI FontGDI)
 
static __inline VOID FASTCALL CleanupFontEntry (PFONT_ENTRY FontEntry)
 
static __inline void FTVectorToPOINTFX (FT_Vector *vec, POINTFX *pt)
 
static __inline FT_Fixed FT_FixedFromFIXED (FIXED f)
 
BOOL FASTCALL IntLoadFontSubstList (PLIST_ENTRY pHead)
 
static NTSTATUS FontLink_AddEntry (LPCWSTR lfFaceName, PZZWSTR pszzFontLink)
 
static void FontLink_DeleteEntries (VOID)
 
static NTSTATUS FontLink_PopulateEntries (VOID)
 
BOOL FASTCALL InitFontSupport (VOID)
 
VOID FASTCALL FreeFontSupport (VOID)
 
static VOID FASTCALL IntEscapeMatrix (FT_Matrix *pmat, LONG lfEscapement)
 
static VOID FASTCALL IntMatrixFromMx (FT_Matrix *pmat, const MATRIX *pmx)
 
static BOOL SubstituteFontByList (PLIST_ENTRY pHead, PUNICODE_STRING pOutputName, PUNICODE_STRING pInputName, BYTE RequestedCharSet, BYTE CharSetMap[FONTSUBST_FROM_AND_TO])
 
static BOOL SubstituteFontRecurse (PLOGFONTW pLogFont)
 
static VOID FontLink_Chain_Init (_Out_ PFONTLINK_CHAIN pChain, _Inout_ PTEXTOBJ pTextObj, _In_ FT_Face face)
 
static PFONTLINK FontLink_Chain_FindLink (PFONTLINK_CHAIN pChain, PLOGFONTW plf)
 
static PFONTLINK FontLink_Create (_Inout_ PFONTLINK_CHAIN pChain, _In_ const LOGFONTW *plfBase, _In_ LPCWSTR pszLink)
 
static PFONTLINK_ENTRY FontLink_FindEntry (const LOGFONTW *pLogFont)
 
static NTSTATUS FontLink_Chain_FindEntry (_Inout_ PFONTLINK_CHAIN pChain, _Inout_ PLOGFONTW pLF)
 
static NTSTATUS FontLink_Chain_Populate (_Inout_ PFONTLINK_CHAIN pChain)
 
VOID FASTCALL IntLoadSystemFonts (VOID)
 
UINT FASTCALL IntGetCharSet (INT nIndex, FT_ULong CodePageRange1)
 
static BOOL select_charmap (FT_Face ft_face, FT_Encoding encoding)
 
static FT_Encoding pick_charmap (FT_Face face, int charset)
 
static INT FASTCALL IntGdiLoadFontsFromMemory (PGDI_LOAD_FONT pLoadFont, PSHARED_FACE SharedFace, FT_Long FontIndex, INT CharSetIndex)
 
static INT FASTCALL IntGdiLoadFontByIndexFromMemory (PGDI_LOAD_FONT pLoadFont, FT_Long FontIndex)
 
static INT FASTCALL IntGdiAddFontResourceSingle (_In_ PCUNICODE_STRING FileName, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
 
INT FASTCALL IntGdiAddFontResourceEx (_In_ PCUNICODE_STRING FileName, _In_ DWORD cFiles, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
 
VOID IntDeleteRegFontEntries (_In_ PCWSTR pszFileName, _In_ DWORD dwFlags)
 
static BOOL FASTCALL IntGdiRemoveFontResourceSingle (_In_ PCUNICODE_STRING FileName, _In_ DWORD dwFlags)
 
BOOL FASTCALL IntGdiRemoveFontResource (_In_ PCUNICODE_STRING FileName, _In_ DWORD cFiles, _In_ DWORD dwFlags)
 
BOOL FASTCALL IntLoadFontsInRegistry (VOID)
 
HANDLE FASTCALL IntGdiAddFontMemResource (PVOID Buffer, DWORD dwSize, PDWORD pNumAdded)
 
VOID FASTCALL IntGdiCleanupMemEntry (PFONT_ENTRY_MEM Head)
 
static VOID FASTCALL UnlinkFontMemCollection (PFONT_ENTRY_COLL_MEM Collection)
 
BOOL FASTCALL IntGdiRemoveFontMemResource (HANDLE hMMFont)
 
VOID FASTCALL IntGdiCleanupPrivateFontsForProcess (VOID)
 
BOOL FASTCALL IntIsFontRenderingEnabled (VOID)
 
VOID FASTCALL IntEnableFontRendering (BOOL Enable)
 
FT_Render_Mode FASTCALL IntGetFontRenderMode (LOGFONTW *logfont)
 
NTSTATUS FASTCALL TextIntCreateFontIndirect (CONST LPLOGFONTW lf, HFONT *NewFont)
 
static BOOLEAN IntTranslateCharsetInfo (PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
 
static BOOL face_has_symbol_charmap (FT_Face ft_face)
 
static void FASTCALL FillTM (TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT)
 
static NTSTATUS IntGetFontLocalizedName (PUNICODE_STRING pNameW, PSHARED_FACE SharedFace, FT_UShort NameID, FT_UShort LangID)
 
static __inline void FASTCALL IntInitFontNames (FONT_NAMES *Names, PSHARED_FACE SharedFace)
 
static SIZE_T FASTCALL IntStoreName (_In_ const UNICODE_STRING *pName, _Out_ PBYTE pb)
 
PBYTE FASTCALL IntStoreFontNames (_In_ const FONT_NAMES *Names, _Out_ OUTLINETEXTMETRICW *Otm)
 
static __inline void FASTCALL IntFreeFontNames (FONT_NAMES *Names)
 
INT FASTCALL IntGetOutlineTextMetrics (PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm, BOOL bLocked)
 
static void FASTCALL FontFamilyFillInfo (PFONTFAMILYINFO Info, LPCWSTR FaceName, LPCWSTR FullName, PFONTGDI FontGDI)
 
static BOOLEAN FASTCALL GetFontFamilyInfoForList (const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LPCWSTR NominalName, LONG *pCount, LONG MaxCount, PLIST_ENTRY Head)
 
static BOOLEAN FASTCALL GetFontFamilyInfoForSubstitutes (const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LONG *pCount, LONG MaxCount)
 
BOOL FASTCALL ftGdiGetRasterizerCaps (LPRASTERIZER_STATUS lprs)
 
static DWORD IntGetHash (IN LPCVOID pv, IN DWORD cdw)
 
static FT_BitmapGlyph IntFindGlyphCache (IN const FONT_CACHE_ENTRY *pCache)
 
static FT_BitmapGlyph IntGetBitmapGlyphWithCache (IN OUT PFONT_CACHE_ENTRY Cache, IN FT_GlyphSlot GlyphSlot)
 
static unsigned int get_native_glyph_outline (FT_Outline *outline, unsigned int buflen, char *buf)
 
static unsigned int get_bezier_glyph_outline (FT_Outline *outline, unsigned int buflen, char *buf)
 
static FT_Error IntRequestFontSizeEx (_In_ FT_Face face, _In_ LONG lfWidth, _In_ LONG lfHeight, _Out_opt_ PLONG ptmHeight, _Out_opt_ PLONG ptmAscent, _Out_opt_ PLONG ptmDescent, _Out_opt_ PLONG ptmInternalLeading, _Out_opt_ PLONG plfHeight, _Out_opt_ PLONG plfWidth)
 
static FT_Error IntRequestFontSize (_Inout_ PFONTGDI FontGDI, _In_ LONG lfWidth, _In_ LONG lfHeight)
 
BOOL FASTCALL TextIntUpdateSize (_In_ PTEXTOBJ TextObj, _In_ PFONTGDI FontGDI, _In_ BOOL bDoLock)
 
static FT_UInt FASTCALL get_glyph_index_symbol (FT_Face ft_face, UINT glyph)
 
static FT_UInt FASTCALL get_glyph_index (FT_Face ft_face, UINT glyph)
 
static FT_UInt FASTCALL get_glyph_index_flagged (FT_Face face, FT_ULong code, BOOL fCodeAsIndex)
 
static VOID FontLink_Chain_Dump (_In_ PFONTLINK_CHAIN pChain)
 
static BOOL IntNeedRequestFontSize (PFONTLINK_CHAIN pChain, FT_Face face, PLIST_ENTRY TargetEntry)
 
static UINT FontLink_Chain_FindGlyph (_Inout_ PFONTLINK_CHAIN pChain, _Out_ PFONT_CACHE_ENTRY pCache, _Inout_ FT_Face *pFace, _In_ UINT code, _In_ BOOL fCodeAsIndex)
 
ULONG FASTCALL ftGdiGetGlyphOutline (PDC dc, WCHAR wch, UINT iFormat, LPGLYPHMETRICS pgm, ULONG cjBuf, PVOID pvBuf, const MAT2 *pmat2, BOOL bIgnoreRotation)
 
static FT_BitmapGlyph IntGetRealGlyph (IN OUT PFONT_CACHE_ENTRY Cache)
 
BOOL FASTCALL TextIntGetTextExtentPoint (_In_ PDC dc, _In_ PTEXTOBJ TextObj, _In_reads_(Count) PCWCH String, _In_ INT Count, _In_ ULONG MaxExtent, _Out_ PINT Fit, _Out_writes_to_opt_(Count, *Fit) PINT Dx, _Out_ PSIZE Size, _In_ FLONG fl)
 
INT FASTCALL ftGdiGetTextCharsetInfo (PDC Dc, LPFONTSIGNATURE lpSig, DWORD dwFlags)
 
DWORD FASTCALL ftGetFontUnicodeRanges (PFONTGDI Font, PGLYPHSET glyphset)
 
BOOL FASTCALL ftGdiGetTextMetricsW (HDC hDC, PTMW_INTERNAL ptmwi)
 
DWORD FASTCALL ftGdiGetFontData (PFONTGDI FontGdi, DWORD Table, DWORD Offset, PVOID Buffer, DWORD Size)
 
static UINT GetFontPenalty (const LOGFONTW *LogFont, const OUTLINETEXTMETRICW *Otm, const char *style_name)
 
static VOID FASTCALL IntFontType (PFONTGDI Font)
 
static BOOL MatchFontNames (PSHARED_FACE SharedFace, LPCWSTR lfFaceName)
 
static BOOL FASTCALL IntGetFullFileName (POBJECT_NAME_INFORMATION NameInfo, ULONG Size, PUNICODE_STRING FileName)
 
static BOOL EqualFamilyInfo (const FONTFAMILYINFO *pInfo1, const FONTFAMILYINFO *pInfo2)
 
static VOID IntAddNameFromFamInfo (LPWSTR psz, FONTFAMILYINFO *FamInfo)
 
NTSTATUS FASTCALL TextIntRealizeFont (HFONT FontHandle, PTEXTOBJ pTextObj)
 
BOOL FASTCALL IntGdiGetFontResourceInfo (PUNICODE_STRING FileName, PVOID pBuffer, DWORD *pdwBytes, DWORD dwType)
 
BOOL FASTCALL ftGdiRealizationInfo (PFONTGDI Font, PREALIZATION_INFO Info)
 
DWORD FASTCALL ftGdiGetKerningPairs (PFONTGDI Font, DWORD cPairs, LPKERNINGPAIR pKerningPair)
 
LONG FASTCALL IntGetFontFamilyInfo (HDC Dc, const LOGFONTW *SafeLogFont, PFONTFAMILYINFO SafeInfo, LONG InfoCount)
 
LONG NTAPI NtGdiGetFontFamilyInfo (_In_ HDC Dc, _In_ const LOGFONTW *UnsafeLogFont, _Out_ PFONTFAMILYINFO UnsafeInfo, _Inout_ PLONG UnsafeInfoCount)
 
static BOOL IntGetTextDisposition (_Out_ LONGLONG *pX64, _Out_ LONGLONG *pY64, _In_reads_(Count) PCWCH String, _In_ INT Count, _In_opt_ const INT *Dx, _Inout_ PFONT_CACHE_ENTRY Cache, _In_ UINT fuOptions, _In_ BOOL bNoTransform, _Inout_ PFONTLINK_CHAIN pChain)
 
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)
 
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)
 
BOOL APIENTRY NtGdiExtTextOutW (_In_ HDC hDC, _In_ INT XStart, _In_ INT YStart, _In_ UINT fuOptions, _In_opt_ LPCRECT UnsafeRect, _In_reads_opt_(Count) PCWCH UnsafeString, _In_range_(0, 0xFFFF) UINT Count, _In_reads_opt_(_Inexpressible_(cwc)) const INT *UnsafeDx, _In_ DWORD dwCodePage)
 
BOOL APIENTRY GreGetCharABCWidthsW (_In_ HDC hDC, _In_ UINT FirstChar, _In_ UINT Count, _In_reads_opt_(Count) PCWCH Safepwch, _In_ FLONG fl, _Out_writes_bytes_(Count *sizeof(ABC)) PVOID SafeBuffer)
 
BOOL APIENTRY GreGetCharWidthW (_In_ HDC hDC, _In_ UINT FirstChar, _In_ UINT Count, _In_reads_opt_(Count) PCWCH Safepwc, _In_ FLONG fl, _Out_writes_bytes_(Count *sizeof(INT)) PVOID Buffer)
 
static BOOL IntGetFontDefaultChar (_In_ FT_Face Face, _Out_ PWCHAR pDefChar)
 
DWORD APIENTRY GreGetGlyphIndicesW (_In_ HDC hdc, _In_reads_opt_(cwc) PCWCH pwc, _In_ INT cwc, _Out_writes_opt_(cwc) PWORD pgi, _In_ DWORD iMode, _In_ BOOL bSubset)
 

Variables

static DWORD s_chFontLinkDefaultChar = FONTLINK_DEFAULT_CHAR
 
static WCHAR s_szDefFontLinkFileName [MAX_PATH] = L""
 
static WCHAR s_szDefFontLinkFontName [MAX_PATH] = L""
 
static BOOL s_fFontLinkUseAnsi = FALSE
 
static BOOL s_fFontLinkUseOem = FALSE
 
static BOOL s_fFontLinkUseSymbol = FALSE
 
const MATRIX gmxWorldToDeviceDefault
 
const MATRIX gmxWorldToPageDefault
 
static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)}
 
FT_Library g_FreeTypeLibrary
 
UNICODE_STRING g_FontRegPath
 
static PFAST_MUTEX g_FreeTypeLock
 
static BOOL g_RenderingEnabled = TRUE
 
static UINT g_FontCacheNumEntries
 
static PWCHAR g_ElfScripts [32]
 
static const CHARSETINFO g_FontTci [MAXTCIINDEX]
 
static const WCHAR s_szzDefFontLink []
 
static const WCHAR s_szzDefFixedFontLink []
 
static const UNICODE_STRING DosPathPrefix = RTL_CONSTANT_STRING(L"\\??\\")
 

Macro Definition Documentation

◆ _TMPF_VARIABLE_PITCH

#define _TMPF_VARIABLE_PITCH   TMPF_FIXED_PITCH

Definition at line 192 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_HELD

#define ASSERT_FREETYPE_LOCK_HELD ( )     ASSERT(g_FreeTypeLock->Owner == KeGetCurrentThread())

Definition at line 219 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_NOT_HELD

#define ASSERT_FREETYPE_LOCK_NOT_HELD ( )     ASSERT(g_FreeTypeLock->Owner != KeGetCurrentThread())

Definition at line 222 of file freetype.c.

◆ CP_MACCP

#define CP_MACCP   2

Definition at line 313 of file freetype.c.

◆ CP_OEMCP

#define CP_OEMCP   1

Definition at line 312 of file freetype.c.

◆ CP_SYMBOL

#define CP_SYMBOL   42

Definition at line 268 of file freetype.c.

◆ EMUBOLD_NEEDED

#define EMUBOLD_NEEDED (   original,
  request 
)     (((request) != FW_DONTCARE) && ((request) - (original) >= FW_BOLD - FW_MEDIUM))

Definition at line 196 of file freetype.c.

◆ FM_SEL_USE_TYPO_METRICS

#define FM_SEL_USE_TYPO_METRICS   0x80

◆ FONTLINK_DEFAULT_CHAR

#define FONTLINK_DEFAULT_CHAR   0x30FB

Definition at line 58 of file freetype.c.

◆ gmxWorldToDeviceDefault

#define gmxWorldToDeviceDefault   gmxWorldToPageDefault

Definition at line 204 of file freetype.c.

◆ GOT_PENALTY

#define GOT_PENALTY (   name,
  value 
)    Penalty += (value)

Definition at line 5411 of file freetype.c.

◆ IntLockFreeType

#define IntLockFreeType ( )
Value:
do { \
ASSERT_FREETYPE_LOCK_NOT_HELD(); \
ExEnterCriticalRegionAndAcquireFastMutexUnsafe(g_FreeTypeLock); \
} while (0)
static PFAST_MUTEX g_FreeTypeLock
Definition: freetype.c:214

Definition at line 225 of file freetype.c.

◆ IntUnLockFreeType

#define IntUnLockFreeType ( )
Value:
do { \
ASSERT_FREETYPE_LOCK_HELD(); \
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(g_FreeTypeLock); \
} while(0)

Definition at line 231 of file freetype.c.

◆ MAX_FONT_CACHE

#define MAX_FONT_CACHE   256

Definition at line 237 of file freetype.c.

◆ MAXTCIINDEX

#define MAXTCIINDEX   32

Definition at line 269 of file freetype.c.

◆ NDEBUG

#define NDEBUG

Definition at line 30 of file freetype.c.

◆ SCALE_X

#define SCALE_X (   value)    ((FT_MulFix((value), XScale) + 32) >> 6)

◆ SCALE_Y

#define SCALE_Y (   value)    ((FT_MulFix((value), YScale) + 32) >> 6)

◆ STACK_TEXT_BUFFER_SIZE

#define STACK_TEXT_BUFFER_SIZE   512

Definition at line 7253 of file freetype.c.

◆ VALIGN_MASK

#define VALIGN_MASK   (TA_TOP | TA_BASELINE | TA_BOTTOM)

Typedef Documentation

◆ FONT_NAMES

◆ FONTLINK

◆ FONTLINK_CHAIN

◆ FONTLINK_ENTRY

◆ LPFONT_NAMES

◆ PFONTLINK

◆ PFONTLINK_CHAIN

◆ PFONTLINK_ENTRY

Function Documentation

◆ CleanupFontEntry()

static __inline VOID FASTCALL CleanupFontEntry ( PFONT_ENTRY  FontEntry)
static

Definition at line 573 of file freetype.c.

574{
575 CleanupFontEntryEx(FontEntry, FontEntry->Font);
576}
static VOID FASTCALL CleanupFontEntryEx(PFONT_ENTRY FontEntry, PFONTGDI FontGDI)
Definition: freetype.c:553
FONTGDI * Font
Definition: font.h:7

Referenced by FreeFontSupport(), IntGdiCleanupMemEntry(), IntGdiCleanupPrivateFontsForProcess(), and IntGdiRemoveFontResourceSingle().

◆ CleanupFontEntryEx()

static VOID FASTCALL CleanupFontEntryEx ( PFONT_ENTRY  FontEntry,
PFONTGDI  FontGDI 
)
static

Definition at line 553 of file freetype.c.

554{
555 // PFONTGDI FontGDI = FontEntry->Font;
556 PSHARED_FACE SharedFace = FontGDI->SharedFace;
557
558 if (FontGDI->Filename)
560
561 if (FontEntry->StyleName.Buffer)
562 RtlFreeUnicodeString(&FontEntry->StyleName);
563
564 if (FontEntry->FaceName.Buffer)
565 RtlFreeUnicodeString(&FontEntry->FaceName);
566
567 EngFreeMem(FontGDI);
568 SharedFace_Release(SharedFace, TRUE);
569 ExFreePoolWithTag(FontEntry, TAG_FONT);
570}
#define TRUE
Definition: types.h:120
static void SharedFace_Release(PSHARED_FACE Ptr, BOOL bDoLock)
Definition: freetype.c:523
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define EngFreeMem
Definition: polytest.cpp:56
LPWSTR Filename
Definition: engobjects.h:151
PSHARED_FACE SharedFace
Definition: engobjects.h:145
UNICODE_STRING StyleName
Definition: font.h:9
UNICODE_STRING FaceName
Definition: font.h:8
#define TAG_FONT
Definition: tags.h:12
#define GDITAG_PFF
Definition: tags.h:149

Referenced by CleanupFontEntry().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( GdiFont  )

◆ EqualFamilyInfo()

static BOOL EqualFamilyInfo ( const FONTFAMILYINFO pInfo1,
const FONTFAMILYINFO pInfo2 
)
static

Definition at line 5956 of file freetype.c.

5957{
5958 const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5959 const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5960 const LOGFONTW *plf1 = &pLog1->elfLogFont;
5961 const LOGFONTW *plf2 = &pLog2->elfLogFont;
5962
5963 if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5964 {
5965 return FALSE;
5966 }
5967
5968 if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5969 {
5970 return FALSE;
5971 }
5972
5973 return TRUE;
5974}
#define FALSE
Definition: types.h:117
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:3150
LOGFONTW elfLogFont
Definition: wingdi.h:3148
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47

Referenced by IntGdiGetFontResourceInfo().

◆ face_has_symbol_charmap()

static BOOL face_has_symbol_charmap ( FT_Face  ft_face)
static

Definition at line 2822 of file freetype.c.

2823{
2824 int i;
2825
2826 for(i = 0; i < ft_face->num_charmaps; i++)
2827 {
2828 if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
2829 ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
2830 {
2831 return TRUE;
2832 }
2833 }
2834 return FALSE;
2835}
#define TT_PLATFORM_MICROSOFT
Definition: font.c:1132
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
FT_Encoding encoding
Definition: freetype.h:820
FT_UShort platform_id
Definition: freetype.h:821
FT_Int num_charmaps
Definition: freetype.h:1044
FT_CharMap * charmaps
Definition: freetype.h:1045

Referenced by FillTM(), and get_glyph_index().

◆ FillTM()

static void FASTCALL FillTM ( TEXTMETRICW TM,
PFONTGDI  FontGDI,
TT_OS2 pOS2,
TT_HoriHeader pHori,
FT_WinFNT_HeaderRec pFNT 
)
static

Definition at line 2838 of file freetype.c.

2841{
2842 FT_Fixed XScale, YScale;
2843 int Ascent, Descent;
2844 FT_Face Face = FontGDI->SharedFace->Face;
2845
2847
2848 XScale = Face->size->metrics.x_scale;
2849 YScale = Face->size->metrics.y_scale;
2850
2851 if (pFNT)
2852 {
2853 TM->tmHeight = pFNT->pixel_height;
2854 TM->tmAscent = pFNT->ascent;
2855 TM->tmDescent = TM->tmHeight - TM->tmAscent;
2858 TM->tmAveCharWidth = pFNT->avg_width;
2859 TM->tmMaxCharWidth = pFNT->max_width;
2860 TM->tmOverhang = 0;
2863 TM->tmFirstChar = pFNT->first_char;
2864 TM->tmLastChar = pFNT->last_char;
2865 TM->tmDefaultChar = pFNT->default_char + pFNT->first_char;
2866 TM->tmBreakChar = pFNT->break_char + pFNT->first_char;
2868 TM->tmWeight = FontGDI->RequestWeight;
2869 TM->tmItalic = FontGDI->RequestItalic;
2870 TM->tmUnderlined = FontGDI->RequestUnderline;
2871 TM->tmStruckOut = FontGDI->RequestStrikeOut;
2872 TM->tmCharSet = FontGDI->CharSet;
2873 return;
2874 }
2875
2876 ASSERT(pOS2);
2877 if (!pOS2)
2878 return;
2879
2880 if ((FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent == 0)
2881 {
2882 Ascent = pHori->Ascender;
2883 Descent = -pHori->Descender;
2884 }
2885 else
2886 {
2887 Ascent = (FT_Short)pOS2->usWinAscent;
2888 Descent = (FT_Short)pOS2->usWinDescent;
2889 }
2890
2891 TM->tmAscent = FontGDI->tmAscent;
2892 TM->tmDescent = FontGDI->tmDescent;
2893 TM->tmHeight = TM->tmAscent + TM->tmDescent;
2894 TM->tmInternalLeading = FontGDI->tmInternalLeading;
2895
2896 /* MSDN says:
2897 * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
2898 */
2899 TM->tmExternalLeading = max(0, (FT_MulFix(pHori->Line_Gap
2900 - ((Ascent + Descent)
2901 - (pHori->Ascender - pHori->Descender)),
2902 YScale) + 32) >> 6);
2903 if (FontGDI->lfWidth != 0)
2904 TM->tmAveCharWidth = FontGDI->lfWidth;
2905 else
2906 TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
2907
2908 if (TM->tmAveCharWidth == 0)
2909 TM->tmAveCharWidth = 1;
2910
2911 /* Correct forumla to get the maxcharwidth from unicode and ansi font */
2912 TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
2913
2914 if (FontGDI->OriginalWeight != FW_DONTCARE &&
2915 FontGDI->OriginalWeight > FontGDI->RequestWeight)
2916 {
2917 TM->tmWeight = FontGDI->OriginalWeight;
2918 }
2919 else
2920 {
2921 TM->tmWeight = FontGDI->RequestWeight;
2922 }
2923
2924 TM->tmOverhang = 0;
2925 TM->tmDigitizedAspectX = 96;
2926 TM->tmDigitizedAspectY = 96;
2927 if (face_has_symbol_charmap(Face) ||
2928 (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
2929 {
2930 USHORT cpOEM, cpAnsi;
2931
2932 EngGetCurrentCodePage(&cpOEM, &cpAnsi);
2933 TM->tmFirstChar = 0;
2934 switch(cpAnsi)
2935 {
2936 case 1257: /* Baltic */
2937 TM->tmLastChar = 0xf8fd;
2938 break;
2939 default:
2940 TM->tmLastChar = 0xf0ff;
2941 }
2942 TM->tmBreakChar = 0x20;
2943 TM->tmDefaultChar = 0x1f;
2944 }
2945 else
2946 {
2947 TM->tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
2948 TM->tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
2949
2950 if(pOS2->usFirstCharIndex <= 1)
2951 TM->tmBreakChar = pOS2->usFirstCharIndex + 2;
2952 else if (pOS2->usFirstCharIndex > 0xff)
2953 TM->tmBreakChar = 0x20;
2954 else
2955 TM->tmBreakChar = pOS2->usFirstCharIndex;
2956 TM->tmDefaultChar = TM->tmBreakChar - 1;
2957 }
2958
2959 if (FontGDI->OriginalItalic || FontGDI->RequestItalic)
2960 {
2961 TM->tmItalic = 0xFF;
2962 }
2963 else
2964 {
2965 TM->tmItalic = 0;
2966 }
2967 TM->tmUnderlined = (FontGDI->RequestUnderline ? 0xFF : 0);
2968 TM->tmStruckOut = (FontGDI->RequestStrikeOut ? 0xFF : 0);
2969
2970 if (!FT_IS_FIXED_WIDTH(Face))
2971 {
2972 switch (pOS2->panose[PAN_PROPORTION_INDEX])
2973 {
2975 TM->tmPitchAndFamily = 0;
2976 break;
2977 default:
2979 break;
2980 }
2981 }
2982 else
2983 {
2984 TM->tmPitchAndFamily = 0;
2985 }
2986
2987 switch (pOS2->panose[PAN_FAMILYTYPE_INDEX])
2988 {
2989 case PAN_FAMILY_SCRIPT:
2991 break;
2994 break;
2995
2996 case PAN_ANY:
2997 case PAN_NO_FIT:
2999 case PAN_FAMILY_PICTORIAL: /* Symbol fonts get treated as if they were text */
3000 /* Which is clearly not what the panose spec says. */
3001 if (TM->tmPitchAndFamily == 0) /* Fixed */
3002 {
3004 }
3005 else
3006 {
3007 switch (pOS2->panose[PAN_SERIFSTYLE_INDEX])
3008 {
3009 case PAN_ANY:
3010 case PAN_NO_FIT:
3011 default:
3013 break;
3014
3015 case PAN_SERIF_COVE:
3019 case PAN_SERIF_SQUARE:
3020 case PAN_SERIF_THIN:
3021 case PAN_SERIF_BONE:
3023 case PAN_SERIF_TRIANGLE:
3025 break;
3026
3030 case PAN_SERIF_FLARED:
3031 case PAN_SERIF_ROUNDED:
3033 break;
3034 }
3035 }
3036 break;
3037 default:
3039 }
3040
3041 if (FT_IS_SCALABLE(Face))
3042 {
3044 }
3045 if (FT_IS_SFNT(Face))
3046 {
3048 }
3049
3050 TM->tmCharSet = FontGDI->CharSet;
3051}
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2822
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:219
#define _TMPF_VARIABLE_PITCH
Definition: freetype.c:192
#define FT_IS_SFNT(face)
Definition: freetype.h:1290
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1271
#define FT_IS_FIXED_WIDTH(face)
Definition: freetype.h:1305
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:508
signed long FT_Fixed
Definition: fttypes.h:287
signed short FT_Short
Definition: fttypes.h:198
#define ASSERT(a)
Definition: mode.c:44
unsigned short USHORT
Definition: pedump.c:61
FT_Size size
Definition: freetype.h:1066
FT_Short max_advance_width
Definition: freetype.h:1059
FT_Size_Metrics metrics
Definition: freetype.h:1636
FT_Fixed y_scale
Definition: freetype.h:1601
FT_Fixed x_scale
Definition: freetype.h:1600
FT_UShort horizontal_resolution
Definition: ftwinfnt.h:191
FT_Byte pitch_and_family
Definition: ftwinfnt.h:202
FT_Byte default_char
Definition: ftwinfnt.h:207
FT_UShort internal_leading
Definition: ftwinfnt.h:193
FT_UShort avg_width
Definition: ftwinfnt.h:203
FT_UShort external_leading
Definition: ftwinfnt.h:194
FT_UShort ascent
Definition: ftwinfnt.h:192
FT_UShort max_width
Definition: ftwinfnt.h:204
FT_UShort pixel_height
Definition: ftwinfnt.h:201
FT_UShort vertical_resolution
Definition: ftwinfnt.h:190
FT_Short Line_Gap
Definition: tttables.h:205
FT_Short Ascender
Definition: tttables.h:203
FT_Short Descender
Definition: tttables.h:204
FT_UShort usLastCharIndex
Definition: tttables.h:405
FT_Byte panose[10]
Definition: tttables.h:394
FT_UShort usWinDescent
Definition: tttables.h:410
FT_UShort usWinAscent
Definition: tttables.h:409
FT_Short xAvgCharWidth
Definition: tttables.h:378
FT_UShort usFirstCharIndex
Definition: tttables.h:404
LONG tmInternalLeading
Definition: engobjects.h:164
BYTE RequestItalic
Definition: engobjects.h:154
LONG RequestWeight
Definition: engobjects.h:155
LONG lfWidth
Definition: engobjects.h:167
LONG tmAscent
Definition: engobjects.h:162
BYTE RequestStrikeOut
Definition: engobjects.h:153
LONG tmDescent
Definition: engobjects.h:163
BYTE OriginalItalic
Definition: engobjects.h:156
BYTE CharSet
Definition: engobjects.h:158
LONG OriginalWeight
Definition: engobjects.h:157
BYTE RequestUnderline
Definition: engobjects.h:152
FT_Face Face
Definition: engobjects.h:132
WCHAR tmFirstChar
Definition: wingdi.h:2840
LONG tmDigitizedAspectX
Definition: wingdi.h:2838
LONG tmDigitizedAspectY
Definition: wingdi.h:2839
LONG tmOverhang
Definition: wingdi.h:2837
LONG tmAveCharWidth
Definition: wingdi.h:2834
LONG tmAscent
Definition: wingdi.h:2830
LONG tmMaxCharWidth
Definition: wingdi.h:2835
BYTE tmItalic
Definition: wingdi.h:2844
BYTE tmStruckOut
Definition: wingdi.h:2846
LONG tmInternalLeading
Definition: wingdi.h:2832
BYTE tmUnderlined
Definition: wingdi.h:2845
LONG tmExternalLeading
Definition: wingdi.h:2833
BYTE tmPitchAndFamily
Definition: wingdi.h:2847
LONG tmWeight
Definition: wingdi.h:2836
WCHAR tmBreakChar
Definition: wingdi.h:2843
WCHAR tmDefaultChar
Definition: wingdi.h:2842
BYTE tmCharSet
Definition: wingdi.h:2848
WCHAR tmLastChar
Definition: wingdi.h:2841
LONG tmHeight
Definition: wingdi.h:2829
LONG tmDescent
Definition: wingdi.h:2831
#define max(a, b)
Definition: svc.c:63
ENGAPI VOID APIENTRY EngGetCurrentCodePage(_Out_ PUSHORT OemCodePage, _Out_ PUSHORT AnsiCodePage)
Definition: engmisc.c:232
#define PAN_SERIF_THIN
Definition: wingdi.h:476
#define PAN_FAMILY_TEXT_DISPLAY
Definition: wingdi.h:467
#define PAN_PROP_MONOSPACED
Definition: wingdi.h:502
#define FW_DONTCARE
Definition: wingdi.h:368
#define PAN_SERIFSTYLE_INDEX
Definition: wingdi.h:455
#define FF_MODERN
Definition: wingdi.h:449
#define FF_DECORATIVE
Definition: wingdi.h:447
#define PAN_SERIF_NORMAL_SANS
Definition: wingdi.h:480
#define FF_SCRIPT
Definition: wingdi.h:451
#define PAN_SERIF_BONE
Definition: wingdi.h:477
#define FF_ROMAN
Definition: wingdi.h:450
#define PAN_SERIF_OBTUSE_SANS
Definition: wingdi.h:481
#define PAN_FAMILY_PICTORIAL
Definition: wingdi.h:470
#define FF_DONTCARE
Definition: wingdi.h:448
#define PAN_SERIF_TRIANGLE
Definition: wingdi.h:479
#define TMPF_TRUETYPE
Definition: wingdi.h:1313
#define PAN_PROPORTION_INDEX
Definition: wingdi.h:457
#define PAN_NO_FIT
Definition: wingdi.h:466
#define PAN_SERIF_SQUARE_COVE
Definition: wingdi.h:473
#define PAN_SERIF_SQUARE
Definition: wingdi.h:475
#define PAN_SERIF_OBTUSE_SQUARE_COVE
Definition: wingdi.h:474
#define PAN_SERIF_COVE
Definition: wingdi.h:471
#define TMPF_VECTOR
Definition: wingdi.h:1312
#define PAN_SERIF_EXAGGERATED
Definition: wingdi.h:478
#define PAN_SERIF_ROUNDED
Definition: wingdi.h:484
#define PAN_FAMILYTYPE_INDEX
Definition: wingdi.h:454
#define PAN_FAMILY_DECORATIVE
Definition: wingdi.h:469
#define PAN_SERIF_PERP_SANS
Definition: wingdi.h:482
#define PAN_SERIF_FLARED
Definition: wingdi.h:483
#define PAN_FAMILY_SCRIPT
Definition: wingdi.h:468
#define PAN_SERIF_OBTUSE_COVE
Definition: wingdi.h:472
#define PAN_ANY
Definition: wingdi.h:465
#define FF_SWISS
Definition: wingdi.h:452

Referenced by ftGdiGetTextMetricsW(), and IntGetOutlineTextMetrics().

◆ FindBestFontFromList()

static __inline VOID FindBestFontFromList ( FONTOBJ **  FontObj,
ULONG MatchPenalty,
const LOGFONTW LogFont,
const PLIST_ENTRY  Head 
)
static

Definition at line 5761 of file freetype.c.

5764{
5765 ULONG Penalty;
5767 PFONT_ENTRY CurrentEntry;
5768 FONTGDI *FontGDI;
5769 OUTLINETEXTMETRICW *Otm = NULL;
5770 UINT OtmSize, OldOtmSize = 0;
5771 FT_Face Face;
5772
5773 ASSERT(FontObj);
5774 ASSERT(MatchPenalty);
5775 ASSERT(LogFont);
5776 ASSERT(Head);
5777
5778 /* Start with a pretty big buffer */
5779 OldOtmSize = 0x200;
5780 Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5781
5782 /* get the FontObj of lowest penalty */
5783 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5784 {
5785 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5786
5787 FontGDI = CurrentEntry->Font;
5788 ASSERT(FontGDI);
5789 Face = FontGDI->SharedFace->Face;
5790
5791 /* get text metrics */
5793 OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL, TRUE);
5794 if (OtmSize > OldOtmSize)
5795 {
5796 if (Otm)
5799 }
5800
5801 /* update FontObj if lowest penalty */
5802 if (Otm)
5803 {
5805 IntRequestFontSize(FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5806
5808 OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm, TRUE);
5809 if (!OtmSize)
5810 continue;
5811
5812 OldOtmSize = OtmSize;
5813
5814 Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5815 if (*MatchPenalty == MAXULONG || Penalty < *MatchPenalty)
5816 {
5817 *FontObj = GDIToObj(FontGDI, FONT);
5818 *MatchPenalty = Penalty;
5819 }
5820 }
5821 }
5822
5823 if (Otm)
5825}
#define NULL
Definition: types.h:112
#define GDIToObj(ClipGDI, Type)
Definition: engobjects.h:185
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
static UINT GetFontPenalty(const LOGFONTW *LogFont, const OUTLINETEXTMETRICW *Otm, const char *style_name)
Definition: freetype.c:5415
static FT_Error IntRequestFontSize(_Inout_ PFONTGDI FontGDI, _In_ LONG lfWidth, _In_ LONG lfHeight)
Definition: freetype.c:4244
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm, BOOL bLocked)
Definition: freetype.c:3140
unsigned int UINT
Definition: sysinfo.c:13
Entry
Definition: section.c:5216
FT_String * style_name
Definition: freetype.h:1039
LONG lfHeight
Definition: dimm.idl:59
LONG lfWidth
Definition: dimm.idl:60
Definition: font.h:5
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define MAXULONG
Definition: typedefs.h:251
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define GDITAG_TEXT
Definition: tags.h:172

Referenced by FontLink_PrepareFontInfo(), and TextIntRealizeFont().

◆ FontFamilyFillInfo()

static void FASTCALL FontFamilyFillInfo ( PFONTFAMILYINFO  Info,
LPCWSTR  FaceName,
LPCWSTR  FullName,
PFONTGDI  FontGDI 
)
static

Definition at line 3444 of file freetype.c.

3446{
3447 ANSI_STRING StyleA;
3448 UNICODE_STRING StyleW;
3449 TT_OS2 *pOS2;
3451 CHARSETINFO CharSetInfo;
3452 unsigned i, Size;
3453 OUTLINETEXTMETRICW *Otm;
3454 LOGFONTW *Lf;
3455 TEXTMETRICW *TM;
3456 NEWTEXTMETRICW *Ntm;
3457 DWORD fs0;
3459 PSHARED_FACE SharedFace = FontGDI->SharedFace;
3460 FT_Face Face = SharedFace->Face;
3461 UNICODE_STRING NameW;
3462
3463 RtlInitUnicodeString(&NameW, NULL);
3466 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL, TRUE);
3467 if (!Size)
3468 return;
3470 if (!Otm)
3471 return;
3473 Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm, TRUE);
3474 if (!Size)
3475 {
3477 return;
3478 }
3479
3480 Lf = &Info->EnumLogFontEx.elfLogFont;
3481 TM = &Otm->otmTextMetrics;
3482
3483 Lf->lfHeight = TM->tmHeight;
3484 Lf->lfWidth = TM->tmAveCharWidth;
3485 Lf->lfWeight = TM->tmWeight;
3486 Lf->lfItalic = TM->tmItalic;
3487 Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
3488 Lf->lfCharSet = TM->tmCharSet;
3492
3493 Ntm = &Info->NewTextMetricEx.ntmTm;
3494 Ntm->tmHeight = TM->tmHeight;
3495 Ntm->tmAscent = TM->tmAscent;
3496 Ntm->tmDescent = TM->tmDescent;
3499 Ntm->tmAveCharWidth = TM->tmAveCharWidth;
3500 Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
3501 Ntm->tmWeight = TM->tmWeight;
3502 Ntm->tmOverhang = TM->tmOverhang;
3505 Ntm->tmFirstChar = TM->tmFirstChar;
3506 Ntm->tmLastChar = TM->tmLastChar;
3507 Ntm->tmDefaultChar = TM->tmDefaultChar;
3508 Ntm->tmBreakChar = TM->tmBreakChar;
3509 Ntm->tmItalic = TM->tmItalic;
3510 Ntm->tmUnderlined = TM->tmUnderlined;
3511 Ntm->tmStruckOut = TM->tmStruckOut;
3513 Ntm->tmCharSet = TM->tmCharSet;
3514 Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
3515
3516 if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
3517
3518 if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
3519
3520 Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
3521 ? TRUETYPE_FONTTYPE : 0);
3522
3523 if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
3524 Info->FontType |= RASTER_FONTTYPE;
3525
3526
3527 /* face name */
3528 if (!FaceName)
3529 FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
3530
3531 RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
3532
3533 /* full name */
3534 if (!FullName)
3535 FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
3536
3537 RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
3538 sizeof(Info->EnumLogFontEx.elfFullName),
3539 FullName);
3540
3541 RtlInitAnsiString(&StyleA, Face->style_name);
3542 StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
3543 StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
3544 status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
3545 if (!NT_SUCCESS(status))
3546 {
3548 return;
3549 }
3550 Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
3551
3552 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
3553
3554 if (!pOS2)
3555 {
3557 return;
3558 }
3559
3560 Ntm->ntmSizeEM = Otm->otmEMSquare;
3562 Ntm->ntmAvgWidth = 0;
3563
3565
3566 fs.fsCsb[0] = pOS2->ulCodePageRange1;
3567 fs.fsCsb[1] = pOS2->ulCodePageRange2;
3568 fs.fsUsb[0] = pOS2->ulUnicodeRange1;
3569 fs.fsUsb[1] = pOS2->ulUnicodeRange2;
3570 fs.fsUsb[2] = pOS2->ulUnicodeRange3;
3571 fs.fsUsb[3] = pOS2->ulUnicodeRange4;
3572
3573 if (0 == pOS2->version)
3574 {
3575 FT_UInt Dummy;
3576
3577 if (FT_Get_First_Char(Face, &Dummy) < 0x100)
3578 fs.fsCsb[0] |= FS_LATIN1;
3579 else
3580 fs.fsCsb[0] |= FS_SYMBOL;
3581 }
3582
3583 if (fs.fsCsb[0] == 0)
3584 {
3585 /* Let's see if we can find any interesting cmaps */
3586 for (i = 0; i < (UINT)Face->num_charmaps; i++)
3587 {
3588 switch (Face->charmaps[i]->encoding)
3589 {
3590 case FT_ENCODING_UNICODE:
3591 case FT_ENCODING_APPLE_ROMAN:
3592 fs.fsCsb[0] |= FS_LATIN1;
3593 break;
3594 case FT_ENCODING_MS_SYMBOL:
3595 fs.fsCsb[0] |= FS_SYMBOL;
3596 break;
3597 default:
3598 break;
3599 }
3600 }
3601 }
3602
3603 for (i = 0; i < MAXTCIINDEX; i++)
3604 {
3605 fs0 = 1L << i;
3606 if (fs.fsCsb[0] & fs0)
3607 {
3608 if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
3609 {
3610 CharSetInfo.ciCharset = DEFAULT_CHARSET;
3611 }
3612 if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
3613 {
3614 if (g_ElfScripts[i])
3615 wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
3616 else
3617 {
3618 DPRINT1("Unknown elfscript for bit %u\n", i);
3619 }
3620 }
3621 }
3622 }
3623 Info->NewTextMetricEx.ntmFontSig = fs;
3624}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ULONG_PTR
Definition: config.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
static PWCHAR g_ElfScripts[32]
Definition: freetype.c:242
#define MAXTCIINDEX
Definition: freetype.c:269
static BOOLEAN IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2776
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3760
unsigned int FT_UInt
Definition: fttypes.h:231
#define fs
Definition: i386-dis.c:444
if(dx< 0)
Definition: linetemp.h:194
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define UNICODE_NULL
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
short WCHAR
Definition: pedump.c:58
wcscpy
BYTE lfOutPrecision
Definition: dimm.idl:68
BYTE lfItalic
Definition: dimm.idl:64
LONG lfWeight
Definition: dimm.idl:63
BYTE lfClipPrecision
Definition: dimm.idl:69
BYTE lfCharSet
Definition: dimm.idl:67
BYTE lfQuality
Definition: dimm.idl:70
BYTE lfPitchAndFamily
Definition: dimm.idl:71
FT_UShort version
Definition: tttables.h:377
FT_ULong ulUnicodeRange1
Definition: tttables.h:396
FT_ULong ulCodePageRange1
Definition: tttables.h:414
FT_ULong ulUnicodeRange3
Definition: tttables.h:398
FT_ULong ulUnicodeRange2
Definition: tttables.h:397
FT_ULong ulCodePageRange2
Definition: tttables.h:415
FT_ULong ulUnicodeRange4
Definition: tttables.h:399
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2960
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: ffs.h:70
Definition: ps.c:97
UINT ciCharset
Definition: wingdi.h:1992
UINT ntmCellHeight
Definition: wingdi.h:3112
WCHAR tmFirstChar
Definition: wingdi.h:3101
LONG tmDigitizedAspectX
Definition: wingdi.h:3099
LONG tmInternalLeading
Definition: wingdi.h:3093
WCHAR tmDefaultChar
Definition: wingdi.h:3103
LONG tmMaxCharWidth
Definition: wingdi.h:3096
LONG tmAveCharWidth
Definition: wingdi.h:3095
WCHAR tmBreakChar
Definition: wingdi.h:3104
LONG tmExternalLeading
Definition: wingdi.h:3094
LONG tmDigitizedAspectY
Definition: wingdi.h:3100
BYTE tmPitchAndFamily
Definition: wingdi.h:3108
WCHAR tmLastChar
Definition: wingdi.h:3102
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4176
#define ft_sfnt_os2
Definition: tttables.h:638
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
#define NTM_ITALIC
Definition: wingdi.h:1315
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1109
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define RASTER_FONTTYPE
Definition: wingdi.h:1107
#define FS_SYMBOL
Definition: wingdi.h:575
#define NTM_REGULAR
Definition: wingdi.h:1317
#define PROOF_QUALITY
Definition: wingdi.h:438
#define FS_LATIN1
Definition: wingdi.h:560
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define NTM_BOLD
Definition: wingdi.h:1316
#define TCI_SRCFONTSIG
Definition: wingdi.h:963
#define OUT_OUTLINE_PRECIS
Definition: wingdi.h:423
_In_ PSTRING FullName
Definition: rtlfuncs.h:1665

Referenced by GetFontFamilyInfoForList(), and IntGdiGetFontResourceInfo().

◆ FontLink_AddEntry()

static NTSTATUS FontLink_AddEntry ( LPCWSTR  lfFaceName,
PZZWSTR  pszzFontLink 
)
static

Definition at line 875 of file freetype.c.

876{
877 SIZE_T FontLinkSize = SZZ_GetSize(pszzFontLink);
878 PZZWSTR pszz = ExAllocatePoolWithTag(PagedPool, FontLinkSize, TAG_FONT);
879 if (!pszz)
880 return STATUS_NO_MEMORY;
881 RtlCopyMemory(pszz, pszzFontLink, FontLinkSize);
882
884 if (!pEntry)
885 {
887 return STATUS_NO_MEMORY;
888 }
889
890 pEntry->pszzFontLink = pszz;
891 RtlStringCchCopyW(pEntry->lfFaceName, _countof(pEntry->lfFaceName), lfFaceName);
892 InsertHeadList(&g_FontLinkEntries, &pEntry->ListEntry);
893 return STATUS_SUCCESS;
894}
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define InsertHeadList(ListHead, Entry)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:432
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_SUCCESS
Definition: shellext.h:65
#define _countof(array)
Definition: sndvol32.h:70
Definition: freetype.c:43
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
SIZE_T SZZ_GetSize(_In_ PCZZWSTR pszz)
Definition: utils.c:15

Referenced by FontLink_PopulateEntries().

◆ FontLink_Chain_Dump()

static VOID FontLink_Chain_Dump ( _In_ PFONTLINK_CHAIN  pChain)
inlinestatic

Definition at line 4323 of file freetype.c.

4325{
4326#if 0
4327 PLIST_ENTRY Entry, Head;
4328 PFONTLINK pFontLink;
4329 INT iLink = 0;
4330
4331 DPRINT1("%S, %p, %p\n", pChain->LogFont.lfFaceName, pChain->pBaseTextObj, pChain->pDefFace);
4332
4333 Head = &pChain->FontLinkList;
4334 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
4335 {
4336 pFontLink = CONTAINING_RECORD(Entry, FONTLINK, ListEntry);
4337 DPRINT1("FontLink #%d: %p, %d, %S, %p, %p\n",
4338 iLink, pFontLink, pFontLink->bIgnore, pFontLink->LogFont.lfFaceName,
4339 pFontLink->pFontGDI, pFontLink->SharedFace);
4340 ++iLink;
4341 }
4342#endif
4343}
int32_t INT
Definition: typedefs.h:58

Referenced by FontLink_Chain_FindGlyph().

◆ FontLink_Chain_FindEntry()

static NTSTATUS FontLink_Chain_FindEntry ( _Inout_ PFONTLINK_CHAIN  pChain,
_Inout_ PLOGFONTW  pLF 
)
static

Definition at line 1283 of file freetype.c.

1286{
1288 if (!pEntry)
1289 {
1290 if (!(pLF->lfPitchAndFamily & FIXED_PITCH))
1291 pChain->pszzFontLink = s_szzDefFontLink;
1292 else
1293 pChain->pszzFontLink = s_szzDefFixedFontLink;
1294 return STATUS_SUCCESS;
1295 }
1296
1297 pChain->pszzFontLink = pEntry->pszzFontLink;
1298 return STATUS_SUCCESS;
1299}
static const WCHAR s_szzDefFixedFontLink[]
Definition: freetype.c:1196
static PFONTLINK_ENTRY FontLink_FindEntry(const LOGFONTW *pLogFont)
Definition: freetype.c:1264
static const WCHAR s_szzDefFontLink[]
Definition: freetype.c:1188
#define FIXED_PITCH
Definition: wingdi.h:444

Referenced by FontLink_Chain_Populate().

◆ FontLink_Chain_FindGlyph()

static UINT FontLink_Chain_FindGlyph ( _Inout_ PFONTLINK_CHAIN  pChain,
_Out_ PFONT_CACHE_ENTRY  pCache,
_Inout_ FT_Face pFace,
_In_ UINT  code,
_In_ BOOL  fCodeAsIndex 
)
static

Search the target glyph and update the current font info.

Returns
The glyph index

Definition at line 4367 of file freetype.c.

4373{
4374 PFONTLINK pFontLink;
4375 PLIST_ENTRY Entry, Head;
4376 UINT index;
4377 FT_Face face;
4378
4379 // Try the default font at first
4380 index = get_glyph_index_flagged(pChain->pDefFace, code, fCodeAsIndex);
4381 if (index)
4382 {
4383 DPRINT("code: 0x%08X, index: 0x%08X, fCodeAsIndex:%d\n", code, index, fCodeAsIndex);
4384 pCache->Hashed.Face = *pFace = pChain->pDefFace;
4385 return index; // The glyph is found on the default font
4386 }
4387
4388 if (!FontLink_Chain_IsPopulated(pChain)) // The chain is not populated yet
4389 {
4391 FontLink_Chain_Dump(pChain);
4392 }
4393
4394 // Now the chain is populated. Looking for the target glyph...
4395 Head = &pChain->FontLinkList;
4396 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
4397 {
4398 pFontLink = CONTAINING_RECORD(Entry, FONTLINK, ListEntry);
4399 if (!FontLink_PrepareFontInfo(pFontLink))
4400 continue; // This link is not useful, check the next one
4401
4402 face = pFontLink->SharedFace->Face;
4404 if (!index)
4405 continue; // The glyph does not exist, continue searching
4406
4407 // The target glyph is found in the chain
4408 DPRINT("code: 0x%08X, index: 0x%08X\n", code, index);
4409 pCache->Hashed.Face = *pFace = face;
4410 if (IntNeedRequestFontSize(pChain, face, Entry))
4411 {
4413 pChain->LogFont.lfWidth,
4414 pChain->LogFont.lfHeight,
4415 NULL, NULL, NULL, NULL, NULL, NULL);
4416 }
4417 FT_Set_Transform(face, &pCache->Hashed.matTransform, NULL);
4418 return index;
4419 }
4420
4421 // No target glyph found in the chain: use default glyph
4423 index = get_glyph_index(*pFace, code);
4424 DPRINT("code: 0x%08X, index: 0x%08X\n", code, index);
4425 pCache->Hashed.Face = *pFace = pChain->pDefFace;
4426 return index;
4427}
#define index(s, c)
Definition: various.h:29
WORD face[3]
Definition: mesh.c:4747
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, BOOL fCodeAsIndex)
Definition: freetype.c:4317
static BOOL IntNeedRequestFontSize(PFONTLINK_CHAIN pChain, FT_Face face, PLIST_ENTRY TargetEntry)
Definition: freetype.c:4346
static BOOL FontLink_PrepareFontInfo(_Inout_ PFONTLINK pFontLink)
Definition: freetype.c:349
static DWORD s_chFontLinkDefaultChar
Definition: freetype.c:61
static VOID FontLink_Chain_Dump(_In_ PFONTLINK_CHAIN pChain)
Definition: freetype.c:4323
static NTSTATUS FontLink_Chain_Populate(_Inout_ PFONTLINK_CHAIN pChain)
Definition: freetype.c:1302
static BOOL FontLink_Chain_IsPopulated(const FONTLINK_CHAIN *pChain)
Definition: freetype.c:185
static FT_Error IntRequestFontSizeEx(_In_ FT_Face face, _In_ LONG lfWidth, _In_ LONG lfHeight, _Out_opt_ PLONG ptmHeight, _Out_opt_ PLONG ptmAscent, _Out_opt_ PLONG ptmDescent, _Out_opt_ PLONG ptmInternalLeading, _Out_opt_ PLONG plfHeight, _Out_opt_ PLONG plfWidth)
Definition: freetype.c:4081
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:4302
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:689
GLuint index
Definition: glext.h:6031
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define DPRINT
Definition: sndvol32.h:73
Definition: inflate.c:139

Referenced by IntExtTextOutW(), IntGetTextDisposition(), and TextIntGetTextExtentPoint().

◆ FontLink_Chain_FindLink()

static PFONTLINK FontLink_Chain_FindLink ( PFONTLINK_CHAIN  pChain,
PLOGFONTW  plf 
)
inlinestatic

Definition at line 1205 of file freetype.c.

1208{
1209 PLIST_ENTRY Entry, Head = &pChain->FontLinkList;
1210 PFONTLINK pLink;
1211
1212 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
1213 {
1214 pLink = CONTAINING_RECORD(Entry, FONTLINK, ListEntry);
1215 if (RtlEqualMemory(&pLink->LogFont, plf, sizeof(*plf)))
1216 return pLink;
1217 }
1218
1219 return NULL;
1220}
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18

Referenced by FontLink_Create().

◆ FontLink_Chain_Init()

static VOID FontLink_Chain_Init ( _Out_ PFONTLINK_CHAIN  pChain,
_Inout_ PTEXTOBJ  pTextObj,
_In_ FT_Face  face 
)
inlinestatic

Definition at line 1176 of file freetype.c.

1180{
1181 RtlZeroMemory(pChain, sizeof(*pChain));
1182 pChain->pBaseTextObj = pTextObj;
1183 pChain->pDefFace = face;
1185}

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ FontLink_Chain_IsPopulated()

static BOOL FontLink_Chain_IsPopulated ( const FONTLINK_CHAIN pChain)
inlinestatic

Definition at line 185 of file freetype.c.

186{
187 return pChain->LogFont.lfFaceName[0];
188}

Referenced by FontLink_Chain_FindGlyph(), FontLink_Chain_Init(), and FontLink_Chain_Populate().

◆ FontLink_Chain_Populate()

static NTSTATUS FontLink_Chain_Populate ( _Inout_ PFONTLINK_CHAIN  pChain)
static

Definition at line 1302 of file freetype.c.

1304{
1306 PFONTLINK pLink;
1307 LOGFONTW lfBase;
1308 PTEXTOBJ pTextObj = pChain->pBaseTextObj;
1309 PFONTGDI pFontGDI;
1310 PCWSTR pszLink;
1311 WCHAR szEntry[MAX_PATH];
1312 BOOL bFixCharSet;
1313
1314 InitializeListHead(&pChain->FontLinkList);
1315
1316 lfBase = pTextObj->logfont.elfEnumLogfontEx.elfLogFont;
1317 pFontGDI = ObjToGDI(pTextObj->Font, FONT);
1318 lfBase.lfHeight = pFontGDI->lfHeight;
1319 lfBase.lfWidth = pFontGDI->lfWidth;
1320
1321 // Use pTextObj->TextFace if lfFaceName was empty
1322 if (!lfBase.lfFaceName[0])
1323 {
1324 ASSERT(pTextObj->TextFace[0]);
1325 RtlStringCchCopyW(lfBase.lfFaceName, _countof(lfBase.lfFaceName), pTextObj->TextFace);
1326 }
1327
1328 // Fix lfCharSet
1329 switch (lfBase.lfCharSet)
1330 {
1331 case ANSI_CHARSET: bFixCharSet = !s_fFontLinkUseAnsi; break;
1332 case OEM_CHARSET: bFixCharSet = !s_fFontLinkUseOem; break;
1333 case SYMBOL_CHARSET: bFixCharSet = !s_fFontLinkUseSymbol; break;
1334 default: bFixCharSet = TRUE; break;
1335 }
1336 if (bFixCharSet)
1337 lfBase.lfCharSet = DEFAULT_CHARSET;
1338
1339 pChain->LogFont = lfBase;
1340
1341 // Load FontLink entry
1342 Status = FontLink_Chain_FindEntry(pChain, &pChain->LogFont);
1343 if (!NT_SUCCESS(Status))
1344 return Status;
1345
1346 pszLink = pChain->pszzFontLink;
1347 while (*pszLink)
1348 {
1349 DPRINT("pszLink: '%S'\n", pszLink);
1350 pLink = FontLink_Create(pChain, &lfBase, pszLink);
1351 if (pLink)
1352 InsertTailList(&pChain->FontLinkList, &pLink->ListEntry);
1353 pszLink += wcslen(pszLink) + 1;
1354 }
1355
1356 // Use default settings (if any)
1358 {
1360 RtlStringCchCatW(szEntry, _countof(szEntry), L",");
1362 DPRINT("szEntry: '%S'\n", szEntry);
1363 pLink = FontLink_Create(pChain, &lfBase, szEntry);
1364 if (pLink)
1365 InsertTailList(&pChain->FontLinkList, &pLink->ListEntry);
1366 }
1367
1369 return Status;
1370}
#define MAX_PATH
Definition: compat.h:34
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define L(x)
Definition: resources.c:13
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:184
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int BOOL
Definition: ntddk_ex.h:94
static WCHAR s_szDefFontLinkFileName[MAX_PATH]
Definition: freetype.c:62
static BOOL s_fFontLinkUseAnsi
Definition: freetype.c:64
static PFONTLINK FontLink_Create(_Inout_ PFONTLINK_CHAIN pChain, _In_ const LOGFONTW *plfBase, _In_ LPCWSTR pszLink)
Definition: freetype.c:1223
static NTSTATUS FontLink_Chain_FindEntry(_Inout_ PFONTLINK_CHAIN pChain, _Inout_ PLOGFONTW pLF)
Definition: freetype.c:1283
static WCHAR s_szDefFontLinkFontName[MAX_PATH]
Definition: freetype.c:63
static BOOL s_fFontLinkUseOem
Definition: freetype.c:65
static BOOL s_fFontLinkUseSymbol
Definition: freetype.c:66
Status
Definition: gdiplustypes.h:24
NTSTRSAFEAPI RtlStringCchCatW(_Inout_updates_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:601
LONG lfHeight
Definition: engobjects.h:166
Definition: text.h:60
WCHAR TextFace[LF_FACESIZE]
Definition: text.h:67
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
FONTOBJ * Font
Definition: text.h:66
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:3225
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define ANSI_CHARSET
Definition: wingdi.h:383
#define OEM_CHARSET
Definition: wingdi.h:400
#define SYMBOL_CHARSET
Definition: wingdi.h:385

Referenced by FontLink_Chain_FindGlyph().

◆ FontLink_Create()

static PFONTLINK FontLink_Create ( _Inout_ PFONTLINK_CHAIN  pChain,
_In_ const LOGFONTW plfBase,
_In_ LPCWSTR  pszLink 
)
inlinestatic

Definition at line 1223 of file freetype.c.

1227{
1228 LPWSTR pch0, pch1;
1229 LOGFONTW lf;
1230 PFONTLINK pLink;
1231
1232 lf = *plfBase;
1233
1234 // pszLink: "<FontFileName>,<FaceName>[,...]"
1235 pch0 = wcschr(pszLink, L',');
1236 if (!pch0)
1237 {
1238 DPRINT1("%S\n", pszLink);
1239 return NULL; // Invalid FontLink data
1240 }
1241 ++pch0;
1242
1243 pch1 = wcschr(pch0, L',');
1244 if (pch1)
1245 RtlStringCchCopyNW(lf.lfFaceName, _countof(lf.lfFaceName), pch0, pch1 - pch0);
1246 else
1248
1250 DPRINT("lfFaceName: %S\n", lf.lfFaceName);
1251
1252 if (RtlEqualMemory(plfBase, &lf, sizeof(lf)) || FontLink_Chain_FindLink(pChain, &lf))
1253 return NULL; // Already exists
1254
1255 pLink = ExAllocatePoolZero(PagedPool, sizeof(FONTLINK), TAG_FONT);
1256 if (!pLink)
1257 return NULL; // Out of memory
1258
1259 pLink->LogFont = lf;
1260 return pLink;
1261}
#define wcschr
Definition: compat.h:17
static PFONTLINK FontLink_Chain_FindLink(PFONTLINK_CHAIN pChain, PLOGFONTW plf)
Definition: freetype.c:1205
static BOOL SubstituteFontRecurse(PLOGFONTW pLogFont)
Definition: freetype.c:1140
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
NTSTRSAFEAPI RtlStringCchCopyNW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_reads_or_z_(cchToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cchToCopy)
Definition: ntstrsafe.h:363
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by FontLink_Chain_Populate().

◆ FontLink_DeleteEntries()

static void FontLink_DeleteEntries ( VOID  )
static

Definition at line 896 of file freetype.c.

897{
900
901 for (Entry = g_FontLinkEntries.Flink; Entry != &g_FontLinkEntries; Entry = Entry->Flink)
902 {
904 ExFreePoolWithTag(pEntry->pszzFontLink, TAG_FONT);
906 }
907}

Referenced by FreeFontSupport().

◆ FontLink_Destroy()

static VOID FontLink_Destroy ( _Inout_ PFONTLINK  pLink)
inlinestatic

Definition at line 179 of file freetype.c.

180{
182}

◆ FontLink_FindEntry()

static PFONTLINK_ENTRY FontLink_FindEntry ( const LOGFONTW pLogFont)
static

Definition at line 1264 of file freetype.c.

1265{
1268 LOGFONTW lf = *pLogFont;
1269
1271
1272 for (Entry = g_FontLinkEntries.Flink; Entry != &g_FontLinkEntries; Entry = Entry->Flink)
1273 {
1275 if (!_wcsicmp(pEntry->lfFaceName, lf.lfFaceName))
1276 return pEntry;
1277 }
1278
1279 return NULL;
1280}

Referenced by FontLink_Chain_FindEntry().

◆ FontLink_LoadDefaultCharset()

static NTSTATUS FontLink_LoadDefaultCharset ( VOID  )
inlinestatic

Definition at line 133 of file freetype.c.

134{
136 HKEY hKey;
138 WCHAR szValue[8];
139
140 // Set the default values
142
143 // Open the registry key
145 L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\FontAssoc\\Associated Charset",
146 &hKey);
147 if (!NT_SUCCESS(Status))
148 return Status;
149
150 cbData = sizeof(szValue);
151 Status = RegQueryValue(hKey, L"ANSI(00)", REG_SZ, szValue, &cbData);
152 if (NT_SUCCESS(Status))
153 {
154 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
155 s_fFontLinkUseAnsi = !_wcsicmp(szValue, L"YES");
156 }
157
158 cbData = sizeof(szValue);
159 Status = RegQueryValue(hKey, L"OEM(FF)", REG_SZ, szValue, &cbData);
160 if (NT_SUCCESS(Status))
161 {
162 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
163 s_fFontLinkUseOem = !_wcsicmp(szValue, L"YES");
164 }
165
166 cbData = sizeof(szValue);
167 Status = RegQueryValue(hKey, L"SYMBOL(02)", REG_SZ, szValue, &cbData);
168 if (NT_SUCCESS(Status))
169 {
170 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
171 s_fFontLinkUseSymbol = !_wcsicmp(szValue, L"YES");
172 }
173
174 ZwClose(hKey); // Close the registry key
175 return STATUS_SUCCESS;
176}
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
#define RegOpenKey
Definition: winreg.h:551
#define RegQueryValue
Definition: winreg.h:555

Referenced by InitFontSupport().

◆ FontLink_LoadDefaultFonts()

static NTSTATUS FontLink_LoadDefaultFonts ( VOID  )
inlinestatic

Definition at line 95 of file freetype.c.

96{
98 HKEY hKey;
100 WCHAR szValue[MAX_PATH];
101
102 // Set the default values
104
105 // Open the registry key
107 L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\FontAssoc\\Associated DefaultFonts",
108 &hKey);
109 if (!NT_SUCCESS(Status))
110 return Status;
111
112 cbData = sizeof(szValue);
113 Status = RegQueryValue(hKey, L"AssocSystemFont", REG_SZ, szValue, &cbData);
114 if (NT_SUCCESS(Status))
115 {
116 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
118 }
119
120 cbData = sizeof(szValue);
121 Status = RegQueryValue(hKey, L"FontPackage", REG_SZ, szValue, &cbData);
122 if (NT_SUCCESS(Status))
123 {
124 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
126 }
127
128 ZwClose(hKey); // Close the registry key
129 return STATUS_SUCCESS;
130}

Referenced by InitFontSupport().

◆ FontLink_LoadSettings()

static NTSTATUS FontLink_LoadSettings ( VOID  )
inlinestatic

Definition at line 69 of file freetype.c.

70{
72 HKEY hKey;
73 DWORD cbData, dwValue;
74
75 // Set the default values
77
78 // Open the registry key
80 L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\FontLink",
81 &hKey);
82 if (!NT_SUCCESS(Status))
83 return Status;
84
85 cbData = sizeof(dwValue);
86 Status = RegQueryValue(hKey, L"FontLinkDefaultChar", REG_DWORD, &dwValue, &cbData);
87 if (NT_SUCCESS(Status) && cbData == sizeof(dwValue))
89
90 ZwClose(hKey); // Close the registry key
91 return STATUS_SUCCESS;
92}
#define FONTLINK_DEFAULT_CHAR
Definition: freetype.c:58
#define REG_DWORD
Definition: sdbapi.c:615

Referenced by InitFontSupport().

◆ FontLink_PopulateEntries()

static NTSTATUS FontLink_PopulateEntries ( VOID  )
static

Definition at line 909 of file freetype.c.

910{
912 HKEY hKey;
913 DWORD cchName, cbData, dwType;
914 WCHAR szName[LF_FACESIZE], szzFontLink[300];
915
916 // Open the registry key
918 L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\FontLink\\SystemLink",
919 &hKey);
920 if (!NT_SUCCESS(Status))
921 return Status;
922
923 for (DWORD dwIndex = 0;; ++dwIndex)
924 {
926 cbData = sizeof(szzFontLink);
927 Status = RegEnumValueW(hKey, dwIndex, szName, &cchName, &dwType, szzFontLink, &cbData);
928 if (!NT_SUCCESS(Status))
929 break;
930 if (dwType != REG_MULTI_SZ)
931 continue;
932
933 // Ensure double-NUL-terminated
934 szzFontLink[_countof(szzFontLink) - 1] = UNICODE_NULL;
935 szzFontLink[_countof(szzFontLink) - 2] = UNICODE_NULL;
936
937 DPRINT("szName: %S\n", szName);
938 DPRINT("szzFontLink: %S\n", szzFontLink);
939
940 FontLink_AddEntry(szName, szzFontLink);
941 }
942
943 ZwClose(hKey); // Close the registry key
944 return STATUS_SUCCESS;
945}
#define LF_FACESIZE
Definition: dimm.idl:39
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
static NTSTATUS FontLink_AddEntry(LPCWSTR lfFaceName, PZZWSTR pszzFontLink)
Definition: freetype.c:875
#define REG_MULTI_SZ
Definition: nt_native.h:1504
static const WCHAR szName[]
Definition: powrprof.c:45
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2497

Referenced by InitFontSupport().

◆ FontLink_PrepareFontInfo()

static BOOL FontLink_PrepareFontInfo ( _Inout_ PFONTLINK  pFontLink)
static

Definition at line 349 of file freetype.c.

351{
352 FONTOBJ *pFontObj;
353 ULONG MatchPenalty;
354 UNICODE_STRING FaceName;
355 PPROCESSINFO Win32Process;
356 PFONTGDI pFontGDI;
357
359
360 if (pFontLink->bIgnore)
361 return FALSE;
362
363 if (pFontLink->SharedFace)
364 return TRUE;
365
366 MatchPenalty = MAXULONG;
367 pFontObj = NULL;
368
369 // Search private fonts
370 Win32Process = PsGetCurrentProcessWin32Process();
371 FindBestFontFromList(&pFontObj, &MatchPenalty, &pFontLink->LogFont,
372 &Win32Process->PrivateFontListHead);
373
374 // Search system fonts
375 FindBestFontFromList(&pFontObj, &MatchPenalty, &pFontLink->LogFont,
376 &g_FontListHead);
377
378 if (!pFontObj) // Not found?
379 {
380 pFontLink->bIgnore = TRUE;
381 return FALSE;
382 }
383
384 pFontGDI = ObjToGDI(pFontObj, FONT);
385 pFontLink->SharedFace = pFontGDI->SharedFace;
386
387 // FontLink uses family name
388 RtlInitUnicodeString(&FaceName, pFontLink->LogFont.lfFaceName);
389 if (!MatchFontName(pFontLink->SharedFace, &FaceName, TT_NAME_ID_FONT_FAMILY, LANG_ENGLISH) &&
390 !MatchFontName(pFontLink->SharedFace, &FaceName, TT_NAME_ID_FONT_FAMILY, gusLanguageID))
391 {
392 pFontLink->bIgnore = TRUE;
393 return FALSE;
394 }
395
396 return TRUE;
397}
static __inline VOID FindBestFontFromList(FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
Definition: freetype.c:5761
static BOOL MatchFontName(PSHARED_FACE SharedFace, PUNICODE_STRING Name1, FT_UShort NameID, FT_UShort LangID)
Definition: freetype.c:5862
#define TT_NAME_ID_FONT_FAMILY
Definition: font.c:3578
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1213
#define LANG_ENGLISH
Definition: nls.h:52
LIST_ENTRY PrivateFontListHead
Definition: win32.h:286
USHORT gusLanguageID
Definition: init.c:12

Referenced by FontLink_Chain_FindGlyph(), and IntNeedRequestFontSize().

◆ FreeFontSupport()

VOID FASTCALL FreeFontSupport ( VOID  )

Definition at line 991 of file freetype.c.

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

Referenced by _Function_class_().

◆ FT_FixedFromFIXED()

static __inline FT_Fixed FT_FixedFromFIXED ( FIXED  f)
static

Definition at line 592 of file freetype.c.

593{
594 return (FT_Fixed)((long)f.value << 16 | (unsigned long)f.fract);
595}
GLfloat f
Definition: glext.h:7540
#define long
Definition: qsort.c:33

Referenced by ftGdiGetGlyphOutline().

◆ ftGdiGetFontData()

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

Definition at line 5373 of file freetype.c.

5379{
5381 FT_Face Face = FontGdi->SharedFace->Face;
5382
5384
5385 if (FT_IS_SFNT(Face))
5386 {
5387 if (Table)
5388 Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
5389 (Table << 8 & 0xFF0000);
5390
5391 if (!Buffer) Size = 0;
5392
5393 if (Buffer && Size)
5394 {
5396 FT_ULong Needed = 0;
5397
5398 Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
5399
5400 if ( !Error && Needed < Size) Size = Needed;
5401 }
5402 if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
5403 Result = Size;
5404 }
5405
5407
5408 return Result;
5409}
BOOL Error
Definition: chkdsk.c:66
Definition: bufpool.h:45
#define IntUnLockFreeType()
Definition: freetype.c:231
#define IntLockFreeType()
Definition: freetype.c:225
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
FT_Load_Sfnt_Table(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte *buffer, FT_ULong *length)
Definition: ftobjs.c:4197
#define GDI_ERROR
Definition: wingdi.h:1309
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by NtGdiGetFontData().

◆ ftGdiGetGlyphOutline()

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

Definition at line 4434 of file freetype.c.

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

Referenced by NtGdiGetGlyphOutline(), and PATH_ExtTextOut().

◆ ftGdiGetKerningPairs()

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

Definition at line 6391 of file freetype.c.

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

Referenced by GreGetKerningPairs(), and NtGdiGetKerningPairs().

◆ ftGdiGetRasterizerCaps()

BOOL FASTCALL ftGdiGetRasterizerCaps ( LPRASTERIZER_STATUS  lprs)

Definition at line 3752 of file freetype.c.

3753{
3754 if ( lprs )
3755 {
3756 lprs->nSize = sizeof(RASTERIZER_STATUS);
3757 lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3758 lprs->nLanguageID = gusLanguageID;
3759 return TRUE;
3760 }
3762 return FALSE;
3763}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#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,
LPFONTSIGNATURE  lpSig,
DWORD  dwFlags 
)

Definition at line 5093 of file freetype.c.

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

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

◆ ftGdiGetTextMetricsW()

BOOL FASTCALL ftGdiGetTextMetricsW ( HDC  hDC,
PTMW_INTERNAL  ptmwi 
)

Definition at line 5289 of file freetype.c.

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

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

◆ ftGdiRealizationInfo()

BOOL FASTCALL ftGdiRealizationInfo ( PFONTGDI  Font,
PREALIZATION_INFO  Info 
)

Definition at line 6372 of file freetype.c.

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

Referenced by NtGdiGetRealizationInfo().

◆ ftGetFontUnicodeRanges()

DWORD FASTCALL ftGetFontUnicodeRanges ( PFONTGDI  Font,
PGLYPHSET  glyphset 
)

Definition at line 5206 of file freetype.c.

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

Referenced by NtGdiGetFontUnicodeRanges().

◆ FTVectorToPOINTFX()

static __inline void FTVectorToPOINTFX ( FT_Vector vec,
POINTFX pt 
)
static

Definition at line 578 of file freetype.c.

579{
580 pt->x.value = vec->x >> 6;
581 pt->x.fract = (vec->x & 0x3f) << 10;
582 pt->x.fract |= ((pt->x.fract >> 6) | (pt->x.fract >> 12));
583 pt->y.value = vec->y >> 6;
584 pt->y.fract = (vec->y & 0x3f) << 10;
585 pt->y.fract |= ((pt->y.fract >> 6) | (pt->y.fract >> 12));
586}
#define pt(x, y)
Definition: drawing.c:79
char * value
Definition: compiler.c:67

Referenced by get_bezier_glyph_outline(), and get_native_glyph_outline().

◆ get_bezier_glyph_outline()

static unsigned int get_bezier_glyph_outline ( FT_Outline outline,
unsigned int  buflen,
char buf 
)
static

Definition at line 3956 of file freetype.c.

3957{
3958 /* Convert the quadratic Beziers to cubic Beziers.
3959 The parametric eqn for a cubic Bezier is, from PLRM:
3960 r(t) = at^3 + bt^2 + ct + r0
3961 with the control points:
3962 r1 = r0 + c/3
3963 r2 = r1 + (c + b)/3
3964 r3 = r0 + c + b + a
3965
3966 A quadratic Bezier has the form:
3967 p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
3968
3969 So equating powers of t leads to:
3970 r1 = 2/3 p1 + 1/3 p0
3971 r2 = 2/3 p1 + 1/3 p2
3972 and of course r0 = p0, r3 = p2
3973 */
3974 int contour, point = 0, first_pt;
3975 TTPOLYGONHEADER *pph;
3976 TTPOLYCURVE *ppc;
3977 DWORD pph_start, cpfx, type;
3978 FT_Vector cubic_control[4];
3979 unsigned int needed = 0;
3980
3981 for (contour = 0; contour < outline->n_contours; contour++)
3982 {
3983 pph_start = needed;
3984 pph = (TTPOLYGONHEADER *)(buf + needed);
3985 first_pt = point;
3986 if (buf)
3987 {
3988 pph->dwType = TT_POLYGON_TYPE;
3989 FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3990 }
3991 needed += sizeof(*pph);
3992 point++;
3993 while (point <= outline->contours[contour])
3994 {
3995 ppc = (TTPOLYCURVE *)(buf + needed);
3996 type = (outline->tags[point] & FT_Curve_Tag_On) ?
3998 cpfx = 0;
3999 do
4000 {
4001 if (type == TT_PRIM_LINE)
4002 {
4003 if (buf)
4004 FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
4005 cpfx++;
4006 point++;
4007 }
4008 else
4009 {
4010 /* Unlike QSPLINEs, CSPLINEs always have their endpoint
4011 so cpfx = 3n */
4012
4013 /* FIXME: Possible optimization in endpoint calculation
4014 if there are two consecutive curves */
4015 cubic_control[0] = outline->points[point-1];
4016 if (!(outline->tags[point-1] & FT_Curve_Tag_On))
4017 {
4018 cubic_control[0].x += outline->points[point].x + 1;
4019 cubic_control[0].y += outline->points[point].y + 1;
4020 cubic_control[0].x >>= 1;
4021 cubic_control[0].y >>= 1;
4022 }
4023 if (point+1 > outline->contours[contour])
4024 cubic_control[3] = outline->points[first_pt];
4025 else
4026 {
4027 cubic_control[3] = outline->points[point+1];
4028 if (!(outline->tags[point+1] & FT_Curve_Tag_On))
4029 {
4030 cubic_control[3].x += outline->points[point].x + 1;
4031 cubic_control[3].y += outline->points[point].y + 1;
4032 cubic_control[3].x >>= 1;
4033 cubic_control[3].y >>= 1;
4034 }
4035 }
4036 /* r1 = 1/3 p0 + 2/3 p1
4037 r2 = 1/3 p2 + 2/3 p1 */
4038 cubic_control[1].x = (2 * outline->points[point].x + 1) / 3;
4039 cubic_control[1].y = (2 * outline->points[point].y + 1) / 3;
4040 cubic_control[2] = cubic_control[1];
4041 cubic_control[1].x += (cubic_control[0].x + 1) / 3;
4042 cubic_control[1].y += (cubic_control[0].y + 1) / 3;
4043 cubic_control[2].x += (cubic_control[3].x + 1) / 3;
4044 cubic_control[2].y += (cubic_control[3].y + 1) / 3;
4045 if (buf)
4046 {
4047 FTVectorToPOINTFX(&cubic_control[1], &ppc->apfx[cpfx]);
4048 FTVectorToPOINTFX(&cubic_control[2], &ppc->apfx[cpfx+1]);
4049 FTVectorToPOINTFX(&cubic_control[3], &ppc->apfx[cpfx+2]);
4050 }
4051 cpfx += 3;
4052 point++;
4053 }
4054 } while (point <= outline->contours[contour] &&
4055 (outline->tags[point] & FT_Curve_Tag_On) ==
4056 (outline->tags[point-1] & FT_Curve_Tag_On));
4057 /* At the end of a contour Windows adds the start point,
4058 but only for Beziers and we've already done that.
4059 */
4060 if (point <= outline->contours[contour] &&
4061 outline->tags[point] & FT_Curve_Tag_On)
4062 {
4063 /* This is the closing pt of a bezier, but we've already
4064 added it, so just inc point and carry on */
4065 point++;
4066 }
4067 if (buf)
4068 {
4069 ppc->wType = type;
4070 ppc->cpfx = cpfx;
4071 }
4072 needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
4073 }
4074 if (buf)
4075 pph->cb = needed - pph_start;
4076 }
4077 return needed;
4078}
POINTL point
Definition: edittest.c:50
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:578
#define FT_Curve_Tag_On
Definition: ftimage.h:478
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
POINTFX apfx[1]
Definition: wingdi.h:3160
POINTFX pfxStart
Definition: wingdi.h:3165
#define TT_PRIM_CSPLINE
Definition: wingdi.h:1321
#define TT_POLYGON_TYPE
Definition: wingdi.h:1318
#define TT_PRIM_LINE
Definition: wingdi.h:1319

Referenced by ftGdiGetGlyphOutline().

◆ get_glyph_index()

static FT_UInt FASTCALL get_glyph_index ( FT_Face  ft_face,
UINT  glyph 
)
inlinestatic

Definition at line 4302 of file freetype.c.

4303{
4304 FT_UInt ret;
4305
4306 if (face_has_symbol_charmap(ft_face))
4307 {
4308 ret = get_glyph_index_symbol(ft_face, glyph);
4309 if (ret != 0)
4310 return ret;
4311 }
4312
4313 return FT_Get_Char_Index(ft_face, glyph);
4314}
return ret
Definition: mutex.c:147
static FT_UInt FASTCALL get_glyph_index_symbol(FT_Face ft_face, UINT glyph)
Definition: freetype.c:4288
FT_Get_Char_Index(FT_Face face, FT_ULong charcode)
Definition: ftobjs.c:3731

Referenced by FontLink_Chain_FindGlyph(), get_glyph_index_flagged(), and GreGetGlyphIndicesW().

◆ get_glyph_index_flagged()

static FT_UInt FASTCALL get_glyph_index_flagged ( FT_Face  face,
FT_ULong  code,
BOOL  fCodeAsIndex 
)
inlinestatic

Definition at line 4317 of file freetype.c.

4318{
4319 return (fCodeAsIndex ? code : get_glyph_index(face, code));
4320}

Referenced by FontLink_Chain_FindGlyph(), ftGdiGetGlyphOutline(), GreGetCharABCWidthsW(), and GreGetCharWidthW().

◆ get_glyph_index_symbol()

static FT_UInt FASTCALL get_glyph_index_symbol ( FT_Face  ft_face,
UINT  glyph 
)
inlinestatic

Definition at line 4288 of file freetype.c.

4289{
4290 FT_UInt ret;
4291
4292 if (glyph < 0x100) glyph += 0xf000;
4293 /* there are a number of old pre-Unicode "broken" TTFs, which
4294 do have symbols at U+00XX instead of U+f0XX */
4295 if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
4296 ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
4297
4298 return ret;
4299}

Referenced by get_glyph_index().

◆ get_native_glyph_outline()

static unsigned int get_native_glyph_outline ( FT_Outline outline,
unsigned int  buflen,
char buf 
)
static

Definition at line 3883 of file freetype.c.

3884{
3885 TTPOLYGONHEADER *pph;
3886 TTPOLYCURVE *ppc;
3887 int needed = 0, point = 0, contour, first_pt;
3888 unsigned int pph_start, cpfx;
3889 DWORD type;
3890
3891 for (contour = 0; contour < outline->n_contours; contour++)
3892 {
3893 /* Ignore contours containing one point */
3894 if (point == outline->contours[contour])
3895 {
3896 point++;
3897 continue;
3898 }
3899
3900 pph_start = needed;
3901 pph = (TTPOLYGONHEADER *)(buf + needed);
3902 first_pt = point;
3903 if (buf)
3904 {
3905 pph->dwType = TT_POLYGON_TYPE;
3906 FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3907 }
3908 needed += sizeof(*pph);
3909 point++;
3910 while (point <= outline->contours[contour])
3911 {
3912 ppc = (TTPOLYCURVE *)(buf + needed);
3913 type = (outline->tags[point] & FT_Curve_Tag_On) ?
3915 cpfx = 0;
3916 do
3917 {
3918 if (buf)
3919 FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3920 cpfx++;
3921 point++;
3922 } while (point <= outline->contours[contour] &&
3923 (outline->tags[point] & FT_Curve_Tag_On) ==
3924 (outline->tags[point-1] & FT_Curve_Tag_On));
3925 /* At the end of a contour Windows adds the start point, but
3926 only for Beziers */
3927 if (point > outline->contours[contour] &&
3928 !(outline->tags[point-1] & FT_Curve_Tag_On))
3929 {
3930 if (buf)
3931 FTVectorToPOINTFX(&outline->points[first_pt], &ppc->apfx[cpfx]);
3932 cpfx++;
3933 }
3934 else if (point <= outline->contours[contour] &&
3935 outline->tags[point] & FT_Curve_Tag_On)
3936 {
3937 /* add closing pt for bezier */
3938 if (buf)
3939 FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3940 cpfx++;
3941 point++;
3942 }
3943 if (buf)
3944 {
3945 ppc->wType = type;
3946 ppc->cpfx = cpfx;
3947 }
3948 needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3949 }
3950 if (buf)
3951 pph->cb = needed - pph_start;
3952 }
3953 return needed;
3954}
#define TT_PRIM_QSPLINE
Definition: wingdi.h:1320

Referenced by ftGdiGetGlyphOutline().

◆ GetFontFamilyInfoForList()

static BOOLEAN FASTCALL GetFontFamilyInfoForList ( const LOGFONTW LogFont,
PFONTFAMILYINFO  Info,
LPCWSTR  NominalName,
LONG pCount,
LONG  MaxCount,
PLIST_ENTRY  Head 
)
static

Definition at line 3627 of file freetype.c.

3633{
3635 PFONT_ENTRY CurrentEntry;
3636 FONTGDI *FontGDI;
3637 FONTFAMILYINFO InfoEntry;
3638 LONG Count = *pCount;
3639
3640 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
3641 {
3642 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
3643 FontGDI = CurrentEntry->Font;
3644 ASSERT(FontGDI);
3645
3646 if (LogFont->lfCharSet != DEFAULT_CHARSET &&
3647 LogFont->lfCharSet != FontGDI->CharSet)
3648 {
3649 continue; /* charset mismatch */
3650 }
3651
3652 /* get one info entry */
3653 FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
3654
3655 if (LogFont->lfFaceName[0] != UNICODE_NULL)
3656 {
3657 /* check name */
3658 if (_wcsnicmp(LogFont->lfFaceName,
3660 RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
3661 _wcsnicmp(LogFont->lfFaceName,
3662 InfoEntry.EnumLogFontEx.elfFullName,
3663 RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
3664 {
3665 continue;
3666 }
3667 }
3668
3669 if (NominalName)
3670 {
3671 /* store the nominal name */
3673 sizeof(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
3674 NominalName);
3675 }
3676
3677 /* store one entry to Info */
3678 if (0 <= Count && Count < MaxCount)
3679 {
3680 RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
3681 }
3682 Count++;
3683 }
3684
3685 *pCount = Count;
3686
3687 return TRUE;
3688}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:200
static void FASTCALL FontFamilyFillInfo(PFONTFAMILYINFO Info, LPCWSTR FaceName, LPCWSTR FullName, PFONTGDI FontGDI)
Definition: freetype.c:3444
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:3149
WCHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:2356

Referenced by GetFontFamilyInfoForSubstitutes(), and IntGetFontFamilyInfo().

◆ GetFontFamilyInfoForSubstitutes()

static BOOLEAN FASTCALL GetFontFamilyInfoForSubstitutes ( const LOGFONTW LogFont,
PFONTFAMILYINFO  Info,
LONG pCount,
LONG  MaxCount 
)
static

Definition at line 3691 of file freetype.c.

3695{
3696 PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
3697 PFONTSUBST_ENTRY pCurrentEntry;
3698 PUNICODE_STRING pFromW, pToW;
3699 LOGFONTW lf = *LogFont;
3701
3702 for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
3703 {
3704 pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
3705
3706 pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
3707 if (LogFont->lfFaceName[0] != UNICODE_NULL)
3708 {
3709 /* check name */
3710 if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
3711 continue; /* mismatch */
3712 }
3713
3714 pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
3715 if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
3716 pCurrentEntry->CharSets[FONTSUBST_FROM] ==
3717 pCurrentEntry->CharSets[FONTSUBST_TO])
3718 {
3719 /* identical mapping */
3720 continue;
3721 }
3722
3723 /* substitute and get the real name */
3724 IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
3726 if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
3727 continue;
3728
3729 /* search in global fonts */
3731 GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
3732
3733 /* search in private fonts */
3734 IntLockProcessPrivateFonts(Win32Process);
3735 GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
3736 &Win32Process->PrivateFontListHead);
3737 IntUnLockProcessPrivateFonts(Win32Process);
3739
3740 if (LogFont->lfFaceName[0] != UNICODE_NULL)
3741 {
3742 /* it's already matched to the exact name and charset if the name
3743 was specified at here, then so don't scan more for another name */
3744 break;
3745 }
3746 }
3747
3748 return TRUE;
3749}
static BOOLEAN FASTCALL GetFontFamilyInfoForList(const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LPCWSTR NominalName, LONG *pCount, LONG MaxCount, PLIST_ENTRY Head)
Definition: freetype.c:3627
#define FONTSUBST_FROM
Definition: font.h:69
#define FONTSUBST_TO
Definition: font.h:70
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
UNICODE_STRING FontNames[FONTSUBST_FROM_AND_TO]
Definition: font.h:79
BYTE CharSets[FONTSUBST_FROM_AND_TO]
Definition: font.h:80
#define IntLockProcessPrivateFonts(W32Process)
Definition: text.h:171
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:174
VOID IntUnicodeStringToBuffer(_Out_ LPWSTR pszBuffer, _In_ SIZE_T cbBuffer, _In_ const UNICODE_STRING *pString)
Definition: utils.c:165

Referenced by IntGetFontFamilyInfo().

◆ GetFontPenalty()

static UINT GetFontPenalty ( const LOGFONTW LogFont,
const OUTLINETEXTMETRICW Otm,
const char style_name 
)
static

Definition at line 5415 of file freetype.c.

5418{
5419 ULONG Penalty = 0;
5420 BYTE Byte;
5421 LONG Long;
5422 BOOL fNeedScaling = FALSE;
5423 const BYTE UserCharSet = IntCharSetFromLangID(gusLanguageID);
5424 const TEXTMETRICW * TM = &Otm->otmTextMetrics;
5425 WCHAR* ActualNameW;
5426
5427 ASSERT(Otm);
5428 ASSERT(LogFont);
5429
5430 /* FIXME: IntSizeSynth Penalty 20 */
5431 /* FIXME: SmallPenalty Penalty 1 */
5432 /* FIXME: FaceNameSubst Penalty 500 */
5433
5434 Byte = LogFont->lfCharSet;
5435
5436 if (Byte != TM->tmCharSet)
5437 {
5439 {
5440 /* CharSet Penalty 65000 */
5441 /* Requested charset does not match the candidate's. */
5442 GOT_PENALTY("CharSet", 65000);
5443 }
5444 else
5445 {
5446 if (UserCharSet != TM->tmCharSet)
5447 {
5448 /* UNDOCUMENTED: Not user language */
5449 GOT_PENALTY("UNDOCUMENTED:NotUserLanguage", 100);
5450
5451 if (ANSI_CHARSET != TM->tmCharSet)
5452 {
5453 /* UNDOCUMENTED: Not ANSI charset */
5454 GOT_PENALTY("UNDOCUMENTED:NotAnsiCharSet", 100);
5455 }
5456 }
5457 }
5458 }
5459
5460 Byte = LogFont->lfOutPrecision;
5461 switch (Byte)
5462 {
5463 case OUT_DEFAULT_PRECIS:
5464 /* nothing to do */
5465 break;
5466 case OUT_DEVICE_PRECIS:
5467 if (!(TM->tmPitchAndFamily & TMPF_DEVICE) ||
5469 {
5470 /* OutputPrecision Penalty 19000 */
5471 /* Requested OUT_STROKE_PRECIS, but the device can't do it
5472 or the candidate is not a vector font. */
5473 GOT_PENALTY("OutputPrecision", 19000);
5474 }
5475 break;
5476 default:
5478 {
5479 /* OutputPrecision Penalty 19000 */
5480 /* Or OUT_STROKE_PRECIS not requested, and the candidate
5481 is a vector font that requires GDI support. */
5482 GOT_PENALTY("OutputPrecision", 19000);
5483 }
5484 break;
5485 }
5486
5487 Byte = (LogFont->lfPitchAndFamily & 0x0F);
5488 if (Byte == DEFAULT_PITCH)
5490 if (Byte == FIXED_PITCH)
5491 {
5493 {
5494 /* FixedPitch Penalty 15000 */
5495 /* Requested a fixed pitch font, but the candidate is a
5496 variable pitch font. */
5497 GOT_PENALTY("FixedPitch", 15000);
5498 }
5499 }
5500 if (Byte == VARIABLE_PITCH)
5501 {
5503 {
5504 /* PitchVariable Penalty 350 */
5505 /* Requested a variable pitch font, but the candidate is not a
5506 variable pitch font. */
5507 GOT_PENALTY("PitchVariable", 350);
5508 }
5509 }
5510
5511 Byte = (LogFont->lfPitchAndFamily & 0x0F);
5512 if (Byte == DEFAULT_PITCH)
5513 {
5515 {
5516 /* DefaultPitchFixed Penalty 1 */
5517 /* Requested DEFAULT_PITCH, but the candidate is fixed pitch. */
5518 GOT_PENALTY("DefaultPitchFixed", 1);
5519 }
5520 }
5521
5522 ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
5523
5524 if (LogFont->lfFaceName[0] != UNICODE_NULL)
5525 {
5526 BOOL Found = FALSE;
5527
5528 /* localized family name */
5529 if (!Found)
5530 {
5531 Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
5532 }
5533 /* localized full name */
5534 if (!Found)
5535 {
5536 ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFaceName);
5537 Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
5538 }
5539 if (!Found)
5540 {
5541 /* FaceName Penalty 10000 */
5542 /* Requested a face name, but the candidate's face name
5543 does not match. */
5544 GOT_PENALTY("FaceName", 10000);
5545 }
5546 }
5547
5548 Byte = (LogFont->lfPitchAndFamily & 0xF0);
5549 if (Byte != FF_DONTCARE)
5550 {
5551 if (Byte != (TM->tmPitchAndFamily & 0xF0))
5552 {
5553 /* Family Penalty 9000 */
5554 /* Requested a family, but the candidate's family is different. */
5555 GOT_PENALTY("Family", 9000);
5556 }
5557 }
5558
5559 if ((TM->tmPitchAndFamily & 0xF0) == FF_DONTCARE)
5560 {
5561 /* FamilyUnknown Penalty 8000 */
5562 /* Requested a family, but the candidate has no family. */
5563 GOT_PENALTY("FamilyUnknown", 8000);
5564 }
5565
5566 /* Is the candidate a non-vector font? */
5568 {
5569 /* Is lfHeight specified? */
5570 if (LogFont->lfHeight != 0)
5571 {
5572 if (labs(LogFont->lfHeight) < TM->tmHeight)
5573 {
5574 /* HeightBigger Penalty 600 */
5575 /* The candidate is a nonvector font and is bigger than the
5576 requested height. */
5577 GOT_PENALTY("HeightBigger", 600);
5578 /* HeightBiggerDifference Penalty 150 */
5579 /* The candidate is a raster font and is larger than the
5580 requested height. Penalty * height difference */
5581 GOT_PENALTY("HeightBiggerDifference", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
5582
5583 fNeedScaling = TRUE;
5584 }
5585 if (TM->tmHeight < labs(LogFont->lfHeight))
5586 {
5587 /* HeightSmaller Penalty 150 */
5588 /* The candidate is a raster font and is smaller than the
5589 requested height. Penalty * height difference */
5590 GOT_PENALTY("HeightSmaller", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
5591
5592 fNeedScaling = TRUE;
5593 }
5594 }
5595 }
5596
5597 switch (LogFont->lfPitchAndFamily & 0xF0)
5598 {
5599 case FF_ROMAN: case FF_MODERN: case FF_SWISS:
5600 switch (TM->tmPitchAndFamily & 0xF0)
5601 {
5602 case FF_DECORATIVE: case FF_SCRIPT:
5603 /* FamilyUnlikely Penalty 50 */
5604 /* Requested a roman/modern/swiss family, but the
5605 candidate is decorative/script. */
5606 GOT_PENALTY("FamilyUnlikely", 50);
5607 break;
5608 default:
5609 break;
5610 }
5611 break;
5612 case FF_DECORATIVE: case FF_SCRIPT:
5613 switch (TM->tmPitchAndFamily & 0xF0)
5614 {
5615 case FF_ROMAN: case FF_MODERN: case FF_SWISS:
5616 /* FamilyUnlikely Penalty 50 */
5617 /* Or requested decorative/script, and the candidate is
5618 roman/modern/swiss. */
5619 GOT_PENALTY("FamilyUnlikely", 50);
5620 break;
5621 default:
5622 break;
5623 }
5624 default:
5625 break;
5626 }
5627
5628 if (LogFont->lfWidth != 0)
5629 {
5630 if (LogFont->lfWidth != TM->tmAveCharWidth)
5631 {
5632 /* Width Penalty 50 */
5633 /* Requested a nonzero width, but the candidate's width
5634 doesn't match. Penalty * width difference */
5635 GOT_PENALTY("Width", 50 * labs(LogFont->lfWidth - TM->tmAveCharWidth));
5636
5638 fNeedScaling = TRUE;
5639 }
5640 }
5641
5642 if (fNeedScaling)
5643 {
5644 /* SizeSynth Penalty 50 */
5645 /* The candidate is a raster font that needs scaling by GDI. */
5646 GOT_PENALTY("SizeSynth", 50);
5647 }
5648
5649 if (!LogFont->lfItalic && TM->tmItalic)
5650 {
5651 /* Italic Penalty 4 */
5652 /* Requested font and candidate font do not agree on italic status,
5653 and the desired result cannot be simulated. */
5654 /* Adjusted to 40 to satisfy (Oblique Penalty > Book Penalty). */
5655 GOT_PENALTY("Italic", 40);
5656 }
5657 else if (LogFont->lfItalic && !TM->tmItalic)
5658 {
5659 /* ItalicSim Penalty 1 */
5660 /* Requested italic font but the candidate is not italic,
5661 although italics can be simulated. */
5662 GOT_PENALTY("ItalicSim", 1);
5663 }
5664
5665 if (LogFont->lfOutPrecision == OUT_TT_PRECIS)
5666 {
5667 if (!(TM->tmPitchAndFamily & TMPF_TRUETYPE))
5668 {
5669 /* NotTrueType Penalty 4 */
5670 /* Requested OUT_TT_PRECIS, but the candidate is not a
5671 TrueType font. */
5672 GOT_PENALTY("NotTrueType", 4);
5673 }
5674 }
5675
5676 Long = LogFont->lfWeight;
5677 if (LogFont->lfWeight == FW_DONTCARE)
5678 Long = FW_NORMAL;
5679 if (Long != TM->tmWeight)
5680 {
5681 /* Weight Penalty 3 */
5682 /* The candidate's weight does not match the requested weight.
5683 Penalty * (weight difference/10) */
5684 GOT_PENALTY("Weight", 3 * (labs(Long - TM->tmWeight) / 10));
5685 }
5686
5687 if (!LogFont->lfUnderline && TM->tmUnderlined)
5688 {
5689 /* Underline Penalty 3 */
5690 /* Requested font has no underline, but the candidate is
5691 underlined. */
5692 GOT_PENALTY("Underline", 3);
5693 }
5694
5695 if (!LogFont->lfStrikeOut && TM->tmStruckOut)
5696 {
5697 /* StrikeOut Penalty 3 */
5698 /* Requested font has no strike-out, but the candidate is
5699 struck out. */
5700 GOT_PENALTY("StrikeOut", 3);
5701 }
5702
5703 /* Is the candidate a non-vector font? */
5705 {
5706 if (LogFont->lfHeight != 0 && TM->tmHeight < LogFont->lfHeight)
5707 {
5708 /* VectorHeightSmaller Penalty 2 */
5709 /* Candidate is a vector font that is smaller than the
5710 requested height. Penalty * height difference */
5711 GOT_PENALTY("VectorHeightSmaller", 2 * labs(TM->tmHeight - LogFont->lfHeight));
5712 }
5713 if (LogFont->lfHeight != 0 && TM->tmHeight > LogFont->lfHeight)
5714 {
5715 /* VectorHeightBigger Penalty 1 */
5716 /* Candidate is a vector font that is bigger than the
5717 requested height. Penalty * height difference */
5718 GOT_PENALTY("VectorHeightBigger", 1 * labs(TM->tmHeight - LogFont->lfHeight));
5719 }
5720 }
5721
5722 if (!(TM->tmPitchAndFamily & TMPF_DEVICE))
5723 {
5724 /* DeviceFavor Penalty 2 */
5725 /* Extra penalty for all nondevice fonts. */
5726 GOT_PENALTY("DeviceFavor", 2);
5727 }
5728
5729 if (TM->tmAveCharWidth >= 5 && TM->tmHeight >= 5)
5730 {
5731 if (TM->tmAveCharWidth / TM->tmHeight >= 3)
5732 {
5733 /* Aspect Penalty 30 */
5734 /* The aspect rate is >= 3. It seems like a bad font. */
5735 GOT_PENALTY("Aspect", ((TM->tmAveCharWidth / TM->tmHeight) - 2) * 30);
5736 }
5737 else if (TM->tmHeight / TM->tmAveCharWidth >= 3)
5738 {
5739 /* Aspect Penalty 30 */
5740 /* The aspect rate is >= 3. It seems like a bad font. */
5741 GOT_PENALTY("Aspect", ((TM->tmHeight / TM->tmAveCharWidth) - 2) * 30);
5742 }
5743 }
5744
5745 if (Penalty < 200)
5746 {
5747 DPRINT("WARNING: Penalty:%ld < 200: RequestedNameW:%ls, "
5748 "ActualNameW:%ls, lfCharSet:%d, lfWeight:%ld, "
5749 "tmCharSet:%d, tmWeight:%ld\n",
5750 Penalty, LogFont->lfFaceName, ActualNameW,
5751 LogFont->lfCharSet, LogFont->lfWeight,
5752 TM->tmCharSet, TM->tmWeight);
5753 }
5754
5755 return Penalty; /* success */
5756}
return Found
Definition: dirsup.c:1270
unsigned char Byte
Definition: zlib.h:37
_ACRTIMP __msvcrt_long __cdecl labs(__msvcrt_long)
Definition: math.c:680
#define GOT_PENALTY(name, value)
Definition: freetype.c:5411
long Long
Definition: ftraster.c:311
BYTE lfStrikeOut
Definition: dimm.idl:66
BYTE lfUnderline
Definition: dimm.idl:65
BYTE IntCharSetFromLangID(_In_ LANGID LangID)
Definition: utils.c:82
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define VARIABLE_PITCH
Definition: wingdi.h:445
#define OUT_DEVICE_PRECIS
Definition: wingdi.h:420
#define TMPF_DEVICE
Definition: wingdi.h:1314
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define OUT_TT_PRECIS
Definition: wingdi.h:419
#define FW_NORMAL
Definition: wingdi.h:373

Referenced by FindBestFontFromList().

◆ GreExtTextOutW()

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

Definition at line 7215 of file freetype.c.

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

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

◆ GreGetCharABCWidthsW()

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

Definition at line 7380 of file freetype.c.

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

Referenced by NtGdiGetCharABCWidthsW().

◆ GreGetCharWidthW()

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

Definition at line 7484 of file freetype.c.

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

Referenced by NtGdiGetCharWidthW().

◆ GreGetGlyphIndicesW()

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

Definition at line 7594 of file freetype.c.

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

Referenced by NtGdiGetGlyphIndicesWInternal().

◆ InitFontSupport()

BOOL FASTCALL InitFontSupport ( VOID  )

Definition at line 948 of file freetype.c.

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

Referenced by InitializeGreCSRSS().

◆ IntAddNameFromFamInfo()

static VOID IntAddNameFromFamInfo ( LPWSTR  psz,
FONTFAMILYINFO FamInfo 
)
static

Definition at line 5977 of file freetype.c.

5978{
5980 if (FamInfo->EnumLogFontEx.elfStyle[0] &&
5981 _wcsicmp(FamInfo->EnumLogFontEx.elfStyle, L"Regular") != 0)
5982 {
5983 wcscat(psz, L" ");
5984 wcscat(psz, FamInfo->EnumLogFontEx.elfStyle);
5985 }
5986}
wcscat

Referenced by IntGdiGetFontResourceInfo().

◆ IntCharSetFromCodePage()

BYTE FASTCALL IntCharSetFromCodePage ( UINT  uCodePage)

Definition at line 318 of file freetype.c.

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

Referenced by CreateStockFonts().

◆ IntDeleteRegFontEntries()

VOID IntDeleteRegFontEntries ( _In_ PCWSTR  pszFileName,
_In_ DWORD  dwFlags 
)

Definition at line 2237 of file freetype.c.

2238{
2240 HKEY hKey;
2241 WCHAR szName[MAX_PATH], szValue[MAX_PATH];
2242 ULONG dwIndex, NameLength, ValueSize, dwType;
2243
2245 if (!NT_SUCCESS(Status))
2246 return;
2247
2248 for (dwIndex = 0;;)
2249 {
2250 NameLength = RTL_NUMBER_OF(szName);
2251 ValueSize = sizeof(szValue);
2252 Status = RegEnumValueW(hKey, dwIndex, szName, &NameLength, &dwType, szValue, &ValueSize);
2253 if (!NT_SUCCESS(Status))
2254 break;
2255
2256 if (dwType != REG_SZ || _wcsicmp(szValue, pszFileName) != 0)
2257 {
2258 ++dwIndex;
2259 continue;
2260 }
2261
2262 /* Delete the found value */
2264 if (!NT_SUCCESS(Status))
2265 break;
2266 }
2267
2268 ZwClose(hKey);
2269}
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
UNICODE_STRING g_FontRegPath
Definition: freetype.c:209
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44

Referenced by IntGdiRemoveFontResourceSingle().

◆ IntEnableFontRendering()

VOID FASTCALL IntEnableFontRendering ( BOOL  Enable)

Definition at line 2707 of file freetype.c.

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

◆ IntEscapeMatrix()

static VOID FASTCALL IntEscapeMatrix ( FT_Matrix pmat,
LONG  lfEscapement 
)
static

Definition at line 1037 of file freetype.c.

1038{
1039 FT_Vector vecAngle;
1040 /* Convert the angle in tenths of degrees into degrees as a 16.16 fixed-point value */
1041 FT_Angle angle = INT_TO_FIXED(lfEscapement) / 10;
1042 FT_Vector_Unit(&vecAngle, angle);
1043 pmat->xx = vecAngle.x;
1044 pmat->xy = -vecAngle.y;
1045 pmat->yx = -pmat->xy;
1046 pmat->yy = pmat->xx;
1047}
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
Definition: fttrigon.h:52
FT_Vector_Unit(FT_Vector *vec, FT_Angle angle)
Definition: fttrigon.c:360
GLfloat angle
Definition: glext.h:10853

Referenced by ftGdiGetGlyphOutline(), and IntExtTextOutW().

◆ IntExtTextOutW()

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 at line 6669 of file freetype.c.

6679{
6680 /*
6681 * FIXME:
6682 * Call EngTextOut, which does the real work (calling DrvTextOut where
6683 * appropriate)
6684 */
6685
6686 PDC_ATTR pdcattr;
6687 SURFOBJ *psoDest, *psoGlyph;
6688 SURFACE *psurf;
6689 INT glyph_index, i;
6690 FT_Face face;
6691 FT_BitmapGlyph realglyph;
6692 LONGLONG X64, Y64, RealXStart64, RealYStart64, DeltaX64, DeltaY64;
6693 ULONG previous;
6694 RECTL DestRect, MaskRect;
6695 HBITMAP hbmGlyph;
6696 SIZEL glyphSize;
6697 FONTOBJ *FontObj;
6698 PFONTGDI FontGDI;
6699 PTEXTOBJ TextObj = NULL;
6700 EXLATEOBJ exloRGB2Dst, exloDst2RGB;
6701 POINT Start;
6702 PMATRIX pmxWorldToDevice;
6703 FT_Vector delta, vecAscent64, vecDescent64, vec;
6704 LOGFONTW *plf;
6705 BOOL use_kerning, bResult, DoBreak;
6706 FONT_CACHE_ENTRY Cache;
6707 FT_Matrix mat;
6708 BOOL bNoTransform;
6709 DWORD ch0, ch1;
6710 const DWORD del = 0x7f, nbsp = 0xa0; // DEL is ASCII DELETE and nbsp is a non-breaking space
6711 FONTLINK_CHAIN Chain;
6712 SIZE spaceWidth;
6713
6714 /* Check if String is valid */
6715 if (Count > 0xFFFF || (Count > 0 && String == NULL))
6716 {
6718 return FALSE;
6719 }
6720
6721 if (PATH_IsPathOpen(dc->dclevel))
6722 {
6723 return PATH_ExtTextOut(dc,
6724 XStart, YStart,
6725 fuOptions,
6726 lprc,
6727 String, Count,
6728 Dx);
6729 }
6730
6732
6733 if (!dc->dclevel.pSurface)
6734 {
6735 /* Memory DC with no surface selected */
6736 bResult = TRUE;
6737 goto Cleanup;
6738 }
6739
6740 pdcattr = dc->pdcattr;
6741 if (pdcattr->flTextAlign & TA_UPDATECP)
6742 {
6743 Start.x = pdcattr->ptlCurrent.x;
6744 Start.y = pdcattr->ptlCurrent.y;
6745 }
6746 else
6747 {
6748 Start.x = XStart;
6749 Start.y = YStart;
6750 }
6751
6752 IntLPtoDP(dc, &Start, 1);
6753 RealXStart64 = ((LONGLONG)Start.x + dc->ptlDCOrig.x) << 6;
6754 RealYStart64 = ((LONGLONG)Start.y + dc->ptlDCOrig.y) << 6;
6755
6756 MaskRect.left = 0;
6757 MaskRect.top = 0;
6758
6759 psurf = dc->dclevel.pSurface;
6760 psoDest = &psurf->SurfObj;
6761
6762 if (pdcattr->iGraphicsMode == GM_ADVANCED)
6763 pmxWorldToDevice = DC_pmxWorldToDevice(dc);
6764 else
6765 pmxWorldToDevice = (PMATRIX)&gmxWorldToDeviceDefault;
6766
6767 if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
6769
6770 if (lprc && (fuOptions & (ETO_CLIPPED | ETO_OPAQUE)))
6771 {
6772 IntLPtoDP(dc, (POINT*)lprc, 2);
6773 lprc->left += dc->ptlDCOrig.x;
6774 lprc->top += dc->ptlDCOrig.y;
6775 lprc->right += dc->ptlDCOrig.x;
6776 lprc->bottom += dc->ptlDCOrig.y;
6777 }
6778
6779 if (lprc && (fuOptions & ETO_OPAQUE))
6780 {
6782 lprc->left, lprc->top,
6783 lprc->right - lprc->left, lprc->bottom - lprc->top,
6784 &dc->eboBackground.BrushObject);
6785 fuOptions &= ~ETO_OPAQUE;
6786 }
6787 else
6788 {
6789 if (pdcattr->jBkMode == OPAQUE)
6790 {
6791 fuOptions |= ETO_OPAQUE;
6792 }
6793 }
6794
6795 TextObj = RealizeFontInit(pdcattr->hlfntNew);
6796 if (TextObj == NULL)
6797 {
6798 bResult = FALSE;
6799 goto Cleanup;
6800 }
6801
6802 FontObj = TextObj->Font;
6803 ASSERT(FontObj);
6804 FontGDI = ObjToGDI(FontObj, FONT);
6805 ASSERT(FontGDI);
6806
6808 Cache.Hashed.Face = face = FontGDI->SharedFace->Face;
6809
6810 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
6811 Cache.Hashed.lfHeight = plf->lfHeight;
6812 Cache.Hashed.lfWidth = plf->lfWidth;
6813 Cache.Hashed.Aspect.Emu.Bold = EMUBOLD_NEEDED(FontGDI->OriginalWeight, plf->lfWeight);
6814 Cache.Hashed.Aspect.Emu.Italic = (plf->lfItalic && !FontGDI->OriginalItalic);
6815
6818 else
6820
6821 if (!TextIntUpdateSize(TextObj, FontGDI, FALSE))
6822 {
6824 bResult = FALSE;
6825 goto Cleanup;
6826 }
6827
6828 FontLink_Chain_Init(&Chain, TextObj, face);
6829
6830 /* Apply lfEscapement */
6831 if (FT_IS_SCALABLE(face) && plf->lfEscapement != 0)
6833 else
6835
6836 /* Apply the world transformation */
6837 IntMatrixFromMx(&mat, pmxWorldToDevice);
6840
6841 /* Is there no transformation? */
6842 bNoTransform = ((mat.xy == 0) && (mat.yx == 0) &&
6843 (mat.xx == (1 << 16)) && (mat.yy == (1 << 16)));
6844
6845 /* Calculate the ascent point and the descent point */
6846 vecAscent64.x = 0;
6847 vecAscent64.y = (FontGDI->tmAscent << 6);
6848 FT_Vector_Transform(&vecAscent64, &Cache.Hashed.matTransform);
6849 vecDescent64.x = 0;
6850 vecDescent64.y = -(FontGDI->tmDescent << 6);
6851 FT_Vector_Transform(&vecDescent64, &Cache.Hashed.matTransform);
6852
6853 /* Process the vertical alignment and fix the real starting point. */
6854#define VALIGN_MASK (TA_TOP | TA_BASELINE | TA_BOTTOM)
6855 if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BASELINE)
6856 {
6857 NOTHING;
6858 }
6859 else if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BOTTOM)
6860 {
6861 RealXStart64 -= vecDescent64.x;
6862 RealYStart64 += vecDescent64.y;
6863 }
6864 else /* TA_TOP */
6865 {
6866 RealXStart64 -= vecAscent64.x;
6867 RealYStart64 += vecAscent64.y;
6868 }
6869#undef VALIGN_MASK
6870
6871 use_kerning = FT_HAS_KERNING(face);
6872
6873 /* Calculate the text width if necessary */
6874 if ((fuOptions & ETO_OPAQUE) || (pdcattr->flTextAlign & (TA_CENTER | TA_RIGHT)))
6875 {
6876 if (!IntGetTextDisposition(&DeltaX64, &DeltaY64, String, Count, Dx, &Cache,
6877 fuOptions, bNoTransform, &Chain))
6878 {
6880 bResult = FALSE;
6881 goto Cleanup;
6882 }
6883
6884 /* Adjust the horizontal position by horizontal alignment */
6885 if ((pdcattr->flTextAlign & TA_CENTER) == TA_CENTER)
6886 {
6887 RealXStart64 -= DeltaX64 / 2;
6888 RealYStart64 -= DeltaY64 / 2;
6889 }
6890 else if ((pdcattr->flTextAlign & TA_RIGHT) == TA_RIGHT)
6891 {
6892 RealXStart64 -= DeltaX64;
6893 RealYStart64 -= DeltaY64;
6894 }
6895
6896 /* Fill background */
6897 if (fuOptions & ETO_OPAQUE)
6898 {
6899 INT X0 = (RealXStart64 + vecAscent64.x + 32) >> 6;
6900 INT Y0 = (RealYStart64 - vecAscent64.y + 32) >> 6;
6901 INT DX = (DeltaX64 >> 6);
6902 if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
6903 {
6904 INT CY = (vecAscent64.y - vecDescent64.y + 32) >> 6;
6905 IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboBackground.BrushObject);
6906 }
6907 else
6908 {
6909 INT DY = (DeltaY64 >> 6);
6910 INT X1 = ((RealXStart64 + vecDescent64.x + 32) >> 6);
6911 INT Y1 = ((RealYStart64 - vecDescent64.y + 32) >> 6);
6912 POINT Points[4] =
6913 {
6914 { X0, Y0 },
6915 { X0 + DX, Y0 + DY },
6916 { X1 + DX, Y1 + DY },
6917 { X1, Y1 },
6918 };
6919 IntEngFillPolygon(dc, Points, 4, &dc->eboBackground.BrushObject);
6920 }
6921 }
6922 }
6923
6924 EXLATEOBJ_vInitialize(&exloRGB2Dst, &gpalRGB, psurf->ppal, 0, 0, 0);
6925 EXLATEOBJ_vInitialize(&exloDst2RGB, psurf->ppal, &gpalRGB, 0, 0, 0);
6926
6927 if (pdcattr->ulDirty_ & DIRTY_TEXT)
6929
6930 /*
6931 * The main rendering loop.
6932 */
6933 X64 = RealXStart64;
6934 Y64 = RealYStart64;
6935 previous = 0;
6936 DoBreak = FALSE;
6937 bResult = TRUE; /* Assume success */
6938 for (i = 0; i < Count; ++i)
6939 {
6940 ch0 = *String++;
6941 if (IS_HIGH_SURROGATE(ch0))
6942 {
6943 ++i;
6944 if (i >= Count)
6945 break;
6946
6947 ch1 = *String++;
6948 if (IS_LOW_SURROGATE(ch1))
6949 ch0 = Utf32FromSurrogatePair(ch0, ch1);
6950 }
6951
6952 glyph_index = FontLink_Chain_FindGlyph(&Chain, &Cache, &face, ch0,
6953 (fuOptions & ETO_GLYPH_INDEX));
6954 Cache.Hashed.GlyphIndex = glyph_index;
6955
6956 realglyph = IntGetRealGlyph(&Cache);
6957 if (!realglyph)
6958 {
6959 bResult = FALSE;
6960 break;
6961 }
6962
6963 /* retrieve kerning distance and move pen position */
6964 if (use_kerning && previous && glyph_index && NULL == Dx)
6965 {
6966 FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
6967 X64 += delta.x;
6968 Y64 -= delta.y;
6969 }
6970
6971 DPRINT("X64, Y64: %I64d, %I64d\n", X64, Y64);
6972 DPRINT("Advance: %d, %d\n", realglyph->root.advance.x, realglyph->root.advance.y);
6973
6974 glyphSize.cx = realglyph->bitmap.width;
6975 glyphSize.cy = realglyph->bitmap.rows;
6976
6977 /* Do chars > space & not DEL & not nbsp have a glyphSize.cx of zero? */
6978 if (ch0 > L' ' && ch0 != del && ch0 != nbsp && glyphSize.cx == 0)
6979 {
6980 DPRINT1("WARNING: family_name '%s' WChar 0x%04x has a glyphSize.cx of zero\n",
6981 face->family_name, ch0);
6982 }
6983
6984 /* Don't ignore spaces or non-breaking spaces when computing offset.
6985 * This completes the fix of CORE-11787. */
6986 if ((pdcattr->flTextAlign & TA_UPDATECP) && glyphSize.cx == 0 &&
6987 (ch0 == L' ' || ch0 == nbsp)) // Space chars needing x-dim widths
6988 {
6990 /* Get the width of the space character */
6991 TextIntGetTextExtentPoint(dc, TextObj, L" ", 1, 0, NULL, NULL, &spaceWidth, 0);
6993 glyphSize.cx = spaceWidth.cx;
6994 realglyph->left = 0;
6995 }
6996
6997 MaskRect.right = realglyph->bitmap.width;
6998 MaskRect.bottom = realglyph->bitmap.rows;
6999
7000 DestRect.left = ((X64 + 32) >> 6) + realglyph->left;
7001 DestRect.right = DestRect.left + glyphSize.cx;
7002 DestRect.top = ((Y64 + 32) >> 6) - realglyph->top;
7003 DestRect.bottom = DestRect.top + glyphSize.cy;
7004
7005 /* Check if the bitmap has any pixels */
7006 if ((glyphSize.cx != 0) && (glyphSize.cy != 0))
7007 {
7008 /*
7009 * We should create the bitmap out of the loop at the biggest possible
7010 * glyph size. Then use memset with 0 to clear it and sourcerect to
7011 * limit the work of the transbitblt.
7012 */
7013 hbmGlyph = EngCreateBitmap(glyphSize, realglyph->bitmap.pitch,
7015 realglyph->bitmap.buffer);
7016 if (!hbmGlyph)
7017 {
7018 DPRINT1("WARNING: EngCreateBitmap() failed!\n");
7019 bResult = FALSE;
7020 break;
7021 }
7022
7023 psoGlyph = EngLockSurface((HSURF)hbmGlyph);
7024 if (!psoGlyph)
7025 {
7026 EngDeleteSurface((HSURF)hbmGlyph);
7027 DPRINT1("WARNING: EngLockSurface() failed!\n");
7028 bResult = FALSE;
7029 break;
7030 }
7031
7032 /*
7033 * Use the font data as a mask to paint onto the DCs surface using a
7034 * brush.
7035 */
7036 if (lprc && (fuOptions & ETO_CLIPPED))
7037 {
7038 // We do the check '>=' instead of '>' to possibly save an iteration
7039 // through this loop, since it's breaking after the drawing is done,
7040 // and x is always incremented.
7041 if (DestRect.right >= lprc->right)
7042 {
7043 DestRect.right = lprc->right;
7044 DoBreak = TRUE;
7045 }
7046
7047 if (DestRect.bottom >= lprc->bottom)
7048 {
7049 DestRect.bottom = lprc->bottom;
7050 }
7051 }
7052
7053 if (!IntEngMaskBlt(psoDest,
7054 psoGlyph,
7055 (CLIPOBJ *)&dc->co,
7056 &exloRGB2Dst.xlo,
7057 &exloDst2RGB.xlo,
7058 &DestRect,
7059 (PPOINTL)&MaskRect,
7060 &dc->eboText.BrushObject,
7061 &g_PointZero))
7062 {
7063 DPRINT1("Failed to MaskBlt a glyph!\n");
7064 }
7065
7066 EngUnlockSurface(psoGlyph);
7067 EngDeleteSurface((HSURF)hbmGlyph);
7068 }
7069
7070 if (DoBreak)
7071 break;
7072
7073 if (NULL == Dx)
7074 {
7075 X64 += realglyph->root.advance.x >> 10;
7076 Y64 -= realglyph->root.advance.y >> 10;
7077 }
7078 else if (fuOptions & ETO_PDY)
7079 {
7080 vec.x = (Dx[2 * i + 0] << 6);
7081 vec.y = (Dx[2 * i + 1] << 6);
7082 if (!bNoTransform)
7084 X64 += vec.x;
7085 Y64 -= vec.y;
7086 }
7087 else
7088 {
7089 vec.x = (Dx[i] << 6);
7090 vec.y = 0;
7091 if (!bNoTransform)
7093 X64 += vec.x;
7094 Y64 -= vec.y;
7095 }
7096
7097 DPRINT("New X64, New Y64: %I64d, %I64d\n", X64, Y64);
7098
7099 previous = glyph_index;
7100 }
7101 /* Don't update position if String == NULL. Fixes CORE-19721. */
7102 if ((pdcattr->flTextAlign & TA_UPDATECP) && String)
7103 pdcattr->ptlCurrent.x = DestRect.right - dc->ptlDCOrig.x;
7104
7105 if (plf->lfUnderline || plf->lfStrikeOut) /* Underline or strike-out? */
7106 {
7107 /* Calculate the position and the thickness */
7108 INT underline_position, thickness;
7109 FT_Vector vecA64, vecB64;
7110
7111 DeltaX64 = X64 - RealXStart64;
7112 DeltaY64 = Y64 - RealYStart64;
7113
7114 if (!face->units_per_EM)
7115 {
7117 thickness = 1;
7118 }
7119 else
7120 {
7122 face->underline_position * face->size->metrics.y_ppem / face->units_per_EM;
7123 thickness =
7124 face->underline_thickness * face->size->metrics.y_ppem / face->units_per_EM;
7125 if (thickness <= 0)
7126 thickness = 1;
7127 }
7128
7129 if (plf->lfUnderline) /* Draw underline */
7130 {
7131 vecA64.x = 0;
7132 vecA64.y = (-underline_position - thickness / 2) << 6;
7133 vecB64.x = 0;
7134 vecB64.y = vecA64.y + (thickness << 6);
7135 FT_Vector_Transform(&vecA64, &Cache.Hashed.matTransform);
7136 FT_Vector_Transform(&vecB64, &Cache.Hashed.matTransform);
7137 {
7138 INT X0 = (RealXStart64 - vecA64.x + 32) >> 6;
7139 INT Y0 = (RealYStart64 + vecA64.y + 32) >> 6;
7140 INT DX = (DeltaX64 >> 6);
7141 if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
7142 {
7143 INT CY = (vecB64.y - vecA64.y + 32) >> 6;
7144 IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboText.BrushObject);
7145 }
7146 else
7147 {
7148 INT DY = (DeltaY64 >> 6);
7149 INT X1 = X0 + ((vecA64.x - vecB64.x + 32) >> 6);
7150 INT Y1 = Y0 + ((vecB64.y - vecA64.y + 32) >> 6);
7151 POINT Points[4] =
7152 {
7153 { X0, Y0 },
7154 { X0 + DX, Y0 + DY },
7155 { X1 + DX, Y1 + DY },
7156 { X1, Y1 },
7157 };
7158 IntEngFillPolygon(dc, Points, 4, &dc->eboText.BrushObject);
7159 }
7160 }
7161 }
7162
7163 if (plf->lfStrikeOut) /* Draw strike-out */
7164 {
7165 vecA64.x = 0;
7166 vecA64.y = -(FontGDI->tmAscent << 6) / 3;
7167 vecB64.x = 0;
7168 vecB64.y = vecA64.y + (thickness << 6);
7169 FT_Vector_Transform(&vecA64, &Cache.Hashed.matTransform);
7170 FT_Vector_Transform(&vecB64, &Cache.Hashed.matTransform);
7171 {
7172 INT X0 = (RealXStart64 - vecA64.x + 32) >> 6;
7173 INT Y0 = (RealYStart64 + vecA64.y + 32) >> 6;
7174 INT DX = (DeltaX64 >> 6);
7175 if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
7176 {
7177 INT CY = (vecB64.y - vecA64.y + 32) >> 6;
7178 IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboText.BrushObject);
7179 }
7180 else
7181 {
7182 INT DY = (DeltaY64 >> 6);
7183 INT X1 = X0 + ((vecA64.x - vecB64.x + 32) >> 6);
7184 INT Y1 = Y0 + ((vecB64.y - vecA64.y + 32) >> 6);
7185 POINT Points[4] =
7186 {
7187 { X0, Y0 },
7188 { X0 + DX, Y0 + DY },
7189 { X1 + DX, Y1 + DY },
7190 { X1, Y1 },
7191 };
7192 IntEngFillPolygon(dc, Points, 4, &dc->eboText.BrushObject);
7193 }
7194 }
7195 }
7196 }
7197
7199
7200 EXLATEOBJ_vCleanup(&exloRGB2Dst);
7201 EXLATEOBJ_vCleanup(&exloDst2RGB);
7202
7203Cleanup:
7205
7206 if (TextObj != NULL)
7207 TEXTOBJ_UnlockText(TextObj);
7208
7209 return bResult;
7210}
static _Out_opt_ PULONGLONG Start
static VOID del(LPHIST_ENTRY item)
Definition: history.c:199
static BOOLEAN IntLPtoDP(DC *pdc, PPOINTL ppt, UINT count)
Definition: coord.h:182
VOID FASTCALL DC_vPrepareDCsForBlit(PDC pdcDest, const RECT *rcDest, PDC pdcSrc, const RECT *rcSrc)
Definition: dclife.c:505
VOID FASTCALL DC_vFinishBlit(PDC pdc1, PDC pdc2)
Definition: dclife.c:614
VOID FASTCALL DC_vUpdateTextBrush(PDC pdc)
Definition: dcobjs.c:108
VOID FASTCALL DC_vUpdateBackgroundBrush(PDC pdc)
Definition: dcobjs.c:126
static const WCHAR Cleanup[]
Definition: register.c:80
BOOL FASTCALL TextIntGetTextExtentPoint(_In_ PDC dc, _In_ PTEXTOBJ TextObj, _In_reads_(Count) PCWCH String, _In_ INT Count, _In_ ULONG MaxExtent, _Out_ PINT Fit, _Out_writes_to_opt_(Count, *Fit) PINT Dx, _Out_ PSIZE Size, _In_ FLONG fl)
Definition: freetype.c:4969
static UINT FontLink_Chain_FindGlyph(_Inout_ PFONTLINK_CHAIN pChain, _Out_ PFONT_CACHE_ENTRY pCache, _Inout_ FT_Face *pFace, _In_ UINT code, _In_ BOOL fCodeAsIndex)
Definition: freetype.c:4367
static BOOL IntGetTextDisposition(_Out_ LONGLONG *pX64, _Out_ LONGLONG *pY64, _In_reads_(Count) PCWCH String, _In_ INT Count, _In_opt_ const INT *Dx, _Inout_ PFONT_CACHE_ENTRY Cache, _In_ UINT fuOptions, _In_ BOOL bNoTransform, _Inout_ PFONTLINK_CHAIN pChain)
Definition: freetype.c:6583
#define EMUBOLD_NEEDED(original, request)
Definition: freetype.c:196
static FT_BitmapGlyph IntGetRealGlyph(IN OUT PFONT_CACHE_ENTRY Cache)
Definition: freetype.c:4929
#define VALIGN_MASK
BOOL FASTCALL IntIsFontRenderingEnabled(VOID)
Definition: freetype.c:2701
#define gmxWorldToDeviceDefault
Definition: freetype.c:204
static VOID FontLink_Chain_Init(_Out_ PFONTLINK_CHAIN pChain, _Inout_ PTEXTOBJ pTextObj, _In_ FT_Face face)
Definition: freetype.c:1176
FT_Render_Mode FASTCALL IntGetFontRenderMode(LOGFONTW *logfont)
Definition: freetype.c:2713
@ FT_RENDER_MODE_MONO
Definition: freetype.h:3251
#define DX
Definition: i386-dis.c:425
#define NOTHING
Definition: input_list.c:10
static HBITMAP
Definition: button.c:44
#define DIRTY_TEXT
Definition: ntgdihdl.h:125
#define DIRTY_BACKGROUND
Definition: ntgdihdl.h:126
struct _MATRIX * PMATRIX
#define PATH_IsPathOpen(dclevel)
Definition: path.h:72
FT_Bitmap bitmap
Definition: ftglyph.h:172
FT_GlyphRec root
Definition: ftglyph.h:169
FT_Vector advance
Definition: ftglyph.h:117
LONG lfEscapement
Definition: dimm.idl:61
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
POINTL ptlCurrent
Definition: ntgdihdl.h:311
BYTE jBkMode
Definition: ntgdihdl.h:308
INT iGraphicsMode
Definition: ntgdihdl.h:306
ULONG ulDirty_
Definition: ntgdihdl.h:294
FLONG flTextAlign
Definition: ntgdihdl.h:324
XLATEOBJ xlo
Definition: xlateobj.h:21
WORD RenderMode
Definition: font.h:37
struct _FONT_ASPECT::@5733::@5734 Emu
FONT_CACHE_HASHED Hashed
Definition: font.h:60
LONG lfHeight
Definition: font.h:44
LONG lfWidth
Definition: font.h:45
INT GlyphIndex
Definition: font.h:42
FT_Face Face
Definition: font.h:43
FT_Matrix matTransform
Definition: font.h:50
FONT_ASPECT Aspect
Definition: font.h:48
LONG y
Definition: windef.h:130
LONG x
Definition: windef.h:129
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
SURFOBJ SurfObj
Definition: surface.h:8
struct _PALETTE *const ppal
Definition: surface.h:11
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT underline_position
Definition: t1tokens.h:40
int64_t LONGLONG
Definition: typedefs.h:68
Definition: compat.h:2255
BOOL APIENTRY IntEngMaskBlt(_Inout_ SURFOBJ *psoDest, _In_ SURFOBJ *psoMask, _In_ CLIPOBJ *pco, _In_ XLATEOBJ *pxloDest, _In_ XLATEOBJ *pxloSource, _In_ RECTL *prclDest, _In_ POINTL *pptlMask, _In_ BRUSHOBJ *pbo, _In_ POINTL *pptlBrushOrg)
Definition: bitblt.c:1103
PALETTE gpalRGB
Definition: palette.c:20
BOOL FASTCALL PATH_ExtTextOut(PDC dc, INT x, INT y, UINT flags, const RECTL *lprc, LPCWSTR str, UINT count, const INT *dx)
Definition: path.c:2370
VOID APIENTRY IntEngFillPolygon(IN OUT PDC dc, IN POINTL *pPoints, IN UINT cPoints, IN BRUSHOBJ *BrushObj)
Definition: utils.c:254
VOID FASTCALL IntEngFillBox(IN OUT PDC dc, IN INT X, IN INT Y, IN INT Width, IN INT Height, IN BRUSHOBJ *BrushObj)
Definition: utils.c:209
POINTL g_PointZero
Definition: utils.c:12
static DWORD Utf32FromSurrogatePair(_In_ DWORD ch0, _In_ DWORD ch1)
Definition: utils.h:47
#define BMF_8BPP
Definition: winddi.h:357
ENGAPI BOOL APIENTRY EngDeleteSurface(_In_ _Post_ptr_invalid_ HSURF hsurf)
Definition: surface.c:574
ENGAPI SURFOBJ *APIENTRY EngLockSurface(_In_ HSURF hsurf)
Definition: surface.c:614
ENGAPI HBITMAP APIENTRY EngCreateBitmap(_In_ SIZEL sizl, _In_ LONG lWidth, _In_ ULONG iFormat, _In_ FLONG fl, _In_opt_ PVOID pvBits)
#define BMF_TOPDOWN
Definition: winddi.h:1180
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
ENGAPI VOID APIENTRY EngUnlockSurface(_In_ _Post_ptr_invalid_ SURFOBJ *pso)
Definition: surface.c:635
#define GM_ADVANCED
Definition: wingdi.h:865
#define TA_UPDATECP
Definition: wingdi.h:936
#define TA_RIGHT
Definition: wingdi.h:933
#define ETO_CLIPPED
Definition: wingdi.h:648
#define ETO_OPAQUE
Definition: wingdi.h:647
#define OPAQUE
Definition: wingdi.h:949
#define ETO_PDY
Definition: wingdi.h:657
#define TA_BOTTOM
Definition: wingdi.h:929
#define TA_BASELINE
Definition: wingdi.h:928
#define TA_CENTER
Definition: wingdi.h:931
#define IS_HIGH_SURROGATE(ch)
Definition: winnls.h:763
#define IS_LOW_SURROGATE(ch)
Definition: winnls.h:764
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:491
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:894

Referenced by GreExtTextOutW().

◆ IntFindGlyphCache()

static FT_BitmapGlyph IntFindGlyphCache ( IN const FONT_CACHE_ENTRY pCache)
static

Definition at line 3781 of file freetype.c.

3782{
3783 PLIST_ENTRY CurrentEntry;
3784 PFONT_CACHE_ENTRY FontEntry;
3785 DWORD dwHash = pCache->dwHash;
3786
3788
3789 for (CurrentEntry = g_FontCacheListHead.Flink;
3790 CurrentEntry != &g_FontCacheListHead;
3791 CurrentEntry = CurrentEntry->Flink)
3792 {
3793 FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
3794 if (FontEntry->dwHash == dwHash &&
3795 FontEntry->Hashed.GlyphIndex == pCache->Hashed.GlyphIndex &&
3796 FontEntry->Hashed.Face == pCache->Hashed.Face &&
3797 FontEntry->Hashed.lfHeight == pCache->Hashed.lfHeight &&
3798 FontEntry->Hashed.lfWidth == pCache->Hashed.lfWidth &&
3799 FontEntry->Hashed.AspectValue == pCache->Hashed.AspectValue &&
3800 memcmp(&FontEntry->Hashed.matTransform, &pCache->Hashed.matTransform,
3801 sizeof(FT_Matrix)) == 0)
3802 {
3803 break;
3804 }
3805 }
3806
3807 if (CurrentEntry == &g_FontCacheListHead)
3808 {
3809 return NULL;
3810 }
3811
3812 RemoveEntryList(CurrentEntry);
3813 InsertHeadList(&g_FontCacheListHead, CurrentEntry);
3814 return FontEntry->BitmapGlyph;
3815}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
FT_BitmapGlyph BitmapGlyph
Definition: font.h:58
DWORD dwHash
Definition: font.h:59
DWORD AspectValue
Definition: font.h:47

Referenced by IntGetRealGlyph().

◆ IntFontType()

static VOID FASTCALL IntFontType ( PFONTGDI  Font)
static

Definition at line 5830 of file freetype.c.

5831{
5832 PS_FontInfoRec psfInfo;
5833 FT_ULong tmp_size = 0;
5834 FT_Face Face = Font->SharedFace->Face;
5835
5837
5838 if (FT_HAS_MULTIPLE_MASTERS(Face))
5839 Font->FontObj.flFontType |= FO_MULTIPLEMASTER;
5840 if (FT_HAS_VERTICAL(Face))
5841 Font->FontObj.flFontType |= FO_VERT_FACE;
5842 if (!FT_IS_SCALABLE(Face))
5843 Font->FontObj.flFontType |= FO_TYPE_RASTER;
5844 if (FT_IS_SFNT(Face))
5845 {
5846 Font->FontObj.flFontType |= FO_TYPE_TRUETYPE;
5848 Font->FontObj.flFontType |= FO_POSTSCRIPT;
5849 }
5850 if (!FT_Get_PS_Font_Info(Face, &psfInfo ))
5851 {
5852 Font->FontObj.flFontType |= FO_POSTSCRIPT;
5853 }
5854 /* Check for the presence of the 'CFF ' table to check if the font is Type1 */
5855 if (!FT_Load_Sfnt_Table(Face, TTAG_CFF, 0, NULL, &tmp_size))
5856 {
5857 Font->FontObj.flFontType |= (FO_CFF|FO_POSTSCRIPT);
5858 }
5859}
#define FT_HAS_MULTIPLE_MASTERS(face)
Definition: freetype.h:1361
#define FT_HAS_VERTICAL(face)
Definition: freetype.h:1242
FT_Get_PS_Font_Info(FT_Face face, PS_FontInfo afont_info)
FT_BEGIN_HEADER struct PS_FontInfoRec_ PS_FontInfoRec
#define ft_sfnt_post
Definition: tttables.h:641
#define TTAG_CFF
Definition: tttags.h:44
#define FO_TYPE_TRUETYPE
Definition: winddi.h:737
#define FO_CFF
Definition: winddi.h:747
#define FO_MULTIPLEMASTER
Definition: winddi.h:749
#define FO_POSTSCRIPT
Definition: winddi.h:748
#define FO_VERT_FACE
Definition: winddi.h:750
#define FO_TYPE_RASTER
Definition: winddi.h:735

Referenced by TextIntRealizeFont().

◆ IntFreeFontNames()

static __inline void FASTCALL IntFreeFontNames ( FONT_NAMES Names)
static

Definition at line 3127 of file freetype.c.

3128{
3129 RtlFreeUnicodeString(&Names->FamilyNameW);
3130 RtlFreeUnicodeString(&Names->FaceNameW);
3131 RtlFreeUnicodeString(&Names->StyleNameW);
3132 RtlFreeUnicodeString(&Names->FullNameW);
3133}
PWSTR Names[]

Referenced by IntGetOutlineTextMetrics().

◆ IntGdiAddFontMemResource()

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

Definition at line 2529 of file freetype.c.

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

Referenced by NtGdiAddFontMemResourceEx().

◆ IntGdiAddFontResourceEx()

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

Definition at line 2198 of file freetype.c.

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

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

◆ IntGdiAddFontResourceSingle()

static INT FASTCALL IntGdiAddFontResourceSingle ( _In_ PCUNICODE_STRING  FileName,
_In_ DWORD  Characteristics,
_In_ DWORD  dwFlags 
)
static

Definition at line 1999 of file freetype.c.

2003{
2006 PVOID Buffer = NULL;
2009 SIZE_T ViewSize = 0, Length;
2010 LARGE_INTEGER SectionSize;
2013 INT FontCount;
2015 UNICODE_STRING PathName;
2016 LPWSTR pszBuffer;
2018 static const UNICODE_STRING TrueTypePostfix = RTL_CONSTANT_STRING(L" (TrueType)");
2019
2020 /* Build PathName */
2022 {
2023 Length = DosPathPrefix.Length + FileName->Length + sizeof(UNICODE_NULL);
2025 if (!pszBuffer)
2026 return 0; /* failure */
2027
2028 RtlInitEmptyUnicodeString(&PathName, pszBuffer, Length);
2031 }
2032 else
2033 {
2035 if (!NT_SUCCESS(Status))
2036 return 0; /* failure */
2037 }
2038
2039 /* Open the font file */
2043 &FileHandle,
2046 &Iosb,
2049 if (!NT_SUCCESS(Status))
2050 {
2051 DPRINT1("Could not load font file: %wZ\n", &PathName);
2052 RtlFreeUnicodeString(&PathName);
2053 return 0;
2054 }
2055
2058 if (!NT_SUCCESS(Status))
2059 {
2060 DPRINT1("ObReferenceObjectByHandle failed.\n");
2062 RtlFreeUnicodeString(&PathName);
2063 return 0;
2064 }
2065
2066 SectionSize.QuadPart = 0LL;
2069 NULL, &SectionSize, PAGE_READONLY,
2071 if (!NT_SUCCESS(Status))
2072 {
2073 DPRINT1("Could not map file: %wZ\n", &PathName);
2076 RtlFreeUnicodeString(&PathName);
2077 return 0;
2078 }
2080
2082 if (!NT_SUCCESS(Status))
2083 {
2084 DPRINT1("Could not map file: %wZ\n", &PathName);
2087 RtlFreeUnicodeString(&PathName);
2088 return 0;
2089 }
2090
2091 RtlZeroMemory(&LoadFont, sizeof(LoadFont));
2092 LoadFont.pFileName = &PathName;
2094 LoadFont.Characteristics = Characteristics;
2095 RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
2096 LoadFont.CharSet = DEFAULT_CHARSET;
2097 FontCount = IntGdiLoadFontByIndexFromMemory(&LoadFont, -1);
2098
2099 /* Release our copy */
2103
2105
2107
2108 /* Save the loaded font name into the registry */
2109 if (FontCount > 0 && (dwFlags & AFRX_WRITE_REGISTRY))
2110 {
2111 UNICODE_STRING NewString;
2112 SIZE_T Length;
2113 PWCHAR pszBuffer;
2114 LPCWSTR CharSetName;
2115 if (LoadFont.IsTrueType)
2116 {
2117 /* Append " (TrueType)" */
2118 Length = LoadFont.RegValueName.Length + TrueTypePostfix.Length + sizeof(UNICODE_NULL);
2120 if (pszBuffer)
2121 {
2122 RtlInitEmptyUnicodeString(&NewString, pszBuffer, Length);
2123 NewString.Buffer[0] = UNICODE_NULL;
2124 RtlAppendUnicodeStringToString(&NewString, &LoadFont.RegValueName);
2125 RtlAppendUnicodeStringToString(&NewString, &TrueTypePostfix);
2126 RtlFreeUnicodeString(&LoadFont.RegValueName);
2127 LoadFont.RegValueName = NewString;
2128 }
2129 else
2130 {
2131 // FIXME!
2132 }
2133 }
2134 else if (LoadFont.CharSet != DEFAULT_CHARSET)
2135 {
2136 /* Append " (CharSetName)" */
2137 CharSetName = IntNameFromCharSet(LoadFont.CharSet);
2138 Length = LoadFont.RegValueName.Length +
2139 (wcslen(CharSetName) + 3) * sizeof(WCHAR) +
2140 sizeof(UNICODE_NULL);
2141
2143 if (pszBuffer)
2144 {
2145 RtlInitEmptyUnicodeString(&NewString, pszBuffer, Length);
2146 NewString.Buffer[0] = UNICODE_NULL;
2147 RtlAppendUnicodeStringToString(&NewString, &LoadFont.RegValueName);
2148 RtlAppendUnicodeToString(&NewString, L" (");
2149 RtlAppendUnicodeToString(&NewString, CharSetName);
2150 RtlAppendUnicodeToString(&NewString, L")");
2151 RtlFreeUnicodeString(&LoadFont.RegValueName);
2152 LoadFont.RegValueName = NewString;
2153 }
2154 else
2155 {
2156 // FIXME!
2157 }
2158 }
2159
2162 NULL, NULL);
2163 Status = ZwOpenKey(&KeyHandle, KEY_WRITE, &ObjectAttributes);
2164 if (NT_SUCCESS(Status))
2165 {
2167 LPWSTR pFileName;
2168
2170 {
2171 pFileName = PathName.Buffer;
2172 }
2173 else
2174 {
2175 pFileName = wcsrchr(PathName.Buffer, L'\\');
2176 }
2177
2178 if (pFileName)
2179 {
2181 {
2182 pFileName++;
2183 }
2184 DataSize = (wcslen(pFileName) + 1) * sizeof(WCHAR);
2185 ZwSetValueKey(KeyHandle, &LoadFont.RegValueName, 0, REG_SZ,
2186 pFileName, DataSize);
2187 }
2189 }
2190 }
2191 RtlFreeUnicodeString(&LoadFont.RegValueName);
2192
2193 RtlFreeUnicodeString(&PathName);
2194 return FontCount;
2195}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define TAG_USTR
Definition: libsupp.c:997
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
#define PAGE_READONLY
Definition: compat.h:138
#define SECTION_MAP_READ
Definition: compat.h:139
#define wcsrchr
Definition: compat.h:16
#define FILE_SHARE_READ
Definition: compat.h:136
return Iosb
Definition: create.c:4403
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
static const UNICODE_STRING DosPathPrefix
Definition: freetype.c:1995
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define KernelMode
Definition: asm.h:38
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:412
#define SEC_COMMIT
Definition: mmtypes.h:100
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define SECTION_QUERY
Definition: nt_native.h:1290
#define KEY_WRITE
Definition: nt_native.h:1034
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:493
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSTATUS NTAPI MmMapViewInSystemSpace(IN PVOID SectionObject, OUT PVOID *MappedBase, IN OUT PSIZE_T ViewSize)
Definition: section.c:4504
NTSTATUS NTAPI MmCreateSection(OUT PVOID *Section, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL, IN PFILE_OBJECT FileObject OPTIONAL)
Definition: section.c:4677
#define LL
Definition: tui.h:166
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * PWCHAR
Definition: typedefs.h:56
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
NTSTATUS IntDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: registry.c:361
#define AFRX_WRITE_REGISTRY
Definition: text.h:104
#define AFRX_DOS_DEVICE_PATH
Definition: text.h:106
#define AFRX_ALTERNATIVE_PATH
Definition: text.h:105
LPCWSTR FASTCALL IntNameFromCharSet(_In_ BYTE CharSet)
Definition: utils.c:54
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by IntGdiAddFontResourceEx().

◆ IntGdiCleanupMemEntry()

VOID FASTCALL IntGdiCleanupMemEntry ( PFONT_ENTRY_MEM  Head)

Definition at line 2579 of file freetype.c.

2580{
2582 PFONT_ENTRY_MEM FontEntry;
2583
2584 while (!IsListEmpty(&Head->ListEntry))
2585 {
2586 Entry = RemoveHeadList(&Head->ListEntry);
2587 FontEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_MEM, ListEntry);
2588
2589 CleanupFontEntry(FontEntry->Entry);
2590 ExFreePoolWithTag(FontEntry, TAG_FONT);
2591 }
2592
2593 CleanupFontEntry(Head->Entry);
2595}
Definition: font.h:14
LIST_ENTRY ListEntry
Definition: font.h:15
FONT_ENTRY * Entry
Definition: font.h:16

Referenced by IntGdiCleanupPrivateFontsForProcess(), and IntGdiRemoveFontMemResource().

◆ IntGdiCleanupPrivateFontsForProcess()

VOID FASTCALL IntGdiCleanupPrivateFontsForProcess ( VOID  )

Definition at line 2651 of file freetype.c.

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

Referenced by GdiProcessDestroy().

◆ IntGdiGetFontResourceInfo()

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

Definition at line 6104 of file freetype.c.

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

Referenced by NtGdiGetFontResourceInfoInternalW().

◆ IntGdiLoadFontByIndexFromMemory()

static INT FASTCALL IntGdiLoadFontByIndexFromMemory ( PGDI_LOAD_FONT  pLoadFont,
FT_Long  FontIndex 
)
static

Definition at line 1922 of file freetype.c.

1923{
1925 FT_Face Face;
1926 FT_Long iFace, num_faces;
1927 PSHARED_FACE SharedFace;
1928 INT FaceCount = 0;
1929
1931
1932 /* Load a face from memory */
1934 pLoadFont->Memory->Buffer, pLoadFont->Memory->BufferSize,
1935 ((FontIndex == -1) ? 0 : FontIndex), &Face);
1936 if (Error)
1937 {
1939 if (Error == FT_Err_Unknown_File_Format)
1940 DPRINT1("Unknown font file format\n");
1941 else
1942 DPRINT1("Error reading font (error code: %d)\n", Error);
1943 return 0; /* Failure */
1944 }
1945
1946 /*
1947 * When CharSetIndex == -1 in IntGdiLoadFontsFromMemory(),
1948 * we will always activate a charmap in the font face.
1949 *
1950 * Note from FreeType documentation:
1951 * https://freetype.org/freetype2/docs/reference/ft2-character_mapping.html#ft_charmap
1952 *
1953 * When a new face is created (either through FT_New_Face or
1954 * FT_Open_Face), the library looks for a Unicode charmap within
1955 * the list and automatically activates it. If there is no
1956 * Unicode charmap, FreeType doesn't set an 'active' charmap.
1957 */
1959 if (!Face->charmap)
1960 {
1961 /* Fail font creation */
1962 FT_Done_Face(Face);
1964 WARN("Could not find default charmap!\n");
1965 // Error = FT_Err_Invalid_CharMap_Handle;
1966 return 0; /* Failure */
1967 }
1968
1969 pLoadFont->IsTrueType = FT_IS_SFNT(Face);
1970 num_faces = Face->num_faces;
1971 SharedFace = SharedFace_Create(Face, pLoadFont->Memory);
1972
1974
1975 if (!SharedFace)
1976 {
1977 DPRINT1("SharedFace_Create failed\n");
1979 return 0; /* Failure */
1980 }
1981
1982 if (FontIndex == -1)
1983 {
1984 for (iFace = 1; iFace < num_faces; ++iFace)
1985 {
1987 }
1988 FontIndex = 0;
1989 }
1990
1991 FaceCount += IntGdiLoadFontsFromMemory(pLoadFont, SharedFace, FontIndex, -1);
1992 return FaceCount;
1993}
#define WARN(fmt,...)
Definition: precomp.h:61
static PSHARED_FACE SharedFace_Create(FT_Face Face, PSHARED_MEM Memory)
Definition: freetype.c:419
static FT_Encoding pick_charmap(FT_Face face, int charset)
Definition: freetype.c:1587
static INT FASTCALL IntGdiLoadFontsFromMemory(PGDI_LOAD_FONT pLoadFont, PSHARED_FACE SharedFace, FT_Long FontIndex, INT CharSetIndex)
Definition: freetype.c:1611
FT_Done_Face(FT_Face face)
Definition: ftobjs.c:2783
FT_New_Memory_Face(FT_Library library, const FT_Byte *file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface)
Definition: ftobjs.c:1493
signed long FT_Long
Definition: fttypes.h:242
FT_CharMap charmap
Definition: freetype.h:1067
FT_Long num_faces
Definition: freetype.h:1030
PSHARED_MEM Memory
Definition: font.h:87
BOOL IsTrueType
Definition: font.h:90
ULONG BufferSize
Definition: engobjects.h:120
PVOID Buffer
Definition: engobjects.h:119
_In_ ULONG_PTR _In_ ULONG iFace
Definition: winddi.h:3836

Referenced by IntGdiAddFontMemResource(), IntGdiAddFontResourceSingle(), and IntGdiLoadFontByIndexFromMemory().

◆ IntGdiLoadFontsFromMemory()

static INT FASTCALL IntGdiLoadFontsFromMemory ( PGDI_LOAD_FONT  pLoadFont,
PSHARED_FACE  SharedFace,
FT_Long  FontIndex,
INT  CharSetIndex 
)
static

Definition at line 1611 of file freetype.c.

1613{
1616 FONT_ENTRY_MEM* PrivateEntry = NULL;
1617 FONTGDI * FontGDI;
1619 FT_Face Face;
1621 FT_WinFNT_HeaderRec WinFNT;
1622 INT FaceCount = 0, CharSetCount = 0;
1623 PUNICODE_STRING pFileName = pLoadFont->pFileName;
1624 DWORD Characteristics = pLoadFont->Characteristics;
1625 PUNICODE_STRING pValueName = &pLoadFont->RegValueName;
1626 TT_OS2 * pOS2;
1627 INT BitIndex;
1628 FT_UShort os2_version;
1629 FT_ULong os2_ulCodePageRange1;
1630 FT_UShort os2_usWeightClass;
1631
1632 ASSERT(SharedFace != NULL);
1633 ASSERT(FontIndex != -1);
1634
1636 Face = SharedFace->Face;
1637 SharedFace_AddRef(SharedFace);
1639
1640 /* allocate a FONT_ENTRY */
1642 if (!Entry)
1643 {
1644 SharedFace_Release(SharedFace, TRUE);
1646 return 0; /* failure */
1647 }
1648
1649 /* allocate a FONTGDI */
1650 FontGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(FONTGDI), GDITAG_RFONT);
1651 if (!FontGDI)
1652 {
1654 SharedFace_Release(SharedFace, TRUE);
1656 return 0; /* failure */
1657 }
1658
1659 /* set file name */
1660 if (pFileName)
1661 {
1663 pFileName->Length + sizeof(UNICODE_NULL),
1664 GDITAG_PFF);
1665 if (FontGDI->Filename == NULL)
1666 {
1667 EngFreeMem(FontGDI);
1669 SharedFace_Release(SharedFace, TRUE);
1671 return 0; /* failure */
1672 }
1673
1674 RtlCopyMemory(FontGDI->Filename, pFileName->Buffer, pFileName->Length);
1675 FontGDI->Filename[pFileName->Length / sizeof(WCHAR)] = UNICODE_NULL;
1676 }
1677 else
1678 {
1679 FontGDI->Filename = NULL;
1680
1681 PrivateEntry = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_ENTRY_MEM), TAG_FONT);
1682 if (!PrivateEntry)
1683 {
1684 if (FontGDI->Filename)
1686 EngFreeMem(FontGDI);
1688 SharedFace_Release(SharedFace, TRUE);
1690 return 0; /* failure */
1691 }
1692
1693 PrivateEntry->Entry = Entry;
1694 if (pLoadFont->PrivateEntry)
1695 {
1696 InsertTailList(&pLoadFont->PrivateEntry->ListEntry, &PrivateEntry->ListEntry);
1697 }
1698 else
1699 {
1700 InitializeListHead(&PrivateEntry->ListEntry);
1701 pLoadFont->PrivateEntry = PrivateEntry;
1702 }
1703 }
1704
1705 /* set face */
1706 FontGDI->SharedFace = SharedFace;
1707 FontGDI->CharSet = ANSI_CHARSET;
1708 FontGDI->OriginalItalic = FALSE;
1709 FontGDI->RequestItalic = FALSE;
1710 FontGDI->OriginalWeight = FW_DONTCARE;
1711 FontGDI->RequestWeight = FW_NORMAL;
1712
1714 pOS2 = (TT_OS2 *)FT_Get_Sfnt_Table(Face, FT_SFNT_OS2);
1715 if (pOS2)
1716 {
1717 FontGDI->OriginalItalic = !!(pOS2->fsSelection & 0x1);
1718 FontGDI->OriginalWeight = pOS2->usWeightClass;
1719 }
1720 else
1721 {
1722 Error = FT_Get_WinFNT_Header(Face, &WinFNT);
1723 if (!Error)
1724 {
1725 FontGDI->OriginalItalic = !!WinFNT.italic;
1726 FontGDI->OriginalWeight = WinFNT.weight;
1727 }
1728 }
1729
1730 os2_version = 0;
1731 if (pOS2)
1732 {
1733 os2_version = pOS2->version;
1734 os2_ulCodePageRange1 = pOS2->ulCodePageRange1;
1735 os2_usWeightClass = pOS2->usWeightClass;
1736 }
1738
1739 if (pOS2 && os2_version >= 1)
1740 {
1741 /* get charset and weight from OS/2 header */
1742
1743 /* Make sure we do not use this pointer anymore */
1744 pOS2 = NULL;
1745
1746 for (BitIndex = 0; BitIndex < MAXTCIINDEX; ++BitIndex)
1747 {
1748 if (os2_ulCodePageRange1 & (1 << BitIndex))
1749 {
1750 if (g_FontTci[BitIndex].ciCharset == DEFAULT_CHARSET)
1751 continue;
1752
1753 if ((CharSetIndex == -1 && CharSetCount == 0) ||
1754 CharSetIndex == CharSetCount)
1755 {
1756 FontGDI->CharSet = g_FontTci[BitIndex].ciCharset;
1757 }
1758
1759 ++CharSetCount;
1760 }
1761 }
1762
1763 /* set actual weight */
1764 FontGDI->OriginalWeight = os2_usWeightClass;
1765 }
1766 else
1767 {
1768 /* get charset from WinFNT header */
1770 Error = FT_Get_WinFNT_Header(Face, &WinFNT);
1771 if (!Error)
1772 {
1773 FontGDI->CharSet = WinFNT.charset;
1774 }
1776 }
1777
1778 /*
1779 * If this is the first time the font face is loaded, activate a charmap in it.
1780 *
1781 * Note from FreeType documentation:
1782 * https://freetype.org/freetype2/docs/reference/ft2-character_mapping.html#ft_charmap
1783 *
1784 * When a new face is created (either through FT_New_Face or
1785 * FT_Open_Face), the library looks for a Unicode charmap within
1786 * the list and automatically activates it. If there is no
1787 * Unicode charmap, FreeType doesn't set an 'active' charmap.
1788 */
1789 if (CharSetIndex == -1)
1790 {
1792 pick_charmap(Face, FontGDI->CharSet);
1794 if (!Face->charmap)
1795 {
1796 /* Fail font creation */
1797 ERR("Could not find desired charmap!\n");
1798 Error = FT_Err_Invalid_CharMap_Handle;
1799 goto CleanupAndFail;
1800 }
1801 }
1802
1805 if (NT_SUCCESS(Status))
1806 {
1807 if (Face->style_name && Face->style_name[0] &&
1808 strcmp(Face->style_name, "Regular") != 0)
1809 {
1812 if (!NT_SUCCESS(Status))
1813 RtlFreeUnicodeString(&Entry->FaceName);
1814 }
1815 else
1816 {
1817 RtlInitUnicodeString(&Entry->StyleName, NULL);
1818 }
1819 }
1820 if (!NT_SUCCESS(Status))
1821 goto CleanupAndFail;
1822
1823 ++FaceCount;
1824 DPRINT("Font loaded: %s (%s)\n",
1825 Face->family_name ? Face->family_name : "<NULL>",
1826 Face->style_name ? Face->style_name : "<NULL>");
1827 DPRINT("Num glyphs: %d\n", Face->num_glyphs);
1828 DPRINT("CharSet: %d\n", FontGDI->CharSet);
1829
1830 /* Add this font resource to the font table */
1831 Entry->Font = FontGDI;
1832 Entry->NotEnum = (Characteristics & FR_NOT_ENUM);
1833
1835 if (Characteristics & FR_PRIVATE)
1836 {
1837 /* private font */
1839 IntLockProcessPrivateFonts(Win32Process);
1840 InsertTailList(&Win32Process->PrivateFontListHead, &Entry->ListEntry);
1841 IntUnLockProcessPrivateFonts(Win32Process);
1842 }
1843 else
1844 {
1845 /* global font */
1846 InsertTailList(&g_FontListHead, &Entry->ListEntry);
1847 }
1849
1850 if (CharSetIndex == -1)
1851 {
1852 INT i;
1853 USHORT NameLength = Entry->FaceName.Length;
1854
1855 if (Entry->StyleName.Length)
1856 NameLength += Entry->StyleName.Length + sizeof(WCHAR);
1857
1858 if (pLoadFont->RegValueName.Length == 0)
1859 {
1860 pValueName->Length = 0;
1861 pValueName->MaximumLength = NameLength + sizeof(WCHAR);
1863 pValueName->MaximumLength,
1864 TAG_USTR);
1865 pValueName->Buffer[0] = UNICODE_NULL;
1866 RtlAppendUnicodeStringToString(pValueName, &Entry->FaceName);
1867 }
1868 else
1869 {
1870 UNICODE_STRING NewString;
1871 USHORT Length = pValueName->Length + 3 * sizeof(WCHAR) + NameLength;
1872 NewString.Length = 0;
1873 NewString.MaximumLength = Length + sizeof(WCHAR);
1875 NewString.MaximumLength,
1876 TAG_USTR);
1877 NewString.Buffer[0] = UNICODE_NULL;
1878
1879 RtlAppendUnicodeStringToString(&NewString, pValueName);
1880 RtlAppendUnicodeToString(&NewString, L" & ");
1881 RtlAppendUnicodeStringToString(&NewString, &Entry->FaceName);
1882
1883 RtlFreeUnicodeString(pValueName);
1884 *pValueName = NewString;
1885 }
1886 if (Entry->StyleName.Length)
1887 {
1888 RtlAppendUnicodeToString(pValueName, L" ");
1889 RtlAppendUnicodeStringToString(pValueName, &Entry->StyleName);
1890 }
1891
1892 for (i = 1; i < CharSetCount; ++i)
1893 {
1894 /* Do not count charsets as loaded 'faces' */
1895 IntGdiLoadFontsFromMemory(pLoadFont, SharedFace, FontIndex, i);
1896 }
1897 }
1898
1899 return FaceCount; /* Number of loaded faces */
1900
1901CleanupAndFail:
1902 if (PrivateEntry)
1903 {
1904 if (pLoadFont->PrivateEntry == PrivateEntry)
1905 pLoadFont->PrivateEntry = NULL;
1906 else
1907 RemoveEntryList(&PrivateEntry->ListEntry);
1908 ExFreePoolWithTag(PrivateEntry, TAG_FONT);
1909 }
1910 if (FontGDI)
1911 {
1912 if (FontGDI->Filename)
1914 EngFreeMem(FontGDI);
1915 }
1917 SharedFace_Release(SharedFace, TRUE);
1918 return 0;
1919}
#define ERR(fmt,...)
Definition: precomp.h:57
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
@ AnsiString
Definition: dnslib.h:19
static void SharedFace_AddRef(PSHARED_FACE Ptr)
Definition: freetype.c:454
unsigned short FT_UShort
Definition: fttypes.h:209
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
FT_String * family_name
Definition: freetype.h:1038
FT_UShort weight
Definition: ftwinfnt.h:198
PUNICODE_STRING pFileName
Definition: font.h:86
PFONT_ENTRY_MEM PrivateEntry
Definition: font.h:92
UNICODE_STRING RegValueName
Definition: font.h:89
DWORD Characteristics
Definition: font.h:88
FT_UShort fsSelection
Definition: tttables.h:403
FT_UShort usWeightClass
Definition: tttables.h:379
@ FT_SFNT_OS2
Definition: tttables.h:624
#define GDITAG_RFONT
Definition: tags.h:92

Referenced by IntGdiLoadFontByIndexFromMemory(), and IntGdiLoadFontsFromMemory().

◆ IntGdiRemoveFontMemResource()

BOOL FASTCALL IntGdiRemoveFontMemResource ( HANDLE  hMMFont)

Definition at line 2615 of file freetype.c.

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

Referenced by NtGdiRemoveFontMemResourceEx().

◆ IntGdiRemoveFontResource()

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

Definition at line 2341 of file freetype.c.

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

Referenced by NtGdiRemoveFontResourceW().

◆ IntGdiRemoveFontResourceSingle()

static BOOL FASTCALL IntGdiRemoveFontResourceSingle ( _In_ PCUNICODE_STRING  FileName,
_In_ DWORD  dwFlags 
)
static

Definition at line 2272 of file freetype.c.

2275{
2276 BOOL ret = FALSE;
2277 UNICODE_STRING PathName;
2278 PLIST_ENTRY CurrentEntry, NextEntry;
2279 PFONT_ENTRY FontEntry;
2280 PFONTGDI FontGDI;
2281 PWSTR pszBuffer, pszFileTitle;
2282 SIZE_T Length;
2284
2285 /* Build PathName */
2287 {
2288 Length = DosPathPrefix.Length + FileName->Length + sizeof(UNICODE_NULL);
2290 if (!pszBuffer)
2291 return FALSE; /* Failure */
2292
2293 RtlInitEmptyUnicodeString(&PathName, pszBuffer, Length);
2296 }
2297 else
2298 {
2300 if (!NT_SUCCESS(Status))
2301 return FALSE; /* Failure */
2302 }
2303
2304 pszFileTitle = PathName.Buffer;
2306 pszFileTitle = PathFindFileNameW(PathName.Buffer);
2307
2308 if (!pszFileTitle || !*pszFileTitle)
2309 {
2310 RtlFreeUnicodeString(&PathName);
2311 return FALSE; /* Failure */
2312 }
2313
2314 /* Delete font entries that matches PathName */
2316 for (CurrentEntry = g_FontListHead.Flink;
2317 CurrentEntry != &g_FontListHead;
2318 CurrentEntry = NextEntry)
2319 {
2320 FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_ENTRY, ListEntry);
2321 NextEntry = CurrentEntry->Flink;
2322
2323 FontGDI = FontEntry->Font;
2324 ASSERT(FontGDI);
2325 if (FontGDI->Filename && _wcsicmp(FontGDI->Filename, pszFileTitle) == 0)
2326 {
2327 RemoveEntryList(&FontEntry->ListEntry);
2328 CleanupFontEntry(FontEntry);
2330 IntDeleteRegFontEntries(pszFileTitle, dwFlags);
2331 ret = TRUE;
2332 }
2333 }
2335
2336 RtlFreeUnicodeString(&PathName);
2337 return ret;
2338}
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1677
VOID IntDeleteRegFontEntries(_In_ PCWSTR pszFileName, _In_ DWORD dwFlags)
Definition: freetype.c:2237
LIST_ENTRY ListEntry
Definition: font.h:6

Referenced by IntGdiRemoveFontResource().

◆ IntGetBitmapGlyphWithCache()

static FT_BitmapGlyph IntGetBitmapGlyphWithCache ( IN OUT PFONT_CACHE_ENTRY  Cache,
IN FT_GlyphSlot  GlyphSlot 
)
static

Definition at line 3818 of file freetype.c.

3821{
3822 FT_Glyph GlyphCopy;
3823 INT error;
3824 PFONT_CACHE_ENTRY NewEntry;
3825 FT_Bitmap AlignedBitmap;
3826 FT_BitmapGlyph BitmapGlyph;
3827
3829
3830 error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
3831 if (error)
3832 {
3833 DPRINT1("Failure caching glyph.\n");
3834 return NULL;
3835 };
3836
3837 error = FT_Glyph_To_Bitmap(&GlyphCopy, Cache->Hashed.Aspect.RenderMode, 0, 1);
3838 if (error)
3839 {
3840 FT_Done_Glyph(GlyphCopy);
3841 DPRINT1("Failure rendering glyph.\n");
3842 return NULL;
3843 };
3844
3846 if (!NewEntry)
3847 {
3848 DPRINT1("Alloc failure caching glyph.\n");
3849 FT_Done_Glyph(GlyphCopy);
3850 return NULL;
3851 }
3852
3853 BitmapGlyph = (FT_BitmapGlyph)GlyphCopy;
3854 FT_Bitmap_New(&AlignedBitmap);
3855 if (FT_Bitmap_Convert_ReactOS_Hack(GlyphSlot->library, &BitmapGlyph->bitmap,
3856 &AlignedBitmap, 4, TRUE))
3857 {
3858 DPRINT1("Conversion failed\n");
3859 ExFreePoolWithTag(NewEntry, TAG_FONT);
3860 FT_Bitmap_Done(GlyphSlot->library, &AlignedBitmap);
3861 FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3862 return NULL;
3863 }
3864
3865 FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3866 BitmapGlyph->bitmap = AlignedBitmap;
3867
3868 NewEntry->BitmapGlyph = BitmapGlyph;
3869 NewEntry->dwHash = Cache->dwHash;
3870 NewEntry->Hashed = Cache->Hashed;
3871
3872 InsertHeadList(&g_FontCacheListHead, &NewEntry->ListEntry);
3874 {
3875 NewEntry = CONTAINING_RECORD(g_FontCacheListHead.Blink, FONT_CACHE_ENTRY, ListEntry);
3876 RemoveCachedEntry(NewEntry);
3877 }
3878
3879 return BitmapGlyph;
3880}
#define MAX_FONT_CACHE
Definition: freetype.c:237
FT_Bitmap_New(FT_Bitmap *abitmap)
Definition: ftbitmap.c:53
FT_Bitmap_Done(FT_Library library, FT_Bitmap *bitmap)
Definition: ftbitmap.c:1197
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:641
FT_Glyph_To_Bitmap(FT_Glyph *the_glyph, FT_Render_Mode render_mode, FT_Vector *origin, FT_Bool destroy)
Definition: ftglyph.c:536
FT_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph)
Definition: ftglyph.c:401
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:131
LIST_ENTRY ListEntry
Definition: font.h:57

Referenced by IntGetRealGlyph().

◆ IntGetCharSet()

UINT FASTCALL IntGetCharSet ( INT  nIndex,
FT_ULong  CodePageRange1 
)

Definition at line 1504 of file freetype.c.

1505{
1506 UINT BitIndex, CharSet;
1507 UINT nCount = 0;
1508
1509 if (CodePageRange1 == 0)
1510 return (nIndex < 0) ? 1 : DEFAULT_CHARSET;
1511
1512 for (BitIndex = 0; BitIndex < MAXTCIINDEX; ++BitIndex)
1513 {
1514 if (CodePageRange1 & (1 << BitIndex))
1515 {
1516 CharSet = g_FontTci[BitIndex].ciCharset;
1517 if ((nIndex >= 0) && (nCount == (UINT)nIndex))
1518 {
1519 return CharSet;
1520 }
1521 ++nCount;
1522 }
1523 }
1524
1525 return (nIndex < 0) ? nCount : ANSI_CHARSET;
1526}
static void CharSet(RTF_Info *info)
Definition: reader.c:2400

◆ IntGetFontDefaultChar()

static BOOL IntGetFontDefaultChar ( _In_ FT_Face  Face,
_Out_ PWCHAR  pDefChar 
)
static

Definition at line 7561 of file freetype.c.

7562{
7563 TT_OS2 *pOS2;
7564 FT_WinFNT_HeaderRec WinFNT;
7566
7568
7569 if (FT_IS_SFNT(Face)) // TrueType / OpenType
7570 {
7572 pOS2 = FT_Get_Sfnt_Table(Face, FT_SFNT_OS2);
7573 if (pOS2)
7574 *pDefChar = pOS2->usDefaultChar;
7576 return !!pOS2;
7577 }
7578
7579 if (!FT_IS_SCALABLE(Face)) // *.fon / *.fnt
7580 {
7582 error = FT_Get_WinFNT_Header(Face, &WinFNT);
7584 if (!error)
7585 *pDefChar = WinFNT.default_char;
7586 return !error;
7587 }
7588
7589 *pDefChar = 0; // .notdef
7590 return TRUE;
7591}
FT_UShort usDefaultChar
Definition: tttables.h:421

Referenced by GreGetGlyphIndicesW().

◆ IntGetFontFamilyInfo()

LONG FASTCALL IntGetFontFamilyInfo ( HDC  Dc,
const LOGFONTW SafeLogFont,
PFONTFAMILYINFO  SafeInfo,
LONG  InfoCount 
)

Definition at line 6442 of file freetype.c.

6446{
6447 LONG AvailCount = 0;
6448 PPROCESSINFO Win32Process;
6449
6450 /* Enumerate font families in the global list */
6452 if (!GetFontFamilyInfoForList(SafeLogFont, SafeInfo, NULL, &AvailCount,
6453 InfoCount, &g_FontListHead))
6454 {
6456 return -1;
6457 }
6458
6459 /* Enumerate font families in the process local list */
6460 Win32Process = PsGetCurrentProcessWin32Process();
6461 IntLockProcessPrivateFonts(Win32Process);
6462 if (!GetFontFamilyInfoForList(SafeLogFont, SafeInfo, NULL, &AvailCount, InfoCount,
6463 &Win32Process->PrivateFontListHead))
6464 {
6465 IntUnLockProcessPrivateFonts(Win32Process);
6467 return -1;
6468 }
6469 IntUnLockProcessPrivateFonts(Win32Process);
6471
6472 /* Enumerate font families in the registry */
6473 if (!GetFontFamilyInfoForSubstitutes(SafeLogFont, SafeInfo, &AvailCount, InfoCount))
6474 {
6475 return -1;
6476 }
6477
6478 return AvailCount;
6479}
static BOOLEAN FASTCALL GetFontFamilyInfoForSubstitutes(const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LONG *pCount, LONG MaxCount)
Definition: freetype.c:3691

Referenced by NtGdiGetFontFamilyInfo().

◆ IntGetFontLocalizedName()

static NTSTATUS IntGetFontLocalizedName ( PUNICODE_STRING  pNameW,
PSHARED_FACE  SharedFace,
FT_UShort  NameID,
FT_UShort  LangID 
)
static

Definition at line 3300 of file freetype.c.

3302{
3304 INT i, Count, BestIndex, Score, BestScore;
3307 ANSI_STRING AnsiName;
3308 PSHARED_FACE_CACHE Cache;
3309 FT_Face Face = SharedFace->Face;
3310
3311 RtlFreeUnicodeString(pNameW);
3312
3313 /* select cache */
3315 Cache = &SharedFace->EnglishUS;
3316 else
3317 Cache = &SharedFace->UserLanguage;
3318
3319 /* use cache if available */
3320 if (NameID == TT_NAME_ID_FONT_FAMILY && Cache->FontFamily.Buffer)
3321 return IntDuplicateUnicodeString(&Cache->FontFamily, pNameW);
3322 if (NameID == TT_NAME_ID_FULL_NAME && Cache->FullName.Buffer)
3323 return IntDuplicateUnicodeString(&Cache->FullName, pNameW);
3324
3325 BestIndex = -1;
3326 BestScore = 0;
3327
3329 for (i = 0; i < Count; ++i)
3330 {
3331 Error = FT_Get_Sfnt_Name(Face, i, &Name);
3332 if (Error)
3333 continue; /* failure */
3334
3335 if (Name.name_id != NameID)
3336 continue; /* mismatched */
3337
3338 if (Name.platform_id != TT_PLATFORM_MICROSOFT ||
3339 (Name.encoding_id != TT_MS_ID_UNICODE_CS &&
3340 Name.encoding_id != TT_MS_ID_SYMBOL_CS))
3341 {
3342 continue; /* not Microsoft Unicode name */
3343 }
3344
3345 if (Name.string == NULL || Name.string_len == 0 ||
3346 (Name.string[0] == 0 && Name.string[1] == 0))
3347 {
3348 continue; /* invalid string */
3349 }
3350
3351 if (Name.language_id == LangID)
3352 {
3353 Score = 30;
3354 BestIndex = i;
3355 break; /* best match */
3356 }
3357 else if (PRIMARYLANGID(Name.language_id) == PRIMARYLANGID(LangID))
3358 {
3359 Score = 20;
3360 }
3361 else if (PRIMARYLANGID(Name.language_id) == LANG_ENGLISH)
3362 {
3363 Score = 10;
3364 }
3365 else
3366 {
3367 Score = 0;
3368 }
3369
3370 if (Score > BestScore)
3371 {
3372 BestScore = Score;
3373 BestIndex = i;
3374 }
3375 }
3376
3377 if (BestIndex >= 0)
3378 {
3379 /* store the best name */
3380 Error = (Score == 30) ? 0 : FT_Get_Sfnt_Name(Face, BestIndex, &Name);
3381 if (!Error)
3382 {
3383 /* NOTE: Name.string is not null-terminated */
3384 UNICODE_STRING Tmp;
3385 Tmp.Buffer = (PWCH)Name.string;
3386 Tmp.Length = Tmp.MaximumLength = Name.string_len;
3387
3388 pNameW->Length = 0;
3389 pNameW->MaximumLength = Name.string_len + sizeof(WCHAR);
3391
3392 if (pNameW->Buffer)
3393 {
3394 Status = RtlAppendUnicodeStringToString(pNameW, &Tmp);
3395 if (Status == STATUS_SUCCESS)
3396 {
3397 /* Convert UTF-16 big endian to little endian */
3398 IntSwapEndian(pNameW->Buffer, pNameW->Length);
3399 }
3400 }
3401 else
3402 {
3404 }
3405 }
3406 }
3407
3408 if (!NT_SUCCESS(Status))
3409 {
3410 /* defaulted */
3411 if (NameID == TT_NAME_ID_FONT_SUBFAMILY)
3412 {
3413 RtlInitAnsiString(&AnsiName, Face->style_name);
3414 Status = RtlAnsiStringToUnicodeString(pNameW, &AnsiName, TRUE);
3415 }
3416 else
3417 {
3418 RtlInitAnsiString(&AnsiName, Face->family_name);
3419 Status = RtlAnsiStringToUnicodeString(pNameW, &AnsiName, TRUE);
3420 }
3421 }
3422
3423 if (NT_SUCCESS(Status))
3424 {
3425 /* make cache */
3426 if (NameID == TT_NAME_ID_FONT_FAMILY)
3427 {
3429 if (!Cache->FontFamily.Buffer)
3430 IntDuplicateUnicodeString(pNameW, &Cache->FontFamily);
3431 }
3432 else if (NameID == TT_NAME_ID_FULL_NAME)
3433 {
3435 if (!Cache->FullName.Buffer)
3436 IntDuplicateUnicodeString(pNameW, &Cache->FullName);
3437 }
3438 }
3439
3440 return Status;
3441}
LPWSTR Name
Definition: desk.c:124
#define TT_MS_ID_UNICODE_CS
Definition: font.c:1139
#define TT_MS_ID_SYMBOL_CS
Definition: font.c:1138
FT_Get_Sfnt_Name_Count(FT_Face face)
Definition: ftsnames.c:148
FT_BEGIN_HEADER struct FT_SfntName_ FT_SfntName
FT_Get_Sfnt_Name(FT_Face face, FT_UInt idx, FT_SfntName *aname)
Definition: ftsnames.c:157
#define TT_NAME_ID_FULL_NAME
Definition: font.c:3581
#define TT_NAME_ID_FONT_SUBFAMILY
Definition: font.c:3579
WCHAR * PWCH
Definition: ntbasedef.h:422
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define STATUS_NOT_FOUND
Definition: shellext.h:72
UNICODE_STRING FontFamily
Definition: engobjects.h:127
UNICODE_STRING FullName
Definition: engobjects.h:128
SHARED_FACE_CACHE UserLanguage
Definition: engobjects.h:136
SHARED_FACE_CACHE EnglishUS
Definition: engobjects.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
VOID IntSwapEndian(_Inout_ LPVOID pvData, _In_ DWORD Size)
Definition: utils.c:125

Referenced by IntInitFontNames(), MatchFontName(), and TextIntRealizeFont().

◆ IntGetFontRenderMode()

FT_Render_Mode FASTCALL IntGetFontRenderMode ( LOGFONTW logfont)

Definition at line 2713 of file freetype.c.

2714{
2715 switch (logfont->lfQuality)
2716 {
2718 break;
2720 return FT_RENDER_MODE_MONO;
2721 case DRAFT_QUALITY:
2722 return FT_RENDER_MODE_LIGHT;
2723 case CLEARTYPE_QUALITY:
2724 if (!gspv.bFontSmoothing)
2725 break;
2727 break;
2728 return FT_RENDER_MODE_LCD;
2729 }
2730 return FT_RENDER_MODE_NORMAL;
2731}
@ FT_RENDER_MODE_NORMAL
Definition: freetype.h:3249
@ FT_RENDER_MODE_LIGHT
Definition: freetype.h:3250
@ FT_RENDER_MODE_LCD
Definition: freetype.h:3252
BOOL bFontSmoothing
Definition: sysparams.h:125
UINT uiFontSmoothingType
Definition: sysparams.h:126
SPIVALUES gspv
Definition: sysparams.c:17
#define ANTIALIASED_QUALITY
Definition: wingdi.h:440
#define DRAFT_QUALITY
Definition: wingdi.h:437
#define CLEARTYPE_QUALITY
Definition: wingdi.h:441
#define NONANTIALIASED_QUALITY
Definition: wingdi.h:439

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ IntGetFullFileName()

static BOOL FASTCALL IntGetFullFileName ( POBJECT_NAME_INFORMATION  NameInfo,
ULONG  Size,
PUNICODE_STRING  FileName 
)
static

Definition at line 5913 of file freetype.c.

5917{
5920 HANDLE hFile;
5922 ULONG Desired;
5923
5925 FileName,
5927 NULL,
5928 NULL);
5929
5931 &hFile,
5932 0, // FILE_READ_ATTRIBUTES,
5936 0);
5937
5938 if (!NT_SUCCESS(Status))
5939 {
5940 DPRINT("ZwOpenFile() failed (Status = 0x%lx)\n", Status);
5941 return FALSE;
5942 }
5943
5944 Status = ZwQueryObject(hFile, ObjectNameInformation, NameInfo, Size, &Desired);
5945 ZwClose(hFile);
5946 if (!NT_SUCCESS(Status))
5947 {
5948 DPRINT("ZwQueryObject() failed (Status = %lx)\n", Status);
5949 return FALSE;
5950 }
5951
5952 return TRUE;
5953}
@ ObjectNameInformation
Definition: DriverTester.h:55
_In_ PIO_STATUS_BLOCK IoStatusBlock
Definition: dispmprt.h:608
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_DELETE
Definition: nt_native.h:682

Referenced by IntGdiGetFontResourceInfo().

◆ IntGetHash()

static DWORD IntGetHash ( IN LPCVOID  pv,
IN DWORD  cdw 
)
static

Definition at line 3766 of file freetype.c.

3767{
3768 DWORD dwHash = cdw;
3769 const DWORD *pdw = pv;
3770
3771 while (cdw-- > 0)
3772 {
3773 dwHash *= 3;
3774 dwHash ^= *pdw++;
3775 }
3776
3777 return dwHash;
3778}

Referenced by IntGetRealGlyph().

◆ IntGetOutlineTextMetrics()

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

Definition at line 3140 of file freetype.c.

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

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

◆ IntGetRealGlyph()

static FT_BitmapGlyph IntGetRealGlyph ( IN OUT PFONT_CACHE_ENTRY  Cache)
static

Definition at line 4929 of file freetype.c.

4931{
4932 INT error;
4933 FT_GlyphSlot glyph;
4934 FT_BitmapGlyph realglyph;
4935
4937
4938 Cache->dwHash = IntGetHash(&Cache->Hashed, sizeof(Cache->Hashed) / sizeof(DWORD));
4939
4940 realglyph = IntFindGlyphCache(Cache);
4941 if (realglyph)
4942 return realglyph;
4943
4944 error = FT_Load_Glyph(Cache->Hashed.Face, Cache->Hashed.GlyphIndex, FT_LOAD_DEFAULT);
4945 if (error)
4946 {
4947 DPRINT1("WARNING: Failed to load and render glyph! [index: %d]\n", Cache->Hashed.GlyphIndex);
4948 return NULL;
4949 }
4950
4951 glyph = Cache->Hashed.Face->glyph;
4952
4953 if (Cache->Hashed.Aspect.Emu.Bold)
4954 FT_GlyphSlot_Embolden(glyph); /* Emulate Bold */
4955
4956 if (Cache->Hashed.Aspect.Emu.Italic)
4957 FT_GlyphSlot_Oblique(glyph); /* Emulate Italic */
4958
4959 realglyph = IntGetBitmapGlyphWithCache(Cache, glyph);
4960
4961 if (!realglyph)
4962 DPRINT1("Failed to render glyph! [index: %d]\n", Cache->Hashed.GlyphIndex);
4963
4964 return realglyph;
4965}
static DWORD IntGetHash(IN LPCVOID pv, IN DWORD cdw)
Definition: freetype.c:3766
static FT_BitmapGlyph IntFindGlyphCache(IN const FONT_CACHE_ENTRY *pCache)
Definition: freetype.c:3781
static FT_BitmapGlyph IntGetBitmapGlyphWithCache(IN OUT PFONT_CACHE_ENTRY Cache, IN FT_GlyphSlot GlyphSlot)
Definition: freetype.c:3818
FT_BEGIN_HEADER FT_GlyphSlot_Embolden(FT_GlyphSlot slot)
Definition: ftsynth.c:89
FT_GlyphSlot_Oblique(FT_GlyphSlot slot)
Definition: ftsynth.c:47

Referenced by IntExtTextOutW(), IntGetTextDisposition(), and TextIntGetTextExtentPoint().

◆ IntGetTextDisposition()

static BOOL IntGetTextDisposition ( _Out_ LONGLONG pX64,
_Out_ LONGLONG pY64,
_In_reads_(Count) PCWCH  String,
_In_ INT  Count,
_In_opt_ const INT Dx,
_Inout_ PFONT_CACHE_ENTRY  Cache,
_In_ UINT  fuOptions,
_In_ BOOL  bNoTransform,
_Inout_ PFONTLINK_CHAIN  pChain 
)
static

Definition at line 6583 of file freetype.c.

6593{
6594 LONGLONG X64 = 0, Y64 = 0;
6595 INT i, glyph_index;
6596 FT_BitmapGlyph realglyph;
6597 FT_Face face = Cache->Hashed.Face;
6598 BOOL use_kerning = FT_HAS_KERNING(face);
6599 ULONG previous = 0;
6600 FT_Vector delta, vec;
6601 DWORD ch0, ch1;
6602
6604
6605 for (i = 0; i < Count; ++i)
6606 {
6607 ch0 = *String++;
6608 if (IS_HIGH_SURROGATE(ch0))
6609 {
6610 ++i;
6611 if (i >= Count)
6612 return TRUE;
6613
6614 ch1 = *String++;
6615 if (IS_LOW_SURROGATE(ch1))
6616 ch0 = Utf32FromSurrogatePair(ch0, ch1);
6617 }
6618
6619 glyph_index = FontLink_Chain_FindGlyph(pChain, Cache, &face, ch0,
6620 (fuOptions & ETO_GLYPH_INDEX));
6621 Cache->Hashed.GlyphIndex = glyph_index;
6622
6623 realglyph = IntGetRealGlyph(Cache);
6624 if (!realglyph)
6625 return FALSE;
6626
6627 /* Retrieve kerning distance */
6628 if (use_kerning && previous && glyph_index)
6629 {
6630 FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
6631 X64 += delta.x;
6632 Y64 -= delta.y;
6633 }
6634
6635 if (NULL == Dx)
6636 {
6637 X64 += realglyph->root.advance.x >> 10;
6638 Y64 -= realglyph->root.advance.y >> 10;
6639 }
6640 else if (fuOptions & ETO_PDY)
6641 {
6642 vec.x = (Dx[2 * i + 0] << 6);
6643 vec.y = (Dx[2 * i + 1] << 6);
6644 if (!bNoTransform)
6645 FT_Vector_Transform(&vec, &Cache->Hashed.matTransform);
6646 X64 += vec.x;
6647 Y64 -= vec.y;
6648 }
6649 else
6650 {
6651 vec.x = (Dx[i] << 6);
6652 vec.y = 0;
6653 if (!bNoTransform)
6654 FT_Vector_Transform(&vec, &Cache->Hashed.matTransform);
6655 X64 += vec.x;
6656 Y64 -= vec.y;
6657 }
6658
6659 previous = glyph_index;
6660 }
6661
6662 *pX64 = X64;
6663 *pY64 = Y64;
6664 return TRUE;
6665}

Referenced by IntExtTextOutW().

◆ IntInitFontNames()

static __inline void FASTCALL IntInitFontNames ( FONT_NAMES Names,
PSHARED_FACE  SharedFace 
)
static

Definition at line 3067 of file freetype.c.

3068{
3069 ULONG OtmSize;
3070
3071 RtlInitUnicodeString(&Names->FamilyNameW, NULL);
3072 RtlInitUnicodeString(&Names->FaceNameW, NULL);
3073 RtlInitUnicodeString(&Names->StyleNameW, NULL);
3074 RtlInitUnicodeString(&Names->FullNameW, NULL);
3075
3076 /* family name */
3078 /* face name */
3080 /* style name */
3082 /* unique name (full name) */
3084
3085 /* Calculate the size of OUTLINETEXTMETRICW with extra data */
3086 OtmSize = sizeof(OUTLINETEXTMETRICW) +
3087 Names->FamilyNameW.Length + sizeof(UNICODE_NULL) +
3088 Names->FaceNameW.Length + sizeof(UNICODE_NULL) +
3089 Names->StyleNameW.Length + sizeof(UNICODE_NULL) +
3090 Names->FullNameW.Length + sizeof(UNICODE_NULL);
3091 Names->OtmSize = OtmSize;
3092}
static NTSTATUS IntGetFontLocalizedName(PUNICODE_STRING pNameW, PSHARED_FACE SharedFace, FT_UShort NameID, FT_UShort LangID)
Definition: freetype.c:3300
#define TT_NAME_ID_UNIQUE_ID
Definition: font.c:3580
struct _OUTLINETEXTMETRICW OUTLINETEXTMETRICW

Referenced by IntGetOutlineTextMetrics().

◆ IntIsFontRenderingEnabled()

BOOL FASTCALL IntIsFontRenderingEnabled ( VOID  )

Definition at line 2701 of file freetype.c.

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

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ IntLoadFontsInRegistry()

BOOL FASTCALL IntLoadFontsInRegistry ( VOID  )

Definition at line 2377 of file freetype.c.

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

Referenced by InitFontSupport().

◆ IntLoadFontSubstList()

BOOL FASTCALL IntLoadFontSubstList ( PLIST_ENTRY  pHead)

Definition at line 729 of file freetype.c.

730{
734 KEY_FULL_INFORMATION KeyFullInfo;
735 ULONG i, Length;
736 UNICODE_STRING FromW, ToW;
737 BYTE InfoBuffer[128];
739 BYTE CharSets[FONTSUBST_FROM_AND_TO];
740 LPWSTR pch;
742
743 /* the FontSubstitutes registry key */
744 static UNICODE_STRING FontSubstKey =
745 RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\"
746 L"Microsoft\\Windows NT\\CurrentVersion\\"
747 L"FontSubstitutes");
748
749 /* open registry key */
752 NULL, NULL);
753 Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
754 if (!NT_SUCCESS(Status))
755 {
756 DPRINT("ZwOpenKey failed: 0x%08X\n", Status);
757 return FALSE; /* failure */
758 }
759
760 /* query count of values */
761 Status = ZwQueryKey(KeyHandle, KeyFullInformation,
762 &KeyFullInfo, sizeof(KeyFullInfo), &Length);
763 if (!NT_SUCCESS(Status))
764 {
765 DPRINT("ZwQueryKey failed: 0x%08X\n", Status);
767 return FALSE; /* failure */
768 }
769
770 /* for each value */
771 for (i = 0; i < KeyFullInfo.Values; ++i)
772 {
773 /* get value name */
774 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
775 InfoBuffer, sizeof(InfoBuffer), &Length);
776 if (!NT_SUCCESS(Status))
777 {
778 DPRINT("ZwEnumerateValueKey failed: 0x%08X\n", Status);
779 break; /* failure */
780 }
781
782 /* create FromW string */
783 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
784 Length = pInfo->NameLength / sizeof(WCHAR);
785 pInfo->Name[Length] = UNICODE_NULL; /* truncate */
786 if (!RtlCreateUnicodeString(&FromW, pInfo->Name))
787 {
789 DPRINT("RtlCreateUnicodeString failed\n");
790 break; /* failure */
791 }
792
793 /* query value */
794 Status = ZwQueryValueKey(KeyHandle, &FromW, KeyValueFullInformation,
795 InfoBuffer, sizeof(InfoBuffer), &Length);
796 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
797 if (!NT_SUCCESS(Status) || !pInfo->DataLength)
798 {
799 DPRINT("ZwQueryValueKey failed: 0x%08X\n", Status);
800 RtlFreeUnicodeString(&FromW);
801 break; /* failure */
802 }
803
804 /* create ToW string */
805 pch = (LPWSTR)((PUCHAR)pInfo + pInfo->DataOffset);
806 Length = pInfo->DataLength / sizeof(WCHAR);
807 pch[Length] = UNICODE_NULL; /* truncate */
808 if (!RtlCreateUnicodeString(&ToW, pch))
809 {
811 DPRINT("RtlCreateUnicodeString failed\n");
812 RtlFreeUnicodeString(&FromW);
813 break; /* failure */
814 }
815
816 /* does charset exist? (from) */
818 pch = wcsrchr(FromW.Buffer, L',');
819 if (pch)
820 {
821 /* truncate */
822 *pch = UNICODE_NULL;
823 FromW.Length = (pch - FromW.Buffer) * sizeof(WCHAR);
824 /* parse charset number */
825 CharSets[FONTSUBST_FROM] = (BYTE)_wtoi(pch + 1);
826 }
827
828 /* does charset exist? (to) */
829 CharSets[FONTSUBST_TO] = DEFAULT_CHARSET;
830 pch = wcsrchr(ToW.Buffer, L',');
831 if (pch)
832 {
833 /* truncate */
834 *pch = UNICODE_NULL;
835 ToW.Length = (pch - ToW.Buffer) * sizeof(WCHAR);
836 /* parse charset number */
837 CharSets[FONTSUBST_TO] = (BYTE)_wtoi(pch + 1);
838 }
839
840 /* is it identical? */
841 if (RtlEqualUnicodeString(&FromW, &ToW, TRUE) &&
842 CharSets[FONTSUBST_FROM] == CharSets[FONTSUBST_TO])
843 {
844 RtlFreeUnicodeString(&FromW);
846 continue;
847 }
848
849 /* allocate an entry */
851 if (pEntry == NULL)
852 {
853 DPRINT("ExAllocatePoolWithTag failed\n");
854 RtlFreeUnicodeString(&FromW);
856 break; /* failure */
857 }
858
859 /* store to *pEntry */
860 pEntry->FontNames[FONTSUBST_FROM] = FromW;
861 pEntry->FontNames[FONTSUBST_TO] = ToW;
862 pEntry->CharSets[FONTSUBST_FROM] = CharSets[FONTSUBST_FROM];
863 pEntry->CharSets[FONTSUBST_TO] = CharSets[FONTSUBST_TO];
864
865 /* insert pEntry to *pHead */
866 InsertTailList(pHead, &pEntry->ListEntry);
867 }
868
869 /* close now */
871
872 return NT_SUCCESS(Status);
873}
_ACRTIMP int __cdecl _wtoi(const wchar_t *)
Definition: wcs.c:2778
#define FONTSUBST_FROM_AND_TO
Definition: font.h:71

Referenced by InitFontSupport().

◆ IntLoadSystemFonts()

VOID FASTCALL IntLoadSystemFonts ( VOID  )

Definition at line 1378 of file freetype.c.

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

Referenced by InitFontSupport().

◆ IntMatrixFromMx()

static VOID FASTCALL IntMatrixFromMx ( FT_Matrix pmat,
const MATRIX pmx 
)
static

Definition at line 1050 of file freetype.c.

1051{
1052 FLOATOBJ ef;
1053
1054 /* Create a freetype matrix, by converting to 16.16 fixpoint format */
1055 ef = pmx->efM11;
1056 FLOATOBJ_MulLong(&ef, 0x00010000);
1057 pmat->xx = FLOATOBJ_GetLong(&ef);
1058
1059 ef = pmx->efM21;
1060 FLOATOBJ_MulLong(&ef, 0x00010000);
1061 pmat->xy = -FLOATOBJ_GetLong(&ef); /* (*1) See below */
1062
1063 ef = pmx->efM12;
1064 FLOATOBJ_MulLong(&ef, 0x00010000);
1065 pmat->yx = -FLOATOBJ_GetLong(&ef); /* (*1) See below */
1066
1067 ef = pmx->efM22;
1068 FLOATOBJ_MulLong(&ef, 0x00010000);
1069 pmat->yy = FLOATOBJ_GetLong(&ef);
1070
1071 // (*1): Y direction is mirrored as follows:
1072 //
1073 // [ M11 -M12 ] [ X ] [ M11*X + M12*Y ]
1074 // [ ] * [ ] == [ ]
1075 // [ -M21 M22 ] [ -Y ] [ -(M21*X + M22*Y) ].
1076}

Referenced by ftGdiGetGlyphOutline(), and IntExtTextOutW().

◆ IntNeedRequestFontSize()

static BOOL IntNeedRequestFontSize ( PFONTLINK_CHAIN  pChain,
FT_Face  face,
PLIST_ENTRY  TargetEntry 
)
static

Definition at line 4346 of file freetype.c.

4347{
4348 PLIST_ENTRY Entry, Head = &pChain->FontLinkList;
4349 PFONTLINK pFontLink;
4350
4351 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
4352 {
4353 pFontLink = CONTAINING_RECORD(Entry, FONTLINK, ListEntry);
4354 if (!FontLink_PrepareFontInfo(pFontLink))
4355 continue; // This link is not useful, check the next one
4356
4357 if (pFontLink->SharedFace->Face == face || Entry == TargetEntry)
4358 return FALSE;
4359 }
4360
4361 return TRUE;
4362}

Referenced by FontLink_Chain_FindGlyph().

◆ IntRequestFontSize()

static FT_Error IntRequestFontSize ( _Inout_ PFONTGDI  FontGDI,
_In_ LONG  lfWidth,
_In_ LONG  lfHeight 
)
static

Definition at line 4244 of file freetype.c.

4248{
4250 Error = IntRequestFontSizeEx(FontGDI->SharedFace->Face, lfWidth, lfHeight,
4251 &FontGDI->tmHeight, &FontGDI->tmAscent,
4252 &FontGDI->tmDescent, &FontGDI->tmInternalLeading,
4253 &FontGDI->lfHeight, &FontGDI->lfWidth);
4254 if (Error == FT_Err_Ok)
4255 FontGDI->Magic = FONTGDI_MAGIC;
4256 return Error;
4257}
#define FONTGDI_MAGIC
Definition: engobjects.h:171
return FT_Err_Ok
Definition: ftbbox.c:526

Referenced by FindBestFontFromList(), and TextIntUpdateSize().

◆ IntRequestFontSizeEx()

static FT_Error IntRequestFontSizeEx ( _In_ FT_Face  face,
_In_ LONG  lfWidth,
_In_ LONG  lfHeight,
_Out_opt_ PLONG  ptmHeight,
_Out_opt_ PLONG  ptmAscent,
_Out_opt_ PLONG  ptmDescent,
_Out_opt_ PLONG  ptmInternalLeading,
_Out_opt_ PLONG  plfHeight,
_Out_opt_ PLONG  plfWidth 
)
static

Definition at line 4081 of file freetype.c.

4091{
4094 TT_OS2 *pOS2;
4095 TT_HoriHeader *pHori;
4096 FT_WinFNT_HeaderRec WinFNT;
4097 LONG Ascent, Descent, Sum, EmHeight;
4098 LONG tmHeight, tmAscent, tmDescent, tmInternalLeading;
4099
4100 lfWidth = abs(lfWidth);
4101 if (lfHeight == 0)
4102 {
4103 if (lfWidth == 0)
4104 {
4105 DPRINT("lfHeight and lfWidth are zero.\n");
4106 lfHeight = -16;
4107 }
4108 else
4109 {
4110 lfHeight = lfWidth;
4111 }
4112 }
4113
4114 if (lfHeight == -1)
4115 lfHeight = -2;
4116
4120
4121 if (!pOS2 || !pHori)
4122 {
4123 error = FT_Get_WinFNT_Header(face, &WinFNT);
4124 if (error)
4125 {
4126 ERR("%s: Failed to request font size.\n", face->family_name);
4127 return error;
4128 }
4129
4130 tmHeight = WinFNT.pixel_height;
4131 tmAscent = WinFNT.ascent;
4132 if (ptmHeight)
4133 *ptmHeight = tmHeight;
4134 if (ptmAscent)
4135 *ptmAscent = tmAscent;
4136 if (ptmDescent)
4137 *ptmDescent = tmHeight - tmAscent;
4138 if (ptmInternalLeading)
4139 *ptmInternalLeading = WinFNT.internal_leading;
4140 if (plfHeight)
4141 *plfHeight = lfHeight;
4142 if (plfWidth)
4143 *plfWidth = lfWidth;
4144 return FT_Err_Ok;
4145 }
4146
4147 /*
4148 * NOTE: We cast TT_OS2.usWinAscent and TT_OS2.usWinDescent to signed FT_Short.
4149 * Why? See: https://learn.microsoft.com/en-us/typography/opentype/spec/os2#uswindescent
4150 *
4151 * > usWinDescent is "usually" a positive value ...
4152 *
4153 * We can read it as "not always". See CORE-14994.
4154 * See also: https://learn.microsoft.com/en-us/typography/opentype/spec/os2#fsselection
4155 */
4156#define FM_SEL_USE_TYPO_METRICS 0x80
4157 if (lfHeight > 0)
4158 {
4159 /* case (A): lfHeight is positive */
4160 Sum = (FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent;
4161 if (Sum == 0 || (pOS2->fsSelection & FM_SEL_USE_TYPO_METRICS))
4162 {
4163 Ascent = pHori->Ascender;
4164 Descent = -pHori->Descender;
4165 Sum = Ascent + Descent;
4166 }
4167 else
4168 {
4169 Ascent = (FT_Short)pOS2->usWinAscent;
4170 Descent = (FT_Short)pOS2->usWinDescent;
4171 }
4172
4173 tmAscent = FT_MulDiv(lfHeight, Ascent, Sum);
4174 tmDescent = FT_MulDiv(lfHeight, Descent, Sum);
4175 tmHeight = tmAscent + tmDescent;
4176 tmInternalLeading = tmHeight - FT_MulDiv(lfHeight, face->units_per_EM, Sum);
4177 }
4178 else if (lfHeight < 0)
4179 {
4180 /* case (B): lfHeight is negative */
4182 {
4183 tmAscent = FT_MulDiv(-lfHeight, pHori->Ascender, face->units_per_EM);
4184 tmDescent = FT_MulDiv(-lfHeight, -pHori->Descender, face->units_per_EM);
4185 }
4186 else
4187 {
4188 tmAscent = FT_MulDiv(-lfHeight, (FT_Short)pOS2->usWinAscent, face->units_per_EM);
4189 tmDescent = FT_MulDiv(-lfHeight, (FT_Short)pOS2->usWinDescent, face->units_per_EM);
4190 }
4191 tmHeight = tmAscent + tmDescent;
4192 tmInternalLeading = tmHeight + lfHeight;
4193 }
4194#undef FM_SEL_USE_TYPO_METRICS
4195
4196 EmHeight = tmHeight - tmInternalLeading;
4197 EmHeight = max(EmHeight, 1);
4198 EmHeight = min(EmHeight, USHORT_MAX);
4199
4200#if 1
4201 /* I think this is wrong implementation but its test result is better. */
4202 if (lfWidth != 0)
4203 req.width = FT_MulDiv(lfWidth, face->units_per_EM, pOS2->xAvgCharWidth) << 6;
4204#else
4205 /* I think this is correct implementation but it is mismatching
4206 * to the other metric functions. The test result is bad. */
4207 if (lfWidth != 0)
4208 req.width = (FT_MulDiv(lfWidth, 96 * 5, 72 * 3) << 6); /* ??? FIXME */
4209#endif
4210 else
4211 req.width = 0;
4212
4213 /* HACK: We do not handle small widths well, so just use zero for these. See CORE-19870. */
4214 if (lfWidth < 10)
4215 req.width = 0;
4216
4218 req.height = (EmHeight << 6);
4219 req.horiResolution = 0;
4220 req.vertResolution = 0;
4221 error = FT_Request_Size(face, &req);
4222 if (error)
4223 {
4224 ERR("%s: Failed to request font size.\n", face->family_name);
4225 return error;
4226 }
4227
4228 if (ptmHeight)
4229 *ptmHeight = tmHeight;
4230 if (ptmAscent)
4231 *ptmAscent = tmAscent;
4232 if (ptmDescent)
4233 *ptmDescent = tmDescent;
4234 if (ptmInternalLeading)
4235 *ptmInternalLeading = tmInternalLeading;
4236 if (plfHeight)
4237 *plfHeight = lfHeight;
4238 if (plfWidth)
4239 *plfWidth = lfWidth;
4240 return FT_Err_Ok;
4241}
#define FM_SEL_USE_TYPO_METRICS
@ FT_SIZE_REQUEST_TYPE_NOMINAL
Definition: freetype.h:2552
FT_Request_Size(FT_Face face, FT_Size_Request req)
Definition: ftobjs.c:3256
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:415
#define USHORT_MAX
Definition: intsafe.h:147
FT_UInt horiResolution
Definition: freetype.h:2607
FT_Size_Request_Type type
Definition: freetype.h:2604
FT_UInt vertResolution
Definition: freetype.h:2608

Referenced by FontLink_Chain_FindGlyph(), and IntRequestFontSize().

◆ IntStoreFontNames()

PBYTE FASTCALL IntStoreFontNames ( _In_ const FONT_NAMES Names,
_Out_ OUTLINETEXTMETRICW Otm 
)

Definition at line 3103 of file freetype.c.

3104{
3105 PBYTE pb = (PBYTE)Otm + sizeof(OUTLINETEXTMETRICW);
3106
3107 /* family name */
3108 Otm->otmpFamilyName = (LPSTR)(pb - (BYTE*) Otm);
3109 pb += IntStoreName(&Names->FamilyNameW, pb);
3110
3111 /* face name */
3112 Otm->otmpFaceName = (LPSTR)(pb - (BYTE*) Otm);
3113 pb += IntStoreName(&Names->FaceNameW, pb);
3114
3115 /* style name */
3116 Otm->otmpStyleName = (LPSTR)(pb - (BYTE*) Otm);
3117 pb += IntStoreName(&Names->StyleNameW, pb);
3118
3119 /* unique name (full name) */
3120 Otm->otmpFullName = (LPSTR)(pb - (BYTE*) Otm);
3121 pb += IntStoreName(&Names->FullNameW, pb);
3122
3123 return pb;
3124}
static SIZE_T FASTCALL IntStoreName(_In_ const UNICODE_STRING *pName, _Out_ PBYTE pb)
Definition: freetype.c:3095
BYTE * PBYTE
Definition: pedump.c:66
char * LPSTR
Definition: typedefs.h:51

Referenced by IntGetOutlineTextMetrics().

◆ IntStoreName()

static SIZE_T FASTCALL IntStoreName ( _In_ const UNICODE_STRING pName,
_Out_ PBYTE  pb 
)
inlinestatic

Definition at line 3095 of file freetype.c.

3096{
3097 RtlCopyMemory(pb, pName->Buffer, pName->Length);
3098 *(WCHAR*)&pb[pName->Length] = UNICODE_NULL;
3099 return pName->Length + sizeof(UNICODE_NULL);
3100}
static LPSTR pName
Definition: security.c:86

Referenced by IntStoreFontNames().

◆ IntTranslateCharsetInfo()

static BOOLEAN IntTranslateCharsetInfo ( PDWORD  Src,
LPCHARSETINFO  Cs,
DWORD  Flags 
)
static

Definition at line 2776 of file freetype.c.

2782{
2783 int Index = 0;
2784
2785 switch (Flags)
2786 {
2787 case TCI_SRCFONTSIG:
2788 while (Index < MAXTCIINDEX && 0 == (*Src >> Index & 0x0001))
2789 {
2790 Index++;
2791 }
2792 break;
2793 case TCI_SRCCODEPAGE:
2794 while (Index < MAXTCIINDEX && *Src != g_FontTci[Index].ciACP)
2795 {
2796 Index++;
2797 }
2798 break;
2799 case TCI_SRCCHARSET:
2800 while (Index < MAXTCIINDEX && *Src != g_FontTci[Index].ciCharset)
2801 {
2802 Index++;
2803 }
2804 break;
2805 case TCI_SRCLOCALE:
2807 return FALSE;
2808 default:
2809 return FALSE;
2810 }
2811
2812 if (Index >= MAXTCIINDEX || DEFAULT_CHARSET == g_FontTci[Index].ciCharset)
2813 {
2814 return FALSE;
2815 }
2816
2817 RtlCopyMemory(Cs, &g_FontTci[Index], sizeof(CHARSETINFO));
2818
2819 return TRUE;
2820}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
_In_ WDFCOLLECTION _In_ ULONG Index
#define TCI_SRCLOCALE
Definition: wingdi.h:964
#define TCI_SRCCHARSET
Definition: wingdi.h:961

Referenced by FontFamilyFillInfo(), and ftGdiGetTextCharsetInfo().

◆ MatchFontName()

static BOOL MatchFontName ( PSHARED_FACE  SharedFace,
PUNICODE_STRING  Name1,
FT_UShort  NameID,
FT_UShort  LangID 
)
static

Definition at line 5862 of file freetype.c.

5863{
5866
5868 Status = IntGetFontLocalizedName(&Name2, SharedFace, NameID, LangID);
5869
5870 if (NT_SUCCESS(Status))
5871 {
5872 if (RtlCompareUnicodeString(Name1, &Name2, TRUE) == 0)
5873 {
5875 return TRUE;
5876 }
5877
5879 }
5880
5881 return FALSE;
5882}
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Must_inspect_result_ _In_ PCUNICODE_STRING Name2
Definition: fsrtlfuncs.h:796

Referenced by FontLink_PrepareFontInfo(), and MatchFontNames().

◆ MatchFontNames()

static BOOL MatchFontNames ( PSHARED_FACE  SharedFace,
LPCWSTR  lfFaceName 
)
static

Definition at line 5885 of file freetype.c.

5886{
5887 UNICODE_STRING Name1;
5888
5889 if (lfFaceName[0] == UNICODE_NULL)
5890 return FALSE;
5891
5892 RtlInitUnicodeString(&Name1, lfFaceName);
5893
5894 if (MatchFontName(SharedFace, &Name1, TT_NAME_ID_FONT_FAMILY, LANG_ENGLISH) ||
5895 MatchFontName(SharedFace, &Name1, TT_NAME_ID_FULL_NAME, LANG_ENGLISH))
5896 {
5897 return TRUE;
5898 }
5900 {
5901 if (MatchFontName(SharedFace, &Name1, TT_NAME_ID_FONT_FAMILY, gusLanguageID) ||
5902 MatchFontName(SharedFace, &Name1, TT_NAME_ID_FULL_NAME, gusLanguageID))
5903 {
5904 return TRUE;
5905 }
5906 }
5907 return FALSE;
5908}

Referenced by TextIntRealizeFont().

◆ NtGdiExtTextOutW()

BOOL APIENTRY NtGdiExtTextOutW ( _In_ HDC  hDC,
_In_ INT  XStart,
_In_ INT  YStart,
_In_ UINT  fuOptions,
_In_opt_ LPCRECT  UnsafeRect,
_In_reads_opt_(Count) PCWCH  UnsafeString,
_In_range_(0, 0xFFFF) UINT  Count,
_In_reads_opt_(_Inexpressible_(cwc)) const INT UnsafeDx,
_In_ DWORD  dwCodePage 
)

Definition at line 7257 of file freetype.c.

7267{
7268 BOOL Result = FALSE;
7270 RECTL SafeRect;
7271 BYTE LocalBuffer[STACK_TEXT_BUFFER_SIZE];
7272 PVOID Buffer = LocalBuffer;
7273 LPCWSTR SafeString = NULL;
7274 PINT SafeDx = NULL;
7275 ULONG BufSize, StringSize, DxSize = 0;
7276
7277 /* Check if String is valid */
7278 if ((Count > 0xFFFF) || (Count > 0 && UnsafeString == NULL))
7279 {
7281 return FALSE;
7282 }
7283
7284 if (Count > 0)
7285 {
7286 /* Calculate buffer size for string and Dx values */
7287 BufSize = StringSize = Count * sizeof(WCHAR);
7288 if (UnsafeDx)
7289 {
7290 /* If ETO_PDY is specified, we have pairs of INTs */
7291 DxSize = (Count * sizeof(INT)) * ((fuOptions & ETO_PDY) ? 2 : 1);
7292 BufSize += DxSize;
7293 }
7294
7295 /* Check if our local buffer is large enough */
7296 if (BufSize > sizeof(LocalBuffer))
7297 {
7298 /* It's not, allocate a temp buffer */
7300 if (!Buffer)
7301 {
7302 return FALSE;
7303 }
7304 }
7305
7306 /* Probe and copy user mode data to the buffer */
7307 _SEH2_TRY
7308 {
7309 /* Put the Dx before the String to assure alignment of 4 */
7310 SafeString = (LPCWSTR)(((ULONG_PTR)Buffer) + DxSize);
7311
7312 /* Probe and copy the string */
7313 ProbeForRead(UnsafeString, StringSize, 1);
7314 RtlCopyMemory((PVOID)SafeString, UnsafeString, StringSize);
7315
7316 /* If we have Dx values... */
7317 if (UnsafeDx)
7318 {
7319 /* ... probe and copy them */
7320 SafeDx = Buffer;
7321 ProbeForRead(UnsafeDx, DxSize, 1);
7322 RtlCopyMemory(SafeDx, UnsafeDx, DxSize);
7323 }
7324 }
7326 {
7328 }
7329 _SEH2_END
7330 if (!NT_SUCCESS(Status))
7331 {
7332 goto cleanup;
7333 }
7334 }
7335
7336 /* If we have a rect, copy it */
7337 if (UnsafeRect)
7338 {
7339 _SEH2_TRY
7340 {
7341 ProbeForRead(UnsafeRect, sizeof(RECT), 1);
7342 SafeRect = *UnsafeRect;
7343 }
7345 {
7347 }
7348 _SEH2_END
7349 if (!NT_SUCCESS(Status))
7350 {
7351 goto cleanup;
7352 }
7353 }
7354
7355 /* Finally call the internal routine */
7357 XStart,
7358 YStart,
7359 fuOptions,
7360 &SafeRect,
7361 SafeString,
7362 Count,
7363 SafeDx,
7364 dwCodePage);
7365
7366cleanup:
7367 /* If we allocated a buffer, free it */
7368 if (Buffer != LocalBuffer)
7369 {
7371 }
7372
7373 return Result;
7374}
#define BufSize
Definition: FsRtlTunnel.c:28
static void cleanup(void)
Definition: main.c:1335
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
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: freetype.c:7215
#define STACK_TEXT_BUFFER_SIZE
Definition: freetype.c:7253
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204

◆ NtGdiGetFontFamilyInfo()

LONG NTAPI NtGdiGetFontFamilyInfo ( _In_ HDC  Dc,
_In_ const LOGFONTW UnsafeLogFont,
_Out_ PFONTFAMILYINFO  UnsafeInfo,
_Inout_ PLONG  UnsafeInfoCount 
)

Definition at line 6482 of file freetype.c.

6487{
6489 LOGFONTW LogFont;
6491 LONG GotCount, AvailCount, SafeInfoCount;
6493
6494 if (UnsafeLogFont == NULL || UnsafeInfo == NULL || UnsafeInfoCount == NULL)
6495 {
6497 return -1;
6498 }
6499
6500 Status = MmCopyFromCaller(&SafeInfoCount, UnsafeInfoCount, sizeof(SafeInfoCount));
6501 if (!NT_SUCCESS(Status))
6502 {
6504 return -1;
6505 }
6506 GotCount = 0;
6507 Status = MmCopyToCaller(UnsafeInfoCount, &GotCount, sizeof(*UnsafeInfoCount));
6508 if (!NT_SUCCESS(Status))
6509 {
6511 return -1;
6512 }
6513 Status = MmCopyFromCaller(&LogFont, UnsafeLogFont, sizeof(LOGFONTW));
6514 if (!NT_SUCCESS(Status))
6515 {
6517 return -1;
6518 }
6519 if (SafeInfoCount <= 0)
6520 {
6522 return -1;
6523 }
6524
6525 /* Allocate space for a safe copy */
6526 Status = RtlULongMult(SafeInfoCount, sizeof(FONTFAMILYINFO), &DataSize);
6528 {
6529 DPRINT1("Overflowed.\n");
6531 return -1;
6532 }
6534 if (Info == NULL)
6535 {
6537 return -1;
6538 }
6539
6540 /* Retrieve the information */
6541 AvailCount = IntGetFontFamilyInfo(Dc, &LogFont, Info, SafeInfoCount);
6542 GotCount = min(AvailCount, SafeInfoCount);
6543 SafeInfoCount = AvailCount;
6544
6545 /* Return data to caller */
6546 if (GotCount > 0)
6547 {
6548 Status = RtlULongMult(GotCount, sizeof(FONTFAMILYINFO), &DataSize);
6550 {
6551 DPRINT1("Overflowed.\n");
6554 return -1;
6555 }
6556 Status = MmCopyToCaller(UnsafeInfo, Info, DataSize);
6557 if (!NT_SUCCESS(Status))
6558 {
6561 return -1;
6562 }
6563 Status = MmCopyToCaller(UnsafeInfoCount, &SafeInfoCount, sizeof(*UnsafeInfoCount));
6564 if (!NT_SUCCESS(Status))
6565 {
6568 return -1;
6569 }
6570 }
6571
6573
6574 return GotCount;
6575}
#define LONG_MAX
Definition: limits.h:30
LONG FASTCALL IntGetFontFamilyInfo(HDC Dc, const LOGFONTW *SafeLogFont, PFONTFAMILYINFO SafeInfo, LONG InfoCount)
Definition: freetype.c:6442
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define MmCopyFromCaller
Definition: polytest.cpp:29

Referenced by IntEnumFontFamilies().

◆ pick_charmap()

static FT_Encoding pick_charmap ( FT_Face  face,
int  charset 
)
static

Definition at line 1587 of file freetype.c.

1588{
1589 static const FT_Encoding regular_order[] = { FT_ENCODING_UNICODE, FT_ENCODING_APPLE_ROMAN, FT_ENCODING_MS_SYMBOL, 0 };
1590 static const FT_Encoding symbol_order[] = { FT_ENCODING_MS_SYMBOL, FT_ENCODING_UNICODE, FT_ENCODING_APPLE_ROMAN, 0 };
1591 const FT_Encoding *encs = regular_order;
1592
1593 if (charset == SYMBOL_CHARSET) encs = symbol_order;
1594
1595 while (*encs != 0)
1596 {
1597 if (select_charmap( face, *encs )) break;
1598 encs++;
1599 }
1600
1601 if (!face->charmap && face->num_charmaps)
1602 {
1603 if (!FT_Set_Charmap(face, face->charmaps[0]))
1604 return face->charmap->encoding;
1605 }
1606
1607 return *encs;
1608}
CFF_Charset charset
Definition: cffcmap.c:137
static BOOL select_charmap(FT_Face ft_face, FT_Encoding encoding)
Definition: freetype.c:1529
FT_Set_Charmap(FT_Face face, FT_CharMap charmap)
Definition: ftobjs.c:3564
enum FT_Encoding_ FT_Encoding

Referenced by IntGdiLoadFontByIndexFromMemory(), and IntGdiLoadFontsFromMemory().

◆ RemoveCachedEntry()

static void RemoveCachedEntry ( PFONT_CACHE_ENTRY  Entry)
static

◆ RemoveCacheEntries()

static void RemoveCacheEntries ( FT_Face  Face)
static

Definition at line 474 of file freetype.c.

475{
476 PLIST_ENTRY CurrentEntry, NextEntry;
477 PFONT_CACHE_ENTRY FontEntry;
478
480
481 for (CurrentEntry = g_FontCacheListHead.Flink;
482 CurrentEntry != &g_FontCacheListHead;
483 CurrentEntry = NextEntry)
484 {
485 FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
486 NextEntry = CurrentEntry->Flink;
487
488 if (FontEntry->Hashed.Face == Face)
489 {
490 RemoveCachedEntry(FontEntry);
491 }
492 }
493}

Referenced by SharedFace_Release().

◆ RTL_STATIC_LIST_HEAD() [1/4]

static RTL_STATIC_LIST_HEAD ( g_FontCacheListHead  )
static

◆ RTL_STATIC_LIST_HEAD() [2/4]

static RTL_STATIC_LIST_HEAD ( g_FontLinkEntries  )
static

◆ RTL_STATIC_LIST_HEAD() [3/4]

static RTL_STATIC_LIST_HEAD ( g_FontListHead  )
static

◆ RTL_STATIC_LIST_HEAD() [4/4]

static RTL_STATIC_LIST_HEAD ( g_FontSubstListHead  )
static

◆ select_charmap()

static BOOL select_charmap ( FT_Face  ft_face,
FT_Encoding  encoding 
)
static

Definition at line 1529 of file freetype.c.

1530{
1531 FT_Error ft_err = FT_Err_Invalid_CharMap_Handle;
1532 FT_CharMap cmap0, cmap1, cmap2, cmap3, cmap_def;
1533 FT_Int i;
1534
1535 cmap0 = cmap1 = cmap2 = cmap3 = cmap_def = NULL;
1536
1537 for (i = 0; i < ft_face->num_charmaps; i++)
1538 {
1539 if (ft_face->charmaps[i]->encoding == encoding)
1540 {
1541 TRACE("found cmap with platform_id %u, encoding_id %u\n",
1542 ft_face->charmaps[i]->platform_id, ft_face->charmaps[i]->encoding_id);
1543
1544 switch (ft_face->charmaps[i]->platform_id)
1545 {
1546 default:
1547 cmap_def = ft_face->charmaps[i];
1548 break;
1549 case TT_PLATFORM_APPLE_UNICODE: // 0: /* Apple Unicode */
1550 cmap0 = ft_face->charmaps[i];
1551 break;
1552 case TT_PLATFORM_MACINTOSH: // 1: /* Macintosh */
1553 cmap1 = ft_face->charmaps[i];
1554 break;
1555 case TT_PLATFORM_ISO: // 2: /* ISO */
1556 cmap2 = ft_face->charmaps[i];
1557 break;
1558 case TT_PLATFORM_MICROSOFT: // 3: /* Microsoft */
1559 cmap3 = ft_face->charmaps[i];
1560 break;
1561 }
1562 }
1563#ifdef __REACTOS__
1564// Wine bug: for each loop iteration, a FT_Set_Charmap() call is made.
1565// ReactOS fix: Instead, loop until we retrieve all the cmap pointers
1566// of interest, then do one single FT_Set_Charmap() call using the
1567// preferred cmap.
1568 }{
1569#endif
1570
1571 if (cmap3) /* prefer Microsoft cmap table */
1572 ft_err = FT_Set_Charmap(ft_face, cmap3);
1573 else if (cmap1)
1574 ft_err = FT_Set_Charmap(ft_face, cmap1);
1575 else if (cmap2)
1576 ft_err = FT_Set_Charmap(ft_face, cmap2);
1577 else if (cmap0)
1578 ft_err = FT_Set_Charmap(ft_face, cmap0);
1579 else if (cmap_def)
1580 ft_err = FT_Set_Charmap(ft_face, cmap_def);
1581 }
1582
1583 return ft_err == FT_Err_Ok;
1584}
#define TT_PLATFORM_MACINTOSH
Definition: font.c:1131
#define TT_PLATFORM_APPLE_UNICODE
Definition: font.c:1130
#define TRACE(s)
Definition: solgame.cpp:4
FT_UShort encoding_id
Definition: freetype.h:822
#define TT_PLATFORM_ISO
Definition: ttnameid.h:88

Referenced by pick_charmap().

◆ SharedFace_AddRef()

static void SharedFace_AddRef ( PSHARED_FACE  Ptr)
static

Definition at line 454 of file freetype.c.

455{
457
458 ++Ptr->RefCount;
459}
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898

Referenced by IntGdiLoadFontsFromMemory().

◆ SharedFace_Create()

static PSHARED_FACE SharedFace_Create ( FT_Face  Face,
PSHARED_MEM  Memory 
)
static

Definition at line 419 of file freetype.c.

420{
423 if (Ptr)
424 {
425 Ptr->Face = Face;
426 Ptr->RefCount = 1;
427 Ptr->Memory = Memory;
428 SharedFaceCache_Init(&Ptr->EnglishUS);
429 SharedFaceCache_Init(&Ptr->UserLanguage);
430
432 DPRINT("Creating SharedFace for %s\n", Face->family_name ? Face->family_name : "<NULL>");
433 }
434 return Ptr;
435}
static void SharedMem_AddRef(PSHARED_MEM Ptr)
Definition: freetype.c:403
static void SharedFaceCache_Init(PSHARED_FACE_CACHE Cache)
Definition: freetype.c:411
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169

Referenced by IntGdiLoadFontByIndexFromMemory().

◆ SharedFace_Release()

static void SharedFace_Release ( PSHARED_FACE  Ptr,
BOOL  bDoLock 
)
static

Definition at line 523 of file freetype.c.

524{
525 if (bDoLock)
527 else
529
530 ASSERT(Ptr->RefCount > 0);
531
532 if (Ptr->RefCount <= 0)
533 return;
534
535 --Ptr->RefCount;
536 if (Ptr->RefCount == 0)
537 {
538 DPRINT("Releasing SharedFace for %s\n", Ptr->Face->family_name ? Ptr->Face->family_name : "<NULL>");
539 RemoveCacheEntries(Ptr->Face);
540 FT_Done_Face(Ptr->Face);
541 SharedMem_Release(Ptr->Memory);
542 SharedFaceCache_Release(&Ptr->EnglishUS);
543 SharedFaceCache_Release(&Ptr->UserLanguage);
545 }
546
547 if (bDoLock)
549}
static void RemoveCacheEntries(FT_Face Face)
Definition: freetype.c:474
static void SharedFaceCache_Release(PSHARED_FACE_CACHE Cache)
Definition: freetype.c:516

Referenced by CleanupFontEntryEx(), and IntGdiLoadFontsFromMemory().

◆ SharedFaceCache_Init()

static void SharedFaceCache_Init ( PSHARED_FACE_CACHE  Cache)
static

Definition at line 411 of file freetype.c.

412{
413 Cache->OutlineRequiredSize = 0;
416}

Referenced by SharedFace_Create().

◆ SharedFaceCache_Release()

static void SharedFaceCache_Release ( PSHARED_FACE_CACHE  Cache)
static

Definition at line 516 of file freetype.c.

517{
520}

Referenced by SharedFace_Release().

◆ SharedMem_AddRef()

static void SharedMem_AddRef ( PSHARED_MEM  Ptr)
static

Definition at line 403 of file freetype.c.

404{
406
407 ++Ptr->RefCount;
408}

Referenced by SharedFace_Create().

◆ SharedMem_Create()

static PSHARED_MEM SharedMem_Create ( PBYTE  Buffer,
ULONG  BufferSize,
BOOL  IsMapping 
)
static

Definition at line 438 of file freetype.c.

439{
442 if (Ptr)
443 {
444 Ptr->Buffer = Buffer;
445 Ptr->BufferSize = BufferSize;
446 Ptr->RefCount = 1;
447 Ptr->IsMapping = IsMapping;
448 DPRINT("Creating SharedMem for %p (%i, %p)\n", Buffer, IsMapping, Ptr);
449 }
450 return Ptr;
451}
#define BufferSize
Definition: mmc.h:75

Referenced by IntGdiAddFontMemResource(), and IntGdiAddFontResourceSingle().

◆ SharedMem_Release()

static void SharedMem_Release ( PSHARED_MEM  Ptr)
static

Definition at line 495 of file freetype.c.

496{
498 ASSERT(Ptr->RefCount > 0);
499
500 if (Ptr->RefCount <= 0)
501 return;
502
503 --Ptr->RefCount;
504 if (Ptr->RefCount == 0)
505 {
506 DPRINT("Releasing SharedMem for %p (%i, %p)\n", Ptr->Buffer, Ptr->IsMapping, Ptr);
507 if (Ptr->IsMapping)
509 else
512 }
513}
NTSTATUS NTAPI MmUnmapViewInSystemSpace(IN PVOID MappedBase)
Definition: section.c:2777

Referenced by IntGdiAddFontMemResource(), IntGdiAddFontResourceSingle(), and SharedFace_Release().

◆ SubstituteFontByList()

static BOOL SubstituteFontByList ( PLIST_ENTRY  pHead,
PUNICODE_STRING  pOutputName,
PUNICODE_STRING  pInputName,
BYTE  RequestedCharSet,
BYTE  CharSetMap[FONTSUBST_FROM_AND_TO] 
)
static

Definition at line 1079 of file freetype.c.

1084{
1085 PLIST_ENTRY pListEntry;
1086 PFONTSUBST_ENTRY pSubstEntry;
1087 BYTE CharSets[FONTSUBST_FROM_AND_TO];
1088
1089 CharSetMap[FONTSUBST_FROM] = DEFAULT_CHARSET;
1090 CharSetMap[FONTSUBST_TO] = RequestedCharSet;
1091
1092 /* for each list entry */
1093 for (pListEntry = pHead->Flink;
1094 pListEntry != pHead;
1095 pListEntry = pListEntry->Flink)
1096 {
1097 pSubstEntry = CONTAINING_RECORD(pListEntry, FONTSUBST_ENTRY, ListEntry);
1098
1099 CharSets[FONTSUBST_FROM] = pSubstEntry->CharSets[FONTSUBST_FROM];
1100
1101 if (CharSets[FONTSUBST_FROM] != DEFAULT_CHARSET &&
1102 CharSets[FONTSUBST_FROM] != RequestedCharSet)
1103 {
1104 continue; /* not matched */
1105 }
1106
1107 /* does charset number exist? (to) */
1108 if (pSubstEntry->CharSets[FONTSUBST_TO] != DEFAULT_CHARSET)
1109 {
1110 CharSets[FONTSUBST_TO] = pSubstEntry->CharSets[FONTSUBST_TO];
1111 }
1112 else
1113 {
1114 CharSets[FONTSUBST_TO] = RequestedCharSet;
1115 }
1116
1117 /* does font name match? */
1119 pInputName, TRUE))
1120 {
1121 continue; /* not matched */
1122 }
1123
1124 /* update *pOutputName */
1125 *pOutputName = pSubstEntry->FontNames[FONTSUBST_TO];
1126
1127 if (CharSetMap[FONTSUBST_FROM] == DEFAULT_CHARSET)
1128 {
1129 /* update CharSetMap */
1130 CharSetMap[FONTSUBST_FROM] = CharSets[FONTSUBST_FROM];
1131 CharSetMap[FONTSUBST_TO] = CharSets[FONTSUBST_TO];
1132 }
1133 return TRUE; /* success */
1134 }
1135
1136 return FALSE;
1137}

Referenced by SubstituteFontRecurse().

◆ SubstituteFontRecurse()

static BOOL SubstituteFontRecurse ( PLOGFONTW  pLogFont)
static

Definition at line 1140 of file freetype.c.

1141{
1142 UINT RecurseCount = 5;
1143 UNICODE_STRING OutputNameW = { 0 };
1144 BYTE CharSetMap[FONTSUBST_FROM_AND_TO];
1145 BOOL Found;
1146 UNICODE_STRING InputNameW;
1147
1148 if (pLogFont->lfFaceName[0] == UNICODE_NULL)
1149 return FALSE;
1150
1151 RtlInitUnicodeString(&InputNameW, pLogFont->lfFaceName);
1152
1153 while (RecurseCount-- > 0)
1154 {
1155 Found = SubstituteFontByList(&g_FontSubstListHead,
1156 &OutputNameW, &InputNameW,
1157 pLogFont->lfCharSet, CharSetMap);
1158 if (!Found)
1159 break;
1160
1161 IntUnicodeStringToBuffer(pLogFont->lfFaceName, sizeof(pLogFont->lfFaceName), &OutputNameW);
1162 RtlInitUnicodeString(&InputNameW, pLogFont->lfFaceName);
1163
1164 if (CharSetMap[FONTSUBST_FROM] == DEFAULT_CHARSET ||
1165 CharSetMap[FONTSUBST_FROM] == pLogFont->lfCharSet)
1166 {
1167 pLogFont->lfCharSet = CharSetMap[FONTSUBST_TO];
1168 }
1169 }
1170
1171 return TRUE; /* success */
1172}
static BOOL SubstituteFontByList(PLIST_ENTRY pHead, PUNICODE_STRING pOutputName, PUNICODE_STRING pInputName, BYTE RequestedCharSet, BYTE CharSetMap[FONTSUBST_FROM_AND_TO])
Definition: freetype.c:1079
BYTE lfCharSet
Definition: wingdi.h:2351

Referenced by FontLink_Create(), FontLink_FindEntry(), GetFontFamilyInfoForSubstitutes(), and TextIntRealizeFont().

◆ TextIntCreateFontIndirect()

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

Definition at line 2734 of file freetype.c.

2735{
2736 PLFONT plfont;
2737 LOGFONTW *plf;
2738
2739 ASSERT(lf);
2740 plfont = LFONT_AllocFontWithHandle();
2741 if (!plfont)
2742 {
2743 return STATUS_NO_MEMORY;
2744 }
2745
2746 ExInitializePushLock(&plfont->lock);
2747 *NewFont = plfont->BaseObject.hHmgr;
2748 plf = &plfont->logfont.elfEnumLogfontEx.elfLogFont;
2749 RtlCopyMemory(plf, lf, sizeof(LOGFONTW));
2750 if (lf->lfEscapement != lf->lfOrientation)
2751 {
2752 /* This should really depend on whether GM_ADVANCED is set */
2753 plf->lfOrientation = plf->lfEscapement;
2754 }
2755 LFONT_UnlockFont(plfont);
2756
2757 return STATUS_SUCCESS;
2758}
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define ExInitializePushLock
Definition: ex.h:1016
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 ( _In_ PDC  dc,
_In_ PTEXTOBJ  TextObj,
_In_reads_(Count) PCWCH  String,
_In_ INT  Count,
_In_ ULONG  MaxExtent,
_Out_ PINT  Fit,
_Out_writes_to_opt_(Count, *Fit) PINT  Dx,
_Out_ PSIZE  Size,
_In_ FLONG  fl 
)

Definition at line 4969 of file freetype.c.

4979{
4980 PFONTGDI FontGDI;
4981 FT_BitmapGlyph realglyph;
4982 INT glyph_index, i, previous, nTenthsOfDegrees;
4983 ULONGLONG TotalWidth64 = 0;
4984 LOGFONTW *plf;
4985 BOOL use_kerning, bVerticalWriting;
4986 LONG ascender, descender;
4987 FONT_CACHE_ENTRY Cache;
4988 DWORD ch0, ch1;
4989 FONTLINK_CHAIN Chain;
4990
4991 FontGDI = ObjToGDI(TextObj->Font, FONT);
4992
4993 Cache.Hashed.Face = FontGDI->SharedFace->Face;
4994 if (NULL != Fit)
4995 {
4996 *Fit = 0;
4997 }
4998
4999 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
5000 Cache.Hashed.lfHeight = plf->lfHeight;
5001 Cache.Hashed.lfWidth = plf->lfWidth;
5002 Cache.Hashed.Aspect.Emu.Bold = EMUBOLD_NEEDED(FontGDI->OriginalWeight, plf->lfWeight);
5003 Cache.Hashed.Aspect.Emu.Italic = (plf->lfItalic && !FontGDI->OriginalItalic);
5004
5005 // Check vertical writing (tategaki)
5006 nTenthsOfDegrees = IntNormalizeAngle(plf->lfEscapement - plf->lfOrientation);
5007 bVerticalWriting = ((nTenthsOfDegrees == 90 * 10) || (nTenthsOfDegrees == 270 * 10));
5008
5011 else
5013
5014 // NOTE: GetTextExtentPoint32 simply ignores lfEscapement and XFORM.
5016 if (!TextIntUpdateSize(TextObj, FontGDI, FALSE))
5017 {
5019 return FALSE;
5020 }
5023
5024 FontLink_Chain_Init(&Chain, TextObj, Cache.Hashed.Face);
5025
5026 use_kerning = FT_HAS_KERNING(Cache.Hashed.Face);
5027 previous = 0;
5028
5029 for (i = 0; i < Count; i++)
5030 {
5031 ch0 = *String++;
5032 if (IS_HIGH_SURROGATE(ch0))
5033 {
5034 ++i;
5035 if (i >= Count)
5036 break;
5037
5038 ch1 = *String++;
5039 if (IS_LOW_SURROGATE(ch1))
5040 ch0 = Utf32FromSurrogatePair(ch0, ch1);
5041 }
5042
5043 glyph_index = FontLink_Chain_FindGlyph(&Chain, &Cache, &Cache.Hashed.Face, ch0,
5044 (fl & GTEF_INDICES));
5045 Cache.Hashed.GlyphIndex = glyph_index;
5046
5047 realglyph = IntGetRealGlyph(&Cache);
5048 if (!realglyph)
5049 break;
5050
5051 /* Retrieve kerning distance */
5052 if (use_kerning && previous && glyph_index)
5053 {
5054 FT_Vector delta;
5055 FT_Get_Kerning(Cache.Hashed.Face, previous, glyph_index, 0, &delta);
5056 TotalWidth64 += delta.x;
5057 }
5058
5059 TotalWidth64 += realglyph->root.advance.x >> 10;
5060
5061 if (((TotalWidth64 + 32) >> 6) <= MaxExtent && NULL != Fit)
5062 {
5063 *Fit = i + 1;
5064 }
5065 if (NULL != Dx)
5066 {
5067 Dx[i] = (TotalWidth64 + 32) >> 6;
5068 }
5069
5070 previous = glyph_index;
5071 }
5072 ASSERT(FontGDI->Magic == FONTGDI_MAGIC);
5073 ascender = FontGDI->tmAscent; /* Units above baseline */
5074 descender = FontGDI->tmDescent; /* Units below baseline */
5076
5077 if (bVerticalWriting)
5078 {
5079 Size->cx = ascender + descender;
5080 Size->cy = (TotalWidth64 + 32) >> 6;
5081 }
5082 else
5083 {
5084 Size->cx = (TotalWidth64 + 32) >> 6;
5085 Size->cy = ascender + descender;
5086 }
5087
5088 return TRUE;
5089}
#define GTEF_INDICES
Definition: ntgdityp.h:213
LONG Magic
Definition: engobjects.h:165
uint64_t ULONGLONG
Definition: typedefs.h:67
LONG IntNormalizeAngle(_In_ LONG nTenthsOfDegrees)
Definition: utils.c:46

Referenced by GreGetTextExtentExW(), GreGetTextExtentW(), IntExtTextOutW(), IntGetCharDimensions(), and NtGdiGetTextExtentExW().

◆ TextIntRealizeFont()

NTSTATUS FASTCALL TextIntRealizeFont ( HFONT  FontHandle,
PTEXTOBJ  pTextObj 
)

Definition at line 5990 of file freetype.c.

5991{
5993 PTEXTOBJ TextObj;
5994 PPROCESSINFO Win32Process;
5995 ULONG MatchPenalty;
5996 LOGFONTW *pLogFont;
5997 LOGFONTW SubstitutedLogFont;
5998
6000
6001 if (!pTextObj)
6002 {
6003 TextObj = TEXTOBJ_LockText(FontHandle);
6004 if (NULL == TextObj)
6005 {
6006 return STATUS_INVALID_HANDLE;
6007 }
6008
6009 if (TextObj->fl & TEXTOBJECT_INIT)
6010 {
6011 TEXTOBJ_UnlockText(TextObj);
6012 return STATUS_SUCCESS;
6013 }
6014 }
6015 else
6016 {
6017 TextObj = pTextObj;
6018 }
6019
6020 pLogFont = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
6021
6022 /* substitute */
6023 SubstitutedLogFont = *pLogFont;
6024 SubstituteFontRecurse(&SubstitutedLogFont);
6025 DPRINT("Font '%S,%u' is substituted by '%S,%u'.\n",
6026 pLogFont->lfFaceName, pLogFont->lfCharSet,
6027 SubstitutedLogFont.lfFaceName, SubstitutedLogFont.lfCharSet);
6028
6029 MatchPenalty = 0xFFFFFFFF;
6030 TextObj->Font = NULL;
6031
6032 Win32Process = PsGetCurrentProcessWin32Process();
6033
6034 /* Search private fonts */
6036 IntLockProcessPrivateFonts(Win32Process);
6037 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
6038 &Win32Process->PrivateFontListHead);
6039 IntUnLockProcessPrivateFonts(Win32Process);
6040
6041 /* Search system fonts */
6042 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
6043 &g_FontListHead);
6045
6046 if (NULL == TextObj->Font)
6047 {
6048 DPRINT1("Request font %S not found, no fonts loaded at all\n",
6049 pLogFont->lfFaceName);
6051 }
6052 else
6053 {
6055 PFONTGDI FontGdi = ObjToGDI(TextObj->Font, FONT);
6056 PSHARED_FACE SharedFace = FontGdi->SharedFace;
6057
6058 TextObj->TextFace[0] = UNICODE_NULL;
6060 if (MatchFontNames(SharedFace, SubstitutedLogFont.lfFaceName))
6061 {
6063 RtlStringCchCopyW(TextObj->TextFace, _countof(TextObj->TextFace), pLogFont->lfFaceName);
6064 }
6065 else
6066 {
6070 if (NT_SUCCESS(Status))
6071 {
6072 /* truncated copy */
6073 IntUnicodeStringToBuffer(TextObj->TextFace, sizeof(TextObj->TextFace), &Name);
6075 }
6076 }
6077
6078 // Need hdev, when freetype is loaded need to create DEVOBJ for
6079 // Consumer and Producer.
6080 TextObj->Font->iUniq = 1; // Now it can be cached.
6081 IntFontType(FontGdi);
6082 FontGdi->flType = TextObj->Font->flFontType;
6083 FontGdi->RequestUnderline = pLogFont->lfUnderline ? 0xFF : 0;
6084 FontGdi->RequestStrikeOut = pLogFont->lfStrikeOut ? 0xFF : 0;
6085 FontGdi->RequestItalic = pLogFont->lfItalic ? 0xFF : 0;
6086 if (pLogFont->lfWeight != FW_DONTCARE)
6087 FontGdi->RequestWeight = pLogFont->lfWeight;
6088 else
6089 FontGdi->RequestWeight = FW_NORMAL;
6090
6091 TextObj->fl |= TEXTOBJECT_INIT;
6093 }
6094
6095 if (!pTextObj) TEXTOBJ_UnlockText(TextObj);
6096
6097 ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->Font)) != 0);
6098
6099 return Status;
6100}
static VOID FASTCALL IntFontType(PFONTGDI Font)
Definition: freetype.c:5830
static BOOL MatchFontNames(PSHARED_FACE SharedFace, LPCWSTR lfFaceName)
Definition: freetype.c:5885
FLONG flType
Definition: engobjects.h:142
ULONG iUniq
Definition: winddi.h:762
FLONG flFontType
Definition: winddi.h:765
FLONG fl
Definition: text.h:65
FORCEINLINE PTEXTOBJ TEXTOBJ_LockText(HFONT hfont)
Definition: text.h:83
#define TEXTOBJECT_INIT
Definition: text.h:56

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

◆ TextIntUpdateSize()

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

Definition at line 4261 of file freetype.c.

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

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

◆ UnlinkFontMemCollection()

static VOID FASTCALL UnlinkFontMemCollection ( PFONT_ENTRY_COLL_MEM  Collection)
static

Definition at line 2598 of file freetype.c.

2599{
2600 PFONT_ENTRY_MEM FontMemEntry = Collection->Entry;
2601 PLIST_ENTRY ListEntry;
2602 RemoveEntryList(&Collection->ListEntry);
2603
2604 do {
2605 /* Also unlink the FONT_ENTRY stuff from the PrivateFontListHead */
2606 RemoveEntryList(&FontMemEntry->Entry->ListEntry);
2607
2608 ListEntry = FontMemEntry->ListEntry.Flink;
2609 FontMemEntry = CONTAINING_RECORD(ListEntry, FONT_ENTRY_MEM, ListEntry);
2610
2611 } while (FontMemEntry != Collection->Entry);
2612}
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ WDFCOLLECTION Collection
Definition: wdfregistry.h:374

Referenced by IntGdiCleanupPrivateFontsForProcess(), and IntGdiRemoveFontMemResource().

Variable Documentation

◆ DosPathPrefix

const UNICODE_STRING DosPathPrefix = RTL_CONSTANT_STRING(L"\\??\\")
static

Definition at line 1995 of file freetype.c.

Referenced by IntGdiAddFontResourceSingle(), and IntGdiRemoveFontResourceSingle().

◆ g_ElfScripts

PWCHAR g_ElfScripts[32]
static
Initial value:
=
{
L"Western",
L"Central_European",
L"Cyrillic",
L"Greek",
L"Turkish",
L"Hebrew",
L"Arabic",
L"Baltic",
L"Vietnamese",
L"Thai",
L"Japanese",
L"CHINESE_GB2312",
L"Hangul",
L"CHINESE_BIG5",
L"Hangul(Johab)",
L"Symbol"
}

Definition at line 242 of file freetype.c.

Referenced by FontFamilyFillInfo().

◆ g_FontCacheNumEntries

UINT g_FontCacheNumEntries
static

Definition at line 240 of file freetype.c.

Referenced by InitFontSupport(), IntGetBitmapGlyphWithCache(), and RemoveCachedEntry().

◆ g_FontRegPath

UNICODE_STRING g_FontRegPath
Initial value:
=
RTL_CONSTANT_STRING(L"\\REGISTRY\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts")

Definition at line 209 of file freetype.c.

Referenced by IntDeleteRegFontEntries(), IntGdiAddFontResourceSingle(), and IntLoadFontsInRegistry().

◆ g_FontTci

◆ g_FreeTypeLibrary

FT_Library g_FreeTypeLibrary

◆ g_FreeTypeLock

PFAST_MUTEX g_FreeTypeLock
static

Definition at line 214 of file freetype.c.

Referenced by FreeFontSupport(), and InitFontSupport().

◆ g_RenderingEnabled

BOOL g_RenderingEnabled = TRUE
static

Definition at line 217 of file freetype.c.

Referenced by IntEnableFontRendering(), and IntIsFontRenderingEnabled().

◆ gmxWorldToDeviceDefault

const MATRIX gmxWorldToDeviceDefault
extern

Definition at line 20 of file dclife.c.

◆ gmxWorldToPageDefault

const MATRIX gmxWorldToPageDefault
extern

Definition at line 36 of file dclife.c.

Referenced by DC_vInitDc().

◆ identityMat

const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)}
static

Definition at line 201 of file freetype.c.

Referenced by ftGdiGetGlyphOutline(), IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ s_chFontLinkDefaultChar

DWORD s_chFontLinkDefaultChar = FONTLINK_DEFAULT_CHAR
static

Definition at line 61 of file freetype.c.

Referenced by FontLink_Chain_FindGlyph(), and FontLink_LoadSettings().

◆ s_fFontLinkUseAnsi

BOOL s_fFontLinkUseAnsi = FALSE
static

Definition at line 64 of file freetype.c.

Referenced by FontLink_Chain_Populate(), and FontLink_LoadDefaultCharset().

◆ s_fFontLinkUseOem

BOOL s_fFontLinkUseOem = FALSE
static

Definition at line 65 of file freetype.c.

Referenced by FontLink_Chain_Populate(), and FontLink_LoadDefaultCharset().

◆ s_fFontLinkUseSymbol

BOOL s_fFontLinkUseSymbol = FALSE
static

Definition at line 66 of file freetype.c.

Referenced by FontLink_Chain_Populate(), and FontLink_LoadDefaultCharset().

◆ s_szDefFontLinkFileName

WCHAR s_szDefFontLinkFileName[MAX_PATH] = L""
static

Definition at line 62 of file freetype.c.

Referenced by FontLink_Chain_Populate(), and FontLink_LoadDefaultFonts().

◆ s_szDefFontLinkFontName

WCHAR s_szDefFontLinkFontName[MAX_PATH] = L""
static

Definition at line 63 of file freetype.c.

Referenced by FontLink_Chain_Populate(), and FontLink_LoadDefaultFonts().

◆ s_szzDefFixedFontLink

const WCHAR s_szzDefFixedFontLink[]
static
Initial value:
=
L"cour.ttf,Courier New\0"
L"msgothic.ttc,MS Gothic\0"
L"mingliu.ttc,MingLiU\0"
L"simsun.ttc,NSimSun\0"
L"gulim.ttc,GulimChe\0"
L"\0"

Definition at line 1196 of file freetype.c.

Referenced by FontLink_Chain_FindEntry().

◆ s_szzDefFontLink

const WCHAR s_szzDefFontLink[]
static
Initial value:
=
L"tahoma.ttf,Tahoma\0"
L"msgothic.ttc,MS UI Gothic\0"
L"mingliu.ttc,PMingLiU\0"
L"simsun.ttc,SimSun\0"
L"gulim.ttc,Gulim\0"
L"\0"

Definition at line 1188 of file freetype.c.

Referenced by FontLink_Chain_FindEntry().