ReactOS 0.4.15-dev-8636-g945e856
freetype.c File Reference
#include <win32k.h>
#include <gdi/eng/floatobj.h>
#include "font.h"
#include <debug.h>
Include dependency graph for freetype.c:

Go to the source code of this file.

Classes

struct  _FONTLINK
 
struct  _FONTLINK_CHAIN
 
struct  _FONTLINK_CACHE
 
struct  FONT_NAMES
 

Macros

#define FT_INTERNAL_INTERNAL_H   <freetype/internal/internal.h>
 
#define NDEBUG
 
#define FONTLINK_DEFAULT_CHAR   0x30FB
 
#define MAX_FONTLINK_CACHE   128
 
#define HIGH_SURROGATE_MIN   0xD800U
 
#define HIGH_SURROGATE_MAX   0xDBFFU
 
#define LOW_SURROGATE_MIN   0xDC00U
 
#define LOW_SURROGATE_MAX   0xDFFFU
 
#define IS_HIGH_SURROGATE(ch0)   (HIGH_SURROGATE_MIN <= (ch0) && (ch0) <= HIGH_SURROGATE_MAX)
 
#define IS_LOW_SURROGATE(ch1)   (LOW_SURROGATE_MIN <= (ch1) && (ch1) <= LOW_SURROGATE_MAX)
 
#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 PX2PT(pixels)   FT_MulDiv((pixels), 72, 96)
 
#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_CHAIN FONTLINK_CHAIN
 
typedef struct _FONTLINK_CHAINPFONTLINK_CHAIN
 
typedef struct _FONTLINK_CACHE FONTLINK_CACHE
 
typedef struct _FONTLINK_CACHEPFONTLINK_CACHE
 
typedef struct FONT_NAMES FONT_NAMES
 
typedef struct FONT_NAMESLPFONT_NAMES
 

Functions

static RTL_STATIC_LIST_HEAD (g_FontLinkCache)
 
static SIZE_T SZZ_GetSize (_In_ PCZZWSTR pszz)
 
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 VOID FontLink_Chain_Free (_Inout_ PFONTLINK_CHAIN pChain)
 
static VOID FontLink_AddCache (_In_ PFONTLINK_CACHE pCache)
 
static VOID IntRebaseList (_Inout_ PLIST_ENTRY pNewHead, _Inout_ PLIST_ENTRY pOldHead)
 
static VOID FontLink_Chain_Finish (_Inout_ PFONTLINK_CHAIN pChain)
 
static PFONTLINK_CACHE FontLink_FindCache (_In_ const LOGFONTW *pLogFont)
 
static VOID FontLink_CleanupCache (VOID)
 
static DWORD Utf32FromSurrogatePair (DWORD ch0, DWORD ch1)
 
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)
 
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)
 
BOOL FASTCALL InitFontSupport (VOID)
 
VOID FASTCALL FreeFontSupport (VOID)
 
static LONG IntNormalizeAngle (LONG nTenthsOfDegrees)
 
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 VOID IntUnicodeStringToBuffer (LPWSTR pszBuffer, SIZE_T cbBuffer, const UNICODE_STRING *pString)
 
static NTSTATUS DuplicateUnicodeString (PUNICODE_STRING Source, PUNICODE_STRING Destination)
 
static BOOL SubstituteFontRecurse (PLOGFONTW pLogFont)
 
static VOID FontLink_Chain_Init (_Out_ PFONTLINK_CHAIN pChain, _Inout_ PTEXTOBJ pTextObj, _In_ FT_Face face)
 
static NTSTATUS FontLink_Chain_LoadReg (_Inout_ PFONTLINK_CHAIN pChain, _Inout_ PLOGFONTW pLF)
 
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 NTSTATUS FontLink_Chain_Populate (_Inout_ PFONTLINK_CHAIN pChain)
 
VOID FASTCALL IntLoadSystemFonts (VOID)
 
UINT FASTCALL IntGetCharSet (INT nIndex, FT_ULong CodePageRange1)
 
static INT FASTCALL IntGdiLoadFontsFromMemory (PGDI_LOAD_FONT pLoadFont, PSHARED_FACE SharedFace, FT_Long FontIndex, INT CharSetIndex)
 
static LPCWSTR FASTCALL NameFromCharSet (BYTE CharSet)
 
INT FASTCALL IntGdiAddFontResourceEx (PUNICODE_STRING FileName, DWORD Characteristics, DWORD dwFlags)
 
INT FASTCALL IntGdiAddFontResource (PUNICODE_STRING FileName, DWORD Characteristics)
 
BOOL WINAPI PathIsRelativeW (LPCWSTR lpszPath)
 
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 __inline SIZE_T FASTCALL IntStoreName (const UNICODE_STRING *pName, BYTE *pb)
 
static __inline BYTE *FASTCALL IntStoreFontNames (const FONT_NAMES *Names, OUTLINETEXTMETRICW *Otm)
 
static __inline void FASTCALL IntFreeFontNames (FONT_NAMES *Names)
 
INT FASTCALL IntGetOutlineTextMetrics (PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm, BOOL bLocked)
 
static BYTE CharSetFromLangID (LANGID LangID)
 
static void SwapEndian (LPVOID pvData, DWORD Size)
 
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 IntRequestFontSize (PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
 
BOOL FASTCALL TextIntUpdateSize (PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, 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 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, LPMAT2 pmat2, BOOL bIgnoreRotation)
 
static FT_BitmapGlyph IntGetRealGlyph (IN OUT PFONT_CACHE_ENTRY Cache)
 
BOOL FASTCALL TextIntGetTextExtentPoint (PDC dc, PTEXTOBJ TextObj, LPCWSTR String, INT Count, ULONG MaxExtent, LPINT Fit, LPINT Dx, LPSIZE Size, 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)
 
NTSTATUS FASTCALL TextIntRealizeFont (HFONT FontHandle, PTEXTOBJ pTextObj)
 
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)
 
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 (HDC Dc, const LOGFONTW *UnsafeLogFont, PFONTFAMILYINFO UnsafeInfo, LPLONG UnsafeInfoCount)
 
static LONG ScaleLong (LONG lValue, PFLOATOBJ pef)
 
static BOOL IntGetTextDisposition (OUT LONGLONG *pX64, OUT LONGLONG *pY64, IN LPCWSTR String, IN INT Count, IN OPTIONAL LPINT Dx, IN OUT PFONT_CACHE_ENTRY Cache, IN UINT fuOptions, IN BOOL bNoTransform, IN OUT PFONTLINK_CHAIN pChain)
 
VOID APIENTRY IntEngFillPolygon (IN OUT PDC dc, IN POINTL *pPoints, IN UINT cPoints, IN BRUSHOBJ *BrushObj)
 
VOID FASTCALL IntEngFillBox (IN OUT PDC dc, IN INT X, IN INT Y, IN INT Width, IN INT Height, IN BRUSHOBJ *BrushObj)
 
BOOL APIENTRY IntExtTextOutW (IN PDC dc, IN INT XStart, IN INT YStart, IN UINT fuOptions, IN OPTIONAL PRECTL lprc, IN LPCWSTR String, IN INT Count, IN OPTIONAL LPINT Dx, IN DWORD dwCodePage)
 
BOOL APIENTRY GreExtTextOutW (IN HDC hDC, IN INT XStart, IN INT YStart, IN UINT fuOptions, IN OPTIONAL PRECTL lprc, IN LPCWSTR String, IN INT Count, IN OPTIONAL LPINT Dx, IN DWORD dwCodePage)
 
BOOL APIENTRY NtGdiExtTextOutW (IN HDC hDC, IN INT XStart, IN INT YStart, IN UINT fuOptions, IN OPTIONAL LPRECT UnsafeRect, IN LPWSTR UnsafeString, IN INT Count, IN OPTIONAL LPINT UnsafeDx, IN DWORD dwCodePage)
 
BOOL APIENTRY NtGdiGetCharABCWidthsW (IN HDC hDC, IN UINT FirstChar, IN ULONG Count, IN OPTIONAL PWCHAR UnSafepwch, IN FLONG fl, OUT PVOID Buffer)
 
BOOL APIENTRY NtGdiGetCharWidthW (IN HDC hDC, IN UINT FirstChar, IN UINT Count, IN OPTIONAL PWCHAR UnSafepwc, IN FLONG fl, OUT PVOID Buffer)
 
__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetGlyphIndicesW (_In_ HDC hdc, _In_reads_opt_(cwc) LPCWSTR pwc, _In_ INT cwc, _Out_writes_opt_(cwc) LPWORD pgi, _In_ DWORD iMode)
 

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
 
static LONG g_nFontLinkCacheCount = 0
 
const MATRIX gmxWorldToDeviceDefault
 
const MATRIX gmxWorldToPageDefault
 
static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)}
 
static POINTL PointZero = { 0, 0 }
 
FT_Library g_FreeTypeLibrary
 
static 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 []
 

Macro Definition Documentation

◆ _TMPF_VARIABLE_PITCH

#define _TMPF_VARIABLE_PITCH   TMPF_FIXED_PITCH

Definition at line 344 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_HELD

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

Definition at line 373 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_NOT_HELD

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

Definition at line 376 of file freetype.c.

◆ CP_MACCP

#define CP_MACCP   2

Definition at line 467 of file freetype.c.

◆ CP_OEMCP

#define CP_OEMCP   1

Definition at line 466 of file freetype.c.

◆ CP_SYMBOL

#define CP_SYMBOL   42

Definition at line 422 of file freetype.c.

◆ EMUBOLD_NEEDED

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

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

◆ FT_INTERNAL_INTERNAL_H

#define FT_INTERNAL_INTERNAL_H   <freetype/internal/internal.h>

Includes

Definition at line 27 of file freetype.c.

◆ gmxWorldToDeviceDefault

#define gmxWorldToDeviceDefault   gmxWorldToPageDefault

Definition at line 357 of file freetype.c.

◆ GOT_PENALTY

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

Definition at line 5402 of file freetype.c.

◆ HIGH_SURROGATE_MAX

#define HIGH_SURROGATE_MAX   0xDBFFU

Definition at line 329 of file freetype.c.

◆ HIGH_SURROGATE_MIN

#define HIGH_SURROGATE_MIN   0xD800U

Definition at line 328 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:368

Definition at line 379 of file freetype.c.

◆ IntUnLockFreeType

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

Definition at line 385 of file freetype.c.

◆ IS_HIGH_SURROGATE

#define IS_HIGH_SURROGATE (   ch0)    (HIGH_SURROGATE_MIN <= (ch0) && (ch0) <= HIGH_SURROGATE_MAX)

Definition at line 333 of file freetype.c.

◆ IS_LOW_SURROGATE

#define IS_LOW_SURROGATE (   ch1)    (LOW_SURROGATE_MIN <= (ch1) && (ch1) <= LOW_SURROGATE_MAX)

Definition at line 334 of file freetype.c.

◆ LOW_SURROGATE_MAX

#define LOW_SURROGATE_MAX   0xDFFFU

Definition at line 331 of file freetype.c.

◆ LOW_SURROGATE_MIN

#define LOW_SURROGATE_MIN   0xDC00U

Definition at line 330 of file freetype.c.

◆ MAX_FONT_CACHE

#define MAX_FONT_CACHE   256

Definition at line 391 of file freetype.c.

◆ MAX_FONTLINK_CACHE

#define MAX_FONTLINK_CACHE   128

Definition at line 71 of file freetype.c.

◆ MAXTCIINDEX

#define MAXTCIINDEX   32

Definition at line 423 of file freetype.c.

◆ NDEBUG

#define NDEBUG

Definition at line 35 of file freetype.c.

◆ PX2PT

#define PX2PT (   pixels)    FT_MulDiv((pixels), 72, 96)

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

◆ VALIGN_MASK

#define VALIGN_MASK   (TA_TOP | TA_BASELINE | TA_BOTTOM)

Typedef Documentation

◆ FONT_NAMES

◆ FONTLINK

◆ FONTLINK_CACHE

◆ FONTLINK_CHAIN

◆ LPFONT_NAMES

◆ PFONTLINK

◆ PFONTLINK_CACHE

◆ PFONTLINK_CHAIN

Function Documentation

◆ CharSetFromLangID()

static BYTE CharSetFromLangID ( LANGID  LangID)
static

Definition at line 3236 of file freetype.c.

