ReactOS 0.4.15-dev-8061-g57b775e
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  FONT_NAMES
 

Macros

#define FT_INTERNAL_INTERNAL_H   <freetype/internal/internal.h>
 
#define NDEBUG
 
#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 IntLockGlobalFonts()    ExEnterCriticalRegionAndAcquireFastMutexUnsafe(g_FontListLock)
 
#define IntUnLockGlobalFonts()    ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(g_FontListLock)
 
#define ASSERT_GLOBALFONTS_LOCK_HELD()    ASSERT(g_FontListLock->Owner == KeGetCurrentThread())
 
#define IntLockFreeType()    ExEnterCriticalRegionAndAcquireFastMutexUnsafe(g_FreeTypeLock)
 
#define IntUnLockFreeType()    ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(g_FreeTypeLock)
 
#define ASSERT_FREETYPE_LOCK_HELD()    ASSERT(g_FreeTypeLock->Owner == KeGetCurrentThread())
 
#define ASSERT_FREETYPE_LOCK_NOT_HELD()    ASSERT(g_FreeTypeLock->Owner != KeGetCurrentThread())
 
#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 FONT_NAMES FONT_NAMES
 
typedef struct FONT_NAMESLPFONT_NAMES
 

Functions

static DWORD Utf32FromSurrogatePair (DWORD ch0, DWORD ch1)
 
BYTE FASTCALL IntCharSetFromCodePage (UINT uCodePage)
 
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)
 
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 (LOGFONTW *pLogFont)
 
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)
 
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, DWORD indexed_flag, DWORD flags)
 
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 __inline VOID FindBestFontFromList (FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
 
static VOID FASTCALL IntFontType (PFONTGDI Font)
 
static BOOL MatchFontName (PSHARED_FACE SharedFace, PUNICODE_STRING Name1, FT_UShort NameID, FT_UShort LangID)
 
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)
 
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

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 LIST_ENTRY g_FontListHead
 
static PFAST_MUTEX g_FontListLock
 
static BOOL g_RenderingEnabled = TRUE
 
static LIST_ENTRY g_FontCacheListHead
 
static UINT g_FontCacheNumEntries
 
static PWCHAR g_ElfScripts [32]
 
static const CHARSETINFO g_FontTci [MAXTCIINDEX]
 

Macro Definition Documentation

◆ _TMPF_VARIABLE_PITCH

#define _TMPF_VARIABLE_PITCH   TMPF_FIXED_PITCH

Definition at line 55 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_HELD

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

Definition at line 100 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_NOT_HELD

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

Definition at line 103 of file freetype.c.

◆ ASSERT_GLOBALFONTS_LOCK_HELD

#define ASSERT_GLOBALFONTS_LOCK_HELD ( )     ASSERT(g_FontListLock->Owner == KeGetCurrentThread())

Definition at line 91 of file freetype.c.

◆ CP_MACCP

#define CP_MACCP   2

Definition at line 182 of file freetype.c.

◆ CP_OEMCP

#define CP_OEMCP   1

Definition at line 181 of file freetype.c.

◆ CP_SYMBOL

#define CP_SYMBOL   42

Definition at line 137 of file freetype.c.

◆ EMUBOLD_NEEDED

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

Definition at line 59 of file freetype.c.

◆ FM_SEL_USE_TYPO_METRICS

#define FM_SEL_USE_TYPO_METRICS   0x80

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

◆ GOT_PENALTY

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

Definition at line 4653 of file freetype.c.

◆ HIGH_SURROGATE_MAX

#define HIGH_SURROGATE_MAX   0xDBFFU

Definition at line 40 of file freetype.c.

◆ HIGH_SURROGATE_MIN

#define HIGH_SURROGATE_MIN   0xD800U

Definition at line 39 of file freetype.c.

◆ IntLockFreeType

Definition at line 94 of file freetype.c.

◆ IntLockGlobalFonts

Definition at line 85 of file freetype.c.

◆ IntUnLockFreeType

Definition at line 97 of file freetype.c.

◆ IntUnLockGlobalFonts

Definition at line 88 of file freetype.c.

◆ IS_HIGH_SURROGATE

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

Definition at line 44 of file freetype.c.

◆ IS_LOW_SURROGATE

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

Definition at line 45 of file freetype.c.

◆ LOW_SURROGATE_MAX

#define LOW_SURROGATE_MAX   0xDFFFU

Definition at line 42 of file freetype.c.

◆ LOW_SURROGATE_MIN

#define LOW_SURROGATE_MIN   0xDC00U

Definition at line 41 of file freetype.c.

◆ MAX_FONT_CACHE

#define MAX_FONT_CACHE   256

Definition at line 106 of file freetype.c.

◆ MAXTCIINDEX

#define MAXTCIINDEX   32

Definition at line 138 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 1062 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 6561 of file freetype.c.

◆ VALIGN_MASK

#define VALIGN_MASK   (TA_TOP | TA_BASELINE | TA_BOTTOM)

Typedef Documentation

◆ FONT_NAMES

◆ LPFONT_NAMES

Function Documentation

◆ CharSetFromLangID()

static BYTE CharSetFromLangID ( LANGID  LangID)
static

Definition at line 2560 of file freetype.c.

2561{
2562 /* FIXME: Add more and fix if wrong */
2563 switch (PRIMARYLANGID(LangID))
2564 {
2565 case LANG_CHINESE:
2566 switch (SUBLANGID(LangID))
2567 {
2569 return CHINESEBIG5_CHARSET;
2571 default:
2572 break;
2573 }
2574 return GB2312_CHARSET;
2575
2576 case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
2577 case LANG_SLOVAK: case LANG_SLOVENIAN: case LANG_ROMANIAN:
2578 return EASTEUROPE_CHARSET;
2579
2581 case LANG_SERBIAN: case LANG_UKRAINIAN:
2582 return RUSSIAN_CHARSET;
2583
2584 case LANG_ARABIC: return ARABIC_CHARSET;
2585 case LANG_GREEK: return GREEK_CHARSET;
2586 case LANG_HEBREW: return HEBREW_CHARSET;
2587 case LANG_JAPANESE: return SHIFTJIS_CHARSET;
2588 case LANG_KOREAN: return JOHAB_CHARSET;
2589 case LANG_TURKISH: return TURKISH_CHARSET;
2590 case LANG_THAI: return THAI_CHARSET;
2591 case LANG_LATVIAN: return BALTIC_CHARSET;
2593
2594 case LANG_ENGLISH: case LANG_BASQUE: case LANG_CATALAN:
2595 case LANG_DANISH: case LANG_DUTCH: case LANG_FINNISH:
2596 case LANG_FRENCH: case LANG_GERMAN: case LANG_ITALIAN:
2598 case LANG_SWEDISH: default:
2599 return ANSI_CHARSET;
2600 }
2601}
#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 377 of file freetype.c.

378{
379 CleanupFontEntryEx(FontEntry, FontEntry->Font);
380}
static VOID FASTCALL CleanupFontEntryEx(PFONT_ENTRY FontEntry, PFONTGDI FontGDI)
Definition: freetype.c:357
FONTGDI * Font
Definition: font.h:7

Referenced by IntGdiCleanupMemEntry(), and IntGdiCleanupPrivateFontsForProcess().

◆ CleanupFontEntryEx()

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

Definition at line 357 of file freetype.c.

358{
359 // PFONTGDI FontGDI = FontEntry->Font;
360 PSHARED_FACE SharedFace = FontGDI->SharedFace;
361
362 if (FontGDI->Filename)
364
365 if (FontEntry->StyleName.Buffer)
366 RtlFreeUnicodeString(&FontEntry->StyleName);
367
368 if (FontEntry->FaceName.Buffer)
369 RtlFreeUnicodeString(&FontEntry->FaceName);
370
371 EngFreeMem(FontGDI);
372 SharedFace_Release(SharedFace);
373 ExFreePoolWithTag(FontEntry, TAG_FONT);
374}
static void SharedFace_Release(PSHARED_FACE Ptr)
Definition: freetype.c:333
#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 845 of file freetype.c.

846{
848 UNICODE_STRING Tmp;
849
850 Tmp.Buffer = ExAllocatePoolWithTag(PagedPool, Source->MaximumLength, TAG_USTR);
851 if (Tmp.Buffer)
852 {
853 Tmp.MaximumLength = Source->MaximumLength;
854 Tmp.Length = 0;
856
860
862 }
863
864 return Status;
865}
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:3004
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 5309 of file freetype.c.

5310{
5311 const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5312 const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5313 const LOGFONTW *plf1 = &pLog1->elfLogFont;
5314 const LOGFONTW *plf2 = &pLog2->elfLogFont;
5315
5316 if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5317 {
5318 return FALSE;
5319 }
5320
5321 if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5322 {
5323 return FALSE;
5324 }
5325
5326 return TRUE;
5327}
#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 2095 of file freetype.c.

2096{
2097 int i;
2098
2099 for(i = 0; i < ft_face->num_charmaps; i++)
2100 {
2101 if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
2102 ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
2103 {
2104 return TRUE;
2105 }
2106 }
2107 return FALSE;
2108}
#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 2111 of file freetype.c.

2114{
2115 FT_Fixed XScale, YScale;
2116 int Ascent, Descent;
2117 FT_Face Face = FontGDI->SharedFace->Face;
2118
2120
2121 XScale = Face->size->metrics.x_scale;
2122 YScale = Face->size->metrics.y_scale;
2123
2124 if (pFNT)
2125 {
2126 TM->tmHeight = pFNT->pixel_height;
2127 TM->tmAscent = pFNT->ascent;
2128 TM->tmDescent = TM->tmHeight - TM->tmAscent;
2131 TM->tmAveCharWidth = pFNT->avg_width;
2132 TM->tmMaxCharWidth = pFNT->max_width;
2133 TM->tmOverhang = 0;
2136 TM->tmFirstChar = pFNT->first_char;
2137 TM->tmLastChar = pFNT->last_char;
2138 TM->tmDefaultChar = pFNT->default_char + pFNT->first_char;
2139 TM->tmBreakChar = pFNT->break_char + pFNT->first_char;
2141 TM->tmWeight = FontGDI->RequestWeight;
2142 TM->tmItalic = FontGDI->RequestItalic;
2143 TM->tmUnderlined = FontGDI->RequestUnderline;
2144 TM->tmStruckOut = FontGDI->RequestStrikeOut;
2145 TM->tmCharSet = FontGDI->CharSet;
2146 return;
2147 }
2148
2149 ASSERT(pOS2);
2150 if (!pOS2)
2151 return;
2152
2153 if ((FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent == 0)
2154 {
2155 Ascent = pHori->Ascender;
2156 Descent = -pHori->Descender;
2157 }
2158 else
2159 {
2160 Ascent = (FT_Short)pOS2->usWinAscent;
2161 Descent = (FT_Short)pOS2->usWinDescent;
2162 }
2163
2164 TM->tmAscent = FontGDI->tmAscent;
2165 TM->tmDescent = FontGDI->tmDescent;
2166 TM->tmHeight = TM->tmAscent + TM->tmDescent;
2167 TM->tmInternalLeading = FontGDI->tmInternalLeading;
2168
2169 /* MSDN says:
2170 * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
2171 */
2172 TM->tmExternalLeading = max(0, (FT_MulFix(pHori->Line_Gap
2173 - ((Ascent + Descent)
2174 - (pHori->Ascender - pHori->Descender)),
2175 YScale) + 32) >> 6);
2176 if (FontGDI->lfWidth != 0)
2177 TM->tmAveCharWidth = FontGDI->lfWidth;
2178 else
2179 TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
2180
2181 if (TM->tmAveCharWidth == 0)
2182 TM->tmAveCharWidth = 1;
2183
2184 /* Correct forumla to get the maxcharwidth from unicode and ansi font */
2185 TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
2186
2187 if (FontGDI->OriginalWeight != FW_DONTCARE &&
2188 FontGDI->OriginalWeight != FW_NORMAL)
2189 {
2190 TM->tmWeight = FontGDI->OriginalWeight;
2191 }
2192 else
2193 {
2194 TM->tmWeight = FontGDI->RequestWeight;
2195 }
2196
2197 TM->tmOverhang = 0;
2198 TM->tmDigitizedAspectX = 96;
2199 TM->tmDigitizedAspectY = 96;
2200 if (face_has_symbol_charmap(Face) ||
2201 (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
2202 {
2203 USHORT cpOEM, cpAnsi;
2204
2205 EngGetCurrentCodePage(&cpOEM, &cpAnsi);
2206 TM->tmFirstChar = 0;
2207 switch(cpAnsi)
2208 {
2209 case 1257: /* Baltic */
2210 TM->tmLastChar = 0xf8fd;
2211 break;
2212 default:
2213 TM->tmLastChar = 0xf0ff;
2214 }
2215 TM->tmBreakChar = 0x20;
2216 TM->tmDefaultChar = 0x1f;
2217 }
2218 else
2219 {
2220 TM->tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
2221 TM->tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
2222
2223 if(pOS2->usFirstCharIndex <= 1)
2224 TM->tmBreakChar = pOS2->usFirstCharIndex + 2;
2225 else if (pOS2->usFirstCharIndex > 0xff)
2226 TM->tmBreakChar = 0x20;
2227 else
2228 TM->tmBreakChar = pOS2->usFirstCharIndex;
2229 TM->tmDefaultChar = TM->tmBreakChar - 1;
2230 }
2231
2232 if (FontGDI->OriginalItalic || FontGDI->RequestItalic)
2233 {
2234 TM->tmItalic = 0xFF;
2235 }
2236 else
2237 {
2238 TM->tmItalic = 0;
2239 }
2240 TM->tmUnderlined = (FontGDI->RequestUnderline ? 0xFF : 0);
2241 TM->tmStruckOut = (FontGDI->RequestStrikeOut ? 0xFF : 0);
2242
2243 if (!FT_IS_FIXED_WIDTH(Face))
2244 {
2245 switch (pOS2->panose[PAN_PROPORTION_INDEX])
2246 {
2248 TM->tmPitchAndFamily = 0;
2249 break;
2250 default:
2252 break;
2253 }
2254 }
2255 else
2256 {
2257 TM->tmPitchAndFamily = 0;
2258 }
2259
2260 switch (pOS2->panose[PAN_FAMILYTYPE_INDEX])
2261 {
2262 case PAN_FAMILY_SCRIPT:
2264 break;
2267 break;
2268
2269 case PAN_ANY:
2270 case PAN_NO_FIT:
2272 case PAN_FAMILY_PICTORIAL: /* Symbol fonts get treated as if they were text */
2273 /* Which is clearly not what the panose spec says. */
2274 if (TM->tmPitchAndFamily == 0) /* Fixed */
2275 {
2277 }
2278 else
2279 {
2280 switch (pOS2->panose[PAN_SERIFSTYLE_INDEX])
2281 {
2282 case PAN_ANY:
2283 case PAN_NO_FIT:
2284 default:
2286 break;
2287
2288 case PAN_SERIF_COVE:
2292 case PAN_SERIF_SQUARE:
2293 case PAN_SERIF_THIN:
2294 case PAN_SERIF_BONE:
2296 case PAN_SERIF_TRIANGLE:
2298 break;
2299
2303 case PAN_SERIF_FLARED:
2304 case PAN_SERIF_ROUNDED:
2306 break;
2307 }
2308 }
2309 break;
2310 default:
2312 }
2313
2314 if (FT_IS_SCALABLE(Face))
2315 {
2317 }
2318 if (FT_IS_SFNT(Face))
2319 {
2321 }
2322
2323 TM->tmCharSet = FontGDI->CharSet;
2324}
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2095
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:100
#define _TMPF_VARIABLE_PITCH
Definition: freetype.c:55
#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 5003 of file freetype.c.

5006{
5007 ULONG Penalty;
5009 PFONT_ENTRY CurrentEntry;
5010 FONTGDI *FontGDI;
5011 OUTLINETEXTMETRICW *Otm = NULL;
5012 UINT OtmSize, OldOtmSize = 0;
5013 FT_Face Face;
5014
5015 ASSERT(FontObj);
5016 ASSERT(MatchPenalty);
5017 ASSERT(LogFont);
5018 ASSERT(Head);
5019
5020 /* Start with a pretty big buffer */
5021 OldOtmSize = 0x200;
5022 Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5023
5024 /* get the FontObj of lowest penalty */
5025 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5026 {
5027 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5028
5029 FontGDI = CurrentEntry->Font;
5030 ASSERT(FontGDI);
5031 Face = FontGDI->SharedFace->Face;
5032
5033 /* get text metrics */
5034 OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
5035 if (OtmSize > OldOtmSize)
5036 {
5037 if (Otm)
5040 }
5041
5042 /* update FontObj if lowest penalty */
5043 if (Otm)
5044 {
5046 IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5048
5049 OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm);
5050 if (!OtmSize)
5051 continue;
5052
5053 OldOtmSize = OtmSize;
5054
5055 Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5056 if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty)
5057 {
5058 *FontObj = GDIToObj(FontGDI, FONT);
5059 *MatchPenalty = Penalty;
5060 }
5061 }
5062 }
5063
5064 if (Otm)
5066}
#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:4657
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3416
#define IntUnLockFreeType()
Definition: freetype.c:97
#define IntLockFreeType()
Definition: freetype.c:94
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2413
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 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 TextIntRealizeFont().

◆ FontFamilyFillInfo()

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

Definition at line 2778 of file freetype.c.

2780{
2781 ANSI_STRING StyleA;
2782 UNICODE_STRING StyleW;
2783 TT_OS2 *pOS2;
2785 CHARSETINFO CharSetInfo;
2786 unsigned i, Size;
2787 OUTLINETEXTMETRICW *Otm;
2788 LOGFONTW *Lf;
2789 TEXTMETRICW *TM;
2790 NEWTEXTMETRICW *Ntm;
2791 DWORD fs0;
2793 PSHARED_FACE SharedFace = FontGDI->SharedFace;
2794 FT_Face Face = SharedFace->Face;
2795 UNICODE_STRING NameW;
2796
2797 RtlInitUnicodeString(&NameW, NULL);
2799 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
2801 if (!Otm)
2802 {
2803 return;
2804 }
2805 Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm);
2806 if (!Size)
2807 {
2809 return;
2810 }
2811
2812 Lf = &Info->EnumLogFontEx.elfLogFont;
2813 TM = &Otm->otmTextMetrics;
2814
2815 Lf->lfHeight = TM->tmHeight;
2816 Lf->lfWidth = TM->tmAveCharWidth;
2817 Lf->lfWeight = TM->tmWeight;
2818 Lf->lfItalic = TM->tmItalic;
2819 Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
2820 Lf->lfCharSet = TM->tmCharSet;
2824
2825 Ntm = &Info->NewTextMetricEx.ntmTm;
2826 Ntm->tmHeight = TM->tmHeight;
2827 Ntm->tmAscent = TM->tmAscent;
2828 Ntm->tmDescent = TM->tmDescent;
2831 Ntm->tmAveCharWidth = TM->tmAveCharWidth;
2832 Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
2833 Ntm->tmWeight = TM->tmWeight;
2834 Ntm->tmOverhang = TM->tmOverhang;
2837 Ntm->tmFirstChar = TM->tmFirstChar;
2838 Ntm->tmLastChar = TM->tmLastChar;
2839 Ntm->tmDefaultChar = TM->tmDefaultChar;
2840 Ntm->tmBreakChar = TM->tmBreakChar;
2841 Ntm->tmItalic = TM->tmItalic;
2842 Ntm->tmUnderlined = TM->tmUnderlined;
2843 Ntm->tmStruckOut = TM->tmStruckOut;
2845 Ntm->tmCharSet = TM->tmCharSet;
2846 Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
2847
2848 if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
2849
2850 if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
2851
2852 Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
2853 ? TRUETYPE_FONTTYPE : 0);
2854
2855 if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
2856 Info->FontType |= RASTER_FONTTYPE;
2857
2858
2859 /* face name */
2860 if (!FaceName)
2861 FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
2862
2863 RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
2864
2865 /* full name */
2866 if (!FullName)
2867 FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
2868
2869 RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
2870 sizeof(Info->EnumLogFontEx.elfFullName),
2871 FullName);
2872
2873 RtlInitAnsiString(&StyleA, Face->style_name);
2874 StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
2875 StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
2876 status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
2877 if (!NT_SUCCESS(status))
2878 {
2880 return;
2881 }
2882 Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
2883
2885 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
2886
2887 if (!pOS2)
2888 {
2891 return;
2892 }
2893
2894 Ntm->ntmSizeEM = Otm->otmEMSquare;
2896 Ntm->ntmAvgWidth = 0;
2897
2899
2900 fs.fsCsb[0] = pOS2->ulCodePageRange1;
2901 fs.fsCsb[1] = pOS2->ulCodePageRange2;
2902 fs.fsUsb[0] = pOS2->ulUnicodeRange1;
2903 fs.fsUsb[1] = pOS2->ulUnicodeRange2;
2904 fs.fsUsb[2] = pOS2->ulUnicodeRange3;
2905 fs.fsUsb[3] = pOS2->ulUnicodeRange4;
2906
2907 if (0 == pOS2->version)
2908 {
2909 FT_UInt Dummy;
2910
2911 if (FT_Get_First_Char(Face, &Dummy) < 0x100)
2912 fs.fsCsb[0] |= FS_LATIN1;
2913 else
2914 fs.fsCsb[0] |= FS_SYMBOL;
2915 }
2917
2918 if (fs.fsCsb[0] == 0)
2919 {
2920 /* Let's see if we can find any interesting cmaps */
2921 for (i = 0; i < (UINT)Face->num_charmaps; i++)
2922 {
2923 switch (Face->charmaps[i]->encoding)
2924 {
2925 case FT_ENCODING_UNICODE:
2926 case FT_ENCODING_APPLE_ROMAN:
2927 fs.fsCsb[0] |= FS_LATIN1;
2928 break;
2929 case FT_ENCODING_MS_SYMBOL:
2930 fs.fsCsb[0] |= FS_SYMBOL;
2931 break;
2932 default:
2933 break;
2934 }
2935 }
2936 }
2937
2938 for (i = 0; i < MAXTCIINDEX; i++)
2939 {
2940 fs0 = 1L << i;
2941 if (fs.fsCsb[0] & fs0)
2942 {
2943 if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
2944 {
2945 CharSetInfo.ciCharset = DEFAULT_CHARSET;
2946 }
2947 if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
2948 {
2949 if (g_ElfScripts[i])
2950 wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
2951 else
2952 {
2953 DPRINT1("Unknown elfscript for bit %u\n", i);
2954 }
2955 }
2956 }
2957 }
2958 Info->NewTextMetricEx.ntmFontSig = fs;
2959}
#define DPRINT1
Definition: precomp.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ULONG_PTR
Definition: config.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
static PWCHAR g_ElfScripts[32]
Definition: freetype.c:111
#define MAXTCIINDEX
Definition: freetype.c:138
static BOOLEAN IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2048
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().

◆ FT_FixedFromFIXED()

static __inline FT_Fixed FT_FixedFromFIXED ( FIXED  f)
static

Definition at line 397 of file freetype.c.

398{
399 return (FT_Fixed)((long)f.value << 16 | (unsigned long)f.fract);
400}
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 4615 of file freetype.c.

4621{
4623 FT_Face Face = FontGdi->SharedFace->Face;
4624
4626
4627 if (FT_IS_SFNT(Face))
4628 {
4629 if (Table)
4630 Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
4631 (Table << 8 & 0xFF0000);
4632
4633 if (!Buffer) Size = 0;
4634
4635 if (Buffer && Size)
4636 {
4638 FT_ULong Needed = 0;
4639
4640 Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
4641
4642 if ( !Error && Needed < Size) Size = Needed;
4643 }
4644 if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
4645 Result = Size;
4646 }
4647
4649
4650 return Result;
4651}
BOOL Error
Definition: chkdsk.c:66
Definition: bufpool.h:45
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 3694 of file freetype.c.

3703{
3704 PDC_ATTR pdcattr;
3705 PTEXTOBJ TextObj;
3706 PFONTGDI FontGDI;
3707 HFONT hFont = 0;
3708 GLYPHMETRICS gm;
3709 ULONG Size;
3710 FT_Face ft_face;
3711 FT_UInt glyph_index;
3712 DWORD width, height, pitch, needed = 0;
3713 FT_Bitmap ft_bitmap;
3715 INT left, right, top = 0, bottom = 0;
3717 FLOATOBJ eM11, widthRatio, eTemp;
3718 FT_Matrix mat, transMat = identityMat;
3719 BOOL needsTransform = FALSE;
3720 INT orientation;
3721 LONG aveWidth;
3722 INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
3723 OUTLINETEXTMETRICW *potm;
3724 XFORMOBJ xo;
3725 XFORML xform;
3726 LOGFONTW *plf;
3727
3728 DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
3729 cjBuf, pvBuf, pmat2);
3730
3731 pdcattr = dc->pdcattr;
3732
3733 XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
3734 XFORMOBJ_iGetXform(&xo, &xform);
3735 FLOATOBJ_SetFloat(&eM11, xform.eM11);
3736
3737 hFont = pdcattr->hlfntNew;
3738 TextObj = RealizeFontInit(hFont);
3739
3740 if (!TextObj)
3741 {
3743 return GDI_ERROR;
3744 }
3745 FontGDI = ObjToGDI(TextObj->Font, FONT);
3746 ft_face = FontGDI->SharedFace->Face;
3747
3748 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
3749 aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
3750 orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
3751
3752 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
3754 if (!potm)
3755 {
3757 TEXTOBJ_UnlockText(TextObj);
3758 return GDI_ERROR;
3759 }
3760 Size = IntGetOutlineTextMetrics(FontGDI, Size, potm);
3761 if (!Size)
3762 {
3763 /* FIXME: last error? */
3765 TEXTOBJ_UnlockText(TextObj);
3766 return GDI_ERROR;
3767 }
3768
3770 TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
3772 FT_Set_Transform(ft_face, &mat, NULL);
3773
3774 TEXTOBJ_UnlockText(TextObj);
3775
3776 glyph_index = get_glyph_index_flagged(ft_face, wch, GGO_GLYPH_INDEX, iFormat);
3777 iFormat &= ~GGO_GLYPH_INDEX;
3778
3779 if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
3780 load_flags |= FT_LOAD_NO_BITMAP;
3781
3782 if (iFormat & GGO_UNHINTED)
3783 {
3784 load_flags |= FT_LOAD_NO_HINTING;
3785 iFormat &= ~GGO_UNHINTED;
3786 }
3787
3788 error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
3789 if (error)
3790 {
3791 DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
3793 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
3794 return GDI_ERROR;
3795 }
3797
3798 FLOATOBJ_Set1(&widthRatio);
3799 if (aveWidth && potm)
3800 {
3801 // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
3802 FLOATOBJ_SetLong(&widthRatio, aveWidth);
3803 FLOATOBJ_Mul(&widthRatio, &eM11);
3805 }
3806
3807 //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
3808 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
3809 FLOATOBJ_Mul(&eTemp, &widthRatio);
3810 left = FLOATOBJ_GetLong(&eTemp) & -64;
3811
3812 //right = (INT)((ft_face->glyph->metrics.horiBearingX +
3813 // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
3814 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
3815 FLOATOBJ_Mul(&eTemp, &widthRatio);
3816 FLOATOBJ_AddLong(&eTemp, 63);
3817 right = FLOATOBJ_GetLong(&eTemp) & -64;
3818
3819 //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
3820 FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
3821 FLOATOBJ_Mul(&eTemp, &widthRatio);
3822 FLOATOBJ_AddLong(&eTemp, 63);
3823 adv = FLOATOBJ_GetLong(&eTemp) >> 6;
3824
3825 lsb = left >> 6;
3826 bbx = (right - left) >> 6;
3827
3828 DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
3829
3831
3832 /* Width scaling transform */
3833 if (!FLOATOBJ_Equal1(&widthRatio))
3834 {
3835 FT_Matrix scaleMat;
3836
3837 eTemp = widthRatio;
3838 FLOATOBJ_MulLong(&eTemp, 1 << 16);
3839
3840 scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
3841 scaleMat.xy = 0;
3842 scaleMat.yx = 0;
3843 scaleMat.yy = INT_TO_FIXED(1);
3844 FT_Matrix_Multiply(&scaleMat, &transMat);
3845 needsTransform = TRUE;
3846 }
3847
3848 /* World transform */
3849 {
3850 FT_Matrix ftmatrix;
3852
3853 /* Create a freetype matrix, by converting to 16.16 fixpoint format */
3854 IntMatrixFromMx(&ftmatrix, pmx);
3855
3856 if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
3857 {
3858 FT_Matrix_Multiply(&ftmatrix, &transMat);
3859 needsTransform = TRUE;
3860 }
3861 }
3862
3863 /* Rotation transform */
3864 if (orientation)
3865 {
3866 FT_Matrix rotationMat;
3867 DPRINT("Rotation Trans!\n");
3868 IntEscapeMatrix(&rotationMat, orientation);
3869 FT_Matrix_Multiply(&rotationMat, &transMat);
3870 needsTransform = TRUE;
3871 }
3872
3873 /* Extra transformation specified by caller */
3874 if (pmat2)
3875 {
3876 FT_Matrix extraMat;
3877 DPRINT("MAT2 Matrix Trans!\n");
3878 extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
3879 extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
3880 extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
3881 extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
3882 FT_Matrix_Multiply(&extraMat, &transMat);
3883 needsTransform = TRUE;
3884 }
3885
3886 if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
3887
3888 if (!needsTransform)
3889 {
3890 DPRINT("No Need to be Transformed!\n");
3891 top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
3892 bottom = (ft_face->glyph->metrics.horiBearingY -
3893 ft_face->glyph->metrics.height) & -64;
3894 gm.gmCellIncX = adv;
3895 gm.gmCellIncY = 0;
3896 }
3897 else
3898 {
3899 INT xc, yc;
3900 FT_Vector vec;
3901 for (xc = 0; xc < 2; xc++)
3902 {
3903 for (yc = 0; yc < 2; yc++)
3904 {
3905 vec.x = (ft_face->glyph->metrics.horiBearingX +
3906 xc * ft_face->glyph->metrics.width);
3907 vec.y = ft_face->glyph->metrics.horiBearingY -
3908 yc * ft_face->glyph->metrics.height;
3909 DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
3910 FT_Vector_Transform(&vec, &transMat);
3911 if (xc == 0 && yc == 0)
3912 {
3913 left = right = vec.x;
3914 top = bottom = vec.y;
3915 }
3916 else
3917 {
3918 if (vec.x < left) left = vec.x;
3919 else if (vec.x > right) right = vec.x;
3920 if (vec.y < bottom) bottom = vec.y;
3921 else if (vec.y > top) top = vec.y;
3922 }
3923 }
3924 }
3925 left = left & -64;
3926 right = (right + 63) & -64;
3927 bottom = bottom & -64;
3928 top = (top + 63) & -64;
3929
3930 DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
3931 vec.x = ft_face->glyph->metrics.horiAdvance;
3932 vec.y = 0;
3933 FT_Vector_Transform(&vec, &transMat);
3934 gm.gmCellIncX = (vec.x+63) >> 6;
3935 gm.gmCellIncY = -((vec.y+63) >> 6);
3936 }
3937 gm.gmBlackBoxX = (right - left) >> 6;
3938 gm.gmBlackBoxY = (top - bottom) >> 6;
3939 gm.gmptGlyphOrigin.x = left >> 6;
3940 gm.gmptGlyphOrigin.y = top >> 6;
3941
3942 DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
3943 gm.gmCellIncX, gm.gmCellIncY,
3944 gm.gmBlackBoxX, gm.gmBlackBoxY,
3946
3948
3949
3950 if (iFormat == GGO_METRICS)
3951 {
3952 DPRINT("GGO_METRICS Exit!\n");
3953 *pgm = gm;
3954 return 1; /* FIXME */
3955 }
3956
3957 if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
3958 {
3959 DPRINT1("Loaded a bitmap\n");
3960 return GDI_ERROR;
3961 }
3962
3963 switch (iFormat)
3964 {
3965 case GGO_BITMAP:
3966 {
3967 width = gm.gmBlackBoxX;
3968 height = gm.gmBlackBoxY;
3969 pitch = ((width + 31) >> 5) << 2;
3970 needed = pitch * height;
3971
3972 if (!pvBuf || !cjBuf) break;
3973 if (!needed) return GDI_ERROR; /* empty glyph */
3974 if (needed > cjBuf)
3975 return GDI_ERROR;
3976
3977 switch (ft_face->glyph->format)
3978 {
3980 {
3981 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
3982 INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
3983 INT h = min( height, ft_face->glyph->bitmap.rows );
3984 while (h--)
3985 {
3987 src += ft_face->glyph->bitmap.pitch;
3988 dst += pitch;
3989 }
3990 break;
3991 }
3992
3994 {
3995 ft_bitmap.width = width;
3996 ft_bitmap.rows = height;
3997 ft_bitmap.pitch = pitch;
3998 ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
3999 ft_bitmap.buffer = pvBuf;
4000
4002 if (needsTransform)
4003 {
4004 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4005 }
4006 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4007 /* Note: FreeType will only set 'black' bits for us. */
4008 RtlZeroMemory(pvBuf, needed);
4009 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4011 break;
4012 }
4013
4014 default:
4015 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4016 return GDI_ERROR;
4017 }
4018
4019 break;
4020 }
4021
4022 case GGO_GRAY2_BITMAP:
4023 case GGO_GRAY4_BITMAP:
4024 case GGO_GRAY8_BITMAP:
4025 {
4026 unsigned int mult, row, col;
4027 BYTE *start, *ptr;
4028
4029 width = gm.gmBlackBoxX;
4030 height = gm.gmBlackBoxY;
4031 pitch = (width + 3) / 4 * 4;
4032 needed = pitch * height;
4033
4034 if (!pvBuf || !cjBuf) break;
4035 if (!needed) return GDI_ERROR; /* empty glyph */
4036 if (needed > cjBuf)
4037 return GDI_ERROR;
4038
4039 switch (ft_face->glyph->format)
4040 {
4042 {
4043 BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4044 INT h = min( height, ft_face->glyph->bitmap.rows );
4045 INT x;
4046 while (h--)
4047 {
4048 for (x = 0; (UINT)x < pitch; x++)
4049 {
4050 if (x < ft_face->glyph->bitmap.width)
4051 dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4052 else
4053 dst[x] = 0;
4054 }
4055 src += ft_face->glyph->bitmap.pitch;
4056 dst += pitch;
4057 }
4058 break;
4059 }
4061 {
4062 ft_bitmap.width = width;
4063 ft_bitmap.rows = height;
4064 ft_bitmap.pitch = pitch;
4065 ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4066 ft_bitmap.buffer = pvBuf;
4067
4069 if (needsTransform)
4070 {
4071 FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4072 }
4073 FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4074 RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4075 FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4077
4079 mult = 4;
4080 else if (iFormat == GGO_GRAY4_BITMAP)
4081 mult = 16;
4082 else if (iFormat == GGO_GRAY8_BITMAP)
4083 mult = 64;
4084 else
4085 {
4086 return GDI_ERROR;
4087 }
4088
4089 start = pvBuf;
4090 for (row = 0; row < height; row++)
4091 {
4092 ptr = start;
4093 for (col = 0; col < width; col++, ptr++)
4094 {
4095 *ptr = (((int)*ptr) * mult + 128) / 256;
4096 }
4097 start += pitch;
4098 }
4099
4100 break;
4101 }
4102 default:
4103 DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4104 return GDI_ERROR;
4105 }
4106
4107 break;
4108 }
4109
4110 case GGO_NATIVE:
4111 {
4112 FT_Outline *outline = &ft_face->glyph->outline;
4113
4114 if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4115
4117 if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4118
4120
4121 if (!pvBuf || !cjBuf)
4122 {
4124 break;
4125 }
4126 if (needed > cjBuf)
4127 {
4129 return GDI_ERROR;
4130 }
4133 break;
4134 }
4135
4136 case GGO_BEZIER:
4137 {
4138 FT_Outline *outline = &ft_face->glyph->outline;
4139 if (cjBuf == 0) pvBuf = NULL;
4140
4141 if (needsTransform && pvBuf)
4142 {
4144 FT_Outline_Transform(outline, &transMat);
4146 }
4148
4149 if (!pvBuf || !cjBuf)
4150 break;
4151 if (needed > cjBuf)
4152 return GDI_ERROR;
4153
4155 break;
4156 }
4157
4158 default:
4159 DPRINT1("Unsupported format %u\n", iFormat);
4160 return GDI_ERROR;
4161 }
4162
4163 DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4164
4165 if (gm.gmBlackBoxX == 0)
4166 gm.gmBlackBoxX = 1;
4167 if (gm.gmBlackBoxY == 0)
4168 gm.gmBlackBoxY = 1;
4169
4170 *pgm = gm;
4171 return needed;
4172}
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 ObjToGDI(ClipObj, Type)
Definition: engobjects.h:184
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FLOATOBJ_Set1(fo)
Definition: floatobj.h:119
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:105
BOOL FASTCALL TextIntUpdateSize(PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:3556
FT_Library g_FreeTypeLibrary
Definition: freetype.c:70
static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3291
static unsigned int get_native_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3218
static VOID FASTCALL IntMatrixFromMx(FT_Matrix *pmat, const MATRIX *pmx)
Definition: freetype.c:739
static VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
Definition: freetype.c:726
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, DWORD indexed_flag, DWORD flags)
Definition: freetype.c:3674
static const FT_Matrix identityMat
Definition: freetype.c:64
static __inline FT_Fixed FT_FixedFromFIXED(FIXED f)
Definition: freetype.c:397
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_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:653
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
#define DPRINT
Definition: sndvol32.h:71
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
Definition: text.h:60
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
FONTOBJ * Font
Definition: text.h:66
FIXED eM22
Definition: wingdi.h:2476
FIXED eM21
Definition: wingdi.h:2475
FIXED eM11
Definition: wingdi.h:2473
FIXED eM12
Definition: wingdi.h:2474
FLOATL eM11
Definition: winddi.h:1234
Definition: mesh.c:5330
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2779
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
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 5630 of file freetype.c.

