ReactOS  0.4.15-dev-5461-g062a8f2
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 _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   100
 

Typedefs

typedef struct FONT_NAMES FONT_NAMES
 
typedef struct FONT_NAMESLPFONT_NAMES
 

Functions

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 FASTCALL IntWidthMatrix (FT_Face face, FT_Matrix *pmat, LONG lfWidth)
 
VOID FASTCALL IntEscapeMatrix (FT_Matrix *pmat, LONG lfEscapement)
 
VOID FASTCALL FtMatrixFromMx (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 ftGdiGlyphCacheGet (IN const FONT_CACHE_ENTRY *pCache)
 
static FT_BitmapGlyph ftGdiGlyphSet (FT_Face Face, FT_GlyphSlot GlyphSlot, FT_Render_Mode RenderMode)
 
static FT_BitmapGlyph ftGdiGlyphCacheSet (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 ftGdiGetRealGlyph (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 ftGdiGetTextWidth (LONGLONG *pTextWidth64, LPCWSTR String, INT Count, PFONT_CACHE_ENTRY Cache, UINT fuOptions)
 
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)}
 
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 41 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_HELD

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

Definition at line 85 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_NOT_HELD

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

Definition at line 88 of file freetype.c.

◆ ASSERT_GLOBALFONTS_LOCK_HELD

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

Definition at line 76 of file freetype.c.

◆ CP_MACCP

#define CP_MACCP   2

Definition at line 167 of file freetype.c.

◆ CP_OEMCP

#define CP_OEMCP   1

Definition at line 166 of file freetype.c.

◆ CP_SYMBOL

#define CP_SYMBOL   42

Definition at line 122 of file freetype.c.

◆ EMUBOLD_NEEDED

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

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

◆ gmxWorldToDeviceDefault

#define gmxWorldToDeviceDefault   gmxWorldToPageDefault

Definition at line 53 of file freetype.c.

◆ GOT_PENALTY

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

Definition at line 4686 of file freetype.c.

◆ IntLockFreeType

Definition at line 79 of file freetype.c.

◆ IntLockGlobalFonts

Definition at line 70 of file freetype.c.

◆ IntUnLockFreeType

Definition at line 82 of file freetype.c.

◆ IntUnLockGlobalFonts

Definition at line 73 of file freetype.c.

◆ MAX_FONT_CACHE

#define MAX_FONT_CACHE   256

Definition at line 91 of file freetype.c.

◆ MAXTCIINDEX

#define MAXTCIINDEX   32

Definition at line 123 of file freetype.c.

◆ NDEBUG

#define NDEBUG

Definition at line 36 of file freetype.c.

◆ PX2PT

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

Definition at line 1075 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   100

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

2575 {
2576  /* FIXME: Add more and fix if wrong */
2577  switch (PRIMARYLANGID(LangID))
2578  {
2579  case LANG_CHINESE:
2580  switch (SUBLANGID(LangID))
2581  {
2583  return CHINESEBIG5_CHARSET;
2585  default:
2586  break;
2587  }
2588  return GB2312_CHARSET;
2589 
2590  case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
2591  case LANG_SLOVAK: case LANG_SLOVENIAN: case LANG_ROMANIAN:
2592  return EASTEUROPE_CHARSET;
2593 
2594  case LANG_RUSSIAN: case LANG_BULGARIAN: case LANG_MACEDONIAN:
2595  case LANG_SERBIAN: case LANG_UKRAINIAN:
2596  return RUSSIAN_CHARSET;
2597 
2598  case LANG_ARABIC: return ARABIC_CHARSET;
2599  case LANG_GREEK: return GREEK_CHARSET;
2600  case LANG_HEBREW: return HEBREW_CHARSET;
2601  case LANG_JAPANESE: return SHIFTJIS_CHARSET;
2602  case LANG_KOREAN: return JOHAB_CHARSET;
2603  case LANG_TURKISH: return TURKISH_CHARSET;
2604  case LANG_THAI: return THAI_CHARSET;
2605  case LANG_LATVIAN: return BALTIC_CHARSET;
2606  case LANG_VIETNAMESE: return VIETNAMESE_CHARSET;
2607 
2608  case LANG_ENGLISH: case LANG_BASQUE: case LANG_CATALAN:
2609  case LANG_DANISH: case LANG_DUTCH: case LANG_FINNISH:
2610  case LANG_FRENCH: case LANG_GERMAN: case LANG_ITALIAN:
2611  case LANG_NORWEGIAN: case LANG_PORTUGUESE: case LANG_SPANISH:
2612  case LANG_SWEDISH: default:
2613  return ANSI_CHARSET;
2614  }
2615 }
#define LANG_BASQUE
Definition: nls.h:34
#define SUBLANG_CHINESE_TRADITIONAL
Definition: nls.h:208
#define EASTEUROPE_CHARSET
Definition: wingdi.h:399
#define LANG_THAI
Definition: nls.h:132
#define LANG_HUNGARIAN
Definition: nls.h:69
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:390
#define LANG_DUTCH
Definition: nls.h:51
#define LANG_CZECH
Definition: nls.h:47
#define LANG_ARABIC
Definition: nls.h:29
#define LANG_ROMANIAN
Definition: nls.h:111
#define LANG_HEBREW
Definition: nls.h:67
#define LANG_SERBIAN
Definition: nls.h:116
#define LANG_MACEDONIAN
Definition: nls.h:91
#define LANG_SLOVAK
Definition: nls.h:120
#define LANG_BULGARIAN
Definition: nls.h:40
#define LANG_JAPANESE
Definition: nls.h:76
#define LANG_TURKISH
Definition: nls.h:136
#define LANG_NORWEGIAN
Definition: nls.h:102
#define LANG_ITALIAN
Definition: nls.h:75
#define TURKISH_CHARSET
Definition: wingdi.h:392
#define LANG_SLOVENIAN
Definition: nls.h:121
#define LANG_PORTUGUESE
Definition: nls.h:108
#define LANG_LATVIAN
Definition: nls.h:87
#define THAI_CHARSET
Definition: wingdi.h:397
#define SHIFTJIS_CHARSET
Definition: wingdi.h:386
#define LANG_DANISH
Definition: nls.h:48
#define LANG_RUSSIAN
Definition: nls.h:113
#define RUSSIAN_CHARSET
Definition: wingdi.h:396
#define LANG_ENGLISH
Definition: nls.h:52
#define GB2312_CHARSET
Definition: wingdi.h:389
#define SUBLANG_CHINESE_SIMPLIFIED
Definition: nls.h:209
#define LANG_FRENCH
Definition: nls.h:58
#define LANG_VIETNAMESE
Definition: nls.h:143
#define LANG_GERMAN
Definition: nls.h:62
#define VIETNAMESE_CHARSET
Definition: wingdi.h:402
#define HEBREW_CHARSET
Definition: wingdi.h:393
#define LANG_UKRAINIAN
Definition: nls.h:139
#define ARABIC_CHARSET
Definition: wingdi.h:394
#define LANG_CHINESE
Definition: nls.h:42
#define LANG_SWEDISH
Definition: nls.h:125
#define LANG_KOREAN
Definition: nls.h:84
#define LANG_POLISH
Definition: nls.h:107
#define ANSI_CHARSET
Definition: wingdi.h:383
#define JOHAB_CHARSET
Definition: wingdi.h:401
_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:1075
#define BALTIC_CHARSET
Definition: wingdi.h:395
#define GREEK_CHARSET
Definition: wingdi.h:391
#define LANG_FINNISH
Definition: nls.h:57
#define LANG_SPANISH
Definition: nls.h:123
#define LANG_GREEK
Definition: nls.h:63
#define LANG_CATALAN
Definition: nls.h:41
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define SUBLANGID(l)
Definition: nls.h:17

Referenced by GetFontPenalty().

◆ CleanupFontEntry()

static __inline VOID FASTCALL CleanupFontEntry ( PFONT_ENTRY  FontEntry)
static

Definition at line 362 of file freetype.c.

363 {
364  CleanupFontEntryEx(FontEntry, FontEntry->Font);
365 }
FONTGDI * Font
Definition: font.h:7
static VOID FASTCALL CleanupFontEntryEx(PFONT_ENTRY FontEntry, PFONTGDI FontGDI)
Definition: freetype.c:342

Referenced by IntGdiCleanupMemEntry(), and IntGdiCleanupPrivateFontsForProcess().

◆ CleanupFontEntryEx()

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

Definition at line 342 of file freetype.c.

343 {
344  // PFONTGDI FontGDI = FontEntry->Font;
345  PSHARED_FACE SharedFace = FontGDI->SharedFace;
346 
347  if (FontGDI->Filename)
349 
350  if (FontEntry->StyleName.Buffer)
351  RtlFreeUnicodeString(&FontEntry->StyleName);
352 
353  if (FontEntry->FaceName.Buffer)
354  RtlFreeUnicodeString(&FontEntry->FaceName);
355 
356  EngFreeMem(FontGDI);
357  SharedFace_Release(SharedFace);
358  ExFreePoolWithTag(FontEntry, TAG_FONT);
359 }
#define EngFreeMem
Definition: polytest.cpp:56
UNICODE_STRING FaceName
Definition: font.h:8
static void SharedFace_Release(PSHARED_FACE Ptr)
Definition: freetype.c:318
#define TAG_FONT
Definition: tags.h:12
LPWSTR Filename
Definition: engobjects.h:151
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
PSHARED_FACE SharedFace
Definition: engobjects.h:145
#define GDITAG_PFF
Definition: tags.h:149
UNICODE_STRING StyleName
Definition: font.h:9
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by CleanupFontEntry().

◆ DuplicateUnicodeString()

static NTSTATUS DuplicateUnicodeString ( PUNICODE_STRING  Source,
PUNICODE_STRING  Destination 
)
static

Definition at line 858 of file freetype.c.

859 {
861  UNICODE_STRING Tmp;
862 
863  Tmp.Buffer = ExAllocatePoolWithTag(PagedPool, Source->MaximumLength, TAG_USTR);
864  if (Tmp.Buffer)
865  {
866  Tmp.MaximumLength = Source->MaximumLength;
867  Tmp.Length = 0;
869 
871  Destination->Length = Tmp.Length;
872  Destination->Buffer = Tmp.Buffer;
873 
875  }
876 
877  return Status;
878 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
Status
Definition: gdiplustypes.h:24
#define TAG_USTR
Definition: tag.h:145
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2991
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by IntGdiAddFontResourceEx(), and IntGetFontLocalizedName().

◆ EqualFamilyInfo()

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

Definition at line 5342 of file freetype.c.

5343 {
5344  const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5345  const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5346  const LOGFONTW *plf1 = &pLog1->elfLogFont;
5347  const LOGFONTW *plf2 = &pLog2->elfLogFont;
5348 
5349  if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5350  {
5351  return FALSE;
5352  }
5353 
5354  if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5355  {
5356  return FALSE;
5357  }
5358 
5359  return TRUE;
5360 }
#define TRUE
Definition: types.h:120
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:2704
#define FALSE
Definition: types.h:117
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
LOGFONTW elfLogFont
Definition: wingdi.h:2702
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by IntGdiGetFontResourceInfo().

◆ face_has_symbol_charmap()

static BOOL face_has_symbol_charmap ( FT_Face  ft_face)
static

Definition at line 2110 of file freetype.c.

2111 {
2112  int i;
2113 
2114  for(i = 0; i < ft_face->num_charmaps; i++)
2115  {
2116  if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
2117  ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
2118  {
2119  return TRUE;
2120  }
2121  }
2122  return FALSE;
2123 }
FT_CharMap * charmaps
Definition: freetype.h:1085
#define TRUE
Definition: types.h:120
#define TT_PLATFORM_MICROSOFT
Definition: font.c:1174
#define FALSE
Definition: types.h:117
FT_Encoding encoding
Definition: freetype.h:843
FT_Int num_charmaps
Definition: freetype.h:1084
FT_UShort platform_id
Definition: freetype.h:844
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

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

2129 {
2130  FT_Fixed XScale, YScale;
2131  int Ascent, Descent;
2132  FT_Face Face = FontGDI->SharedFace->Face;
2133 
2135 
2136  XScale = Face->size->metrics.x_scale;
2137  YScale = Face->size->metrics.y_scale;
2138 
2139  if (pFNT)
2140  {
2141  TM->tmHeight = pFNT->pixel_height;
2142  TM->tmAscent = pFNT->ascent;
2143  TM->tmDescent = TM->tmHeight - TM->tmAscent;
2144  TM->tmInternalLeading = pFNT->internal_leading;
2145  TM->tmExternalLeading = pFNT->external_leading;
2146  TM->tmAveCharWidth = pFNT->avg_width;
2147  TM->tmMaxCharWidth = pFNT->max_width;
2148  TM->tmOverhang = 0;
2151  TM->tmFirstChar = pFNT->first_char;
2152  TM->tmLastChar = pFNT->last_char;
2153  TM->tmDefaultChar = pFNT->default_char + pFNT->first_char;
2154  TM->tmBreakChar = pFNT->break_char + pFNT->first_char;
2155  TM->tmPitchAndFamily = pFNT->pitch_and_family;
2156  TM->tmWeight = FontGDI->RequestWeight;
2157  TM->tmItalic = FontGDI->RequestItalic;
2158  TM->tmUnderlined = FontGDI->RequestUnderline;
2159  TM->tmStruckOut = FontGDI->RequestStrikeOut;
2160  TM->tmCharSet = FontGDI->CharSet;
2161  return;
2162  }
2163 
2164  ASSERT(pOS2);
2165  if (!pOS2)
2166  return;
2167 
2168  if ((FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent == 0)
2169  {
2170  Ascent = pHori->Ascender;
2171  Descent = -pHori->Descender;
2172  }
2173  else
2174  {
2175  Ascent = (FT_Short)pOS2->usWinAscent;
2176  Descent = (FT_Short)pOS2->usWinDescent;
2177  }
2178 
2179  TM->tmAscent = FontGDI->tmAscent;
2180  TM->tmDescent = FontGDI->tmDescent;
2181  TM->tmHeight = TM->tmAscent + TM->tmDescent;
2182  TM->tmInternalLeading = FontGDI->tmInternalLeading;
2183 
2184  /* MSDN says:
2185  * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
2186  */
2187  TM->tmExternalLeading = max(0, (FT_MulFix(pHori->Line_Gap
2188  - ((Ascent + Descent)
2189  - (pHori->Ascender - pHori->Descender)),
2190  YScale) + 32) >> 6);
2191 
2192  TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
2193  if (TM->tmAveCharWidth == 0)
2194  {
2195  TM->tmAveCharWidth = 1;
2196  }
2197 
2198  /* Correct forumla to get the maxcharwidth from unicode and ansi font */
2199  TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
2200 
2201  if (FontGDI->OriginalWeight != FW_DONTCARE &&
2202  FontGDI->OriginalWeight != FW_NORMAL)
2203  {
2204  TM->tmWeight = FontGDI->OriginalWeight;
2205  }
2206  else
2207  {
2208  TM->tmWeight = FontGDI->RequestWeight;
2209  }
2210 
2211  TM->tmOverhang = 0;
2212  TM->tmDigitizedAspectX = 96;
2213  TM->tmDigitizedAspectY = 96;
2214  if (face_has_symbol_charmap(Face) ||
2215  (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
2216  {
2217  USHORT cpOEM, cpAnsi;
2218 
2219  EngGetCurrentCodePage(&cpOEM, &cpAnsi);
2220  TM->tmFirstChar = 0;
2221  switch(cpAnsi)
2222  {
2223  case 1257: /* Baltic */
2224  TM->tmLastChar = 0xf8fd;
2225  break;
2226  default:
2227  TM->tmLastChar = 0xf0ff;
2228  }
2229  TM->tmBreakChar = 0x20;
2230  TM->tmDefaultChar = 0x1f;
2231  }
2232  else
2233  {
2234  TM->tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
2235  TM->tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
2236 
2237  if(pOS2->usFirstCharIndex <= 1)
2238  TM->tmBreakChar = pOS2->usFirstCharIndex + 2;
2239  else if (pOS2->usFirstCharIndex > 0xff)
2240  TM->tmBreakChar = 0x20;
2241  else
2242  TM->tmBreakChar = pOS2->usFirstCharIndex;
2243  TM->tmDefaultChar = TM->tmBreakChar - 1;
2244  }
2245 
2246  if (FontGDI->OriginalItalic || FontGDI->RequestItalic)
2247  {
2248  TM->tmItalic = 0xFF;
2249  }
2250  else
2251  {
2252  TM->tmItalic = 0;
2253  }
2254  TM->tmUnderlined = (FontGDI->RequestUnderline ? 0xFF : 0);
2255  TM->tmStruckOut = (FontGDI->RequestStrikeOut ? 0xFF : 0);
2256 
2257  if (!FT_IS_FIXED_WIDTH(Face))
2258  {
2259  switch (pOS2->panose[PAN_PROPORTION_INDEX])
2260  {
2261  case PAN_PROP_MONOSPACED:
2262  TM->tmPitchAndFamily = 0;
2263  break;
2264  default:
2266  break;
2267  }
2268  }
2269  else
2270  {
2271  TM->tmPitchAndFamily = 0;
2272  }
2273 
2274  switch (pOS2->panose[PAN_FAMILYTYPE_INDEX])
2275  {
2276  case PAN_FAMILY_SCRIPT:
2277  TM->tmPitchAndFamily |= FF_SCRIPT;
2278  break;
2279  case PAN_FAMILY_DECORATIVE:
2281  break;
2282 
2283  case PAN_ANY:
2284  case PAN_NO_FIT:
2286  case PAN_FAMILY_PICTORIAL: /* Symbol fonts get treated as if they were text */
2287  /* Which is clearly not what the panose spec says. */
2288  if (TM->tmPitchAndFamily == 0) /* Fixed */
2289  {
2291  }
2292  else
2293  {
2294  switch (pOS2->panose[PAN_SERIFSTYLE_INDEX])
2295  {
2296  case PAN_ANY:
2297  case PAN_NO_FIT:
2298  default:
2300  break;
2301 
2302  case PAN_SERIF_COVE:
2303  case PAN_SERIF_OBTUSE_COVE:
2304  case PAN_SERIF_SQUARE_COVE:
2306  case PAN_SERIF_SQUARE:
2307  case PAN_SERIF_THIN:
2308  case PAN_SERIF_BONE:
2309  case PAN_SERIF_EXAGGERATED:
2310  case PAN_SERIF_TRIANGLE:
2311  TM->tmPitchAndFamily |= FF_ROMAN;
2312  break;
2313 
2314  case PAN_SERIF_NORMAL_SANS:
2315  case PAN_SERIF_OBTUSE_SANS:
2316  case PAN_SERIF_PERP_SANS:
2317  case PAN_SERIF_FLARED:
2318  case PAN_SERIF_ROUNDED:
2319  TM->tmPitchAndFamily |= FF_SWISS;
2320  break;
2321  }
2322  }
2323  break;
2324  default:
2326  }
2327 
2328  if (FT_IS_SCALABLE(Face))
2329  {
2331  }
2332  if (FT_IS_SFNT(Face))
2333  {
2335  }
2336 
2337  TM->tmCharSet = FontGDI->CharSet;
2338 }
#define PAN_SERIF_NORMAL_SANS
Definition: wingdi.h:480
LONG tmMaxCharWidth
Definition: wingdi.h:2389
LONG tmAscent
Definition: engobjects.h:162
#define max(a, b)
Definition: svc.c:63
BYTE tmUnderlined
Definition: wingdi.h:2399
#define PAN_FAMILY_DECORATIVE
Definition: wingdi.h:469
#define FF_DONTCARE
Definition: wingdi.h:448
LONG tmExternalLeading
Definition: wingdi.h:2387
FT_Size size
Definition: freetype.h:1106
#define PAN_SERIF_OBTUSE_COVE
Definition: wingdi.h:472
FT_Fixed y_scale
Definition: freetype.h:1644
#define FF_DECORATIVE
Definition: wingdi.h:447
FT_UShort external_leading
Definition: ftwinfnt.h:195
FT_UShort horizontal_resolution
Definition: ftwinfnt.h:192
FT_UShort usFirstCharIndex
Definition: tttables.h:409
LONG tmAveCharWidth
Definition: wingdi.h:2388
LONG tmDescent
Definition: wingdi.h:2385
LONG tmAscent
Definition: wingdi.h:2384
LONG tmInternalLeading
Definition: wingdi.h:2386
#define PAN_SERIF_BONE
Definition: wingdi.h:477
#define PAN_SERIF_ROUNDED
Definition: wingdi.h:484
FT_Short Ascender
Definition: tttables.h:202
BYTE RequestStrikeOut
Definition: engobjects.h:153
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2110
#define PAN_ANY
Definition: wingdi.h:465
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
LONG tmDescent
Definition: engobjects.h:163
#define PAN_SERIF_FLARED
Definition: wingdi.h:483
#define TMPF_TRUETYPE
Definition: wingdi.h:1313
FT_UShort vertical_resolution
Definition: ftwinfnt.h:191
FT_Short xAvgCharWidth
Definition: tttables.h:383
#define PAN_SERIF_SQUARE
Definition: wingdi.h:475
FT_UShort internal_leading
Definition: ftwinfnt.h:194
FT_UShort ascent
Definition: ftwinfnt.h:193
FT_UShort usWinDescent
Definition: tttables.h:415
BYTE OriginalItalic
Definition: engobjects.h:156
BYTE tmPitchAndFamily
Definition: wingdi.h:2401
#define _TMPF_VARIABLE_PITCH
Definition: freetype.c:41
#define PAN_SERIF_OBTUSE_SANS
Definition: wingdi.h:481
#define PAN_SERIFSTYLE_INDEX
Definition: wingdi.h:455
WCHAR tmBreakChar
Definition: wingdi.h:2397
#define PAN_SERIF_TRIANGLE
Definition: wingdi.h:479
FT_UShort pixel_height
Definition: ftwinfnt.h:202
#define PAN_SERIF_COVE
Definition: wingdi.h:471
FT_UShort usLastCharIndex
Definition: tttables.h:410
#define PAN_SERIF_EXAGGERATED
Definition: wingdi.h:478
#define FT_IS_FIXED_WIDTH(face)
Definition: freetype.h:1346
BYTE tmStruckOut
Definition: wingdi.h:2400
FT_UShort max_width
Definition: ftwinfnt.h:205
#define PAN_SERIF_PERP_SANS
Definition: wingdi.h:482
#define PAN_FAMILYTYPE_INDEX
Definition: wingdi.h:454
#define PAN_SERIF_OBTUSE_SQUARE_COVE
Definition: wingdi.h:474
#define PAN_NO_FIT
Definition: wingdi.h:466
#define ASSERT(a)
Definition: mode.c:44
FT_UShort avg_width
Definition: ftwinfnt.h:204
LONG OriginalWeight
Definition: engobjects.h:157
#define PAN_FAMILY_SCRIPT
Definition: wingdi.h:468
LONG tmInternalLeading
Definition: engobjects.h:164
FT_Short Line_Gap
Definition: tttables.h:204
#define PAN_FAMILY_PICTORIAL
Definition: wingdi.h:470
LONG tmOverhang
Definition: wingdi.h:2391
#define FT_IS_SFNT(face)
Definition: freetype.h:1331
FT_Short Descender
Definition: tttables.h:203
FT_Face Face
Definition: engobjects.h:132
#define PAN_PROP_MONOSPACED
Definition: wingdi.h:502
BYTE tmCharSet
Definition: wingdi.h:2402
#define PAN_PROPORTION_INDEX
Definition: wingdi.h:457
FT_Size_Metrics metrics
Definition: freetype.h:1677
signed short FT_Short
Definition: fttypes.h:198
LONG tmDigitizedAspectY
Definition: wingdi.h:2393
#define FF_ROMAN
Definition: wingdi.h:450
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
#define TMPF_VECTOR
Definition: wingdi.h:1312
BYTE RequestUnderline
Definition: engobjects.h:152
FT_Short max_advance_width
Definition: freetype.h:1099
ENGAPI VOID APIENTRY EngGetCurrentCodePage(_Out_ PUSHORT OemCodePage, _Out_ PUSHORT AnsiCodePage)
Definition: engmisc.c:232
#define FW_DONTCARE
Definition: wingdi.h:368
#define FF_SWISS
Definition: wingdi.h:452
signed long FT_Fixed
Definition: fttypes.h:288
FT_Byte pitch_and_family
Definition: ftwinfnt.h:203
PSHARED_FACE SharedFace
Definition: engobjects.h:145
FT_Fixed x_scale
Definition: freetype.h:1643
unsigned short USHORT
Definition: pedump.c:61
FT_Byte default_char
Definition: ftwinfnt.h:208
LONG RequestWeight
Definition: engobjects.h:155
#define FF_MODERN
Definition: wingdi.h:449
FT_UShort usWinAscent
Definition: tttables.h:414
WCHAR tmDefaultChar
Definition: wingdi.h:2396
#define FF_SCRIPT
Definition: wingdi.h:451
#define FW_NORMAL
Definition: wingdi.h:373
BYTE RequestItalic
Definition: engobjects.h:154
LONG tmWeight
Definition: wingdi.h:2390
#define PAN_SERIF_SQUARE_COVE
Definition: wingdi.h:473
LONG tmHeight
Definition: wingdi.h:2383
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312
#define PAN_SERIF_THIN
Definition: wingdi.h:476
BYTE CharSet
Definition: engobjects.h:158
BYTE tmItalic
Definition: wingdi.h:2398
WCHAR tmFirstChar
Definition: wingdi.h:2394
#define PAN_FAMILY_TEXT_DISPLAY
Definition: wingdi.h:467
FT_Byte panose[10]
Definition: tttables.h:399
WCHAR tmLastChar
Definition: wingdi.h:2395
LONG tmDigitizedAspectX
Definition: wingdi.h:2392

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

5039 {
5040  ULONG Penalty;
5042  PFONT_ENTRY CurrentEntry;
5043  FONTGDI *FontGDI;
5044  OUTLINETEXTMETRICW *Otm = NULL;
5045  UINT OtmSize, OldOtmSize = 0;
5046  FT_Face Face;
5047 
5048  ASSERT(FontObj);
5049  ASSERT(MatchPenalty);
5050  ASSERT(LogFont);
5051  ASSERT(Head);
5052 
5053  /* Start with a pretty big buffer */
5054  OldOtmSize = 0x200;
5055  Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5056 
5057  /* get the FontObj of lowest penalty */
5058  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5059  {
5060  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5061 
5062  FontGDI = CurrentEntry->Font;
5063  ASSERT(FontGDI);
5064  Face = FontGDI->SharedFace->Face;
5065 
5066  /* get text metrics */
5067  OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
5068  if (OtmSize > OldOtmSize)
5069  {
5070  if (Otm)
5072  Otm = ExAllocatePoolWithTag(PagedPool, OtmSize, GDITAG_TEXT);
5073  }
5074 
5075  /* update FontObj if lowest penalty */
5076  if (Otm)
5077  {
5078  IntLockFreeType();
5079  IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5081 
5082  OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm);
5083  if (!OtmSize)
5084  continue;
5085 
5086  OldOtmSize = OtmSize;
5087 
5088  Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5089  if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty)
5090  {
5091  *FontObj = GDIToObj(FontGDI, FONT);
5092  *MatchPenalty = Penalty;
5093  }
5094  }
5095  }
5096 
5097  if (Otm)
5099 }
struct _Entry Entry
Definition: kefuncs.h:629
LONG lfHeight
Definition: dimm.idl:59
static UINT GetFontPenalty(const LOGFONTW *LogFont, const OUTLINETEXTMETRICW *Otm, const char *style_name)
Definition: freetype.c:4690
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2427
LONG lfWidth
Definition: dimm.idl:60
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Definition: font.h:4
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:44
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3472
#define IntUnLockFreeType()
Definition: freetype.c:82
FT_Face Face
Definition: engobjects.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IntLockFreeType()
Definition: freetype.c:79
Definition: typedefs.h:119
#define GDITAG_TEXT
Definition: tags.h:172
PSHARED_FACE SharedFace
Definition: engobjects.h:145
FONTGDI * Font
Definition: font.h:7
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
FT_String * style_name
Definition: freetype.h:1079
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
base of all file and directory entries
Definition: entries.h:82
#define GDIToObj(ClipGDI, Type)
Definition: engobjects.h:184

Referenced by TextIntRealizeFont().

◆ FontFamilyFillInfo()

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

Definition at line 2792 of file freetype.c.

2794 {
2795  ANSI_STRING StyleA;
2796  UNICODE_STRING StyleW;
2797  TT_OS2 *pOS2;
2798  FONTSIGNATURE fs;
2799  CHARSETINFO CharSetInfo;
2800  unsigned i, Size;
2801  OUTLINETEXTMETRICW *Otm;
2802  LOGFONTW *Lf;
2803  TEXTMETRICW *TM;
2804  NEWTEXTMETRICW *Ntm;
2805  DWORD fs0;
2806  NTSTATUS status;
2807  PSHARED_FACE SharedFace = FontGDI->SharedFace;
2808  FT_Face Face = SharedFace->Face;
2809  UNICODE_STRING NameW;
2810 
2811  RtlInitUnicodeString(&NameW, NULL);
2812  RtlZeroMemory(Info, sizeof(FONTFAMILYINFO));
2813  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
2815  if (!Otm)
2816  {
2817  return;
2818  }
2819  Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm);
2820  if (!Size)
2821  {
2823  return;
2824  }
2825 
2826  Lf = &Info->EnumLogFontEx.elfLogFont;
2827  TM = &Otm->otmTextMetrics;
2828 
2829  Lf->lfHeight = TM->tmHeight;
2830  Lf->lfWidth = TM->tmAveCharWidth;
2831  Lf->lfWeight = TM->tmWeight;
2832  Lf->lfItalic = TM->tmItalic;
2833  Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
2834  Lf->lfCharSet = TM->tmCharSet;
2837  Lf->lfQuality = PROOF_QUALITY;
2838 
2839  Ntm = &Info->NewTextMetricEx.ntmTm;
2840  Ntm->tmHeight = TM->tmHeight;
2841  Ntm->tmAscent = TM->tmAscent;
2842  Ntm->tmDescent = TM->tmDescent;
2845  Ntm->tmAveCharWidth = TM->tmAveCharWidth;
2846  Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
2847  Ntm->tmWeight = TM->tmWeight;
2848  Ntm->tmOverhang = TM->tmOverhang;
2851  Ntm->tmFirstChar = TM->tmFirstChar;
2852  Ntm->tmLastChar = TM->tmLastChar;
2853  Ntm->tmDefaultChar = TM->tmDefaultChar;
2854  Ntm->tmBreakChar = TM->tmBreakChar;
2855  Ntm->tmItalic = TM->tmItalic;
2856  Ntm->tmUnderlined = TM->tmUnderlined;
2857  Ntm->tmStruckOut = TM->tmStruckOut;
2859  Ntm->tmCharSet = TM->tmCharSet;
2860  Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
2861 
2862  if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
2863 
2864  if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
2865 
2866  Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
2867  ? TRUETYPE_FONTTYPE : 0);
2868 
2869  if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
2870  Info->FontType |= RASTER_FONTTYPE;
2871 
2872 
2873  /* face name */
2874  if (!FaceName)
2875  FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
2876 
2877  RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
2878 
2879  /* full name */
2880  if (!FullName)
2881  FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
2882 
2883  RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
2884  sizeof(Info->EnumLogFontEx.elfFullName),
2885  FullName);
2886 
2887  RtlInitAnsiString(&StyleA, Face->style_name);
2888  StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
2889  StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
2890  status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
2891  if (!NT_SUCCESS(status))
2892  {
2894  return;
2895  }
2896  Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
2897 
2898  IntLockFreeType();
2899  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
2900 
2901  if (!pOS2)
2902  {
2905  return;
2906  }
2907 
2908  Ntm->ntmSizeEM = Otm->otmEMSquare;
2909  Ntm->ntmCellHeight = (FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent;
2910  Ntm->ntmAvgWidth = 0;
2911 
2913 
2914  fs.fsCsb[0] = pOS2->ulCodePageRange1;
2915  fs.fsCsb[1] = pOS2->ulCodePageRange2;
2916  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
2917  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
2918  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
2919  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
2920 
2921  if (0 == pOS2->version)
2922  {
2923  FT_UInt Dummy;
2924 
2925  if (FT_Get_First_Char(Face, &Dummy) < 0x100)
2926  fs.fsCsb[0] |= FS_LATIN1;
2927  else
2928  fs.fsCsb[0] |= FS_SYMBOL;
2929  }
2931 
2932  if (fs.fsCsb[0] == 0)
2933  {
2934  /* Let's see if we can find any interesting cmaps */
2935  for (i = 0; i < (UINT)Face->num_charmaps; i++)
2936  {
2937  switch (Face->charmaps[i]->encoding)
2938  {
2939  case FT_ENCODING_UNICODE:
2940  case FT_ENCODING_APPLE_ROMAN:
2941  fs.fsCsb[0] |= FS_LATIN1;
2942  break;
2943  case FT_ENCODING_MS_SYMBOL:
2944  fs.fsCsb[0] |= FS_SYMBOL;
2945  break;
2946  default:
2947  break;
2948  }
2949  }
2950  }
2951 
2952  for (i = 0; i < MAXTCIINDEX; i++)
2953  {
2954  fs0 = 1L << i;
2955  if (fs.fsCsb[0] & fs0)
2956  {
2957  if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
2958  {
2959  CharSetInfo.ciCharset = DEFAULT_CHARSET;
2960  }
2961  if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
2962  {
2963  if (g_ElfScripts[i])
2964  wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
2965  else
2966  {
2967  DPRINT1("Unknown elfscript for bit %u\n", i);
2968  }
2969  }
2970  }
2971  }
2972  Info->NewTextMetricEx.ntmFontSig = fs;
2973 }
WCHAR tmFirstChar
Definition: wingdi.h:2655
LONG tmMaxCharWidth
Definition: wingdi.h:2389
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
BYTE tmUnderlined
Definition: wingdi.h:2399
FT_CharMap * charmaps
Definition: freetype.h:1085
BYTE lfPitchAndFamily
Definition: dimm.idl:71
LONG tmExternalLeading
Definition: wingdi.h:2387
#define ft_sfnt_os2
Definition: tttables.h:631
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TCI_SRCFONTSIG
Definition: wingdi.h:963
LONG tmAveCharWidth
Definition: wingdi.h:2388
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
BYTE lfCharSet
Definition: dimm.idl:67
LONG tmDigitizedAspectX
Definition: wingdi.h:2653
BYTE lfClipPrecision
Definition: dimm.idl:69
WCHAR tmDefaultChar
Definition: wingdi.h:2657
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define NTM_BOLD
Definition: wingdi.h:1316
LONG tmDescent
Definition: wingdi.h:2385
LONG tmAscent
Definition: wingdi.h:2384
LONG tmInternalLeading
Definition: wingdi.h:2386
if(dx==0 &&dy==0)
Definition: linetemp.h:174
Definition: ffs.h:70
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define PROOF_QUALITY
Definition: wingdi.h:438
LONG tmDigitizedAspectY
Definition: wingdi.h:2654
#define MAXTCIINDEX
Definition: freetype.c:123
static PWCHAR g_ElfScripts[32]
Definition: freetype.c:96
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
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:683
#define L(x)
Definition: ntvdm.h:50
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define TMPF_TRUETYPE
Definition: wingdi.h:1313
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
FT_UShort usWinDescent
Definition: tttables.h:415
UINT ciCharset
Definition: wingdi.h:1546
BYTE tmPitchAndFamily
Definition: wingdi.h:2401
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2427
LONG lfWidth
Definition: dimm.idl:60
WCHAR tmBreakChar
Definition: wingdi.h:2397
FT_UShort version
Definition: tttables.h:382
BYTE tmStruckOut
Definition: wingdi.h:2400
BYTE lfOutPrecision
Definition: dimm.idl:68
LONG tmMaxCharWidth
Definition: wingdi.h:2650
#define OUT_OUTLINE_PRECIS
Definition: wingdi.h:423
#define fs
Definition: i386-dis.c:445
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FS_SYMBOL
Definition: wingdi.h:575
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1648
WCHAR tmLastChar
Definition: wingdi.h:2656
BYTE tmPitchAndFamily
Definition: wingdi.h:2662
LONG tmOverhang
Definition: wingdi.h:2391
FT_Face Face
Definition: engobjects.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RASTER_FONTTYPE
Definition: wingdi.h:1107
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
FT_Encoding encoding
Definition: freetype.h:843
BYTE tmCharSet
Definition: wingdi.h:2402
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BYTE lfQuality
Definition: dimm.idl:70
#define NTM_REGULAR
Definition: wingdi.h:1317
#define IntLockFreeType()
Definition: freetype.c:79
signed short FT_Short
Definition: fttypes.h:198
LONG tmInternalLeading
Definition: wingdi.h:2647
LONG tmDigitizedAspectY
Definition: wingdi.h:2393
LONG tmExternalLeading
Definition: wingdi.h:2648
FT_Int num_charmaps
Definition: freetype.h:1084
#define TMPF_VECTOR
Definition: wingdi.h:1312
static BOOLEAN IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2063
FT_ULong ulCodePageRange1
Definition: tttables.h:419
#define GDITAG_TEXT
Definition: tags.h:172
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
UINT ntmCellHeight
Definition: wingdi.h:2666
PSHARED_FACE SharedFace
Definition: engobjects.h:145
WCHAR tmBreakChar
Definition: wingdi.h:2658
unsigned int FT_UInt
Definition: fttypes.h:231
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
FT_ULong ulUnicodeRange4
Definition: tttables.h:404
BYTE lfItalic
Definition: dimm.idl:64
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2514
FT_UShort usWinAscent
Definition: tttables.h:414
WCHAR tmDefaultChar
Definition: wingdi.h:2396
FT_String * style_name
Definition: freetype.h:1079
FT_ULong ulCodePageRange2
Definition: tttables.h:420
#define DPRINT1
Definition: precomp.h:8
FT_ULong ulUnicodeRange3
Definition: tttables.h:403
#define FS_LATIN1
Definition: wingdi.h:560
LONG tmAveCharWidth
Definition: wingdi.h:2649
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG tmWeight
Definition: wingdi.h:2390
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
LONG tmHeight
Definition: wingdi.h:2383
LONG lfWeight
Definition: dimm.idl:63
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define NTM_ITALIC
Definition: wingdi.h:1315
static SERVICE_STATUS status
Definition: service.c:31
BYTE tmItalic
Definition: wingdi.h:2398
WCHAR tmFirstChar
Definition: wingdi.h:2394
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1109
FT_ULong ulUnicodeRange2
Definition: tttables.h:402
WCHAR tmLastChar
Definition: wingdi.h:2395
LONG tmDigitizedAspectX
Definition: wingdi.h:2392
Definition: ps.c:97

Referenced by GetFontFamilyInfoForList(), and IntGdiGetFontResourceInfo().

◆ FT_FixedFromFIXED()

static __inline FT_Fixed FT_FixedFromFIXED ( FIXED  f)
static

Definition at line 382 of file freetype.c.

383 {
384  return (FT_Fixed)((long)f.value << 16 | (unsigned long)f.fract);
385 }
GLfloat f
Definition: glext.h:7540
signed long FT_Fixed
Definition: fttypes.h:288
#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 4648 of file freetype.c.

4654 {
4656  FT_Face Face = FontGdi->SharedFace->Face;
4657 
4658  IntLockFreeType();
4659 
4660  if (FT_IS_SFNT(Face))
4661  {
4662  if (Table)
4663  Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
4664  (Table << 8 & 0xFF0000);
4665 
4666  if (!Buffer) Size = 0;
4667 
4668  if (Buffer && Size)
4669  {
4670  FT_Error Error;
4671  FT_ULong Needed = 0;
4672 
4673  Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
4674 
4675  if ( !Error && Needed < Size) Size = Needed;
4676  }
4677  if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
4678  Result = Size;
4679  }
4680 
4682 
4683  return Result;
4684 }
int FT_Error
Definition: fttypes.h:300
ASMGENDATA Table[]
Definition: genincdata.c:61
unsigned long FT_ULong
Definition: fttypes.h:253
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_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:426
Definition: bufpool.h:45
FT_Load_Sfnt_Table(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte *buffer, FT_ULong *length)
Definition: ftobjs.c:4134
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
#define FT_IS_SFNT(face)
Definition: freetype.h:1331
FT_Face Face
Definition: engobjects.h:132
#define IntLockFreeType()
Definition: freetype.c:79
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PSHARED_FACE SharedFace
Definition: engobjects.h:145
#define NULL
Definition: types.h:112
#define GDI_ERROR
Definition: wingdi.h:1309

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

3738 {
3739  PDC_ATTR pdcattr;
3740  PTEXTOBJ TextObj;
3741  PFONTGDI FontGDI;
3742  HFONT hFont = 0;
3743  GLYPHMETRICS gm;
3744  ULONG Size;
3745  FT_Face ft_face;
3746  FT_UInt glyph_index;
3747  DWORD width, height, pitch, needed = 0;
3748  FT_Bitmap ft_bitmap;
3749  FT_Error error;
3750  INT left, right, top = 0, bottom = 0;
3752  FLOATOBJ eM11, widthRatio, eTemp;
3753  FT_Matrix mat, transMat = identityMat;
3754  BOOL needsTransform = FALSE;
3755  INT orientation;
3756  LONG aveWidth;
3757  INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
3758  OUTLINETEXTMETRICW *potm;
3759  XFORMOBJ xo;
3760  XFORML xform;
3761  LOGFONTW *plf;
3762 
3763  DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
3764  cjBuf, pvBuf, pmat2);
3765 
3766  pdcattr = dc->pdcattr;
3767 
3768  XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
3769  XFORMOBJ_iGetXform(&xo, &xform);
3770  FLOATOBJ_SetFloat(&eM11, xform.eM11);
3771 
3772  hFont = pdcattr->hlfntNew;
3773  TextObj = RealizeFontInit(hFont);
3774 
3775  if (!TextObj)
3776  {
3778  return GDI_ERROR;
3779  }
3780  FontGDI = ObjToGDI(TextObj->Font, FONT);
3781  ft_face = FontGDI->SharedFace->Face;
3782 
3783  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
3784  aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
3785  orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
3786 
3787  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
3789  if (!potm)
3790  {
3792  TEXTOBJ_UnlockText(TextObj);
3793  return GDI_ERROR;
3794  }
3795  Size = IntGetOutlineTextMetrics(FontGDI, Size, potm);
3796  if (!Size)
3797  {
3798  /* FIXME: last error? */
3800  TEXTOBJ_UnlockText(TextObj);
3801  return GDI_ERROR;
3802  }
3803 
3804  IntLockFreeType();
3805  TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
3807  FT_Set_Transform(ft_face, &mat, 0);
3808 
3809  TEXTOBJ_UnlockText(TextObj);
3810 
3811  glyph_index = get_glyph_index_flagged(ft_face, wch, GGO_GLYPH_INDEX, iFormat);
3813 
3814  if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
3815  load_flags |= FT_LOAD_NO_BITMAP;
3816 
3817  if (iFormat & GGO_UNHINTED)
3818  {
3819  load_flags |= FT_LOAD_NO_HINTING;
3820  iFormat &= ~GGO_UNHINTED;
3821  }
3822 
3823  error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
3824  if (error)
3825  {
3826  DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
3828  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
3829  return GDI_ERROR;
3830  }
3832 
3833  FLOATOBJ_Set1(&widthRatio);
3834  if (aveWidth && potm)
3835  {
3836  // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
3837  FLOATOBJ_SetLong(&widthRatio, aveWidth);
3838  FLOATOBJ_Mul(&widthRatio, &eM11);
3839  FLOATOBJ_DivLong(&widthRatio, potm->otmTextMetrics.tmAveCharWidth);
3840  }
3841 
3842  //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
3843  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
3844  FLOATOBJ_Mul(&eTemp, &widthRatio);
3845  left = FLOATOBJ_GetLong(&eTemp) & -64;
3846 
3847  //right = (INT)((ft_face->glyph->metrics.horiBearingX +
3848  // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
3849  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
3850  FLOATOBJ_Mul(&eTemp, &widthRatio);
3851  FLOATOBJ_AddLong(&eTemp, 63);
3852  right = FLOATOBJ_GetLong(&eTemp) & -64;
3853 
3854  //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
3855  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
3856  FLOATOBJ_Mul(&eTemp, &widthRatio);
3857  FLOATOBJ_AddLong(&eTemp, 63);
3858  adv = FLOATOBJ_GetLong(&eTemp) >> 6;
3859 
3860  lsb = left >> 6;
3861  bbx = (right - left) >> 6;
3862 
3863  DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
3864 
3865  IntLockFreeType();
3866 
3867  /* Width scaling transform */
3868  if (!FLOATOBJ_Equal1(&widthRatio))
3869  {
3870  FT_Matrix scaleMat;
3871 
3872  eTemp = widthRatio;
3873  FLOATOBJ_MulLong(&eTemp, 1 << 16);
3874 
3875  scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
3876  scaleMat.xy = 0;
3877  scaleMat.yx = 0;
3878  scaleMat.yy = INT_TO_FIXED(1);
3879  FT_Matrix_Multiply(&scaleMat, &transMat);
3880  needsTransform = TRUE;
3881  }
3882 
3883  /* World transform */
3884  {
3885  FT_Matrix ftmatrix;
3887 
3888  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
3889  FtMatrixFromMx(&ftmatrix, pmx);
3890 
3891  if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
3892  {
3893  FT_Matrix_Multiply(&ftmatrix, &transMat);
3894  needsTransform = TRUE;
3895  }
3896  }
3897 
3898  /* Rotation transform */
3899  if (orientation)
3900  {
3901  FT_Matrix rotationMat;
3902  DPRINT("Rotation Trans!\n");
3903  IntEscapeMatrix(&rotationMat, orientation);
3904  FT_Matrix_Multiply(&rotationMat, &transMat);
3905  needsTransform = TRUE;
3906  }
3907 
3908  /* Extra transformation specified by caller */
3909  if (pmat2)
3910  {
3911  FT_Matrix extraMat;
3912  DPRINT("MAT2 Matrix Trans!\n");
3913  extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
3914  extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
3915  extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
3916  extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
3917  FT_Matrix_Multiply(&extraMat, &transMat);
3918  needsTransform = TRUE;
3919  }
3920 
3921  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
3922 
3923  if (!needsTransform)
3924  {
3925  DPRINT("No Need to be Transformed!\n");
3926  top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
3927  bottom = (ft_face->glyph->metrics.horiBearingY -
3928  ft_face->glyph->metrics.height) & -64;
3929  gm.gmCellIncX = adv;
3930  gm.gmCellIncY = 0;
3931  }
3932  else
3933  {
3934  INT xc, yc;
3935  FT_Vector vec;
3936  for (xc = 0; xc < 2; xc++)
3937  {
3938  for (yc = 0; yc < 2; yc++)
3939  {
3940  vec.x = (ft_face->glyph->metrics.horiBearingX +
3941  xc * ft_face->glyph->metrics.width);
3942  vec.y = ft_face->glyph->metrics.horiBearingY -
3943  yc * ft_face->glyph->metrics.height;
3944  DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
3945  FT_Vector_Transform(&vec, &transMat);
3946  if (xc == 0 && yc == 0)
3947  {
3948  left = right = vec.x;
3949  top = bottom = vec.y;
3950  }
3951  else
3952  {
3953  if (vec.x < left) left = vec.x;
3954  else if (vec.x > right) right = vec.x;
3955  if (vec.y < bottom) bottom = vec.y;
3956  else if (vec.y > top) top = vec.y;
3957  }
3958  }
3959  }
3960  left = left & -64;
3961  right = (right + 63) & -64;
3962  bottom = bottom & -64;
3963  top = (top + 63) & -64;
3964 
3965  DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
3966  vec.x = ft_face->glyph->metrics.horiAdvance;
3967  vec.y = 0;
3968  FT_Vector_Transform(&vec, &transMat);
3969  gm.gmCellIncX = (vec.x+63) >> 6;
3970  gm.gmCellIncY = -((vec.y+63) >> 6);
3971  }
3972  gm.gmBlackBoxX = (right - left) >> 6;
3973  gm.gmBlackBoxY = (top - bottom) >> 6;
3974  gm.gmptGlyphOrigin.x = left >> 6;
3975  gm.gmptGlyphOrigin.y = top >> 6;
3976 
3977  DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
3978  gm.gmCellIncX, gm.gmCellIncY,
3979  gm.gmBlackBoxX, gm.gmBlackBoxY,
3981 
3983 
3984 
3985  if (iFormat == GGO_METRICS)
3986  {
3987  DPRINT("GGO_METRICS Exit!\n");
3988  *pgm = gm;
3989  return 1; /* FIXME */
3990  }
3991 
3992  if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
3993  {
3994  DPRINT1("Loaded a bitmap\n");
3995  return GDI_ERROR;
3996  }
3997 
3998  switch (iFormat)
3999  {
4000  case GGO_BITMAP:
4001  {
4002  width = gm.gmBlackBoxX;
4003  height = gm.gmBlackBoxY;
4004  pitch = ((width + 31) >> 5) << 2;
4005  needed = pitch * height;
4006 
4007  if (!pvBuf || !cjBuf) break;
4008  if (!needed) return GDI_ERROR; /* empty glyph */
4009  if (needed > cjBuf)
4010  return GDI_ERROR;
4011 
4012  switch (ft_face->glyph->format)
4013  {
4015  {
4016  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4017  INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4018  INT h = min( height, ft_face->glyph->bitmap.rows );
4019  while (h--)
4020  {
4021  RtlCopyMemory(dst, src, w);
4022  src += ft_face->glyph->bitmap.pitch;
4023  dst += pitch;
4024  }
4025  break;
4026  }
4027 
4029  {
4030  ft_bitmap.width = width;
4031  ft_bitmap.rows = height;
4032  ft_bitmap.pitch = pitch;
4033  ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4034  ft_bitmap.buffer = pvBuf;
4035 
4036  IntLockFreeType();
4037  if (needsTransform)
4038  {
4039  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4040  }
4041  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4042  /* Note: FreeType will only set 'black' bits for us. */
4043  RtlZeroMemory(pvBuf, needed);
4044  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4046  break;
4047  }
4048 
4049  default:
4050  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4051  return GDI_ERROR;
4052  }
4053 
4054  break;
4055  }
4056 
4057  case GGO_GRAY2_BITMAP:
4058  case GGO_GRAY4_BITMAP:
4059  case GGO_GRAY8_BITMAP:
4060  {
4061  unsigned int mult, row, col;
4062  BYTE *start, *ptr;
4063 
4064  width = gm.gmBlackBoxX;
4065  height = gm.gmBlackBoxY;
4066  pitch = (width + 3) / 4 * 4;
4067  needed = pitch * height;
4068 
4069  if (!pvBuf || !cjBuf) break;
4070  if (!needed) return GDI_ERROR; /* empty glyph */
4071  if (needed > cjBuf)
4072  return GDI_ERROR;
4073 
4074  switch (ft_face->glyph->format)
4075  {
4077  {
4078  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4079  INT h = min( height, ft_face->glyph->bitmap.rows );
4080  INT x;
4081  while (h--)
4082  {
4083  for (x = 0; (UINT)x < pitch; x++)
4084  {
4085  if (x < ft_face->glyph->bitmap.width)
4086  dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4087  else
4088  dst[x] = 0;
4089  }
4090  src += ft_face->glyph->bitmap.pitch;
4091  dst += pitch;
4092  }
4093  break;
4094  }
4096  {
4097  ft_bitmap.width = width;
4098  ft_bitmap.rows = height;
4099  ft_bitmap.pitch = pitch;
4100  ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4101  ft_bitmap.buffer = pvBuf;
4102 
4103  IntLockFreeType();
4104  if (needsTransform)
4105  {
4106  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4107  }
4108  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4109  RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4110  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4112 
4113  if (iFormat == GGO_GRAY2_BITMAP)
4114  mult = 4;
4115  else if (iFormat == GGO_GRAY4_BITMAP)
4116  mult = 16;
4117  else if (iFormat == GGO_GRAY8_BITMAP)
4118  mult = 64;
4119  else
4120  {
4121  return GDI_ERROR;
4122  }
4123 
4124  start = pvBuf;
4125  for (row = 0; row < height; row++)
4126  {
4127  ptr = start;
4128  for (col = 0; col < width; col++, ptr++)
4129  {
4130  *ptr = (((int)*ptr) * mult + 128) / 256;
4131  }
4132  start += pitch;
4133  }
4134 
4135  break;
4136  }
4137  default:
4138  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4139  return GDI_ERROR;
4140  }
4141 
4142  break;
4143  }
4144 
4145  case GGO_NATIVE:
4146  {
4147  FT_Outline *outline = &ft_face->glyph->outline;
4148 
4149  if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4150 
4151  IntLockFreeType();
4152  if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4153 
4155 
4156  if (!pvBuf || !cjBuf)
4157  {
4159  break;
4160  }
4161  if (needed > cjBuf)
4162  {
4164  return GDI_ERROR;
4165  }
4168  break;
4169  }
4170 
4171  case GGO_BEZIER:
4172  {
4173  FT_Outline *outline = &ft_face->glyph->outline;
4174  if (cjBuf == 0) pvBuf = NULL;
4175 
4176  if (needsTransform && pvBuf)
4177  {
4178  IntLockFreeType();
4179  FT_Outline_Transform(outline, &transMat);
4181  }
4183 
4184  if (!pvBuf || !cjBuf)
4185  break;
4186  if (needed > cjBuf)
4187  return GDI_ERROR;
4188 
4190  break;
4191  }
4192 
4193  default:
4194  DPRINT1("Unsupported format %u\n", iFormat);
4195  return GDI_ERROR;
4196  }
4197 
4198  DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4199 
4200  if (gm.gmBlackBoxX == 0)
4201  gm.gmBlackBoxX = 1;
4202  if (gm.gmBlackBoxY == 0)
4203  gm.gmBlackBoxY = 1;
4204 
4205  *pgm = gm;
4206  return needed;
4207 }
#define abs(i)
Definition: fconv.c:206
int FT_Error
Definition: fttypes.h:300
GLint GLint GLsizei width
Definition: gl.h:1546
VOID FASTCALL FtMatrixFromMx(FT_Matrix *pmat, const MATRIX *pmx)
Definition: freetype.c:752
FT_Pos y
Definition: ftimage.h:77
FLOATL eM11
Definition: winddi.h:1234
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define GGO_METRICS
Definition: wingdi.h:848
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
unsigned char pixel_mode
Definition: ftimage.h:268
long y
Definition: polytest.cpp:48
unsigned int rows
Definition: ftimage.h:263
#define error(str)
Definition: mkdosfs.c:1605
long x
Definition: polytest.cpp:48
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:653
FT_Pos x
Definition: ftimage.h:76
#define TRUE
Definition: types.h:120
#define FLOATOBJ_Set1(fo)
Definition: floatobj.h:119
signed int FT_Int
Definition: fttypes.h:220
#define FLOATOBJ_DivLong(pf, l)
Definition: winddi.h:2829
FT_Glyph_Metrics metrics
Definition: freetype.h:1916
LONG tmAveCharWidth
Definition: wingdi.h:2388
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3010
static __inline FT_Fixed FT_FixedFromFIXED(FIXED f)
Definition: freetype.c:382
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
unsigned char * buffer
Definition: ftimage.h:266
#define GGO_GRAY4_BITMAP
Definition: wingdi.h:853
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static const MAT2 mat
Definition: font.c:66
short gmCellIncY
Definition: wingdi.h:2446
FT_Matrix_Multiply(const FT_Matrix *a, FT_Matrix *b)
Definition: ftcalc.c:661
FORCEINLINE VOID XFORMOBJ_vInit(OUT XFORMOBJ *pxo, IN MATRIX *pmx)
Definition: xformobj.h:21
#define FT_LOAD_DEFAULT
Definition: freetype.h:3008
int32_t INT
Definition: typedefs.h:58
HFONT hFont
Definition: main.c:53
#define GGO_BITMAP
Definition: wingdi.h:849
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
FT_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap *abitmap)
Definition: ftoutln.c:661
#define GGO_GRAY8_BITMAP
Definition: wingdi.h:854
#define GGO_BEZIER
Definition: wingdi.h:851
#define FLOATOBJ_SetFloat(pf, f)
Definition: winddi.h:2814
FT_Fixed xx
Definition: fttypes.h:387
#define FALSE
Definition: types.h:117
BOOL FASTCALL TextIntUpdateSize(PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:3591
Definition: text.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
#define XFORMOBJ_iGetXform
Definition: xformobj.h:9
long LONG
Definition: pedump.c:60
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:760
LONG lfOrientation
Definition: dimm.idl:62
HANDLE hlfntNew
Definition: ntgdihdl.h:330
static PVOID ptr
Definition: dispmode.c:27
#define GGO_NATIVE
Definition: wingdi.h:850
#define FLOATOBJ_AddLong(pf, l)
Definition: winddi.h:2820
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2427
LONG lfWidth
Definition: dimm.idl:60
FT_Library g_FreeTypeLibrary
Definition: freetype.c:55
GLint GLint bottom
Definition: glext.h:7726
FIXED eM22
Definition: wingdi.h:2476
FIXED eM11
Definition: wingdi.h:2473
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
FIXED eM21
Definition: wingdi.h:2475
#define ft_glyph_format_outline
Definition: ftimage.h:732
#define ft_glyph_format_bitmap
Definition: ftimage.h:731
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
POINT gmptGlyphOrigin
Definition: wingdi.h:2444
FLOAT FLOATOBJ
Definition: winddi.h:677
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
static unsigned int get_native_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3274
FT_Face Face
Definition: engobjects.h:132
FT_Vector * vec
Definition: ftbbox.c:448
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define GGO_UNHINTED
Definition: wingdi.h:856
#define GGO_GLYPH_INDEX
Definition: wingdi.h:855
_In_ DWORD cjBuf
Definition: winddi.h:3827
static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3347
#define IntLockFreeType()
Definition: freetype.c:79
FT_Outline outline
Definition: freetype.h:1927
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, DWORD indexed_flag, DWORD flags)
Definition: freetype.c:3709
FIXED eM12
Definition: wingdi.h:2474
GLenum src
Definition: glext.h:6340
FT_Bitmap bitmap
Definition: freetype.h:1923
LONG APIENTRY FLOATOBJ_GetLong(FLOATOBJ *pf)
Definition: floatobj.c:17
Definition: mesh.c:5329
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
unsigned char BYTE
Definition: xxhash.c:193
short gmCellIncX
Definition: wingdi.h:2445
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3467
FT_GlyphSlot glyph
Definition: freetype.h:1105
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
FT_Glyph_Format format
Definition: freetype.h:1921
FONTOBJ * Font
Definition: text.h:66
VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
Definition: freetype.c:739
FT_Vector_Transform(FT_Vector *vec, const FT_Matrix *matrix)
Definition: ftoutln.c:688
#define GDITAG_TEXT
Definition: tags.h:172
PSHARED_FACE SharedFace
Definition: engobjects.h:145
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
unsigned int FT_UInt
Definition: fttypes.h:231
GLuint start
Definition: gl.h:1545
FT_Fixed xy
Definition: fttypes.h:387
GLenum GLenum dst
Definition: glext.h:6340
UINT gmBlackBoxY
Definition: wingdi.h:2443
#define min(a, b)
Definition: monoChain.cc:55
#define GGO_GRAY2_BITMAP
Definition: wingdi.h:852
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2514
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
Definition: freetype.h:3017
int pitch
Definition: ftimage.h:265
#define DPRINT1
Definition: precomp.h:8
static const FT_Matrix identityMat
Definition: freetype.c:50
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:528
LOGFONTW elfLogFont
Definition: wingdi.h:2702
UINT gmBlackBoxX
Definition: wingdi.h:2442
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:183
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:105
static const WCHAR dc[]
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:135
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3012
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
FT_Fixed yx
Definition: fttypes.h:388
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2779
FT_Fixed yy
Definition: fttypes.h:388
#define DPRINT
Definition: sndvol32.h:71
#define INT_TO_FIXED(x)
Definition: ftcalc.h:404
#define FLOATOBJ_Mul(pf, pf1)
Definition: winddi.h:2824
#define GDI_ERROR
Definition: wingdi.h:1309
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
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 width
Definition: ftimage.h:264
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by NtGdiGetGlyphOutline(), and PATH_ExtTextOut().

