ReactOS  0.4.15-dev-439-g292f67a
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)
 
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, PMATRIX pmx)
 
VOID FtSetCoordinateTransform (FT_Face face, PMATRIX 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)
 
static FT_Error IntRequestFontSize (PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
 
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 APIENTRY 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 BOOL SameScaleMatrix (PMATRIX pmx1, PMATRIX pmx2)
 
FT_BitmapGlyph APIENTRY ftGdiGlyphCacheGet (FT_Face Face, INT GlyphIndex, INT Height, FT_Render_Mode RenderMode, PMATRIX pmx)
 
FT_BitmapGlyph APIENTRY ftGdiGlyphSet (FT_Face Face, FT_GlyphSlot GlyphSlot, FT_Render_Mode RenderMode)
 
FT_BitmapGlyph APIENTRY ftGdiGlyphCacheSet (FT_Face Face, INT GlyphIndex, INT Height, PMATRIX pmx, FT_GlyphSlot GlyphSlot, FT_Render_Mode RenderMode)
 
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)
 
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)
 
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, LPCWSTR lfFaceName, 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)
 
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 4676 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 1077 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 6639 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 2580 of file freetype.c.

2581 {
2582  /* FIXME: Add more and fix if wrong */
2583  switch (PRIMARYLANGID(LangID))
2584  {
2585  case LANG_CHINESE:
2586  switch (SUBLANGID(LangID))
2587  {
2589  return CHINESEBIG5_CHARSET;
2591  default:
2592  break;
2593  }
2594  return GB2312_CHARSET;
2595 
2596  case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
2597  case LANG_SLOVAK: case LANG_SLOVENIAN: case LANG_ROMANIAN:
2598  return EASTEUROPE_CHARSET;
2599 
2600  case LANG_RUSSIAN: case LANG_BULGARIAN: case LANG_MACEDONIAN:
2601  case LANG_SERBIAN: case LANG_UKRAINIAN:
2602  return RUSSIAN_CHARSET;
2603 
2604  case LANG_ARABIC: return ARABIC_CHARSET;
2605  case LANG_GREEK: return GREEK_CHARSET;
2606  case LANG_HEBREW: return HEBREW_CHARSET;
2607  case LANG_JAPANESE: return SHIFTJIS_CHARSET;
2608  case LANG_KOREAN: return JOHAB_CHARSET;
2609  case LANG_TURKISH: return TURKISH_CHARSET;
2610  case LANG_THAI: return THAI_CHARSET;
2611  case LANG_LATVIAN: return BALTIC_CHARSET;
2612  case LANG_VIETNAMESE: return VIETNAMESE_CHARSET;
2613 
2614  case LANG_ENGLISH: case LANG_BASQUE: case LANG_CATALAN:
2615  case LANG_DANISH: case LANG_DUTCH: case LANG_FINNISH:
2616  case LANG_FRENCH: case LANG_GERMAN: case LANG_ITALIAN:
2617  case LANG_NORWEGIAN: case LANG_PORTUGUESE: case LANG_SPANISH:
2618  case LANG_SWEDISH: default:
2619  return ANSI_CHARSET;
2620  }
2621 }
#define LANG_BASQUE
Definition: nls.h:34
#define SUBLANG_CHINESE_TRADITIONAL
Definition: nls.h:208
#define EASTEUROPE_CHARSET
Definition: wingdi.h:398
#define LANG_THAI
Definition: nls.h:132
#define LANG_HUNGARIAN
Definition: nls.h:69
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:389
#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:391
#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:396
#define SHIFTJIS_CHARSET
Definition: wingdi.h:385
#define LANG_DANISH
Definition: nls.h:48
#define LANG_RUSSIAN
Definition: nls.h:113
#define RUSSIAN_CHARSET
Definition: wingdi.h:395
#define LANG_ENGLISH
Definition: nls.h:52
#define GB2312_CHARSET
Definition: wingdi.h:388
#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:401
#define HEBREW_CHARSET
Definition: wingdi.h:392
#define LANG_UKRAINIAN
Definition: nls.h:139
#define ARABIC_CHARSET
Definition: wingdi.h:393
#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:382
#define JOHAB_CHARSET
Definition: wingdi.h:400
#define BALTIC_CHARSET
Definition: wingdi.h:394
#define GREEK_CHARSET
Definition: wingdi.h:390
#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:148
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
PSHARED_FACE SharedFace
Definition: engobjects.h:142
#define GDITAG_PFF
Definition: tags.h:148
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 881 of file freetype.c.

882 {
884  UNICODE_STRING Tmp;
885 
886  Tmp.Buffer = ExAllocatePoolWithTag(PagedPool, Source->MaximumLength, TAG_USTR);
887  if (Tmp.Buffer)
888  {
889  Tmp.MaximumLength = Source->MaximumLength;
890  Tmp.Length = 0;
892 
894  Destination->Length = Tmp.Length;
895  Destination->Buffer = Tmp.Buffer;
896 
898  }
899 
900  return Status;
901 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2937
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TAG_USTR
Definition: libsupp.c:111
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by IntGdiAddFontResourceEx(), and IntGetFontLocalizedName().

◆ EqualFamilyInfo()

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

Definition at line 5334 of file freetype.c.

5335 {
5336  const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5337  const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5338  const LOGFONTW *plf1 = &pLog1->elfLogFont;
5339  const LOGFONTW *plf2 = &pLog2->elfLogFont;
5340 
5341  if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5342  {
5343  return FALSE;
5344  }
5345 
5346  if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5347  {
5348  return FALSE;
5349  }
5350 
5351  return TRUE;
5352 }
#define TRUE
Definition: types.h:120
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:2703
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
LOGFONTW elfLogFont
Definition: wingdi.h:2701
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 2116 of file freetype.c.

2117 {
2118  int i;
2119 
2120  for(i = 0; i < ft_face->num_charmaps; i++)
2121  {
2122  if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
2123  ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
2124  {
2125  return TRUE;
2126  }
2127  }
2128  return FALSE;
2129 }
#define TRUE
Definition: types.h:120
FT_CharMap * charmaps
Definition: freetype.h:1085
#define TT_PLATFORM_MICROSOFT
Definition: font.c:1174
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FT_Encoding encoding
Definition: freetype.h:843
FT_Int num_charmaps
Definition: freetype.h:1084
FT_UShort platform_id
Definition: freetype.h:844

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

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

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

5029 {
5030  ULONG Penalty;
5032  PFONT_ENTRY CurrentEntry;
5033  FONTGDI *FontGDI;
5034  OUTLINETEXTMETRICW *Otm = NULL;
5035  UINT OtmSize, OldOtmSize = 0;
5036  FT_Face Face;
5037 
5038  ASSERT(FontObj);
5039  ASSERT(MatchPenalty);
5040  ASSERT(LogFont);
5041  ASSERT(Head);
5042 
5043  /* Start with a pretty big buffer */
5044  OldOtmSize = 0x200;
5045  Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5046 
5047  /* get the FontObj of lowest penalty */
5048  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5049  {
5050  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5051 
5052  FontGDI = CurrentEntry->Font;
5053  ASSERT(FontGDI);
5054  Face = FontGDI->SharedFace->Face;
5055 
5056  /* get text metrics */
5057  OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
5058  if (OtmSize > OldOtmSize)
5059  {
5060  if (Otm)
5062  Otm = ExAllocatePoolWithTag(PagedPool, OtmSize, GDITAG_TEXT);
5063  }
5064 
5065  /* update FontObj if lowest penalty */
5066  if (Otm)
5067  {
5068  IntLockFreeType();
5069  IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5071 
5072  OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm);
5073  if (!OtmSize)
5074  continue;
5075 
5076  OldOtmSize = OtmSize;
5077 
5078  Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5079  if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty)
5080  {
5081  *FontObj = GDIToObj(FontGDI, FONT);
5082  *MatchPenalty = Penalty;
5083  }
5084  }
5085  }
5086 
5087  if (Otm)
5089 }
struct _Entry Entry
Definition: kefuncs.h:627
LONG lfHeight
Definition: dimm.idl:59
static UINT GetFontPenalty(const LOGFONTW *LogFont, const OUTLINETEXTMETRICW *Otm, const char *style_name)
Definition: freetype.c:4680
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2433
LONG lfWidth
Definition: dimm.idl:60
smooth NULL
Definition: ftsmooth.c:416
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:120
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3481
#define IntUnLockFreeType()
Definition: freetype.c:82
FT_Face Face
Definition: engobjects.h:129
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IntLockFreeType()
Definition: freetype.c:79
Definition: typedefs.h:118
#define GDITAG_TEXT
Definition: tags.h:171
PSHARED_FACE SharedFace
Definition: engobjects.h:142
FONTGDI * Font
Definition: font.h:7
unsigned int UINT
Definition: ndis.h:50
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:181