5633{
5634 DWORD Count = 0;
5635 INT i = 0;
5636 FT_Face face = Font->SharedFace->Face;
5637
5638 if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
5639 {
5640 FT_UInt previous_index = 0, glyph_index = 0;
5641 FT_ULong char_code, char_previous;
5642 FT_Vector delta;
5643
5644 char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
5645
5647
5648 while (glyph_index)
5649 {
5650 if (previous_index && glyph_index)
5651 {
5652 FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
5653
5654 if (pKerningPair && cPairs)
5655 {
5656 pKerningPair[i].wFirst = char_previous;
5657 pKerningPair[i].wSecond = char_code;
5658 pKerningPair[i].iKernAmount = delta.x;
5659 i++;
5660 if (i == cPairs) break;
5661 }
5662 Count++;
5663 }
5664 previous_index = glyph_index;
5665 char_previous = char_code;
5666 char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
5667 }
5669 }
5670 return Count;
5671}
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
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
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 3088 of file freetype.c.

3089{
3090 if ( lprs )
3091 {
3092 lprs->nSize = sizeof(RASTERIZER_STATUS);
3093 lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3094 lprs->nLanguageID = gusLanguageID;
3095 return TRUE;
3096 }
3098 return FALSE;
3099}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
USHORT gusLanguageID
Definition: init.c:12
#define TT_ENABLED
Definition: wingdi.h:889
struct _RASTERIZER_STATUS RASTERIZER_STATUS
#define TT_AVAILABLE
Definition: wingdi.h:888

Referenced by NtGdiGetRasterizerCaps().

◆ ftGdiGetTextCharsetInfo()

INT FASTCALL ftGdiGetTextCharsetInfo ( PDC  Dc,
LPFONTSIGNATURE  lpSig,
DWORD  dwFlags 
)

Definition at line 4331 of file freetype.c.

4335{
4336 PDC_ATTR pdcattr;
4337 UINT Ret = DEFAULT_CHARSET;
4338 INT i;
4339 HFONT hFont;
4340 PTEXTOBJ TextObj;
4341 PFONTGDI FontGdi;
4343 TT_OS2 *pOS2;
4344 FT_Face Face;
4345 CHARSETINFO csi;
4346 DWORD cp, fs0;
4347 USHORT usACP, usOEM;
4348
4349 pdcattr = Dc->pdcattr;
4350 hFont = pdcattr->hlfntNew;
4351 TextObj = RealizeFontInit(hFont);
4352
4353 if (!TextObj)
4354 {
4356 return Ret;
4357 }
4358 FontGdi = ObjToGDI(TextObj->Font, FONT);
4359 Face = FontGdi->SharedFace->Face;
4360 TEXTOBJ_UnlockText(TextObj);
4361
4362 memset(&fs, 0, sizeof(FONTSIGNATURE));
4364 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4365 if (NULL != pOS2)
4366 {
4367 fs.fsCsb[0] = pOS2->ulCodePageRange1;
4368 fs.fsCsb[1] = pOS2->ulCodePageRange2;
4369 fs.fsUsb[0] = pOS2->ulUnicodeRange1;
4370 fs.fsUsb[1] = pOS2->ulUnicodeRange2;
4371 fs.fsUsb[2] = pOS2->ulUnicodeRange3;
4372 fs.fsUsb[3] = pOS2->ulUnicodeRange4;
4373 if (pOS2->version == 0)
4374 {
4375 FT_UInt dummy;
4376
4377 if (FT_Get_First_Char( Face, &dummy ) < 0x100)
4378 fs.fsCsb[0] |= FS_LATIN1;
4379 else
4380 fs.fsCsb[0] |= FS_SYMBOL;
4381 }
4382 }
4383 pOS2 = NULL;
4385 DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
4386 if (fs.fsCsb[0] == 0)
4387 { /* Let's see if we can find any interesting cmaps */
4388 for (i = 0; i < Face->num_charmaps; i++)
4389 {
4390 switch (Face->charmaps[i]->encoding)
4391 {
4392 case FT_ENCODING_UNICODE:
4393 case FT_ENCODING_APPLE_ROMAN:
4394 fs.fsCsb[0] |= FS_LATIN1;
4395 break;
4396 case FT_ENCODING_MS_SYMBOL:
4397 fs.fsCsb[0] |= FS_SYMBOL;
4398 break;
4399 default:
4400 break;
4401 }
4402 }
4403 }
4404 if (lpSig)
4405 {
4406 RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
4407 }
4408
4409 RtlGetDefaultCodePage(&usACP, &usOEM);
4410 cp = usACP;
4411
4413 if (csi.fs.fsCsb[0] & fs.fsCsb[0])
4414 {
4415 DPRINT("Hit 1\n");
4416 Ret = csi.ciCharset;
4417 goto Exit;
4418 }
4419
4420 for (i = 0; i < MAXTCIINDEX; i++)
4421 {
4422 fs0 = 1L << i;
4423 if (fs.fsCsb[0] & fs0)
4424 {
4425 if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
4426 {
4427 // *cp = csi.ciACP;
4428 DPRINT("Hit 2\n");
4429 Ret = csi.ciCharset;
4430 goto Exit;
4431 }
4432 else
4433 DPRINT1("TCI failing on %x\n", fs0);
4434 }
4435 }
4436Exit:
4437 DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
4438 return (MAKELONG(csi.ciACP, csi.ciCharset));
4439}
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 4518 of file freetype.c.

4521{
4522 PDC dc;
4523 PDC_ATTR pdcattr;
4524 PTEXTOBJ TextObj;
4525 PFONTGDI FontGDI;
4526 FT_Face Face;
4527 TT_OS2 *pOS2;
4528 TT_HoriHeader *pHori;
4530 ULONG Error;
4532 LOGFONTW *plf;
4533
4534 if (!ptmwi)
4535 {
4537 return FALSE;
4538 }
4539 RtlZeroMemory(ptmwi, sizeof(TMW_INTERNAL));
4540
4541 if (!(dc = DC_LockDc(hDC)))
4542 {
4544 return FALSE;
4545 }
4546 pdcattr = dc->pdcattr;
4547 TextObj = RealizeFontInit(pdcattr->hlfntNew);
4548 if (NULL != TextObj)
4549 {
4550 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4551 FontGDI = ObjToGDI(TextObj->Font, FONT);
4552
4553 Face = FontGDI->SharedFace->Face;
4554
4555 // NOTE: GetTextMetrics simply ignores lfEscapement and XFORM.
4557 Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4558 FT_Set_Transform(Face, NULL, NULL);
4559
4561
4562 if (0 != Error)
4563 {
4564 DPRINT1("Error in setting pixel sizes: %u\n", Error);
4566 }
4567 else
4568 {
4570
4572 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4573 if (NULL == pOS2)
4574 {
4575 DPRINT1("Can't find OS/2 table - not TT font?\n");
4577 }
4578
4579 pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
4580 if (NULL == pHori)
4581 {
4582 DPRINT1("Can't find HHEA table - not TT font?\n");
4584 }
4585
4586 Error = FT_Get_WinFNT_Header(Face, &Win);
4587
4588 if (NT_SUCCESS(Status) || !Error)
4589 {
4590 FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
4591
4592 /* FIXME: Fill Diff member */
4593 }
4594
4596 }
4597 TEXTOBJ_UnlockText(TextObj);
4598 }
4599 else
4600 {
4602 }
4603 DC_UnlockDc(dc);
4604
4605 if (!NT_SUCCESS(Status))
4606 {
4608 return FALSE;
4609 }
4610 return TRUE;
4611}
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:2111
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 5611 of file freetype.c.

5612{
5613 if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
5614 Info->iTechnology = RI_TECH_BITMAP;
5615 else
5616 {
5617 if (FT_IS_SCALABLE(Font->SharedFace->Face))
5618 Info->iTechnology = RI_TECH_SCALABLE;
5619 else
5620 Info->iTechnology = RI_TECH_FIXED;
5621 }
5622 Info->iUniq = Font->FontObj.iUniq;
5623 Info->dwUnknown = -1;
5624 return TRUE;
5625}
#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 4444 of file freetype.c.

4445{
4446 DWORD size = 0;
4447 DWORD num_ranges = 0;
4448 FT_Face face = Font->SharedFace->Face;
4449
4450 if (face->charmap == NULL)
4451 {
4452 DPRINT1("FIXME: No charmap selected! This is a BUG!\n");
4453 return 0;
4454 }
4455
4456 if (face->charmap->encoding == FT_ENCODING_UNICODE)
4457 {
4458 FT_UInt glyph_code = 0;
4459 FT_ULong char_code, char_code_prev;
4460
4461 char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
4462
4463 DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
4464 face->num_glyphs, glyph_code, char_code);
4465
4466 if (!glyph_code) return 0;
4467
4468 if (glyphset)
4469 {
4470 glyphset->ranges[0].wcLow = (USHORT)char_code;
4471 glyphset->ranges[0].cGlyphs = 0;
4472 glyphset->cGlyphsSupported = 0;
4473 }
4474
4475 num_ranges = 1;
4476 while (glyph_code)
4477 {
4478 if (char_code < char_code_prev)
4479 {
4480 DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
4481 return 0;
4482 }
4483 if (char_code - char_code_prev > 1)
4484 {
4485 num_ranges++;
4486 if (glyphset)
4487 {
4488 glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
4489 glyphset->ranges[num_ranges - 1].cGlyphs = 1;
4490 glyphset->cGlyphsSupported++;
4491 }
4492 }
4493 else if (glyphset)
4494 {
4495 glyphset->ranges[num_ranges - 1].cGlyphs++;
4496 glyphset->cGlyphsSupported++;
4497 }
4498 char_code_prev = char_code;
4499 char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
4500 }
4501 }
4502 else
4503 DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
4504
4505 size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
4506 if (glyphset)
4507 {
4508 glyphset->cbThis = size;
4509 glyphset->cRanges = num_ranges;
4510 glyphset->flAccel = 0;
4511 }
4512 return size;
4513}
GLsizeiptr size
Definition: glext.h:5919

Referenced by NtGdiGetFontUnicodeRanges().

◆ FTVectorToPOINTFX()

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

Definition at line 383 of file freetype.c.

384{
385 pt->x.value = vec->x >> 6;
386 pt->x.fract = (vec->x & 0x3f) << 10;
387 pt->x.fract |= ((pt->x.fract >> 6) | (pt->x.fract >> 12));
388 pt->y.value = vec->y >> 6;
389 pt->y.fract = (vec->y & 0x3f) << 10;
390 pt->y.fract |= ((pt->y.fract >> 6) | (pt->y.fract >> 12));
391}
#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 3291 of file freetype.c.

3292{
3293 /* Convert the quadratic Beziers to cubic Beziers.
3294 The parametric eqn for a cubic Bezier is, from PLRM:
3295 r(t) = at^3 + bt^2 + ct + r0
3296 with the control points:
3297 r1 = r0 + c/3
3298 r2 = r1 + (c + b)/3
3299 r3 = r0 + c + b + a
3300
3301 A quadratic Bezier has the form:
3302 p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
3303
3304 So equating powers of t leads to:
3305 r1 = 2/3 p1 + 1/3 p0
3306 r2 = 2/3 p1 + 1/3 p2
3307 and of course r0 = p0, r3 = p2
3308 */
3309 int contour, point = 0, first_pt;
3310 TTPOLYGONHEADER *pph;
3311 TTPOLYCURVE *ppc;
3312 DWORD pph_start, cpfx, type;
3313 FT_Vector cubic_control[4];
3314 unsigned int needed = 0;
3315
3316 for (contour = 0; contour < outline->n_contours; contour++)
3317 {
3318 pph_start = needed;
3319 pph = (TTPOLYGONHEADER *)(buf + needed);
3320 first_pt = point;
3321 if (buf)
3322 {
3323 pph->dwType = TT_POLYGON_TYPE;
3324 FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3325 }
3326 needed += sizeof(*pph);
3327 point++;
3328 while (point <= outline->contours[contour])
3329 {
3330 ppc = (TTPOLYCURVE *)(buf + needed);
3331 type = (outline->tags[point] & FT_Curve_Tag_On) ?
3333 cpfx = 0;
3334 do
3335 {
3336 if (type == TT_PRIM_LINE)
3337 {
3338 if (buf)
3339 FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3340 cpfx++;
3341 point++;
3342 }
3343 else
3344 {
3345 /* Unlike QSPLINEs, CSPLINEs always have their endpoint
3346 so cpfx = 3n */
3347
3348 /* FIXME: Possible optimization in endpoint calculation
3349 if there are two consecutive curves */
3350 cubic_control[0] = outline->points[point-1];
3351 if (!(outline->tags[point-1] & FT_Curve_Tag_On))
3352 {
3353 cubic_control[0].x += outline->points[point].x + 1;
3354 cubic_control[0].y += outline->points[point].y + 1;
3355 cubic_control[0].x >>= 1;
3356 cubic_control[0].y >>= 1;
3357 }
3358 if (point+1 > outline->contours[contour])
3359 cubic_control[3] = outline->points[first_pt];
3360 else
3361 {
3362 cubic_control[3] = outline->points[point+1];
3363 if (!(outline->tags[point+1] & FT_Curve_Tag_On))
3364 {
3365 cubic_control[3].x += outline->points[point].x + 1;
3366 cubic_control[3].y += outline->points[point].y + 1;
3367 cubic_control[3].x >>= 1;
3368 cubic_control[3].y >>= 1;
3369 }
3370 }
3371 /* r1 = 1/3 p0 + 2/3 p1
3372 r2 = 1/3 p2 + 2/3 p1 */
3373 cubic_control[1].x = (2 * outline->points[point].x + 1) / 3;
3374 cubic_control[1].y = (2 * outline->points[point].y + 1) / 3;
3375 cubic_control[2] = cubic_control[1];
3376 cubic_control[1].x += (cubic_control[0].x + 1) / 3;
3377 cubic_control[1].y += (cubic_control[0].y + 1) / 3;
3378 cubic_control[2].x += (cubic_control[3].x + 1) / 3;
3379 cubic_control[2].y += (cubic_control[3].y + 1) / 3;
3380 if (buf)
3381 {
3382 FTVectorToPOINTFX(&cubic_control[1], &ppc->apfx[cpfx]);
3383 FTVectorToPOINTFX(&cubic_control[2], &ppc->apfx[cpfx+1]);
3384 FTVectorToPOINTFX(&cubic_control[3], &ppc->apfx[cpfx+2]);
3385 }
3386 cpfx += 3;
3387 point++;
3388 }
3389 } while (point <= outline->contours[contour] &&
3390 (outline->tags[point] & FT_Curve_Tag_On) ==
3391 (outline->tags[point-1] & FT_Curve_Tag_On));
3392 /* At the end of a contour Windows adds the start point,
3393 but only for Beziers and we've already done that.
3394 */
3395 if (point <= outline->contours[contour] &&
3396 outline->tags[point] & FT_Curve_Tag_On)
3397 {
3398 /* This is the closing pt of a bezier, but we've already
3399 added it, so just inc point and carry on */
3400 point++;
3401 }
3402 if (buf)
3403 {
3404 ppc->wType = type;
3405 ppc->cpfx = cpfx;
3406 }
3407 needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3408 }
3409 if (buf)
3410 pph->cb = needed - pph_start;
3411 }
3412 return needed;
3413}
POINTL point
Definition: edittest.c:50
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:383
#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 3659 of file freetype.c.