3237{
3238 /* FIXME: Add more and fix if wrong */
3239 switch (PRIMARYLANGID(LangID))
3240 {
3241 case LANG_CHINESE:
3242 switch (SUBLANGID(LangID))
3243 {
3245 return CHINESEBIG5_CHARSET;
3247 default:
3248 break;
3249 }
3250 return GB2312_CHARSET;
3251
3252 case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
3253 case LANG_SLOVAK: case LANG_SLOVENIAN: case LANG_ROMANIAN:
3254 return EASTEUROPE_CHARSET;
3255
3257 case LANG_SERBIAN: case LANG_UKRAINIAN:
3258 return RUSSIAN_CHARSET;
3259
3260 case LANG_ARABIC: return ARABIC_CHARSET;
3261 case LANG_GREEK: return GREEK_CHARSET;
3262 case LANG_HEBREW: return HEBREW_CHARSET;
3263 case LANG_JAPANESE: return SHIFTJIS_CHARSET;
3264 case LANG_KOREAN: return JOHAB_CHARSET;
3265 case LANG_TURKISH: return TURKISH_CHARSET;
3266 case LANG_THAI: return THAI_CHARSET;
3267 case LANG_LATVIAN: return BALTIC_CHARSET;
3269
3270 case LANG_ENGLISH: case LANG_BASQUE: case LANG_CATALAN:
3271 case LANG_DANISH: case LANG_DUTCH: case LANG_FINNISH:
3272 case LANG_FRENCH: case LANG_GERMAN: case LANG_ITALIAN:
3274 case LANG_SWEDISH: default:
3275 return ANSI_CHARSET;
3276 }
3277}
#define LANG_THAI
Definition: nls.h:132
#define LANG_NORWEGIAN
Definition: nls.h:102
#define SUBLANGID(l)
Definition: nls.h:17
#define LANG_TURKISH
Definition: nls.h:136
#define LANG_DANISH
Definition: nls.h:48
#define LANG_SPANISH
Definition: nls.h:123
#define LANG_POLISH
Definition: nls.h:107
#define LANG_GERMAN
Definition: nls.h:62
#define LANG_HEBREW
Definition: nls.h:67
#define LANG_UKRAINIAN
Definition: nls.h:139
#define LANG_BULGARIAN
Definition: nls.h:40
#define LANG_FINNISH
Definition: nls.h:57
#define LANG_GREEK
Definition: nls.h:63
#define LANG_BASQUE
Definition: nls.h:34
#define LANG_MACEDONIAN
Definition: nls.h:91
#define LANG_ENGLISH
Definition: nls.h:52
#define LANG_ROMANIAN
Definition: nls.h:111
#define SUBLANG_CHINESE_TRADITIONAL
Definition: nls.h:208
#define LANG_DUTCH
Definition: nls.h:51
#define SUBLANG_CHINESE_SIMPLIFIED
Definition: nls.h:209
#define LANG_RUSSIAN
Definition: nls.h:113
#define LANG_VIETNAMESE
Definition: nls.h:143
#define LANG_CZECH
Definition: nls.h:47
#define LANG_HUNGARIAN
Definition: nls.h:69
#define LANG_SWEDISH
Definition: nls.h:125
#define LANG_ARABIC
Definition: nls.h:29
#define LANG_CHINESE
Definition: nls.h:42
#define LANG_SERBIAN
Definition: nls.h:116
#define LANG_JAPANESE
Definition: nls.h:76
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LANG_LATVIAN
Definition: nls.h:87
#define LANG_SLOVAK
Definition: nls.h:120
#define LANG_KOREAN
Definition: nls.h:84
#define LANG_SLOVENIAN
Definition: nls.h:121
#define LANG_FRENCH
Definition: nls.h:58
#define LANG_ITALIAN
Definition: nls.h:75
#define LANG_PORTUGUESE
Definition: nls.h:108
#define LANG_CATALAN
Definition: nls.h:41
_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
#define RUSSIAN_CHARSET
Definition: wingdi.h:396
#define ARABIC_CHARSET
Definition: wingdi.h:394
#define THAI_CHARSET
Definition: wingdi.h:397
#define GREEK_CHARSET
Definition: wingdi.h:391
#define JOHAB_CHARSET
Definition: wingdi.h:401
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:390
#define ANSI_CHARSET
Definition: wingdi.h:383
#define VIETNAMESE_CHARSET
Definition: wingdi.h:402
#define HEBREW_CHARSET
Definition: wingdi.h:393
#define SHIFTJIS_CHARSET
Definition: wingdi.h:386
#define EASTEUROPE_CHARSET
Definition: wingdi.h:399
#define GB2312_CHARSET
Definition: wingdi.h:389
#define BALTIC_CHARSET
Definition: wingdi.h:395
#define TURKISH_CHARSET
Definition: wingdi.h:392

Referenced by GetFontPenalty().

◆ CleanupFontEntry()

static __inline VOID FASTCALL CleanupFontEntry ( PFONT_ENTRY  FontEntry)
static

Definition at line 721 of file freetype.c.

722{
723 CleanupFontEntryEx(FontEntry, FontEntry->Font);
724}
static VOID FASTCALL CleanupFontEntryEx(PFONT_ENTRY FontEntry, PFONTGDI FontGDI)
Definition: freetype.c:701
FONTGDI * Font
Definition: font.h:7

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

◆ CleanupFontEntryEx()

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

Definition at line 701 of file freetype.c.

702{
703 // PFONTGDI FontGDI = FontEntry->Font;
704 PSHARED_FACE SharedFace = FontGDI->SharedFace;
705
706 if (FontGDI->Filename)
708
709 if (FontEntry->StyleName.Buffer)
710 RtlFreeUnicodeString(&FontEntry->StyleName);
711
712 if (FontEntry->FaceName.Buffer)
713 RtlFreeUnicodeString(&FontEntry->FaceName);
714
715 EngFreeMem(FontGDI);
716 SharedFace_Release(SharedFace);
717 ExFreePoolWithTag(FontEntry, TAG_FONT);
718}
static void SharedFace_Release(PSHARED_FACE Ptr)
Definition: freetype.c:677
#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().

◆ DuplicateUnicodeString()

static NTSTATUS DuplicateUnicodeString ( PUNICODE_STRING  Source,
PUNICODE_STRING  Destination 
)
static

Definition at line 1235 of file freetype.c.

1236{
1238 UNICODE_STRING Tmp;
1239
1240 Tmp.Buffer = ExAllocatePoolWithTag(PagedPool, Source->MaximumLength, TAG_USTR);
1241 if (Tmp.Buffer)
1242 {
1243 Tmp.MaximumLength = Source->MaximumLength;
1244 Tmp.Length = 0;
1246
1248 Destination->Length = Tmp.Length;
1249 Destination->Buffer = Tmp.Buffer;
1250
1252 }
1253
1254 return Status;
1255}
LONG NTSTATUS
Definition: precomp.h:26
#define TAG_USTR
Definition: libsupp.c:997
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3016
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT MaximumLength
Definition: env_spec_w32.h:370

Referenced by IntGdiAddFontResourceEx(), and IntGetFontLocalizedName().

◆ EqualFamilyInfo()

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

Definition at line 6061 of file freetype.c.

6062{
6063 const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
6064 const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
6065 const LOGFONTW *plf1 = &pLog1->elfLogFont;
6066 const LOGFONTW *plf2 = &pLog2->elfLogFont;
6067
6068 if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
6069 {
6070 return FALSE;
6071 }
6072
6073 if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
6074 {
6075 return FALSE;
6076 }
6077
6078 return TRUE;
6079}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:2704
LOGFONTW elfLogFont
Definition: wingdi.h:2702
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 2757 of file freetype.c.

2758{
2759 int i;
2760
2761 for(i = 0; i < ft_face->num_charmaps; i++)
2762 {
2763 if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
2764 ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
2765 {
2766 return TRUE;
2767 }
2768 }
2769 return FALSE;
2770}
#define TT_PLATFORM_MICROSOFT
Definition: font.c:1174
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:843
FT_UShort platform_id
Definition: freetype.h:844
FT_Int num_charmaps
Definition: freetype.h:1084
FT_CharMap * charmaps
Definition: freetype.h:1085

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