◆ ftGdiGetKerningPairs()

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

Definition at line 5663 of file freetype.c.

5666 {
5667  DWORD Count = 0;
5668  INT i = 0;
5669  FT_Face face = Font->SharedFace->Face;
5670 
5671  if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
5672  {
5673  FT_UInt previous_index = 0, glyph_index = 0;
5674  FT_ULong char_code, char_previous;
5675  FT_Vector delta;
5676 
5677  char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
5678 
5679  IntLockFreeType();
5680 
5681  while (glyph_index)
5682  {
5683  if (previous_index && glyph_index)
5684  {
5685  FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
5686 
5687  if (pKerningPair && cPairs)
5688  {
5689  pKerningPair[i].wFirst = char_previous;
5690  pKerningPair[i].wSecond = char_code;
5691  pKerningPair[i].iKernAmount = delta.x;
5692  i++;
5693  if (i == cPairs) break;
5694  }
5695  Count++;
5696  }
5697  previous_index = glyph_index;
5698  char_previous = char_code;
5699  char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
5700  }
5702  }
5703  return Count;
5704 }
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
unsigned long FT_ULong
Definition: fttypes.h:253
WORD wSecond
Definition: wingdi.h:2465
FT_Pos x
Definition: ftimage.h:76
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3722
int32_t INT
Definition: typedefs.h:58
#define FT_HAS_KERNING(face)
Definition: freetype.h:1297
int Count
Definition: noreturn.cpp:7
int iKernAmount
Definition: wingdi.h:2466
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
#define IntLockFreeType()
Definition: freetype.c:79
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
unsigned int FT_UInt
Definition: fttypes.h:231
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by GreGetKerningPairs(), and NtGdiGetKerningPairs().