3660{
3661 FT_UInt ret;
3662
3663 if (face_has_symbol_charmap(ft_face))
3664 {
3665 ret = get_glyph_index_symbol(ft_face, glyph);
3666 if (ret != 0)
3667 return ret;
3668 }
3669
3670 return FT_Get_Char_Index(ft_face, glyph);
3671}
static FT_UInt FASTCALL get_glyph_index_symbol(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3645
FT_Get_Char_Index(FT_Face face, FT_ULong charcode)
Definition: ftobjs.c:3668
int ret

Referenced by get_glyph_index_flagged(), and NtGdiGetGlyphIndicesW().

◆ get_glyph_index_flagged()

static FT_UInt FASTCALL get_glyph_index_flagged ( FT_Face  face,
FT_ULong  code,
DWORD  indexed_flag,
DWORD  flags 
)
inlinestatic

Definition at line 3674 of file freetype.c.

3675{
3676 FT_UInt glyph_index;
3677 if (flags & indexed_flag)
3678 {
3679 glyph_index = code;
3680 }
3681 else
3682 {
3683 glyph_index = get_glyph_index(face, code);
3684 }
3685 return glyph_index;
3686}
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3659
GLbitfield flags
Definition: glext.h:7161
Definition: inflate.c:139

Referenced by ftGdiGetGlyphOutline(), IntExtTextOutW(), IntGetTextDisposition(), NtGdiGetCharABCWidthsW(), NtGdiGetCharWidthW(), and TextIntGetTextExtentPoint().

◆ get_glyph_index_symbol()

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

Definition at line 3645 of file freetype.c.

3646{
3647 FT_UInt ret;
3648
3649 if (glyph < 0x100) glyph += 0xf000;
3650 /* there are a number of old pre-Unicode "broken" TTFs, which
3651 do have symbols at U+00XX instead of U+f0XX */
3652 if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
3653 ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
3654
3655 return ret;
3656}

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

3219{
3220 TTPOLYGONHEADER *pph;
3221 TTPOLYCURVE *ppc;
3222 int needed = 0, point = 0, contour, first_pt;
3223 unsigned int pph_start, cpfx;
3224 DWORD type;
3225
3226 for (contour = 0; contour < outline->n_contours; contour++)
3227 {
3228 /* Ignore contours containing one point */
3229 if (point == outline->contours[contour])
3230 {
3231 point++;
3232 continue;
3233 }
3234
3235 pph_start = needed;
3236 pph = (TTPOLYGONHEADER *)(buf + needed);
3237 first_pt = point;
3238 if (buf)
3239 {
3240 pph->dwType = TT_POLYGON_TYPE;
3241 FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3242 }
3243 needed += sizeof(*pph);
3244 point++;
3245 while (point <= outline->contours[contour])
3246 {
3247 ppc = (TTPOLYCURVE *)(buf + needed);
3248 type = (outline->tags[point] & FT_Curve_Tag_On) ?
3250 cpfx = 0;
3251 do
3252 {
3253 if (buf)
3254 FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3255 cpfx++;
3256 point++;
3257 } while (point <= outline->contours[contour] &&
3258 (outline->tags[point] & FT_Curve_Tag_On) ==
3259 (outline->tags[point-1] & FT_Curve_Tag_On));
3260 /* At the end of a contour Windows adds the start point, but
3261 only for Beziers */
3262 if (point > outline->contours[contour] &&
3263 !(outline->tags[point-1] & FT_Curve_Tag_On))
3264 {
3265 if (buf)
3266 FTVectorToPOINTFX(&outline->points[first_pt], &ppc->apfx[cpfx]);
3267 cpfx++;
3268 }
3269 else if (point <= outline->contours[contour] &&
3270 outline->tags[point] & FT_Curve_Tag_On)
3271 {
3272 /* add closing pt for bezier */
3273 if (buf)
3274 FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3275 cpfx++;
3276 point++;
3277 }
3278 if (buf)
3279 {
3280 ppc->wType = type;
3281 ppc->cpfx = cpfx;
3282 }
3283 needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3284 }
3285 if (buf)
3286 pph->cb = needed - pph_start;
3287 }
3288 return needed;
3289}
#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 2962 of file freetype.c.

2968{
2970 PFONT_ENTRY CurrentEntry;
2971 FONTGDI *FontGDI;
2972 FONTFAMILYINFO InfoEntry;
2973 LONG Count = *pCount;
2974
2975 for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
2976 {
2977 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
2978 FontGDI = CurrentEntry->Font;
2979 ASSERT(FontGDI);
2980
2981 if (LogFont->lfCharSet != DEFAULT_CHARSET &&
2982 LogFont->lfCharSet != FontGDI->CharSet)
2983 {
2984 continue; /* charset mismatch */
2985 }
2986
2987 /* get one info entry */
2988 FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
2989
2990 if (LogFont->lfFaceName[0] != UNICODE_NULL)
2991 {
2992 /* check name */
2993 if (_wcsnicmp(LogFont->lfFaceName,
2995 RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
2996 _wcsnicmp(LogFont->lfFaceName,
2997 InfoEntry.EnumLogFontEx.elfFullName,
2998 RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
2999 {
3000 continue;
3001 }
3002 }
3003
3004 if (NominalName)
3005 {
3006 /* store the nominal name */
3008 sizeof(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
3009 NominalName);
3010 }
3011
3012 /* store one entry to Info */
3013 if (0 <= Count && Count < MaxCount)
3014 {
3015 RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
3016 }
3017 Count++;
3018 }
3019
3020 *pCount = Count;
3021
3022 return TRUE;
3023}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static void FASTCALL FontFamilyFillInfo(PFONTFAMILYINFO Info, LPCWSTR FaceName, LPCWSTR FullName, PFONTGDI FontGDI)
Definition: freetype.c:2778
_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 3026 of file freetype.c.

3030{
3031 PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
3032 PFONTSUBST_ENTRY pCurrentEntry;
3033 PUNICODE_STRING pFromW, pToW;
3034 LOGFONTW lf = *LogFont;
3036
3037 for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
3038 {
3039 pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
3040
3041 pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
3042 if (LogFont->lfFaceName[0] != UNICODE_NULL)
3043 {
3044 /* check name */
3045 if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
3046 continue; /* mismatch */
3047 }
3048
3049 pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
3050 if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
3051 pCurrentEntry->CharSets[FONTSUBST_FROM] ==
3052 pCurrentEntry->CharSets[FONTSUBST_TO])
3053 {
3054 /* identical mapping */
3055 continue;
3056 }
3057
3058 /* substitute and get the real name */
3059 IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
3061 if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
3062 continue;
3063
3064 /* search in global fonts */
3066 GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
3068
3069 /* search in private fonts */
3070 IntLockProcessPrivateFonts(Win32Process);
3071 GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
3072 &Win32Process->PrivateFontListHead);
3073 IntUnLockProcessPrivateFonts(Win32Process);
3074
3075 if (LogFont->lfFaceName[0] != UNICODE_NULL)
3076 {
3077 /* it's already matched to the exact name and charset if the name
3078 was specified at here, then so don't scan more for another name */
3079 break;
3080 }
3081 }
3082
3083 return TRUE;
3084}
static BOOLEAN FASTCALL GetFontFamilyInfoForList(const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LPCWSTR NominalName, LONG *pCount, LONG MaxCount, PLIST_ENTRY Head)
Definition: freetype.c:2962
static LIST_ENTRY g_FontListHead
Definition: freetype.c:81
static BOOL SubstituteFontRecurse(LOGFONTW *pLogFont)
Definition: freetype.c:868
static VOID IntUnicodeStringToBuffer(LPWSTR pszBuffer, SIZE_T cbBuffer, const UNICODE_STRING *pString)
Definition: freetype.c:830
#define IntUnLockGlobalFonts()
Definition: freetype.c:88
#define IntLockGlobalFonts()
Definition: freetype.c:85
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#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)
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
Definition: font.h:77
UNICODE_STRING FontNames[FONTSUBST_FROM_AND_TO]
Definition: font.h:79
BYTE CharSets[FONTSUBST_FROM_AND_TO]
Definition: font.h:80
LIST_ENTRY PrivateFontListHead
Definition: win32.h:284
#define IntLockProcessPrivateFonts(W32Process)
Definition: text.h:147
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:150

Referenced by IntGetFontFamilyInfo().

◆ GetFontPenalty()

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

Definition at line 4657 of file freetype.c.

4660{
4661 ULONG Penalty = 0;
4662 BYTE Byte;
4663 LONG Long;
4664 BOOL fNeedScaling = FALSE;
4665 const BYTE UserCharSet = CharSetFromLangID(gusLanguageID);
4666 const TEXTMETRICW * TM = &Otm->otmTextMetrics;
4667 WCHAR* ActualNameW;
4668
4669 ASSERT(Otm);
4670 ASSERT(LogFont);
4671
4672 /* FIXME: IntSizeSynth Penalty 20 */
4673 /* FIXME: SmallPenalty Penalty 1 */
4674 /* FIXME: FaceNameSubst Penalty 500 */
4675
4676 Byte = LogFont->lfCharSet;
4677
4678 if (Byte != TM->tmCharSet)
4679 {
4681 {
4682 /* CharSet Penalty 65000 */
4683 /* Requested charset does not match the candidate's. */
4684 GOT_PENALTY("CharSet", 65000);
4685 }
4686 else
4687 {
4688 if (UserCharSet != TM->tmCharSet)
4689 {
4690 /* UNDOCUMENTED: Not user language */
4691 GOT_PENALTY("UNDOCUMENTED:NotUserLanguage", 100);
4692
4693 if (ANSI_CHARSET != TM->tmCharSet)
4694 {
4695 /* UNDOCUMENTED: Not ANSI charset */
4696 GOT_PENALTY("UNDOCUMENTED:NotAnsiCharSet", 100);
4697 }
4698 }
4699 }
4700 }
4701
4702 Byte = LogFont->lfOutPrecision;
4703 switch (Byte)
4704 {
4705 case OUT_DEFAULT_PRECIS:
4706 /* nothing to do */
4707 break;
4708 case OUT_DEVICE_PRECIS:
4709 if (!(TM->tmPitchAndFamily & TMPF_DEVICE) ||
4711 {
4712 /* OutputPrecision Penalty 19000 */
4713 /* Requested OUT_STROKE_PRECIS, but the device can't do it
4714 or the candidate is not a vector font. */
4715 GOT_PENALTY("OutputPrecision", 19000);
4716 }
4717 break;
4718 default:
4720 {
4721 /* OutputPrecision Penalty 19000 */
4722 /* Or OUT_STROKE_PRECIS not requested, and the candidate
4723 is a vector font that requires GDI support. */
4724 GOT_PENALTY("OutputPrecision", 19000);
4725 }
4726 break;
4727 }
4728
4729 Byte = (LogFont->lfPitchAndFamily & 0x0F);
4730 if (Byte == DEFAULT_PITCH)
4732 if (Byte == FIXED_PITCH)
4733 {
4735 {
4736 /* FixedPitch Penalty 15000 */
4737 /* Requested a fixed pitch font, but the candidate is a
4738 variable pitch font. */
4739 GOT_PENALTY("FixedPitch", 15000);
4740 }
4741 }
4742 if (Byte == VARIABLE_PITCH)
4743 {
4745 {
4746 /* PitchVariable Penalty 350 */
4747 /* Requested a variable pitch font, but the candidate is not a
4748 variable pitch font. */
4749 GOT_PENALTY("PitchVariable", 350);
4750 }
4751 }
4752
4753 Byte = (LogFont->lfPitchAndFamily & 0x0F);
4754 if (Byte == DEFAULT_PITCH)
4755 {
4757 {
4758 /* DefaultPitchFixed Penalty 1 */
4759 /* Requested DEFAULT_PITCH, but the candidate is fixed pitch. */
4760 GOT_PENALTY("DefaultPitchFixed", 1);
4761 }
4762 }
4763
4764 ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
4765
4766 if (LogFont->lfFaceName[0] != UNICODE_NULL)
4767 {
4768 BOOL Found = FALSE;
4769
4770 /* localized family name */
4771 if (!Found)
4772 {
4773 Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
4774 }
4775 /* localized full name */
4776 if (!Found)
4777 {
4778 ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFaceName);
4779 Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
4780 }
4781 if (!Found)
4782 {
4783 /* FaceName Penalty 10000 */
4784 /* Requested a face name, but the candidate's face name
4785 does not match. */
4786 GOT_PENALTY("FaceName", 10000);
4787 }
4788 }
4789
4790 Byte = (LogFont->lfPitchAndFamily & 0xF0);
4791 if (Byte != FF_DONTCARE)
4792 {
4793 if (Byte != (TM->tmPitchAndFamily & 0xF0))
4794 {
4795 /* Family Penalty 9000 */
4796 /* Requested a family, but the candidate's family is different. */
4797 GOT_PENALTY("Family", 9000);
4798 }
4799 }
4800
4801 if ((TM->tmPitchAndFamily & 0xF0) == FF_DONTCARE)
4802 {
4803 /* FamilyUnknown Penalty 8000 */
4804 /* Requested a family, but the candidate has no family. */
4805 GOT_PENALTY("FamilyUnknown", 8000);
4806 }
4807
4808 /* Is the candidate a non-vector font? */
4810 {
4811 /* Is lfHeight specified? */
4812 if (LogFont->lfHeight != 0)
4813 {
4814 if (labs(LogFont->lfHeight) < TM->tmHeight)
4815 {
4816 /* HeightBigger Penalty 600 */
4817 /* The candidate is a nonvector font and is bigger than the
4818 requested height. */
4819 GOT_PENALTY("HeightBigger", 600);
4820 /* HeightBiggerDifference Penalty 150 */
4821 /* The candidate is a raster font and is larger than the
4822 requested height. Penalty * height difference */
4823 GOT_PENALTY("HeightBiggerDifference", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
4824
4825 fNeedScaling = TRUE;
4826 }
4827 if (TM->tmHeight < labs(LogFont->lfHeight))
4828 {
4829 /* HeightSmaller Penalty 150 */
4830 /* The candidate is a raster font and is smaller than the
4831 requested height. Penalty * height difference */
4832 GOT_PENALTY("HeightSmaller", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
4833
4834 fNeedScaling = TRUE;
4835 }
4836 }
4837 }
4838
4839 switch (LogFont->lfPitchAndFamily & 0xF0)
4840 {
4841 case FF_ROMAN: case FF_MODERN: case FF_SWISS:
4842 switch (TM->tmPitchAndFamily & 0xF0)
4843 {
4844 case FF_DECORATIVE: case FF_SCRIPT:
4845 /* FamilyUnlikely Penalty 50 */
4846 /* Requested a roman/modern/swiss family, but the
4847 candidate is decorative/script. */
4848 GOT_PENALTY("FamilyUnlikely", 50);
4849 break;
4850 default:
4851 break;
4852 }
4853 break;
4854 case FF_DECORATIVE: case FF_SCRIPT:
4855 switch (TM->tmPitchAndFamily & 0xF0)
4856 {
4857 case FF_ROMAN: case FF_MODERN: case FF_SWISS:
4858 /* FamilyUnlikely Penalty 50 */
4859 /* Or requested decorative/script, and the candidate is
4860 roman/modern/swiss. */
4861 GOT_PENALTY("FamilyUnlikely", 50);
4862 break;
4863 default:
4864 break;
4865 }
4866 default:
4867 break;
4868 }
4869
4870 if (LogFont->lfWidth != 0)
4871 {
4872 if (LogFont->lfWidth != TM->tmAveCharWidth)
4873 {
4874 /* Width Penalty 50 */
4875 /* Requested a nonzero width, but the candidate's width
4876 doesn't match. Penalty * width difference */
4877 GOT_PENALTY("Width", 50 * labs(LogFont->lfWidth - TM->tmAveCharWidth));
4878
4880 fNeedScaling = TRUE;
4881 }
4882 }
4883
4884 if (fNeedScaling)
4885 {
4886 /* SizeSynth Penalty 50 */
4887 /* The candidate is a raster font that needs scaling by GDI. */
4888 GOT_PENALTY("SizeSynth", 50);
4889 }
4890
4891 if (!LogFont->lfItalic && TM->tmItalic)
4892 {
4893 /* Italic Penalty 4 */
4894 /* Requested font and candidate font do not agree on italic status,
4895 and the desired result cannot be simulated. */
4896 /* Adjusted to 40 to satisfy (Oblique Penalty > Book Penalty). */
4897 GOT_PENALTY("Italic", 40);
4898 }
4899 else if (LogFont->lfItalic && !TM->tmItalic)
4900 {
4901 /* ItalicSim Penalty 1 */
4902 /* Requested italic font but the candidate is not italic,
4903 although italics can be simulated. */
4904 GOT_PENALTY("ItalicSim", 1);
4905 }
4906
4907 if (LogFont->lfOutPrecision == OUT_TT_PRECIS)
4908 {
4909 if (!(TM->tmPitchAndFamily & TMPF_TRUETYPE))
4910 {
4911 /* NotTrueType Penalty 4 */
4912 /* Requested OUT_TT_PRECIS, but the candidate is not a
4913 TrueType font. */
4914 GOT_PENALTY("NotTrueType", 4);
4915 }
4916 }
4917
4918 Long = LogFont->lfWeight;
4919 if (LogFont->lfWeight == FW_DONTCARE)
4920 Long = FW_NORMAL;
4921 if (Long != TM->tmWeight)
4922 {
4923 /* Weight Penalty 3 */
4924 /* The candidate's weight does not match the requested weight.
4925 Penalty * (weight difference/10) */
4926 GOT_PENALTY("Weight", 3 * (labs(Long - TM->tmWeight) / 10));
4927 }
4928
4929 if (!LogFont->lfUnderline && TM->tmUnderlined)
4930 {
4931 /* Underline Penalty 3 */
4932 /* Requested font has no underline, but the candidate is
4933 underlined. */
4934 GOT_PENALTY("Underline", 3);
4935 }
4936
4937 if (!LogFont->lfStrikeOut && TM->tmStruckOut)
4938 {
4939 /* StrikeOut Penalty 3 */
4940 /* Requested font has no strike-out, but the candidate is
4941 struck out. */
4942 GOT_PENALTY("StrikeOut", 3);
4943 }
4944
4945 /* Is the candidate a non-vector font? */
4947 {
4948 if (LogFont->lfHeight != 0 && TM->tmHeight < LogFont->lfHeight)
4949 {
4950 /* VectorHeightSmaller Penalty 2 */
4951 /* Candidate is a vector font that is smaller than the
4952 requested height. Penalty * height difference */
4953 GOT_PENALTY("VectorHeightSmaller", 2 * labs(TM->tmHeight - LogFont->lfHeight));
4954 }
4955 if (LogFont->lfHeight != 0 && TM->tmHeight > LogFont->lfHeight)
4956 {
4957 /* VectorHeightBigger Penalty 1 */
4958 /* Candidate is a vector font that is bigger than the
4959 requested height. Penalty * height difference */
4960 GOT_PENALTY("VectorHeightBigger", 1 * labs(TM->tmHeight - LogFont->lfHeight));
4961 }
4962 }
4963
4964 if (!(TM->tmPitchAndFamily & TMPF_DEVICE))
4965 {
4966 /* DeviceFavor Penalty 2 */
4967 /* Extra penalty for all nondevice fonts. */
4968 GOT_PENALTY("DeviceFavor", 2);
4969 }
4970
4971 if (TM->tmAveCharWidth >= 5 && TM->tmHeight >= 5)
4972 {
4973 if (TM->tmAveCharWidth / TM->tmHeight >= 3)
4974 {
4975 /* Aspect Penalty 30 */
4976 /* The aspect rate is >= 3. It seems like a bad font. */
4977 GOT_PENALTY("Aspect", ((TM->tmAveCharWidth / TM->tmHeight) - 2) * 30);
4978 }
4979 else if (TM->tmHeight / TM->tmAveCharWidth >= 3)
4980 {
4981 /* Aspect Penalty 30 */
4982 /* The aspect rate is >= 3. It seems like a bad font. */
4983 GOT_PENALTY("Aspect", ((TM->tmHeight / TM->tmAveCharWidth) - 2) * 30);
4984 }
4985 }
4986
4987 if (Penalty < 200)
4988 {
4989 DPRINT("WARNING: Penalty:%ld < 200: RequestedNameW:%ls, "
4990 "ActualNameW:%ls, lfCharSet:%d, lfWeight:%ld, "
4991 "tmCharSet:%d, tmWeight:%ld\n",
4992 Penalty, LogFont->lfFaceName, ActualNameW,
4993 LogFont->lfCharSet, LogFont->lfWeight,
4994 TM->tmCharSet, TM->tmWeight);
4995 }
4996
4997 return Penalty; /* success */
4998}
return Found
Definition: dirsup.c:1270
unsigned char Byte
Definition: zlib.h:37
#define GOT_PENALTY(name, value)
Definition: freetype.c:4653
static BYTE CharSetFromLangID(LANGID LangID)
Definition: freetype.c:2560
long Long
Definition: ftraster.c:313
_Check_return_ long __cdecl labs(_In_ long x)
BYTE lfStrikeOut
Definition: dimm.idl:66
BYTE lfUnderline
Definition: dimm.idl:65
#define FIXED_PITCH
Definition: wingdi.h:444
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define VARIABLE_PITCH
Definition: wingdi.h:445
#define OUT_DEVICE_PRECIS
Definition: wingdi.h:420
#define TMPF_DEVICE
Definition: wingdi.h:1314
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define OUT_TT_PRECIS
Definition: wingdi.h:419

Referenced by FindBestFontFromList().

◆ GreExtTextOutW()

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 
)

Definition at line 6523 of file freetype.c.

6533{
6534 BOOL bResult;
6535 DC *dc;
6536
6537 // TODO: Write test-cases to exactly match real Windows in different
6538 // bad parameters (e.g. does Windows check the DC or the RECT first?).
6539 dc = DC_LockDc(hDC);
6540 if (!dc)
6541 {
6543 return FALSE;
6544 }
6545
6546 bResult = IntExtTextOutW( dc,
6547 XStart,
6548 YStart,
6549 fuOptions,
6550 lprc,
6551 String,
6552 Count,
6553 Dx,
6554 dwCodePage );
6555
6556 DC_UnlockDc(dc);
6557
6558 return bResult;
6559}
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)
Definition: freetype.c:6003
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4466

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

◆ InitFontSupport()

BOOL FASTCALL InitFontSupport ( VOID  )

Definition at line 672 of file freetype.c.

673{
674 ULONG ulError;
675
679 /* Fast Mutexes must be allocated from non paged pool */
681 if (g_FontListLock == NULL)
682 {
683 return FALSE;
684 }
685
688 if (g_FreeTypeLock == NULL)
689 {
690 return FALSE;
691 }
693
695 if (ulError)
696 {
697 DPRINT1("FT_Init_FreeType failed with error code 0x%x\n", ulError);
698 return FALSE;
699 }
700
702 {
703 DPRINT1("Fonts registry is empty.\n");
704
705 /* Load font(s) with writing registry */
707 }
708
709 IntLoadFontSubstList(&g_FontSubstListHead);
710
711#if DBG
712 DumpFontInfo(TRUE);
713#endif
714
715 return TRUE;
716}
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
static PFAST_MUTEX g_FreeTypeLock
Definition: freetype.c:79
BOOL FASTCALL IntLoadFontSubstList(PLIST_ENTRY pHead)
Definition: freetype.c:525
static UINT g_FontCacheNumEntries
Definition: freetype.c:109
VOID FASTCALL IntLoadSystemFonts(VOID)
Definition: freetype.c:907
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:108
static PFAST_MUTEX g_FontListLock
Definition: freetype.c:82
BOOL FASTCALL IntLoadFontsInRegistry(VOID)
Definition: freetype.c:1652
FT_Init_FreeType(FT_Library *alibrary)
Definition: ftinit.c:320
#define TAG_INTERNAL_SYNC
Definition: tags.h:18
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
FAST_MUTEX
Definition: extypes.h:17

Referenced by InitializeGreCSRSS().

◆ IntAddNameFromFamInfo()

static VOID IntAddNameFromFamInfo ( LPWSTR  psz,
FONTFAMILYINFO FamInfo 
)
static

Definition at line 5330 of file freetype.c.

5331{
5333 if (FamInfo->EnumLogFontEx.elfStyle[0] &&
5334 _wcsicmp(FamInfo->EnumLogFontEx.elfStyle, L"Regular") != 0)
5335 {
5336 wcscat(psz, L" ");
5337 wcscat(psz, FamInfo->EnumLogFontEx.elfStyle);
5338 }
5339}
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)

Referenced by IntGdiGetFontResourceInfo().

◆ IntCharSetFromCodePage()

BYTE FASTCALL IntCharSetFromCodePage ( UINT  uCodePage)

Definition at line 187 of file freetype.c.

188{
189 UINT i;
190
191 if (uCodePage == CP_OEMCP)
192 return OEM_CHARSET;
193
194 if (uCodePage == CP_MACCP)
195 return MAC_CHARSET;
196
197 for (i = 0; i < MAXTCIINDEX; ++i)
198 {
199 if (g_FontTci[i].ciACP == 0)
200 continue;
201
202 if (g_FontTci[i].ciACP == uCodePage)
203 return g_FontTci[i].ciCharset;
204 }
205
206 return DEFAULT_CHARSET;
207}
#define CP_OEMCP
Definition: freetype.c:181
static const CHARSETINFO g_FontTci[MAXTCIINDEX]
Definition: freetype.c:139
#define CP_MACCP
Definition: freetype.c:182
#define OEM_CHARSET
Definition: wingdi.h:400
#define MAC_CHARSET
Definition: wingdi.h:403

Referenced by CreateStockFonts().

◆ IntEnableFontRendering()

VOID FASTCALL IntEnableFontRendering ( BOOL  Enable)

Definition at line 1978 of file freetype.c.

1979{
1981}
static BOOL g_RenderingEnabled
Definition: freetype.c:83
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142

◆ IntEngFillBox()

VOID FASTCALL IntEngFillBox ( IN OUT PDC  dc,
IN INT  X,
IN INT  Y,
IN INT  Width,
IN INT  Height,
IN BRUSHOBJ BrushObj 
)

Definition at line 5956 of file freetype.c.

5963{
5964 RECTL DestRect;
5965 SURFACE *psurf = dc->dclevel.pSurface;
5966
5968 ASSERT(psurf != NULL);
5969
5970 if (Width < 0)
5971 {
5972 X += Width;
5973 Width = -Width;
5974 }
5975
5976 if (Height < 0)
5977 {
5978 Y += Height;
5979 Height = -Height;
5980 }
5981
5982 DestRect.left = X;
5983 DestRect.right = X + Width;
5984 DestRect.top = Y;
5985 DestRect.bottom = Y + Height;
5986
5987 IntEngBitBlt(&psurf->SurfObj,
5988 NULL,
5989 NULL,
5990 (CLIPOBJ *)&dc->co,
5991 NULL,
5992 &DestRect,
5993 NULL,
5994 NULL,
5995 BrushObj,
5996 &PointZero,
5998}
#define ASSERT_DC_PREPARED(pdc)
Definition: dc.h:300
#define Y(I)
static POINTL PointZero
Definition: freetype.c:65
#define X(b, s)
#define ROP4_FROM_INDEX(index)
Definition: inteng.h:42
@ R3_OPINDEX_PATCOPY
Definition: inteng.h:35
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
SURFOBJ SurfObj
Definition: surface.h:8
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
BOOL APIENTRY IntEngBitBlt(SURFOBJ *psoTrg, SURFOBJ *psoSrc, SURFOBJ *psoMask, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
Definition: bitblt.c:656

Referenced by IntExtTextOutW().

◆ IntEngFillPolygon()

VOID APIENTRY IntEngFillPolygon ( IN OUT PDC  dc,
IN POINTL pPoints,
IN UINT  cPoints,
IN BRUSHOBJ BrushObj 
)

Definition at line 5920 of file freetype.c.

5925{
5926 SURFACE *psurf = dc->dclevel.pSurface;
5927 RECT Rect;
5928 UINT i;
5929 INT x, y;
5930
5932 ASSERT(psurf != NULL);
5933
5934 Rect.left = Rect.right = pPoints[0].x;
5935 Rect.top = Rect.bottom = pPoints[0].y;
5936 for (i = 1; i < cPoints; ++i)
5937 {
5938 x = pPoints[i].x;
5939 if (x < Rect.left)
5940 Rect.left = x;
5941 else if (Rect.right < x)
5942 Rect.right = x;
5943
5944 y = pPoints[i].y;
5945 if (y < Rect.top)
5946 Rect.top = y;
5947 else if (Rect.bottom < y)
5948 Rect.bottom = y;
5949 }
5950
5951 IntFillPolygon(dc, dc->dclevel.pSurface, BrushObj, pPoints, cPoints, Rect, &PointZero);
5952}
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL FASTCALL IntFillPolygon(PDC dc, SURFACE *psurf, BRUSHOBJ *BrushObj, CONST PPOINT Points, int Count, RECTL DestRect, POINTL *BrushOrigin)
Definition: polyfill.c:590

Referenced by IntExtTextOutW().

◆ IntEscapeMatrix()

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

Definition at line 726 of file freetype.c.

727{
728 FT_Vector vecAngle;
729 /* Convert the angle in tenths of degrees into degrees as a 16.16 fixed-point value */
730 FT_Angle angle = INT_TO_FIXED(lfEscapement) / 10;
731 FT_Vector_Unit(&vecAngle, angle);
732 pmat->xx = vecAngle.x;
733 pmat->xy = -vecAngle.y;
734 pmat->yx = -pmat->xy;
735 pmat->yy = pmat->xx;
736}
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
Definition: fttrigon.h:52
FT_Vector_Unit(FT_Vector *vec, FT_Angle angle)
Definition: fttrigon.c:361
GLfloat angle
Definition: glext.h:10853

Referenced by ftGdiGetGlyphOutline(), and IntExtTextOutW().

◆ IntExtTextOutW()

BOOL APIENTRY IntExtTextOutW ( IN PDC  dc,
IN INT  XStart,
IN INT  YStart,
IN UINT  fuOptions,
IN OPTIONAL PRECTL  lprc,
IN LPCWSTR  String,
IN INT  Count,
IN OPTIONAL LPINT  Dx,
IN DWORD  dwCodePage 
)

Definition at line 6003 of file freetype.c.

6013{
6014 /*
6015 * FIXME:
6016 * Call EngTextOut, which does the real work (calling DrvTextOut where
6017 * appropriate)
6018 */
6019
6020 PDC_ATTR pdcattr;
6021 SURFOBJ *SurfObj, *SourceGlyphSurf;
6022 SURFACE *psurf;
6023 INT glyph_index, i;
6024 FT_Face face;
6025 FT_BitmapGlyph realglyph;
6026 LONGLONG X64, Y64, RealXStart64, RealYStart64, DeltaX64, DeltaY64;
6027 ULONG previous;
6028 RECTL DestRect, MaskRect;
6029 HBITMAP HSourceGlyph;
6030 SIZEL bitSize;
6031 FONTOBJ *FontObj;
6032 PFONTGDI FontGDI;
6033 PTEXTOBJ TextObj = NULL;
6034 EXLATEOBJ exloRGB2Dst, exloDst2RGB;
6035 POINT Start;
6036 PMATRIX pmxWorldToDevice;
6037 FT_Vector delta, vecAscent64, vecDescent64, vec;
6038 LOGFONTW *plf;
6039 BOOL use_kerning, bResult, DoBreak;
6041 FT_Matrix mat;
6042 BOOL bNoTransform;
6043 DWORD ch0, ch1;
6044
6045 /* Check if String is valid */
6046 if (Count > 0xFFFF || (Count > 0 && String == NULL))
6047 {
6049 return FALSE;
6050 }
6051
6052 if (PATH_IsPathOpen(dc->dclevel))
6053 {
6054 return PATH_ExtTextOut(dc,
6055 XStart, YStart,
6056 fuOptions,
6057 lprc,
6058 String, Count,
6059 Dx);
6060 }
6061
6063
6064 if (!dc->dclevel.pSurface)
6065 {
6066 /* Memory DC with no surface selected */
6067 bResult = TRUE;
6068 goto Cleanup;
6069 }
6070
6071 pdcattr = dc->pdcattr;
6072 if (pdcattr->flTextAlign & TA_UPDATECP)
6073 {
6074 Start.x = pdcattr->ptlCurrent.x;
6075 Start.y = pdcattr->ptlCurrent.y;
6076 }
6077 else
6078 {
6079 Start.x = XStart;
6080 Start.y = YStart;
6081 }
6082
6083 IntLPtoDP(dc, &Start, 1);
6084 RealXStart64 = ((LONGLONG)Start.x + dc->ptlDCOrig.x) << 6;
6085 RealYStart64 = ((LONGLONG)Start.y + dc->ptlDCOrig.y) << 6;
6086
6087 MaskRect.left = 0;
6088 MaskRect.top = 0;
6089
6090 psurf = dc->dclevel.pSurface;
6091 SurfObj = &psurf->SurfObj;
6092
6093 if (pdcattr->iGraphicsMode == GM_ADVANCED)
6094 pmxWorldToDevice = DC_pmxWorldToDevice(dc);
6095 else
6096 pmxWorldToDevice = (PMATRIX)&gmxWorldToDeviceDefault;
6097
6098 if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
6100
6101 if (lprc && (fuOptions & (ETO_CLIPPED | ETO_OPAQUE)))
6102 {
6103 IntLPtoDP(dc, (POINT*)lprc, 2);
6104 lprc->left += dc->ptlDCOrig.x;
6105 lprc->top += dc->ptlDCOrig.y;
6106 lprc->right += dc->ptlDCOrig.x;
6107 lprc->bottom += dc->ptlDCOrig.y;
6108 }
6109
6110 if (lprc && (fuOptions & ETO_OPAQUE))
6111 {
6113 lprc->left, lprc->top,
6114 lprc->right - lprc->left, lprc->bottom - lprc->top,
6115 &dc->eboBackground.BrushObject);
6116 fuOptions &= ~ETO_OPAQUE;
6117 }
6118 else
6119 {
6120 if (pdcattr->jBkMode == OPAQUE)
6121 {
6122 fuOptions |= ETO_OPAQUE;
6123 }
6124 }
6125
6126 TextObj = RealizeFontInit(pdcattr->hlfntNew);
6127 if (TextObj == NULL)
6128 {
6129 bResult = FALSE;
6130 goto Cleanup;
6131 }
6132
6133 FontObj = TextObj->Font;
6134 ASSERT(FontObj);
6135 FontGDI = ObjToGDI(FontObj, FONT);
6136 ASSERT(FontGDI);
6137
6139 Cache.Hashed.Face = face = FontGDI->SharedFace->Face;
6140
6141 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
6142 Cache.Hashed.lfHeight = plf->lfHeight;
6143 Cache.Hashed.lfWidth = plf->lfWidth;
6144 Cache.Hashed.Aspect.Emu.Bold = EMUBOLD_NEEDED(FontGDI->OriginalWeight, plf->lfWeight);
6145 Cache.Hashed.Aspect.Emu.Italic = (plf->lfItalic && !FontGDI->OriginalItalic);
6146
6148 Cache.Hashed.Aspect.RenderMode = (BYTE)IntGetFontRenderMode(plf);
6149 else
6150 Cache.Hashed.Aspect.RenderMode = (BYTE)FT_RENDER_MODE_MONO;
6151
6152 if (!TextIntUpdateSize(dc, TextObj, FontGDI, FALSE))
6153 {
6155 bResult = FALSE;
6156 goto Cleanup;
6157 }
6158
6159 /* Apply lfEscapement */
6160 if (FT_IS_SCALABLE(face) && plf->lfEscapement != 0)
6161 IntEscapeMatrix(&Cache.Hashed.matTransform, plf->lfEscapement);
6162 else
6163 Cache.Hashed.matTransform = identityMat;
6164
6165 /* Apply the world transformation */
6166 IntMatrixFromMx(&mat, pmxWorldToDevice);
6167 FT_Matrix_Multiply(&mat, &Cache.Hashed.matTransform);
6168 FT_Set_Transform(face, &Cache.Hashed.matTransform, NULL);
6169
6170 /* Is there no transformation? */
6171 bNoTransform = ((mat.xy == 0) && (mat.yx == 0) &&
6172 (mat.xx == (1 << 16)) && (mat.yy == (1 << 16)));
6173
6174 /* Calculate the ascent point and the descent point */
6175 vecAscent64.x = 0;
6176 vecAscent64.y = (FontGDI->tmAscent << 6);
6177 FT_Vector_Transform(&vecAscent64, &Cache.Hashed.matTransform);
6178 vecDescent64.x = 0;
6179 vecDescent64.y = -(FontGDI->tmDescent << 6);
6180 FT_Vector_Transform(&vecDescent64, &Cache.Hashed.matTransform);
6181
6182 /* Process the vertical alignment and fix the real starting point. */
6183#define VALIGN_MASK (TA_TOP | TA_BASELINE | TA_BOTTOM)
6184 if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BASELINE)
6185 {
6186 NOTHING;
6187 }
6188 else if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BOTTOM)
6189 {
6190 RealXStart64 -= vecDescent64.x;
6191 RealYStart64 += vecDescent64.y;
6192 }
6193 else /* TA_TOP */
6194 {
6195 RealXStart64 -= vecAscent64.x;
6196 RealYStart64 += vecAscent64.y;
6197 }
6198#undef VALIGN_MASK
6199
6200 use_kerning = FT_HAS_KERNING(face);
6201
6202 /* Calculate the text width if necessary */
6203 if ((fuOptions & ETO_OPAQUE) || (pdcattr->flTextAlign & (TA_CENTER | TA_RIGHT)))
6204 {
6205 if (!IntGetTextDisposition(&DeltaX64, &DeltaY64, String, Count, Dx, &Cache,
6206 fuOptions, bNoTransform))
6207 {
6209 bResult = FALSE;
6210 goto Cleanup;
6211 }
6212
6213 /* Adjust the horizontal position by horizontal alignment */
6214 if ((pdcattr->flTextAlign & TA_CENTER) == TA_CENTER)
6215 {
6216 RealXStart64 -= DeltaX64 / 2;
6217 RealYStart64 -= DeltaY64 / 2;
6218 }
6219 else if ((pdcattr->flTextAlign & TA_RIGHT) == TA_RIGHT)
6220 {
6221 RealXStart64 -= DeltaX64;
6222 RealYStart64 -= DeltaY64;
6223 }
6224
6225 /* Fill background */
6226 if (fuOptions & ETO_OPAQUE)
6227 {
6228 INT X0 = (RealXStart64 + vecAscent64.x + 32) >> 6;
6229 INT Y0 = (RealYStart64 - vecAscent64.y + 32) >> 6;
6230 INT DX = (DeltaX64 >> 6);
6231 if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
6232 {
6233 INT CY = (vecAscent64.y - vecDescent64.y + 32) >> 6;
6234 IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboBackground.BrushObject);
6235 }
6236 else
6237 {
6238 INT DY = (DeltaY64 >> 6);
6239 INT X1 = ((RealXStart64 + vecDescent64.x + 32) >> 6);
6240 INT Y1 = ((RealYStart64 - vecDescent64.y + 32) >> 6);
6241 POINT Points[4] =
6242 {
6243 { X0, Y0 },
6244 { X0 + DX, Y0 + DY },
6245 { X1 + DX, Y1 + DY },
6246 { X1, Y1 },
6247 };
6248 IntEngFillPolygon(dc, Points, 4, &dc->eboBackground.BrushObject);
6249 }
6250 }
6251 }
6252
6253 EXLATEOBJ_vInitialize(&exloRGB2Dst, &gpalRGB, psurf->ppal, 0, 0, 0);
6254 EXLATEOBJ_vInitialize(&exloDst2RGB, psurf->ppal, &gpalRGB, 0, 0, 0);
6255
6256 if (pdcattr->ulDirty_ & DIRTY_TEXT)
6258
6259 /*
6260 * The main rendering loop.
6261 */
6262 X64 = RealXStart64;
6263 Y64 = RealYStart64;
6264 previous = 0;
6265 DoBreak = FALSE;
6266 bResult = TRUE; /* Assume success */
6267 for (i = 0; i < Count; ++i)
6268 {
6269 ch0 = *String++;
6270 if (IS_HIGH_SURROGATE(ch0))
6271 {
6272 ++i;
6273 if (i >= Count)
6274 break;
6275
6276 ch1 = *String++;
6277 if (IS_LOW_SURROGATE(ch1))
6278 ch0 = Utf32FromSurrogatePair(ch0, ch1);
6279 }
6280
6281 glyph_index = get_glyph_index_flagged(face, ch0, ETO_GLYPH_INDEX, fuOptions);
6282 Cache.Hashed.GlyphIndex = glyph_index;
6283
6284 realglyph = IntGetRealGlyph(&Cache);
6285 if (!realglyph)
6286 {
6287 bResult = FALSE;
6288 break;
6289 }
6290
6291 /* retrieve kerning distance and move pen position */
6292 if (use_kerning && previous && glyph_index && NULL == Dx)
6293 {
6294 FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
6295 X64 += delta.x;
6296 Y64 -= delta.y;
6297 }
6298
6299 DPRINT("X64, Y64: %I64d, %I64d\n", X64, Y64);
6300 DPRINT("Advance: %d, %d\n", realglyph->root.advance.x, realglyph->root.advance.y);
6301
6302 bitSize.cx = realglyph->bitmap.width;
6303 bitSize.cy = realglyph->bitmap.rows;
6304
6305 MaskRect.right = realglyph->bitmap.width;
6306 MaskRect.bottom = realglyph->bitmap.rows;
6307
6308 DestRect.left = ((X64 + 32) >> 6) + realglyph->left;
6309 DestRect.right = DestRect.left + bitSize.cx;
6310 DestRect.top = ((Y64 + 32) >> 6) - realglyph->top;
6311 DestRect.bottom = DestRect.top + bitSize.cy;
6312
6313 /* Check if the bitmap has any pixels */
6314 if ((bitSize.cx != 0) && (bitSize.cy != 0))
6315 {
6316 /*
6317 * We should create the bitmap out of the loop at the biggest possible
6318 * glyph size. Then use memset with 0 to clear it and sourcerect to
6319 * limit the work of the transbitblt.
6320 */
6321 HSourceGlyph = EngCreateBitmap(bitSize, realglyph->bitmap.pitch,
6323 realglyph->bitmap.buffer);
6324 if (!HSourceGlyph)
6325 {
6326 DPRINT1("WARNING: EngCreateBitmap() failed!\n");
6327 bResult = FALSE;
6328 break;
6329 }
6330
6331 SourceGlyphSurf = EngLockSurface((HSURF)HSourceGlyph);
6332 if (!SourceGlyphSurf)
6333 {
6334 EngDeleteSurface((HSURF)HSourceGlyph);
6335 DPRINT1("WARNING: EngLockSurface() failed!\n");
6336 bResult = FALSE;
6337 break;
6338 }
6339
6340 /*
6341 * Use the font data as a mask to paint onto the DCs surface using a
6342 * brush.
6343 */
6344 if (lprc && (fuOptions & ETO_CLIPPED))
6345 {
6346 // We do the check '>=' instead of '>' to possibly save an iteration
6347 // through this loop, since it's breaking after the drawing is done,
6348 // and x is always incremented.
6349 if (DestRect.right >= lprc->right)
6350 {
6351 DestRect.right = lprc->right;
6352 DoBreak = TRUE;
6353 }
6354
6355 if (DestRect.bottom >= lprc->bottom)
6356 {
6357 DestRect.bottom = lprc->bottom;
6358 }
6359 }
6360
6361 if (!IntEngMaskBlt(SurfObj,
6362 SourceGlyphSurf,
6363 (CLIPOBJ *)&dc->co,
6364 &exloRGB2Dst.xlo,
6365 &exloDst2RGB.xlo,
6366 &DestRect,
6367 (PPOINTL)&MaskRect,
6368 &dc->eboText.BrushObject,
6369 &PointZero))
6370 {
6371 DPRINT1("Failed to MaskBlt a glyph!\n");
6372 }
6373
6374 EngUnlockSurface(SourceGlyphSurf);
6375 EngDeleteSurface((HSURF)HSourceGlyph);
6376 }
6377
6378 if (DoBreak)
6379 break;
6380
6381 if (NULL == Dx)
6382 {
6383 X64 += realglyph->root.advance.x >> 10;
6384 Y64 -= realglyph->root.advance.y >> 10;
6385 }
6386 else if (fuOptions & ETO_PDY)
6387 {
6388 vec.x = (Dx[2 * i + 0] << 6);
6389 vec.y = (Dx[2 * i + 1] << 6);
6390 if (!bNoTransform)
6391 FT_Vector_Transform(&vec, &Cache.Hashed.matTransform);
6392 X64 += vec.x;
6393 Y64 -= vec.y;
6394 }
6395 else
6396 {
6397 vec.x = (Dx[i] << 6);
6398 vec.y = 0;
6399 if (!bNoTransform)
6400 FT_Vector_Transform(&vec, &Cache.Hashed.matTransform);
6401 X64 += vec.x;
6402 Y64 -= vec.y;
6403 }
6404
6405 DPRINT("New X64, New Y64: %I64d, %I64d\n", X64, Y64);
6406
6407 previous = glyph_index;
6408 }
6409
6410 if (pdcattr->flTextAlign & TA_UPDATECP)
6411 pdcattr->ptlCurrent.x = DestRect.right - dc->ptlDCOrig.x;
6412
6413 if (plf->lfUnderline || plf->lfStrikeOut) /* Underline or strike-out? */
6414 {
6415 /* Calculate the position and the thickness */
6416 INT underline_position, thickness;
6417 FT_Vector vecA64, vecB64;
6418
6419 DeltaX64 = X64 - RealXStart64;
6420 DeltaY64 = Y64 - RealYStart64;
6421
6422 if (!face->units_per_EM)
6423 {
6425 thickness = 1;
6426 }
6427 else
6428 {
6430 face->underline_position * face->size->metrics.y_ppem / face->units_per_EM;
6431 thickness =
6432 face->underline_thickness * face->size->metrics.y_ppem / face->units_per_EM;
6433 if (thickness <= 0)
6434 thickness = 1;
6435 }
6436
6437 if (plf->lfUnderline) /* Draw underline */
6438 {
6439 vecA64.x = 0;
6440 vecA64.y = (-underline_position - thickness / 2) << 6;
6441 vecB64.x = 0;
6442 vecB64.y = vecA64.y + (thickness << 6);
6443 FT_Vector_Transform(&vecA64, &Cache.Hashed.matTransform);
6444 FT_Vector_Transform(&vecB64, &Cache.Hashed.matTransform);
6445 {
6446 INT X0 = (RealXStart64 - vecA64.x + 32) >> 6;
6447 INT Y0 = (RealYStart64 + vecA64.y + 32) >> 6;
6448 INT DX = (DeltaX64 >> 6);
6449 if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
6450 {
6451 INT CY = (vecB64.y - vecA64.y + 32) >> 6;
6452 IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboText.BrushObject);
6453 }
6454 else
6455 {
6456 INT DY = (DeltaY64 >> 6);
6457 INT X1 = X0 + ((vecA64.x - vecB64.x + 32) >> 6);
6458 INT Y1 = Y0 + ((vecB64.y - vecA64.y + 32) >> 6);
6459 POINT Points[4] =
6460 {
6461 { X0, Y0 },
6462 { X0 + DX, Y0 + DY },
6463 { X1 + DX, Y1 + DY },
6464 { X1, Y1 },
6465 };
6466 IntEngFillPolygon(dc, Points, 4, &dc->eboText.BrushObject);
6467 }
6468 }
6469 }
6470
6471 if (plf->lfStrikeOut) /* Draw strike-out */
6472 {
6473 vecA64.x = 0;
6474 vecA64.y = -(FontGDI->tmAscent << 6) / 3;
6475 vecB64.x = 0;
6476 vecB64.y = vecA64.y + (thickness << 6);
6477 FT_Vector_Transform(&vecA64, &Cache.Hashed.matTransform);
6478 FT_Vector_Transform(&vecB64, &Cache.Hashed.matTransform);
6479 {
6480 INT X0 = (RealXStart64 - vecA64.x + 32) >> 6;
6481 INT Y0 = (RealYStart64 + vecA64.y + 32) >> 6;
6482 INT DX = (DeltaX64 >> 6);
6483 if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
6484 {
6485 INT CY = (vecB64.y - vecA64.y + 32) >> 6;
6486 IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboText.BrushObject);
6487 }
6488 else
6489 {
6490 INT DY = (DeltaY64 >> 6);
6491 INT X1 = X0 + ((vecA64.x - vecB64.x + 32) >> 6);
6492 INT Y1 = Y0 + ((vecB64.y - vecA64.y + 32) >> 6);
6493 POINT Points[4] =
6494 {
6495 { X0, Y0 },
6496 { X0 + DX, Y0 + DY },
6497 { X1 + DX, Y1 + DY },
6498 { X1, Y1 },
6499 };
6500 IntEngFillPolygon(dc, Points, 4, &dc->eboText.BrushObject);
6501 }
6502 }
6503 }
6504 }
6505
6507
6508 EXLATEOBJ_vCleanup(&exloRGB2Dst);
6509 EXLATEOBJ_vCleanup(&exloDst2RGB);
6510
6511Cleanup:
6513
6514 if (TextObj != NULL)
6515 TEXTOBJ_UnlockText(TextObj);
6516
6517 return bResult;
6518}
static BOOLEAN IntLPtoDP(DC *pdc, PPOINTL ppt, UINT count)
Definition: coord.h:182
VOID FASTCALL DC_vPrepareDCsForBlit(PDC pdcDest, const RECT *rcDest, PDC pdcSrc, const RECT *rcSrc)
Definition: dclife.c:505
VOID FASTCALL DC_vFinishBlit(PDC pdc1, PDC pdc2)
Definition: dclife.c:614
VOID FASTCALL DC_vUpdateTextBrush(PDC pdc)
Definition: dcobjs.c:108
VOID FASTCALL DC_vUpdateBackgroundBrush(PDC pdc)
Definition: dcobjs.c:126
WORD face[3]
Definition: mesh.c:4747
static const WCHAR Cleanup[]
Definition: register.c:80
VOID APIENTRY IntEngFillPolygon(IN OUT PDC dc, IN POINTL *pPoints, IN UINT cPoints, IN BRUSHOBJ *BrushObj)
Definition: freetype.c:5920
#define IS_HIGH_SURROGATE(ch0)
Definition: freetype.c:44
static DWORD Utf32FromSurrogatePair(DWORD ch0, DWORD ch1)
Definition: freetype.c:48
#define IS_LOW_SURROGATE(ch1)
Definition: freetype.c:45
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)
Definition: freetype.c:5837
#define EMUBOLD_NEEDED(original, request)
Definition: freetype.c:59
static FT_BitmapGlyph IntGetRealGlyph(IN OUT PFONT_CACHE_ENTRY Cache)
Definition: freetype.c:4175
#define VALIGN_MASK
BOOL FASTCALL IntIsFontRenderingEnabled(VOID)
Definition: freetype.c:1972
#define gmxWorldToDeviceDefault
Definition: freetype.c:68
FT_Render_Mode FASTCALL IntGetFontRenderMode(LOGFONTW *logfont)
Definition: freetype.c:1984
VOID FASTCALL IntEngFillBox(IN OUT PDC dc, IN INT X, IN INT Y, IN INT Width, IN INT Height, IN BRUSHOBJ *BrushObj)
Definition: freetype.c:5956
@ FT_RENDER_MODE_MONO
Definition: freetype.h:3236
#define DX
Definition: i386-dis.c:425
#define NOTHING
Definition: input_list.c:10
static HBITMAP
Definition: button.c:44
#define DIRTY_TEXT
Definition: ntgdihdl.h:125
#define DIRTY_BACKGROUND
Definition: ntgdihdl.h:126
struct _MATRIX * PMATRIX
#define PATH_IsPathOpen(dclevel)
Definition: path.h:72
Definition: fatfs.h:173
FT_Bitmap bitmap
Definition: ftglyph.h:165
FT_GlyphRec root
Definition: ftglyph.h:162
FT_Vector advance
Definition: ftglyph.h:113
LONG lfEscapement
Definition: dimm.idl:61
POINTL ptlCurrent
Definition: ntgdihdl.h:311
BYTE jBkMode
Definition: ntgdihdl.h:308
INT iGraphicsMode
Definition: ntgdihdl.h:306
ULONG ulDirty_
Definition: ntgdihdl.h:294
FLONG flTextAlign
Definition: ntgdihdl.h:324
XLATEOBJ xlo
Definition: xlateobj.h:21
Definition: font.h:56
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
struct _PALETTE *const ppal
Definition: surface.h:11
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT underline_position
Definition: t1tokens.h:40
int64_t LONGLONG
Definition: typedefs.h:68
Definition: compat.h:2255
@ Start
Definition: partlist.h:33
BOOL APIENTRY IntEngMaskBlt(_Inout_ SURFOBJ *psoDest, _In_ SURFOBJ *psoMask, _In_ CLIPOBJ *pco, _In_ XLATEOBJ *pxloDest, _In_ XLATEOBJ *pxloSource, _In_ RECTL *prclDest, _In_ POINTL *pptlMask, _In_ BRUSHOBJ *pbo, _In_ POINTL *pptlBrushOrg)
Definition: bitblt.c:1103
PALETTE gpalRGB
Definition: palette.c:20
BOOL FASTCALL PATH_ExtTextOut(PDC dc, INT x, INT y, UINT flags, const RECTL *lprc, LPCWSTR str, UINT count, const INT *dx)
Definition: path.c:2355
#define BMF_8BPP
Definition: winddi.h:357
ENGAPI BOOL APIENTRY EngDeleteSurface(_In_ _Post_ptr_invalid_ HSURF hsurf)
Definition: surface.c:567
ENGAPI SURFOBJ *APIENTRY EngLockSurface(_In_ HSURF hsurf)
Definition: surface.c:607
ENGAPI HBITMAP APIENTRY EngCreateBitmap(_In_ SIZEL sizl, _In_ LONG lWidth, _In_ ULONG iFormat, _In_ FLONG fl, _In_opt_ PVOID pvBits)
#define BMF_TOPDOWN
Definition: winddi.h:1180
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
ENGAPI VOID APIENTRY EngUnlockSurface(_In_ _Post_ptr_invalid_ SURFOBJ *pso)
Definition: surface.c:628
#define GM_ADVANCED
Definition: wingdi.h:865
#define TA_UPDATECP
Definition: wingdi.h:936
#define TA_RIGHT
Definition: wingdi.h:933
#define ETO_CLIPPED
Definition: wingdi.h:648
#define ETO_OPAQUE
Definition: wingdi.h:647
#define OPAQUE
Definition: wingdi.h:949
#define ETO_PDY
Definition: wingdi.h:657
#define TA_BOTTOM
Definition: wingdi.h:929
#define TA_BASELINE
Definition: wingdi.h:928
#define TA_CENTER
Definition: wingdi.h:931
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:358
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:649