2776{
2777 FT_Fixed XScale, YScale;
2778 int Ascent, Descent;
2779 FT_Face Face = FontGDI->SharedFace->Face;
2780
2782
2783 XScale = Face->size->metrics.x_scale;
2784 YScale = Face->size->metrics.y_scale;
2785
2786 if (pFNT)
2787 {
2788 TM->tmHeight = pFNT->pixel_height;
2789 TM->tmAscent = pFNT->ascent;
2790 TM->tmDescent = TM->tmHeight - TM->tmAscent;
2793 TM->tmAveCharWidth = pFNT->avg_width;
2794 TM->tmMaxCharWidth = pFNT->max_width;
2795 TM->tmOverhang = 0;
2798 TM->tmFirstChar = pFNT->first_char;
2799 TM->tmLastChar = pFNT->last_char;
2800 TM->tmDefaultChar = pFNT->default_char + pFNT->first_char;
2801 TM->tmBreakChar = pFNT->break_char + pFNT->first_char;
2803 TM->tmWeight = FontGDI->RequestWeight;
2804 TM->tmItalic = FontGDI->RequestItalic;
2805 TM->tmUnderlined = FontGDI->RequestUnderline;
2806 TM->tmStruckOut = FontGDI->RequestStrikeOut;
2807 TM->tmCharSet = FontGDI->CharSet;
2808 return;
2809 }
2810
2811 ASSERT(pOS2);
2812 if (!pOS2)
2813 return;
2814
2815 if ((FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent == 0)
2816 {
2817 Ascent = pHori->Ascender;
2818 Descent = -pHori->Descender;
2819 }
2820 else
2821 {
2822 Ascent = (FT_Short)pOS2->usWinAscent;
2823 Descent = (FT_Short)pOS2->usWinDescent;
2824 }
2825
2826 TM->tmAscent = FontGDI->tmAscent;
2827 TM->tmDescent = FontGDI->tmDescent;
2828 TM->tmHeight = TM->tmAscent + TM->tmDescent;
2829 TM->tmInternalLeading = FontGDI->tmInternalLeading;
2830
2831 /* MSDN says:
2832 * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
2833 */
2834 TM->tmExternalLeading = max(0, (FT_MulFix(pHori->Line_Gap
2835 - ((Ascent + Descent)
2836 - (pHori->Ascender - pHori->Descender)),
2837 YScale) + 32) >> 6);
2838 if (FontGDI->lfWidth != 0)
2839 TM->tmAveCharWidth = FontGDI->lfWidth;
2840 else
2841 TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
2842
2843 if (TM->tmAveCharWidth == 0)
2844 TM->tmAveCharWidth = 1;
2845
2846 /* Correct forumla to get the maxcharwidth from unicode and ansi font */
2847 TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
2848
2849 if (FontGDI->OriginalWeight != FW_DONTCARE &&
2850 FontGDI->OriginalWeight != FW_NORMAL)
2851 {
2852 TM->tmWeight = FontGDI->OriginalWeight;
2853 }
2854 else
2855 {
2856 TM->tmWeight = FontGDI->RequestWeight;
2857 }
2858
2859 TM->tmOverhang = 0;
2860 TM->tmDigitizedAspectX = 96;
2861 TM->tmDigitizedAspectY = 96;
2862 if (face_has_symbol_charmap(Face) ||
2863 (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
2864 {
2865 USHORT cpOEM, cpAnsi;
2866
2867 EngGetCurrentCodePage(&cpOEM, &cpAnsi);
2868 TM->tmFirstChar = 0;
2869 switch(cpAnsi)
2870 {
2871 case 1257: /* Baltic */
2872 TM->tmLastChar = 0xf8fd;
2873 break;
2874 default:
2875 TM->tmLastChar = 0xf0ff;
2876 }
2877 TM->tmBreakChar = 0x20;
2878 TM->tmDefaultChar = 0x1f;
2879 }
2880 else
2881 {
2882 TM->tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
2883 TM->tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
2884
2885 if(pOS2->usFirstCharIndex <= 1)
2886 TM->tmBreakChar = pOS2->usFirstCharIndex + 2;
2887 else if (pOS2->usFirstCharIndex > 0xff)
2888 TM->tmBreakChar = 0x20;
2889 else
2890 TM->tmBreakChar = pOS2->usFirstCharIndex;
2891 TM->tmDefaultChar = TM->tmBreakChar - 1;
2892 }
2893
2894 if (FontGDI->OriginalItalic || FontGDI->RequestItalic)
2895 {
2896 TM->tmItalic = 0xFF;
2897 }
2898 else
2899 {
2900 TM->tmItalic = 0;
2901 }
2902 TM->tmUnderlined = (FontGDI->RequestUnderline ? 0xFF : 0);
2903 TM->tmStruckOut = (FontGDI->RequestStrikeOut ? 0xFF : 0);
2904
2905 if (!FT_IS_FIXED_WIDTH(Face))
2906 {
2907 switch (pOS2->panose[PAN_PROPORTION_INDEX])
2908 {
2910 TM->tmPitchAndFamily = 0;
2911 break;
2912 default:
2914 break;
2915 }
2916 }
2917 else
2918 {
2919 TM->tmPitchAndFamily = 0;
2920 }
2921
2922 switch (pOS2->panose[PAN_FAMILYTYPE_INDEX])
2923 {
2924 case PAN_FAMILY_SCRIPT:
2926 break;
2929 break;
2930
2931 case PAN_ANY:
2932 case PAN_NO_FIT:
2934 case PAN_FAMILY_PICTORIAL: /* Symbol fonts get treated as if they were text */
2935 /* Which is clearly not what the panose spec says. */
2936 if (TM->tmPitchAndFamily == 0) /* Fixed */
2937 {
2939 }
2940 else
2941 {
2942 switch (pOS2->panose[PAN_SERIFSTYLE_INDEX])
2943 {
2944 case PAN_ANY:
2945 case PAN_NO_FIT:
2946 default:
2948 break;
2949
2950 case PAN_SERIF_COVE:
2954 case PAN_SERIF_SQUARE:
2955 case PAN_SERIF_THIN:
2956 case PAN_SERIF_BONE:
2958 case PAN_SERIF_TRIANGLE:
2960 break;
2961
2965 case PAN_SERIF_FLARED:
2966 case PAN_SERIF_ROUNDED:
2968 break;
2969 }
2970 }
2971 break;
2972 default:
2974 }
2975
2976 if (FT_IS_SCALABLE(Face))
2977 {
2979 }
2980 if (FT_IS_SFNT(Face))
2981 {
2983 }
2984
2985 TM->tmCharSet = FontGDI->CharSet;
2986}
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2757
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:373
#define _TMPF_VARIABLE_PITCH
Definition: freetype.c:344
#define FT_IS_SFNT(face)
Definition: freetype.h:1331
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312
#define FT_IS_FIXED_WIDTH(face)
Definition: freetype.h:1346
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
signed long FT_Fixed
Definition: fttypes.h:288
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:1106
FT_Short max_advance_width
Definition: freetype.h:1099
FT_Size_Metrics metrics
Definition: freetype.h:1677
FT_Fixed y_scale
Definition: freetype.h:1644
FT_Fixed x_scale
Definition: freetype.h:1643
FT_UShort horizontal_resolution
Definition: ftwinfnt.h:192
FT_Byte pitch_and_family
Definition: ftwinfnt.h:203
FT_Byte default_char
Definition: ftwinfnt.h:208
FT_UShort internal_leading
Definition: ftwinfnt.h:194
FT_UShort avg_width
Definition: ftwinfnt.h:204
FT_UShort external_leading
Definition: ftwinfnt.h:195
FT_UShort ascent
Definition: ftwinfnt.h:193
FT_UShort max_width
Definition: ftwinfnt.h:205
FT_UShort pixel_height
Definition: ftwinfnt.h:202
FT_UShort vertical_resolution
Definition: ftwinfnt.h:191
FT_Short Line_Gap
Definition: tttables.h:204
FT_Short Ascender
Definition: tttables.h:202
FT_Short Descender
Definition: tttables.h:203
FT_UShort usLastCharIndex
Definition: tttables.h:410
FT_Byte panose[10]
Definition: tttables.h:399
FT_UShort usWinDescent
Definition: tttables.h:415
FT_UShort usWinAscent
Definition: tttables.h:414
FT_Short xAvgCharWidth
Definition: tttables.h:383
FT_UShort usFirstCharIndex
Definition: tttables.h:409
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:2394
LONG tmDigitizedAspectX
Definition: wingdi.h:2392
LONG tmDigitizedAspectY
Definition: wingdi.h:2393
LONG tmOverhang
Definition: wingdi.h:2391
LONG tmAveCharWidth
Definition: wingdi.h:2388
LONG tmAscent
Definition: wingdi.h:2384
LONG tmMaxCharWidth
Definition: wingdi.h:2389
BYTE tmItalic
Definition: wingdi.h:2398
BYTE tmStruckOut
Definition: wingdi.h:2400
LONG tmInternalLeading
Definition: wingdi.h:2386
BYTE tmUnderlined
Definition: wingdi.h:2399
LONG tmExternalLeading
Definition: wingdi.h:2387
BYTE tmPitchAndFamily
Definition: wingdi.h:2401
LONG tmWeight
Definition: wingdi.h:2390
WCHAR tmBreakChar
Definition: wingdi.h:2397
WCHAR tmDefaultChar
Definition: wingdi.h:2396
BYTE tmCharSet
Definition: wingdi.h:2402
WCHAR tmLastChar
Definition: wingdi.h:2395
LONG tmHeight
Definition: wingdi.h:2383
LONG tmDescent
Definition: wingdi.h:2385
#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 FW_NORMAL
Definition: wingdi.h:373
#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 5752 of file freetype.c.

5755{
5756 ULONG Penalty;
5758 PFONT_ENTRY CurrentEntry;
5759 FONTGDI *FontGDI;
5760 OUTLINETEXTMETRICW *Otm = NULL;
5761 UINT OtmSize, OldOtmSize = 0;
5762 FT_Face Face;
5763
5764 ASSERT(FontObj);
5765 ASSERT(MatchPenalty);
5766 ASSERT(LogFont);
5767 ASSERT(Head);
5768
5769 /* Start with a pretty big buffer */
5770 OldOtmSize = 0x200;
5771 Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5772
5773 /* get the FontObj of lowest penalty */
5774 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5775 {
5776 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5777
5778 FontGDI = CurrentEntry->Font;
5779 ASSERT(FontGDI);
5780 Face = FontGDI->SharedFace->Face;
5781
5782 /* get text metrics */
5784 OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL, TRUE);
5785 if (OtmSize > OldOtmSize)
5786 {
5787 if (Otm)
5790 }
5791
5792 /* update FontObj if lowest penalty */
5793 if (Otm)
5794 {
5796 IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5797
5799 OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm, TRUE);
5800 if (!OtmSize)
5801 continue;
5802
5803 OldOtmSize = OtmSize;
5804
5805 Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5806 if (*MatchPenalty == MAXULONG || Penalty < *MatchPenalty)
5807 {
5808 *FontObj = GDIToObj(FontGDI, FONT);
5809 *MatchPenalty = Penalty;
5810 }
5811 }
5812 }
5813
5814 if (Otm)
5816}
#define NULL
Definition: types.h:112
#define GDIToObj(ClipGDI, Type)
Definition: engobjects.h:185
static UINT GetFontPenalty(const LOGFONTW *LogFont, const OUTLINETEXTMETRICW *Otm, const char *style_name)
Definition: freetype.c:5406
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:4087
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm, BOOL bLocked)
Definition: freetype.c:3075
unsigned int UINT
Definition: ndis.h:50
base of all file and directory entries
Definition: entries.h:83
FT_String * style_name
Definition: freetype.h:1079
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 3450 of file freetype.c.

3452{
3453 ANSI_STRING StyleA;
3454 UNICODE_STRING StyleW;
3455 TT_OS2 *pOS2;
3457 CHARSETINFO CharSetInfo;
3458 unsigned i, Size;
3459 OUTLINETEXTMETRICW *Otm;
3460 LOGFONTW *Lf;
3461 TEXTMETRICW *TM;
3462 NEWTEXTMETRICW *Ntm;
3463 DWORD fs0;
3465 PSHARED_FACE SharedFace = FontGDI->SharedFace;
3466 FT_Face Face = SharedFace->Face;
3467 UNICODE_STRING NameW;
3468
3469 RtlInitUnicodeString(&NameW, NULL);
3472 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL, TRUE);
3474 if (!Otm)
3475 {
3476 return;
3477 }
3479 Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm, TRUE);
3480 if (!Size)
3481 {
3483 return;
3484 }
3485
3486 Lf = &Info->EnumLogFontEx.elfLogFont;
3487 TM = &Otm->otmTextMetrics;
3488
3489 Lf->lfHeight = TM->tmHeight;
3490 Lf->lfWidth = TM->tmAveCharWidth;
3491 Lf->lfWeight = TM->tmWeight;
3492 Lf->lfItalic = TM->tmItalic;
3493 Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
3494 Lf->lfCharSet = TM->tmCharSet;
3498
3499 Ntm = &Info->NewTextMetricEx.ntmTm;
3500 Ntm->tmHeight = TM->tmHeight;
3501 Ntm->tmAscent = TM->tmAscent;
3502 Ntm->tmDescent = TM->tmDescent;
3505 Ntm->tmAveCharWidth = TM->tmAveCharWidth;
3506 Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
3507 Ntm->tmWeight = TM->tmWeight;
3508 Ntm->tmOverhang = TM->tmOverhang;
3511 Ntm->tmFirstChar = TM->tmFirstChar;
3512 Ntm->tmLastChar = TM->tmLastChar;
3513 Ntm->tmDefaultChar = TM->tmDefaultChar;
3514 Ntm->tmBreakChar = TM->tmBreakChar;
3515 Ntm->tmItalic = TM->tmItalic;
3516 Ntm->tmUnderlined = TM->tmUnderlined;
3517 Ntm->tmStruckOut = TM->tmStruckOut;
3519 Ntm->tmCharSet = TM->tmCharSet;
3520 Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
3521
3522 if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
3523
3524 if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
3525
3526 Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
3527 ? TRUETYPE_FONTTYPE : 0);
3528
3529 if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
3530 Info->FontType |= RASTER_FONTTYPE;
3531
3532
3533 /* face name */
3534 if (!FaceName)
3535 FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
3536
3537 RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
3538
3539 /* full name */
3540 if (!FullName)
3541 FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
3542
3543 RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
3544 sizeof(Info->EnumLogFontEx.elfFullName),
3545 FullName);
3546
3547 RtlInitAnsiString(&StyleA, Face->style_name);
3548 StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
3549 StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
3550 status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
3551 if (!NT_SUCCESS(status))
3552 {
3554 return;
3555 }
3556 Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
3557
3558 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
3559
3560 if (!pOS2)
3561 {
3563 return;
3564 }
3565
3566 Ntm->ntmSizeEM = Otm->otmEMSquare;
3568 Ntm->ntmAvgWidth = 0;
3569
3571
3572 fs.fsCsb[0] = pOS2->ulCodePageRange1;
3573 fs.fsCsb[1] = pOS2->ulCodePageRange2;
3574 fs.fsUsb[0] = pOS2->ulUnicodeRange1;
3575 fs.fsUsb[1] = pOS2->ulUnicodeRange2;
3576 fs.fsUsb[2] = pOS2->ulUnicodeRange3;
3577 fs.fsUsb[3] = pOS2->ulUnicodeRange4;
3578
3579 if (0 == pOS2->version)
3580 {
3581 FT_UInt Dummy;
3582
3583 if (FT_Get_First_Char(Face, &Dummy) < 0x100)
3584 fs.fsCsb[0] |= FS_LATIN1;
3585 else
3586 fs.fsCsb[0] |= FS_SYMBOL;
3587 }
3588
3589 if (fs.fsCsb[0] == 0)
3590 {
3591 /* Let's see if we can find any interesting cmaps */
3592 for (i = 0; i < (UINT)Face->num_charmaps; i++)
3593 {
3594 switch (Face->charmaps[i]->encoding)
3595 {
3596 case FT_ENCODING_UNICODE:
3597 case FT_ENCODING_APPLE_ROMAN:
3598 fs.fsCsb[0] |= FS_LATIN1;
3599 break;
3600 case FT_ENCODING_MS_SYMBOL:
3601 fs.fsCsb[0] |= FS_SYMBOL;
3602 break;
3603 default:
3604 break;
3605 }
3606 }
3607 }
3608
3609 for (i = 0; i < MAXTCIINDEX; i++)
3610 {
3611 fs0 = 1L << i;
3612 if (fs.fsCsb[0] & fs0)
3613 {
3614 if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
3615 {
3616 CharSetInfo.ciCharset = DEFAULT_CHARSET;
3617 }
3618 if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
3619 {
3620 if (g_ElfScripts[i])
3621 wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
3622 else
3623 {
3624 DPRINT1("Unknown elfscript for bit %u\n", i);
3625 }
3626 }
3627 }
3628 }
3629 Info->NewTextMetricEx.ntmFontSig = fs;
3630}
#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:396
#define MAXTCIINDEX
Definition: freetype.c:423
static BOOLEAN IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2710
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
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
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
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:382
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
FT_ULong ulCodePageRange1
Definition: tttables.h:419
FT_ULong ulUnicodeRange3
Definition: tttables.h:403
FT_ULong ulUnicodeRange2
Definition: tttables.h:402
FT_ULong ulCodePageRange2
Definition: tttables.h:420
FT_ULong ulUnicodeRange4
Definition: tttables.h:404
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2514
Definition: ffs.h:70
Definition: ps.c:97
UINT ciCharset
Definition: wingdi.h:1546
UINT ntmCellHeight
Definition: wingdi.h:2666
WCHAR tmFirstChar
Definition: wingdi.h:2655
LONG tmDigitizedAspectX
Definition: wingdi.h:2653
LONG tmInternalLeading
Definition: wingdi.h:2647
WCHAR tmDefaultChar
Definition: wingdi.h:2657
LONG tmMaxCharWidth
Definition: wingdi.h:2650
LONG tmAveCharWidth
Definition: wingdi.h:2649
WCHAR tmBreakChar
Definition: wingdi.h:2658
LONG tmExternalLeading
Definition: wingdi.h:2648
LONG tmDigitizedAspectY
Definition: wingdi.h:2654
BYTE tmPitchAndFamily
Definition: wingdi.h:2662
WCHAR tmLastChar
Definition: wingdi.h:2656
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
#define ft_sfnt_os2
Definition: tttables.h:631
#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:4533
#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:1648
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetFontFamilyInfoForList(), and IntGdiGetFontResourceInfo().

◆ FontLink_AddCache()

static VOID FontLink_AddCache ( _In_ PFONTLINK_CACHE  pCache)
inlinestatic

Definition at line 235 of file freetype.c.