◆ ftGdiGetRasterizerCaps()

BOOL FASTCALL ftGdiGetRasterizerCaps ( LPRASTERIZER_STATUS  lprs)

Definition at line 3102 of file freetype.c.

3103 {
3104  if ( lprs )
3105  {
3106  lprs->nSize = sizeof(RASTERIZER_STATUS);
3107  lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3108  lprs->nLanguageID = gusLanguageID;
3109  return TRUE;
3110  }
3112  return FALSE;
3113 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define TRUE
Definition: types.h:120
struct _RASTERIZER_STATUS RASTERIZER_STATUS
#define FALSE
Definition: types.h:117
#define TT_AVAILABLE
Definition: wingdi.h:888
USHORT gusLanguageID
Definition: main.c:29
#define TT_ENABLED
Definition: wingdi.h:889
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by NtGdiGetRasterizerCaps().

◆ ftGdiGetRealGlyph()

static FT_BitmapGlyph ftGdiGetRealGlyph ( IN OUT PFONT_CACHE_ENTRY  Cache)
static

Definition at line 4210 of file freetype.c.

4212 {
4213  INT error;
4214  FT_GlyphSlot glyph;
4215  FT_BitmapGlyph realglyph;
4216  DWORD cdw;
4217 
4219 
4220  if (Cache->Aspect.EmuBoldItalic)
4221  {
4222  error = FT_Load_Glyph(Cache->Face, Cache->GlyphIndex, FT_LOAD_NO_BITMAP);
4223  if (error)
4224  {
4225  DPRINT1("WARNING: Failed to load and render glyph! [index: %d]\n", Cache->GlyphIndex);
4226  return NULL;
4227  }
4228 
4229  glyph = Cache->Face->glyph;
4230 
4231  if (Cache->Aspect.Emu.Bold)
4232  FT_GlyphSlot_Embolden(glyph);
4233  if (Cache->Aspect.Emu.Italic)
4234  FT_GlyphSlot_Oblique(glyph);
4235  realglyph = ftGdiGlyphSet(Cache->Face, glyph, Cache->Aspect.RenderMode);
4236  }
4237  else
4238  {
4239  cdw = (sizeof(FONT_CACHE_ENTRY) - offsetof(FONT_CACHE_ENTRY, GlyphIndex)) / sizeof(DWORD);
4240  Cache->dwHash = IntGetHash(&Cache->GlyphIndex, cdw);
4241 
4242  realglyph = ftGdiGlyphCacheGet(Cache);
4243  if (realglyph)
4244  return realglyph;
4245 
4246  error = FT_Load_Glyph(Cache->Face, Cache->GlyphIndex, FT_LOAD_DEFAULT);
4247  if (error)
4248  {
4249  DPRINT1("WARNING: Failed to load and render glyph! [index: %d]\n", Cache->GlyphIndex);
4250  return NULL;
4251  }
4252 
4253  glyph = Cache->Face->glyph;
4254  realglyph = ftGdiGlyphCacheSet(Cache, glyph);
4255  }
4256 
4257  if (!realglyph)
4258  DPRINT1("Failed to render glyph! [index: %d]\n", Cache->GlyphIndex);
4259 
4260  return realglyph;
4261 }
#define error(str)
Definition: mkdosfs.c:1605
Definition: fatfs.h:173
static FT_BitmapGlyph ftGdiGlyphSet(FT_Face Face, FT_GlyphSlot GlyphSlot, FT_Render_Mode RenderMode)
Definition: freetype.c:3167
#define FT_LOAD_DEFAULT
Definition: freetype.h:3008
int32_t INT
Definition: typedefs.h:58
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:760
FT_BEGIN_HEADER FT_GlyphSlot_Embolden(FT_GlyphSlot slot)
Definition: ftsynth.c:90
FT_GlyphSlot_Oblique(FT_GlyphSlot slot)
Definition: ftsynth.c:48
#define offsetof(TYPE, MEMBER)
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: font.h:43
static FT_BitmapGlyph ftGdiGlyphCacheSet(IN OUT PFONT_CACHE_ENTRY Cache, IN FT_GlyphSlot GlyphSlot)
Definition: freetype.c:3210
struct _FONT_CACHE_ENTRY FONT_CACHE_ENTRY
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3012
static DWORD IntGetHash(IN LPCVOID pv, IN DWORD cdw)
Definition: freetype.c:3116
static FT_BitmapGlyph ftGdiGlyphCacheGet(IN const FONT_CACHE_ENTRY *pCache)
Definition: freetype.c:3131

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

◆ ftGdiGetTextCharsetInfo()

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

Definition at line 4369 of file freetype.c.

4373 {
4374  PDC_ATTR pdcattr;
4375  UINT Ret = DEFAULT_CHARSET;
4376  INT i;
4377  HFONT hFont;
4378  PTEXTOBJ TextObj;
4379  PFONTGDI FontGdi;
4380  FONTSIGNATURE fs;
4381  TT_OS2 *pOS2;
4382  FT_Face Face;
4383  CHARSETINFO csi;
4384  DWORD cp, fs0;
4385  USHORT usACP, usOEM;
4386 
4387  pdcattr = Dc->pdcattr;
4388  hFont = pdcattr->hlfntNew;
4389  TextObj = RealizeFontInit(hFont);
4390 
4391  if (!TextObj)
4392  {
4394  return Ret;
4395  }
4396  FontGdi = ObjToGDI(TextObj->Font, FONT);
4397  Face = FontGdi->SharedFace->Face;
4398  TEXTOBJ_UnlockText(TextObj);
4399 
4400  memset(&fs, 0, sizeof(FONTSIGNATURE));
4401  IntLockFreeType();
4402  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4403  if (NULL != pOS2)
4404  {
4405  fs.fsCsb[0] = pOS2->ulCodePageRange1;
4406  fs.fsCsb[1] = pOS2->ulCodePageRange2;
4407  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
4408  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
4409  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
4410  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
4411  if (pOS2->version == 0)
4412  {
4413  FT_UInt dummy;
4414 
4415  if (FT_Get_First_Char( Face, &dummy ) < 0x100)
4416  fs.fsCsb[0] |= FS_LATIN1;
4417  else
4418  fs.fsCsb[0] |= FS_SYMBOL;
4419  }
4420  }
4421  pOS2 = NULL;
4423  DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
4424  if (fs.fsCsb[0] == 0)
4425  { /* Let's see if we can find any interesting cmaps */
4426  for (i = 0; i < Face->num_charmaps; i++)
4427  {
4428  switch (Face->charmaps[i]->encoding)
4429  {
4430  case FT_ENCODING_UNICODE:
4431  case FT_ENCODING_APPLE_ROMAN:
4432  fs.fsCsb[0] |= FS_LATIN1;
4433  break;
4434  case FT_ENCODING_MS_SYMBOL:
4435  fs.fsCsb[0] |= FS_SYMBOL;
4436  break;
4437  default:
4438  break;
4439  }
4440  }
4441  }
4442  if (lpSig)
4443  {
4444  RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
4445  }
4446 
4447  RtlGetDefaultCodePage(&usACP, &usOEM);
4448  cp = usACP;
4449 
4451  if (csi.fs.fsCsb[0] & fs.fsCsb[0])
4452  {
4453  DPRINT("Hit 1\n");
4454  Ret = csi.ciCharset;
4455  goto Exit;
4456  }
4457 
4458  for (i = 0; i < MAXTCIINDEX; i++)
4459  {
4460  fs0 = 1L << i;
4461  if (fs.fsCsb[0] & fs0)
4462  {
4463  if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
4464  {
4465  // *cp = csi.ciACP;
4466  DPRINT("Hit 2\n");
4467  Ret = csi.ciCharset;
4468  goto Exit;
4469  }
4470  else
4471  DPRINT1("TCI failing on %x\n", fs0);
4472  }
4473  }
4474 Exit:
4475  DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
4476  return (MAKELONG(csi.ciACP, csi.ciCharset));
4477 }
FONTSIGNATURE fs
Definition: wingdi.h:1548
FT_CharMap * charmaps
Definition: freetype.h:1085
#define ft_sfnt_os2
Definition: tttables.h:631
#define TCI_SRCFONTSIG
Definition: wingdi.h:963
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
Definition: ffs.h:70
#define DEFAULT_CHARSET
Definition: wingdi.h:384
int32_t INT
Definition: typedefs.h:58
#define MAXTCIINDEX
Definition: freetype.c:123
HFONT hFont
Definition: main.c:53
#define L(x)
Definition: ntvdm.h:50
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:330
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
UINT ciCharset
Definition: wingdi.h:1546
#define MAKELONG(a, b)
Definition: typedefs.h:249
FT_UShort version
Definition: tttables.h:382
NTSYSAPI VOID NTAPI RtlGetDefaultCodePage(_Out_ PUSHORT AnsiCodePage, _Out_ PUSHORT OemCodePage)
#define fs
Definition: i386-dis.c:445
#define FS_SYMBOL
Definition: wingdi.h:575
static void Exit(void)
Definition: sock.c:1331
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
FT_Face Face
Definition: engobjects.h:132
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
FT_Encoding encoding
Definition: freetype.h:843
#define IntLockFreeType()
Definition: freetype.c:79
FT_Int num_charmaps
Definition: freetype.h:1084
static BOOLEAN IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2063
FONTOBJ * Font
Definition: text.h:66
DWORD fsCsb[2]
Definition: wingdi.h:1543
FT_ULong ulCodePageRange1
Definition: tttables.h:419
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
PSHARED_FACE SharedFace
Definition: engobjects.h:145
unsigned short USHORT
Definition: pedump.c:61
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
unsigned int FT_UInt
Definition: fttypes.h:231
unsigned char dummy
Definition: maze.c:118
FT_ULong ulUnicodeRange4
Definition: tttables.h:404
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
FT_ULong ulCodePageRange2
Definition: tttables.h:420
#define DPRINT1
Definition: precomp.h:8
FT_ULong ulUnicodeRange3
Definition: tttables.h:403
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define TCI_SRCCODEPAGE
Definition: wingdi.h:962
#define FS_LATIN1
Definition: wingdi.h:560
POINT cp
Definition: magnifier.c:59
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:183
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define DPRINT
Definition: sndvol32.h:71
#define memset(x, y, z)
Definition: compat.h:39
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
FT_ULong ulUnicodeRange2
Definition: tttables.h:402

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

◆ ftGdiGetTextMetricsW()

BOOL FASTCALL ftGdiGetTextMetricsW ( HDC  hDC,
PTMW_INTERNAL  ptmwi 
)

Definition at line 4550 of file freetype.c.

4553 {
4554  PDC dc;
4555  PDC_ATTR pdcattr;
4556  PTEXTOBJ TextObj;
4557  PFONTGDI FontGDI;
4558  FT_Face Face;
4559  TT_OS2 *pOS2;
4560  TT_HoriHeader *pHori;
4561  FT_WinFNT_HeaderRec Win;
4562  ULONG Error;
4564  LOGFONTW *plf;
4565  FT_Matrix mat;
4566 
4567  if (!ptmwi)
4568  {
4570  return FALSE;
4571  }
4572  RtlZeroMemory(ptmwi, sizeof(TMW_INTERNAL));
4573 
4574  if (!(dc = DC_LockDc(hDC)))
4575  {
4577  return FALSE;
4578  }
4579  pdcattr = dc->pdcattr;
4580  TextObj = RealizeFontInit(pdcattr->hlfntNew);
4581  if (NULL != TextObj)
4582  {
4583  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4584  FontGDI = ObjToGDI(TextObj->Font, FONT);
4585 
4586  Face = FontGDI->SharedFace->Face;
4587 
4588  IntLockFreeType();
4589  Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4591  FT_Set_Transform(Face, &mat, 0);
4593 
4594  if (0 != Error)
4595  {
4596  DPRINT1("Error in setting pixel sizes: %u\n", Error);
4598  }
4599  else
4600  {
4601  FT_Face Face = FontGDI->SharedFace->Face;
4603 
4604  IntLockFreeType();
4605  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4606  if (NULL == pOS2)
4607  {
4608  DPRINT1("Can't find OS/2 table - not TT font?\n");
4610  }
4611 
4612  pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
4613  if (NULL == pHori)
4614  {
4615  DPRINT1("Can't find HHEA table - not TT font?\n");
4617  }
4618 
4619  Error = FT_Get_WinFNT_Header(Face, &Win);
4620 
4621  if (NT_SUCCESS(Status) || !Error)
4622  {
4623  FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
4624 
4625  /* FIXME: Fill Diff member */
4626  }
4627 
4629  }
4630  TEXTOBJ_UnlockText(TextObj);
4631  }
4632  else
4633  {
4635  }
4636  DC_UnlockDc(dc);
4637 
4638  if (!NT_SUCCESS(Status))
4639  {
4641  return FALSE;
4642  }
4643  return TRUE;
4644 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
VOID FASTCALL FtMatrixFromMx(FT_Matrix *pmat, const MATRIX *pmx)
Definition: freetype.c:752
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
FT_Get_WinFNT_Header(FT_Face face, FT_WinFNT_HeaderRec *aheader)
Definition: ftwinfnt.c:29
#define ft_sfnt_os2
Definition: tttables.h:631
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:653
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
static const MAT2 mat
Definition: font.c:66
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define FALSE
Definition: types.h:117
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:330
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
static void FASTCALL FillTM(TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT)
Definition: freetype.c:2126
LONG lfWidth
Definition: dimm.idl:60
#define ft_sfnt_hhea
Definition: tttables.h:632
Status
Definition: gdiplustypes.h:24
Definition: polytest.cpp:40
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3472
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IntUnLockFreeType()
Definition: freetype.c:82
BOOL Error
Definition: chkdsk.c:66
FT_Face Face
Definition: engobjects.h:132
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define IntLockFreeType()
Definition: freetype.c:79
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
static HDC hDC
Definition: 3dtext.c:33
FONTOBJ * Font
Definition: text.h:66
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
PSHARED_FACE SharedFace
Definition: engobjects.h:145
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
LOGFONTW elfLogFont
Definition: wingdi.h:2702
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:183
static const WCHAR dc[]
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:135
#define STATUS_SUCCESS
Definition: shellext.h:65
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2779
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

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

◆ ftGdiGetTextWidth()

static BOOL ftGdiGetTextWidth ( LONGLONG pTextWidth64,
LPCWSTR  String,
INT  Count,
PFONT_CACHE_ENTRY  Cache,
UINT  fuOptions 
)
static

Definition at line 5867 of file freetype.c.

5873 {
5874  LONGLONG TextLeft64 = 0;
5875  INT glyph_index;
5876  FT_BitmapGlyph realglyph;
5877  FT_Face face = Cache->Face;
5878  BOOL use_kerning = FT_HAS_KERNING(face);
5879  ULONG previous = 0;
5880  FT_Vector delta;
5881 
5883 
5884  while (Count-- > 0)
5885  {
5886  glyph_index = get_glyph_index_flagged(face, *String, ETO_GLYPH_INDEX, fuOptions);
5887  Cache->GlyphIndex = glyph_index;
5888 
5889  realglyph = ftGdiGetRealGlyph(Cache);
5890  if (!realglyph)
5891  return FALSE;
5892 
5893  /* Retrieve kerning distance */
5894  if (use_kerning && previous && glyph_index)
5895  {
5896  FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
5897  TextLeft64 += delta.x;
5898  }
5899 
5900  TextLeft64 += realglyph->root.advance.x >> 10;
5901 
5902  if (Cache->Aspect.EmuBoldItalic)
5903  FT_Done_Glyph((FT_Glyph)realglyph);
5904 
5905  previous = glyph_index;
5906  String++;
5907  }
5908 
5909  *pTextWidth64 = TextLeft64;
5910  return TRUE;
5911 }
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
Definition: fatfs.h:173
FT_Pos x
Definition: ftimage.h:76
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
#define FT_HAS_KERNING(face)
Definition: freetype.h:1297
static FT_BitmapGlyph ftGdiGetRealGlyph(IN OUT PFONT_CACHE_ENTRY Cache)
Definition: freetype.c:4210
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
FT_GlyphRec root
Definition: ftglyph.h:162
int64_t LONGLONG
Definition: typedefs.h:68
int Count
Definition: noreturn.cpp:7
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, DWORD indexed_flag, DWORD flags)
Definition: freetype.c:3709
FT_Vector advance
Definition: ftglyph.h:113
unsigned int ULONG
Definition: retypes.h:1
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by IntExtTextOutW().

◆ ftGdiGlyphCacheGet()

static FT_BitmapGlyph ftGdiGlyphCacheGet ( IN const FONT_CACHE_ENTRY pCache)
static

Definition at line 3131 of file freetype.c.

3132 {
3133  PLIST_ENTRY CurrentEntry;
3134  PFONT_CACHE_ENTRY FontEntry;
3135  DWORD dwHash = pCache->dwHash;
3136 
3138 
3139  for (CurrentEntry = g_FontCacheListHead.Flink;
3140  CurrentEntry != &g_FontCacheListHead;
3141  CurrentEntry = CurrentEntry->Flink)
3142  {
3143  FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
3144  if (FontEntry->dwHash == dwHash &&
3145  FontEntry->GlyphIndex == pCache->GlyphIndex &&
3146  FontEntry->Face == pCache->Face &&
3147  FontEntry->lfHeight == pCache->lfHeight &&
3148  FontEntry->AspectValue == pCache->AspectValue &&
3149  memcmp(&FontEntry->matTransform, &pCache->matTransform, sizeof(FT_Matrix)) == 0)
3150  {
3151  break;
3152  }
3153  }
3154 
3155  if (CurrentEntry == &g_FontCacheListHead)
3156  {
3157  return NULL;
3158  }
3159 
3160  RemoveEntryList(CurrentEntry);
3161  InsertHeadList(&g_FontCacheListHead, CurrentEntry);
3162  return FontEntry->BitmapGlyph;
3163 }
DWORD AspectValue
Definition: font.h:55
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
FT_Matrix matTransform
Definition: font.h:57
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FT_BitmapGlyph BitmapGlyph
Definition: font.h:46
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
FT_Face Face
Definition: font.h:51
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
unsigned long DWORD
Definition: ntddk_ex.h:95
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:93
Definition: font.h:43
INT GlyphIndex
Definition: font.h:50
Definition: typedefs.h:119
LONG lfHeight
Definition: font.h:52
#define NULL
Definition: types.h:112
DWORD dwHash
Definition: font.h:47

Referenced by ftGdiGetRealGlyph().

◆ ftGdiGlyphCacheSet()

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

Definition at line 3210 of file freetype.c.

3213 {
3214  FT_Glyph GlyphCopy;
3215  INT error;
3216  PFONT_CACHE_ENTRY NewEntry;
3217  FT_Bitmap AlignedBitmap;
3218  FT_BitmapGlyph BitmapGlyph;
3219 
3221 
3222  error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
3223  if (error)
3224  {
3225  DPRINT1("Failure caching glyph.\n");
3226  return NULL;
3227  };
3228 
3229  error = FT_Glyph_To_Bitmap(&GlyphCopy, Cache->Aspect.RenderMode, 0, 1);
3230  if (error)
3231  {
3232  FT_Done_Glyph(GlyphCopy);
3233  DPRINT1("Failure rendering glyph.\n");
3234  return NULL;
3235  };
3236 
3238  if (!NewEntry)
3239  {
3240  DPRINT1("Alloc failure caching glyph.\n");
3241  FT_Done_Glyph(GlyphCopy);
3242  return NULL;
3243  }
3244 
3245  BitmapGlyph = (FT_BitmapGlyph)GlyphCopy;
3246  FT_Bitmap_New(&AlignedBitmap);
3247  if(FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3248  {
3249  DPRINT1("Conversion failed\n");
3250  ExFreePoolWithTag(NewEntry, TAG_FONT);
3251  FT_Bitmap_Done(GlyphSlot->library, &AlignedBitmap);
3252  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3253  return NULL;
3254  }
3255 
3256  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3257  BitmapGlyph->bitmap = AlignedBitmap;
3258 
3259  NewEntry->BitmapGlyph = BitmapGlyph;
3260  RtlCopyMemory(&NewEntry->dwHash, &Cache->dwHash,
3261  sizeof(FONT_CACHE_ENTRY) - offsetof(FONT_CACHE_ENTRY, dwHash));
3262 
3265  {
3267  RemoveCachedEntry(NewEntry);
3268  }
3269 
3270  return BitmapGlyph;
3271 }
FT_Bitmap bitmap
Definition: ftglyph.h:165
#define error(str)
Definition: mkdosfs.c:1605
static UINT g_FontCacheNumEntries
Definition: freetype.c:94
Definition: fatfs.h:173
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FT_BitmapGlyph BitmapGlyph
Definition: font.h:46
#define TAG_FONT
Definition: tags.h:12
FT_Bitmap_Done(FT_Library library, FT_Bitmap *bitmap)
Definition: ftbitmap.c:826
int32_t INT
Definition: typedefs.h:58
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:127
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
FT_Bitmap_Convert(FT_Library library, const FT_Bitmap *source, FT_Bitmap *target, FT_Int alignment)
Definition: ftbitmap.c:504
#define offsetof(TYPE, MEMBER)
#define MAX_FONT_CACHE
Definition: freetype.c:91
FT_Bitmap_New(FT_Bitmap *abitmap)
Definition: ftbitmap.c:44
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static void RemoveCachedEntry(PFONT_CACHE_ENTRY Entry)
Definition: freetype.c:257
LIST_ENTRY ListEntry
Definition: font.h:45
FT_Glyph_To_Bitmap(FT_Glyph *the_glyph, FT_Render_Mode render_mode, FT_Vector *origin, FT_Bool destroy)
Definition: ftglyph.c:527
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:93
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: font.h:43
FT_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph)
Definition: ftglyph.c:363
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
DWORD dwHash
Definition: font.h:47
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by ftGdiGetRealGlyph().

◆ ftGdiGlyphSet()

static FT_BitmapGlyph ftGdiGlyphSet ( FT_Face  Face,
FT_GlyphSlot  GlyphSlot,
FT_Render_Mode  RenderMode 
)
static

Definition at line 3167 of file freetype.c.

3171 {
3172  FT_Glyph Glyph;
3173  INT error;
3174  FT_Bitmap AlignedBitmap;
3175  FT_BitmapGlyph BitmapGlyph;
3176 
3178 
3179  error = FT_Get_Glyph(GlyphSlot, &Glyph);
3180  if (error)
3181  {
3182  DPRINT1("Failure getting glyph.\n");
3183  return NULL;
3184  }
3185 
3186  error = FT_Glyph_To_Bitmap(&Glyph, RenderMode, 0, 1);
3187  if (error)
3188  {
3189  FT_Done_Glyph(Glyph);
3190  DPRINT1("Failure rendering glyph.\n");
3191  return NULL;
3192  }
3193 
3194  BitmapGlyph = (FT_BitmapGlyph)Glyph;
3195  FT_Bitmap_New(&AlignedBitmap);
3196  if (FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3197  {
3198  DPRINT1("Conversion failed\n");
3199  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3200  return NULL;
3201  }
3202 
3203  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3204  BitmapGlyph->bitmap = AlignedBitmap;
3205 
3206  return BitmapGlyph;
3207 }
FT_Bitmap bitmap
Definition: ftglyph.h:165
#define error(str)
Definition: mkdosfs.c:1605
FT_Bitmap_Done(FT_Library library, FT_Bitmap *bitmap)
Definition: ftbitmap.c:826
int32_t INT
Definition: typedefs.h:58
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:127
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
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_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
FT_Library library
Definition: freetype.h:1910
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633

Referenced by ftGdiGetRealGlyph().

◆ ftGdiRealizationInfo()

BOOL FASTCALL ftGdiRealizationInfo ( PFONTGDI  Font,
PREALIZATION_INFO  Info 
)

Definition at line 5644 of file freetype.c.

5645 {
5646  if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
5647  Info->iTechnology = RI_TECH_BITMAP;
5648  else
5649  {
5650  if (FT_IS_SCALABLE(Font->SharedFace->Face))
5651  Info->iTechnology = RI_TECH_SCALABLE;
5652  else
5653  Info->iTechnology = RI_TECH_FIXED;
5654  }
5655  Info->iUniq = Font->FontObj.iUniq;
5656  Info->dwUnknown = -1;
5657  return TRUE;
5658 }
#define RI_TECH_BITMAP
Definition: ntgdityp.h:271
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define RI_TECH_SCALABLE
Definition: ntgdityp.h:273
#define FT_HAS_FIXED_SIZES(face)
Definition: freetype.h:1361
#define RI_TECH_FIXED
Definition: ntgdityp.h:272
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312

Referenced by NtGdiGetRealizationInfo().

◆ ftGetFontUnicodeRanges()

DWORD FASTCALL ftGetFontUnicodeRanges ( PFONTGDI  Font,
PGLYPHSET  glyphset 
)

Definition at line 4482 of file freetype.c.

4483 {
4484  DWORD size = 0;
4485  DWORD num_ranges = 0;
4486  FT_Face face = Font->SharedFace->Face;
4487 
4488  if (face->charmap->encoding == FT_ENCODING_UNICODE)
4489  {
4490  FT_UInt glyph_code = 0;
4491  FT_ULong char_code, char_code_prev;
4492 
4493  char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
4494 
4495  DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
4496  face->num_glyphs, glyph_code, char_code);
4497 
4498  if (!glyph_code) return 0;
4499 
4500  if (glyphset)
4501  {
4502  glyphset->ranges[0].wcLow = (USHORT)char_code;
4503  glyphset->ranges[0].cGlyphs = 0;
4504  glyphset->cGlyphsSupported = 0;
4505  }
4506 
4507  num_ranges = 1;
4508  while (glyph_code)
4509  {
4510  if (char_code < char_code_prev)
4511  {
4512  DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
4513  return 0;
4514  }
4515  if (char_code - char_code_prev > 1)
4516  {
4517  num_ranges++;
4518  if (glyphset)
4519  {
4520  glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
4521  glyphset->ranges[num_ranges - 1].cGlyphs = 1;
4522  glyphset->cGlyphsSupported++;
4523  }
4524  }
4525  else if (glyphset)
4526  {
4527  glyphset->ranges[num_ranges - 1].cGlyphs++;
4528  glyphset->cGlyphsSupported++;
4529  }
4530  char_code_prev = char_code;
4531  char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
4532  }
4533  }
4534  else
4535  DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
4536 
4537  size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
4538  if (glyphset)
4539  {
4540  glyphset->cbThis = size;
4541  glyphset->cRanges = num_ranges;
4542  glyphset->flAccel = 0;
4543  }
4544  return size;
4545 }
unsigned long FT_ULong
Definition: fttypes.h:253
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3722
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
unsigned short USHORT
Definition: pedump.c:61
unsigned int FT_UInt
Definition: fttypes.h:231
#define DPRINT1
Definition: precomp.h:8
#define DPRINT
Definition: sndvol32.h:71
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by NtGdiGetFontUnicodeRanges().

◆ FtMatrixFromMx()

VOID FASTCALL FtMatrixFromMx ( FT_Matrix pmat,
const MATRIX pmx 
)

Definition at line 752 of file freetype.c.

753 {
754  FLOATOBJ ef;
755 
756  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
757  ef = pmx->efM11;
758  FLOATOBJ_MulLong(&ef, 0x00010000);
759  pmat->xx = FLOATOBJ_GetLong(&ef);
760 
761  ef = pmx->efM21;
762  FLOATOBJ_MulLong(&ef, 0x00010000);
763  pmat->xy = -FLOATOBJ_GetLong(&ef); /* (*1) See below */
764 
765  ef = pmx->efM12;
766  FLOATOBJ_MulLong(&ef, 0x00010000);
767  pmat->yx = -FLOATOBJ_GetLong(&ef); /* (*1) See below */
768 
769  ef = pmx->efM22;
770  FLOATOBJ_MulLong(&ef, 0x00010000);
771  pmat->yy = FLOATOBJ_GetLong(&ef);
772 
773  // (*1): Y direction is mirrored as follows:
774  //
775  // [ M11 -M12 ] [ X ] [ M11*X + M12*Y ]
776  // [ ] * [ ] == [ ]
777  // [ -M21 M22 ] [ -Y ] [ -(M21*X + M22*Y) ].
778 }
FT_Fixed xx
Definition: fttypes.h:387
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
FLOAT FLOATOBJ
Definition: winddi.h:677
LONG APIENTRY FLOATOBJ_GetLong(FLOATOBJ *pf)
Definition: floatobj.c:17
FT_Fixed xy
Definition: fttypes.h:387
FT_Fixed yx
Definition: fttypes.h:388
FT_Fixed yy
Definition: fttypes.h:388

Referenced by ftGdiGetGlyphOutline(), ftGdiGetTextMetricsW(), IntExtTextOutW(), NtGdiGetCharABCWidthsW(), and NtGdiGetCharWidthW().

◆ FTVectorToPOINTFX()

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

Definition at line 368 of file freetype.c.

369 {
370  pt->x.value = vec->x >> 6;
371  pt->x.fract = (vec->x & 0x3f) << 10;
372  pt->x.fract |= ((pt->x.fract >> 6) | (pt->x.fract >> 12));
373  pt->y.value = vec->y >> 6;
374  pt->y.fract = (vec->y & 0x3f) << 10;
375  pt->y.fract |= ((pt->y.fract >> 6) | (pt->y.fract >> 12));
376 }
FT_Pos y
Definition: ftimage.h:77
FT_Pos x
Definition: ftimage.h:76
#define pt(x, y)
Definition: drawing.c:79
FT_Vector * vec
Definition: ftbbox.c:448
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 3347 of file freetype.c.

3348 {
3349  /* Convert the quadratic Beziers to cubic Beziers.
3350  The parametric eqn for a cubic Bezier is, from PLRM:
3351  r(t) = at^3 + bt^2 + ct + r0
3352  with the control points:
3353  r1 = r0 + c/3
3354  r2 = r1 + (c + b)/3
3355  r3 = r0 + c + b + a
3356 
3357  A quadratic Bezier has the form:
3358  p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
3359 
3360  So equating powers of t leads to:
3361  r1 = 2/3 p1 + 1/3 p0
3362  r2 = 2/3 p1 + 1/3 p2
3363  and of course r0 = p0, r3 = p2
3364  */
3365  int contour, point = 0, first_pt;
3366  TTPOLYGONHEADER *pph;
3367  TTPOLYCURVE *ppc;
3368  DWORD pph_start, cpfx, type;
3369  FT_Vector cubic_control[4];
3370  unsigned int needed = 0;
3371 
3372  for (contour = 0; contour < outline->n_contours; contour++)
3373  {
3374  pph_start = needed;
3375  pph = (TTPOLYGONHEADER *)(buf + needed);
3376  first_pt = point;
3377  if (buf)
3378  {
3379  pph->dwType = TT_POLYGON_TYPE;
3380  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3381  }
3382  needed += sizeof(*pph);
3383  point++;
3384  while (point <= outline->contours[contour])
3385  {
3386  ppc = (TTPOLYCURVE *)(buf + needed);
3387  type = (outline->tags[point] & FT_Curve_Tag_On) ?
3389  cpfx = 0;
3390  do
3391  {
3392  if (type == TT_PRIM_LINE)
3393  {
3394  if (buf)
3395  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3396  cpfx++;
3397  point++;
3398  }
3399  else
3400  {
3401  /* Unlike QSPLINEs, CSPLINEs always have their endpoint
3402  so cpfx = 3n */
3403 
3404  /* FIXME: Possible optimization in endpoint calculation
3405  if there are two consecutive curves */
3406  cubic_control[0] = outline->points[point-1];
3407  if (!(outline->tags[point-1] & FT_Curve_Tag_On))
3408  {
3409  cubic_control[0].x += outline->points[point].x + 1;
3410  cubic_control[0].y += outline->points[point].y + 1;
3411  cubic_control[0].x >>= 1;
3412  cubic_control[0].y >>= 1;
3413  }
3414  if (point+1 > outline->contours[contour])
3415  cubic_control[3] = outline->points[first_pt];
3416  else
3417  {
3418  cubic_control[3] = outline->points[point+1];
3419  if (!(outline->tags[point+1] & FT_Curve_Tag_On))
3420  {
3421  cubic_control[3].x += outline->points[point].x + 1;
3422  cubic_control[3].y += outline->points[point].y + 1;
3423  cubic_control[3].x >>= 1;
3424  cubic_control[3].y >>= 1;
3425  }
3426  }
3427  /* r1 = 1/3 p0 + 2/3 p1
3428  r2 = 1/3 p2 + 2/3 p1 */
3429  cubic_control[1].x = (2 * outline->points[point].x + 1) / 3;
3430  cubic_control[1].y = (2 * outline->points[point].y + 1) / 3;
3431  cubic_control[2] = cubic_control[1];
3432  cubic_control[1].x += (cubic_control[0].x + 1) / 3;
3433  cubic_control[1].y += (cubic_control[0].y + 1) / 3;
3434  cubic_control[2].x += (cubic_control[3].x + 1) / 3;
3435  cubic_control[2].y += (cubic_control[3].y + 1) / 3;
3436  if (buf)
3437  {
3438  FTVectorToPOINTFX(&cubic_control[1], &ppc->apfx[cpfx]);
3439  FTVectorToPOINTFX(&cubic_control[2], &ppc->apfx[cpfx+1]);
3440  FTVectorToPOINTFX(&cubic_control[3], &ppc->apfx[cpfx+2]);
3441  }
3442  cpfx += 3;
3443  point++;
3444  }
3445  } while (point <= outline->contours[contour] &&
3446  (outline->tags[point] & FT_Curve_Tag_On) ==
3447  (outline->tags[point-1] & FT_Curve_Tag_On));
3448  /* At the end of a contour Windows adds the start point,
3449  but only for Beziers and we've already done that.
3450  */
3451  if (point <= outline->contours[contour] &&
3452  outline->tags[point] & FT_Curve_Tag_On)
3453  {
3454  /* This is the closing pt of a bezier, but we've already
3455  added it, so just inc point and carry on */
3456  point++;
3457  }
3458  if (buf)
3459  {
3460  ppc->wType = type;
3461  ppc->cpfx = cpfx;
3462  }
3463  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3464  }
3465  if (buf)
3466  pph->cb = needed - pph_start;
3467  }
3468  return needed;
3469 }
#define FT_Curve_Tag_On
Definition: ftimage.h:465
FT_Pos y
Definition: ftimage.h:77
#define TT_POLYGON_TYPE
Definition: wingdi.h:1318
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:368
FT_Pos x
Definition: ftimage.h:76
POINTL point
Definition: edittest.c:50
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TT_PRIM_CSPLINE
Definition: wingdi.h:1321
POINTFX apfx[1]
Definition: wingdi.h:2714
unsigned long DWORD
Definition: ntddk_ex.h:95
POINTFX pfxStart
Definition: wingdi.h:2719
Definition: mesh.c:5329
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#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 3694 of file freetype.c.

3695 {
3696  FT_UInt ret;
3697 
3698  if (face_has_symbol_charmap(ft_face))
3699  {
3700  ret = get_glyph_index_symbol(ft_face, glyph);
3701  if (ret != 0)
3702  return ret;
3703  }
3704 
3705  return FT_Get_Char_Index(ft_face, glyph);
3706 }
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2110
FT_Get_Char_Index(FT_Face face, FT_ULong charcode)
Definition: ftobjs.c:3668
int ret
static FT_UInt FASTCALL get_glyph_index_symbol(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3680
unsigned int FT_UInt
Definition: fttypes.h:231

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

3710 {
3711  FT_UInt glyph_index;
3712  if (flags & indexed_flag)
3713  {
3714  glyph_index = code;
3715  }
3716  else
3717  {
3718  glyph_index = get_glyph_index(face, code);
3719  }
3720  return glyph_index;
3721 }
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3694
GLbitfield flags
Definition: glext.h:7161
Definition: inflate.c:139
int code
Definition: main.c:75
unsigned int FT_UInt
Definition: fttypes.h:231
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by ftGdiGetGlyphOutline(), ftGdiGetTextWidth(), IntExtTextOutW(), 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 3680 of file freetype.c.

3681 {
3682  FT_UInt ret;
3683 
3684  if (glyph < 0x100) glyph += 0xf000;
3685  /* there are a number of old pre-Unicode "broken" TTFs, which
3686  do have symbols at U+00XX instead of U+f0XX */
3687  if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
3688  ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
3689 
3690  return ret;
3691 }
FT_Get_Char_Index(FT_Face face, FT_ULong charcode)
Definition: ftobjs.c:3668
int ret
unsigned int FT_UInt
Definition: fttypes.h:231

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

3275 {
3276  TTPOLYGONHEADER *pph;
3277  TTPOLYCURVE *ppc;
3278  int needed = 0, point = 0, contour, first_pt;
3279  unsigned int pph_start, cpfx;
3280  DWORD type;
3281 
3282  for (contour = 0; contour < outline->n_contours; contour++)
3283  {
3284  /* Ignore contours containing one point */
3285  if (point == outline->contours[contour])
3286  {
3287  point++;
3288  continue;
3289  }
3290 
3291  pph_start = needed;
3292  pph = (TTPOLYGONHEADER *)(buf + needed);
3293  first_pt = point;
3294  if (buf)
3295  {
3296  pph->dwType = TT_POLYGON_TYPE;
3297  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3298  }
3299  needed += sizeof(*pph);
3300  point++;
3301  while (point <= outline->contours[contour])
3302  {
3303  ppc = (TTPOLYCURVE *)(buf + needed);
3304  type = (outline->tags[point] & FT_Curve_Tag_On) ?
3306  cpfx = 0;
3307  do
3308  {
3309  if (buf)
3310  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3311  cpfx++;
3312  point++;
3313  } while (point <= outline->contours[contour] &&
3314  (outline->tags[point] & FT_Curve_Tag_On) ==
3315  (outline->tags[point-1] & FT_Curve_Tag_On));
3316  /* At the end of a contour Windows adds the start point, but
3317  only for Beziers */
3318  if (point > outline->contours[contour] &&
3319  !(outline->tags[point-1] & FT_Curve_Tag_On))
3320  {
3321  if (buf)
3322  FTVectorToPOINTFX(&outline->points[first_pt], &ppc->apfx[cpfx]);
3323  cpfx++;
3324  }
3325  else if (point <= outline->contours[contour] &&
3326  outline->tags[point] & FT_Curve_Tag_On)
3327  {
3328  /* add closing pt for bezier */
3329  if (buf)
3330  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3331  cpfx++;
3332  point++;
3333  }
3334  if (buf)
3335  {
3336  ppc->wType = type;
3337  ppc->cpfx = cpfx;
3338  }
3339  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3340  }
3341  if (buf)
3342  pph->cb = needed - pph_start;
3343  }
3344  return needed;
3345 }
#define FT_Curve_Tag_On
Definition: ftimage.h:465
#define TT_POLYGON_TYPE
Definition: wingdi.h:1318
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:368
POINTL point
Definition: edittest.c:50
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TT_PRIM_QSPLINE
Definition: wingdi.h:1320
POINTFX apfx[1]
Definition: wingdi.h:2714
unsigned long DWORD
Definition: ntddk_ex.h:95
POINTFX pfxStart
Definition: wingdi.h:2719
Definition: mesh.c:5329
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define TT_PRIM_LINE
Definition: wingdi.h:1319

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

2982 {
2984  PFONT_ENTRY CurrentEntry;
2985  FONTGDI *FontGDI;
2986  FONTFAMILYINFO InfoEntry;
2987  LONG Count = *pCount;
2988 
2989  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
2990  {
2991  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
2992  FontGDI = CurrentEntry->Font;
2993  ASSERT(FontGDI);
2994 
2995  if (LogFont->lfCharSet != DEFAULT_CHARSET &&
2996  LogFont->lfCharSet != FontGDI->CharSet)
2997  {
2998  continue; /* charset mismatch */
2999  }
3000 
3001  /* get one info entry */
3002  FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
3003 
3004  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3005  {
3006  /* check name */
3007  if (_wcsnicmp(LogFont->lfFaceName,
3009  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
3010  _wcsnicmp(LogFont->lfFaceName,
3011  InfoEntry.EnumLogFontEx.elfFullName,
3012  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
3013  {
3014  continue;
3015  }
3016  }
3017 
3018  if (NominalName)
3019  {
3020  /* store the nominal name */
3022  sizeof(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
3023  NominalName);
3024  }
3025 
3026  /* store one entry to Info */
3027  if (0 <= Count && Count < MaxCount)
3028  {
3029  RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
3030  }
3031  Count++;
3032  }
3033 
3034  *pCount = Count;
3035 
3036  return TRUE;
3037 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2703
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
BYTE lfCharSet
Definition: dimm.idl:67
_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)
#define DEFAULT_CHARSET
Definition: wingdi.h:384
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Definition: font.h:4
static void FASTCALL FontFamilyFillInfo(PFONTFAMILYINFO Info, LPCWSTR FaceName, LPCWSTR FullName, PFONTGDI FontGDI)
Definition: freetype.c:2792
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
int Count
Definition: noreturn.cpp:7
#define ASSERT(a)
Definition: mode.c:44
Definition: typedefs.h:119
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
FONTGDI * Font
Definition: font.h:7
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define NULL
Definition: types.h:112
LOGFONTW elfLogFont
Definition: wingdi.h:2702
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
BYTE CharSet
Definition: engobjects.h:158
base of all file and directory entries
Definition: entries.h:82

Referenced by GetFontFamilyInfoForSubstitutes(), and IntGetFontFamilyInfo().

◆ GetFontFamilyInfoForSubstitutes()

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

Definition at line 3040 of file freetype.c.

3044 {
3045  PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
3046  PFONTSUBST_ENTRY pCurrentEntry;
3047  PUNICODE_STRING pFromW, pToW;
3048  LOGFONTW lf = *LogFont;
3050 
3051  for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
3052  {
3053  pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
3054 
3055  pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
3056  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3057  {
3058  /* check name */
3059  if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
3060  continue; /* mismatch */
3061  }
3062 
3063  pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
3064  if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
3065  pCurrentEntry->CharSets[FONTSUBST_FROM] ==
3066  pCurrentEntry->CharSets[FONTSUBST_TO])
3067  {
3068  /* identical mapping */
3069  continue;
3070  }
3071 
3072  /* substitute and get the real name */
3073  IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
3074  SubstituteFontRecurse(&lf);
3075  if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
3076  continue;
3077 
3078  /* search in global fonts */
3080  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
3082 
3083  /* search in private fonts */
3084  IntLockProcessPrivateFonts(Win32Process);
3085  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
3086  &Win32Process->PrivateFontListHead);
3087  IntUnLockProcessPrivateFonts(Win32Process);
3088 
3089  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3090  {
3091  /* it's already matched to the exact name and charset if the name
3092  was specified at here, then so don't scan more for another name */
3093  break;
3094  }
3095  }
3096 
3097  return TRUE;
3098 }
static LIST_ENTRY g_FontListHead
Definition: freetype.c:66
#define FONTSUBST_FROM
Definition: font.h:68
#define IntLockProcessPrivateFonts(W32Process)
Definition: text.h:147
#define TRUE
Definition: types.h:120
BYTE lfCharSet
Definition: dimm.idl:67
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:150
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define IntUnLockGlobalFonts()
Definition: freetype.c:73
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define UNICODE_NULL
#define FONTSUBST_TO
Definition: font.h:69
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
static BOOL SubstituteFontRecurse(LOGFONTW *pLogFont)
Definition: freetype.c:881
BYTE CharSets[FONTSUBST_FROM_AND_TO]
Definition: font.h:79
Definition: typedefs.h:119
#define IntLockGlobalFonts()
Definition: freetype.c:70
static BOOLEAN FASTCALL GetFontFamilyInfoForList(const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LPCWSTR NominalName, LONG *pCount, LONG MaxCount, PLIST_ENTRY Head)
Definition: freetype.c:2976
static VOID IntUnicodeStringToBuffer(LPWSTR pszBuffer, SIZE_T cbBuffer, const UNICODE_STRING *pString)
Definition: freetype.c:843
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
Definition: font.h:75
UNICODE_STRING FontNames[FONTSUBST_FROM_AND_TO]
Definition: font.h:78
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
LIST_ENTRY PrivateFontListHead
Definition: win32.h:284

Referenced by IntGetFontFamilyInfo().

◆ GetFontPenalty()

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

Definition at line 4690 of file freetype.c.

4693 {
4694  ULONG Penalty = 0;
4695  BYTE Byte;
4696  LONG Long;
4697  BOOL fNeedScaling = FALSE;
4698  const BYTE UserCharSet = CharSetFromLangID(gusLanguageID);
4699  const TEXTMETRICW * TM = &Otm->otmTextMetrics;
4700  WCHAR* ActualNameW;
4701 
4702  ASSERT(Otm);
4703  ASSERT(LogFont);
4704 
4705  /* FIXME: IntSizeSynth Penalty 20 */
4706  /* FIXME: SmallPenalty Penalty 1 */
4707  /* FIXME: FaceNameSubst Penalty 500 */
4708 
4709  Byte = LogFont->lfCharSet;
4710 
4711  if (Byte != TM->tmCharSet)
4712  {
4713  if (Byte != DEFAULT_CHARSET && Byte != ANSI_CHARSET)
4714  {
4715  /* CharSet Penalty 65000 */
4716  /* Requested charset does not match the candidate's. */
4717  GOT_PENALTY("CharSet", 65000);
4718  }
4719  else
4720  {
4721  if (UserCharSet != TM->tmCharSet)
4722  {
4723  /* UNDOCUMENTED: Not user language */
4724  GOT_PENALTY("UNDOCUMENTED:NotUserLanguage", 100);
4725 
4726  if (ANSI_CHARSET != TM->tmCharSet)
4727  {
4728  /* UNDOCUMENTED: Not ANSI charset */
4729  GOT_PENALTY("UNDOCUMENTED:NotAnsiCharSet", 100);
4730  }
4731  }
4732  }
4733  }
4734 
4735  Byte = LogFont->lfOutPrecision;
4736  switch (Byte)
4737  {
4738  case OUT_DEFAULT_PRECIS:
4739  /* nothing to do */
4740  break;
4741  case OUT_DEVICE_PRECIS:
4742  if (!(TM->tmPitchAndFamily & TMPF_DEVICE) ||
4744  {
4745  /* OutputPrecision Penalty 19000 */
4746  /* Requested OUT_STROKE_PRECIS, but the device can't do it
4747  or the candidate is not a vector font. */
4748  GOT_PENALTY("OutputPrecision", 19000);
4749  }
4750  break;
4751  default:
4753  {
4754  /* OutputPrecision Penalty 19000 */
4755  /* Or OUT_STROKE_PRECIS not requested, and the candidate
4756  is a vector font that requires GDI support. */
4757  GOT_PENALTY("OutputPrecision", 19000);
4758  }
4759  break;
4760  }
4761 
4762  Byte = (LogFont->lfPitchAndFamily & 0x0F);
4763  if (Byte == DEFAULT_PITCH)
4764  Byte = VARIABLE_PITCH;
4765  if (Byte == FIXED_PITCH)
4766  {
4768  {
4769  /* FixedPitch Penalty 15000 */
4770  /* Requested a fixed pitch font, but the candidate is a
4771  variable pitch font. */
4772  GOT_PENALTY("FixedPitch", 15000);
4773  }
4774  }
4775  if (Byte == VARIABLE_PITCH)
4776  {
4778  {
4779  /* PitchVariable Penalty 350 */
4780  /* Requested a variable pitch font, but the candidate is not a
4781  variable pitch font. */
4782  GOT_PENALTY("PitchVariable", 350);
4783  }
4784  }
4785 
4786  Byte = (LogFont->lfPitchAndFamily & 0x0F);
4787  if (Byte == DEFAULT_PITCH)
4788  {
4790  {
4791  /* DefaultPitchFixed Penalty 1 */
4792  /* Requested DEFAULT_PITCH, but the candidate is fixed pitch. */
4793  GOT_PENALTY("DefaultPitchFixed", 1);
4794  }
4795  }
4796 
4797  ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
4798 
4799  if (LogFont->lfFaceName[0] != UNICODE_NULL)
4800  {
4801  BOOL Found = FALSE;
4802 
4803  /* localized family name */
4804  if (!Found)
4805  {
4806  Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
4807  }
4808  /* localized full name */
4809  if (!Found)
4810  {
4811  ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFaceName);
4812  Found = (