Referenced by GdiFlushUserBatch(), and GreExtTextOutW().

◆ IntFindGlyphCache()

static FT_BitmapGlyph IntFindGlyphCache ( IN const FONT_CACHE_ENTRY pCache)
static

Definition at line 3117 of file freetype.c.

3118{
3119 PLIST_ENTRY CurrentEntry;
3120 PFONT_CACHE_ENTRY FontEntry;
3121 DWORD dwHash = pCache->dwHash;
3122
3124
3125 for (CurrentEntry = g_FontCacheListHead.Flink;
3126 CurrentEntry != &g_FontCacheListHead;
3127 CurrentEntry = CurrentEntry->Flink)
3128 {
3129 FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
3130 if (FontEntry->dwHash == dwHash &&
3131 FontEntry->Hashed.GlyphIndex == pCache->Hashed.GlyphIndex &&
3132 FontEntry->Hashed.Face == pCache->Hashed.Face &&
3133 FontEntry->Hashed.lfHeight == pCache->Hashed.lfHeight &&
3134 FontEntry->Hashed.lfWidth == pCache->Hashed.lfWidth &&
3135 FontEntry->Hashed.AspectValue == pCache->Hashed.AspectValue &&
3136 memcmp(&FontEntry->Hashed.matTransform, &pCache->Hashed.matTransform,
3137 sizeof(FT_Matrix)) == 0)
3138 {
3139 break;
3140 }
3141 }
3142
3143 if (CurrentEntry == &g_FontCacheListHead)
3144 {
3145 return NULL;
3146 }
3147
3148 RemoveEntryList(CurrentEntry);
3149 InsertHeadList(&g_FontCacheListHead, CurrentEntry);
3150 return FontEntry->BitmapGlyph;
3151}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertHeadList(ListHead, Entry)
FT_BitmapGlyph BitmapGlyph
Definition: font.h:58
FONT_CACHE_HASHED Hashed
Definition: font.h:60
DWORD dwHash
Definition: font.h:59
LONG lfHeight
Definition: font.h:44
LONG lfWidth
Definition: font.h:45
INT GlyphIndex
Definition: font.h:42
FT_Face Face
Definition: font.h:43
FT_Matrix matTransform
Definition: font.h:50
DWORD AspectValue
Definition: font.h:47

Referenced by IntGetRealGlyph().

◆ IntFontType()

static VOID FASTCALL IntFontType ( PFONTGDI  Font)
static

Definition at line 5071 of file freetype.c.

5072{
5073 PS_FontInfoRec psfInfo;
5074 FT_ULong tmp_size = 0;
5075 FT_Face Face = Font->SharedFace->Face;
5076
5079
5080 if (FT_HAS_MULTIPLE_MASTERS(Face))
5081 Font->FontObj.flFontType |= FO_MULTIPLEMASTER;
5082 if (FT_HAS_VERTICAL(Face))
5083 Font->FontObj.flFontType |= FO_VERT_FACE;
5084 if (!FT_IS_SCALABLE(Face))
5085 Font->FontObj.flFontType |= FO_TYPE_RASTER;
5086 if (FT_IS_SFNT(Face))
5087 {
5088 Font->FontObj.flFontType |= FO_TYPE_TRUETYPE;
5090 Font->FontObj.flFontType |= FO_POSTSCRIPT;
5091 }
5092 if (!FT_Get_PS_Font_Info(Face, &psfInfo ))
5093 {
5094 Font->FontObj.flFontType |= FO_POSTSCRIPT;
5095 }
5096 /* Check for the presence of the 'CFF ' table to check if the font is Type1 */
5097 if (!FT_Load_Sfnt_Table(Face, TTAG_CFF, 0, NULL, &tmp_size))
5098 {
5099 Font->FontObj.flFontType |= (FO_CFF|FO_POSTSCRIPT);
5100 }
5101
5103}
#define ASSERT_FREETYPE_LOCK_NOT_HELD()
Definition: freetype.c:103
#define FT_HAS_MULTIPLE_MASTERS(face)
Definition: freetype.h:1402
#define FT_HAS_VERTICAL(face)
Definition: freetype.h:1283
FT_Get_PS_Font_Info(FT_Face face, PS_FontInfo afont_info)
FT_BEGIN_HEADER struct PS_FontInfoRec_ PS_FontInfoRec
#define ft_sfnt_post
Definition: tttables.h:634
#define TTAG_CFF
Definition: tttags.h:45
#define FO_TYPE_TRUETYPE
Definition: winddi.h:737
#define FO_CFF
Definition: winddi.h:747
#define FO_MULTIPLEMASTER
Definition: winddi.h:749
#define FO_POSTSCRIPT
Definition: winddi.h:748
#define FO_VERT_FACE
Definition: winddi.h:750
#define FO_TYPE_RASTER
Definition: winddi.h:735

Referenced by TextIntRealizeFont().

◆ IntFreeFontNames()

static __inline void FASTCALL IntFreeFontNames ( FONT_NAMES Names)
static

Definition at line 2400 of file freetype.c.

2401{
2402 RtlFreeUnicodeString(&Names->FamilyNameW);
2403 RtlFreeUnicodeString(&Names->FaceNameW);
2404 RtlFreeUnicodeString(&Names->StyleNameW);
2405 RtlFreeUnicodeString(&Names->FullNameW);
2406}
PWSTR Names[]

Referenced by IntGetOutlineTextMetrics().

◆ IntGdiAddFontMemResource()

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

Definition at line 1804 of file freetype.c.

1805{
1806 HANDLE Ret = NULL;
1808 PFONT_ENTRY_COLL_MEM EntryCollection;
1809 INT FaceCount;
1810
1812 if (!BufferCopy)
1813 {
1814 *pNumAdded = 0;
1815 return NULL;
1816 }
1817 RtlCopyMemory(BufferCopy, Buffer, dwSize);
1818
1819 LoadFont.pFileName = NULL;
1820 LoadFont.Memory = SharedMem_Create(BufferCopy, dwSize, FALSE);
1821 LoadFont.Characteristics = FR_PRIVATE | FR_NOT_ENUM;
1822 RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
1823 LoadFont.IsTrueType = FALSE;
1824 LoadFont.PrivateEntry = NULL;
1826
1827 RtlFreeUnicodeString(&LoadFont.RegValueName);
1828
1829 /* Release our copy */
1833
1834 if (FaceCount > 0)
1835 {
1836 EntryCollection = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_ENTRY_COLL_MEM), TAG_FONT);
1837 if (EntryCollection)
1838 {
1840 EntryCollection->Entry = LoadFont.PrivateEntry;
1841 IntLockProcessPrivateFonts(Win32Process);
1842 EntryCollection->Handle = ULongToHandle(++Win32Process->PrivateMemFontHandleCount);
1843 InsertTailList(&Win32Process->PrivateMemFontListHead, &EntryCollection->ListEntry);
1844 IntUnLockProcessPrivateFonts(Win32Process);
1845 Ret = EntryCollection->Handle;
1846 }
1847 }
1848 *pNumAdded = FaceCount;
1849
1850 return Ret;
1851}
#define ULongToHandle(h)
Definition: basetsd.h:81
#define InsertTailList(ListHead, Entry)
BOOL LoadFont(LPWSTR lpCmdLine)
static PSHARED_MEM SharedMem_Create(PBYTE Buffer, ULONG BufferSize, BOOL IsMapping)
Definition: freetype.c:248
static INT FASTCALL IntGdiLoadFontsFromMemory(PGDI_LOAD_FONT pLoadFont, PSHARED_FACE SharedFace, FT_Long FontIndex, INT CharSetIndex)
Definition: freetype.c:1065
static void SharedMem_Release(PSHARED_MEM Ptr)
Definition: freetype.c:305
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
Definition: font.h:20
FONT_ENTRY_MEM * Entry
Definition: font.h:23
LIST_ENTRY ListEntry
Definition: font.h:21
HANDLE Handle
Definition: font.h:22
LIST_ENTRY PrivateMemFontListHead
Definition: win32.h:285
UINT PrivateMemFontHandleCount
Definition: win32.h:286

Referenced by NtGdiAddFontMemResourceEx().

◆ IntGdiAddFontResource()

INT FASTCALL IntGdiAddFontResource ( PUNICODE_STRING  FileName,
DWORD  Characteristics 
)

Definition at line 1636 of file freetype.c.

1637{
1638 return IntGdiAddFontResourceEx(FileName, Characteristics, 0);
1639}
INT FASTCALL IntGdiAddFontResourceEx(PUNICODE_STRING FileName, DWORD Characteristics, DWORD dwFlags)
Definition: freetype.c:1437

Referenced by NtGdiAddFontResourceW().

◆ IntGdiAddFontResourceEx()

INT FASTCALL IntGdiAddFontResourceEx ( PUNICODE_STRING  FileName,
DWORD  Characteristics,
DWORD  dwFlags 
)

Definition at line 1437 of file freetype.c.

1439{
1442 PVOID Buffer = NULL;
1445 SIZE_T ViewSize = 0, Length;
1446 LARGE_INTEGER SectionSize;
1449 INT FontCount;
1451 UNICODE_STRING PathName;
1452 LPWSTR pszBuffer;
1454 static const UNICODE_STRING TrueTypePostfix = RTL_CONSTANT_STRING(L" (TrueType)");
1455 static const UNICODE_STRING DosPathPrefix = RTL_CONSTANT_STRING(L"\\??\\");
1456
1457 /* Build PathName */
1459 {
1460 Length = DosPathPrefix.Length + FileName->Length + sizeof(UNICODE_NULL);
1462 if (!pszBuffer)
1463 return 0; /* failure */
1464
1465 RtlInitEmptyUnicodeString(&PathName, pszBuffer, Length);
1466 RtlAppendUnicodeStringToString(&PathName, &DosPathPrefix);
1468 }
1469 else
1470 {
1472 if (!NT_SUCCESS(Status))
1473 return 0; /* failure */
1474 }
1475
1476 /* Open the font file */
1480 &FileHandle,
1483 &Iosb,
1486 if (!NT_SUCCESS(Status))
1487 {
1488 DPRINT1("Could not load font file: %wZ\n", &PathName);
1489 RtlFreeUnicodeString(&PathName);
1490 return 0;
1491 }
1492
1495 if (!NT_SUCCESS(Status))
1496 {
1497 DPRINT1("ObReferenceObjectByHandle failed.\n");
1499 RtlFreeUnicodeString(&PathName);
1500 return 0;
1501 }
1502
1503 SectionSize.QuadPart = 0LL;
1506 NULL, &SectionSize, PAGE_READONLY,
1508 if (!NT_SUCCESS(Status))
1509 {
1510 DPRINT1("Could not map file: %wZ\n", &PathName);
1513 RtlFreeUnicodeString(&PathName);
1514 return 0;
1515 }
1517
1519 if (!NT_SUCCESS(Status))
1520 {
1521 DPRINT1("Could not map file: %wZ\n", &PathName);
1524 RtlFreeUnicodeString(&PathName);
1525 return 0;
1526 }
1527
1528 LoadFont.pFileName = &PathName;
1530 LoadFont.Characteristics = Characteristics;
1531 RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
1532 LoadFont.IsTrueType = FALSE;
1533 LoadFont.CharSet = DEFAULT_CHARSET;
1534 LoadFont.PrivateEntry = NULL;
1535 FontCount = IntGdiLoadFontsFromMemory(&LoadFont, NULL, -1, -1);
1536
1537 /* Release our copy */
1541
1543
1545
1546 /* Save the loaded font name into the registry */
1547 if (FontCount > 0 && (dwFlags & AFRX_WRITE_REGISTRY))
1548 {
1549 UNICODE_STRING NewString;
1550 SIZE_T Length;
1551 PWCHAR pszBuffer;
1552 LPCWSTR CharSetName;
1553 if (LoadFont.IsTrueType)
1554 {
1555 /* Append " (TrueType)" */
1556 Length = LoadFont.RegValueName.Length + TrueTypePostfix.Length + sizeof(UNICODE_NULL);
1558 if (pszBuffer)
1559 {
1560 RtlInitEmptyUnicodeString(&NewString, pszBuffer, Length);
1561 NewString.Buffer[0] = UNICODE_NULL;
1562 RtlAppendUnicodeStringToString(&NewString, &LoadFont.RegValueName);
1563 RtlAppendUnicodeStringToString(&NewString, &TrueTypePostfix);
1564 RtlFreeUnicodeString(&LoadFont.RegValueName);
1565 LoadFont.RegValueName = NewString;
1566 }
1567 else
1568 {
1569 // FIXME!
1570 }
1571 }
1572 else if (LoadFont.CharSet != DEFAULT_CHARSET)
1573 {
1574 /* Append " (CharSetName)" */
1575 CharSetName = NameFromCharSet(LoadFont.CharSet);
1576 Length = LoadFont.RegValueName.Length +
1577 (wcslen(CharSetName) + 3) * sizeof(WCHAR) +
1578 sizeof(UNICODE_NULL);
1579
1581 if (pszBuffer)
1582 {
1583 RtlInitEmptyUnicodeString(&NewString, pszBuffer, Length);
1584 NewString.Buffer[0] = UNICODE_NULL;
1585 RtlAppendUnicodeStringToString(&NewString, &LoadFont.RegValueName);
1586 RtlAppendUnicodeToString(&NewString, L" (");
1587 RtlAppendUnicodeToString(&NewString, CharSetName);
1588 RtlAppendUnicodeToString(&NewString, L")");
1589 RtlFreeUnicodeString(&LoadFont.RegValueName);
1590 LoadFont.RegValueName = NewString;
1591 }
1592 else
1593 {
1594 // FIXME!
1595 }
1596 }
1597
1600 NULL, NULL);
1601 Status = ZwOpenKey(&KeyHandle, KEY_WRITE, &ObjectAttributes);
1602 if (NT_SUCCESS(Status))
1603 {
1605 LPWSTR pFileName;
1606
1608 {
1609 pFileName = PathName.Buffer;
1610 }
1611 else
1612 {
1613 pFileName = wcsrchr(PathName.Buffer, L'\\');
1614 }
1615
1616 if (pFileName)
1617 {
1619 {
1620 pFileName++;
1621 }
1622 DataSize = (wcslen(pFileName) + 1) * sizeof(WCHAR);
1623 ZwSetValueKey(KeyHandle, &LoadFont.RegValueName, 0, REG_SZ,
1624 pFileName, DataSize);
1625 }
1627 }
1628 }
1629 RtlFreeUnicodeString(&LoadFont.RegValueName);
1630
1631 RtlFreeUnicodeString(&PathName);
1632 return FontCount;
1633}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define PAGE_READONLY
Definition: compat.h:138
#define SECTION_MAP_READ
Definition: compat.h:139
#define wcsrchr
Definition: compat.h:16
#define FILE_SHARE_READ
Definition: compat.h:136
return Iosb
Definition: create.c:4402
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
static NTSTATUS DuplicateUnicodeString(PUNICODE_STRING Source, PUNICODE_STRING Destination)
Definition: freetype.c:845
static UNICODE_STRING g_FontRegPath
Definition: freetype.c:73
static LPCWSTR FASTCALL NameFromCharSet(BYTE CharSet)
Definition: freetype.c:1403
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define REG_SZ
Definition: layer.c:22
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:408
#define SEC_COMMIT
Definition: mmtypes.h:100
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define SECTION_QUERY
Definition: nt_native.h:1287
#define KEY_WRITE
Definition: nt_native.h:1031
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
NTSTATUS NTAPI MmMapViewInSystemSpace(IN PVOID SectionObject, OUT PVOID *MappedBase, IN OUT PSIZE_T ViewSize)
Definition: section.c:4447
NTSTATUS NTAPI MmCreateSection(OUT PVOID *Section, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL, IN PFILE_OBJECT FileObject OPTIONAL)
Definition: section.c:4620
#define LL
Definition: tui.h:167
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint16_t * PWCHAR
Definition: typedefs.h:56
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
#define AFRX_WRITE_REGISTRY
Definition: text.h:104
#define AFRX_DOS_DEVICE_PATH
Definition: text.h:106
#define AFRX_ALTERNATIVE_PATH
Definition: text.h:105
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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

◆ IntGdiCleanupMemEntry()

VOID FASTCALL IntGdiCleanupMemEntry ( PFONT_ENTRY_MEM  Head)

Definition at line 1856 of file freetype.c.

1857{
1859 PFONT_ENTRY_MEM FontEntry;
1860
1861 while (!IsListEmpty(&Head->ListEntry))
1862 {
1863 Entry = RemoveHeadList(&Head->ListEntry);
1864 FontEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_MEM, ListEntry);
1865
1866 CleanupFontEntry(FontEntry->Entry);
1867 ExFreePoolWithTag(FontEntry, TAG_FONT);
1868 }
1869
1870 CleanupFontEntry(Head->Entry);
1872}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
static __inline VOID FASTCALL CleanupFontEntry(PFONT_ENTRY FontEntry)
Definition: freetype.c:377
Definition: font.h:14
LIST_ENTRY ListEntry
Definition: font.h:15
FONT_ENTRY * Entry
Definition: font.h:16

Referenced by IntGdiCleanupPrivateFontsForProcess(), and IntGdiRemoveFontMemResource().

◆ IntGdiCleanupPrivateFontsForProcess()

VOID FASTCALL IntGdiCleanupPrivateFontsForProcess ( VOID  )

Definition at line 1926 of file freetype.c.

1927{
1930 PFONT_ENTRY_COLL_MEM EntryCollection;
1931
1932 DPRINT("IntGdiCleanupPrivateFontsForProcess()\n");
1933 do {
1934 Entry = NULL;
1935 EntryCollection = NULL;
1936
1937 IntLockProcessPrivateFonts(Win32Process);
1938 if (!IsListEmpty(&Win32Process->PrivateMemFontListHead))
1939 {
1940 Entry = Win32Process->PrivateMemFontListHead.Flink;
1941 EntryCollection = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
1942 UnlinkFontMemCollection(EntryCollection);
1943 }
1944 IntUnLockProcessPrivateFonts(Win32Process);
1945
1946 if (EntryCollection)
1947 {
1948 IntGdiCleanupMemEntry(EntryCollection->Entry);
1949 ExFreePoolWithTag(EntryCollection, TAG_FONT);
1950 }
1951 else
1952 {
1953 /* No Mem fonts anymore, see if we have any other private fonts left */
1954 Entry = NULL;
1955 IntLockProcessPrivateFonts(Win32Process);
1956 if (!IsListEmpty(&Win32Process->PrivateFontListHead))
1957 {
1958 Entry = RemoveHeadList(&Win32Process->PrivateFontListHead);
1959 }
1960 IntUnLockProcessPrivateFonts(Win32Process);
1961
1962 if (Entry)
1963 {
1965 }
1966 }
1967
1968 } while (Entry);
1969}
VOID FASTCALL IntGdiCleanupMemEntry(PFONT_ENTRY_MEM Head)
Definition: freetype.c:1856
static VOID FASTCALL UnlinkFontMemCollection(PFONT_ENTRY_COLL_MEM Collection)
Definition: freetype.c:1875

Referenced by GdiProcessDestroy().

◆ IntGdiGetFontResourceInfo()

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

Definition at line 5343 of file freetype.c.