237{
239
240 /* Add the new cache entry to the top of the cache list */
242 InsertHeadList(&g_FontLinkCache, &pCache->ListEntry);
243
244 /* If there are too many cache entries in the list, remove the oldest one at the bottom */
246 {
247 ASSERT(!IsListEmpty(&g_FontLinkCache));
248 Entry = RemoveTailList(&g_FontLinkCache);
250 pCache = CONTAINING_RECORD(Entry, FONTLINK_CACHE, ListEntry);
251 FontLink_Chain_Free(&pCache->Chain);
253 }
254}
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveTailList(ListHead)
Definition: env_spec_w32.h:975
static VOID FontLink_Chain_Free(_Inout_ PFONTLINK_CHAIN pChain)
Definition: freetype.c:214
static LONG g_nFontLinkCacheCount
Definition: freetype.c:73
#define MAX_FONTLINK_CACHE
Definition: freetype.c:71

Referenced by FontLink_Chain_Finish().

◆ FontLink_Chain_Dump()

static VOID FontLink_Chain_Dump ( _In_ PFONTLINK_CHAIN  pChain)
inlinestatic

Definition at line 4351 of file freetype.c.

4353{
4354#if 0
4355 PLIST_ENTRY Entry, Head;
4356 PFONTLINK pFontLink;
4357 INT iLink = 0;
4358
4359 DPRINT1("%S, %p, %p\n", pChain->LogFont.lfFaceName, pChain->pBaseTextObj, pChain->pDefFace);
4360
4361 Head = &pChain->FontLinkList;
4362 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
4363 {
4364 pFontLink = CONTAINING_RECORD(Entry, FONTLINK, ListEntry);
4365 DPRINT1("FontLink #%d: %p, %d, %S, %p, %p\n",
4366 iLink, pFontLink, pFontLink->bIgnore, pFontLink->LogFont.lfFaceName,
4367 pFontLink->pFontGDI, pFontLink->SharedFace);
4368 ++iLink;
4369 }
4370#endif
4371}
int32_t INT
Definition: typedefs.h:58

Referenced by FontLink_Chain_FindGlyph().

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

4382{
4383 PFONTLINK pFontLink;
4384 PLIST_ENTRY Entry, Head;
4385 UINT index;
4386 FT_Face face;
4387
4388 // Try the default font at first
4389 index = get_glyph_index_flagged(pChain->pDefFace, code, fCodeAsIndex);
4390 if (index)
4391 {
4392 DPRINT("code: 0x%08X, index: 0x%08X, fCodeAsIndex:%d\n", code, index, fCodeAsIndex);
4393 pCache->Hashed.Face = *pFace = pChain->pDefFace;
4394 return index; // The glyph is found on the default font
4395 }
4396
4397 if (!FontLink_Chain_IsPopulated(pChain)) // The chain is not populated yet
4398 {
4400 FontLink_Chain_Dump(pChain);
4401 }
4402
4403 // Now the chain is populated. Looking for the target glyph...
4404 Head = &pChain->FontLinkList;
4405 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
4406 {
4407 pFontLink = CONTAINING_RECORD(Entry, FONTLINK, ListEntry);
4408 if (!FontLink_PrepareFontInfo(pFontLink))
4409 continue; // This link is not useful, check the next one
4410
4411 face = pFontLink->SharedFace->Face;
4413 if (!index)
4414 continue; // The glyph does not exist, continue searching
4415
4416 // The target glyph is found in the chain
4417 DPRINT("code: 0x%08X, index: 0x%08X\n", code, index);
4418 pCache->Hashed.Face = *pFace = face;
4419 FT_Set_Transform(face, &pCache->Hashed.matTransform, NULL);
4420 return index;
4421 }
4422
4423 // No target glyph found in the chain: use default glyph
4425 index = get_glyph_index(*pFace, code);
4426 DPRINT("code: 0x%08X, index: 0x%08X\n", code, index);
4427 pCache->Hashed.Face = *pFace = pChain->pDefFace;
4428 return index;
4429}
#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:4345
static BOOL FontLink_PrepareFontInfo(_Inout_ PFONTLINK pFontLink)
Definition: freetype.c:503
static DWORD s_chFontLinkDefaultChar
Definition: freetype.c:64
static VOID FontLink_Chain_Dump(_In_ PFONTLINK_CHAIN pChain)
Definition: freetype.c:4351
static NTSTATUS FontLink_Chain_Populate(_Inout_ PFONTLINK_CHAIN pChain)
Definition: freetype.c:1473
static BOOL FontLink_Chain_IsPopulated(const FONTLINK_CHAIN *pChain)
Definition: freetype.c:208
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:4330
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:653
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 1414 of file freetype.c.

1417{
1418 PLIST_ENTRY Entry, Head = &pChain->FontLinkList;
1419 PFONTLINK pLink;
1420
1421 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
1422 {
1423 pLink = CONTAINING_RECORD(Entry, FONTLINK, ListEntry);
1424 if (RtlEqualMemory(&pLink->LogFont, plf, sizeof(*plf)))
1425 return pLink;
1426 }
1427
1428 return NULL;
1429}
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18

Referenced by FontLink_Create().

◆ FontLink_Chain_Finish()

static VOID FontLink_Chain_Finish ( _Inout_ PFONTLINK_CHAIN  pChain)
inlinestatic

Add the chain to the cache (g_FontLinkCache) if the chain had been populated.

Parameters
pChainThe chain.

Definition at line 276 of file freetype.c.

278{
279 PFONTLINK_CACHE pCache;
280
281 if (!FontLink_Chain_IsPopulated(pChain))
282 return; // The chain is not populated yet
283
285 if (!pCache)
286 return; // Out of memory
287
288 pCache->LogFont = pChain->LogFont;
289 pCache->Chain = *pChain;
290 IntRebaseList(&pCache->Chain.FontLinkList, &pChain->FontLinkList);
291
292 FontLink_AddCache(pCache);
293}
static VOID FontLink_AddCache(_In_ PFONTLINK_CACHE pCache)
Definition: freetype.c:235
static VOID IntRebaseList(_Inout_ PLIST_ENTRY pNewHead, _Inout_ PLIST_ENTRY pOldHead)
Definition: freetype.c:257

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ FontLink_Chain_Free()

static VOID FontLink_Chain_Free ( _Inout_ PFONTLINK_CHAIN  pChain)
static

Definition at line 214 of file freetype.c.

216{
218 PFONTLINK pLink;
219
220 if (!FontLink_Chain_IsPopulated(pChain)) // The chain is not populated yet
221 return;
222
223 if (pChain->pszzFontLink)
224 ExFreePoolWithTag(pChain->pszzFontLink, TAG_FONT);
225
226 while (!IsListEmpty(&pChain->FontLinkList))
227 {
228 Entry = RemoveHeadList(&pChain->FontLinkList);
229 pLink = CONTAINING_RECORD(Entry, FONTLINK, ListEntry);
230 FontLink_Destroy(pLink);
231 }
232}
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
static VOID FontLink_Destroy(_Inout_ PFONTLINK pLink)
Definition: freetype.c:201

Referenced by FontLink_AddCache(), and FontLink_CleanupCache().

◆ FontLink_Chain_Init()

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

Definition at line 1294 of file freetype.c.

1298{
1299 RtlZeroMemory(pChain, sizeof(*pChain));
1300 pChain->pBaseTextObj = pTextObj;
1301 pChain->pDefFace = face;
1303}

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ FontLink_Chain_IsPopulated()

static BOOL FontLink_Chain_IsPopulated ( const FONTLINK_CHAIN pChain)
inlinestatic

Definition at line 208 of file freetype.c.

209{
210 return pChain->LogFont.lfFaceName[0];
211}

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

◆ FontLink_Chain_LoadReg()

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

Definition at line 1323 of file freetype.c.

1326{
1328 HKEY hKey;
1329 DWORD cbData;
1330 WCHAR szzFontLink[512];
1331 SIZE_T FontLinkSize;
1332 PZZWSTR pszzFontLink = NULL;
1333
1334 ASSERT(pLF->lfFaceName[0]);
1335
1336 // Open the registry key
1338 L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\FontLink\\SystemLink",
1339 &hKey);
1340 if (!NT_SUCCESS(Status))
1341 return Status;
1342
1343 // Load the FontLink entry
1344 cbData = sizeof(szzFontLink);
1345 Status = RegQueryValue(hKey, pLF->lfFaceName, REG_MULTI_SZ, szzFontLink, &cbData);
1346 if (!NT_SUCCESS(Status) &&
1348 {
1349 // Retry with substituted
1351 cbData = sizeof(szzFontLink);
1352 Status = RegQueryValue(hKey, pLF->lfFaceName, REG_MULTI_SZ, szzFontLink, &cbData);
1353 }
1354
1356 {
1357 // Buffer is too small. Retry with larger buffer
1358 if (cbData >= 2 * sizeof(WCHAR)) // Sanity check
1359 {
1360 FontLinkSize = cbData;
1361 pszzFontLink = ExAllocatePoolWithTag(PagedPool, FontLinkSize, TAG_FONT);
1362 if (!pszzFontLink)
1363 {
1364 ZwClose(hKey); // Close the registry key
1365 return STATUS_NO_MEMORY;
1366 }
1367 Status = RegQueryValue(hKey, pLF->lfFaceName, REG_MULTI_SZ, pszzFontLink, &cbData);
1368 if (!NT_SUCCESS(Status))
1369 {
1370 ExFreePoolWithTag(pszzFontLink, TAG_FONT);
1371 pszzFontLink = NULL;
1372 }
1373 }
1374 }
1375
1376 ZwClose(hKey); // Close the registry key
1377
1378 if (!NT_SUCCESS(Status)) // Failed to get registry value
1379 {
1380 // Use default value
1381 ASSERT(sizeof(szzFontLink) >= sizeof(s_szzDefFontLink));
1382 ASSERT(sizeof(szzFontLink) >= sizeof(s_szzDefFixedFontLink));
1383 if (!(pLF->lfPitchAndFamily & FIXED_PITCH))
1384 RtlCopyMemory(szzFontLink, s_szzDefFontLink, sizeof(s_szzDefFontLink));
1385 else
1387 }
1388
1389 if (pszzFontLink)
1390 {
1391 // Ensure double-NUL-terminated
1392 ASSERT(FontLinkSize / sizeof(WCHAR) >= 2);
1393 pszzFontLink[FontLinkSize / sizeof(WCHAR) - 1] = UNICODE_NULL;
1394 pszzFontLink[FontLinkSize / sizeof(WCHAR) - 2] = UNICODE_NULL;
1395 }
1396 else
1397 {
1398 // Ensure double-NUL-terminated
1399 szzFontLink[_countof(szzFontLink) - 1] = UNICODE_NULL;
1400 szzFontLink[_countof(szzFontLink) - 2] = UNICODE_NULL;
1401
1402 FontLinkSize = SZZ_GetSize(szzFontLink);
1403 pszzFontLink = ExAllocatePoolWithTag(PagedPool, FontLinkSize, TAG_FONT);
1404 if (!pszzFontLink)
1405 return STATUS_NO_MEMORY;
1406 RtlCopyMemory(pszzFontLink, szzFontLink, FontLinkSize);
1407 }
1408 pChain->pszzFontLink = pszzFontLink;
1409
1410 return STATUS_SUCCESS;
1411}
static const WCHAR s_szzDefFixedFontLink[]
Definition: freetype.c:1314
static SIZE_T SZZ_GetSize(_In_ PCZZWSTR pszz)
Definition: freetype.c:76
static BOOL SubstituteFontRecurse(PLOGFONTW pLogFont)
Definition: freetype.c:1258
static const WCHAR s_szzDefFontLink[]
Definition: freetype.c:1306
FxAutoRegKey hKey
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define REG_MULTI_SZ
Definition: nt_native.h:1501
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:420
#define L(x)
Definition: ntvdm.h:50
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define _countof(array)
Definition: sndvol32.h:70
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define FIXED_PITCH
Definition: wingdi.h:444
#define RegOpenKey
Definition: winreg.h:519
#define RegQueryValue
Definition: winreg.h:523

Referenced by FontLink_Chain_Populate().

◆ FontLink_Chain_Populate()

static NTSTATUS FontLink_Chain_Populate ( _Inout_ PFONTLINK_CHAIN  pChain)
static

Definition at line 1473 of file freetype.c.