Referenced by TextIntRealizeFont().

◆ FontFamilyFillInfo()

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

Definition at line 2798 of file freetype.c.

2800 {
2801  ANSI_STRING StyleA;
2802  UNICODE_STRING StyleW;
2803  TT_OS2 *pOS2;
2804  FONTSIGNATURE fs;
2805  CHARSETINFO CharSetInfo;
2806  unsigned i, Size;
2807  OUTLINETEXTMETRICW *Otm;
2808  LOGFONTW *Lf;
2809  TEXTMETRICW *TM;
2810  NEWTEXTMETRICW *Ntm;
2811  DWORD fs0;
2812  NTSTATUS status;
2813  PSHARED_FACE SharedFace = FontGDI->SharedFace;
2814  FT_Face Face = SharedFace->Face;
2815  UNICODE_STRING NameW;
2816 
2817  RtlInitUnicodeString(&NameW, NULL);
2818  RtlZeroMemory(Info, sizeof(FONTFAMILYINFO));
2819  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
2821  if (!Otm)
2822  {
2823  return;
2824  }
2825  Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm);
2826  if (!Size)
2827  {
2829  return;
2830  }
2831 
2832  Lf = &Info->EnumLogFontEx.elfLogFont;
2833  TM = &Otm->otmTextMetrics;
2834 
2835  Lf->lfHeight = TM->tmHeight;
2836  Lf->lfWidth = TM->tmAveCharWidth;
2837  Lf->lfWeight = TM->tmWeight;
2838  Lf->lfItalic = TM->tmItalic;
2839  Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
2840  Lf->lfCharSet = TM->tmCharSet;
2843  Lf->lfQuality = PROOF_QUALITY;
2844 
2845  Ntm = &Info->NewTextMetricEx.ntmTm;
2846  Ntm->tmHeight = TM->tmHeight;
2847  Ntm->tmAscent = TM->tmAscent;
2848  Ntm->tmDescent = TM->tmDescent;
2851  Ntm->tmAveCharWidth = TM->tmAveCharWidth;
2852  Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
2853  Ntm->tmWeight = TM->tmWeight;
2854  Ntm->tmOverhang = TM->tmOverhang;
2857  Ntm->tmFirstChar = TM->tmFirstChar;
2858  Ntm->tmLastChar = TM->tmLastChar;
2859  Ntm->tmDefaultChar = TM->tmDefaultChar;
2860  Ntm->tmBreakChar = TM->tmBreakChar;
2861  Ntm->tmItalic = TM->tmItalic;
2862  Ntm->tmUnderlined = TM->tmUnderlined;
2863  Ntm->tmStruckOut = TM->tmStruckOut;
2865  Ntm->tmCharSet = TM->tmCharSet;
2866  Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
2867 
2868  if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
2869 
2870  if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
2871 
2872  Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
2873  ? TRUETYPE_FONTTYPE : 0);
2874 
2875  if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
2876  Info->FontType |= RASTER_FONTTYPE;
2877 
2878 
2879  /* face name */
2880  if (!FaceName)
2881  FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
2882 
2883  RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
2884 
2885  /* full name */
2886  if (!FullName)
2887  FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
2888 
2889  RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
2890  sizeof(Info->EnumLogFontEx.elfFullName),
2891  FullName);
2892 
2893  RtlInitAnsiString(&StyleA, Face->style_name);
2894  StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
2895  StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
2896  status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
2897  if (!NT_SUCCESS(status))
2898  {
2900  return;
2901  }
2902  Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
2903 
2904  IntLockFreeType();
2905  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
2906 
2907  if (!pOS2)
2908  {
2911  return;
2912  }
2913 
2914  Ntm->ntmSizeEM = Otm->otmEMSquare;
2915  Ntm->ntmCellHeight = (FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent;
2916  Ntm->ntmAvgWidth = 0;
2917 
2919 
2920  fs.fsCsb[0] = pOS2->ulCodePageRange1;
2921  fs.fsCsb[1] = pOS2->ulCodePageRange2;
2922  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
2923  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
2924  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
2925  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
2926 
2927  if (0 == pOS2->version)
2928  {
2929  FT_UInt Dummy;
2930 
2931  if (FT_Get_First_Char(Face, &Dummy) < 0x100)
2932  fs.fsCsb[0] |= FS_LATIN1;
2933  else
2934  fs.fsCsb[0] |= FS_SYMBOL;
2935  }
2937 
2938  if (fs.fsCsb[0] == 0)
2939  {
2940  /* Let's see if we can find any interesting cmaps */
2941  for (i = 0; i < (UINT)Face->num_charmaps; i++)
2942  {
2943  switch (Face->charmaps[i]->encoding)
2944  {
2945  case FT_ENCODING_UNICODE:
2946  case FT_ENCODING_APPLE_ROMAN:
2947  fs.fsCsb[0] |= FS_LATIN1;
2948  break;
2949  case FT_ENCODING_MS_SYMBOL:
2950  fs.fsCsb[0] |= FS_SYMBOL;
2951  break;
2952  default:
2953  break;
2954  }
2955  }
2956  }
2957 
2958  for (i = 0; i < MAXTCIINDEX; i++)
2959  {
2960  fs0 = 1L << i;
2961  if (fs.fsCsb[0] & fs0)
2962  {
2963  if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
2964  {
2965  CharSetInfo.ciCharset = DEFAULT_CHARSET;
2966  }
2967  if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
2968  {
2969  if (g_ElfScripts[i])
2970  wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
2971  else
2972  {
2973  DPRINT1("Unknown elfscript for bit %u\n", i);
2974  }
2975  }
2976  }
2977  }
2978  Info->NewTextMetricEx.ntmFontSig = fs;
2979 }
WCHAR tmFirstChar
Definition: wingdi.h:2654
LONG tmMaxCharWidth
Definition: wingdi.h:2388
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:2398
FT_CharMap * charmaps
Definition: freetype.h:1085
BYTE lfPitchAndFamily
Definition: dimm.idl:71
LONG tmExternalLeading
Definition: wingdi.h:2386
#define ft_sfnt_os2
Definition: tttables.h:631
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TCI_SRCFONTSIG
Definition: wingdi.h:962
LONG tmAveCharWidth
Definition: wingdi.h:2387
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
BYTE lfCharSet
Definition: dimm.idl:67
LONG tmDigitizedAspectX
Definition: wingdi.h:2652
BYTE lfClipPrecision
Definition: dimm.idl:69
WCHAR tmDefaultChar
Definition: wingdi.h:2656
#define NTM_BOLD
Definition: wingdi.h:1315
LONG tmDescent
Definition: wingdi.h:2384
LONG tmAscent
Definition: wingdi.h:2383
LONG tmInternalLeading
Definition: wingdi.h:2385
Definition: fs.h:235
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define PROOF_QUALITY
Definition: wingdi.h:437
LONG tmDigitizedAspectY
Definition: wingdi.h:2653
#define MAXTCIINDEX
Definition: freetype.c:123
struct TraceInfo Info
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:64
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
#define UNICODE_NULL
#define TMPF_TRUETYPE
Definition: wingdi.h:1312
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
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:1545
BYTE tmPitchAndFamily
Definition: wingdi.h:2400
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2433
LONG lfWidth
Definition: dimm.idl:60
smooth NULL
Definition: ftsmooth.c:416
WCHAR tmBreakChar
Definition: wingdi.h:2396
FT_UShort version
Definition: tttables.h:382
BYTE tmStruckOut
Definition: wingdi.h:2399
BYTE lfOutPrecision
Definition: dimm.idl:68
LONG tmMaxCharWidth
Definition: wingdi.h:2649
#define OUT_OUTLINE_PRECIS
Definition: wingdi.h:422
static BOOLEAN APIENTRY IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2069
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FS_SYMBOL
Definition: wingdi.h:574
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
WCHAR tmLastChar
Definition: wingdi.h:2655
BYTE tmPitchAndFamily
Definition: wingdi.h:2661
LONG tmOverhang
Definition: wingdi.h:2390
FT_Face Face
Definition: engobjects.h:129
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RASTER_FONTTYPE
Definition: wingdi.h:1106
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:2401
_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:1316
static const WCHAR L[]
Definition: oid.c:1250
#define IntLockFreeType()
Definition: freetype.c:79
signed short FT_Short
Definition: fttypes.h:198
LONG tmInternalLeading
Definition: wingdi.h:2646
LONG tmDigitizedAspectY
Definition: wingdi.h:2392
LONG tmExternalLeading
Definition: wingdi.h:2647
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
FT_Int num_charmaps
Definition: freetype.h:1084
#define TMPF_VECTOR
Definition: wingdi.h:1311
FT_ULong ulCodePageRange1
Definition: tttables.h:419
#define GDITAG_TEXT
Definition: tags.h:171
UINT ntmCellHeight
Definition: wingdi.h:2665
PSHARED_FACE SharedFace
Definition: engobjects.h:142
WCHAR tmBreakChar
Definition: wingdi.h:2657
#define fs
Definition: i386-dis.c:435
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
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2513
FT_UShort usWinAscent
Definition: tttables.h:414
WCHAR tmDefaultChar
Definition: wingdi.h:2395
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:559
LONG tmAveCharWidth
Definition: wingdi.h:2648
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG tmWeight
Definition: wingdi.h:2389
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
LONG tmHeight
Definition: wingdi.h:2382
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
LONG lfWeight
Definition: dimm.idl:63
#define NTM_ITALIC
Definition: wingdi.h:1314
static SERVICE_STATUS status
Definition: service.c:31
BYTE tmItalic
Definition: wingdi.h:2397
WCHAR tmFirstChar
Definition: wingdi.h:2393
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1108
FT_ULong ulUnicodeRange2
Definition: tttables.h:402
WCHAR tmLastChar
Definition: wingdi.h:2394
LONG tmDigitizedAspectX
Definition: wingdi.h:2391
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 4638 of file freetype.c.