5348{
5349 UNICODE_STRING EntryFileName;
5350 POBJECT_NAME_INFORMATION NameInfo1 = NULL, NameInfo2 = NULL;
5351 PLIST_ENTRY ListEntry;
5352 PFONT_ENTRY FontEntry;
5353 ULONG Size, i, Count;
5354 LPBYTE pbBuffer;
5355 BOOL IsEqual;
5356 FONTFAMILYINFO *FamInfo;
5357 const ULONG MaxFamInfo = 64;
5358 const ULONG MAX_FAM_INFO_BYTES = sizeof(FONTFAMILYINFO) * MaxFamInfo;
5359 BOOL bSuccess;
5360 const ULONG NAMEINFO_SIZE = sizeof(OBJECT_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR);
5361
5362 DPRINT("IntGdiGetFontResourceInfo: dwType == %lu\n", dwType);
5363
5364 do
5365 {
5366 /* Create buffer for full path name */
5367 NameInfo1 = ExAllocatePoolWithTag(PagedPool, NAMEINFO_SIZE, TAG_FINF);
5368 if (!NameInfo1)
5369 break;
5370
5371 /* Get the full path name */
5372 if (!IntGetFullFileName(NameInfo1, NAMEINFO_SIZE, FileName))
5373 break;
5374
5375 /* Create a buffer for the entries' names */
5376 NameInfo2 = ExAllocatePoolWithTag(PagedPool, NAMEINFO_SIZE, TAG_FINF);
5377 if (!NameInfo2)
5378 break;
5379
5380 FamInfo = ExAllocatePoolWithTag(PagedPool, MAX_FAM_INFO_BYTES, TAG_FINF);
5381 } while (0);
5382
5383 if (!NameInfo1 || !NameInfo2 || !FamInfo)
5384 {
5385 if (NameInfo2)
5386 ExFreePoolWithTag(NameInfo2, TAG_FINF);
5387
5388 if (NameInfo1)
5389 ExFreePoolWithTag(NameInfo1, TAG_FINF);
5390
5392 return FALSE;
5393 }
5394
5395 Count = 0;
5396
5397 /* Try to find the pathname in the global font list */
5399 for (ListEntry = g_FontListHead.Flink; ListEntry != &g_FontListHead;
5400 ListEntry = ListEntry->Flink)
5401 {
5402 FontEntry = CONTAINING_RECORD(ListEntry, FONT_ENTRY, ListEntry);
5403 if (FontEntry->Font->Filename == NULL)
5404 continue;
5405
5406 RtlInitUnicodeString(&EntryFileName , FontEntry->Font->Filename);
5407 if (!IntGetFullFileName(NameInfo2, NAMEINFO_SIZE, &EntryFileName))
5408 continue;
5409
5410 if (!RtlEqualUnicodeString(&NameInfo1->Name, &NameInfo2->Name, FALSE))
5411 continue;
5412
5413 IsEqual = FALSE;
5414 FontFamilyFillInfo(&FamInfo[Count], FontEntry->FaceName.Buffer,
5415 NULL, FontEntry->Font);
5416 for (i = 0; i < Count; ++i)
5417 {
5418 if (EqualFamilyInfo(&FamInfo[i], &FamInfo[Count]))
5419 {
5420 IsEqual = TRUE;
5421 break;
5422 }
5423 }
5424 if (!IsEqual)
5425 {
5426 /* Found */
5427 ++Count;
5428 if (Count >= MaxFamInfo)
5429 break;
5430 }
5431 }
5433
5434 /* Free the buffers */
5435 ExFreePoolWithTag(NameInfo1, TAG_FINF);
5436 ExFreePoolWithTag(NameInfo2, TAG_FINF);
5437
5438 if (Count == 0 && dwType != 5)
5439 {
5440 /* Font could not be found in system table
5441 dwType == 5 will still handle this */
5442 ExFreePoolWithTag(FamInfo, TAG_FINF);
5443 return FALSE;
5444 }
5445
5446 bSuccess = FALSE;
5447 switch (dwType)
5448 {
5449 case 0: /* FIXME: Returns 1 or 2, don't know what this is atm */
5450 Size = sizeof(DWORD);
5451 if (*pdwBytes == 0)
5452 {
5453 *pdwBytes = Size;
5454 bSuccess = TRUE;
5455 }
5456 else if (pBuffer)
5457 {
5458 if (*pdwBytes >= Size)
5459 {
5460 *(DWORD*)pBuffer = Count;
5461 }
5462 *pdwBytes = Size;
5463 bSuccess = TRUE;
5464 }
5465 break;
5466
5467 case 1: /* copy the font title */
5468 /* calculate the required size */
5469 Size = 0;
5470 for (i = 0; i < Count; ++i)
5471 {
5472 if (i > 0)
5473 Size += 3; /* " & " */
5474 Size += wcslen(FamInfo[i].EnumLogFontEx.elfLogFont.lfFaceName);
5475 if (FamInfo[i].EnumLogFontEx.elfStyle[0] &&
5476 _wcsicmp(FamInfo[i].EnumLogFontEx.elfStyle, L"Regular") != 0)
5477 {
5478 Size += 1 + wcslen(FamInfo[i].EnumLogFontEx.elfStyle);
5479 }
5480 }
5481 Size += 2; /* "\0\0" */
5482 Size *= sizeof(WCHAR);
5483
5484 if (*pdwBytes == 0)
5485 {
5486 *pdwBytes = Size;
5487 bSuccess = TRUE;
5488 }
5489 else if (pBuffer)
5490 {
5491 if (*pdwBytes >= Size)
5492 {
5493 /* store font title to buffer */
5494 WCHAR *psz = pBuffer;
5495 *psz = 0;
5496 for (i = 0; i < Count; ++i)
5497 {
5498 if (i > 0)
5499 wcscat(psz, L" & ");
5500 IntAddNameFromFamInfo(psz, &FamInfo[i]);
5501 }
5502 psz[wcslen(psz) + 1] = UNICODE_NULL;
5503 *pdwBytes = Size;
5504 bSuccess = TRUE;
5505 }
5506 else
5507 {
5508 *pdwBytes = 1024; /* this is confirmed value */
5509 }
5510 }
5511 break;
5512
5513 case 2: /* Copy an array of LOGFONTW */
5514 Size = Count * sizeof(LOGFONTW);
5515 if (*pdwBytes == 0)
5516 {
5517 *pdwBytes = Size;
5518 bSuccess = TRUE;
5519 }
5520 else if (pBuffer)
5521 {
5522 if (*pdwBytes >= Size)
5523 {
5524 pbBuffer = (LPBYTE)pBuffer;
5525 for (i = 0; i < Count; ++i)
5526 {
5527 FamInfo[i].EnumLogFontEx.elfLogFont.lfWidth = 0;
5528 RtlCopyMemory(pbBuffer, &FamInfo[i].EnumLogFontEx.elfLogFont, sizeof(LOGFONTW));
5529 pbBuffer += sizeof(LOGFONTW);
5530 }
5531 }
5532 *pdwBytes = Size;
5533 bSuccess = TRUE;
5534 }
5535 else
5536 {
5537 *pdwBytes = 1024; /* this is confirmed value */
5538 }
5539 break;
5540
5541 case 3:
5542 Size = sizeof(DWORD);
5543 if (*pdwBytes == 0)
5544 {
5545 *pdwBytes = Size;
5546 bSuccess = TRUE;
5547 }
5548 else if (pBuffer)
5549 {
5550 if (*pdwBytes >= Size)
5551 {
5552 /* FIXME: What exactly is copied here? */
5553 *(DWORD*)pBuffer = 1;
5554 }
5555 *pdwBytes = Size;
5556 bSuccess = TRUE;
5557 }
5558 break;
5559
5560 case 4: /* full file path */
5561 if (FileName->Length >= 4 * sizeof(WCHAR))
5562 {
5563 /* The beginning of FileName is \??\ */
5564 LPWSTR pch = FileName->Buffer + 4;
5565 DWORD Length = FileName->Length - 4 * sizeof(WCHAR);
5566
5567 Size = Length + sizeof(WCHAR);
5568 if (*pdwBytes == 0)
5569 {
5570 *pdwBytes = Size;
5571 bSuccess = TRUE;
5572 }
5573 else if (pBuffer)
5574 {
5575 if (*pdwBytes >= Size)
5576 {
5578 }
5579 *pdwBytes = Size;
5580 bSuccess = TRUE;
5581 }
5582 }
5583 break;
5584
5585 case 5: /* Looks like a BOOL that is copied, TRUE, if the font was not found */
5586 Size = sizeof(BOOL);
5587 if (*pdwBytes == 0)
5588 {
5589 *pdwBytes = Size;
5590 bSuccess = TRUE;
5591 }
5592 else if (pBuffer)
5593 {
5594 if (*pdwBytes >= Size)
5595 {
5596 *(BOOL*)pBuffer = Count == 0;
5597 }
5598 *pdwBytes = Size;
5599 bSuccess = TRUE;
5600 }
5601 break;
5602 }
5603 ExFreePoolWithTag(FamInfo, TAG_FINF);
5604
5605 return bSuccess;
5606}
#define MAX_PATH
Definition: compat.h:34
static BOOLEAN bSuccess
Definition: drive.cpp:433
@ IsEqual
Definition: fatprocs.h:1886
static BOOL FASTCALL IntGetFullFileName(POBJECT_NAME_INFORMATION NameInfo, ULONG Size, PUNICODE_STRING FileName)
Definition: freetype.c:5266
static BOOL EqualFamilyInfo(const FONTFAMILYINFO *pInfo1, const FONTFAMILYINFO *pInfo2)
Definition: freetype.c:5309
static VOID IntAddNameFromFamInfo(LPWSTR psz, FONTFAMILYINFO *FamInfo)
Definition: freetype.c:5330
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
#define pch(ap)
Definition: match.c:418
#define BOOL
Definition: nt_native.h:43
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
#define DWORD
Definition: nt_native.h:44
struct tagFONTFAMILYINFO FONTFAMILYINFO
PVOID pBuffer
UNICODE_STRING Name
Definition: nt_native.h:1270
LONG lfWidth
Definition: wingdi.h:1898
unsigned char * LPBYTE
Definition: typedefs.h:53
#define TAG_FINF
Definition: text.h:3

Referenced by NtGdiGetFontResourceInfoInternalW().

◆ IntGdiLoadFontsFromMemory()

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

Definition at line 1065 of file freetype.c.

1067{
1070 FONT_ENTRY_MEM* PrivateEntry = NULL;
1071 FONTGDI * FontGDI;
1073 FT_Face Face;
1075 FT_WinFNT_HeaderRec WinFNT;
1076 INT FaceCount = 0, CharSetCount = 0;
1077 PUNICODE_STRING pFileName = pLoadFont->pFileName;
1078 DWORD Characteristics = pLoadFont->Characteristics;
1079 PUNICODE_STRING pValueName = &pLoadFont->RegValueName;
1080 TT_OS2 * pOS2;
1081 INT BitIndex;
1082 FT_UShort os2_version;
1083 FT_ULong os2_ulCodePageRange1;
1084 FT_UShort os2_usWeightClass;
1085
1086 if (SharedFace == NULL && CharSetIndex == -1)
1087 {
1088 /* load a face from memory */
1092 pLoadFont->Memory->Buffer,
1093 pLoadFont->Memory->BufferSize,
1094 ((FontIndex != -1) ? FontIndex : 0),
1095 &Face);
1096
1097 if (!Error)
1098 SharedFace = SharedFace_Create(Face, pLoadFont->Memory);
1099
1101
1102 if (!Error && FT_IS_SFNT(Face))
1103 pLoadFont->IsTrueType = TRUE;
1104
1105 if (Error || SharedFace == NULL)
1106 {
1107 if (SharedFace)
1108 SharedFace_Release(SharedFace);
1109
1110 if (Error == FT_Err_Unknown_File_Format)
1111 DPRINT1("Unknown font file format\n");
1112 else
1113 DPRINT1("Error reading font (error code: %d)\n", Error);
1114 return 0; /* failure */
1115 }
1116 }
1117 else
1118 {
1119 Face = SharedFace->Face;
1121 SharedFace_AddRef(SharedFace);
1123 }
1124
1125 /* allocate a FONT_ENTRY */
1127 if (!Entry)
1128 {
1129 SharedFace_Release(SharedFace);
1131 return 0; /* failure */
1132 }
1133
1134 /* allocate a FONTGDI */
1135 FontGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(FONTGDI), GDITAG_RFONT);
1136 if (!FontGDI)
1137 {
1138 SharedFace_Release(SharedFace);
1141 return 0; /* failure */
1142 }
1143
1144 /* set file name */
1145 if (pFileName)
1146 {
1148 pFileName->Length + sizeof(UNICODE_NULL),
1149 GDITAG_PFF);
1150 if (FontGDI->Filename == NULL)
1151 {
1152 EngFreeMem(FontGDI);
1153 SharedFace_Release(SharedFace);
1156 return 0; /* failure */
1157 }
1158
1159 RtlCopyMemory(FontGDI->Filename, pFileName->Buffer, pFileName->Length);
1160 FontGDI->Filename[pFileName->Length / sizeof(WCHAR)] = UNICODE_NULL;
1161 }
1162 else
1163 {
1164 FontGDI->Filename = NULL;
1165
1166 PrivateEntry = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_ENTRY_MEM), TAG_FONT);
1167 if (!PrivateEntry)
1168 {
1169 if (FontGDI->Filename)
1171 EngFreeMem(FontGDI);
1172 SharedFace_Release(SharedFace);
1174 return 0;
1175 }
1176
1177 PrivateEntry->Entry = Entry;
1178 if (pLoadFont->PrivateEntry)
1179 {
1180 InsertTailList(&pLoadFont->PrivateEntry->ListEntry, &PrivateEntry->ListEntry);
1181 }
1182 else
1183 {
1184 InitializeListHead(&PrivateEntry->ListEntry);
1185 pLoadFont->PrivateEntry = PrivateEntry;
1186 }
1187 }
1188
1189 /* set face */
1190 FontGDI->SharedFace = SharedFace;
1191 FontGDI->CharSet = ANSI_CHARSET;
1192 FontGDI->OriginalItalic = FALSE;
1193 FontGDI->RequestItalic = FALSE;
1194 FontGDI->OriginalWeight = FALSE;
1195 FontGDI->RequestWeight = FW_NORMAL;
1196
1198 pOS2 = (TT_OS2 *)FT_Get_Sfnt_Table(Face, FT_SFNT_OS2);
1199 if (pOS2)
1200 {
1201 FontGDI->OriginalItalic = !!(pOS2->fsSelection & 0x1);
1202 FontGDI->OriginalWeight = pOS2->usWeightClass;
1203 }
1204 else
1205 {
1206 Error = FT_Get_WinFNT_Header(Face, &WinFNT);
1207 if (!Error)
1208 {
1209 FontGDI->OriginalItalic = !!WinFNT.italic;
1210 FontGDI->OriginalWeight = WinFNT.weight;
1211 }
1212 }
1214
1217 if (NT_SUCCESS(Status))
1218 {
1219 if (Face->style_name && Face->style_name[0] &&
1220 strcmp(Face->style_name, "Regular") != 0)
1221 {
1224 if (!NT_SUCCESS(Status))
1225 {
1226 RtlFreeUnicodeString(&Entry->FaceName);
1227 }
1228 }
1229 else
1230 {
1231 RtlInitUnicodeString(&Entry->StyleName, NULL);
1232 }
1233 }
1234 if (!NT_SUCCESS(Status))
1235 {
1236 if (PrivateEntry)
1237 {
1238 if (pLoadFont->PrivateEntry == PrivateEntry)
1239 {
1240 pLoadFont->PrivateEntry = NULL;
1241 }
1242 else
1243 {
1244 RemoveEntryList(&PrivateEntry->ListEntry);
1245 }
1246 ExFreePoolWithTag(PrivateEntry, TAG_FONT);
1247 }
1248 if (FontGDI->Filename)
1250 EngFreeMem(FontGDI);
1251 SharedFace_Release(SharedFace);
1253 return 0;
1254 }
1255
1256 os2_version = 0;
1258 pOS2 = (TT_OS2 *)FT_Get_Sfnt_Table(Face, FT_SFNT_OS2);
1259 if (pOS2)
1260 {
1261 os2_version = pOS2->version;
1262 os2_ulCodePageRange1 = pOS2->ulCodePageRange1;
1263 os2_usWeightClass = pOS2->usWeightClass;
1264 }
1266
1267 if (pOS2 && os2_version >= 1)
1268 {
1269 /* get charset and weight from OS/2 header */
1270
1271 /* Make sure we do not use this pointer anymore */
1272 pOS2 = NULL;
1273
1274 for (BitIndex = 0; BitIndex < MAXTCIINDEX; ++BitIndex)
1275 {
1276 if (os2_ulCodePageRange1 & (1 << BitIndex))
1277 {
1278 if (g_FontTci[BitIndex].ciCharset == DEFAULT_CHARSET)
1279 continue;
1280
1281 if ((CharSetIndex == -1 && CharSetCount == 0) ||
1282 CharSetIndex == CharSetCount)
1283 {
1284 FontGDI->CharSet = g_FontTci[BitIndex].ciCharset;
1285 }
1286
1287 ++CharSetCount;
1288 }
1289 }
1290
1291 /* set actual weight */
1292 FontGDI->OriginalWeight = os2_usWeightClass;
1293 }
1294 else
1295 {
1296 /* get charset from WinFNT header */
1298 Error = FT_Get_WinFNT_Header(Face, &WinFNT);
1299 if (!Error)
1300 {
1301 FontGDI->CharSet = WinFNT.charset;
1302 }
1304 }
1305
1306 ++FaceCount;
1307 DPRINT("Font loaded: %s (%s)\n",
1308 Face->family_name ? Face->family_name : "<NULL>",
1309 Face->style_name ? Face->style_name : "<NULL>");
1310 DPRINT("Num glyphs: %d\n", Face->num_glyphs);
1311 DPRINT("CharSet: %d\n", FontGDI->CharSet);
1312
1313 /* Add this font resource to the font table */
1314 Entry->Font = FontGDI;
1315 Entry->NotEnum = (Characteristics & FR_NOT_ENUM);
1316
1317 if (Characteristics & FR_PRIVATE)
1318 {
1319 /* private font */
1321 IntLockProcessPrivateFonts(Win32Process);
1322 InsertTailList(&Win32Process->PrivateFontListHead, &Entry->ListEntry);
1323 IntUnLockProcessPrivateFonts(Win32Process);
1324 }
1325 else
1326 {
1327 /* global font */
1329 InsertTailList(&g_FontListHead, &Entry->ListEntry);
1331 }
1332
1333 if (FontIndex == -1)
1334 {
1335 if (FT_IS_SFNT(Face))
1336 {
1337 TT_Face TrueType = (TT_Face)Face;
1338 if (TrueType->ttc_header.count > 1)
1339 {
1340 FT_Long i;
1341 for (i = 1; i < TrueType->ttc_header.count; ++i)
1342 {
1343 FaceCount += IntGdiLoadFontsFromMemory(pLoadFont, NULL, i, -1);
1344 }
1345 }
1346 }
1347 FontIndex = 0;
1348 }
1349
1350 if (CharSetIndex == -1)
1351 {
1352 INT i;
1353 USHORT NameLength = Entry->FaceName.Length;
1354
1355 if (Entry->StyleName.Length)
1356 NameLength += Entry->StyleName.Length + sizeof(WCHAR);
1357
1358 if (pLoadFont->RegValueName.Length == 0)
1359 {
1360 pValueName->Length = 0;
1361 pValueName->MaximumLength = NameLength + sizeof(WCHAR);
1363 pValueName->MaximumLength,
1364 TAG_USTR);
1365 pValueName->Buffer[0] = UNICODE_NULL;
1366 RtlAppendUnicodeStringToString(pValueName, &Entry->FaceName);
1367 }
1368 else
1369 {
1370 UNICODE_STRING NewString;
1371 USHORT Length = pValueName->Length + 3 * sizeof(WCHAR) + NameLength;
1372 NewString.Length = 0;
1373 NewString.MaximumLength = Length + sizeof(WCHAR);
1375 NewString.MaximumLength,
1376 TAG_USTR);
1377 NewString.Buffer[0] = UNICODE_NULL;
1378
1379 RtlAppendUnicodeStringToString(&NewString, pValueName);
1380 RtlAppendUnicodeToString(&NewString, L" & ");
1381 RtlAppendUnicodeStringToString(&NewString, &Entry->FaceName);
1382
1383 RtlFreeUnicodeString(pValueName);
1384 *pValueName = NewString;
1385 }
1386 if (Entry->StyleName.Length)
1387 {
1388 RtlAppendUnicodeToString(pValueName, L" ");
1389 RtlAppendUnicodeStringToString(pValueName, &Entry->StyleName);
1390 }
1391
1392 for (i = 1; i < CharSetCount; ++i)
1393 {
1394 /* Do not count charsets towards 'faces' loaded */
1395 IntGdiLoadFontsFromMemory(pLoadFont, SharedFace, FontIndex, i);
1396 }
1397 }
1398
1399 return FaceCount; /* number of loaded faces */
1400}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
@ AnsiString
Definition: dnslib.h:19
static PSHARED_FACE SharedFace_Create(FT_Face Face, PSHARED_MEM Memory)
Definition: freetype.c:229
static void SharedFace_AddRef(PSHARED_FACE Ptr)
Definition: freetype.c:264
FT_New_Memory_Face(FT_Library library, const FT_Byte *file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface)
Definition: ftobjs.c:1431
signed long FT_Long
Definition: fttypes.h:242
unsigned short FT_UShort
Definition: fttypes.h:209
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
FT_Long num_glyphs
Definition: freetype.h:1076
FT_String * family_name
Definition: freetype.h:1078
FT_UShort weight
Definition: ftwinfnt.h:199
PUNICODE_STRING pFileName
Definition: font.h:86
PFONT_ENTRY_MEM PrivateEntry
Definition: font.h:92
PSHARED_MEM Memory
Definition: font.h:87
UNICODE_STRING RegValueName
Definition: font.h:89
BOOL IsTrueType
Definition: font.h:90
DWORD Characteristics
Definition: font.h:88
TTC_HeaderRec ttc_header
Definition: tttypes.h:1395
FT_UShort fsSelection
Definition: tttables.h:408
FT_UShort usWeightClass
Definition: tttables.h:384
ULONG BufferSize
Definition: engobjects.h:120
PVOID Buffer
Definition: engobjects.h:119
@ FT_SFNT_OS2
Definition: tttables.h:617
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:973
#define GDITAG_RFONT
Definition: tags.h:92

Referenced by IntGdiAddFontMemResource(), IntGdiAddFontResourceEx(), and IntGdiLoadFontsFromMemory().

◆ IntGdiRemoveFontMemResource()

BOOL FASTCALL IntGdiRemoveFontMemResource ( HANDLE  hMMFont)

Definition at line 1892 of file freetype.c.

1893{
1895 PFONT_ENTRY_COLL_MEM CurrentEntry;
1896 PFONT_ENTRY_COLL_MEM EntryCollection = NULL;
1898
1899 IntLockProcessPrivateFonts(Win32Process);
1900 for (Entry = Win32Process->PrivateMemFontListHead.Flink;
1901 Entry != &Win32Process->PrivateMemFontListHead;
1902 Entry = Entry->Flink)
1903 {
1904 CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
1905
1906 if (CurrentEntry->Handle == hMMFont)
1907 {
1908 EntryCollection = CurrentEntry;
1909 UnlinkFontMemCollection(CurrentEntry);
1910 break;
1911 }
1912 }
1913 IntUnLockProcessPrivateFonts(Win32Process);
1914
1915 if (EntryCollection)
1916 {
1917 IntGdiCleanupMemEntry(EntryCollection->Entry);
1918 ExFreePoolWithTag(EntryCollection, TAG_FONT);
1919 return TRUE;
1920 }
1921 return FALSE;
1922}

Referenced by NtGdiRemoveFontMemResourceEx().

◆ IntGetBitmapGlyphWithCache()

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

Definition at line 3154 of file freetype.c.

3157{
3158 FT_Glyph GlyphCopy;
3159 INT error;
3160 PFONT_CACHE_ENTRY NewEntry;
3161 FT_Bitmap AlignedBitmap;
3162 FT_BitmapGlyph BitmapGlyph;
3163
3165
3166 error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
3167 if (error)
3168 {
3169 DPRINT1("Failure caching glyph.\n");
3170 return NULL;
3171 };
3172
3173 error = FT_Glyph_To_Bitmap(&GlyphCopy, Cache->Hashed.Aspect.RenderMode, 0, 1);
3174 if (error)
3175 {
3176 FT_Done_Glyph(GlyphCopy);
3177 DPRINT1("Failure rendering glyph.\n");
3178 return NULL;
3179 };
3180
3182 if (!NewEntry)
3183 {
3184 DPRINT1("Alloc failure caching glyph.\n");
3185 FT_Done_Glyph(GlyphCopy);
3186 return NULL;
3187 }
3188
3189 BitmapGlyph = (FT_BitmapGlyph)GlyphCopy;
3190 FT_Bitmap_New(&AlignedBitmap);
3191 if(FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3192 {
3193 DPRINT1("Conversion failed\n");
3194 ExFreePoolWithTag(NewEntry, TAG_FONT);
3195 FT_Bitmap_Done(GlyphSlot->library, &AlignedBitmap);
3196 FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3197 return NULL;
3198 }
3199
3200 FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3201 BitmapGlyph->bitmap = AlignedBitmap;
3202
3203 NewEntry->BitmapGlyph = BitmapGlyph;
3204 NewEntry->dwHash = Cache->dwHash;
3205 NewEntry->Hashed = Cache->Hashed;
3206
3209 {
3211 RemoveCachedEntry(NewEntry);
3212 }
3213
3214 return BitmapGlyph;
3215}
#define MAX_FONT_CACHE
Definition: freetype.c:106
static void RemoveCachedEntry(PFONT_CACHE_ENTRY Entry)
Definition: freetype.c:272
FT_Bitmap_Convert(FT_Library library, const FT_Bitmap *source, FT_Bitmap *target, FT_Int alignment)
Definition: ftbitmap.c:504
FT_Bitmap_New(FT_Bitmap *abitmap)
Definition: ftbitmap.c:44
FT_Bitmap_Done(FT_Library library, FT_Bitmap *bitmap)
Definition: ftbitmap.c:826
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633
FT_Glyph_To_Bitmap(FT_Glyph *the_glyph, FT_Render_Mode render_mode, FT_Vector *origin, FT_Bool destroy)
Definition: ftglyph.c:527
FT_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph)
Definition: ftglyph.c:363
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:127
LIST_ENTRY ListEntry
Definition: font.h:57
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122

Referenced by IntGetRealGlyph().

◆ IntGetCharSet()

UINT FASTCALL IntGetCharSet ( INT  nIndex,
FT_ULong  CodePageRange1 
)

Definition at line 1035 of file freetype.c.

1036{
1037 UINT BitIndex, CharSet;
1038 UINT nCount = 0;
1039
1040 if (CodePageRange1 == 0)
1041 {
1042 return (nIndex < 0) ? 1 : DEFAULT_CHARSET;
1043 }
1044
1045 for (BitIndex = 0; BitIndex < MAXTCIINDEX; ++BitIndex)
1046 {
1047 if (CodePageRange1 & (1 << BitIndex))
1048 {
1049 CharSet = g_FontTci[BitIndex].ciCharset;
1050 if ((nIndex >= 0) && (nCount == (UINT)nIndex))
1051 {
1052 return CharSet;
1053 }
1054 ++nCount;
1055 }
1056 }
1057
1058 return (nIndex < 0) ? nCount : ANSI_CHARSET;
1059}
static void CharSet(RTF_Info *info)
Definition: reader.c:2420

◆ IntGetFontFamilyInfo()

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

Definition at line 5681 of file freetype.c.

5685{
5686 LONG AvailCount = 0;
5687 PPROCESSINFO Win32Process;
5688
5689 /* Enumerate font families in the global list */
5691 if (!GetFontFamilyInfoForList(SafeLogFont, SafeInfo, NULL, &AvailCount,
5692 InfoCount, &g_FontListHead))
5693 {
5695 return -1;
5696 }
5698
5699 /* Enumerate font families in the process local list */
5700 Win32Process = PsGetCurrentProcessWin32Process();
5701 IntLockProcessPrivateFonts(Win32Process);
5702 if (!GetFontFamilyInfoForList(SafeLogFont, SafeInfo, NULL, &AvailCount, InfoCount,
5703 &Win32Process->PrivateFontListHead))
5704 {
5705 IntUnLockProcessPrivateFonts(Win32Process);
5706 return -1;
5707 }
5708 IntUnLockProcessPrivateFonts(Win32Process);
5709
5710 /* Enumerate font families in the registry */
5711 if (!GetFontFamilyInfoForSubstitutes(SafeLogFont, SafeInfo, &AvailCount, InfoCount))
5712 {
5713 return -1;
5714 }
5715
5716 return AvailCount;
5717}
static BOOLEAN FASTCALL GetFontFamilyInfoForSubstitutes(const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LONG *pCount, LONG MaxCount)
Definition: freetype.c:3026

Referenced by NtGdiGetFontFamilyInfo().

◆ IntGetFontLocalizedName()

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

Definition at line 2618 of file freetype.c.

2620{
2622 INT i, Count, BestIndex, Score, BestScore;
2625 ANSI_STRING AnsiName;
2627 FT_Face Face = SharedFace->Face;
2628
2629 RtlFreeUnicodeString(pNameW);
2630
2631 /* select cache */
2633 {
2634 Cache = &SharedFace->EnglishUS;
2635 }
2636 else
2637 {
2638 Cache = &SharedFace->UserLanguage;
2639 }
2640
2641 /* use cache if available */
2642 if (NameID == TT_NAME_ID_FONT_FAMILY && Cache->FontFamily.Buffer)
2643 {
2644 return DuplicateUnicodeString(&Cache->FontFamily, pNameW);
2645 }
2646 if (NameID == TT_NAME_ID_FULL_NAME && Cache->FullName.Buffer)
2647 {
2648 return DuplicateUnicodeString(&Cache->FullName, pNameW);
2649 }
2650
2651 BestIndex = -1;
2652 BestScore = 0;
2653
2655 for (i = 0; i < Count; ++i)
2656 {
2657 Error = FT_Get_Sfnt_Name(Face, i, &Name);
2658 if (Error)
2659 {
2660 continue; /* failure */
2661 }
2662
2663 if (Name.name_id != NameID)
2664 {
2665 continue; /* mismatched */
2666 }
2667
2668 if (Name.platform_id != TT_PLATFORM_MICROSOFT ||
2669 (Name.encoding_id != TT_MS_ID_UNICODE_CS &&
2670 Name.encoding_id != TT_MS_ID_SYMBOL_CS))
2671 {
2672 continue; /* not Microsoft Unicode name */
2673 }
2674
2675 if (Name.string == NULL || Name.string_len == 0 ||
2676 (Name.string[0] == 0 && Name.string[1] == 0))
2677 {
2678 continue; /* invalid string */
2679 }
2680
2681 if (Name.language_id == LangID)
2682 {
2683 Score = 30;
2684 BestIndex = i;
2685 break; /* best match */
2686 }
2687 else if (PRIMARYLANGID(Name.language_id) == PRIMARYLANGID(LangID))
2688 {
2689 Score = 20;
2690 }
2691 else if (PRIMARYLANGID(Name.language_id) == LANG_ENGLISH)
2692 {
2693 Score = 10;
2694 }
2695 else
2696 {
2697 Score = 0;
2698 }
2699
2700 if (Score > BestScore)
2701 {
2702 BestScore = Score;
2703 BestIndex = i;
2704 }
2705 }
2706
2707 if (BestIndex >= 0)
2708 {
2709 /* store the best name */
2710 Error = (Score == 30) ? 0 : FT_Get_Sfnt_Name(Face, BestIndex, &Name);
2711 if (!Error)
2712 {
2713 /* NOTE: Name.string is not null-terminated */
2714 UNICODE_STRING Tmp;
2715 Tmp.Buffer = (PWCH)Name.string;
2716 Tmp.Length = Tmp.MaximumLength = Name.string_len;
2717
2718 pNameW->Length = 0;
2719 pNameW->MaximumLength = Name.string_len + sizeof(WCHAR);
2721
2722 if (pNameW->Buffer)
2723 {
2724 Status = RtlAppendUnicodeStringToString(pNameW, &Tmp);
2725 if (Status == STATUS_SUCCESS)
2726 {
2727 /* Convert UTF-16 big endian to little endian */
2728 SwapEndian(pNameW->Buffer, pNameW->Length);
2729 }
2730 }
2731 else
2732 {
2734 }
2735 }
2736 }
2737
2738 if (!NT_SUCCESS(Status))
2739 {
2740 /* defaulted */
2741 if (NameID == TT_NAME_ID_FONT_SUBFAMILY)
2742 {
2743 RtlInitAnsiString(&AnsiName, Face->style_name);
2744 Status = RtlAnsiStringToUnicodeString(pNameW, &AnsiName, TRUE);
2745 }
2746 else
2747 {
2748 RtlInitAnsiString(&AnsiName, Face->family_name);
2749 Status = RtlAnsiStringToUnicodeString(pNameW, &AnsiName, TRUE);
2750 }
2751 }
2752
2753 if (NT_SUCCESS(Status))
2754 {
2755 /* make cache */
2756 if (NameID == TT_NAME_ID_FONT_FAMILY)
2757 {
2760 if (!Cache->FontFamily.Buffer)
2761 DuplicateUnicodeString(pNameW, &Cache->FontFamily);
2763 }
2764 else if (NameID == TT_NAME_ID_FULL_NAME)
2765 {
2768 if (!Cache->FullName.Buffer)
2769 DuplicateUnicodeString(pNameW, &Cache->FullName);
2771 }
2772 }
2773
2774 return Status;
2775}
struct NameRec_ * Name
Definition: cdprocs.h:460
#define TT_MS_ID_UNICODE_CS
Definition: font.c:1181
#define TT_MS_ID_SYMBOL_CS
Definition: font.c:1180
static void SwapEndian(LPVOID pvData, DWORD Size)
Definition: freetype.c:2604
FT_Get_Sfnt_Name_Count(FT_Face face)
FT_BEGIN_HEADER struct FT_SfntName_ FT_SfntName
FT_Get_Sfnt_Name(FT_Face face, FT_UInt idx, FT_SfntName *aname)
#define TT_NAME_ID_FULL_NAME
Definition: font.c:3539
#define TT_NAME_ID_FONT_FAMILY
Definition: font.c:3536
#define TT_NAME_ID_FONT_SUBFAMILY
Definition: font.c:3537
WCHAR * PWCH
Definition: ntbasedef.h:410
#define STATUS_NOT_FOUND
Definition: shellext.h:72
SHARED_FACE_CACHE UserLanguage
Definition: engobjects.h:136
SHARED_FACE_CACHE EnglishUS
Definition: engobjects.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

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

◆ IntGetFontRenderMode()

FT_Render_Mode FASTCALL IntGetFontRenderMode ( LOGFONTW logfont)

Definition at line 1984 of file freetype.c.

1985{
1986 switch (logfont->lfQuality)
1987 {
1989 break;
1991 return FT_RENDER_MODE_MONO;
1992 case DRAFT_QUALITY:
1993 return FT_RENDER_MODE_LIGHT;
1994 case CLEARTYPE_QUALITY:
1995 if (!gspv.bFontSmoothing)
1996 break;
1998 break;
1999 return FT_RENDER_MODE_LCD;
2000 }
2001 return FT_RENDER_MODE_NORMAL;
2002}
@ FT_RENDER_MODE_NORMAL
Definition: freetype.h:3234
@ FT_RENDER_MODE_LIGHT
Definition: freetype.h:3235
@ FT_RENDER_MODE_LCD
Definition: freetype.h:3237
BOOL bFontSmoothing
Definition: sysparams.h:125
UINT uiFontSmoothingType
Definition: sysparams.h:126
SPIVALUES gspv
Definition: sysparams.c:17
#define ANTIALIASED_QUALITY
Definition: wingdi.h:440
#define DRAFT_QUALITY
Definition: wingdi.h:437
#define CLEARTYPE_QUALITY
Definition: wingdi.h:441
#define NONANTIALIASED_QUALITY
Definition: wingdi.h:439

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ IntGetFullFileName()

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