1475{
1477 PFONTLINK pLink;
1478 LOGFONTW lfBase;
1479 PTEXTOBJ pTextObj = pChain->pBaseTextObj;
1480 PFONTGDI pFontGDI;
1481 PWSTR pszLink;
1482 PFONTLINK_CACHE pLinkCache;
1483 WCHAR szEntry[MAX_PATH];
1484 BOOL bFixCharSet;
1485
1486 InitializeListHead(&pChain->FontLinkList);
1487
1488 lfBase = pTextObj->logfont.elfEnumLogfontEx.elfLogFont;
1489 pFontGDI = ObjToGDI(pTextObj->Font, FONT);
1490 lfBase.lfHeight = pFontGDI->lfHeight;
1491 lfBase.lfWidth = pFontGDI->lfWidth;
1492
1493 // Use pTextObj->TextFace if lfFaceName was empty
1494 if (!lfBase.lfFaceName[0])
1495 {
1496 ASSERT(pTextObj->TextFace[0]);
1497 RtlStringCchCopyW(lfBase.lfFaceName, _countof(lfBase.lfFaceName), pTextObj->TextFace);
1498 }
1499
1500 // Fix lfCharSet
1501 switch (lfBase.lfCharSet)
1502 {
1503 case ANSI_CHARSET: bFixCharSet = !s_fFontLinkUseAnsi; break;
1504 case OEM_CHARSET: bFixCharSet = !s_fFontLinkUseOem; break;
1505 case SYMBOL_CHARSET: bFixCharSet = !s_fFontLinkUseSymbol; break;
1506 default: bFixCharSet = TRUE; break;
1507 }
1508 if (bFixCharSet)
1509 lfBase.lfCharSet = DEFAULT_CHARSET;
1510
1511 // Use cache if any
1512 pLinkCache = FontLink_FindCache(&lfBase);
1513 if (pLinkCache)
1514 {
1515 RemoveEntryList(&pLinkCache->ListEntry);
1516 *pChain = pLinkCache->Chain;
1517 IntRebaseList(&pChain->FontLinkList, &pLinkCache->Chain.FontLinkList);
1518 ExFreePoolWithTag(pLinkCache, TAG_FONT);
1519 return STATUS_SUCCESS;
1520 }
1521
1522 pChain->LogFont = lfBase;
1523
1524 // Load FontLink entry from registry
1525 Status = FontLink_Chain_LoadReg(pChain, &pChain->LogFont);
1526 if (!NT_SUCCESS(Status))
1527 return Status;
1528
1529 pszLink = pChain->pszzFontLink;
1530 while (*pszLink)
1531 {
1532 DPRINT("pszLink: '%S'\n", pszLink);
1533 pLink = FontLink_Create(pChain, &lfBase, pszLink);
1534 if (pLink)
1535 InsertTailList(&pChain->FontLinkList, &pLink->ListEntry);
1536 pszLink += wcslen(pszLink) + 1;
1537 }
1538
1539 // Use default settings (if any)
1541 {
1543 RtlStringCchCatW(szEntry, _countof(szEntry), L",");
1545 DPRINT("szEntry: '%S'\n", szEntry);
1546 pLink = FontLink_Create(pChain, &lfBase, szEntry);
1547 if (pLink)
1548 InsertTailList(&pChain->FontLinkList, &pLink->ListEntry);
1549 }
1550
1552 return Status;
1553}
#define MAX_PATH
Definition: compat.h:34
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:184
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#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:65
static BOOL s_fFontLinkUseAnsi
Definition: freetype.c:67
static PFONTLINK FontLink_Create(_Inout_ PFONTLINK_CHAIN pChain, _In_ const LOGFONTW *plfBase, _In_ LPCWSTR pszLink)
Definition: freetype.c:1432
static WCHAR s_szDefFontLinkFontName[MAX_PATH]
Definition: freetype.c:66
static NTSTATUS FontLink_Chain_LoadReg(_Inout_ PFONTLINK_CHAIN pChain, _Inout_ PLOGFONTW pLF)
Definition: freetype.c:1323
static BOOL s_fFontLinkUseOem
Definition: freetype.c:68
static BOOL s_fFontLinkUseSymbol
Definition: freetype.c:69
static PFONTLINK_CACHE FontLink_FindCache(_In_ const LOGFONTW *pLogFont)
Definition: freetype.c:296
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
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:2779
uint16_t * PWSTR
Definition: typedefs.h:56
#define OEM_CHARSET
Definition: wingdi.h:400
#define SYMBOL_CHARSET
Definition: wingdi.h:385

Referenced by FontLink_Chain_FindGlyph().

◆ FontLink_CleanupCache()

static VOID FontLink_CleanupCache ( VOID  )
inlinestatic

Definition at line 311 of file freetype.c.

312{
314 PFONTLINK_CACHE pLinkCache;
315
316 while (!IsListEmpty(&g_FontLinkCache))
317 {
318 Entry = RemoveHeadList(&g_FontLinkCache);
319 pLinkCache = CONTAINING_RECORD(Entry, FONTLINK_CACHE, ListEntry);
320 FontLink_Chain_Free(&pLinkCache->Chain);
321 ExFreePoolWithTag(pLinkCache, TAG_FONT);
322 }
323
325}

Referenced by FreeFontSupport().

◆ FontLink_Create()

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

Definition at line 1432 of file freetype.c.

1436{
1437 LPWSTR pch0, pch1;
1438 LOGFONTW lf;
1439 PFONTLINK pLink;
1440
1441 lf = *plfBase;
1442
1443 // pszLink: "<FontFileName>,<FaceName>[,...]"
1444 pch0 = wcschr(pszLink, L',');
1445 if (!pch0)
1446 {
1447 DPRINT1("%S\n", pszLink);
1448 return NULL; // Invalid FontLink data
1449 }
1450 ++pch0;
1451
1452 pch1 = wcschr(pch0, L',');
1453 if (pch1)
1454 RtlStringCchCopyNW(lf.lfFaceName, _countof(lf.lfFaceName), pch0, pch1 - pch0);
1455 else
1457
1459 DPRINT("lfFaceName: %S\n", lf.lfFaceName);
1460
1461 if (RtlEqualMemory(plfBase, &lf, sizeof(lf)) || FontLink_Chain_FindLink(pChain, &lf))
1462 return NULL; // Already exists
1463
1464 pLink = ExAllocatePoolZero(PagedPool, sizeof(FONTLINK), TAG_FONT);
1465 if (!pLink)
1466 return NULL; // Out of memory
1467
1468 pLink->LogFont = lf;
1469 return pLink;
1470}
#define wcschr
Definition: compat.h:17
static PFONTLINK FontLink_Chain_FindLink(PFONTLINK_CHAIN pChain, PLOGFONTW plf)
Definition: freetype.c:1414
FORCEINLINE 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
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by FontLink_Chain_Populate().

◆ FontLink_Destroy()

static VOID FontLink_Destroy ( _Inout_ PFONTLINK  pLink)
inlinestatic

Definition at line 201 of file freetype.c.

202{
203 ASSERT(pLink);
205}

Referenced by FontLink_Chain_Free().

◆ FontLink_FindCache()

static PFONTLINK_CACHE FontLink_FindCache ( _In_ const LOGFONTW pLogFont)
inlinestatic

Definition at line 296 of file freetype.c.

298{
300 PFONTLINK_CACHE pLinkCache;
301 for (Entry = g_FontLinkCache.Flink; Entry != &g_FontLinkCache; Entry = Entry->Flink)
302 {
303 pLinkCache = CONTAINING_RECORD(Entry, FONTLINK_CACHE, ListEntry);
304 if (RtlEqualMemory(&pLinkCache->LogFont, pLogFont, sizeof(LOGFONTW)))
305 return pLinkCache;
306 }
307 return NULL;
308}

Referenced by FontLink_Chain_Populate().

◆ FontLink_LoadDefaultCharset()

static NTSTATUS FontLink_LoadDefaultCharset ( VOID  )
inlinestatic

Definition at line 155 of file freetype.c.

156{
158 HKEY hKey;
159 DWORD cbData;
160 WCHAR szValue[8];
161
162 // Set the default values
164
165 // Open the registry key
167 L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\FontAssoc\\Associated Charset",
168 &hKey);
169 if (!NT_SUCCESS(Status))
170 return Status;
171
172 cbData = sizeof(szValue);
173 Status = RegQueryValue(hKey, L"ANSI(00)", REG_SZ, szValue, &cbData);
174 if (NT_SUCCESS(Status))
175 {
176 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
177 s_fFontLinkUseAnsi = !_wcsicmp(szValue, L"YES");
178 }
179
180 cbData = sizeof(szValue);
181 Status = RegQueryValue(hKey, L"OEM(FF)", REG_SZ, szValue, &cbData);
182 if (NT_SUCCESS(Status))
183 {
184 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
185 s_fFontLinkUseOem = !_wcsicmp(szValue, L"YES");
186 }
187
188 cbData = sizeof(szValue);
189 Status = RegQueryValue(hKey, L"SYMBOL(02)", REG_SZ, szValue, &cbData);
190 if (NT_SUCCESS(Status))
191 {
192 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
193 s_fFontLinkUseSymbol = !_wcsicmp(szValue, L"YES");
194 }
195
196 ZwClose(hKey); // Close the registry key
197 return STATUS_SUCCESS;
198}
#define REG_SZ
Definition: layer.c:22

Referenced by InitFontSupport().

◆ FontLink_LoadDefaultFonts()

static NTSTATUS FontLink_LoadDefaultFonts ( VOID  )
inlinestatic

Definition at line 117 of file freetype.c.

118{
120 HKEY hKey;
121 DWORD cbData;
122 WCHAR szValue[MAX_PATH];
123
124 // Set the default values
126
127 // Open the registry key
129 L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\FontAssoc\\Associated DefaultFonts",
130 &hKey);
131 if (!NT_SUCCESS(Status))
132 return Status;
133
134 cbData = sizeof(szValue);
135 Status = RegQueryValue(hKey, L"AssocSystemFont", REG_SZ, szValue, &cbData);
136 if (NT_SUCCESS(Status))
137 {
138 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
140 }
141
142 cbData = sizeof(szValue);
143 Status = RegQueryValue(hKey, L"FontPackage", REG_SZ, szValue, &cbData);
144 if (NT_SUCCESS(Status))
145 {
146 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
148 }
149
150 ZwClose(hKey); // Close the registry key
151 return STATUS_SUCCESS;
152}

Referenced by InitFontSupport().

◆ FontLink_LoadSettings()

static NTSTATUS FontLink_LoadSettings ( VOID  )
inlinestatic

Definition at line 91 of file freetype.c.

92{
94 HKEY hKey;
95 DWORD cbData, dwValue;
96
97 // Set the default values
99
100 // Open the registry key
102 L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\FontLink",
103 &hKey);
104 if (!NT_SUCCESS(Status))
105 return Status;
106
107 cbData = sizeof(dwValue);
108 Status = RegQueryValue(hKey, L"FontLinkDefaultChar", REG_DWORD, &dwValue, &cbData);
109 if (NT_SUCCESS(Status) && cbData == sizeof(dwValue))
110 s_chFontLinkDefaultChar = dwValue;
111
112 ZwClose(hKey); // Close the registry key
113 return STATUS_SUCCESS;
114}
#define FONTLINK_DEFAULT_CHAR
Definition: freetype.c:62
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by InitFontSupport().

◆ FontLink_PrepareFontInfo()

static BOOL FontLink_PrepareFontInfo ( _Inout_ PFONTLINK  pFontLink)
static

Definition at line 503 of file freetype.c.