4644 {
4646  FT_Face Face = FontGdi->SharedFace->Face;
4647 
4648  IntLockFreeType();
4649 
4650  if (FT_IS_SFNT(Face))
4651  {
4652  if (Table)
4653  Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
4654  (Table << 8 & 0xFF0000);
4655 
4656  if (!Buffer) Size = 0;
4657 
4658  if (Buffer && Size)
4659  {
4660  FT_Error Error;
4661  FT_ULong Needed = 0;
4662 
4663  Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
4664 
4665  if ( !Error && Needed < Size) Size = Needed;
4666  }
4667  if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
4668  Result = Size;
4669  }
4670 
4672 
4673  return Result;
4674 }
int FT_Error
Definition: fttypes.h:300
ASMGENDATA Table[]
Definition: genincdata.c:61
unsigned long FT_ULong
Definition: fttypes.h:253
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
_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:129
#define IntLockFreeType()
Definition: freetype.c:79
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
PSHARED_FACE SharedFace
Definition: engobjects.h:142
#define GDI_ERROR
Definition: wingdi.h:1308

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

3746 {
3747  PDC_ATTR pdcattr;
3748  PTEXTOBJ TextObj;
3749  PFONTGDI FontGDI;
3750  HFONT hFont = 0;
3751  GLYPHMETRICS gm;
3752  ULONG Size;
3753  FT_Face ft_face;
3754  FT_UInt glyph_index;
3755  DWORD width, height, pitch, needed = 0;
3756  FT_Bitmap ft_bitmap;
3757  FT_Error error;
3758  INT left, right, top = 0, bottom = 0;
3760  FLOATOBJ eM11, widthRatio, eTemp;
3761  FT_Matrix transMat = identityMat;
3762  BOOL needsTransform = FALSE;
3763  INT orientation;
3764  LONG aveWidth;
3765  INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
3766  OUTLINETEXTMETRICW *potm;
3767  XFORMOBJ xo;
3768  XFORML xform;
3769  LOGFONTW *plf;
3770 
3771  DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
3772  cjBuf, pvBuf, pmat2);
3773 
3774  pdcattr = dc->pdcattr;
3775 
3776  XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
3777  XFORMOBJ_iGetXform(&xo, &xform);
3778  FLOATOBJ_SetFloat(&eM11, xform.eM11);
3779 
3780  hFont = pdcattr->hlfntNew;
3781  TextObj = RealizeFontInit(hFont);
3782 
3783  if (!TextObj)
3784  {
3786  return GDI_ERROR;
3787  }
3788  FontGDI = ObjToGDI(TextObj->Font, FONT);
3789  ft_face = FontGDI->SharedFace->Face;
3790 
3791  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
3792  aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
3793  orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
3794 
3795  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
3797  if (!potm)
3798  {
3800  TEXTOBJ_UnlockText(TextObj);
3801  return GDI_ERROR;
3802  }
3803  Size = IntGetOutlineTextMetrics(FontGDI, Size, potm);
3804  if (!Size)
3805  {
3806  /* FIXME: last error? */
3808  TEXTOBJ_UnlockText(TextObj);
3809  return GDI_ERROR;
3810  }
3811 
3812  IntLockFreeType();
3813  TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
3815 
3816  TEXTOBJ_UnlockText(TextObj);
3817 
3818  glyph_index = get_glyph_index_flagged(ft_face, wch, GGO_GLYPH_INDEX, iFormat);
3820 
3821  if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
3822  load_flags |= FT_LOAD_NO_BITMAP;
3823 
3824  if (iFormat & GGO_UNHINTED)
3825  {
3826  load_flags |= FT_LOAD_NO_HINTING;
3827  iFormat &= ~GGO_UNHINTED;
3828  }
3829 
3830  error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
3831  if (error)
3832  {
3833  DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
3835  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
3836  return GDI_ERROR;
3837  }
3839 
3840  FLOATOBJ_Set1(&widthRatio);
3841  if (aveWidth && potm)
3842  {
3843  // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
3844  FLOATOBJ_SetLong(&widthRatio, aveWidth);
3845  FLOATOBJ_Mul(&widthRatio, &eM11);
3846  FLOATOBJ_DivLong(&widthRatio, potm->otmTextMetrics.tmAveCharWidth);
3847  }
3848 
3849  //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
3850  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
3851  FLOATOBJ_Mul(&eTemp, &widthRatio);
3852  left = FLOATOBJ_GetLong(&eTemp) & -64;
3853 
3854  //right = (INT)((ft_face->glyph->metrics.horiBearingX +
3855  // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
3856  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
3857  FLOATOBJ_Mul(&eTemp, &widthRatio);
3858  FLOATOBJ_AddLong(&eTemp, 63);
3859  right = FLOATOBJ_GetLong(&eTemp) & -64;
3860 
3861  //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
3862  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
3863  FLOATOBJ_Mul(&eTemp, &widthRatio);
3864  FLOATOBJ_AddLong(&eTemp, 63);
3865  adv = FLOATOBJ_GetLong(&eTemp) >> 6;
3866 
3867  lsb = left >> 6;
3868  bbx = (right - left) >> 6;
3869 
3870  DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
3871 
3872  IntLockFreeType();
3873 
3874  /* Width scaling transform */
3875  if (!FLOATOBJ_Equal1(&widthRatio))
3876  {
3877  FT_Matrix scaleMat;
3878 
3879  eTemp = widthRatio;
3880  FLOATOBJ_MulLong(&eTemp, 1 << 16);
3881 
3882  scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
3883  scaleMat.xy = 0;
3884  scaleMat.yx = 0;
3885  scaleMat.yy = INT_TO_FIXED(1);
3886  FT_Matrix_Multiply(&scaleMat, &transMat);
3887  needsTransform = TRUE;
3888  }
3889 
3890  /* World transform */
3891  {
3892  FT_Matrix ftmatrix;
3894 
3895  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
3896  FtMatrixFromMx(&ftmatrix, pmx);
3897 
3898  if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
3899  {
3900  FT_Matrix_Multiply(&ftmatrix, &transMat);
3901  needsTransform = TRUE;
3902  }
3903  }
3904 
3905  /* Rotation transform */
3906  if (orientation)
3907  {
3908  FT_Matrix rotationMat;
3909  DPRINT("Rotation Trans!\n");
3910  IntEscapeMatrix(&rotationMat, orientation);
3911  FT_Matrix_Multiply(&rotationMat, &transMat);
3912  needsTransform = TRUE;
3913  }
3914 
3915  /* Extra transformation specified by caller */
3916  if (pmat2)
3917  {
3918  FT_Matrix extraMat;
3919  DPRINT("MAT2 Matrix Trans!\n");
3920  extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
3921  extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
3922  extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
3923  extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
3924  FT_Matrix_Multiply(&extraMat, &transMat);
3925  needsTransform = TRUE;
3926  }
3927 
3928  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
3929 
3930  if (!needsTransform)
3931  {
3932  DPRINT("No Need to be Transformed!\n");
3933  top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
3934  bottom = (ft_face->glyph->metrics.horiBearingY -
3935  ft_face->glyph->metrics.height) & -64;
3936  gm.gmCellIncX = adv;
3937  gm.gmCellIncY = 0;
3938  }
3939  else
3940  {
3941  INT xc, yc;
3942  FT_Vector vec;
3943  for (xc = 0; xc < 2; xc++)
3944  {
3945  for (yc = 0; yc < 2; yc++)
3946  {
3947  vec.x = (ft_face->glyph->metrics.horiBearingX +
3948  xc * ft_face->glyph->metrics.width);
3949  vec.y = ft_face->glyph->metrics.horiBearingY -
3950  yc * ft_face->glyph->metrics.height;
3951  DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
3952  FT_Vector_Transform(&vec, &transMat);
3953  if (xc == 0 && yc == 0)
3954  {
3955  left = right = vec.x;
3956  top = bottom = vec.y;
3957  }
3958  else
3959  {
3960  if (vec.x < left) left = vec.x;
3961  else if (vec.x > right) right = vec.x;
3962  if (vec.y < bottom) bottom = vec.y;
3963  else if (vec.y > top) top = vec.y;
3964  }
3965  }
3966  }
3967  left = left & -64;
3968  right = (right + 63) & -64;
3969  bottom = bottom & -64;
3970  top = (top + 63) & -64;
3971 
3972  DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
3973  vec.x = ft_face->glyph->metrics.horiAdvance;
3974  vec.y = 0;
3975  FT_Vector_Transform(&vec, &transMat);
3976  gm.gmCellIncX = (vec.x+63) >> 6;
3977  gm.gmCellIncY = -((vec.y+63) >> 6);
3978  }
3979  gm.gmBlackBoxX = (right - left) >> 6;
3980  gm.gmBlackBoxY = (top - bottom) >> 6;
3981  gm.gmptGlyphOrigin.x = left >> 6;
3982  gm.gmptGlyphOrigin.y = top >> 6;
3983 
3984  DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
3985  gm.gmCellIncX, gm.gmCellIncY,
3986  gm.gmBlackBoxX, gm.gmBlackBoxY,
3988 
3990 
3991 
3992  if (iFormat == GGO_METRICS)
3993  {
3994  DPRINT("GGO_METRICS Exit!\n");
3995  *pgm = gm;
3996  return 1; /* FIXME */
3997  }
3998 
3999  if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
4000  {
4001  DPRINT1("Loaded a bitmap\n");
4002  return GDI_ERROR;
4003  }
4004 
4005  switch (iFormat)
4006  {
4007  case GGO_BITMAP:
4008  {
4009  width = gm.gmBlackBoxX;
4010  height = gm.gmBlackBoxY;
4011  pitch = ((width + 31) >> 5) << 2;
4012  needed = pitch * height;
4013 
4014  if (!pvBuf || !cjBuf) break;
4015  if (!needed) return GDI_ERROR; /* empty glyph */
4016  if (needed > cjBuf)
4017  return GDI_ERROR;
4018 
4019  switch (ft_face->glyph->format)
4020  {
4022  {
4023  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4024  INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4025  INT h = min( height, ft_face->glyph->bitmap.rows );
4026  while (h--)
4027  {
4028  RtlCopyMemory(dst, src, w);
4029  src += ft_face->glyph->bitmap.pitch;
4030  dst += pitch;
4031  }
4032  break;
4033  }
4034 
4036  {
4037  ft_bitmap.width = width;
4038  ft_bitmap.rows = height;
4039  ft_bitmap.pitch = pitch;
4040  ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4041  ft_bitmap.buffer = pvBuf;
4042 
4043  IntLockFreeType();
4044  if (needsTransform)
4045  {
4046  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4047  }
4048  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4049  /* Note: FreeType will only set 'black' bits for us. */
4050  RtlZeroMemory(pvBuf, needed);
4051  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4053  break;
4054  }
4055 
4056  default:
4057  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4058  return GDI_ERROR;
4059  }
4060 
4061  break;
4062  }
4063 
4064  case GGO_GRAY2_BITMAP:
4065  case GGO_GRAY4_BITMAP:
4066  case GGO_GRAY8_BITMAP:
4067  {
4068  unsigned int mult, row, col;
4069  BYTE *start, *ptr;
4070 
4071  width = gm.gmBlackBoxX;
4072  height = gm.gmBlackBoxY;
4073  pitch = (width + 3) / 4 * 4;
4074  needed = pitch * height;
4075 
4076  if (!pvBuf || !cjBuf) break;
4077  if (!needed) return GDI_ERROR; /* empty glyph */
4078  if (needed > cjBuf)
4079  return GDI_ERROR;
4080 
4081  switch (ft_face->glyph->format)
4082  {
4084  {
4085  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4086  INT h = min( height, ft_face->glyph->bitmap.rows );
4087  INT x;
4088  while (h--)
4089  {
4090  for (x = 0; (UINT)x < pitch; x++)
4091  {
4092  if (x < ft_face->glyph->bitmap.width)
4093  dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4094  else
4095  dst[x] = 0;
4096  }
4097  src += ft_face->glyph->bitmap.pitch;
4098  dst += pitch;
4099  }
4100  break;
4101  }
4103  {
4104  ft_bitmap.width = width;
4105  ft_bitmap.rows = height;
4106  ft_bitmap.pitch = pitch;
4107  ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4108  ft_bitmap.buffer = pvBuf;
4109 
4110  IntLockFreeType();
4111  if (needsTransform)
4112  {
4113  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4114  }
4115  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4116  RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4117  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4119 
4120  if (iFormat == GGO_GRAY2_BITMAP)
4121  mult = 4;
4122  else if (iFormat == GGO_GRAY4_BITMAP)
4123  mult = 16;
4124  else if (iFormat == GGO_GRAY8_BITMAP)
4125  mult = 64;
4126  else
4127  {
4128  return GDI_ERROR;
4129  }
4130 
4131  start = pvBuf;
4132  for (row = 0; row < height; row++)
4133  {
4134  ptr = start;
4135  for (col = 0; col < width; col++, ptr++)
4136  {
4137  *ptr = (((int)*ptr) * mult + 128) / 256;
4138  }
4139  start += pitch;
4140  }
4141 
4142  break;
4143  }
4144  default:
4145  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4146  return GDI_ERROR;
4147  }
4148 
4149  break;
4150  }
4151 
4152  case GGO_NATIVE:
4153  {
4154  FT_Outline *outline = &ft_face->glyph->outline;
4155 
4156  if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4157 
4158  IntLockFreeType();
4159  if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4160 
4162 
4163  if (!pvBuf || !cjBuf)
4164  {
4166  break;
4167  }
4168  if (needed > cjBuf)
4169  {
4171  return GDI_ERROR;
4172  }
4175  break;
4176  }
4177 
4178  case GGO_BEZIER:
4179  {
4180  FT_Outline *outline = &ft_face->glyph->outline;
4181  if (cjBuf == 0) pvBuf = NULL;
4182 
4183  if (needsTransform && pvBuf)
4184  {
4185  IntLockFreeType();
4186  FT_Outline_Transform(outline, &transMat);
4188  }
4190 
4191  if (!pvBuf || !cjBuf)
4192  break;
4193  if (needed > cjBuf)
4194  return GDI_ERROR;
4195 
4197  break;
4198  }
4199 
4200  default:
4201  DPRINT1("Unsupported format %u\n", iFormat);
4202  return GDI_ERROR;
4203  }
4204 
4205  DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4206 
4207  if (gm.gmBlackBoxX == 0)
4208  gm.gmBlackBoxX = 1;
4209  if (gm.gmBlackBoxY == 0)
4210  gm.gmBlackBoxY = 1;
4211 
4212  *pgm = gm;
4213  return needed;
4214 }
#define abs(i)
Definition: fconv.c:206
int FT_Error
Definition: fttypes.h:300
GLint GLint GLsizei width
Definition: gl.h:1546
FT_Pos y
Definition: ftimage.h:77
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FLOATL eM11
Definition: winddi.h:1234
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define GGO_METRICS
Definition: wingdi.h:847
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_Pos x
Definition: ftimage.h:76
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define FLOATOBJ_Set1(fo)
Definition: floatobj.h:120
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:2387
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#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
unsigned char * buffer
Definition: ftimage.h:266
#define FLOATOBJ_GetLong(pf)
Definition: winddi.h:2817
#define GGO_GRAY4_BITMAP
Definition: wingdi.h:852
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
short gmCellIncY
Definition: wingdi.h:2445
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:57
HFONT hFont
Definition: main.c:53
#define GGO_BITMAP
Definition: wingdi.h:848
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:853
#define GGO_BEZIER
Definition: wingdi.h:850
#define FLOATOBJ_SetFloat(pf, f)
Definition: winddi.h:2814
FT_Fixed xx
Definition: fttypes.h:387
BOOL FASTCALL TextIntUpdateSize(PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:3599
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:334
static PVOID ptr
Definition: dispmode.c:27
#define GGO_NATIVE
Definition: wingdi.h:849
#define FLOATOBJ_AddLong(pf, l)
Definition: winddi.h:2820
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2433
LONG lfWidth
Definition: dimm.idl:60
smooth NULL
Definition: ftsmooth.c:416
FT_Library g_FreeTypeLibrary
Definition: freetype.c:55
void DPRINT(...)
Definition: polytest.cpp:61
GLint GLint bottom
Definition: glext.h:7726
FIXED eM22
Definition: wingdi.h:2475
FIXED eM11
Definition: wingdi.h:2472
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
FIXED eM21
Definition: wingdi.h:2474
#define ft_glyph_format_outline
Definition: ftimage.h:732
#define ft_glyph_format_bitmap
Definition: ftimage.h:731
VOID FASTCALL FtMatrixFromMx(FT_Matrix *pmat, PMATRIX pmx)
Definition: freetype.c:752
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
POINT gmptGlyphOrigin
Definition: wingdi.h:2443
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:3283
FT_Face Face
Definition: engobjects.h:129
FT_Vector * vec
Definition: ftbbox.c:448
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define GGO_UNHINTED
Definition: wingdi.h:855
VOID FtSetCoordinateTransform(FT_Face face, PMATRIX pmx)
Definition: freetype.c:775
#define GGO_GLYPH_INDEX
Definition: wingdi.h:854
_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:3356
#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:3717
FIXED eM12
Definition: wingdi.h:2473
GLenum src
Definition: glext.h:6340
FT_Bitmap bitmap
Definition: freetype.h:1923
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Definition: mesh.c:5329
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
unsigned char BYTE
Definition: xxhash.c:193
short gmCellIncX
Definition: wingdi.h:2444
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:171
PSHARED_FACE SharedFace
Definition: engobjects.h:142
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:2442
#define min(a, b)
Definition: monoChain.cc:55
#define GGO_GRAY2_BITMAP
Definition: wingdi.h:851
unsigned int UINT
Definition: ndis.h:50
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2513
#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:2701
UINT gmBlackBoxX
Definition: wingdi.h:2441
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:107
static const WCHAR dc[]
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:98
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3012
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
FT_Fixed yx
Definition: fttypes.h:388
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2778
FT_Fixed yy
Definition: fttypes.h:388
#define INT_TO_FIXED(x)
Definition: ftcalc.h:404
#define FLOATOBJ_Mul(pf, pf1)
Definition: winddi.h:2824
#define GDI_ERROR
Definition: wingdi.h:1308
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
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 5655 of file freetype.c.

5658 {
5659  DWORD Count = 0;
5660  INT i = 0;
5661  FT_Face face = Font->SharedFace->Face;
5662 
5663  if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
5664  {
5665  FT_UInt previous_index = 0, glyph_index = 0;
5666  FT_ULong char_code, char_previous;
5667  FT_Vector delta;
5668 
5669  char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
5670 
5671  IntLockFreeType();
5672 
5673  while (glyph_index)
5674  {
5675  if (previous_index && glyph_index)
5676  {
5677  FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
5678 
5679  if (pKerningPair && cPairs)
5680  {
5681  pKerningPair[i].wFirst = char_previous;
5682  pKerningPair[i].wSecond = char_code;
5683  pKerningPair[i].iKernAmount = delta.x;
5684  i++;
5685  if (i == cPairs) break;
5686  }
5687  Count++;
5688  }
5689  previous_index = glyph_index;
5690  char_previous = char_code;
5691  char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
5692  }
5694  }
5695  return Count;
5696 }
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:2464
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
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int32_t INT
Definition: typedefs.h:57
#define FT_HAS_KERNING(face)
Definition: freetype.h:1297
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int iKernAmount
Definition: wingdi.h:2465
#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
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 3108 of file freetype.c.

3109 {
3110  if ( lprs )
3111  {
3112  lprs->nSize = sizeof(RASTERIZER_STATUS);
3113  lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3114  lprs->nLanguageID = gusLanguageID;
3115  return TRUE;
3116  }
3118  return FALSE;
3119 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
struct _RASTERIZER_STATUS RASTERIZER_STATUS
#define TT_AVAILABLE
Definition: wingdi.h:887
USHORT gusLanguageID
Definition: main.c:29
#define TT_ENABLED
Definition: wingdi.h:888
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by NtGdiGetRasterizerCaps().

◆ ftGdiGetTextCharsetInfo()

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

Definition at line 4361 of file freetype.c.

4365 {
4366  PDC_ATTR pdcattr;
4367  UINT Ret = DEFAULT_CHARSET;
4368  INT i;
4369  HFONT hFont;
4370  PTEXTOBJ TextObj;
4371  PFONTGDI FontGdi;
4372  FONTSIGNATURE fs;
4373  TT_OS2 *pOS2;
4374  FT_Face Face;
4375  CHARSETINFO csi;
4376  DWORD cp, fs0;
4377  USHORT usACP, usOEM;
4378 
4379  pdcattr = Dc->pdcattr;
4380  hFont = pdcattr->hlfntNew;
4381  TextObj = RealizeFontInit(hFont);
4382 
4383  if (!TextObj)
4384  {
4386  return Ret;
4387  }
4388  FontGdi = ObjToGDI(TextObj->Font, FONT);
4389  Face = FontGdi->SharedFace->Face;
4390  TEXTOBJ_UnlockText(TextObj);
4391 
4392  memset(&fs, 0, sizeof(FONTSIGNATURE));
4393  IntLockFreeType();
4394  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4395  if (NULL != pOS2)
4396  {
4397  fs.fsCsb[0] = pOS2->ulCodePageRange1;
4398  fs.fsCsb[1] = pOS2->ulCodePageRange2;
4399  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
4400  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
4401  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
4402  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
4403  if (pOS2->version == 0)
4404  {
4405  FT_UInt dummy;
4406 
4407  if (FT_Get_First_Char( Face, &dummy ) < 0x100)
4408  fs.fsCsb[0] |= FS_LATIN1;
4409  else
4410  fs.fsCsb[0] |= FS_SYMBOL;
4411  }
4412  }
4413  pOS2 = NULL;
4415  DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
4416  if (fs.fsCsb[0] == 0)
4417  { /* Let's see if we can find any interesting cmaps */
4418  for (i = 0; i < Face->num_charmaps; i++)
4419  {
4420  switch (Face->charmaps[i]->encoding)
4421  {
4422  case FT_ENCODING_UNICODE:
4423  case FT_ENCODING_APPLE_ROMAN:
4424  fs.fsCsb[0] |= FS_LATIN1;
4425  break;
4426  case FT_ENCODING_MS_SYMBOL:
4427  fs.fsCsb[0] |= FS_SYMBOL;
4428  break;
4429  default:
4430  break;
4431  }
4432  }
4433  }
4434  if (lpSig)
4435  {
4436  RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
4437  }
4438 
4439  RtlGetDefaultCodePage(&usACP, &usOEM);
4440  cp = usACP;
4441 
4443  if (csi.fs.fsCsb[0] & fs.fsCsb[0])
4444  {
4445  DPRINT("Hit 1\n");
4446  Ret = csi.ciCharset;
4447  goto Exit;
4448  }
4449 
4450  for (i = 0; i < MAXTCIINDEX; i++)
4451  {
4452  fs0 = 1L << i;
4453  if (fs.fsCsb[0] & fs0)
4454  {
4455  if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
4456  {
4457  // *cp = csi.ciACP;
4458  DPRINT("Hit 2\n");
4459  Ret = csi.ciCharset;
4460  goto Exit;
4461  }
4462  else
4463  DPRINT1("TCI failing on %x\n", fs0);
4464  }
4465  }
4466 Exit:
4467  DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
4468  return (MAKELONG(csi.ciACP, csi.ciCharset));
4469 }
FONTSIGNATURE fs
Definition: wingdi.h:1547
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FT_CharMap * charmaps
Definition: freetype.h:1085
#define ft_sfnt_os2
Definition: tttables.h:631
#define TCI_SRCFONTSIG
Definition: wingdi.h:962
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
Definition: fs.h:235
#define DEFAULT_CHARSET
Definition: wingdi.h:383
int32_t INT
Definition: typedefs.h:57
#define MAXTCIINDEX
Definition: freetype.c:123
HFONT hFont
Definition: main.c:53
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:334
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
UINT ciCharset
Definition: wingdi.h:1545
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
FT_UShort version
Definition: tttables.h:382
void DPRINT(...)
Definition: polytest.cpp:61
NTSYSAPI VOID NTAPI RtlGetDefaultCodePage(_Out_ PUSHORT AnsiCodePage, _Out_ PUSHORT OemCodePage)
static BOOLEAN APIENTRY IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2069
#define FS_SYMBOL
Definition: wingdi.h:574
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:129
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
FT_Encoding encoding
Definition: freetype.h:843
static const WCHAR L[]
Definition: oid.c:1250
#define IntLockFreeType()
Definition: freetype.c:79
FT_Int num_charmaps
Definition: freetype.h:1084
FONTOBJ * Font
Definition: text.h:66
DWORD fsCsb[2]
Definition: wingdi.h:1542
FT_ULong ulCodePageRange1
Definition: tttables.h:419
PSHARED_FACE SharedFace
Definition: engobjects.h:142
unsigned short USHORT
Definition: pedump.c:61
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
#define fs
Definition: i386-dis.c:435
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
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:961
#define FS_LATIN1
Definition: wingdi.h:559
POINT cp
Definition: magnifier.c:59
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define memset(x, y, z)
Definition: compat.h:39
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
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 4542 of file freetype.c.

4545 {
4546  PDC dc;
4547  PDC_ATTR pdcattr;
4548  PTEXTOBJ TextObj;
4549  PFONTGDI FontGDI;
4550  FT_Face Face;
4551  TT_OS2 *pOS2;
4552  TT_HoriHeader *pHori;
4553  FT_WinFNT_HeaderRec Win;
4554  ULONG Error;
4556  LOGFONTW *plf;
4557 
4558  if (!ptmwi)
4559  {
4561  return FALSE;
4562  }
4563 
4564  if (!(dc = DC_LockDc(hDC)))
4565  {
4567  return FALSE;
4568  }
4569  pdcattr = dc->pdcattr;
4570  TextObj = RealizeFontInit(pdcattr->hlfntNew);
4571  if (NULL != TextObj)
4572  {
4573  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4574  FontGDI = ObjToGDI(TextObj->Font, FONT);
4575 
4576  Face = FontGDI->SharedFace->Face;
4577 
4578  IntLockFreeType();
4579  Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4582 
4583  if (0 != Error)
4584  {
4585  DPRINT1("Error in setting pixel sizes: %u\n", Error);
4587  }
4588  else
4589  {
4590  FT_Face Face = FontGDI->SharedFace->Face;
4592 
4593  IntLockFreeType();
4594  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4595  if (NULL == pOS2)
4596  {
4597  DPRINT1("Can't find OS/2 table - not TT font?\n");
4599  }
4600 
4601  pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
4602  if (NULL == pHori)
4603  {
4604  DPRINT1("Can't find HHEA table - not TT font?\n");
4606  }
4607 
4608  Error = FT_Get_WinFNT_Header(Face, &Win);
4609 
4610  if (NT_SUCCESS(Status) || !Error)
4611  {
4612  FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
4613 
4614  /* FIXME: Fill Diff member */
4615  RtlZeroMemory(&ptmwi->Diff, sizeof(ptmwi->Diff));
4616  }
4617 
4619  }
4620  TEXTOBJ_UnlockText(TextObj);
4621  }
4622  else
4623  {
4625  }
4626  DC_UnlockDc(dc);
4627 
4628  if (!NT_SUCCESS(Status))
4629  {
4631  return FALSE;
4632  }
4633  return TRUE;
4634 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
#define TRUE
Definition: types.h:120
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FT_Get_WinFNT_Header(FT_Face face, FT_WinFNT_HeaderRec *aheader)
Definition: ftwinfnt.c:29
#define ft_sfnt_os2
Definition: tttables.h:631
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:334
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:2132
LONG lfWidth
Definition: dimm.idl:60
smooth NULL
Definition: ftsmooth.c:416
#define ft_sfnt_hhea
Definition: tttables.h:632
Definition: polytest.cpp:40
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3481
#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:129
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID FtSetCoordinateTransform(FT_Face face, PMATRIX pmx)
Definition: freetype.c:775
#define IntLockFreeType()
Definition: freetype.c:79
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
Status
Definition: gdiplustypes.h:24
static HDC hDC
Definition: 3dtext.c:33
FONTOBJ * Font
Definition: text.h:66
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PSHARED_FACE SharedFace
Definition: engobjects.h:142
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
#define DPRINT1
Definition: precomp.h:8
TMDIFF Diff
Definition: ntgdityp.h:371
LOGFONTW elfLogFont
Definition: wingdi.h:2701
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
static const WCHAR dc[]
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:98
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2778
return STATUS_SUCCESS
Definition: btrfs.c:3014
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

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

◆ ftGdiGlyphCacheGet()

FT_BitmapGlyph APIENTRY ftGdiGlyphCacheGet ( FT_Face  Face,
INT  GlyphIndex,
INT  Height,
FT_Render_Mode  RenderMode,
PMATRIX  pmx 
)

Definition at line 3134 of file freetype.c.

3140 {
3141  PLIST_ENTRY CurrentEntry;
3142  PFONT_CACHE_ENTRY FontEntry;
3143 
3145 
3146  for (CurrentEntry = g_FontCacheListHead.Flink;
3147  CurrentEntry != &g_FontCacheListHead;
3148  CurrentEntry = CurrentEntry->Flink)
3149  {
3150  FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
3151  if ((FontEntry->Face == Face) &&
3152  (FontEntry->GlyphIndex == GlyphIndex) &&
3153  (FontEntry->Height == Height) &&
3154  (FontEntry->RenderMode == RenderMode) &&
3155  (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx)))
3156  break;
3157  }
3158 
3159  if (CurrentEntry == &g_FontCacheListHead)
3160  {
3161  return NULL;
3162  }
3163 
3164  RemoveEntryList(CurrentEntry);
3165  InsertHeadList(&g_FontCacheListHead, CurrentEntry);
3166  return FontEntry->BitmapGlyph;
3167 }
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FT_BitmapGlyph BitmapGlyph
Definition: font.h:31
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
int GlyphIndex
Definition: font.h:29
smooth NULL
Definition: ftsmooth.c:416
FT_Face Face
Definition: font.h:30
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
MATRIX mxWorldToDevice
Definition: font.h:36
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
static BOOL SameScaleMatrix(PMATRIX pmx1, PMATRIX pmx2)
Definition: freetype.c:3123
int Height
Definition: font.h:32
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:93
Definition: font.h:26
Definition: typedefs.h:118
FT_Render_Mode RenderMode
Definition: font.h:35

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ ftGdiGlyphCacheSet()

FT_BitmapGlyph APIENTRY ftGdiGlyphCacheSet ( FT_Face  Face,
INT  GlyphIndex,
INT  Height,
PMATRIX  pmx,
FT_GlyphSlot  GlyphSlot,
FT_Render_Mode  RenderMode 
)

Definition at line 3212 of file freetype.c.

3219 {
3220  FT_Glyph GlyphCopy;
3221  INT error;
3222  PFONT_CACHE_ENTRY NewEntry;
3223  FT_Bitmap AlignedBitmap;
3224  FT_BitmapGlyph BitmapGlyph;
3225 
3227 
3228  error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
3229  if (error)
3230  {
3231  DPRINT1("Failure caching glyph.\n");
3232  return NULL;
3233  };
3234 
3235  error = FT_Glyph_To_Bitmap(&GlyphCopy, RenderMode, 0, 1);
3236  if (error)
3237  {
3238  FT_Done_Glyph(GlyphCopy);
3239  DPRINT1("Failure rendering glyph.\n");
3240  return NULL;
3241  };
3242 
3244  if (!NewEntry)
3245  {
3246  DPRINT1("Alloc failure caching glyph.\n");
3247  FT_Done_Glyph(GlyphCopy);
3248  return NULL;
3249  }
3250 
3251  BitmapGlyph = (FT_BitmapGlyph)GlyphCopy;
3252  FT_Bitmap_New(&AlignedBitmap);
3253  if(FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3254  {
3255  DPRINT1("Conversion failed\n");
3256  ExFreePoolWithTag(NewEntry, TAG_FONT);
3257  FT_Bitmap_Done(GlyphSlot->library, &AlignedBitmap);
3258  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3259  return NULL;
3260  }
3261 
3262  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3263  BitmapGlyph->bitmap = AlignedBitmap;
3264 
3265  NewEntry->GlyphIndex = GlyphIndex;
3266  NewEntry->Face = Face;
3267  NewEntry->BitmapGlyph = BitmapGlyph;
3268  NewEntry->Height = Height;
3269  NewEntry->RenderMode = RenderMode;
3270  NewEntry->mxWorldToDevice = *pmx;
3271 
3274  {
3276  RemoveCachedEntry(NewEntry);
3277  }
3278 
3279  return BitmapGlyph;
3280 }
FT_Bitmap bitmap
Definition: ftglyph.h:165
#define error(str)
Definition: mkdosfs.c:1605
static UINT g_FontCacheNumEntries
Definition: freetype.c:94
struct _LIST_ENTRY * Blink
Definition: typedefs.h:121
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FT_BitmapGlyph BitmapGlyph
Definition: font.h:31
#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:57
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:127
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
int GlyphIndex
Definition: font.h:29
FT_Bitmap_Convert(FT_Library library, const FT_Bitmap *source, FT_Bitmap *target, FT_Int alignment)
Definition: ftbitmap.c:504
smooth NULL
Definition: ftsmooth.c:416
#define MAX_FONT_CACHE
Definition: freetype.c:91
FT_Face Face
Definition: font.h:30
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
MATRIX mxWorldToDevice
Definition: font.h:36
static void RemoveCachedEntry(PFONT_CACHE_ENTRY Entry)
Definition: freetype.c:257
LIST_ENTRY ListEntry
Definition: font.h:28
int Height
Definition: font.h:32
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:26
FT_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph)
Definition: ftglyph.c:363
FT_Render_Mode RenderMode
Definition: font.h:35
FT_Library library
Definition: freetype.h:1910
#define DPRINT1
Definition: precomp.h:8
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ ftGdiGlyphSet()

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

Definition at line 3171 of file freetype.c.

3175 {
3176  FT_Glyph Glyph;
3177  INT error;
3178  FT_Bitmap AlignedBitmap;
3179  FT_BitmapGlyph BitmapGlyph;
3180 
3181  error = FT_Get_Glyph(GlyphSlot, &Glyph);
3182  if (error)
3183  {
3184  DPRINT1("Failure getting glyph.\n");
3185  return NULL;
3186  }
3187 
3188  error = FT_Glyph_To_Bitmap(&Glyph, RenderMode, 0, 1);
3189  if (error)
3190  {
3191  FT_Done_Glyph(Glyph);
3192  DPRINT1("Failure rendering glyph.\n");
3193  return NULL;
3194  }
3195 
3196  BitmapGlyph = (FT_BitmapGlyph)Glyph;
3197  FT_Bitmap_New(&AlignedBitmap);
3198  if (FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3199  {
3200  DPRINT1("Conversion failed\n");
3201  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3202  return NULL;
3203  }
3204 
3205  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3206  BitmapGlyph->bitmap = AlignedBitmap;
3207 
3208  return BitmapGlyph;
3209 }
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:57
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:127
FT_Bitmap_Convert(FT_Library library, const FT_Bitmap *source, FT_Bitmap *target, FT_Int alignment)
Definition: ftbitmap.c:504
smooth NULL
Definition: ftsmooth.c:416
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 DPRINT1
Definition: precomp.h:8
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ ftGdiRealizationInfo()

BOOL FASTCALL ftGdiRealizationInfo ( PFONTGDI  Font,
PREALIZATION_INFO  Info 
)

Definition at line 5636 of file freetype.c.

5637 {
5638  if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
5639  Info->iTechnology = RI_TECH_BITMAP;
5640  else
5641  {
5642  if (FT_IS_SCALABLE(Font->SharedFace->Face))
5643  Info->iTechnology = RI_TECH_SCALABLE;
5644  else
5645  Info->iTechnology = RI_TECH_FIXED;
5646  }
5647  Info->iUniq = Font->FontObj.iUniq;
5648  Info->dwUnknown = -1;
5649  return TRUE;
5650 }
#define TRUE
Definition: types.h:120
#define RI_TECH_BITMAP
Definition: ntgdityp.h:271
struct TraceInfo Info
#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 4474 of file freetype.c.

4475 {
4476  DWORD size = 0;
4477  DWORD num_ranges = 0;
4478  FT_Face face = Font->SharedFace->Face;
4479 
4480  if (face->charmap->encoding == FT_ENCODING_UNICODE)
4481  {
4482  FT_UInt glyph_code = 0;
4483  FT_ULong char_code, char_code_prev;
4484 
4485  char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
4486 
4487  DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
4488  face->num_glyphs, glyph_code, char_code);
4489 
4490  if (!glyph_code) return 0;
4491 
4492  if (glyphset)
4493  {
4494  glyphset->ranges[0].wcLow = (USHORT)char_code;
4495  glyphset->ranges[0].cGlyphs = 0;
4496  glyphset->cGlyphsSupported = 0;
4497  }
4498 
4499  num_ranges = 1;
4500  while (glyph_code)
4501  {
4502  if (char_code < char_code_prev)
4503  {
4504  DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
4505  return 0;
4506  }
4507  if (char_code - char_code_prev > 1)
4508  {
4509  num_ranges++;
4510  if (glyphset)
4511  {
4512  glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
4513  glyphset->ranges[num_ranges - 1].cGlyphs = 1;
4514  glyphset->cGlyphsSupported++;
4515  }
4516  }
4517  else if (glyphset)
4518  {
4519  glyphset->ranges[num_ranges - 1].cGlyphs++;
4520  glyphset->cGlyphsSupported++;
4521  }
4522  char_code_prev = char_code;
4523  char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
4524  }
4525  }
4526  else
4527  DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
4528 
4529  size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
4530  if (glyphset)
4531  {
4532  glyphset->cbThis = size;
4533  glyphset->cRanges = num_ranges;
4534  glyphset->flAccel = 0;
4535  }
4536  return size;
4537 }
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
void DPRINT(...)
Definition: polytest.cpp:61
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
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by NtGdiGetFontUnicodeRanges().

◆ FtMatrixFromMx()

VOID FASTCALL FtMatrixFromMx ( FT_Matrix pmat,
PMATRIX  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);
764 
765  ef = pmx->efM12;
766  FLOATOBJ_MulLong(&ef, 0x00010000);
767  pmat->yx = FLOATOBJ_GetLong(&ef);
768 
769  ef = pmx->efM22;
770  FLOATOBJ_MulLong(&ef, 0x00010000);
771  pmat->yy = FLOATOBJ_GetLong(&ef);
772 }
FLOATOBJ efM21
Definition: ntgdityp.h:414
#define FLOATOBJ_GetLong(pf)
Definition: winddi.h:2817
FT_Fixed xx
Definition: fttypes.h:387
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
FLOAT FLOATOBJ
Definition: winddi.h:677
FLOATOBJ efM12
Definition: ntgdityp.h:413
FLOATOBJ efM22
Definition: ntgdityp.h:415
FT_Fixed xy
Definition: fttypes.h:387
FLOATOBJ efM11
Definition: ntgdityp.h:412
FT_Fixed yx
Definition: fttypes.h:388
FT_Fixed yy
Definition: fttypes.h:388

Referenced by ftGdiGetGlyphOutline().

◆ FtSetCoordinateTransform()

VOID FtSetCoordinateTransform ( FT_Face  face,
PMATRIX  pmx 
)

Definition at line 775 of file freetype.c.

778 {
779  FT_Matrix ftmatrix;
780  FLOATOBJ efTemp;
781 
782  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
783  efTemp = pmx->efM11;
784  FLOATOBJ_MulLong(&efTemp, 0x00010000);
785  ftmatrix.xx = FLOATOBJ_GetLong(&efTemp);
786 
787  efTemp = pmx->efM12;
788  FLOATOBJ_MulLong(&efTemp, 0x00010000);
789  ftmatrix.xy = FLOATOBJ_GetLong(&efTemp);
790 
791  efTemp = pmx->efM21;
792  FLOATOBJ_MulLong(&efTemp, 0x00010000);
793  ftmatrix.yx = FLOATOBJ_GetLong(&efTemp);
794 
795  efTemp = pmx->efM22;
796  FLOATOBJ_MulLong(&efTemp, 0x00010000);
797  ftmatrix.yy = FLOATOBJ_GetLong(&efTemp);
798 
799  /* Set the transformation matrix */
800  FT_Set_Transform(face, &ftmatrix, 0);
801 }
FLOATOBJ efM21
Definition: ntgdityp.h:414
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:653
#define FLOATOBJ_GetLong(pf)
Definition: winddi.h:2817
FT_Fixed xx
Definition: fttypes.h:387
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
FLOAT FLOATOBJ
Definition: winddi.h:677
FLOATOBJ efM12
Definition: ntgdityp.h:413
FLOATOBJ efM22
Definition: ntgdityp.h:415
FT_Fixed xy
Definition: fttypes.h:387
FLOATOBJ efM11
Definition: ntgdityp.h:412
FT_Fixed yx
Definition: fttypes.h:388
FT_Fixed yy
Definition: fttypes.h:388
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

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

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

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

Referenced by ftGdiGetGlyphOutline().

◆ get_glyph_index()

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

Definition at line 3702 of file freetype.c.

3703 {
3704  FT_UInt ret;
3705 
3706  if (face_has_symbol_charmap(ft_face))
3707  {
3708  ret = get_glyph_index_symbol(ft_face, glyph);
3709  if (ret != 0)
3710  return ret;
3711  }
3712 
3713  return FT_Get_Char_Index(ft_face, glyph);
3714 }
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2116
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:3688
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 3717 of file freetype.c.

3718 {
3719  FT_UInt glyph_index;
3720  if (flags & indexed_flag)
3721  {
3722  glyph_index = code;
3723  }
3724  else
3725  {
3726  glyph_index = get_glyph_index(face, code);
3727  }
3728  return glyph_index;
3729 }
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3702
GLbitfield flags
Definition: glext.h:7161
int code
Definition: i386-dis.c:3591
unsigned int FT_UInt
Definition: fttypes.h:231
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

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

3689 {
3690  FT_UInt ret;
3691 
3692  if (glyph < 0x100) glyph += 0xf000;
3693  /* there are a number of old pre-Unicode "broken" TTFs, which
3694  do have symbols at U+00XX instead of U+f0XX */
3695  if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
3696  ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
3697 
3698  return ret;
3699 }
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 3283 of file freetype.c.

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

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

2988 {
2990  PFONT_ENTRY CurrentEntry;
2991  FONTGDI *FontGDI;
2992  FONTFAMILYINFO InfoEntry;
2993  LONG Count = *pCount;
2994 
2995  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
2996  {
2997  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
2998  FontGDI = CurrentEntry->Font;
2999  ASSERT(FontGDI);
3000 
3001  if (LogFont->lfCharSet != DEFAULT_CHARSET &&
3002  LogFont->lfCharSet != FontGDI->CharSet)
3003  {
3004  continue; /* charset mismatch */
3005  }
3006 
3007  /* get one info entry */
3008  FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
3009 
3010  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3011  {
3012  /* check name */
3013  if (_wcsnicmp(LogFont->lfFaceName,
3015  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
3016  _wcsnicmp(LogFont->lfFaceName,
3017  InfoEntry.EnumLogFontEx.elfFullName,
3018  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
3019  {
3020  continue;
3021  }
3022  }
3023 
3024  if (NominalName)
3025  {
3026  /* store the nominal name */
3028  sizeof(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
3029  NominalName);
3030  }
3031 
3032  /* store one entry to Info */
3033  if (0 <= Count && Count < MaxCount)
3034  {
3035  RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
3036  }
3037  Count++;
3038  }
3039 
3040  *pCount = Count;
3041 
3042  return TRUE;
3043 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2702
struct _Entry Entry
Definition: kefuncs.h:627
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)
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define DEFAULT_CHARSET
Definition: wingdi.h:383
struct TraceInfo Info
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
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:2798
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:118
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
FONTGDI * Font
Definition: font.h:7
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
LOGFONTW elfLogFont
Definition: wingdi.h:2701
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
BYTE CharSet
Definition: engobjects.h:155
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 3046 of file freetype.c.

3050 {
3051  PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
3052  PFONTSUBST_ENTRY pCurrentEntry;
3053  PUNICODE_STRING pFromW, pToW;
3054  LOGFONTW lf = *LogFont;
3056 
3057  for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
3058  {
3059  pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
3060 
3061  pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
3062  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3063  {
3064  /* check name */
3065  if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
3066  continue; /* mismatch */
3067  }
3068 
3069  pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
3070  if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
3071  pCurrentEntry->CharSets[FONTSUBST_FROM] ==
3072  pCurrentEntry->CharSets[FONTSUBST_TO])
3073  {
3074  /* identical mapping */
3075  continue;
3076  }
3077 
3078  /* substitute and get the real name */
3079  IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
3080  SubstituteFontRecurse(&lf);
3081  if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
3082  continue;
3083 
3084  /* search in global fonts */
3086  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
3088 
3089  /* search in private fonts */
3090  IntLockProcessPrivateFonts(Win32Process);
3091  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
3092  &Win32Process->PrivateFontListHead);
3093  IntUnLockProcessPrivateFonts(Win32Process);
3094 
3095  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3096  {
3097  /* it's already matched to the exact name and charset if the name
3098  was specified at here, then so don't scan more for another name */
3099  break;
3100  }
3101  }
3102 
3103  return TRUE;
3104 }
static LIST_ENTRY g_FontListHead
Definition: freetype.c:66
#define FONTSUBST_FROM
Definition: font.h:43
#define TRUE
Definition: types.h:120
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:150
BYTE lfCharSet
Definition: dimm.idl:67
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define IntUnLockGlobalFonts()
Definition: freetype.c:73
struct TraceInfo Info
#define UNICODE_NULL
#define FONTSUBST_TO
Definition: font.h: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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
static BOOL SubstituteFontRecurse(LOGFONTW *pLogFont)
Definition: freetype.c:904
BYTE CharSets[FONTSUBST_FROM_AND_TO]
Definition: font.h:54
Definition: typedefs.h:118
#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:2982
static VOID IntUnicodeStringToBuffer(LPWSTR pszBuffer, SIZE_T cbBuffer, const UNICODE_STRING *pString)
Definition: freetype.c:866
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
Definition: font.h:50
UNICODE_STRING FontNames[FONTSUBST_FROM_AND_TO]
Definition: font.h:53
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)
#define IntLockProcessPrivateFonts(W32Process)
Definition: text.h:147
LIST_ENTRY PrivateFontListHead
Definition: win32.h:276

Referenced by IntGetFontFamilyInfo().

◆ GetFontPenalty()

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

Definition at line 4680 of file freetype.c.

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