Definition at line 5266 of file freetype.c.

5270{
5273 HANDLE hFile;
5275 ULONG Desired;
5276
5278 FileName,
5280 NULL,
5281 NULL);
5282
5284 &hFile,
5285 0, // FILE_READ_ATTRIBUTES,
5289 0);
5290
5291 if (!NT_SUCCESS(Status))
5292 {
5293 DPRINT("ZwOpenFile() failed (Status = 0x%lx)\n", Status);
5294 return FALSE;
5295 }
5296
5297 Status = ZwQueryObject(hFile, ObjectNameInformation, NameInfo, Size, &Desired);
5298 ZwClose(hFile);
5299 if (!NT_SUCCESS(Status))
5300 {
5301 DPRINT("ZwQueryObject() failed (Status = %lx)\n", Status);
5302 return FALSE;
5303 }
5304
5305 return TRUE;
5306}
@ ObjectNameInformation
Definition: DriverTester.h:55
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_DELETE
Definition: nt_native.h:682

Referenced by IntGdiGetFontResourceInfo().

◆ IntGetHash()

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

Definition at line 3102 of file freetype.c.

3103{
3104 DWORD dwHash = cdw;
3105 const DWORD *pdw = pv;
3106
3107 while (cdw-- > 0)
3108 {
3109 dwHash *= 3;
3110 dwHash ^= *pdw++;
3111 }
3112
3113 return dwHash;
3114}

Referenced by IntGetRealGlyph().

◆ IntGetOutlineTextMetrics()

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

Definition at line 2413 of file freetype.c.

2416{
2417 TT_OS2 *pOS2;
2418 TT_HoriHeader *pHori;
2419 TT_Postscript *pPost;
2420 FT_Fixed XScale, YScale;
2421 FT_WinFNT_HeaderRec WinFNT;
2423 BYTE *pb;
2424 FONT_NAMES FontNames;
2425 PSHARED_FACE SharedFace = FontGDI->SharedFace;
2427 FT_Face Face = SharedFace->Face;
2428
2430 {
2431 Cache = &SharedFace->EnglishUS;
2432 }
2433 else
2434 {
2435 Cache = &SharedFace->UserLanguage;
2436 }
2437
2438 if (Size == 0 && Cache->OutlineRequiredSize > 0)
2439 {
2440 ASSERT(Otm == NULL);
2441 return Cache->OutlineRequiredSize;
2442 }
2443
2444 IntInitFontNames(&FontNames, SharedFace);
2445 Cache->OutlineRequiredSize = FontNames.OtmSize;
2446
2447 if (Size == 0)
2448 {
2449 ASSERT(Otm == NULL);
2450 IntFreeFontNames(&FontNames);
2451 return Cache->OutlineRequiredSize;
2452 }
2453
2454 ASSERT(Otm != NULL);
2455
2456 if (Size < Cache->OutlineRequiredSize)
2457 {
2458 DPRINT1("Size %u < OutlineRequiredSize %u\n", Size,
2459 Cache->OutlineRequiredSize);
2460 IntFreeFontNames(&FontNames);
2461 return 0; /* failure */
2462 }
2463
2464 XScale = Face->size->metrics.x_scale;
2465 YScale = Face->size->metrics.y_scale;
2466
2468
2469 pOS2 = FT_Get_Sfnt_Table(Face, FT_SFNT_OS2);
2470 pHori = FT_Get_Sfnt_Table(Face, FT_SFNT_HHEA);
2471 pPost = FT_Get_Sfnt_Table(Face, FT_SFNT_POST); /* We can live with this failing */
2472 Error = FT_Get_WinFNT_Header(Face, &WinFNT);
2473
2474 if (pOS2 == NULL && Error)
2475 {
2477 DPRINT1("Can't find OS/2 table - not TT font?\n");
2478 IntFreeFontNames(&FontNames);
2479 return 0;
2480 }
2481
2482 if (pHori == NULL && Error)
2483 {
2485 DPRINT1("Can't find HHEA table - not TT font?\n");
2486 IntFreeFontNames(&FontNames);
2487 return 0;
2488 }
2489
2490 Otm->otmSize = Cache->OutlineRequiredSize;
2491
2492 FillTM(&Otm->otmTextMetrics, FontGDI, pOS2, pHori, !Error ? &WinFNT : 0);
2493
2494 if (!pOS2)
2495 goto skip_os2;
2496
2497 Otm->otmFiller = 0;
2499 Otm->otmfsSelection = pOS2->fsSelection;
2500 Otm->otmfsType = pOS2->fsType;
2501 Otm->otmsCharSlopeRise = pHori->caret_Slope_Rise;
2502 Otm->otmsCharSlopeRun = pHori->caret_Slope_Run;
2503 Otm->otmItalicAngle = 0; /* POST table */
2504 Otm->otmEMSquare = Face->units_per_EM;
2505
2506#define SCALE_X(value) ((FT_MulFix((value), XScale) + 32) >> 6)
2507#define SCALE_Y(value) ((FT_MulFix((value), YScale) + 32) >> 6)
2508
2509 Otm->otmAscent = SCALE_Y(pOS2->sTypoAscender);
2510 Otm->otmDescent = SCALE_Y(pOS2->sTypoDescender);
2511 Otm->otmLineGap = SCALE_Y(pOS2->sTypoLineGap);
2512 Otm->otmsCapEmHeight = SCALE_Y(pOS2->sCapHeight);
2513 Otm->otmsXHeight = SCALE_Y(pOS2->sxHeight);
2514 Otm->otmrcFontBox.left = SCALE_X(Face->bbox.xMin);
2515 Otm->otmrcFontBox.right = SCALE_X(Face->bbox.xMax);
2516 Otm->otmrcFontBox.top = SCALE_Y(Face->bbox.yMax);
2517 Otm->otmrcFontBox.bottom = SCALE_Y(Face->bbox.yMin);
2520 Otm->otmMacLineGap = Otm->otmLineGap;
2521 Otm->otmusMinimumPPEM = 0; /* TT Header */
2532
2533 if (!pPost)
2534 {
2535 Otm->otmsUnderscoreSize = 0;
2536 Otm->otmsUnderscorePosition = 0;
2537 }
2538 else
2539 {
2542 }
2543
2544#undef SCALE_X
2545#undef SCALE_Y
2546
2547skip_os2:
2549
2550 pb = IntStoreFontNames(&FontNames, Otm);
2551 ASSERT(pb - (BYTE*)Otm == Cache->OutlineRequiredSize);
2552
2553 IntFreeFontNames(&FontNames);
2554
2555 return Cache->OutlineRequiredSize;
2556}
#define SCALE_Y(value)
static __inline void FASTCALL IntInitFontNames(FONT_NAMES *Names, PSHARED_FACE SharedFace)
Definition: freetype.c:2340
static __inline BYTE *FASTCALL IntStoreFontNames(const FONT_NAMES *Names, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2376
#define SCALE_X(value)
static __inline void FASTCALL IntFreeFontNames(FONT_NAMES *Names)
Definition: freetype.c:2400
ULONG OtmSize
Definition: freetype.c:2336
FT_Pos xMin
Definition: ftimage.h:117
FT_Pos yMax
Definition: ftimage.h:118
FT_Pos yMin
Definition: ftimage.h:117
FT_Pos xMax
Definition: ftimage.h:118
FT_BBox bbox
Definition: freetype.h:1092
FT_UShort units_per_EM
Definition: freetype.h:1094
FT_Short caret_Slope_Run
Definition: tttables.h:212
FT_Short caret_Slope_Rise
Definition: tttables.h:211
FT_Short sTypoDescender
Definition: tttables.h:412
FT_Short ySuperscriptYSize
Definition: tttables.h:392
FT_Short sxHeight
Definition: tttables.h:424
FT_Short yStrikeoutSize
Definition: tttables.h:395
FT_Short ySubscriptXSize
Definition: tttables.h:387
FT_Short sTypoLineGap
Definition: tttables.h:413
FT_Short sTypoAscender
Definition: tttables.h:411
FT_Short ySuperscriptXSize
Definition: tttables.h:391
FT_Short ySubscriptYOffset
Definition: tttables.h:390
FT_Short ySuperscriptYOffset
Definition: tttables.h:394
FT_Short ySubscriptXOffset
Definition: tttables.h:389
FT_Short yStrikeoutPosition
Definition: tttables.h:396
FT_Short sCapHeight
Definition: tttables.h:425
FT_UShort fsType
Definition: tttables.h:386
FT_Short ySuperscriptXOffset
Definition: tttables.h:393
FT_Short ySubscriptYSize
Definition: tttables.h:388
FT_Short underlineThickness
Definition: tttables.h:460
FT_Short underlinePosition
Definition: tttables.h:459
PANOSE otmPanoseNumber
Definition: wingdi.h:2516
POINT otmptSuperscriptOffset
Definition: wingdi.h:2536
POINT otmptSuperscriptSize
Definition: wingdi.h:2535
POINT otmptSubscriptSize
Definition: wingdi.h:2533
int otmsStrikeoutPosition
Definition: wingdi.h:2538
int otmsUnderscorePosition
Definition: wingdi.h:2540
POINT otmptSubscriptOffset
Definition: wingdi.h:2534
UINT otmsStrikeoutSize
Definition: wingdi.h:2537
@ FT_SFNT_HHEA
Definition: tttables.h:618
@ FT_SFNT_POST
Definition: tttables.h:620
#define PANOSE_COUNT
Definition: wingdi.h:453

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

◆ IntGetRealGlyph()

static FT_BitmapGlyph IntGetRealGlyph ( IN OUT PFONT_CACHE_ENTRY  Cache)
static

Definition at line 4175 of file freetype.c.

4177{
4178 INT error;
4179 FT_GlyphSlot glyph;
4180 FT_BitmapGlyph realglyph;
4181
4183
4184 Cache->dwHash = IntGetHash(&Cache->Hashed, sizeof(Cache->Hashed) / sizeof(DWORD));
4185
4186 realglyph = IntFindGlyphCache(Cache);
4187 if (realglyph)
4188 return realglyph;
4189
4190 error = FT_Load_Glyph(Cache->Hashed.Face, Cache->Hashed.GlyphIndex, FT_LOAD_DEFAULT);
4191 if (error)
4192 {
4193 DPRINT1("WARNING: Failed to load and render glyph! [index: %d]\n", Cache->Hashed.GlyphIndex);
4194 return NULL;
4195 }
4196
4197 glyph = Cache->Hashed.Face->glyph;
4198
4199 if (Cache->Hashed.Aspect.Emu.Bold)
4200 FT_GlyphSlot_Embolden(glyph); /* Emulate Bold */
4201
4202 if (Cache->Hashed.Aspect.Emu.Italic)
4203 FT_GlyphSlot_Oblique(glyph); /* Emulate Italic */
4204
4205 realglyph = IntGetBitmapGlyphWithCache(Cache, glyph);
4206
4207 if (!realglyph)
4208 DPRINT1("Failed to render glyph! [index: %d]\n", Cache->Hashed.GlyphIndex);
4209
4210 return realglyph;
4211}
static DWORD IntGetHash(IN LPCVOID pv, IN DWORD cdw)
Definition: freetype.c:3102
static FT_BitmapGlyph IntFindGlyphCache(IN const FONT_CACHE_ENTRY *pCache)
Definition: freetype.c:3117
static FT_BitmapGlyph IntGetBitmapGlyphWithCache(IN OUT PFONT_CACHE_ENTRY Cache, IN FT_GlyphSlot GlyphSlot)
Definition: freetype.c:3154
FT_BEGIN_HEADER FT_GlyphSlot_Embolden(FT_GlyphSlot slot)
Definition: ftsynth.c:90
FT_GlyphSlot_Oblique(FT_GlyphSlot slot)
Definition: ftsynth.c:48

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

◆ IntGetTextDisposition()

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

Definition at line 5837 of file freetype.c.

5846{
5847 LONGLONG X64 = 0, Y64 = 0;
5848 INT i, glyph_index;
5849 FT_BitmapGlyph realglyph;
5850 FT_Face face = Cache->Hashed.Face;
5851 BOOL use_kerning = FT_HAS_KERNING(face);
5852 ULONG previous = 0;
5853 FT_Vector delta, vec;
5854 DWORD ch0, ch1;
5855
5857
5858 for (i = 0; i < Count; ++i)
5859 {
5860 ch0 = *String++;
5861 if (IS_HIGH_SURROGATE(ch0))
5862 {
5863 ++i;
5864 if (i >= Count)
5865 return TRUE;
5866
5867 ch1 = *String++;
5868 if (IS_LOW_SURROGATE(ch1))
5869 ch0 = Utf32FromSurrogatePair(ch0, ch1);
5870 }
5871
5872 glyph_index = get_glyph_index_flagged(face, ch0, ETO_GLYPH_INDEX, fuOptions);
5873 Cache->Hashed.GlyphIndex = glyph_index;
5874
5875 realglyph = IntGetRealGlyph(Cache);
5876 if (!realglyph)
5877 return FALSE;
5878
5879 /* Retrieve kerning distance */
5880 if (use_kerning && previous && glyph_index)
5881 {
5882 FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
5883 X64 += delta.x;
5884 Y64 -= delta.y;
5885 }
5886
5887 if (NULL == Dx)
5888 {
5889 X64 += realglyph->root.advance.x >> 10;
5890 Y64 -= realglyph->root.advance.y >> 10;
5891 }
5892 else if (fuOptions & ETO_PDY)
5893 {
5894 vec.x = (Dx[2 * i + 0] << 6);
5895 vec.y = (Dx[2 * i + 1] << 6);
5896 if (!bNoTransform)
5897 FT_Vector_Transform(&vec, &Cache->Hashed.matTransform);
5898 X64 += vec.x;
5899 Y64 -= vec.y;
5900 }
5901 else
5902 {
5903 vec.x = (Dx[i] << 6);
5904 vec.y = 0;
5905 if (!bNoTransform)
5906 FT_Vector_Transform(&vec, &Cache->Hashed.matTransform);
5907 X64 += vec.x;
5908 Y64 -= vec.y;
5909 }
5910
5911 previous = glyph_index;
5912 }
5913
5914 *pX64 = X64;
5915 *pY64 = Y64;
5916 return TRUE;
5917}

Referenced by IntExtTextOutW().

◆ IntInitFontNames()

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

Definition at line 2340 of file freetype.c.

2341{
2342 ULONG OtmSize;
2343
2344 RtlInitUnicodeString(&Names->FamilyNameW, NULL);
2345 RtlInitUnicodeString(&Names->FaceNameW, NULL);
2346 RtlInitUnicodeString(&Names->StyleNameW, NULL);
2347 RtlInitUnicodeString(&Names->FullNameW, NULL);
2348
2349 /* family name */
2351 /* face name */
2353 /* style name */
2355 /* unique name (full name) */
2357
2358 /* Calculate the size of OUTLINETEXTMETRICW with extra data */
2359 OtmSize = sizeof(OUTLINETEXTMETRICW) +
2360 Names->FamilyNameW.Length + sizeof(UNICODE_NULL) +
2361 Names->FaceNameW.Length + sizeof(UNICODE_NULL) +
2362 Names->StyleNameW.Length + sizeof(UNICODE_NULL) +
2363 Names->FullNameW.Length + sizeof(UNICODE_NULL);
2364 Names->OtmSize = OtmSize;
2365}
static NTSTATUS IntGetFontLocalizedName(PUNICODE_STRING pNameW, PSHARED_FACE SharedFace, FT_UShort NameID, FT_UShort LangID)
Definition: freetype.c:2618
#define TT_NAME_ID_UNIQUE_ID
Definition: font.c:3538
struct _OUTLINETEXTMETRICW OUTLINETEXTMETRICW

Referenced by IntGetOutlineTextMetrics().

◆ IntIsFontRenderingEnabled()

BOOL FASTCALL IntIsFontRenderingEnabled ( VOID  )

Definition at line 1972 of file freetype.c.

1973{
1974 return (gpsi->BitsPixel > 8) && g_RenderingEnabled;
1975}
PSERVERINFO gpsi
Definition: imm.c:18

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ IntLoadFontsInRegistry()

BOOL FASTCALL IntLoadFontsInRegistry ( VOID  )

Definition at line 1652 of file freetype.c.

1653{
1657 KEY_FULL_INFORMATION KeyFullInfo;
1658 ULONG i, Length;
1659 UNICODE_STRING FontTitleW, FileNameW;
1660 SIZE_T InfoSize;
1661 LPBYTE InfoBuffer;
1663 LPWSTR pchPath;
1665 INT nFontCount = 0;
1666 DWORD dwFlags;
1667
1668 /* open registry key */
1671 NULL, NULL);
1672 Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
1673 if (!NT_SUCCESS(Status))
1674 {
1675 DPRINT1("ZwOpenKey failed: 0x%08X\n", Status);
1676 return FALSE; /* failure */
1677 }
1678
1679 /* query count of values */
1680 Status = ZwQueryKey(KeyHandle, KeyFullInformation,
1681 &KeyFullInfo, sizeof(KeyFullInfo), &Length);
1682 if (!NT_SUCCESS(Status))
1683 {
1684 DPRINT1("ZwQueryKey failed: 0x%08X\n", Status);
1686 return FALSE; /* failure */
1687 }
1688
1689 /* allocate buffer */
1690 InfoSize = (MAX_PATH + 256) * sizeof(WCHAR);
1691 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
1692 if (!InfoBuffer)
1693 {
1694 DPRINT1("ExAllocatePoolWithTag failed\n");
1696 return FALSE;
1697 }
1698
1699 /* for each value */
1700 for (i = 0; i < KeyFullInfo.Values; ++i)
1701 {
1702 /* get value name */
1703 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
1704 InfoBuffer, InfoSize, &Length);
1706 {
1707 /* too short buffer */
1708 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
1709 InfoSize *= 2;
1710 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
1711 if (!InfoBuffer)
1712 {
1713 DPRINT1("ExAllocatePoolWithTag failed\n");
1714 break;
1715 }
1716 /* try again */
1717 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
1718 InfoBuffer, InfoSize, &Length);
1719 }
1720 if (!NT_SUCCESS(Status))
1721 {
1722 DPRINT1("ZwEnumerateValueKey failed: 0x%08X\n", Status);
1723 break; /* failure */
1724 }
1725
1726 /* create FontTitleW string */
1727 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
1728 Length = pInfo->NameLength / sizeof(WCHAR);
1729 pInfo->Name[Length] = UNICODE_NULL; /* truncate */
1730 if (!RtlCreateUnicodeString(&FontTitleW, pInfo->Name))
1731 {
1733 DPRINT1("RtlCreateUnicodeString failed\n");
1734 break; /* failure */
1735 }
1736
1737 /* query value */
1738 Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation,
1739 InfoBuffer, InfoSize, &Length);
1741 {
1742 /* too short buffer */
1743 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
1744 InfoSize *= 2;
1745 InfoBuffer = ExAllocatePoolWithTag(PagedPool, InfoSize, TAG_FONT);
1746 if (!InfoBuffer)
1747 {
1748 DPRINT1("ExAllocatePoolWithTag failed\n");
1749 break;
1750 }
1751 /* try again */
1752 Status = ZwQueryValueKey(KeyHandle, &FontTitleW, KeyValueFullInformation,
1753 InfoBuffer, InfoSize, &Length);
1754 }
1755 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
1756 if (!NT_SUCCESS(Status) || !pInfo->DataLength)
1757 {
1758 DPRINT1("ZwQueryValueKey failed: 0x%08X\n", Status);
1759 RtlFreeUnicodeString(&FontTitleW);
1760 break; /* failure */
1761 }
1762
1763 /* Build pchPath */
1764 pchPath = (LPWSTR)((PUCHAR)pInfo + pInfo->DataOffset);
1765 Length = pInfo->DataLength / sizeof(WCHAR);
1766 pchPath[Length] = UNICODE_NULL; /* truncate */
1767
1768 /* Load font(s) without writing registry */
1769 if (PathIsRelativeW(pchPath))
1770 {
1771 dwFlags = 0;
1773 L"\\SystemRoot\\Fonts\\%s", pchPath);
1774 }
1775 else
1776 {
1778 Status = RtlStringCbCopyW(szPath, sizeof(szPath), pchPath);
1779 }
1780
1781 if (NT_SUCCESS(Status))
1782 {
1783 RtlCreateUnicodeString(&FileNameW, szPath);
1784 nFontCount += IntGdiAddFontResourceEx(&FileNameW, 0, dwFlags);
1785 RtlFreeUnicodeString(&FileNameW);
1786 }
1787
1788 RtlFreeUnicodeString(&FontTitleW);
1789 }
1790
1791 /* close now */
1793
1794 /* free memory block */
1795 if (InfoBuffer)
1796 {
1797 ExFreePoolWithTag(InfoBuffer, TAG_FONT);
1798 }
1799
1800 return (KeyFullInfo.Values != 0 && nFontCount != 0);
1801}
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: freetype.c:1642
LPCWSTR szPath
Definition: env.c:37
@ KeyFullInformation
Definition: nt_native.h:1133
@ KeyValueFullInformation
Definition: nt_native.h:1181
#define KEY_READ
Definition: nt_native.h:1023
struct _KEY_VALUE_FULL_INFORMATION * PKEY_VALUE_FULL_INFORMATION
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by InitFontSupport().

◆ IntLoadFontSubstList()

BOOL FASTCALL IntLoadFontSubstList ( PLIST_ENTRY  pHead)

Definition at line 525 of file freetype.c.

526{
530 KEY_FULL_INFORMATION KeyFullInfo;
531 ULONG i, Length;
532 UNICODE_STRING FromW, ToW;
533 BYTE InfoBuffer[128];
535 BYTE CharSets[FONTSUBST_FROM_AND_TO];
536 LPWSTR pch;
538
539 /* the FontSubstitutes registry key */
540 static UNICODE_STRING FontSubstKey =
541 RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\"
542 L"Microsoft\\Windows NT\\CurrentVersion\\"
543 L"FontSubstitutes");
544
545 /* open registry key */
548 NULL, NULL);
549 Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
550 if (!NT_SUCCESS(Status))
551 {
552 DPRINT("ZwOpenKey failed: 0x%08X\n", Status);
553 return FALSE; /* failure */
554 }
555
556 /* query count of values */
557 Status = ZwQueryKey(KeyHandle, KeyFullInformation,
558 &KeyFullInfo, sizeof(KeyFullInfo), &Length);
559 if (!NT_SUCCESS(Status))
560 {
561 DPRINT("ZwQueryKey failed: 0x%08X\n", Status);
563 return FALSE; /* failure */
564 }
565
566 /* for each value */
567 for (i = 0; i < KeyFullInfo.Values; ++i)
568 {
569 /* get value name */
570 Status = ZwEnumerateValueKey(KeyHandle, i, KeyValueFullInformation,
571 InfoBuffer, sizeof(InfoBuffer), &Length);
572 if (!NT_SUCCESS(Status))
573 {
574 DPRINT("ZwEnumerateValueKey failed: 0x%08X\n", Status);
575 break; /* failure */
576 }
577
578 /* create FromW string */
579 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
580 Length = pInfo->NameLength / sizeof(WCHAR);
581 pInfo->Name[Length] = UNICODE_NULL; /* truncate */
582 if (!RtlCreateUnicodeString(&FromW, pInfo->Name))
583 {
585 DPRINT("RtlCreateUnicodeString failed\n");
586 break; /* failure */
587 }
588
589 /* query value */
590 Status = ZwQueryValueKey(KeyHandle, &FromW, KeyValueFullInformation,
591 InfoBuffer, sizeof(InfoBuffer), &Length);
592 pInfo = (PKEY_VALUE_FULL_INFORMATION)InfoBuffer;
593 if (!NT_SUCCESS(Status) || !pInfo->DataLength)
594 {
595 DPRINT("ZwQueryValueKey failed: 0x%08X\n", Status);
596 RtlFreeUnicodeString(&FromW);
597 break; /* failure */
598 }
599
600 /* create ToW string */
601 pch = (LPWSTR)((PUCHAR)pInfo + pInfo->DataOffset);
602 Length = pInfo->DataLength / sizeof(WCHAR);
603 pch[Length] = UNICODE_NULL; /* truncate */
604 if (!RtlCreateUnicodeString(&ToW, pch))
605 {
607 DPRINT("RtlCreateUnicodeString failed\n");
608 RtlFreeUnicodeString(&FromW);
609 break; /* failure */
610 }
611
612 /* does charset exist? (from) */
614 pch = wcsrchr(FromW.Buffer, L',');
615 if (pch)
616 {
617 /* truncate */
618 *pch = UNICODE_NULL;
619 FromW.Length = (pch - FromW.Buffer) * sizeof(WCHAR);
620 /* parse charset number */
621 CharSets[FONTSUBST_FROM] = (BYTE)_wtoi(pch + 1);
622 }
623
624 /* does charset exist? (to) */
625 CharSets[FONTSUBST_TO] = DEFAULT_CHARSET;
626 pch = wcsrchr(ToW.Buffer, L',');
627 if (pch)
628 {
629 /* truncate */
630 *pch = UNICODE_NULL;
631 ToW.Length = (pch - ToW.Buffer) * sizeof(WCHAR);
632 /* parse charset number */
633 CharSets[FONTSUBST_TO] = (BYTE)_wtoi(pch + 1);
634 }
635
636 /* is it identical? */
637 if (RtlEqualUnicodeString(&FromW, &ToW, TRUE) &&
638 CharSets[FONTSUBST_FROM] == CharSets[FONTSUBST_TO])
639 {
640 RtlFreeUnicodeString(&FromW);
642 continue;
643 }
644
645 /* allocate an entry */
647 if (pEntry == NULL)
648 {
649 DPRINT("ExAllocatePoolWithTag failed\n");
650 RtlFreeUnicodeString(&FromW);
652 break; /* failure */
653 }
654
655 /* store to *pEntry */
656 pEntry->FontNames[FONTSUBST_FROM] = FromW;
657 pEntry->FontNames[FONTSUBST_TO] = ToW;
658 pEntry->CharSets[FONTSUBST_FROM] = CharSets[FONTSUBST_FROM];
659 pEntry->CharSets[FONTSUBST_TO] = CharSets[FONTSUBST_TO];
660
661 /* insert pEntry to *pHead */
662 InsertTailList(pHead, &pEntry->ListEntry);
663 }
664
665 /* close now */
667
668 return NT_SUCCESS(Status);
669}
#define FONTSUBST_FROM_AND_TO
Definition: font.h:71
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)

Referenced by InitFontSupport().

◆ IntLoadSystemFonts()

VOID FASTCALL IntLoadSystemFonts ( VOID  )

Definition at line 907 of file freetype.c.

908{
910 UNICODE_STRING Directory, FileName, TempString;
912 HANDLE hDirectory;
913 BYTE *DirInfoBuffer;
915 BOOLEAN bRestartScan = TRUE;
917 INT i;
918 static UNICODE_STRING SearchPatterns[] =
919 {
920 RTL_CONSTANT_STRING(L"*.ttf"),
921 RTL_CONSTANT_STRING(L"*.ttc"),
922 RTL_CONSTANT_STRING(L"*.otf"),
923 RTL_CONSTANT_STRING(L"*.otc"),
924 RTL_CONSTANT_STRING(L"*.fon"),
925 RTL_CONSTANT_STRING(L"*.fnt")
926 };
927 static UNICODE_STRING IgnoreFiles[] =
928 {
931 };
932
933 RtlInitUnicodeString(&Directory, L"\\SystemRoot\\Fonts\\");
934
937 &Directory,
939 NULL,
940 NULL);
941
943 &hDirectory,
946 &Iosb,
949
950 if (NT_SUCCESS(Status))
951 {
952 for (i = 0; i < _countof(SearchPatterns); ++i)
953 {
954 DirInfoBuffer = ExAllocatePoolWithTag(PagedPool, 0x4000, TAG_FONT);
955 if (DirInfoBuffer == NULL)
956 {
957 ZwClose(hDirectory);
958 return;
959 }
960
962 if (FileName.Buffer == NULL)
963 {
964 ExFreePoolWithTag(DirInfoBuffer, TAG_FONT);
965 ZwClose(hDirectory);
966 return;
967 }
968 FileName.Length = 0;
969 FileName.MaximumLength = MAX_PATH * sizeof(WCHAR);
970
971 while (1)
972 {
973 Status = ZwQueryDirectoryFile(
974 hDirectory,
975 NULL,
976 NULL,
977 NULL,
978 &Iosb,
979 DirInfoBuffer,
980 0x4000,
982 FALSE,
983 &SearchPatterns[i],
984 bRestartScan);
985
987 {
988 break;
989 }
990
991 DirInfo = (PFILE_DIRECTORY_INFORMATION)DirInfoBuffer;
992 while (1)
993 {
994 SIZE_T ign;
995
996 TempString.Buffer = DirInfo->FileName;
997 TempString.Length = TempString.MaximumLength = DirInfo->FileNameLength;
998
999 /* Should we ignore this file? */
1000 for (ign = 0; ign < _countof(IgnoreFiles); ++ign)
1001 {
1002 /* Yes.. */
1003 if (RtlEqualUnicodeString(IgnoreFiles + ign, &TempString, FALSE))
1004 break;
1005 }
1006
1007 /* If we tried all Ignore patterns and there was no match, try to create a font */
1008 if (ign == _countof(IgnoreFiles))
1009 {
1013 {
1014 DPRINT1("ERR: Failed to load %wZ\n", &FileName);
1015 }
1016 }
1017
1018 if (DirInfo->NextEntryOffset == 0)
1019 break;
1020
1021 DirInfo = (PFILE_DIRECTORY_INFORMATION)((ULONG_PTR)DirInfo + DirInfo->NextEntryOffset);
1022 }
1023
1024 bRestartScan = FALSE;
1025 }
1026
1028 ExFreePoolWithTag(DirInfoBuffer, TAG_FONT);
1029 }
1030 ZwClose(hDirectory);
1031 }
1032}
@ IgnoreFiles
Definition: ACListISF.cpp:75
unsigned char BOOLEAN
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
struct _FileName FileName
Definition: fatprocs.h:896
@ FileDirectoryInformation
Definition: from_kernel.h:62
struct _FILE_DIRECTORY_INFORMATION * PFILE_DIRECTORY_INFORMATION
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
#define _countof(array)
Definition: sndvol32.h:68
base for all directory entries
Definition: entries.h:138
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:524
#define STATUS_NO_MORE_FILES
Definition: udferr_usr.h:128

Referenced by InitFontSupport().

◆ IntMatrixFromMx()

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

Definition at line 739 of file freetype.c.

740{
741 FLOATOBJ ef;
742
743 /* Create a freetype matrix, by converting to 16.16 fixpoint format */
744 ef = pmx->efM11;
745 FLOATOBJ_MulLong(&ef, 0x00010000);
746 pmat->xx = FLOATOBJ_GetLong(&ef);
747
748 ef = pmx->efM21;
749 FLOATOBJ_MulLong(&ef, 0x00010000);
750 pmat->xy = -FLOATOBJ_GetLong(&ef); /* (*1) See below */
751
752 ef = pmx->efM12;
753 FLOATOBJ_MulLong(&ef, 0x00010000);
754 pmat->yx = -FLOATOBJ_GetLong(&ef); /* (*1) See below */
755
756 ef = pmx->efM22;
757 FLOATOBJ_MulLong(&ef, 0x00010000);
758 pmat->yy = FLOATOBJ_GetLong(&ef);
759
760 // (*1): Y direction is mirrored as follows:
761 //
762 // [ M11 -M12 ] [ X ] [ M11*X + M12*Y ]
763 // [ ] * [ ] == [ ]
764 // [ -M21 M22 ] [ -Y ] [ -(M21*X + M22*Y) ].
765}

Referenced by ftGdiGetGlyphOutline(), and IntExtTextOutW().

◆ IntNormalizeAngle()

static LONG IntNormalizeAngle ( LONG  nTenthsOfDegrees)
static

Definition at line 718 of file freetype.c.

719{
720 nTenthsOfDegrees %= 360 * 10;
721 if (nTenthsOfDegrees >= 0)
722 return nTenthsOfDegrees;
723 return nTenthsOfDegrees + 360 * 10;
724}

Referenced by TextIntGetTextExtentPoint().

◆ IntRequestFontSize()

static FT_Error IntRequestFontSize ( PDC  dc,
PFONTGDI  FontGDI,
LONG  lfWidth,
LONG  lfHeight 
)
static

Definition at line 3416 of file freetype.c.