505{
506 FONTOBJ *pFontObj;
507 ULONG MatchPenalty;
508 UNICODE_STRING FaceName;
509 PPROCESSINFO Win32Process;
510 PFONTGDI pFontGDI;
511
513
514 if (pFontLink->bIgnore)
515 return FALSE;
516
517 if (pFontLink->SharedFace)
518 return TRUE;
519
520 MatchPenalty = MAXULONG;
521 pFontObj = NULL;
522
523 // Search private fonts
524 Win32Process = PsGetCurrentProcessWin32Process();
525 FindBestFontFromList(&pFontObj, &MatchPenalty, &pFontLink->LogFont,
526 &Win32Process->PrivateFontListHead);
527
528 // Search system fonts
529 FindBestFontFromList(&pFontObj, &MatchPenalty, &pFontLink->LogFont,
530 &g_FontListHead);
531
532 if (!pFontObj) // Not found?
533 {
534 pFontLink->bIgnore = TRUE;
535 return FALSE;
536 }
537
538 pFontGDI = ObjToGDI(pFontObj, FONT);
539 pFontLink->SharedFace = pFontGDI->SharedFace;
540
541 // FontLink uses family name
542 RtlInitUnicodeString(&FaceName, pFontLink->LogFont.lfFaceName);
543 if (!MatchFontName(pFontLink->SharedFace, &FaceName, TT_NAME_ID_FONT_FAMILY, LANG_ENGLISH) &&
544 !MatchFontName(pFontLink->SharedFace, &FaceName, TT_NAME_ID_FONT_FAMILY, gusLanguageID))
545 {
546 pFontLink->bIgnore = TRUE;
547 return FALSE;
548 }
549
550 return TRUE;
551}
static __inline VOID FindBestFontFromList(FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
Definition: freetype.c:5752
static BOOL MatchFontName(PSHARED_FACE SharedFace, PUNICODE_STRING Name1, FT_UShort NameID, FT_UShort LangID)
Definition: freetype.c:5856
#define TT_NAME_ID_FONT_FAMILY
Definition: font.c:3536
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
LIST_ENTRY PrivateFontListHead
Definition: win32.h:284
USHORT gusLanguageID
Definition: init.c:12

Referenced by FontLink_Chain_FindGlyph().

◆ FreeFontSupport()

VOID FASTCALL FreeFontSupport ( VOID  )

Definition at line 1062 of file freetype.c.

1063{
1064 PLIST_ENTRY pHead, pEntry;
1065 PFONT_CACHE_ENTRY pFontCache;
1066 PFONTSUBST_ENTRY pSubstEntry;
1067 PFONT_ENTRY pFontEntry;
1068
1069 // Cleanup the FontLink cache
1071
1072 // Free font cache list
1073 pHead = &g_FontCacheListHead;
1074 while (!IsListEmpty(pHead))
1075 {
1076 pEntry = RemoveHeadList(pHead);
1077 pFontCache = CONTAINING_RECORD(pEntry, FONT_CACHE_ENTRY, ListEntry);
1078 RemoveCachedEntry(pFontCache);
1079 }
1080
1081 // Free font subst list
1082 pHead = &g_FontSubstListHead;
1083 while (!IsListEmpty(pHead))
1084 {
1085 pEntry = RemoveHeadList(pHead);
1086 pSubstEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
1087 ExFreePoolWithTag(pSubstEntry, TAG_FONT);
1088 }
1089
1090 // Free font list
1091 pHead = &g_FontListHead;
1092 while (!IsListEmpty(pHead))
1093 {
1094 pEntry = RemoveHeadList(pHead);
1095 pFontEntry = CONTAINING_RECORD(pEntry, FONT_ENTRY, ListEntry);
1096 CleanupFontEntry(pFontEntry);
1097 }
1098
1100 {
1103 }
1104
1107}
FT_Library g_FreeTypeLibrary
Definition: freetype.c:359
static VOID FontLink_CleanupCache(VOID)
Definition: freetype.c:311
static __inline VOID FASTCALL CleanupFontEntry(PFONT_ENTRY FontEntry)
Definition: freetype.c:721
static void RemoveCachedEntry(PFONT_CACHE_ENTRY Entry)
Definition: freetype.c:616
FT_Done_Library(FT_Library library)
Definition: ftobjs.c:5220
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
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 741 of file freetype.c.

742{
743 return (FT_Fixed)((long)f.value << 16 | (unsigned long)f.fract);
744}
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 5364 of file freetype.c.

5370{
5372 FT_Face Face = FontGdi->SharedFace->Face;
5373
5375
5376 if (FT_IS_SFNT(Face))
5377 {
5378 if (Table)
5379 Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
5380 (Table << 8 & 0xFF0000);
5381
5382 if (!Buffer) Size = 0;
5383
5384 if (Buffer && Size)
5385 {
5387 FT_ULong Needed = 0;
5388
5389 Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
5390
5391 if ( !Error && Needed < Size) Size = Needed;
5392 }
5393 if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
5394 Result = Size;
5395 }
5396
5398
5399 return Result;
5400}
BOOL Error
Definition: chkdsk.c:66
Definition: bufpool.h:45
#define IntUnLockFreeType()
Definition: freetype.c:385
#define IntLockFreeType()
Definition: freetype.c:379
unsigned long FT_ULong
Definition: fttypes.h:253
int FT_Error
Definition: fttypes.h:300
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:4134
#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,
LPMAT2  pmat2,
BOOL  bIgnoreRotation 
)

Definition at line 4436 of file freetype.c.

4445{
4446 PDC_ATTR pdcattr;
4447 PTEXTOBJ TextObj;
4448 PFONTGDI FontGDI;
4449 HFONT hFont = 0;
4450 GLYPHMETRICS gm;
4451 ULONG Size;
4452 FT_Face ft_face;
4453 FT_UInt glyph_index;
4454 DWORD width, height, pitch, needed = 0;
4455 FT_Bitmap ft_bitmap;
4457 INT left, right, top = 0, bottom = 0;
4459 FLOATOBJ eM11, widthRatio, eTemp;
4460 FT_Matrix mat, transMat = identityMat;
4461 BOOL needsTransform = FALSE;
4462 INT orientation;
4463 LONG aveWidth;
4464 INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
4465 OUTLINETEXTMETRICW *potm;
4466 XFORMOBJ xo;
4467 XFORML xform;
4468 LOGFONTW *plf;
4469
4470 DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
4471 cjBuf, pvBuf, pmat2);
4472
4473 pdcattr = dc->pdcattr;
4474
4475 XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
4476 XFORMOBJ_iGetXform(&xo, &xform);
4477 FLOATOBJ_SetFloat(&eM11, xform.eM11);
4478
4479 hFont = pdcattr->hlfntNew;
4480 TextObj = RealizeFontInit(hFont);
4481
4482 if (!TextObj)
4483 {
4485 return GDI_ERROR;
4486 }
4487 FontGDI = ObjToGDI(TextObj->Font, FONT);
4488 ft_face = FontGDI->SharedFace->Face;
4489
4490 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4491 aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
4492 orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
4493
4495 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL, FALSE);
4497 if (!potm)
4498 {
4500 TEXTOBJ_UnlockText(TextObj);
4501 return GDI_ERROR;
4502 }
4504 Size = IntGetOutlineTextMetrics(FontGDI, Size, potm, FALSE);
4505 if (!Size)
4506 {
4507 /* FIXME: last error? */
4509 TEXTOBJ_UnlockText(TextObj);
4510 return GDI_ERROR;
4511 }
4512
4514 TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
4516 FT_Set_Transform(ft_face, &mat, NULL);
4517
4518 TEXTOBJ_UnlockText(TextObj);
4519
4520 glyph_index = get_glyph_index_flagged(ft_face, wch, (iFormat & GGO_GLYPH_INDEX));
4521 iFormat &= ~GGO_GLYPH_INDEX;
4522
4523 if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
4524 load_flags |= FT_LOAD_NO_BITMAP;
4525
4526 if (iFormat & GGO_UNHINTED)
4527 {
4528 load_flags |= FT_LOAD_NO_HINTING;
4529 iFormat &= ~GGO_UNHINTED;
4530 }
4531
4532 error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
4533 if (error)
4534 {
4535 DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
4537 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
4538 return GDI_ERROR;
4539 }
4541
4542 FLOATOBJ_Set1(&widthRatio);
4543 if (aveWidth && potm)
4544 {
4545 // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
4546 FLOATOBJ_SetLong(&widthRatio, aveWidth);
4547 FLOATOBJ_Mul(&widthRatio, &eM11);
4549 }
4550
4551 //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
4552 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
4553 FLOATOBJ_Mul(&eTemp, &widthRatio);
4554 left = FLOATOBJ_GetLong(&eTemp) & -64;
4555
4556 //right = (INT)((ft_face->glyph->metrics.horiBearingX +
4557 // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
4558 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
4559 FLOATOBJ_Mul(&eTemp, &widthRatio);
4560 FLOATOBJ_AddLong(&eTemp, 63);
4561 right = FLOATOBJ_GetLong(&eTemp) & -64;
4562
4563 //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
4564 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
4565 FLOATOBJ_Mul(&eTemp, &widthRatio);
4566 FLOATOBJ_AddLong(&eTemp, 63);
4567 adv = FLOATOBJ_GetLong(&eTemp) >> 6;
4568
4569 lsb = left >> 6;
4570 bbx = (right - left) >> 6;
4571
4572 DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
4573
4575
4576 /* Width scaling transform */
4577 if (!FLOATOBJ_Equal1(&widthRatio))
4578 {
4579 FT_Matrix scaleMat;
4580
4581 eTemp = widthRatio;
4582 FLOATOBJ_MulLong(&eTemp, 1 << 16);
4583
4584 scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
4585 scaleMat.xy = 0;
4586 scaleMat.yx = 0;
4587 scaleMat.yy = INT_TO_FIXED(1);
4588 FT_Matrix_Multiply(&scaleMat, &transMat);
4589 needsTransform = TRUE;
4590 }
4591
4592 /* World transform */
4593 {
4594 FT_Matrix ftmatrix;
4596
4597 /* Create a freetype matrix, by converting to 16.16 fixpoint format */
4598 IntMatrixFromMx(&ftmatrix, pmx);
4599
4600 if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
4601 {
4602 FT_Matrix_Multiply(&ftmatrix, &transMat);
4603 needsTransform = TRUE;
4604 }
4605 }
4606
4607 /* Rotation transform */
4608 if (orientation)
4609 {
4610 FT_Matrix rotationMat;
4611 DPRINT("Rotation Trans!\n");
4612 IntEscapeMatrix(&rotationMat, orientation);
4613 FT_Matrix_Multiply(&rotationMat, &transMat);
4614 needsTransform = TRUE;
4615 }
4616
4617 /* Extra transformation specified by caller */
4618 if (pmat2)
4619 {
4620 FT_Matrix extraMat;
4621 DPRINT("MAT2 Matrix Trans!\n");
4622 extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
4623 extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
4624 extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
4625 extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
4626 FT_Matrix_Multiply(&extraMat, &transMat);
4627 needsTransform = TRUE;
4628 }
4629
4630 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
4631
4632 if (!needsTransform)
4633 {
4634 DPRINT("No Need to be Transformed!\n");
4635 top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
4636 bottom = (ft_face->glyph->metrics.horiBearingY -
4637 ft_face->glyph->metrics.height) & -64;
4638 gm.gmCellIncX = adv;
4639 gm.gmCellIncY = 0;
4640 }
4641 else
4642 {
4643 INT xc, yc;
4644 FT_Vector vec;
4645 for (xc = 0; xc < 2; xc++)
4646 {
4647 for (yc = 0; yc < 2; yc++)
4648 {
4649 vec.x = (ft_face->glyph->metrics.horiBearingX +
4650 xc * ft_face->glyph->metrics.width);
4651 vec.y = ft_face->glyph->metrics.horiBearingY -
4652 yc * ft_face->glyph->metrics.height;
4653 DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
4654 FT_Vector_Transform(&vec, &transMat);
4655 if (xc == 0 && yc == 0)
4656 {
4657 left = right = vec.x;
4658 top = bottom = vec.y;
4659 }
4660 else
4661 {
4662 if (vec.x < left) left = vec.x;
4663 else if (vec.x > right) right = vec.x;
4664 if (vec.y < bottom) bottom = vec.y;
4665 else if (vec.y > top) top = vec.y;
4666 }
4667 }
4668 }
4669 left = left & -64;
4670 right = (right + 63) & -64;
4671 bottom = bottom & -64;
4672 top = (top + 63) & -64;
4673
4674 DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
4675 vec.x = ft_face->glyph->metrics.horiAdvance;
4676 vec.y = 0;
4677 FT_Vector_Transform(&vec, &transMat);
4678 gm.gmCellIncX = (vec.x+63) >> 6;
4679 gm.gmCellIncY = -((vec.y+63) >> 6);
4680 }
4681 gm.gmBlackBoxX = (right - left) >> 6;
4682 gm.gmBlackBoxY = (top - bottom) >> 6;
4683 gm.gmptGlyphOrigin.x = left >> 6;
4684 gm.gmptGlyphOrigin.y = top >> 6;
4685
4686 DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
4687 gm.gmCellIncX, gm.gmCellIncY,
4688 gm.gmBlackBoxX, gm.gmBlackBoxY,
4690
4692
4693 if (iFormat == GGO_METRICS)
4694 {
4695 DPRINT("GGO_METRICS Exit!\n");
4696 *pgm = gm;
4697 return 1; /* FIXME */
4698 }
4699
4700 if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
4701 {
4702 DPRINT1("Loaded a bitmap\n");
4703 return GDI_ERROR;
4704 }
4705
4706 switch (iFormat)
4707 {
4708 case GGO_BITMAP:
4709 {
4710 width = gm.gmBlackBoxX;
4711 height = gm.gmBlackBoxY;
4712 pitch = ((width + 31) >> 5) << 2;
4713 needed = pitch * height;
4714
4715 if (!pvBuf || !cjBuf) break;
4716 if (!needed) return GDI_ERROR; /* empty glyph */
4717 if (needed > cjBuf)
4718 return GDI_ERROR;
4719
4720 switch (ft_face->glyph->format)
4721 {
4723 {
4724 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4725 INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4726 INT h = min( height, ft_face->glyph->bitmap.rows );
4727 while (h--)
4728 {
4730 src += ft_face->glyph->bitmap.pitch;
4731 dst += pitch;
4732 }
4733 break;
4734 }
4735
4737 {
4738 ft_bitmap.width = width;
4739 ft_bitmap.rows = height;
4740 ft_bitmap.pitch = pitch;
4741 ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4742 ft_bitmap.buffer = pvBuf;
4743
4745 if (needsTransform)
4746 {
4747 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4748 }
4749 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4750 /* Note: FreeType will only set 'black' bits for us. */
4751 RtlZeroMemory(pvBuf, needed);
4752 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4754 break;
4755 }
4756
4757 default:
4758 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4759 return GDI_ERROR;
4760 }
4761
4762 break;
4763 }
4764
4765 case GGO_GRAY2_BITMAP:
4766 case GGO_GRAY4_BITMAP:
4767 case GGO_GRAY8_BITMAP:
4768 {
4769 unsigned int mult, row, col;
4770 BYTE *start, *ptr;
4771
4772 width = gm.gmBlackBoxX;
4773 height = gm.gmBlackBoxY;
4774 pitch = (width + 3) / 4 * 4;
4775 needed = pitch * height;
4776
4777 if (!pvBuf || !cjBuf) break;
4778 if (!needed) return GDI_ERROR; /* empty glyph */
4779 if (needed > cjBuf)
4780 return GDI_ERROR;
4781
4782 switch (ft_face->glyph->format)
4783 {
4785 {
4786 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4787 INT h = min( height, ft_face->glyph->bitmap.rows );
4788 INT x;
4789 while (h--)
4790 {
4791 for (x = 0; (UINT)x < pitch; x++)
4792 {
4793 if (x < ft_face->glyph->bitmap.width)
4794 dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4795 else
4796 dst[x] = 0;
4797 }
4798 src += ft_face->glyph->bitmap.pitch;
4799 dst += pitch;
4800 }
4801 break;
4802 }
4804 {
4805 ft_bitmap.width = width;
4806 ft_bitmap.rows = height;
4807 ft_bitmap.pitch = pitch;
4808 ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4809 ft_bitmap.buffer = pvBuf;
4810
4812 if (needsTransform)
4813 {
4814 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4815 }
4816 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4817 RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4818 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4820
4822 mult = 4;
4823 else if (iFormat == GGO_GRAY4_BITMAP)
4824 mult = 16;
4825 else if (iFormat == GGO_GRAY8_BITMAP)
4826 mult = 64;
4827 else
4828 {
4829 return GDI_ERROR;
4830 }
4831
4832 start = pvBuf;
4833 for (row = 0; row < height; row++)
4834 {
4835 ptr = start;
4836 for (col = 0; col < width; col++, ptr++)
4837 {
4838 *ptr = (((int)*ptr) * mult + 128) / 256;
4839 }
4840 start += pitch;
4841 }
4842
4843 break;
4844 }
4845 default:
4846 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4847 return GDI_ERROR;
4848 }
4849
4850 break;
4851 }
4852
4853 case GGO_NATIVE:
4854 {
4855 FT_Outline *outline = &ft_face->glyph->outline;
4856
4857 if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4858
4860 if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4861
4863
4864 if (!pvBuf || !cjBuf)
4865 {
4867 break;
4868 }
4869 if (needed > cjBuf)
4870 {
4872 return GDI_ERROR;
4873 }
4876 break;
4877 }
4878
4879 case GGO_BEZIER:
4880 {
4881 FT_Outline *outline = &ft_face->glyph->outline;
4882 if (cjBuf == 0) pvBuf = NULL;
4883
4884 if (needsTransform && pvBuf)
4885 {
4887 FT_Outline_Transform(outline, &transMat);
4889 }
4891
4892 if (!pvBuf || !cjBuf)
4893 break;
4894 if (needed > cjBuf)
4895 return GDI_ERROR;
4896
4898 break;
4899 }
4900
4901 default:
4902 DPRINT1("Unsupported format %u\n", iFormat);
4903 return GDI_ERROR;
4904 }
4905
4906 DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4907
4908 if (gm.gmBlackBoxX == 0)
4909 gm.gmBlackBoxX = 1;
4910 if (gm.gmBlackBoxY == 0)
4911 gm.gmBlackBoxY = 1;
4912
4913 *pgm = gm;
4914 return needed;
4915}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HFONT hFont
Definition: main.c:53
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:135
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define abs(i)
Definition: fconv.c:206
#define FLOATOBJ_Set1(fo)
Definition: floatobj.h:119
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:105
BOOL FASTCALL TextIntUpdateSize(PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:4227
#define ASSERT_FREETYPE_LOCK_NOT_HELD()
Definition: freetype.c:376
static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3962
static unsigned int get_native_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3889
static VOID FASTCALL IntMatrixFromMx(FT_Matrix *pmat, const MATRIX *pmx)
Definition: freetype.c:1130
static VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
Definition: freetype.c:1117
static const FT_Matrix identityMat
Definition: freetype.c:353
static __inline FT_Fixed FT_FixedFromFIXED(FIXED f)
Definition: freetype.c:741
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:760
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3012
FT_Vector_Transform(FT_Vector *vec, const FT_Matrix *matrix)
Definition: ftoutln.c:688
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3010
#define FT_LOAD_DEFAULT
Definition: freetype.h:3008
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
Definition: freetype.h:3017
FT_Vector * vec
Definition: ftbbox.c:448
#define INT_TO_FIXED(x)
Definition: ftcalc.h:404
FT_Matrix_Multiply(const FT_Matrix *a, FT_Matrix *b)
Definition: ftcalc.c:661
#define ft_glyph_format_bitmap
Definition: ftimage.h:731
@ FT_PIXEL_MODE_MONO
Definition: ftimage.h:183
@ FT_PIXEL_MODE_GRAY
Definition: ftimage.h:184
#define ft_glyph_format_outline
Definition: ftimage.h:732
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:528
FT_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap *abitmap)
Definition: ftoutln.c:661
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
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
static const WCHAR dc[]
#define error(str)
Definition: mkdosfs.c:1605
static PVOID ptr
Definition: dispmode.c:27
static const MAT2 mat
Definition: font.c:66
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define min(a, b)
Definition: monoChain.cc:55
long LONG
Definition: pedump.c:60
unsigned int width
Definition: ftimage.h:264
unsigned char * buffer
Definition: ftimage.h:266
unsigned char pixel_mode
Definition: ftimage.h:268
unsigned int rows
Definition: ftimage.h:263
int pitch
Definition: ftimage.h:265
FT_GlyphSlot glyph
Definition: freetype.h:1105
FT_Bitmap bitmap
Definition: freetype.h:1923
FT_Outline outline
Definition: freetype.h:1927
FT_Glyph_Metrics metrics
Definition: freetype.h:1916
FT_Glyph_Format format
Definition: freetype.h:1921
FT_Fixed xx
Definition: fttypes.h:387
FT_Fixed yx
Definition: fttypes.h:388
FT_Fixed yy
Definition: fttypes.h:388
FT_Fixed xy
Definition: fttypes.h:387
FT_Pos x
Definition: ftimage.h:76
FT_Pos y
Definition: ftimage.h:77
LONG lfOrientation
Definition: dimm.idl:62
HANDLE hlfntNew
Definition: ntgdihdl.h:330
short gmCellIncX
Definition: wingdi.h:2445
UINT gmBlackBoxY
Definition: wingdi.h:2443
UINT gmBlackBoxX
Definition: wingdi.h:2442
short gmCellIncY
Definition: wingdi.h:2446
POINT gmptGlyphOrigin
Definition: wingdi.h:2444
FIXED eM22
Definition: wingdi.h:2476
FIXED eM21
Definition: wingdi.h:2475
FIXED eM11
Definition: wingdi.h:2473
FIXED eM12
Definition: wingdi.h:2474
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(HFONT hFont)
Definition: font.c:422
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:22
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3468
#define FLOATOBJ_AddLong(pf, l)
Definition: winddi.h:2820
#define 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 6382 of file freetype.c.

6385{
6386 DWORD Count = 0;
6387 INT i = 0;
6388 FT_Face face = Font->SharedFace->Face;
6389
6390 if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
6391 {
6392 FT_UInt previous_index = 0, glyph_index = 0;
6393 FT_ULong char_code, char_previous;
6394 FT_Vector delta;
6395
6396 char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
6397
6399
6400 while (glyph_index)
6401 {
6402 if (previous_index && glyph_index)
6403 {
6404 FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
6405
6406 if (pKerningPair && cPairs)
6407 {
6408 pKerningPair[i].wFirst = char_previous;
6409 pKerningPair[i].wSecond = char_code;
6410 pKerningPair[i].iKernAmount = delta.x;
6411 i++;
6412 if (i == cPairs) break;
6413 }
6414 Count++;
6415 }
6416 previous_index = glyph_index;
6417 char_previous = char_code;
6418 char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
6419 }
6421 }
6422 return Count;
6423}
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3722
FT_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning)
Definition: ftobjs.c:3347
@ FT_KERNING_DEFAULT
Definition: freetype.h:3389
#define FT_HAS_KERNING(face)
Definition: freetype.h:1297
int Count
Definition: noreturn.cpp:7
WORD wSecond
Definition: wingdi.h:2465
int iKernAmount
Definition: wingdi.h:2466

Referenced by GreGetKerningPairs(), and NtGdiGetKerningPairs().

◆ ftGdiGetRasterizerCaps()

BOOL FASTCALL ftGdiGetRasterizerCaps ( LPRASTERIZER_STATUS  lprs)

Definition at line 3759 of file freetype.c.

3760{
3761 if ( lprs )
3762 {
3763 lprs->nSize = sizeof(RASTERIZER_STATUS);
3764 lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3765 lprs->nLanguageID = gusLanguageID;
3766 return TRUE;
3767 }
3769 return FALSE;
3770}
#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 5080 of file freetype.c.

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

5270{
5271 PDC dc;
5272 PDC_ATTR pdcattr;
5273 PTEXTOBJ TextObj;
5274 PFONTGDI FontGDI;
5275 FT_Face Face;
5276 TT_OS2 *pOS2;
5277 TT_HoriHeader *pHori;
5279 ULONG Error;
5281 LOGFONTW *plf;
5282
5283 if (!ptmwi)
5284 {
5286 return FALSE;
5287 }
5288 RtlZeroMemory(ptmwi, sizeof(TMW_INTERNAL));
5289
5290 if (!(dc = DC_LockDc(hDC)))
5291 {
5293 return FALSE;
5294 }
5295 pdcattr = dc->pdcattr;
5296 TextObj = RealizeFontInit(pdcattr->hlfntNew);
5297 if (NULL != TextObj)
5298 {
5299 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
5300 FontGDI = ObjToGDI(TextObj->Font, FONT);
5301
5302 Face = FontGDI->SharedFace->Face;
5303
5304 // NOTE: GetTextMetrics simply ignores lfEscapement and XFORM.
5306 Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
5307 FT_Set_Transform(Face, NULL, NULL);
5308
5310
5311 if (0 != Error)
5312 {
5313 DPRINT1("Error in setting pixel sizes: %u\n", Error);
5315 }
5316 else
5317 {
5319
5321 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
5322 if (NULL == pOS2)
5323 {
5324 DPRINT1("Can't find OS/2 table - not TT font?\n");
5326 }
5327
5328 pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
5329 if (NULL == pHori)
5330 {
5331 DPRINT1("Can't find HHEA table - not TT font?\n");
5333 }
5334
5335 Error = FT_Get_WinFNT_Header(Face, &Win);
5336
5337 if (NT_SUCCESS(Status) || !Error)
5338 {
5339 FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
5340
5341 /* FIXME: Fill Diff member */
5342 }
5343
5345 }
5346 TEXTOBJ_UnlockText(TextObj);
5347 }
5348 else
5349 {
5351 }
5352 DC_UnlockDc(dc);
5353
5354 if (!NT_SUCCESS(Status))
5355 {
5357 return FALSE;
5358 }
5359 return TRUE;
5360}
static HDC hDC
Definition: 3dtext.c:33
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:2773
FT_Get_WinFNT_Header(FT_Face face, FT_WinFNT_HeaderRec *aheader)
Definition: ftwinfnt.c:29
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
Definition: polytest.cpp:41
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
#define ft_sfnt_hhea
Definition: tttables.h:632
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31

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

◆ ftGdiRealizationInfo()

BOOL FASTCALL ftGdiRealizationInfo ( PFONTGDI  Font,
PREALIZATION_INFO  Info 
)

Definition at line 6363 of file freetype.c.

6364{
6365 if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
6366 Info->iTechnology = RI_TECH_BITMAP;
6367 else
6368 {
6369 if (FT_IS_SCALABLE(Font->SharedFace->Face))
6370 Info->iTechnology = RI_TECH_SCALABLE;
6371 else
6372 Info->iTechnology = RI_TECH_FIXED;
6373 }
6374 Info->iUniq = Font->FontObj.iUniq;
6375 Info->dwUnknown = -1;
6376 return TRUE;
6377}
#define FT_HAS_FIXED_SIZES(face)
Definition: freetype.h:1361
#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 5193 of file freetype.c.

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

Referenced by NtGdiGetFontUnicodeRanges().

◆ FTVectorToPOINTFX()

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

Definition at line 727 of file freetype.c.

728{
729 pt->x.value = vec->x >> 6;
730 pt->x.fract = (vec->x & 0x3f) << 10;
731 pt->x.fract |= ((pt->x.fract >> 6) | (pt->x.fract >> 12));
732 pt->y.value = vec->y >> 6;
733 pt->y.fract = (vec->y & 0x3f) << 10;
734 pt->y.fract |= ((pt->y.fract >> 6) | (pt->y.fract >> 12));
735}
#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 3962 of file freetype.c.

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

4331{
4332 FT_UInt ret;
4333
4334 if (face_has_symbol_charmap(ft_face))
4335 {
4336 ret = get_glyph_index_symbol(ft_face, glyph);
4337 if (ret != 0)
4338 return ret;
4339 }
4340
4341 return FT_Get_Char_Index(ft_face, glyph);
4342}
static FT_UInt FASTCALL get_glyph_index_symbol(FT_Face ft_face, UINT glyph)
Definition: freetype.c:4316
FT_Get_Char_Index(FT_Face face, FT_ULong charcode)
Definition: ftobjs.c:3668
int ret

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

◆ get_glyph_index_flagged()

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

Definition at line 4345 of file freetype.c.