3417{
3420 FT_Face face = FontGDI->SharedFace->Face;
3421 TT_OS2 *pOS2;
3422 TT_HoriHeader *pHori;
3423 FT_WinFNT_HeaderRec WinFNT;
3424 LONG Ascent, Descent, Sum, EmHeight, Width64;
3425
3426 lfWidth = abs(lfWidth);
3427 if (lfHeight == 0)
3428 {
3429 if (lfWidth == 0)
3430 {
3431 DPRINT("lfHeight and lfWidth are zero.\n");
3432 lfHeight = -16;
3433 }
3434 else
3435 {
3436 lfHeight = lfWidth;
3437 }
3438 }
3439
3440 if (lfHeight == -1)
3441 lfHeight = -2;
3442
3443 if (FontGDI->Magic == FONTGDI_MAGIC &&
3444 FontGDI->lfHeight == lfHeight &&
3445 FontGDI->lfWidth == lfWidth)
3446 {
3447 return 0; /* Cached */
3448 }
3449
3453
3454 if (!pOS2 || !pHori)
3455 {
3456 error = FT_Get_WinFNT_Header(face, &WinFNT);
3457 if (error)
3458 {
3459 DPRINT1("%s: Failed to request font size.\n", face->family_name);
3460 ASSERT(FALSE);
3461 return error;
3462 }
3463
3464 FontGDI->tmHeight = WinFNT.pixel_height;
3465 FontGDI->tmAscent = WinFNT.ascent;
3466 FontGDI->tmDescent = FontGDI->tmHeight - FontGDI->tmAscent;
3467 FontGDI->tmInternalLeading = WinFNT.internal_leading;
3468 FontGDI->Magic = FONTGDI_MAGIC;
3469 FontGDI->lfHeight = lfHeight;
3470 FontGDI->lfWidth = lfWidth;
3471 return 0;
3472 }
3473
3474 /*
3475 * NOTE: We cast TT_OS2.usWinAscent and TT_OS2.usWinDescent to signed FT_Short.
3476 * Why? See: https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswindescent
3477 *
3478 * > usWinDescent is "usually" a positive value ...
3479 *
3480 * We can read it as "not always". See CORE-14994.
3481 * See also: https://docs.microsoft.com/en-us/typography/opentype/spec/os2#fsselection
3482 */
3483#define FM_SEL_USE_TYPO_METRICS 0x80
3484 if (lfHeight > 0)
3485 {
3486 /* case (A): lfHeight is positive */
3487 Sum = (FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent;
3488 if (Sum == 0 || (pOS2->fsSelection & FM_SEL_USE_TYPO_METRICS))
3489 {
3490 Ascent = pHori->Ascender;
3491 Descent = -pHori->Descender;
3492 Sum = Ascent + Descent;
3493 }
3494 else
3495 {
3496 Ascent = (FT_Short)pOS2->usWinAscent;
3497 Descent = (FT_Short)pOS2->usWinDescent;
3498 }
3499
3500 FontGDI->tmAscent = FT_MulDiv(lfHeight, Ascent, Sum);
3501 FontGDI->tmDescent = FT_MulDiv(lfHeight, Descent, Sum);
3502 FontGDI->tmHeight = FontGDI->tmAscent + FontGDI->tmDescent;
3503 FontGDI->tmInternalLeading = FontGDI->tmHeight - FT_MulDiv(lfHeight, face->units_per_EM, Sum);
3504 }
3505 else if (lfHeight < 0)
3506 {
3507 /* case (B): lfHeight is negative */
3509 {
3510 FontGDI->tmAscent = FT_MulDiv(-lfHeight, pHori->Ascender, face->units_per_EM);
3511 FontGDI->tmDescent = FT_MulDiv(-lfHeight, -pHori->Descender, face->units_per_EM);
3512 }
3513 else
3514 {
3515 FontGDI->tmAscent = FT_MulDiv(-lfHeight, (FT_Short)pOS2->usWinAscent, face->units_per_EM);
3516 FontGDI->tmDescent = FT_MulDiv(-lfHeight, (FT_Short)pOS2->usWinDescent, face->units_per_EM);
3517 }
3518 FontGDI->tmHeight = FontGDI->tmAscent + FontGDI->tmDescent;
3519 FontGDI->tmInternalLeading = FontGDI->tmHeight + lfHeight;
3520 }
3521#undef FM_SEL_USE_TYPO_METRICS
3522
3523 FontGDI->Magic = FONTGDI_MAGIC;
3524 FontGDI->lfHeight = lfHeight;
3525 FontGDI->lfWidth = lfWidth;
3526
3527 EmHeight = FontGDI->tmHeight - FontGDI->tmInternalLeading;
3528 EmHeight = max(EmHeight, 1);
3529 EmHeight = min(EmHeight, USHORT_MAX);
3530
3531#if 1
3532 /* I think this is wrong implementation but its test result is better. */
3533 if (lfWidth != 0)
3534 Width64 = FT_MulDiv(lfWidth, face->units_per_EM, pOS2->xAvgCharWidth) << 6;
3535 else
3536 Width64 = 0;
3537#else
3538 /* I think this is correct implementation but it is mismatching to the
3539 other metric functions. The test result is bad. */
3540 if (lfWidth != 0)
3541 Width64 = (FT_MulDiv(lfWidth, 96 * 5, 72 * 3) << 6); /* ??? FIXME */
3542 else
3543 Width64 = 0;
3544#endif
3545
3547 req.width = Width64;
3548 req.height = (EmHeight << 6);
3549 req.horiResolution = 0;
3550 req.vertResolution = 0;
3551 return FT_Request_Size(face, &req);
3552}
#define FONTGDI_MAGIC
Definition: engobjects.h:171
#define FM_SEL_USE_TYPO_METRICS
@ FT_SIZE_REQUEST_TYPE_NOMINAL
Definition: freetype.h:2570
FT_Request_Size(FT_Face face, FT_Size_Request req)
Definition: ftobjs.c:3192
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:416
#define USHORT_MAX
Definition: intsafe.h:147
FT_UInt horiResolution
Definition: freetype.h:2622
FT_Size_Request_Type type
Definition: freetype.h:2619
FT_UInt vertResolution
Definition: freetype.h:2623
LONG tmHeight
Definition: engobjects.h:161
LONG lfHeight
Definition: engobjects.h:166
LONG Magic
Definition: engobjects.h:165

Referenced by FindBestFontFromList(), ftGdiGetTextMetricsW(), NtGdiGetCharABCWidthsW(), NtGdiGetCharWidthW(), and TextIntUpdateSize().

◆ IntStoreFontNames()

static __inline BYTE *FASTCALL IntStoreFontNames ( const FONT_NAMES Names,
OUTLINETEXTMETRICW Otm 
)
static

Definition at line 2376 of file freetype.c.

2377{
2378 BYTE *pb = (BYTE *)Otm + sizeof(OUTLINETEXTMETRICW);
2379
2380 /* family name */
2381 Otm->otmpFamilyName = (LPSTR)(pb - (BYTE*) Otm);
2382 pb += IntStoreName(&Names->FamilyNameW, pb);
2383
2384 /* face name */
2385 Otm->otmpFaceName = (LPSTR)(pb - (BYTE*) Otm);
2386 pb += IntStoreName(&Names->FaceNameW, pb);
2387
2388 /* style name */
2389 Otm->otmpStyleName = (LPSTR)(pb - (BYTE*) Otm);
2390 pb += IntStoreName(&Names->StyleNameW, pb);
2391
2392 /* unique name (full name) */
2393 Otm->otmpFullName = (LPSTR)(pb - (BYTE*) Otm);
2394 pb += IntStoreName(&Names->FullNameW, pb);
2395
2396 return pb;
2397}
static __inline SIZE_T FASTCALL IntStoreName(const UNICODE_STRING *pName, BYTE *pb)
Definition: freetype.c:2368
char * LPSTR
Definition: xmlstorage.h:182

Referenced by IntGetOutlineTextMetrics().

◆ IntStoreName()

static __inline SIZE_T FASTCALL IntStoreName ( const UNICODE_STRING pName,
BYTE pb 
)
static

Definition at line 2368 of file freetype.c.

2369{
2370 RtlCopyMemory(pb, pName->Buffer, pName->Length);
2371 *(WCHAR *)&pb[pName->Length] = UNICODE_NULL;
2372 return pName->Length + sizeof(UNICODE_NULL);
2373}
static LPSTR pName
Definition: security.c:75

Referenced by IntStoreFontNames().

◆ IntTranslateCharsetInfo()

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

Definition at line 2048 of file freetype.c.

2054{
2055 int Index = 0;
2056
2057 switch (Flags)
2058 {
2059 case TCI_SRCFONTSIG:
2060 while (Index < MAXTCIINDEX && 0 == (*Src >> Index & 0x0001))
2061 {
2062 Index++;
2063 }
2064 break;
2065 case TCI_SRCCODEPAGE:
2066 while (Index < MAXTCIINDEX && *Src != g_FontTci[Index].ciACP)
2067 {
2068 Index++;
2069 }
2070 break;
2071 case TCI_SRCCHARSET:
2072 while (Index < MAXTCIINDEX && *Src != g_FontTci[Index].ciCharset)
2073 {
2074 Index++;
2075 }
2076 break;
2077 case TCI_SRCLOCALE:
2079 return FALSE;
2080 default:
2081 return FALSE;
2082 }
2083
2084 if (Index >= MAXTCIINDEX || DEFAULT_CHARSET == g_FontTci[Index].ciCharset)
2085 {
2086 return FALSE;
2087 }
2088
2089 RtlCopyMemory(Cs, &g_FontTci[Index], sizeof(CHARSETINFO));
2090
2091 return TRUE;
2092}
#define UNIMPLEMENTED
Definition: debug.h:118
_In_ WDFCOLLECTION _In_ ULONG Index
#define TCI_SRCLOCALE
Definition: wingdi.h:964
#define TCI_SRCCHARSET
Definition: wingdi.h:961
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by FontFamilyFillInfo(), and ftGdiGetTextCharsetInfo().

◆ IntUnicodeStringToBuffer()

static VOID IntUnicodeStringToBuffer ( LPWSTR  pszBuffer,
SIZE_T  cbBuffer,
const UNICODE_STRING pString 
)
static

Definition at line 830 of file freetype.c.

831{
832 SIZE_T cbLength = pString->Length;
833
834 if (cbBuffer < sizeof(UNICODE_NULL))
835 return;
836
837 if (cbLength > cbBuffer - sizeof(UNICODE_NULL))
838 cbLength = cbBuffer - sizeof(UNICODE_NULL);
839
840 RtlCopyMemory(pszBuffer, pString->Buffer, cbLength);
841 pszBuffer[cbLength / sizeof(WCHAR)] = UNICODE_NULL;
842}
__inline USHORT Length(VOID)
Definition: fxstring.hpp:85
__inline PWCHAR Buffer(VOID)
Definition: fxstring.hpp:144
FxString * pString

Referenced by GetFontFamilyInfoForSubstitutes(), SubstituteFontRecurse(), and TextIntRealizeFont().

◆ MatchFontName()

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

Definition at line 5106 of file freetype.c.

5107{
5110
5112 Status = IntGetFontLocalizedName(&Name2, SharedFace, NameID, LangID);
5113
5114 if (NT_SUCCESS(Status))
5115 {
5116 if (RtlCompareUnicodeString(Name1, &Name2, TRUE) == 0)
5117 {
5119 return TRUE;
5120 }
5121
5123 }
5124
5125 return FALSE;
5126}
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Must_inspect_result_ _In_ PCUNICODE_STRING Name2
Definition: fsrtlfuncs.h:796

Referenced by MatchFontNames().

◆ MatchFontNames()

static BOOL MatchFontNames ( PSHARED_FACE  SharedFace,
LPCWSTR  lfFaceName 
)
static

Definition at line 5129 of file freetype.c.

5130{
5131 UNICODE_STRING Name1;
5132
5133 if (lfFaceName[0] == UNICODE_NULL)
5134 return FALSE;
5135
5136 RtlInitUnicodeString(&Name1, lfFaceName);
5137
5138 if (MatchFontName(SharedFace, &Name1, TT_NAME_ID_FONT_FAMILY, LANG_ENGLISH) ||
5139 MatchFontName(SharedFace, &Name1, TT_NAME_ID_FULL_NAME, LANG_ENGLISH))
5140 {
5141 return TRUE;
5142 }
5144 {
5145 if (MatchFontName(SharedFace, &Name1, TT_NAME_ID_FONT_FAMILY, gusLanguageID) ||
5146 MatchFontName(SharedFace, &Name1, TT_NAME_ID_FULL_NAME, gusLanguageID))
5147 {
5148 return TRUE;
5149 }
5150 }
5151 return FALSE;
5152}
static BOOL MatchFontName(PSHARED_FACE SharedFace, PUNICODE_STRING Name1, FT_UShort NameID, FT_UShort LangID)
Definition: freetype.c:5106

Referenced by TextIntRealizeFont().

◆ NameFromCharSet()

static LPCWSTR FASTCALL NameFromCharSet ( BYTE  CharSet)
static

Definition at line 1403 of file freetype.c.

1404{
1405 switch (CharSet)
1406 {
1407 case ANSI_CHARSET: return L"ANSI";
1408 case DEFAULT_CHARSET: return L"Default";
1409 case SYMBOL_CHARSET: return L"Symbol";
1410 case SHIFTJIS_CHARSET: return L"Shift_JIS";
1411 case HANGUL_CHARSET: return L"Hangul";
1412 case GB2312_CHARSET: return L"GB 2312";
1413 case CHINESEBIG5_CHARSET: return L"Chinese Big5";
1414 case OEM_CHARSET: return L"OEM";
1415 case JOHAB_CHARSET: return L"Johab";
1416 case HEBREW_CHARSET: return L"Hebrew";
1417 case ARABIC_CHARSET: return L"Arabic";
1418 case GREEK_CHARSET: return L"Greek";
1419 case TURKISH_CHARSET: return L"Turkish";
1420 case VIETNAMESE_CHARSET: return L"Vietnamese";
1421 case THAI_CHARSET: return L"Thai";
1422 case EASTEUROPE_CHARSET: return L"Eastern European";
1423 case RUSSIAN_CHARSET: return L"Russian";
1424 case MAC_CHARSET: return L"Mac";
1425 case BALTIC_CHARSET: return L"Baltic";
1426 default: return L"Unknown";
1427 }
1428}
#define HANGUL_CHARSET
Definition: wingdi.h:388
#define SYMBOL_CHARSET
Definition: wingdi.h:385

Referenced by IntGdiAddFontResourceEx().

◆ NtGdiExtTextOutW()

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 
)

Definition at line 6565 of file freetype.c.

6575{
6576 BOOL Result = FALSE;
6578 RECTL SafeRect;
6579 BYTE LocalBuffer[STACK_TEXT_BUFFER_SIZE];
6580 PVOID Buffer = LocalBuffer;
6581 LPCWSTR SafeString = NULL;
6582 LPINT SafeDx = NULL;
6583 ULONG BufSize, StringSize, DxSize = 0;
6584
6585 /* Check if String is valid */
6586 if ((Count > 0xFFFF) || (Count > 0 && UnsafeString == NULL))
6587 {
6589 return FALSE;
6590 }
6591
6592 if (Count > 0)
6593 {
6594 /* Calculate buffer size for string and Dx values */
6595 BufSize = StringSize = Count * sizeof(WCHAR);
6596 if (UnsafeDx)
6597 {
6598 /* If ETO_PDY is specified, we have pairs of INTs */
6599 DxSize = (Count * sizeof(INT)) * ((fuOptions & ETO_PDY) ? 2 : 1);
6600 BufSize += DxSize;
6601 }
6602
6603 /* Check if our local buffer is large enough */
6604 if (BufSize > sizeof(LocalBuffer))
6605 {
6606 /* It's not, allocate a temp buffer */
6608 if (!Buffer)
6609 {
6610 return FALSE;
6611 }
6612 }
6613
6614 /* Probe and copy user mode data to the buffer */
6615 _SEH2_TRY
6616 {
6617 /* Put the Dx before the String to assure alignment of 4 */
6618 SafeString = (LPCWSTR)(((ULONG_PTR)Buffer) + DxSize);
6619
6620 /* Probe and copy the string */
6621 ProbeForRead(UnsafeString, StringSize, 1);
6622 RtlCopyMemory((PVOID)SafeString, UnsafeString, StringSize);
6623
6624 /* If we have Dx values... */
6625 if (UnsafeDx)
6626 {
6627 /* ... probe and copy them */
6628 SafeDx = Buffer;
6629 ProbeForRead(UnsafeDx, DxSize, 1);
6630 RtlCopyMemory(SafeDx, UnsafeDx, DxSize);
6631 }
6632 }
6634 {
6636 }
6637 _SEH2_END
6638 if (!NT_SUCCESS(Status))
6639 {
6640 goto cleanup;
6641 }
6642 }
6643
6644 /* If we have a rect, copy it */
6645 if (UnsafeRect)
6646 {
6647 _SEH2_TRY
6648 {
6649 ProbeForRead(UnsafeRect, sizeof(RECT), 1);
6650 SafeRect = *UnsafeRect;
6651 }
6653 {
6655 }
6656 _SEH2_END
6657 if (!NT_SUCCESS(Status))
6658 {
6659 goto cleanup;
6660 }
6661 }
6662
6663 /* Finally call the internal routine */
6665 XStart,
6666 YStart,
6667 fuOptions,
6668 &SafeRect,
6669 SafeString,
6670 Count,
6671 SafeDx,
6672 dwCodePage);
6673
6674cleanup:
6675 /* If we allocated a buffer, free it */
6676 if (Buffer != LocalBuffer)
6677 {
6679 }
6680
6681 return Result;
6682}
#define BufSize
Definition: FsRtlTunnel.c:28
static void cleanup(void)
Definition: main.c:1335
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
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)
Definition: freetype.c:6523
#define STACK_TEXT_BUFFER_SIZE
Definition: freetype.c:6561
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define INT
Definition: polytest.cpp:20
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
int * LPINT
Definition: windef.h:178

◆ NtGdiGetCharABCWidthsW()

BOOL APIENTRY NtGdiGetCharABCWidthsW ( IN HDC  hDC,
IN UINT  FirstChar,
IN ULONG  Count,
IN OPTIONAL PWCHAR  UnSafepwch,
IN FLONG  fl,
OUT PVOID  Buffer 
)

Definition at line 6690 of file freetype.c.

6697{
6698 LPABC SafeBuff;
6699 LPABCFLOAT SafeBuffF = NULL;
6700 PDC dc;
6701 PDC_ATTR pdcattr;
6702 PTEXTOBJ TextObj;
6703 PFONTGDI FontGDI;
6704 FT_Face face;
6705 FT_CharMap charmap, found = NULL;
6706 UINT i, glyph_index, BufferSize;
6707 HFONT hFont = 0;
6709 PWCHAR Safepwch = NULL;
6710 LOGFONTW *plf;
6711
6712 if (!Buffer)
6713 {
6715 return FALSE;
6716 }
6717
6718 if (UnSafepwch)
6719 {
6720 UINT pwchSize = Count * sizeof(WCHAR);
6721 Safepwch = ExAllocatePoolWithTag(PagedPool, pwchSize, GDITAG_TEXT);
6722
6723 if(!Safepwch)
6724 {
6726 return FALSE;
6727 }
6728
6729 _SEH2_TRY
6730 {
6731 ProbeForRead(UnSafepwch, pwchSize, 1);
6732 RtlCopyMemory(Safepwch, UnSafepwch, pwchSize);
6733 }
6735 {
6737 }
6738 _SEH2_END;
6739 }
6740
6741 if (!NT_SUCCESS(Status))
6742 {
6743 if(Safepwch)
6744 ExFreePoolWithTag(Safepwch , GDITAG_TEXT);
6745
6747 return FALSE;
6748 }
6749
6750 BufferSize = Count * sizeof(ABC); // Same size!
6752 if (!fl) SafeBuffF = (LPABCFLOAT) SafeBuff;
6753 if (SafeBuff == NULL)
6754 {
6755
6756 if(Safepwch)
6757 ExFreePoolWithTag(Safepwch , GDITAG_TEXT);
6758
6760 return FALSE;
6761 }
6762
6763 dc = DC_LockDc(hDC);
6764 if (dc == NULL)
6765 {
6766 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
6767
6768 if(Safepwch)
6769 ExFreePoolWithTag(Safepwch , GDITAG_TEXT);
6770
6772 return FALSE;
6773 }
6774 pdcattr = dc->pdcattr;
6775 hFont = pdcattr->hlfntNew;
6776 TextObj = RealizeFontInit(hFont);
6777
6778 DC_UnlockDc(dc);
6779
6780 if (TextObj == NULL)
6781 {
6782 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
6783
6784 if(Safepwch)
6785 ExFreePoolWithTag(Safepwch , GDITAG_TEXT);
6786
6788 return FALSE;
6789 }
6790
6791 FontGDI = ObjToGDI(TextObj->Font, FONT);
6792
6793 face = FontGDI->SharedFace->Face;
6794 if (face->charmap == NULL)
6795 {
6796 for (i = 0; i < (UINT)face->num_charmaps; i++)
6797 {
6798 charmap = face->charmaps[i];
6799 if (charmap->encoding != 0)
6800 {
6801 found = charmap;
6802 break;
6803 }
6804 }
6805
6806 if (!found)
6807 {
6808 DPRINT1("WARNING: Could not find desired charmap!\n");
6809 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
6810
6811 if(Safepwch)
6812 ExFreePoolWithTag(Safepwch , GDITAG_TEXT);
6813
6815 return FALSE;
6816 }
6817
6819 FT_Set_Charmap(face, found);
6821 }
6822
6823 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
6824
6825 // NOTE: GetCharABCWidths simply ignores lfEscapement and XFORM.
6827 IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
6829
6830 for (i = FirstChar; i < FirstChar+Count; i++)
6831 {
6832 int adv, lsb, bbx, left, right;
6833
6834 if (Safepwch)
6835 {
6836 glyph_index = get_glyph_index_flagged(face, Safepwch[i - FirstChar], GCABCW_INDICES, fl);
6837 }
6838 else
6839 {
6841 }
6842 FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
6843
6844 left = (INT)face->glyph->metrics.horiBearingX & -64;
6845 right = (INT)((face->glyph->metrics.horiBearingX + face->glyph->metrics.width) + 63) & -64;
6846 adv = (face->glyph->advance.x + 32) >> 6;
6847
6848// int test = (INT)(face->glyph->metrics.horiAdvance + 63) >> 6;
6849// DPRINT1("Advance Wine %d and Advance Ros %d\n",test, adv ); /* It's the same! */
6850
6851 lsb = left >> 6;
6852 bbx = (right - left) >> 6;
6853 /*
6854 DPRINT1("lsb %d and bbx %d\n", lsb, bbx );
6855 */
6856 if (!fl)
6857 {
6858 SafeBuffF[i - FirstChar].abcfA = (FLOAT) lsb;
6859 SafeBuffF[i - FirstChar].abcfB = (FLOAT) bbx;
6860 SafeBuffF[i - FirstChar].abcfC = (FLOAT) (adv - lsb - bbx);
6861 }
6862 else
6863 {
6864 SafeBuff[i - FirstChar].abcA = lsb;
6865 SafeBuff[i - FirstChar].abcB = bbx;
6866 SafeBuff[i - FirstChar].abcC = adv - lsb - bbx;
6867 }
6868 }
6870 TEXTOBJ_UnlockText(TextObj);
6871 Status = MmCopyToCaller(Buffer, SafeBuff, BufferSize);
6872
6873 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
6874
6875 if(Safepwch)
6876 ExFreePoolWithTag(Safepwch , GDITAG_TEXT);
6877
6878 if (!NT_SUCCESS(Status))
6879 {
6881 return FALSE;
6882 }
6883
6884 DPRINT("NtGdiGetCharABCWidths Worked!\n");
6885 return TRUE;
6886}
#define BufferSize
Definition: mmc.h:75
FT_Set_Charmap(FT_Face face, FT_CharMap charmap)
Definition: ftobjs.c:3499
#define FLOAT
Definition: i386-dis.c:525
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define GCABCW_INDICES
Definition: ntgdityp.h:210
FLOAT abcfA
Definition: wingdi.h:1416
FLOAT abcfC
Definition: wingdi.h:1418
FLOAT abcfB
Definition: wingdi.h:1417
Definition: wingdi.h:1410
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_In_ FLONG fl
Definition: winddi.h:1279
struct _ABCFLOAT * LPABCFLOAT
struct _ABC ABC

◆ NtGdiGetCharWidthW()

BOOL APIENTRY NtGdiGetCharWidthW ( IN HDC  hDC,
IN UINT  FirstChar,
IN UINT  Count,
IN OPTIONAL PWCHAR  UnSafepwc,
IN FLONG  fl,
OUT PVOID  Buffer 
)

Definition at line 6893 of file freetype.c.

6900{
6902 LPINT SafeBuff;
6903 PFLOAT SafeBuffF = NULL;
6904 PDC dc;
6905 PDC_ATTR pdcattr;
6906 PTEXTOBJ TextObj;
6907 PFONTGDI FontGDI;
6908 FT_Face face;
6909 FT_CharMap charmap, found = NULL;
6910 UINT i, glyph_index, BufferSize;
6911 HFONT hFont = 0;
6912 PWCHAR Safepwc = NULL;
6913 LOGFONTW *plf;
6914
6915 if (UnSafepwc)
6916 {
6917 UINT pwcSize = Count * sizeof(WCHAR);
6918 Safepwc = ExAllocatePoolWithTag(PagedPool, pwcSize, GDITAG_TEXT);
6919
6920 if(!Safepwc)
6921 {
6923 return FALSE;
6924 }
6925 _SEH2_TRY
6926 {
6927 ProbeForRead(UnSafepwc, pwcSize, 1);
6928 RtlCopyMemory(Safepwc, UnSafepwc, pwcSize);
6929 }
6931 {
6933 }
6934 _SEH2_END;
6935 }
6936
6937 if (!NT_SUCCESS(Status))
6938 {
6940 return FALSE;
6941 }
6942
6943 BufferSize = Count * sizeof(INT); // Same size!
6945 if (!fl) SafeBuffF = (PFLOAT) SafeBuff;
6946 if (SafeBuff == NULL)
6947 {
6948 if(Safepwc)
6950
6952 return FALSE;
6953 }
6954
6955 dc = DC_LockDc(hDC);
6956 if (dc == NULL)
6957 {
6958 if(Safepwc)
6960
6961 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
6963 return FALSE;
6964 }
6965 pdcattr = dc->pdcattr;
6966 hFont = pdcattr->hlfntNew;
6967 TextObj = RealizeFontInit(hFont);
6968 DC_UnlockDc(dc);
6969
6970 if (TextObj == NULL)
6971 {
6972 if(Safepwc)
6974
6975 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
6977 return FALSE;
6978 }
6979
6980 FontGDI = ObjToGDI(TextObj->Font, FONT);
6981
6982 face = FontGDI->SharedFace->Face;
6983 if (face->charmap == NULL)
6984 {
6985 for (i = 0; i < (UINT)face->num_charmaps; i++)
6986 {
6987 charmap = face->charmaps[i];
6988 if (charmap->encoding != 0)
6989 {
6990 found = charmap;
6991 break;
6992 }
6993 }
6994
6995 if (!found)
6996 {
6997 DPRINT1("WARNING: Could not find desired charmap!\n");
6998
6999 if(Safepwc)
7001
7002 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
7004 return FALSE;
7005 }
7006
7008 FT_Set_Charmap(face, found);
7010 }
7011
7012 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
7013
7014 // NOTE: GetCharWidth simply ignores lfEscapement and XFORM.
7016 IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
7018
7019 for (i = FirstChar; i < FirstChar+Count; i++)
7020 {
7021 if (Safepwc)
7022 {
7023 glyph_index = get_glyph_index_flagged(face, Safepwc[i - FirstChar], GCW_INDICES, fl);
7024 }
7025 else
7026 {
7027 glyph_index = get_glyph_index_flagged(face, i, GCW_INDICES, fl);
7028 }
7029 FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
7030 if (!fl)
7031 SafeBuffF[i - FirstChar] = (FLOAT) ((face->glyph->advance.x + 32) >> 6);
7032 else
7033 SafeBuff[i - FirstChar] = (face->glyph->advance.x + 32) >> 6;
7034 }
7036 TEXTOBJ_UnlockText(TextObj);
7037 MmCopyToCaller(Buffer, SafeBuff, BufferSize);
7038
7039 if(Safepwc)
7041
7042 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
7043 return TRUE;
7044}
#define GCW_INDICES
Definition: ntgdityp.h:206
FLOAT * PFLOAT
Definition: windef.h:174

◆ NtGdiGetFontFamilyInfo()

LONG NTAPI NtGdiGetFontFamilyInfo ( HDC  Dc,
const LOGFONTW UnsafeLogFont,
PFONTFAMILYINFO  UnsafeInfo,
LPLONG  UnsafeInfoCount 
)

Definition at line 5720 of file freetype.c.

5724{
5726 LOGFONTW LogFont;
5728 LONG GotCount, AvailCount, SafeInfoCount;
5730
5731 if (UnsafeLogFont == NULL || UnsafeInfo == NULL || UnsafeInfoCount == NULL)
5732 {
5734 return -1;
5735 }
5736
5737 Status = MmCopyFromCaller(&SafeInfoCount, UnsafeInfoCount, sizeof(SafeInfoCount));
5738 if (!NT_SUCCESS(Status))
5739 {
5741 return -1;
5742 }
5743 GotCount = 0;
5744 Status = MmCopyToCaller(UnsafeInfoCount, &GotCount, sizeof(*UnsafeInfoCount));
5745 if (!NT_SUCCESS(Status))
5746 {
5748 return -1;
5749 }
5750 Status = MmCopyFromCaller(&LogFont, UnsafeLogFont, sizeof(LOGFONTW));
5751 if (!NT_SUCCESS(Status))
5752 {
5754 return -1;
5755 }
5756 if (SafeInfoCount <= 0)
5757 {
5759 return -1;
5760 }
5761
5762 /* Allocate space for a safe copy */
5763 Status = RtlULongMult(SafeInfoCount, sizeof(FONTFAMILYINFO), &DataSize);
5765 {
5766 DPRINT1("Overflowed.\n");
5768 return -1;
5769 }
5771 if (Info == NULL)
5772 {
5774 return -1;
5775 }
5776
5777 /* Retrieve the information */
5778 AvailCount = IntGetFontFamilyInfo(Dc, &LogFont, Info, SafeInfoCount);
5779 GotCount = min(AvailCount, SafeInfoCount);
5780 SafeInfoCount = AvailCount;
5781
5782 /* Return data to caller */
5783 if (GotCount > 0)
5784 {
5785 Status = RtlULongMult(GotCount, sizeof(FONTFAMILYINFO), &DataSize);
5787 {
5788 DPRINT1("Overflowed.\n");
5791 return -1;
5792 }
5793 Status = MmCopyToCaller(UnsafeInfo, Info, DataSize);
5794 if (!NT_SUCCESS(Status))
5795 {
5798 return -1;
5799 }
5800 Status = MmCopyToCaller(UnsafeInfoCount, &SafeInfoCount, sizeof(*UnsafeInfoCount));
5801 if (!NT_SUCCESS(Status))
5802 {
5805 return -1;
5806 }
5807 }
5808
5810
5811 return GotCount;
5812}
LONG FASTCALL IntGetFontFamilyInfo(HDC Dc, const LOGFONTW *SafeLogFont, PFONTFAMILYINFO SafeInfo, LONG InfoCount)
Definition: freetype.c:5681
#define LONG_MAX
Definition: limits.h:43
#define MmCopyFromCaller
Definition: polytest.cpp:29

Referenced by IntEnumFontFamilies().

◆ NtGdiGetGlyphIndicesW()

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

Definition at line 7057 of file freetype.c.