4346{
4347 return (fCodeAsIndex ? code : get_glyph_index(face, code));
4348}

Referenced by FontLink_Chain_FindGlyph(), ftGdiGetGlyphOutline(), NtGdiGetCharABCWidthsW(), and NtGdiGetCharWidthW().

◆ get_glyph_index_symbol()

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

Definition at line 4316 of file freetype.c.

4317{
4318 FT_UInt ret;
4319
4320 if (glyph < 0x100) glyph += 0xf000;
4321 /* there are a number of old pre-Unicode "broken" TTFs, which
4322 do have symbols at U+00XX instead of U+f0XX */
4323 if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
4324 ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
4325
4326 return ret;
4327}

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

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

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

Referenced by GetFontFamilyInfoForSubstitutes(), and IntGetFontFamilyInfo().

◆ GetFontFamilyInfoForSubstitutes()

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

Definition at line 3697 of file freetype.c.

3701{
3702 PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
3703 PFONTSUBST_ENTRY pCurrentEntry;
3704 PUNICODE_STRING pFromW, pToW;
3705 LOGFONTW lf = *LogFont;
3707
3708 for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
3709 {
3710 pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
3711
3712 pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
3713 if (LogFont->lfFaceName[0] != UNICODE_NULL)
3714 {
3715 /* check name */
3716 if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
3717 continue; /* mismatch */
3718 }
3719
3720 pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
3721 if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
3722 pCurrentEntry->CharSets[FONTSUBST_FROM] ==
3723 pCurrentEntry->CharSets[FONTSUBST_TO])
3724 {
3725 /* identical mapping */
3726 continue;
3727 }
3728
3729 /* substitute and get the real name */
3730 IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
3732 if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
3733 continue;
3734
3735 /* search in global fonts */
3737 GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
3738
3739 /* search in private fonts */
3740 IntLockProcessPrivateFonts(Win32Process);
3741 GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
3742 &Win32Process->PrivateFontListHead);
3743 IntUnLockProcessPrivateFonts(Win32Process);
3745
3746 if (LogFont->lfFaceName[0] != UNICODE_NULL)
3747 {
3748 /* it's already matched to the exact name and charset if the name
3749 was specified at here, then so don't scan more for another name */
3750 break;
3751 }
3752 }
3753
3754 return TRUE;
3755}
static BOOLEAN FASTCALL GetFontFamilyInfoForList(const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LPCWSTR NominalName, LONG *pCount, LONG MaxCount, PLIST_ENTRY Head)
Definition: freetype.c:3633
static VOID IntUnicodeStringToBuffer(LPWSTR pszBuffer, SIZE_T cbBuffer, const UNICODE_STRING *pString)
Definition: freetype.c:1220
#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:148
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:151

Referenced by IntGetFontFamilyInfo().

◆ GetFontPenalty()

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

Definition at line 5406 of file freetype.c.

5409{
5410 ULONG Penalty = 0;
5411 BYTE Byte;
5412 LONG Long;
5413 BOOL fNeedScaling = FALSE;
5414 const BYTE UserCharSet = CharSetFromLangID(gusLanguageID);
5415 const TEXTMETRICW * TM = &Otm->otmTextMetrics;
5416 WCHAR* ActualNameW;
5417
5418 ASSERT(Otm);
5419 ASSERT(LogFont);
5420
5421 /* FIXME: IntSizeSynth Penalty 20 */
5422 /* FIXME: SmallPenalty Penalty 1 */
5423 /* FIXME: FaceNameSubst Penalty 500 */
5424
5425 Byte = LogFont->lfCharSet;
5426
5427 if (Byte != TM->tmCharSet)
5428 {
5430 {
5431 /* CharSet Penalty 65000 */
5432 /* Requested charset does not match the candidate's. */
5433 GOT_PENALTY("CharSet", 65000);
5434 }
5435 else
5436 {
5437 if (UserCharSet != TM->tmCharSet)
5438 {
5439 /* UNDOCUMENTED: Not user language */
5440 GOT_PENALTY("UNDOCUMENTED:NotUserLanguage", 100);
5441
5442 if (ANSI_CHARSET != TM->tmCharSet)
5443 {
5444 /* UNDOCUMENTED: Not ANSI charset */
5445 GOT_PENALTY("UNDOCUMENTED:NotAnsiCharSet", 100);
5446 }
5447 }
5448 }
5449 }
5450
5451 Byte = LogFont->lfOutPrecision;
5452 switch (Byte)
5453 {
5454 case OUT_DEFAULT_PRECIS:
5455 /* nothing to do */
5456 break;
5457 case OUT_DEVICE_PRECIS:
5458 if (!(TM->tmPitchAndFamily & TMPF_DEVICE) ||
5460 {
5461 /* OutputPrecision Penalty 19000 */
5462 /* Requested OUT_STROKE_PRECIS, but the device can't do it
5463 or the candidate is not a vector font. */
5464 GOT_PENALTY("OutputPrecision", 19000);
5465 }
5466 break;
5467 default:
5469 {
5470 /* OutputPrecision Penalty 19000 */
5471 /* Or OUT_STROKE_PRECIS not requested, and the candidate
5472 is a vector font that requires GDI support. */
5473 GOT_PENALTY("OutputPrecision", 19000);
5474 }
5475 break;
5476 }
5477
5478 Byte = (LogFont->lfPitchAndFamily & 0x0F);
5479 if (Byte == DEFAULT_PITCH)
5481 if (Byte == FIXED_PITCH)
5482 {
5484 {
5485 /* FixedPitch Penalty 15000 */
5486 /* Requested a fixed pitch font, but the candidate is a
5487 variable pitch font. */
5488 GOT_PENALTY("FixedPitch", 15000);
5489 }
5490 }
5491 if (Byte == VARIABLE_PITCH)
5492 {
5494 {
5495 /* PitchVariable Penalty 350 */
5496 /* Requested a variable pitch font, but the candidate is not a
5497 variable pitch font. */
5498 GOT_PENALTY("PitchVariable", 350);
5499 }
5500 }
5501
5502 Byte = (LogFont->lfPitchAndFamily & 0x0F);
5503 if (Byte == DEFAULT_PITCH)
5504 {
5506 {
5507 /* DefaultPitchFixed Penalty 1 */
5508 /* Requested DEFAULT_PITCH, but the candidate is fixed pitch. */
5509 GOT_PENALTY("DefaultPitchFixed", 1);
5510 }
5511 }
5512
5513 ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
5514
5515 if (LogFont->lfFaceName[0] != UNICODE_NULL)
5516 {
5517 BOOL Found = FALSE;
5518
5519 /* localized family name */
5520 if (!Found)
5521 {
5522 Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
5523 }
5524 /* localized full name */
5525 if (!Found)
5526 {
5527 ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFaceName);
5528 Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
5529 }
5530 if (!Found)
5531 {
5532 /* FaceName Penalty 10000 */
5533 /* Requested a face name, but the candidate's face name
5534 does not match. */
5535 GOT_PENALTY("FaceName", 10000);
5536 }
5537 }
5538
5539 Byte = (LogFont->lfPitchAndFamily & 0xF0);
5540 if (Byte != FF_DONTCARE)
5541 {
5542 if (Byte != (TM->tmPitchAndFamily & 0xF0))
5543 {
5544 /* Family Penalty 9000 */
5545 /* Requested a family, but the candidate's family is different. */
5546 GOT_PENALTY("Family", 9000);
5547 }
5548 }
5549
5550 if ((TM->tmPitchAndFamily & 0xF0) == FF_DONTCARE)
5551 {
5552 /* FamilyUnknown Penalty 8000 */
5553 /* Requested a family, but the candidate has no family. */
5554 GOT_PENALTY("FamilyUnknown", 8000);
5555 }
5556
5557 /* Is the candidate a non-vector font? */
5559 {
5560 /* Is lfHeight specified? */
5561 if (LogFont->lfHeight != 0)
5562 {
5563 if (labs(LogFont->lfHeight) < TM->tmHeight)
5564 {
5565 /* HeightBigger Penalty 600 */
5566 /* The candidate is a nonvector font and is bigger than the
5567 requested height. */
5568 GOT_PENALTY("HeightBigger", 600);
5569 /* HeightBiggerDifference Penalty 150 */
5570 /* The candidate is a raster font and is larger than the
5571 requested height. Penalty * height difference */
5572 GOT_PENALTY("HeightBiggerDifference", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
5573
5574 fNeedScaling = TRUE;
5575 }
5576 if (TM->tmHeight < labs(LogFont->lfHeight))
5577 {
5578 /* HeightSmaller Penalty 150 */
5579 /* The candidate is a raster font and is smaller than the
5580 requested height. Penalty * height difference */
5581 GOT_PENALTY("HeightSmaller", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
5582
5583 fNeedScaling = TRUE;
5584 }
5585 }
5586 }
5587
5588 switch (LogFont->lfPitchAndFamily & 0xF0)
5589 {
5590 case FF_ROMAN: case FF_MODERN: case FF_SWISS:
5591 switch (TM->tmPitchAndFamily & 0xF0)
5592 {
5593 case FF_DECORATIVE: case FF_SCRIPT:
5594 /* FamilyUnlikely Penalty 50 */
5595 /* Requested a roman/modern/swiss family, but the
5596 candidate is decorative/script. */
5597 GOT_PENALTY("FamilyUnlikely", 50);
5598 break;
5599 default:
5600 break;
5601 }
5602 break;
5603 case FF_DECORATIVE: case FF_SCRIPT:
5604 switch (TM->tmPitchAndFamily & 0xF0)
5605 {
5606 case FF_ROMAN: case FF_MODERN: case FF_SWISS:
5607 /* FamilyUnlikely Penalty 50 */
5608 /* Or requested decorative/script, and the candidate is
5609 roman/modern/swiss. */
5610 GOT_PENALTY("FamilyUnlikely", 50);
5611 break;
5612 default:
5613 break;
5614 }
5615 default:
5616 break;
5617 }
5618
5619 if (LogFont->lfWidth != 0)
5620 {
5621 if (LogFont->lfWidth != TM->tmAveCharWidth)
5622 {
5623 /* Width Penalty 50 */
5624 /* Requested a nonzero width, but the candidate's width
5625 doesn't match. Penalty * width difference */
5626 GOT_PENALTY("Width", 50 * labs(LogFont->lfWidth - TM->tmAveCharWidth));
5627
5629 fNeedScaling = TRUE;
5630 }
5631 }
5632
5633 if (fNeedScaling)
5634 {
5635 /* SizeSynth Penalty 50 */
5636 /* The candidate is a raster font that needs scaling by GDI. */
5637 GOT_PENALTY("SizeSynth", 50);
5638 }
5639
5640 if (!LogFont->lfItalic && TM->tmItalic)
5641 {
5642 /* Italic Penalty 4 */
5643 /* Requested font and candidate font do not agree on italic status,
5644 and the desired result cannot be simulated. */
5645 /* Adjusted to 40 to satisfy (Oblique Penalty > Book Penalty). */
5646 GOT_PENALTY("Italic", 40);
5647 }
5648 else if (LogFont->lfItalic && !TM->tmItalic)
5649 {
5650 /* ItalicSim Penalty 1 */
5651 /* Requested italic font but the candidate is not italic,
5652 although italics can be simulated. */
5653 GOT_PENALTY("ItalicSim", 1);
5654 }
5655
5656 if (LogFont->lfOutPrecision == OUT_TT_PRECIS)
5657 {
5658 if (!(TM->tmPitchAndFamily & TMPF_TRUETYPE))
5659 {
5660 /* NotTrueType Penalty 4 */
5661 /* Requested OUT_TT_PRECIS, but the candidate is not a
5662 TrueType font. */
5663 GOT_PENALTY("NotTrueType", 4);
5664 }
5665 }
5666
5667 Long = LogFont->lfWeight;
5668 if (LogFont->lfWeight == FW_DONTCARE)
5669 Long = FW_NORMAL;
5670 if (Long != TM->tmWeight)
5671 {
5672 /* Weight Penalty 3 */
5673 /* The candidate's weight does not match the requested weight.
5674 Penalty * (weight difference/10) */
5675 GOT_PENALTY("Weight", 3 * (labs(Long - TM->tmWeight) / 10));
5676 }
5677
5678 if (!LogFont->lfUnderline && TM->tmUnderlined)
5679 {
5680 /* Underline Penalty 3 */
5681 /* Requested font has no underline, but the candidate is
5682 underlined. */
5683 GOT_PENALTY("Underline", 3);
5684 }
5685
5686 if (!LogFont->lfStrikeOut && TM->tmStruckOut)
5687 {
5688 /* StrikeOut Penalty 3 */
5689 /* Requested font has no strike-out, but the candidate is
5690 struck out. */
5691 GOT_PENALTY("StrikeOut", 3);
5692 }
5693
5694 /* Is the candidate a non-vector font? */
5696 {
5697 if (LogFont->lfHeight != 0 && TM->tmHeight < LogFont->lfHeight)
5698 {
5699 /* VectorHeightSmaller Penalty 2 */
5700 /* Candidate is a vector font that is smaller than the
5701 requested height. Penalty * height difference */
5702 GOT_PENALTY("VectorHeightSmal