7063{
7064 PDC dc;
7065 PDC_ATTR pdcattr;
7066 PTEXTOBJ TextObj;
7067 PFONTGDI FontGDI;
7068 HFONT hFont = NULL;
7070 OUTLINETEXTMETRICW *potm;
7071 INT i;
7072 WCHAR DefChar = 0xffff;
7073 PWSTR Buffer = NULL;
7074 ULONG Size, pwcSize;
7075 PWSTR Safepwc = NULL;
7076 LPCWSTR UnSafepwc = pwc;
7077 LPWORD UnSafepgi = pgi;
7078 FT_Face Face;
7079 TT_OS2 *pOS2;
7080
7081 if (cwc < 0)
7082 {
7083 DPRINT1("cwc < 0\n");
7084 return GDI_ERROR;
7085 }
7086
7087 if (!UnSafepwc && !UnSafepgi && cwc > 0)
7088 {
7089 DPRINT1("!UnSafepwc && !UnSafepgi && cwc > 0\n");
7090 return GDI_ERROR;
7091 }
7092
7093 if (!UnSafepwc != !UnSafepgi)
7094 {
7095 DPRINT1("UnSafepwc == %p, UnSafepgi = %p\n", UnSafepwc, UnSafepgi);
7096 return GDI_ERROR;
7097 }
7098
7099 /* Get FontGDI */
7100 dc = DC_LockDc(hdc);
7101 if (!dc)
7102 {
7103 DPRINT1("!DC_LockDC\n");
7104 return GDI_ERROR;
7105 }
7106 pdcattr = dc->pdcattr;
7107 hFont = pdcattr->hlfntNew;
7108 TextObj = RealizeFontInit(hFont);
7109 DC_UnlockDc(dc);
7110 if (!TextObj)
7111 {
7112 DPRINT1("!TextObj\n");
7113 return GDI_ERROR;
7114 }
7115 FontGDI = ObjToGDI(TextObj->Font, FONT);
7116 TEXTOBJ_UnlockText(TextObj);
7117
7118 if (cwc == 0)
7119 {
7120 if (!UnSafepwc && !UnSafepgi)
7121 {
7122 Face = FontGDI->SharedFace->Face;
7123 return Face->num_glyphs;
7124 }
7125 else
7126 {
7128 goto ErrorRet;
7129 }
7130 }
7131
7133 if (!Buffer)
7134 {
7135 DPRINT1("ExAllocatePoolWithTag\n");
7136 return GDI_ERROR;
7137 }
7138
7139 /* Get DefChar */
7141 {
7142 DefChar = 0xffff;
7143 }
7144 else
7145 {
7146 Face = FontGDI->SharedFace->Face;
7147 if (FT_IS_SFNT(Face))
7148 {
7150 pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
7151 DefChar = (pOS2->usDefaultChar ? get_glyph_index(Face, pOS2->usDefaultChar) : 0);
7153 }
7154 else
7155 {
7156 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
7157 if (!Size)
7158 {
7160 DPRINT1("!Size\n");
7161 goto ErrorRet;
7162 }
7164 if (!potm)
7165 {
7167 DPRINT1("!potm\n");
7168 goto ErrorRet;
7169 }
7170 Size = IntGetOutlineTextMetrics(FontGDI, Size, potm);
7171 if (Size)
7172 DefChar = potm->otmTextMetrics.tmDefaultChar;
7174 }
7175 }
7176
7177 /* Allocate for Safepwc */
7178 pwcSize = cwc * sizeof(WCHAR);
7179 Safepwc = ExAllocatePoolWithTag(PagedPool, pwcSize, GDITAG_TEXT);
7180 if (!Safepwc)
7181 {
7183 DPRINT1("!Safepwc\n");
7184 goto ErrorRet;
7185 }
7186
7187 _SEH2_TRY
7188 {
7189 ProbeForRead(UnSafepwc, pwcSize, 1);
7190 RtlCopyMemory(Safepwc, UnSafepwc, pwcSize);
7191 }
7193 {
7195 }
7196 _SEH2_END;
7197
7198 if (!NT_SUCCESS(Status))
7199 {
7200 DPRINT1("Status: %08lX\n", Status);
7201 goto ErrorRet;
7202 }
7203
7204 /* Get glyph indeces */
7206 for (i = 0; i < cwc; i++)
7207 {
7208 Buffer[i] = get_glyph_index(FontGDI->SharedFace->Face, Safepwc[i]);
7209 if (Buffer[i] == 0)
7210 {
7211 Buffer[i] = DefChar;
7212 }
7213 }
7215
7216 _SEH2_TRY
7217 {
7218 ProbeForWrite(UnSafepgi, cwc * sizeof(WORD), 1);
7219 RtlCopyMemory(UnSafepgi, Buffer, cwc * sizeof(WORD));
7220 }
7222 {
7224 }
7225 _SEH2_END;
7226
7227ErrorRet:
7228 if (Buffer != NULL)
7229 {
7231 }
7232 if (Safepwc != NULL)
7233 {
7235 }
7236
7237 if (NT_SUCCESS(Status))
7238 return cwc;
7239
7240 return GDI_ERROR;
7241}
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
unsigned short WORD
Definition: ntddk_ex.h:93
HDC hdc
Definition: main.c:9
static LPCSTR INT LPWORD pgi
Definition: font.c:51
FT_UShort usDefaultChar
Definition: tttables.h:426
uint16_t * PWSTR
Definition: typedefs.h:56
uint16_t * LPWORD
Definition: typedefs.h:56
_In_ ULONG iMode
Definition: winddi.h:3520
#define GGI_MARK_NONEXISTING_GLYPHS
Definition: wingdi.h:1085

Referenced by GetCharacterPlacementW(), and GetGlyphIndicesA().

◆ PathIsRelativeW()

BOOL WINAPI PathIsRelativeW ( LPCWSTR  lpszPath)

Definition at line 1642 of file freetype.c.

1643{
1644 if (!lpszPath || !*lpszPath)
1645 return TRUE;
1646 if (*lpszPath == L'\\' || (*lpszPath && lpszPath[1] == L':'))
1647 return FALSE;
1648 return TRUE;
1649}

Referenced by IntLoadFontsInRegistry().

◆ RemoveCachedEntry()

static void RemoveCachedEntry ( PFONT_CACHE_ENTRY  Entry)
static

◆ RemoveCacheEntries()

static void RemoveCacheEntries ( FT_Face  Face)
static

Definition at line 284 of file freetype.c.

285{
286 PLIST_ENTRY CurrentEntry, NextEntry;
287 PFONT_CACHE_ENTRY FontEntry;
288
290
291 for (CurrentEntry = g_FontCacheListHead.Flink;
292 CurrentEntry != &g_FontCacheListHead;
293 CurrentEntry = NextEntry)
294 {
295 FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
296 NextEntry = CurrentEntry->Flink;
297
298 if (FontEntry->Hashed.Face == Face)
299 {
300 RemoveCachedEntry(FontEntry);
301 }
302 }
303}

Referenced by SharedFace_Release().

◆ RTL_STATIC_LIST_HEAD()

static RTL_STATIC_LIST_HEAD ( g_FontSubstListHead  )
static

◆ ScaleLong()

static LONG ScaleLong ( LONG  lValue,
PFLOATOBJ  pef 
)
inlinestatic

Definition at line 5816 of file freetype.c.

5817{
5818 FLOATOBJ efTemp;
5819
5820 /* Check if we have scaling different from 1 */
5821 if (!FLOATOBJ_Equal(pef, (PFLOATOBJ)&gef1))
5822 {
5823 /* Need to multiply */
5824 FLOATOBJ_SetLong(&efTemp, lValue);
5825 FLOATOBJ_Mul(&efTemp, pef);
5826 lValue = FLOATOBJ_GetLong(&efTemp);
5827 }
5828
5829 return lValue;
5830}
static const FLOATOBJ gef1
Definition: floatobj.h:114
#define FLOATOBJ_Equal(pf, pf1)
Definition: winddi.h:2831
FLOAT * PFLOATOBJ
Definition: winddi.h:677

◆ SharedFace_AddRef()

static void SharedFace_AddRef ( PSHARED_FACE  Ptr)
static

Definition at line 264 of file freetype.c.

265{
267
268 ++Ptr->RefCount;
269}
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898

Referenced by IntGdiLoadFontsFromMemory().

◆ SharedFace_Create()

static PSHARED_FACE SharedFace_Create ( FT_Face  Face,
PSHARED_MEM  Memory 
)
static

Definition at line 229 of file freetype.c.

230{
233 if (Ptr)
234 {
235 Ptr->Face = Face;
236 Ptr->RefCount = 1;
237 Ptr->Memory = Memory;
238 SharedFaceCache_Init(&Ptr->EnglishUS);
239 SharedFaceCache_Init(&Ptr->UserLanguage);
240
242 DPRINT("Creating SharedFace for %s\n", Face->family_name ? Face->family_name : "<NULL>");
243 }
244 return Ptr;
245}
static void SharedMem_AddRef(PSHARED_MEM Ptr)
Definition: freetype.c:213
static void SharedFaceCache_Init(PSHARED_FACE_CACHE Cache)
Definition: freetype.c:221
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169

Referenced by IntGdiLoadFontsFromMemory().

◆ SharedFace_Release()

static void SharedFace_Release ( PSHARED_FACE  Ptr)
static

Definition at line 333 of file freetype.c.

334{
336 ASSERT(Ptr->RefCount > 0);
337
338 if (Ptr->RefCount <= 0)
339 return;
340
341 --Ptr->RefCount;
342 if (Ptr->RefCount == 0)
343 {
344 DPRINT("Releasing SharedFace for %s\n", Ptr->Face->family_name ? Ptr->Face->family_name : "<NULL>");
345 RemoveCacheEntries(Ptr->Face);
346 FT_Done_Face(Ptr->Face);
347 SharedMem_Release(Ptr->Memory);
348 SharedFaceCache_Release(&Ptr->EnglishUS);
349 SharedFaceCache_Release(&Ptr->UserLanguage);
351 }
353}
static void RemoveCacheEntries(FT_Face Face)
Definition: freetype.c:284
static void SharedFaceCache_Release(PSHARED_FACE_CACHE Cache)
Definition: freetype.c:326
FT_Done_Face(FT_Face face)
Definition: ftobjs.c:2721

Referenced by CleanupFontEntryEx(), and IntGdiLoadFontsFromMemory().

◆ SharedFaceCache_Init()

static void SharedFaceCache_Init ( PSHARED_FACE_CACHE  Cache)
static

Definition at line 221 of file freetype.c.

222{
223 Cache->OutlineRequiredSize = 0;
224 RtlInitUnicodeString(&Cache->FontFamily, NULL);
225 RtlInitUnicodeString(&Cache->FullName, NULL);
226}

Referenced by SharedFace_Create().

◆ SharedFaceCache_Release()

static void SharedFaceCache_Release ( PSHARED_FACE_CACHE  Cache)
static

Definition at line 326 of file freetype.c.

327{
328 RtlFreeUnicodeString(&Cache->FontFamily);
329 RtlFreeUnicodeString(&Cache->FullName);
330}

Referenced by SharedFace_Release().

◆ SharedMem_AddRef()

static void SharedMem_AddRef ( PSHARED_MEM  Ptr)
static

Definition at line 213 of file freetype.c.

214{
216
217 ++Ptr->RefCount;
218}

Referenced by SharedFace_Create().

◆ SharedMem_Create()

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

Definition at line 248 of file freetype.c.

249{
252 if (Ptr)
253 {
254 Ptr->Buffer = Buffer;
255 Ptr->BufferSize = BufferSize;
256 Ptr->RefCount = 1;
257 Ptr->IsMapping = IsMapping;
258 DPRINT("Creating SharedMem for %p (%i, %p)\n", Buffer, IsMapping, Ptr);
259 }
260 return Ptr;
261}

Referenced by IntGdiAddFontMemResource(), and IntGdiAddFontResourceEx().

◆ SharedMem_Release()

static void SharedMem_Release ( PSHARED_MEM  Ptr)
static

Definition at line 305 of file freetype.c.

306{
308 ASSERT(Ptr->RefCount > 0);
309
310 if (Ptr->RefCount <= 0)
311 return;
312
313 --Ptr->RefCount;
314 if (Ptr->RefCount == 0)
315 {
316 DPRINT("Releasing SharedMem for %p (%i, %p)\n", Ptr->Buffer, Ptr->IsMapping, Ptr);
317 if (Ptr->IsMapping)
319 else
322 }
323}
NTSTATUS NTAPI MmUnmapViewInSystemSpace(IN PVOID MappedBase)
Definition: section.c:3128

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

◆ SubstituteFontByList()

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

Definition at line 768 of file freetype.c.

773{
774 PLIST_ENTRY pListEntry;
775 PFONTSUBST_ENTRY pSubstEntry;
776 BYTE CharSets[FONTSUBST_FROM_AND_TO];
777
778 CharSetMap[FONTSUBST_FROM] = DEFAULT_CHARSET;
779 CharSetMap[FONTSUBST_TO] = RequestedCharSet;
780
781 /* for each list entry */
782 for (pListEntry = pHead->Flink;
783 pListEntry != pHead;
784 pListEntry = pListEntry->Flink)
785 {
786 pSubstEntry =
787 (PFONTSUBST_ENTRY)CONTAINING_RECORD(pListEntry, FONT_ENTRY, ListEntry);
788
789 CharSets[FONTSUBST_FROM] = pSubstEntry->CharSets[FONTSUBST_FROM];
790
791 if (CharSets[FONTSUBST_FROM] != DEFAULT_CHARSET &&
792 CharSets[FONTSUBST_FROM] != RequestedCharSet)
793 {
794 continue; /* not matched */
795 }
796
797 /* does charset number exist? (to) */
798 if (pSubstEntry->CharSets[FONTSUBST_TO] != DEFAULT_CHARSET)
799 {
800 CharSets[FONTSUBST_TO] = pSubstEntry->CharSets[FONTSUBST_TO];
801 }
802 else
803 {
804 CharSets[FONTSUBST_TO] = RequestedCharSet;
805 }
806
807 /* does font name match? */
809 pInputName, TRUE))
810 {
811 continue; /* not matched */
812 }
813
814 /* update *pOutputName */
815 *pOutputName = pSubstEntry->FontNames[FONTSUBST_TO];
816
817 if (CharSetMap[FONTSUBST_FROM] == DEFAULT_CHARSET)
818 {
819 /* update CharSetMap */
820 CharSetMap[FONTSUBST_FROM] = CharSets[FONTSUBST_FROM];
821 CharSetMap[FONTSUBST_TO] = CharSets[FONTSUBST_TO];
822 }
823 return TRUE; /* success */
824 }
825
826 return FALSE;
827}
struct FONTSUBST_ENTRY * PFONTSUBST_ENTRY

Referenced by SubstituteFontRecurse().

◆ SubstituteFontRecurse()

static BOOL SubstituteFontRecurse ( LOGFONTW pLogFont)
static

Definition at line 868 of file freetype.c.

869{
870 UINT RecurseCount = 5;
871 UNICODE_STRING OutputNameW = { 0 };
872 BYTE CharSetMap[FONTSUBST_FROM_AND_TO];
873 BOOL Found;
874 UNICODE_STRING InputNameW;
875
876 if (pLogFont->lfFaceName[0] == UNICODE_NULL)
877 return FALSE;
878
879 RtlInitUnicodeString(&InputNameW, pLogFont->lfFaceName);
880
881 while (RecurseCount-- > 0)
882 {
883 Found = SubstituteFontByList(&g_FontSubstListHead,
884 &OutputNameW, &InputNameW,
885 pLogFont->lfCharSet, CharSetMap);
886 if (!Found)
887 break;
888
889 IntUnicodeStringToBuffer(pLogFont->lfFaceName, sizeof(pLogFont->lfFaceName), &OutputNameW);
890
891 if (CharSetMap[FONTSUBST_FROM] == DEFAULT_CHARSET ||
892 CharSetMap[FONTSUBST_FROM] == pLogFont->lfCharSet)
893 {
894 pLogFont->lfCharSet = CharSetMap[FONTSUBST_TO];
895 }
896 }
897
898 return TRUE; /* success */
899}
static BOOL SubstituteFontByList(PLIST_ENTRY pHead, PUNICODE_STRING pOutputName, PUNICODE_STRING pInputName, BYTE RequestedCharSet, BYTE CharSetMap[FONTSUBST_FROM_AND_TO])
Definition: freetype.c:768

Referenced by GetFontFamilyInfoForSubstitutes(), and TextIntRealizeFont().

◆ SwapEndian()

static void SwapEndian ( LPVOID  pvData,
DWORD  Size 
)
static

Definition at line 2604 of file freetype.c.

2605{
2606 BYTE b, *pb = pvData;
2607 Size /= 2;
2608 while (Size-- > 0)
2609 {
2610 b = pb[0];
2611 pb[0] = pb[1];
2612 pb[1] = b;
2613 ++pb; ++pb;
2614 }
2615}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749

Referenced by IntGetFontLocalizedName().

◆ TextIntCreateFontIndirect()

NTSTATUS FASTCALL TextIntCreateFontIndirect ( CONST LPLOGFONTW  lf,
HFONT NewFont 
)

Definition at line 2006 of file freetype.c.

2007{
2008 PLFONT plfont;
2009 LOGFONTW *plf;
2010
2011 ASSERT(lf);
2012 plfont = LFONT_AllocFontWithHandle();
2013 if (!plfont)
2014 {
2015 return STATUS_NO_MEMORY;
2016 }
2017
2018 ExInitializePushLock(&plfont->lock);
2019 *NewFont = plfont->BaseObject.hHmgr;
2020 plf = &plfont->logfont.elfEnumLogfontEx.elfLogFont;
2021 RtlCopyMemory(plf, lf, sizeof(LOGFONTW));
2022 if (lf->lfEscapement != lf->lfOrientation)
2023 {
2024 /* This should really depend on whether GM_ADVANCED is set */
2025 plf->lfOrientation = plf->lfEscapement;
2026 }
2027 LFONT_UnlockFont(plfont);
2028
2029 return STATUS_SUCCESS;
2030}
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define ExInitializePushLock
Definition: ex.h:1013
BASEOBJECT BaseObject
Definition: text.h:63
EX_PUSH_LOCK lock
Definition: text.h:71
#define LFONT_UnlockFont(plfnt)
Definition: text.h:79
#define LFONT_AllocFontWithHandle()
Definition: text.h:76

Referenced by CreateStockFonts(), and UserDrawCaptionText().

◆ TextIntGetTextExtentPoint()

BOOL FASTCALL TextIntGetTextExtentPoint ( PDC  dc,
PTEXTOBJ  TextObj,
LPCWSTR  String,
INT  Count,
ULONG  MaxExtent,
LPINT  Fit,
LPINT  Dx,
LPSIZE  Size,
FLONG  fl 
)

Definition at line 4215 of file freetype.c.

4224{
4225 PFONTGDI FontGDI;
4226 FT_BitmapGlyph realglyph;
4227 INT glyph_index, i, previous, nTenthsOfDegrees;
4228 ULONGLONG TotalWidth64 = 0;
4229 LOGFONTW *plf;
4230 BOOL use_kerning, bVerticalWriting;
4231 LONG ascender, descender;
4233 DWORD ch0, ch1;
4234
4235 FontGDI = ObjToGDI(TextObj->Font, FONT);
4236
4237 Cache.Hashed.Face = FontGDI->SharedFace->Face;
4238 if (NULL != Fit)
4239 {
4240 *Fit = 0;
4241 }
4242
4243 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4244 Cache.Hashed.lfHeight = plf->lfHeight;
4245 Cache.Hashed.lfWidth = plf->lfWidth;
4246 Cache.Hashed.Aspect.Emu.Bold = EMUBOLD_NEEDED(FontGDI->OriginalWeight, plf->lfWeight);
4247 Cache.Hashed.Aspect.Emu.Italic = (plf->lfItalic && !FontGDI->OriginalItalic);
4248
4249 // Check vertical writing (tategaki)
4250 nTenthsOfDegrees = IntNormalizeAngle(plf->lfEscapement - plf->lfOrientation);
4251 bVerticalWriting = ((nTenthsOfDegrees == 90 * 10) || (nTenthsOfDegrees == 270 * 10));
4252
4254 Cache.Hashed.Aspect.RenderMode = (BYTE)IntGetFontRenderMode(plf);
4255 else
4256 Cache.Hashed.Aspect.RenderMode = (BYTE)FT_RENDER_MODE_MONO;
4257
4258 // NOTE: GetTextExtentPoint32 simply ignores lfEscapement and XFORM.
4260 TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
4261 Cache.Hashed.matTransform = identityMat;
4262 FT_Set_Transform(Cache.Hashed.Face, NULL, NULL);
4263
4264 use_kerning = FT_HAS_KERNING(Cache.Hashed.Face);
4265 previous = 0;
4266
4267 for (i = 0; i < Count; i++)
4268 {
4269 ch0 = *String++;
4270 if (IS_HIGH_SURROGATE(ch0))
4271 {
4272 ++i;
4273 if (i >= Count)
4274 break;
4275
4276 ch1 = *String++;
4277 if (IS_LOW_SURROGATE(ch1))
4278 ch0 = Utf32FromSurrogatePair(ch0, ch1);
4279 }
4280
4281 glyph_index = get_glyph_index_flagged(Cache.Hashed.Face, ch0, GTEF_INDICES, fl);
4282 Cache.Hashed.GlyphIndex = glyph_index;
4283
4284 realglyph = IntGetRealGlyph(&Cache);
4285 if (!realglyph)
4286 break;
4287
4288 /* Retrieve kerning distance */
4289 if (use_kerning && previous && glyph_index)
4290 {
4291 FT_Vector delta;
4292 FT_Get_Kerning(Cache.Hashed.Face, previous, glyph_index, 0, &delta);
4293 TotalWidth64 += delta.x;
4294 }
4295
4296 TotalWidth64 += realglyph->root.advance.x >> 10;
4297
4298 if (((TotalWidth64 + 32) >> 6) <= MaxExtent && NULL != Fit)
4299 {
4300 *Fit = i + 1;
4301 }
4302 if (NULL != Dx)
4303 {
4304 Dx[i] = (TotalWidth64 + 32) >> 6;
4305 }
4306
4307 previous = glyph_index;
4308 }
4309 ASSERT(FontGDI->Magic == FONTGDI_MAGIC);
4310 ascender = FontGDI->tmAscent; /* Units above baseline */
4311 descender = FontGDI->tmDescent; /* Units below baseline */
4313
4314 if (bVerticalWriting)
4315 {
4316 Size->cx = ascender + descender;
4317 Size->cy = (TotalWidth64 + 32) >> 6;
4318 }
4319 else
4320 {
4321 Size->cx = (TotalWidth64 + 32) >> 6;
4322 Size->cy = ascender + descender;
4323 }
4324
4325 return TRUE;
4326}
static LONG IntNormalizeAngle(LONG nTenthsOfDegrees)
Definition: freetype.c:718
#define GTEF_INDICES
Definition: ntgdityp.h:213
uint64_t ULONGLONG
Definition: typedefs.h:67

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

◆ TextIntRealizeFont()

NTSTATUS FASTCALL TextIntRealizeFont ( HFONT  FontHandle,
PTEXTOBJ  pTextObj 
)

Definition at line 5156 of file freetype.c.

5157{
5159 PTEXTOBJ TextObj;
5160 PPROCESSINFO Win32Process;
5161 ULONG MatchPenalty;
5162 LOGFONTW *pLogFont;
5163 LOGFONTW SubstitutedLogFont;
5164
5165 if (!pTextObj)
5166 {
5167 TextObj = TEXTOBJ_LockText(FontHandle);
5168 if (NULL == TextObj)
5169 {
5170 return STATUS_INVALID_HANDLE;
5171 }
5172
5173 if (TextObj->fl & TEXTOBJECT_INIT)
5174 {
5175 TEXTOBJ_UnlockText(TextObj);
5176 return STATUS_SUCCESS;
5177 }
5178 }
5179 else
5180 {
5181 TextObj = pTextObj;
5182 }
5183
5184 pLogFont = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
5185
5186 /* substitute */
5187 SubstitutedLogFont = *pLogFont;
5188 DPRINT("Font '%S,%u' is substituted by: ", pLogFont->lfFaceName, pLogFont->lfCharSet);
5189 SubstituteFontRecurse(&SubstitutedLogFont);
5190 DPRINT("'%S,%u'.\n", SubstitutedLogFont.lfFaceName, SubstitutedLogFont.lfCharSet);
5191
5192 MatchPenalty = 0xFFFFFFFF;
5193 TextObj->Font = NULL;
5194
5195 Win32Process = PsGetCurrentProcessWin32Process();
5196
5197 /* Search private fonts */
5198 IntLockProcessPrivateFonts(Win32Process);
5199 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
5200 &Win32Process->PrivateFontListHead);
5201 IntUnLockProcessPrivateFonts(Win32Process);
5202
5203 /* Search system fonts */
5205 FindBestFontFromList(&TextObj->Font, &MatchPenalty, &SubstitutedLogFont,
5208
5209 if (NULL == TextObj->Font)
5210 {
5211 DPRINT1("Request font %S not found, no fonts loaded at all\n",
5212 pLogFont->lfFaceName);
5214 }
5215 else
5216 {
5218 PFONTGDI FontGdi = ObjToGDI(TextObj->Font, FONT);
5219 PSHARED_FACE SharedFace = FontGdi->SharedFace;
5220
5221 TextObj->TextFace[0] = UNICODE_NULL;
5222 if (MatchFontNames(SharedFace, SubstitutedLogFont.lfFaceName))
5223 {
5224 RtlStringCchCopyW(TextObj->TextFace, _countof(TextObj->TextFace), pLogFont->lfFaceName);
5225 }
5226 else
5227 {
5230 if (NT_SUCCESS(Status))
5231 {
5232 /* truncated copy */
5233 IntUnicodeStringToBuffer(TextObj->TextFace, sizeof(TextObj->TextFace), &Name);
5235 }
5236 }
5237
5238 // Need hdev, when freetype is loaded need to create DEVOBJ for
5239 // Consumer and Producer.
5240 TextObj->Font->iUniq = 1; // Now it can be cached.
5241 IntFontType(FontGdi);
5242 FontGdi->flType = TextObj->Font->flFontType;
5243 FontGdi->RequestUnderline = pLogFont->lfUnderline ? 0xFF : 0;
5244 FontGdi->RequestStrikeOut = pLogFont->lfStrikeOut ? 0xFF : 0;
5245 FontGdi->RequestItalic = pLogFont->lfItalic ? 0xFF : 0;
5246 if (pLogFont->lfWeight != FW_DONTCARE)
5247 FontGdi->RequestWeight = pLogFont->lfWeight;
5248 else
5249 FontGdi->RequestWeight = FW_NORMAL;
5250
5251 TextObj->fl |= TEXTOBJECT_INIT;
5253 }
5254
5255 if (!pTextObj) TEXTOBJ_UnlockText(TextObj);
5256
5257 ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->Font)) != 0);
5258
5259 return Status;
5260}
static VOID FASTCALL IntFontType(PFONTGDI Font)
Definition: freetype.c:5071
static __inline VOID FindBestFontFromList(FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
Definition: freetype.c:5003
static BOOL MatchFontNames(PSHARED_FACE SharedFace, LPCWSTR lfFaceName)
Definition: freetype.c:5129
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
FLONG flType
Definition: engobjects.h:142
ULONG iUniq
Definition: winddi.h:762
FLONG flFontType
Definition: winddi.h:765
FLONG fl
Definition: text.h:65
WCHAR TextFace[LF_FACESIZE]
Definition: text.h:67
FORCEINLINE PTEXTOBJ TEXTOBJ_LockText(HFONT hfont)
Definition: text.h:83
#define TEXTOBJECT_INIT
Definition: text.h:56

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

◆ TextIntUpdateSize()

BOOL FASTCALL TextIntUpdateSize ( PDC  dc,
PTEXTOBJ  TextObj,
PFONTGDI  FontGDI,
BOOL  bDoLock 
)

Definition at line 3556 of file freetype.c.

3560{
3561 FT_Face face;
3562 INT error, n;
3563 FT_CharMap charmap, found;
3564 LOGFONTW *plf;
3565
3566 if (bDoLock)
3568
3569 face = FontGDI->SharedFace->Face;
3570 if (face->charmap == NULL)
3571 {
3572 DPRINT("WARNING: No charmap selected!\n");
3573 DPRINT("This font face has %d charmaps\n", face->num_charmaps);
3574
3575 found = NULL;
3576 for (n = 0; n < face->num_charmaps; n++)
3577 {
3578 charmap = face->charmaps[n];
3579 if (charmap->encoding == FT_ENCODING_UNICODE)
3580 {
3581 found = charmap;
3582 break;
3583 }
3584 }
3585 if (!found)
3586 {
3587 for (n = 0; n < face->num_charmaps; n++)
3588 {
3589 charmap = face->charmaps[n];
3590 if (charmap->platform_id == TT_PLATFORM_APPLE_UNICODE)
3591 {
3592 found = charmap;
3593 break;
3594 }
3595 }
3596 }
3597 if (!found)
3598 {
3599 for (n = 0; n < face->num_charmaps; n++)
3600 {
3601 charmap = face->charmaps[n];
3602 if (charmap->encoding == FT_ENCODING_MS_SYMBOL)
3603 {
3604 found = charmap;
3605 break;
3606 }
3607 }
3608 }
3609 if (!found && face->num_charmaps > 0)
3610 {
3611 found = face->charmaps[0];
3612 }
3613 if (!found)
3614 {
3615 DPRINT1("WARNING: Could not find desired charmap!\n");
3616 }
3617 else
3618 {
3619 DPRINT("Found charmap encoding: %i\n", found->encoding);
3620 error = FT_Set_Charmap(face, found);
3621 if (error)
3622 {
3623 DPRINT1("WARNING: Could not set the charmap!\n");
3624 }
3625 }
3626 }
3627
3628 plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
3629
3630 error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
3631
3632 if (bDoLock)
3634
3635 if (error)
3636 {
3637 DPRINT1("Error in setting pixel sizes: %d\n", error);
3638 return FALSE;
3639 }
3640
3641 return TRUE;
3642}
#define TT_PLATFORM_APPLE_UNICODE
Definition: font.c:1172
GLdouble n
Definition: glext.h:7729

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

◆ UnlinkFontMemCollection()

static VOID FASTCALL UnlinkFontMemCollection ( PFONT_ENTRY_COLL_MEM  Collection)
static

Definition at line 1875 of file freetype.c.

1876{
1877 PFONT_ENTRY_MEM FontMemEntry = Collection->Entry;
1878 PLIST_ENTRY ListEntry;
1879 RemoveEntryList(&Collection->ListEntry);
1880
1881 do {
1882 /* Also unlink the FONT_ENTRY stuff from the PrivateFontListHead */
1883 RemoveEntryList(&FontMemEntry->Entry->ListEntry);
1884
1885 ListEntry = FontMemEntry->ListEntry.Flink;
1886 FontMemEntry = CONTAINING_RECORD(ListEntry, FONT_ENTRY_MEM, ListEntry);
1887
1888 } while (FontMemEntry != Collection->Entry);
1889}
LIST_ENTRY ListEntry
Definition: font.h:6
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ WDFCOLLECTION Collection
Definition: wdfregistry.h:374

Referenced by IntGdiCleanupPrivateFontsForProcess(), and IntGdiRemoveFontMemResource().

◆ Utf32FromSurrogatePair()

static DWORD Utf32FromSurrogatePair ( DWORD  ch0,
DWORD  ch1 
)
inlinestatic

Definition at line 48 of file freetype.c.

49{
50 return ((ch0 - HIGH_SURROGATE_MIN) << 10) + (ch1 - LOW_SURROGATE_MIN) + 0x10000;
51}
#define LOW_SURROGATE_MIN
Definition: freetype.c:41
#define HIGH_SURROGATE_MIN
Definition: freetype.c:39

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

Variable Documentation

◆ g_ElfScripts

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

Definition at line 111 of file freetype.c.

Referenced by FontFamilyFillInfo().

◆ g_FontCacheListHead

LIST_ENTRY g_FontCacheListHead
static

◆ g_FontCacheNumEntries

UINT g_FontCacheNumEntries
static

Definition at line 109 of file freetype.c.

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

◆ g_FontListHead

◆ g_FontListLock

PFAST_MUTEX g_FontListLock
static

Definition at line 82 of file freetype.c.

Referenced by InitFontSupport().

◆ g_FontRegPath

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

Definition at line 73 of file freetype.c.

Referenced by IntGdiAddFontResourceEx(), and IntLoadFontsInRegistry().

◆ g_FontTci

◆ g_FreeTypeLibrary

FT_Library g_FreeTypeLibrary

Definition at line 70 of file freetype.c.

Referenced by ftGdiGetGlyphOutline(), InitFontSupport(), and IntGdiLoadFontsFromMemory().

◆ g_FreeTypeLock

PFAST_MUTEX g_FreeTypeLock
static

Definition at line 79 of file freetype.c.

Referenced by InitFontSupport().

◆ g_RenderingEnabled

BOOL g_RenderingEnabled = TRUE
static

Definition at line 83 of file freetype.c.

Referenced by IntEnableFontRendering(), and IntIsFontRenderingEnabled().

◆ gmxWorldToDeviceDefault

const MATRIX gmxWorldToDeviceDefault
extern

Definition at line 20 of file dclife.c.

◆ gmxWorldToPageDefault

const MATRIX gmxWorldToPageDefault
extern

Definition at line 36 of file dclife.c.

Referenced by DC_vInitDc().

◆ identityMat

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

Definition at line 64 of file freetype.c.

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

◆ PointZero

POINTL PointZero = { 0, 0 }
static

Definition at line 65 of file freetype.c.

Referenced by IntEngFillBox(), IntEngFillPolygon(), and IntExtTextOutW().