ReactOS  0.4.14-dev-831-gef8c9239
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)
 
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)
 
FORCEINLINE 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 4775 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 6738 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 2685 of file freetype.c.

2686 {
2687  /* FIXME: Add more and fix if wrong */
2688  switch (PRIMARYLANGID(LangID))
2689  {
2690  case LANG_CHINESE:
2691  switch (SUBLANGID(LangID))
2692  {
2694  return CHINESEBIG5_CHARSET;
2696  default:
2697  break;
2698  }
2699  return GB2312_CHARSET;
2700 
2701  case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
2702  case LANG_SLOVAK: case LANG_SLOVENIAN: case LANG_ROMANIAN:
2703  return EASTEUROPE_CHARSET;
2704 
2705  case LANG_RUSSIAN: case LANG_BULGARIAN: case LANG_MACEDONIAN:
2706  case LANG_SERBIAN: case LANG_UKRAINIAN:
2707  return RUSSIAN_CHARSET;
2708 
2709  case LANG_ARABIC: return ARABIC_CHARSET;
2710  case LANG_GREEK: return GREEK_CHARSET;
2711  case LANG_HEBREW: return HEBREW_CHARSET;
2712  case LANG_JAPANESE: return SHIFTJIS_CHARSET;
2713  case LANG_KOREAN: return JOHAB_CHARSET;
2714  case LANG_TURKISH: return TURKISH_CHARSET;
2715  case LANG_THAI: return THAI_CHARSET;
2716  case LANG_LATVIAN: return BALTIC_CHARSET;
2717  case LANG_VIETNAMESE: return VIETNAMESE_CHARSET;
2718 
2719  case LANG_ENGLISH: case LANG_BASQUE: case LANG_CATALAN:
2720  case LANG_DANISH: case LANG_DUTCH: case LANG_FINNISH:
2721  case LANG_FRENCH: case LANG_GERMAN: case LANG_ITALIAN:
2722  case LANG_NORWEGIAN: case LANG_PORTUGUESE: case LANG_SPANISH:
2723  case LANG_SWEDISH: default:
2724  return ANSI_CHARSET;
2725  }
2726 }
#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(), IntGdiCleanupPrivateFontsForProcess(), and IntGdiLoadFontsFromMemory().

◆ 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(), and IntGdiLoadFontsFromMemory().

◆ 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:2922
#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:2938

Referenced by IntGdiAddFontResourceEx(), and IntGetFontLocalizedName().

◆ EqualFamilyInfo()

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

Definition at line 5433 of file freetype.c.

5434 {
5435  const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5436  const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5437  const LOGFONTW *plf1 = &pLog1->elfLogFont;
5438  const LOGFONTW *plf2 = &pLog2->elfLogFont;
5439 
5440  if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5441  {
5442  return FALSE;
5443  }
5444 
5445  if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5446  {
5447  return FALSE;
5448  }
5449 
5450  return TRUE;
5451 }
#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 2221 of file freetype.c.

2222 {
2223  int i;
2224 
2225  for(i = 0; i < ft_face->num_charmaps; i++)
2226  {
2227  if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
2228  ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
2229  {
2230  return TRUE;
2231  }
2232  }
2233  return FALSE;
2234 }
#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 2237 of file freetype.c.

2240 {
2241  FT_Fixed XScale, YScale;
2242  int Ascent, Descent;
2243  FT_Face Face = FontGDI->SharedFace->Face;
2244 
2246 
2247  XScale = Face->size->metrics.x_scale;
2248  YScale = Face->size->metrics.y_scale;
2249 
2250  if (pFNT)
2251  {
2252  TM->tmHeight = pFNT->pixel_height;
2253  TM->tmAscent = pFNT->ascent;
2254  TM->tmDescent = TM->tmHeight - TM->tmAscent;
2255  TM->tmInternalLeading = pFNT->internal_leading;
2256  TM->tmExternalLeading = pFNT->external_leading;
2257  TM->tmAveCharWidth = pFNT->avg_width;
2258  TM->tmMaxCharWidth = pFNT->max_width;
2259  TM->tmOverhang = 0;
2262  TM->tmFirstChar = pFNT->first_char;
2263  TM->tmLastChar = pFNT->last_char;
2264  TM->tmDefaultChar = pFNT->default_char + pFNT->first_char;
2265  TM->tmBreakChar = pFNT->break_char + pFNT->first_char;
2266  TM->tmPitchAndFamily = pFNT->pitch_and_family;
2267  TM->tmWeight = FontGDI->RequestWeight;
2268  TM->tmItalic = FontGDI->RequestItalic;
2269  TM->tmUnderlined = FontGDI->RequestUnderline;
2270  TM->tmStruckOut = FontGDI->RequestStrikeOut;
2271  TM->tmCharSet = FontGDI->CharSet;
2272  return;
2273  }
2274 
2275  ASSERT(pOS2);
2276  if (!pOS2)
2277  return;
2278 
2279  if ((FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent == 0)
2280  {
2281  Ascent = pHori->Ascender;
2282  Descent = -pHori->Descender;
2283  }
2284  else
2285  {
2286  Ascent = (FT_Short)pOS2->usWinAscent;
2287  Descent = (FT_Short)pOS2->usWinDescent;
2288  }
2289 
2290  TM->tmAscent = FontGDI->tmAscent;
2291  TM->tmDescent = FontGDI->tmDescent;
2292  TM->tmHeight = TM->tmAscent + TM->tmDescent;
2293  TM->tmInternalLeading = FontGDI->tmInternalLeading;
2294 
2295  /* MSDN says:
2296  * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
2297  */
2298  TM->tmExternalLeading = max(0, (FT_MulFix(pHori->Line_Gap
2299  - ((Ascent + Descent)
2300  - (pHori->Ascender - pHori->Descender)),
2301  YScale) + 32) >> 6);
2302 
2303  TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
2304  if (TM->tmAveCharWidth == 0)
2305  {
2306  TM->tmAveCharWidth = 1;
2307  }
2308 
2309  /* Correct forumla to get the maxcharwidth from unicode and ansi font */
2310  TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
2311 
2312  if (FontGDI->OriginalWeight != FW_DONTCARE &&
2313  FontGDI->OriginalWeight != FW_NORMAL)
2314  {
2315  TM->tmWeight = FontGDI->OriginalWeight;
2316  }
2317  else
2318  {
2319  TM->tmWeight = FontGDI->RequestWeight;
2320  }
2321 
2322  TM->tmOverhang = 0;
2323  TM->tmDigitizedAspectX = 96;
2324  TM->tmDigitizedAspectY = 96;
2325  if (face_has_symbol_charmap(Face) ||
2326  (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
2327  {
2328  USHORT cpOEM, cpAnsi;
2329 
2330  EngGetCurrentCodePage(&cpOEM, &cpAnsi);
2331  TM->tmFirstChar = 0;
2332  switch(cpAnsi)
2333  {
2334  case 1257: /* Baltic */
2335  TM->tmLastChar = 0xf8fd;
2336  break;
2337  default:
2338  TM->tmLastChar = 0xf0ff;
2339  }
2340  TM->tmBreakChar = 0x20;
2341  TM->tmDefaultChar = 0x1f;
2342  }
2343  else
2344  {
2345  TM->tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
2346  TM->tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
2347 
2348  if(pOS2->usFirstCharIndex <= 1)
2349  TM->tmBreakChar = pOS2->usFirstCharIndex + 2;
2350  else if (pOS2->usFirstCharIndex > 0xff)
2351  TM->tmBreakChar = 0x20;
2352  else
2353  TM->tmBreakChar = pOS2->usFirstCharIndex;
2354  TM->tmDefaultChar = TM->tmBreakChar - 1;
2355  }
2356 
2357  if (FontGDI->OriginalItalic || FontGDI->RequestItalic)
2358  {
2359  TM->tmItalic = 0xFF;
2360  }
2361  else
2362  {
2363  TM->tmItalic = 0;
2364  }
2365  TM->tmUnderlined = (FontGDI->RequestUnderline ? 0xFF : 0);
2366  TM->tmStruckOut = (FontGDI->RequestStrikeOut ? 0xFF : 0);
2367 
2368  if (!FT_IS_FIXED_WIDTH(Face))
2369  {
2370  switch (pOS2->panose[PAN_PROPORTION_INDEX])
2371  {
2372  case PAN_PROP_MONOSPACED:
2373  TM->tmPitchAndFamily = 0;
2374  break;
2375  default:
2377  break;
2378  }
2379  }
2380  else
2381  {
2382  TM->tmPitchAndFamily = 0;
2383  }
2384 
2385  switch (pOS2->panose[PAN_FAMILYTYPE_INDEX])
2386  {
2387  case PAN_FAMILY_SCRIPT:
2388  TM->tmPitchAndFamily |= FF_SCRIPT;
2389  break;
2390  case PAN_FAMILY_DECORATIVE:
2392  break;
2393 
2394  case PAN_ANY:
2395  case PAN_NO_FIT:
2397  case PAN_FAMILY_PICTORIAL: /* Symbol fonts get treated as if they were text */
2398  /* Which is clearly not what the panose spec says. */
2399  if (TM->tmPitchAndFamily == 0) /* Fixed */
2400  {
2402  }
2403  else
2404  {
2405  switch (pOS2->panose[PAN_SERIFSTYLE_INDEX])
2406  {
2407  case PAN_ANY:
2408  case PAN_NO_FIT:
2409  default:
2411  break;
2412 
2413  case PAN_SERIF_COVE:
2414  case PAN_SERIF_OBTUSE_COVE:
2415  case PAN_SERIF_SQUARE_COVE:
2417  case PAN_SERIF_SQUARE:
2418  case PAN_SERIF_THIN:
2419  case PAN_SERIF_BONE:
2420  case PAN_SERIF_EXAGGERATED:
2421  case PAN_SERIF_TRIANGLE:
2422  TM->tmPitchAndFamily |= FF_ROMAN;
2423  break;
2424 
2425  case PAN_SERIF_NORMAL_SANS:
2426  case PAN_SERIF_OBTUSE_SANS:
2427  case PAN_SERIF_PERP_SANS:
2428  case PAN_SERIF_FLARED:
2429  case PAN_SERIF_ROUNDED:
2430  TM->tmPitchAndFamily |= FF_SWISS;
2431  break;
2432  }
2433  }
2434  break;
2435  default:
2437  }
2438 
2439  if (FT_IS_SCALABLE(Face))
2440  {
2442  }
2443  if (FT_IS_SFNT(Face))
2444  {
2446  }
2447 
2448  TM->tmCharSet = FontGDI->CharSet;
2449 }
#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:2221
#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 5125 of file freetype.c.

5128 {
5129  ULONG Penalty;
5131  PFONT_ENTRY CurrentEntry;
5132  FONTGDI *FontGDI;
5133  OUTLINETEXTMETRICW *Otm = NULL;
5134  UINT OtmSize, OldOtmSize = 0;
5135  FT_Face Face;
5136 
5137  ASSERT(FontObj);
5138  ASSERT(MatchPenalty);
5139  ASSERT(LogFont);
5140  ASSERT(Head);
5141 
5142  /* Start with a pretty big buffer */
5143  OldOtmSize = 0x200;
5144  Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5145 
5146  /* get the FontObj of lowest penalty */
5147  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5148  {
5149  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5150 
5151  FontGDI = CurrentEntry->Font;
5152  ASSERT(FontGDI);
5153  Face = FontGDI->SharedFace->Face;
5154 
5155  /* get text metrics */
5156  OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
5157  if (OtmSize > OldOtmSize)
5158  {
5159  if (Otm)
5161  Otm = ExAllocatePoolWithTag(PagedPool, OtmSize, GDITAG_TEXT);
5162  }
5163 
5164  /* update FontObj if lowest penalty */
5165  if (Otm)
5166  {
5167  IntLockFreeType();
5168  IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5170 
5171  OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm);
5172  if (!OtmSize)
5173  continue;
5174 
5175  OldOtmSize = OtmSize;
5176 
5177  Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5178  if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty)
5179  {
5180  *FontObj = GDIToObj(FontGDI, FONT);
5181  *MatchPenalty = Penalty;
5182  }
5183  }
5184  }
5185 
5186  if (Otm)
5188 }
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:4779
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2538
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:119
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3586
#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:117
#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 2903 of file freetype.c.

2905 {
2906  ANSI_STRING StyleA;
2907  UNICODE_STRING StyleW;
2908  TT_OS2 *pOS2;
2909  FONTSIGNATURE fs;
2910  CHARSETINFO CharSetInfo;
2911  unsigned i, Size;
2912  OUTLINETEXTMETRICW *Otm;
2913  LOGFONTW *Lf;
2914  TEXTMETRICW *TM;
2915  NEWTEXTMETRICW *Ntm;
2916  DWORD fs0;
2917  NTSTATUS status;
2918  PSHARED_FACE SharedFace = FontGDI->SharedFace;
2919  FT_Face Face = SharedFace->Face;
2920  UNICODE_STRING NameW;
2921 
2922  RtlInitUnicodeString(&NameW, NULL);
2923  RtlZeroMemory(Info, sizeof(FONTFAMILYINFO));
2924  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
2926  if (!Otm)
2927  {
2928  return;
2929  }
2930  Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm);
2931  if (!Size)
2932  {
2934  return;
2935  }
2936 
2937  Lf = &Info->EnumLogFontEx.elfLogFont;
2938  TM = &Otm->otmTextMetrics;
2939 
2940  Lf->lfHeight = TM->tmHeight;
2941  Lf->lfWidth = TM->tmAveCharWidth;
2942  Lf->lfWeight = TM->tmWeight;
2943  Lf->lfItalic = TM->tmItalic;
2944  Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
2945  Lf->lfCharSet = TM->tmCharSet;
2948  Lf->lfQuality = PROOF_QUALITY;
2949 
2950  Ntm = &Info->NewTextMetricEx.ntmTm;
2951  Ntm->tmHeight = TM->tmHeight;
2952  Ntm->tmAscent = TM->tmAscent;
2953  Ntm->tmDescent = TM->tmDescent;
2956  Ntm->tmAveCharWidth = TM->tmAveCharWidth;
2957  Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
2958  Ntm->tmWeight = TM->tmWeight;
2959  Ntm->tmOverhang = TM->tmOverhang;
2962  Ntm->tmFirstChar = TM->tmFirstChar;
2963  Ntm->tmLastChar = TM->tmLastChar;
2964  Ntm->tmDefaultChar = TM->tmDefaultChar;
2965  Ntm->tmBreakChar = TM->tmBreakChar;
2966  Ntm->tmItalic = TM->tmItalic;
2967  Ntm->tmUnderlined = TM->tmUnderlined;
2968  Ntm->tmStruckOut = TM->tmStruckOut;
2970  Ntm->tmCharSet = TM->tmCharSet;
2971  Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
2972 
2973  if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
2974 
2975  if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
2976 
2977  Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
2978  ? TRUETYPE_FONTTYPE : 0);
2979 
2980  if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
2981  Info->FontType |= RASTER_FONTTYPE;
2982 
2983 
2984  /* face name */
2985  if (!FaceName)
2986  FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
2987 
2988  RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
2989 
2990  /* full name */
2991  if (!FullName)
2992  FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
2993 
2994  RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
2995  sizeof(Info->EnumLogFontEx.elfFullName),
2996  FullName);
2997 
2998  RtlInitAnsiString(&StyleA, Face->style_name);
2999  StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
3000  StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
3001  status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
3002  if (!NT_SUCCESS(status))
3003  {
3005  return;
3006  }
3007  Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
3008 
3009  IntLockFreeType();
3010  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
3011 
3012  if (!pOS2)
3013  {
3016  return;
3017  }
3018 
3019  Ntm->ntmSizeEM = Otm->otmEMSquare;
3020  Ntm->ntmCellHeight = (FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent;
3021  Ntm->ntmAvgWidth = 0;
3022 
3024 
3025  fs.fsCsb[0] = pOS2->ulCodePageRange1;
3026  fs.fsCsb[1] = pOS2->ulCodePageRange2;
3027  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
3028  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
3029  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
3030  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
3031 
3032  if (0 == pOS2->version)
3033  {
3034  FT_UInt Dummy;
3035 
3036  if (FT_Get_First_Char(Face, &Dummy) < 0x100)
3037  fs.fsCsb[0] |= FS_LATIN1;
3038  else
3039  fs.fsCsb[0] |= FS_SYMBOL;
3040  }
3042 
3043  if (fs.fsCsb[0] == 0)
3044  {
3045  /* Let's see if we can find any interesting cmaps */
3046  for (i = 0; i < (UINT)Face->num_charmaps; i++)
3047  {
3048  switch (Face->charmaps[i]->encoding)
3049  {
3050  case FT_ENCODING_UNICODE:
3051  case FT_ENCODING_APPLE_ROMAN:
3052  fs.fsCsb[0] |= FS_LATIN1;
3053  break;
3054  case FT_ENCODING_MS_SYMBOL:
3055  fs.fsCsb[0] |= FS_SYMBOL;
3056  break;
3057  default:
3058  break;
3059  }
3060  }
3061  }
3062 
3063  for (i = 0; i < MAXTCIINDEX; i++)
3064  {
3065  fs0 = 1L << i;
3066  if (fs.fsCsb[0] & fs0)
3067  {
3068  if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
3069  {
3070  CharSetInfo.ciCharset = DEFAULT_CHARSET;
3071  }
3072  if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
3073  {
3074  if (g_ElfScripts[i])
3075  wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
3076  else
3077  {
3078  DPRINT1("Unknown elfscript for bit %u\n", i);
3079  }
3080  }
3081  }
3082  }
3083  Info->NewTextMetricEx.ntmFontSig = fs;
3084 }
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:63
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:2538
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:2174
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:359
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 4737 of file freetype.c.

4743 {
4745  FT_Face Face = FontGdi->SharedFace->Face;
4746 
4747  IntLockFreeType();
4748 
4749  if (FT_IS_SFNT(Face))
4750  {
4751  if (Table)
4752  Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
4753  (Table << 8 & 0xFF0000);
4754 
4755  if (!Buffer) Size = 0;
4756 
4757  if (Buffer && Size)
4758  {
4759  FT_Error Error;
4760  FT_ULong Needed = 0;
4761 
4762  Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
4763 
4764  if ( !Error && Needed < Size) Size = Needed;
4765  }
4766  if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
4767  Result = Size;
4768  }
4769 
4771 
4772  return Result;
4773 }
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:359
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 3842 of file freetype.c.

3851 {
3852  PDC_ATTR pdcattr;
3853  PTEXTOBJ TextObj;
3854  PFONTGDI FontGDI;
3855  HFONT hFont = 0;
3856  GLYPHMETRICS gm;
3857  ULONG Size;
3858  FT_Face ft_face;
3859  FT_UInt glyph_index;
3860  DWORD width, height, pitch, needed = 0;
3861  FT_Bitmap ft_bitmap;
3862  FT_Error error;
3863  INT left, right, top = 0, bottom = 0;
3865  FLOATOBJ eM11, widthRatio, eTemp;
3866  FT_Matrix transMat = identityMat;
3867  BOOL needsTransform = FALSE;
3868  INT orientation;
3869  LONG aveWidth;
3870  INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
3871  OUTLINETEXTMETRICW *potm;
3872  XFORMOBJ xo;
3873  XFORML xform;
3874  LOGFONTW *plf;
3875 
3876  DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
3877  cjBuf, pvBuf, pmat2);
3878 
3879  pdcattr = dc->pdcattr;
3880 
3881  XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
3882  XFORMOBJ_iGetXform(&xo, &xform);
3883  FLOATOBJ_SetFloat(&eM11, xform.eM11);
3884 
3885  hFont = pdcattr->hlfntNew;
3886  TextObj = RealizeFontInit(hFont);
3887 
3888  if (!TextObj)
3889  {
3891  return GDI_ERROR;
3892  }
3893  FontGDI = ObjToGDI(TextObj->Font, FONT);
3894  ft_face = FontGDI->SharedFace->Face;
3895 
3896  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
3897  aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
3898  orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
3899 
3900  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
3902  if (!potm)
3903  {
3905  TEXTOBJ_UnlockText(TextObj);
3906  return GDI_ERROR;
3907  }
3908  Size = IntGetOutlineTextMetrics(FontGDI, Size, potm);
3909  if (!Size)
3910  {
3911  /* FIXME: last error? */
3913  TEXTOBJ_UnlockText(TextObj);
3914  return GDI_ERROR;
3915  }
3916 
3917  IntLockFreeType();
3918  TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
3920 
3921  TEXTOBJ_UnlockText(TextObj);
3922 
3923  glyph_index = get_glyph_index_flagged(ft_face, wch, GGO_GLYPH_INDEX, iFormat);
3925 
3926  if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
3927  load_flags |= FT_LOAD_NO_BITMAP;
3928 
3929  if (iFormat & GGO_UNHINTED)
3930  {
3931  load_flags |= FT_LOAD_NO_HINTING;
3932  iFormat &= ~GGO_UNHINTED;
3933  }
3934 
3935  error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
3936  if (error)
3937  {
3938  DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
3940  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
3941  return GDI_ERROR;
3942  }
3944 
3945  FLOATOBJ_Set1(&widthRatio);
3946  if (aveWidth && potm)
3947  {
3948  // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
3949  FLOATOBJ_SetLong(&widthRatio, aveWidth);
3950  FLOATOBJ_Mul(&widthRatio, &eM11);
3951  FLOATOBJ_DivLong(&widthRatio, potm->otmTextMetrics.tmAveCharWidth);
3952  }
3953 
3954  //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
3955  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
3956  FLOATOBJ_Mul(&eTemp, &widthRatio);
3957  left = FLOATOBJ_GetLong(&eTemp) & -64;
3958 
3959  //right = (INT)((ft_face->glyph->metrics.horiBearingX +
3960  // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
3961  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
3962  FLOATOBJ_Mul(&eTemp, &widthRatio);
3963  FLOATOBJ_AddLong(&eTemp, 63);
3964  right = FLOATOBJ_GetLong(&eTemp) & -64;
3965 
3966  //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
3967  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
3968  FLOATOBJ_Mul(&eTemp, &widthRatio);
3969  FLOATOBJ_AddLong(&eTemp, 63);
3970  adv = FLOATOBJ_GetLong(&eTemp) >> 6;
3971 
3972  lsb = left >> 6;
3973  bbx = (right - left) >> 6;
3974 
3975  DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
3976 
3977  IntLockFreeType();
3978 
3979  /* Width scaling transform */
3980  if (!FLOATOBJ_Equal1(&widthRatio))
3981  {
3982  FT_Matrix scaleMat;
3983 
3984  eTemp = widthRatio;
3985  FLOATOBJ_MulLong(&eTemp, 1 << 16);
3986 
3987  scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
3988  scaleMat.xy = 0;
3989  scaleMat.yx = 0;
3990  scaleMat.yy = INT_TO_FIXED(1);
3991  FT_Matrix_Multiply(&scaleMat, &transMat);
3992  needsTransform = TRUE;
3993  }
3994 
3995  /* World transform */
3996  {
3997  FT_Matrix ftmatrix;
3999 
4000  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
4001  FtMatrixFromMx(&ftmatrix, pmx);
4002 
4003  if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
4004  {
4005  FT_Matrix_Multiply(&ftmatrix, &transMat);
4006  needsTransform = TRUE;
4007  }
4008  }
4009 
4010  /* Rotation transform */
4011  if (orientation)
4012  {
4013  FT_Matrix rotationMat;
4014  DPRINT("Rotation Trans!\n");
4015  IntEscapeMatrix(&rotationMat, orientation);
4016  FT_Matrix_Multiply(&rotationMat, &transMat);
4017  needsTransform = TRUE;
4018  }
4019 
4020  /* Extra transformation specified by caller */
4021  if (pmat2)
4022  {
4023  FT_Matrix extraMat;
4024  DPRINT("MAT2 Matrix Trans!\n");
4025  extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
4026  extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
4027  extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
4028  extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
4029  FT_Matrix_Multiply(&extraMat, &transMat);
4030  needsTransform = TRUE;
4031  }
4032 
4033  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
4034 
4035  if (!needsTransform)
4036  {
4037  DPRINT("No Need to be Transformed!\n");
4038  top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
4039  bottom = (ft_face->glyph->metrics.horiBearingY -
4040  ft_face->glyph->metrics.height) & -64;
4041  gm.gmCellIncX = adv;
4042  gm.gmCellIncY = 0;
4043  }
4044  else
4045  {
4046  INT xc, yc;
4047  FT_Vector vec;
4048  for (xc = 0; xc < 2; xc++)
4049  {
4050  for (yc = 0; yc < 2; yc++)
4051  {
4052  vec.x = (ft_face->glyph->metrics.horiBearingX +
4053  xc * ft_face->glyph->metrics.width);
4054  vec.y = ft_face->glyph->metrics.horiBearingY -
4055  yc * ft_face->glyph->metrics.height;
4056  DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
4057  FT_Vector_Transform(&vec, &transMat);
4058  if (xc == 0 && yc == 0)
4059  {
4060  left = right = vec.x;
4061  top = bottom = vec.y;
4062  }
4063  else
4064  {
4065  if (vec.x < left) left = vec.x;
4066  else if (vec.x > right) right = vec.x;
4067  if (vec.y < bottom) bottom = vec.y;
4068  else if (vec.y > top) top = vec.y;
4069  }
4070  }
4071  }
4072  left = left & -64;
4073  right = (right + 63) & -64;
4074  bottom = bottom & -64;
4075  top = (top + 63) & -64;
4076 
4077  DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
4078  vec.x = ft_face->glyph->metrics.horiAdvance;
4079  vec.y = 0;
4080  FT_Vector_Transform(&vec, &transMat);
4081  gm.gmCellIncX = (vec.x+63) >> 6;
4082  gm.gmCellIncY = -((vec.y+63) >> 6);
4083  }
4084  gm.gmBlackBoxX = (right - left) >> 6;
4085  gm.gmBlackBoxY = (top - bottom) >> 6;
4086  gm.gmptGlyphOrigin.x = left >> 6;
4087  gm.gmptGlyphOrigin.y = top >> 6;
4088 
4089  DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
4090  gm.gmCellIncX, gm.gmCellIncY,
4091  gm.gmBlackBoxX, gm.gmBlackBoxY,
4093 
4095 
4096 
4097  if (iFormat == GGO_METRICS)
4098  {
4099  DPRINT("GGO_METRICS Exit!\n");
4100  *pgm = gm;
4101  return 1; /* FIXME */
4102  }
4103 
4104  if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
4105  {
4106  DPRINT1("Loaded a bitmap\n");
4107  return GDI_ERROR;
4108  }
4109 
4110  switch (iFormat)
4111  {
4112  case GGO_BITMAP:
4113  {
4114  width = gm.gmBlackBoxX;
4115  height = gm.gmBlackBoxY;
4116  pitch = ((width + 31) >> 5) << 2;
4117  needed = pitch * height;
4118 
4119  if (!pvBuf || !cjBuf) break;
4120  if (!needed) return GDI_ERROR; /* empty glyph */
4121  if (needed > cjBuf)
4122  return GDI_ERROR;
4123 
4124  switch (ft_face->glyph->format)
4125  {
4127  {
4128  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4129  INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4130  INT h = min( height, ft_face->glyph->bitmap.rows );
4131  while (h--)
4132  {
4133  RtlCopyMemory(dst, src, w);
4134  src += ft_face->glyph->bitmap.pitch;
4135  dst += pitch;
4136  }
4137  break;
4138  }
4139 
4141  {
4142  ft_bitmap.width = width;
4143  ft_bitmap.rows = height;
4144  ft_bitmap.pitch = pitch;
4145  ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4146  ft_bitmap.buffer = pvBuf;
4147 
4148  IntLockFreeType();
4149  if (needsTransform)
4150  {
4151  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4152  }
4153  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4154  /* Note: FreeType will only set 'black' bits for us. */
4155  RtlZeroMemory(pvBuf, needed);
4156  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4158  break;
4159  }
4160 
4161  default:
4162  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4163  return GDI_ERROR;
4164  }
4165 
4166  break;
4167  }
4168 
4169  case GGO_GRAY2_BITMAP:
4170  case GGO_GRAY4_BITMAP:
4171  case GGO_GRAY8_BITMAP:
4172  {
4173  unsigned int mult, row, col;
4174  BYTE *start, *ptr;
4175 
4176  width = gm.gmBlackBoxX;
4177  height = gm.gmBlackBoxY;
4178  pitch = (width + 3) / 4 * 4;
4179  needed = pitch * height;
4180 
4181  if (!pvBuf || !cjBuf) break;
4182  if (!needed) return GDI_ERROR; /* empty glyph */
4183  if (needed > cjBuf)
4184  return GDI_ERROR;
4185 
4186  switch (ft_face->glyph->format)
4187  {
4189  {
4190  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4191  INT h = min( height, ft_face->glyph->bitmap.rows );
4192  INT x;
4193  while (h--)
4194  {
4195  for (x = 0; (UINT)x < pitch; x++)
4196  {
4197  if (x < ft_face->glyph->bitmap.width)
4198  dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4199  else
4200  dst[x] = 0;
4201  }
4202  src += ft_face->glyph->bitmap.pitch;
4203  dst += pitch;
4204  }
4205  break;
4206  }
4208  {
4209  ft_bitmap.width = width;
4210  ft_bitmap.rows = height;
4211  ft_bitmap.pitch = pitch;
4212  ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4213  ft_bitmap.buffer = pvBuf;
4214 
4215  IntLockFreeType();
4216  if (needsTransform)
4217  {
4218  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4219  }
4220  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4221  RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4222  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4224 
4225  if (iFormat == GGO_GRAY2_BITMAP)
4226  mult = 4;
4227  else if (iFormat == GGO_GRAY4_BITMAP)
4228  mult = 16;
4229  else if (iFormat == GGO_GRAY8_BITMAP)
4230  mult = 64;
4231  else
4232  {
4233  return GDI_ERROR;
4234  }
4235 
4236  start = pvBuf;
4237  for (row = 0; row < height; row++)
4238  {
4239  ptr = start;
4240  for (col = 0; col < width; col++, ptr++)
4241  {
4242  *ptr = (((int)*ptr) * mult + 128) / 256;
4243  }
4244  start += pitch;
4245  }
4246 
4247  break;
4248  }
4249  default:
4250  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4251  return GDI_ERROR;
4252  }
4253 
4254  break;
4255  }
4256 
4257  case GGO_NATIVE:
4258  {
4259  FT_Outline *outline = &ft_face->glyph->outline;
4260 
4261  if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4262 
4263  IntLockFreeType();
4264  if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4265 
4267 
4268  if (!pvBuf || !cjBuf)
4269  {
4271  break;
4272  }
4273  if (needed > cjBuf)
4274  {
4276  return GDI_ERROR;
4277  }
4280  break;
4281  }
4282 
4283  case GGO_BEZIER:
4284  {
4285  FT_Outline *outline = &ft_face->glyph->outline;
4286  if (cjBuf == 0) pvBuf = NULL;
4287 
4288  if (needsTransform && pvBuf)
4289  {
4290  IntLockFreeType();
4291  FT_Outline_Transform(outline, &transMat);
4293  }
4295 
4296  if (!pvBuf || !cjBuf)
4297  break;
4298  if (needed > cjBuf)
4299  return GDI_ERROR;
4300 
4302  break;
4303  }
4304 
4305  default:
4306  DPRINT1("Unsupported format %u\n", iFormat);
4307  return GDI_ERROR;
4308  }
4309 
4310  DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4311  *pgm = gm;
4312  return needed;
4313 }
#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:56
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:3704
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:2538
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:3388
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:3461
#define IntLockFreeType()
Definition: freetype.c:79
FT_Outline outline
Definition: freetype.h:1927
unsigned char BYTE
Definition: mem.h:68
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, DWORD indexed_flag, DWORD flags)
Definition: freetype.c:3822
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:359
Definition: mesh.c:5329
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
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 5754 of file freetype.c.

5757 {
5758  DWORD Count = 0;
5759  INT i = 0;
5760  FT_Face face = Font->SharedFace->Face;
5761 
5762  if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
5763  {
5764  FT_UInt previous_index = 0, glyph_index = 0;
5765  FT_ULong char_code, char_previous;
5766  FT_Vector delta;
5767 
5768  char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
5769 
5770  IntLockFreeType();
5771 
5772  while (glyph_index)
5773  {
5774  if (previous_index && glyph_index)
5775  {
5776  FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
5777 
5778  if (pKerningPair && cPairs)
5779  {
5780  pKerningPair[i].wFirst = char_previous;
5781  pKerningPair[i].wSecond = char_code;
5782  pKerningPair[i].iKernAmount = delta.x;
5783  i++;
5784  if (i == cPairs) break;
5785  }
5786  Count++;
5787  }
5788  previous_index = glyph_index;
5789  char_previous = char_code;
5790  char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
5791  }
5793  }
5794  return Count;
5795 }
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:56
#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 3213 of file freetype.c.

3214 {
3215  if ( lprs )
3216  {
3217  lprs->nSize = sizeof(RASTERIZER_STATUS);
3218  lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3219  lprs->nLanguageID = gusLanguageID;
3220  return TRUE;
3221  }
3223  return FALSE;
3224 }
#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 4460 of file freetype.c.

4464 {
4465  PDC_ATTR pdcattr;
4466  UINT Ret = DEFAULT_CHARSET;
4467  INT i;
4468  HFONT hFont;
4469  PTEXTOBJ TextObj;
4470  PFONTGDI FontGdi;
4471  FONTSIGNATURE fs;
4472  TT_OS2 *pOS2;
4473  FT_Face Face;
4474  CHARSETINFO csi;
4475  DWORD cp, fs0;
4476  USHORT usACP, usOEM;
4477 
4478  pdcattr = Dc->pdcattr;
4479  hFont = pdcattr->hlfntNew;
4480  TextObj = RealizeFontInit(hFont);
4481 
4482  if (!TextObj)
4483  {
4485  return Ret;
4486  }
4487  FontGdi = ObjToGDI(TextObj->Font, FONT);
4488  Face = FontGdi->SharedFace->Face;
4489  TEXTOBJ_UnlockText(TextObj);
4490 
4491  memset(&fs, 0, sizeof(FONTSIGNATURE));
4492  IntLockFreeType();
4493  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4494  if (NULL != pOS2)
4495  {
4496  fs.fsCsb[0] = pOS2->ulCodePageRange1;
4497  fs.fsCsb[1] = pOS2->ulCodePageRange2;
4498  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
4499  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
4500  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
4501  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
4502  if (pOS2->version == 0)
4503  {
4504  FT_UInt dummy;
4505 
4506  if (FT_Get_First_Char( Face, &dummy ) < 0x100)
4507  fs.fsCsb[0] |= FS_LATIN1;
4508  else
4509  fs.fsCsb[0] |= FS_SYMBOL;
4510  }
4511  }
4512  pOS2 = NULL;
4514  DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
4515  if (fs.fsCsb[0] == 0)
4516  { /* Let's see if we can find any interesting cmaps */
4517  for (i = 0; i < Face->num_charmaps; i++)
4518  {
4519  switch (Face->charmaps[i]->encoding)
4520  {
4521  case FT_ENCODING_UNICODE:
4522  case FT_ENCODING_APPLE_ROMAN:
4523  fs.fsCsb[0] |= FS_LATIN1;
4524  break;
4525  case FT_ENCODING_MS_SYMBOL:
4526  fs.fsCsb[0] |= FS_SYMBOL;
4527  break;
4528  default:
4529  break;
4530  }
4531  }
4532  }
4533  if (lpSig)
4534  {
4535  RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
4536  }
4537 
4538  RtlGetDefaultCodePage(&usACP, &usOEM);
4539  cp = usACP;
4540 
4542  if (csi.fs.fsCsb[0] & fs.fsCsb[0])
4543  {
4544  DPRINT("Hit 1\n");
4545  Ret = csi.ciCharset;
4546  goto Exit;
4547  }
4548 
4549  for (i = 0; i < MAXTCIINDEX; i++)
4550  {
4551  fs0 = 1L << i;
4552  if (fs.fsCsb[0] & fs0)
4553  {
4554  if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
4555  {
4556  // *cp = csi.ciACP;
4557  DPRINT("Hit 2\n");
4558  Ret = csi.ciCharset;
4559  goto Exit;
4560  }
4561  else
4562  DPRINT1("TCI failing on %x\n", fs0);
4563  }
4564  }
4565 Exit:
4566  DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
4567  return (MAKELONG(csi.ciACP, csi.ciCharset));
4568 }
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:56
#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:2174
#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 4641 of file freetype.c.

4644 {
4645  PDC dc;
4646  PDC_ATTR pdcattr;
4647  PTEXTOBJ TextObj;
4648  PFONTGDI FontGDI;
4649  FT_Face Face;
4650  TT_OS2 *pOS2;
4651  TT_HoriHeader *pHori;
4652  FT_WinFNT_HeaderRec Win;
4653  ULONG Error;
4655  LOGFONTW *plf;
4656 
4657  if (!ptmwi)
4658  {
4660  return FALSE;
4661  }
4662 
4663  if (!(dc = DC_LockDc(hDC)))
4664  {
4666  return FALSE;
4667  }
4668  pdcattr = dc->pdcattr;
4669  TextObj = RealizeFontInit(pdcattr->hlfntNew);
4670  if (NULL != TextObj)
4671  {
4672  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4673  FontGDI = ObjToGDI(TextObj->Font, FONT);
4674 
4675  Face = FontGDI->SharedFace->Face;
4676 
4677  IntLockFreeType();
4678  Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4681 
4682  if (0 != Error)
4683  {
4684  DPRINT1("Error in setting pixel sizes: %u\n", Error);
4686  }
4687  else
4688  {
4689  FT_Face Face = FontGDI->SharedFace->Face;
4691 
4692  IntLockFreeType();
4693  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4694  if (NULL == pOS2)
4695  {
4696  DPRINT1("Can't find OS/2 table - not TT font?\n");
4698  }
4699 
4700  pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
4701  if (NULL == pHori)
4702  {
4703  DPRINT1("Can't find HHEA table - not TT font?\n");
4705  }
4706 
4707  Error = FT_Get_WinFNT_Header(Face, &Win);
4708 
4709  if (NT_SUCCESS(Status) || !Error)
4710  {
4711  FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
4712 
4713  /* FIXME: Fill Diff member */
4714  RtlZeroMemory(&ptmwi->Diff, sizeof(ptmwi->Diff));
4715  }
4716 
4718  }
4719  TEXTOBJ_UnlockText(TextObj);
4720  }
4721  else
4722  {
4724  }
4725  DC_UnlockDc(dc);
4726 
4727  if (!NT_SUCCESS(Status))
4728  {
4730  return FALSE;
4731  }
4732  return TRUE;
4733 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:369
#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:2237
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:3586
#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:370
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:2938
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 3239 of file freetype.c.

3245 {
3246  PLIST_ENTRY CurrentEntry;
3247  PFONT_CACHE_ENTRY FontEntry;
3248 
3250 
3251  for (CurrentEntry = g_FontCacheListHead.Flink;
3252  CurrentEntry != &g_FontCacheListHead;
3253  CurrentEntry = CurrentEntry->Flink)
3254  {
3255  FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
3256  if ((FontEntry->Face == Face) &&
3257  (FontEntry->GlyphIndex == GlyphIndex) &&
3258  (FontEntry->Height == Height) &&
3259  (FontEntry->RenderMode == RenderMode) &&
3260  (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx)))
3261  break;
3262  }
3263 
3264  if (CurrentEntry == &g_FontCacheListHead)
3265  {
3266  return NULL;
3267  }
3268 
3269  RemoveEntryList(CurrentEntry);
3270  InsertHeadList(&g_FontCacheListHead, CurrentEntry);
3271  return FontEntry->BitmapGlyph;
3272 }
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:119
static BOOL SameScaleMatrix(PMATRIX pmx1, PMATRIX pmx2)
Definition: freetype.c:3228
int Height
Definition: font.h:32
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:93
Definition: font.h:26
Definition: typedefs.h:117
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 3317 of file freetype.c.

3324 {
3325  FT_Glyph GlyphCopy;
3326  INT error;
3327  PFONT_CACHE_ENTRY NewEntry;
3328  FT_Bitmap AlignedBitmap;
3329  FT_BitmapGlyph BitmapGlyph;
3330 
3332 
3333  error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
3334  if (error)
3335  {
3336  DPRINT1("Failure caching glyph.\n");
3337  return NULL;
3338  };
3339 
3340  error = FT_Glyph_To_Bitmap(&GlyphCopy, RenderMode, 0, 1);
3341  if (error)
3342  {
3343  FT_Done_Glyph(GlyphCopy);
3344  DPRINT1("Failure rendering glyph.\n");
3345  return NULL;
3346  };
3347 
3349  if (!NewEntry)
3350  {
3351  DPRINT1("Alloc failure caching glyph.\n");
3352  FT_Done_Glyph(GlyphCopy);
3353  return NULL;
3354  }
3355 
3356  BitmapGlyph = (FT_BitmapGlyph)GlyphCopy;
3357  FT_Bitmap_New(&AlignedBitmap);
3358  if(FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3359  {
3360  DPRINT1("Conversion failed\n");
3361  ExFreePoolWithTag(NewEntry, TAG_FONT);
3362  FT_Bitmap_Done(GlyphSlot->library, &AlignedBitmap);
3363  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3364  return NULL;
3365  }
3366 
3367  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3368  BitmapGlyph->bitmap = AlignedBitmap;
3369 
3370  NewEntry->GlyphIndex = GlyphIndex;
3371  NewEntry->Face = Face;
3372  NewEntry->BitmapGlyph = BitmapGlyph;
3373  NewEntry->Height = Height;
3374  NewEntry->RenderMode = RenderMode;
3375  NewEntry->mxWorldToDevice = *pmx;
3376 
3379  {
3381  RemoveCachedEntry(NewEntry);
3382  }
3383 
3384  return BitmapGlyph;
3385 }
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:120
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:56
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 3276 of file freetype.c.

3280 {
3281  FT_Glyph Glyph;
3282  INT error;
3283  FT_Bitmap AlignedBitmap;
3284  FT_BitmapGlyph BitmapGlyph;
3285 
3286  error = FT_Get_Glyph(GlyphSlot, &Glyph);
3287  if (error)
3288  {
3289  DPRINT1("Failure getting glyph.\n");
3290  return NULL;
3291  }
3292 
3293  error = FT_Glyph_To_Bitmap(&Glyph, RenderMode, 0, 1);
3294  if (error)
3295  {
3296  FT_Done_Glyph(Glyph);
3297  DPRINT1("Failure rendering glyph.\n");
3298  return NULL;
3299  }
3300 
3301  BitmapGlyph = (FT_BitmapGlyph)Glyph;
3302  FT_Bitmap_New(&AlignedBitmap);
3303  if (FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3304  {
3305  DPRINT1("Conversion failed\n");
3306  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3307  return NULL;
3308  }
3309 
3310  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3311  BitmapGlyph->bitmap = AlignedBitmap;
3312 
3313  return BitmapGlyph;
3314 }
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:56
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 5735 of file freetype.c.

5736 {
5737  if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
5738  Info->iTechnology = RI_TECH_BITMAP;
5739  else
5740  {
5741  if (FT_IS_SCALABLE(Font->SharedFace->Face))
5742  Info->iTechnology = RI_TECH_SCALABLE;
5743  else
5744  Info->iTechnology = RI_TECH_FIXED;
5745  }
5746  Info->iUniq = Font->FontObj.iUniq;
5747  Info->dwUnknown = -1;
5748  return TRUE;
5749 }
#define TRUE
Definition: types.h:120
#define RI_TECH_BITMAP
Definition: ntgdityp.h:270
struct TraceInfo Info
#define RI_TECH_SCALABLE
Definition: ntgdityp.h:272
#define FT_HAS_FIXED_SIZES(face)
Definition: freetype.h:1361
#define RI_TECH_FIXED
Definition: ntgdityp.h:271
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312

Referenced by NtGdiGetRealizationInfo().

◆ ftGetFontUnicodeRanges()

DWORD FASTCALL ftGetFontUnicodeRanges ( PFONTGDI  Font,
PGLYPHSET  glyphset 
)

Definition at line 4573 of file freetype.c.

4574 {
4575  DWORD size = 0;
4576  DWORD num_ranges = 0;
4577  FT_Face face = Font->SharedFace->Face;
4578 
4579  if (face->charmap->encoding == FT_ENCODING_UNICODE)
4580  {
4581  FT_UInt glyph_code = 0;
4582  FT_ULong char_code, char_code_prev;
4583 
4584  char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
4585 
4586  DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
4587  face->num_glyphs, glyph_code, char_code);
4588 
4589  if (!glyph_code) return 0;
4590 
4591  if (glyphset)
4592  {
4593  glyphset->ranges[0].wcLow = (USHORT)char_code;
4594  glyphset->ranges[0].cGlyphs = 0;
4595  glyphset->cGlyphsSupported = 0;
4596  }
4597 
4598  num_ranges = 1;
4599  while (glyph_code)
4600  {
4601  if (char_code < char_code_prev)
4602  {
4603  DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
4604  return 0;
4605  }
4606  if (char_code - char_code_prev > 1)
4607  {
4608  num_ranges++;
4609  if (glyphset)
4610  {
4611  glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
4612  glyphset->ranges[num_ranges - 1].cGlyphs = 1;
4613  glyphset->cGlyphsSupported++;
4614  }
4615  }
4616  else if (glyphset)
4617  {
4618  glyphset->ranges[num_ranges - 1].cGlyphs++;
4619  glyphset->cGlyphsSupported++;
4620  }
4621  char_code_prev = char_code;
4622  char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
4623  }
4624  }
4625  else
4626  DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
4627 
4628  size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
4629  if (glyphset)
4630  {
4631  glyphset->cbThis = size;
4632  glyphset->cRanges = num_ranges;
4633  glyphset->flAccel = 0;
4634  }
4635  return size;
4636 }
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:413
#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:412
FLOATOBJ efM22
Definition: ntgdityp.h:414
FT_Fixed xy
Definition: fttypes.h:387
FLOATOBJ efM11
Definition: ntgdityp.h:411
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:413
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:412
FLOATOBJ efM22
Definition: ntgdityp.h:414
FT_Fixed xy
Definition: fttypes.h:387
FLOATOBJ efM11
Definition: ntgdityp.h:411
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 3461 of file freetype.c.

3462 {
3463  /* Convert the quadratic Beziers to cubic Beziers.
3464  The parametric eqn for a cubic Bezier is, from PLRM:
3465  r(t) = at^3 + bt^2 + ct + r0
3466  with the control points:
3467  r1 = r0 + c/3
3468  r2 = r1 + (c + b)/3
3469  r3 = r0 + c + b + a
3470 
3471  A quadratic Bezier has the form:
3472  p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
3473 
3474  So equating powers of t leads to:
3475  r1 = 2/3 p1 + 1/3 p0
3476  r2 = 2/3 p1 + 1/3 p2
3477  and of course r0 = p0, r3 = p2
3478  */
3479  int contour, point = 0, first_pt;
3480  TTPOLYGONHEADER *pph;
3481  TTPOLYCURVE *ppc;
3482  DWORD pph_start, cpfx, type;
3483  FT_Vector cubic_control[4];
3484  unsigned int needed = 0;
3485 
3486  for (contour = 0; contour < outline->n_contours; contour++)
3487  {
3488  pph_start = needed;
3489  pph = (TTPOLYGONHEADER *)(buf + needed);
3490  first_pt = point;
3491  if (buf)
3492  {
3493  pph->dwType = TT_POLYGON_TYPE;
3494  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3495  }
3496  needed += sizeof(*pph);
3497  point++;
3498  while (point <= outline->contours[contour])
3499  {
3500  ppc = (TTPOLYCURVE *)(buf + needed);
3501  type = (outline->tags[point] & FT_Curve_Tag_On) ?
3503  cpfx = 0;
3504  do
3505  {
3506  if (type == TT_PRIM_LINE)
3507  {
3508  if (buf)
3509  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3510  cpfx++;
3511  point++;
3512  }
3513  else
3514  {
3515  /* Unlike QSPLINEs, CSPLINEs always have their endpoint
3516  so cpfx = 3n */
3517 
3518  /* FIXME: Possible optimization in endpoint calculation
3519  if there are two consecutive curves */
3520  cubic_control[0] = outline->points[point-1];
3521  if (!(outline->tags[point-1] & FT_Curve_Tag_On))
3522  {
3523  cubic_control[0].x += outline->points[point].x + 1;
3524  cubic_control[0].y += outline->points[point].y + 1;
3525  cubic_control[0].x >>= 1;
3526  cubic_control[0].y >>= 1;
3527  }
3528  if (point+1 > outline->contours[contour])
3529  cubic_control[3] = outline->points[first_pt];
3530  else
3531  {
3532  cubic_control[3] = outline->points[point+1];
3533  if (!(outline->tags[point+1] & FT_Curve_Tag_On))
3534  {
3535  cubic_control[3].x += outline->points[point].x + 1;
3536  cubic_control[3].y += outline->points[point].y + 1;
3537  cubic_control[3].x >>= 1;
3538  cubic_control[3].y >>= 1;
3539  }
3540  }
3541  /* r1 = 1/3 p0 + 2/3 p1
3542  r2 = 1/3 p2 + 2/3 p1 */
3543  cubic_control[1].x = (2 * outline->points[point].x + 1) / 3;
3544  cubic_control[1].y = (2 * outline->points[point].y + 1) / 3;
3545  cubic_control[2] = cubic_control[1];
3546  cubic_control[1].x += (cubic_control[0].x + 1) / 3;
3547  cubic_control[1].y += (cubic_control[0].y + 1) / 3;
3548  cubic_control[2].x += (cubic_control[3].x + 1) / 3;
3549  cubic_control[2].y += (cubic_control[3].y + 1) / 3;
3550  if (buf)
3551  {
3552  FTVectorToPOINTFX(&cubic_control[1], &ppc->apfx[cpfx]);
3553  FTVectorToPOINTFX(&cubic_control[2], &ppc->apfx[cpfx+1]);
3554  FTVectorToPOINTFX(&cubic_control[3], &ppc->apfx[cpfx+2]);
3555  }
3556  cpfx += 3;
3557  point++;
3558  }
3559  } while (point <= outline->contours[contour] &&
3560  (outline->tags[point] & FT_Curve_Tag_On) ==
3561  (outline->tags[point-1] & FT_Curve_Tag_On));
3562  /* At the end of a contour Windows adds the start point,
3563  but only for Beziers and we've already done that.
3564  */
3565  if (point <= outline->contours[contour] &&
3566  outline->tags[point] & FT_Curve_Tag_On)
3567  {
3568  /* This is the closing pt of a bezier, but we've already
3569  added it, so just inc point and carry on */
3570  point++;
3571  }
3572  if (buf)
3573  {
3574  ppc->wType = type;
3575  ppc->cpfx = cpfx;
3576  }
3577  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3578  }
3579  if (buf)
3580  pph->cb = needed - pph_start;
3581  }
3582  return needed;
3583 }
#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 3807 of file freetype.c.

3808 {
3809  FT_UInt ret;
3810 
3811  if (face_has_symbol_charmap(ft_face))
3812  {
3813  ret = get_glyph_index_symbol(ft_face, glyph);
3814  if (ret != 0)
3815  return ret;
3816  }
3817 
3818  return FT_Get_Char_Index(ft_face, glyph);
3819 }
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2221
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:3793
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 3822 of file freetype.c.

3823 {
3824  FT_UInt glyph_index;
3825  if (flags & indexed_flag)
3826  {
3827  glyph_index = code;
3828  }
3829  else
3830  {
3831  glyph_index = get_glyph_index(face, code);
3832  }
3833  return glyph_index;
3834 }
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3807
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 3793 of file freetype.c.

3794 {
3795  FT_UInt ret;
3796 
3797  if (glyph < 0x100) glyph += 0xf000;
3798  /* there are a number of old pre-Unicode "broken" TTFs, which
3799  do have symbols at U+00XX instead of U+f0XX */
3800  if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
3801  ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
3802 
3803  return ret;
3804 }
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 3388 of file freetype.c.

3389 {
3390  TTPOLYGONHEADER *pph;
3391  TTPOLYCURVE *ppc;
3392  int needed = 0, point = 0, contour, first_pt;
3393  unsigned int pph_start, cpfx;
3394  DWORD type;
3395 
3396  for (contour = 0; contour < outline->n_contours; contour++)
3397  {
3398  /* Ignore contours containing one point */
3399  if (point == outline->contours[contour])
3400  {
3401  point++;
3402  continue;
3403  }
3404 
3405  pph_start = needed;
3406  pph = (TTPOLYGONHEADER *)(buf + needed);
3407  first_pt = point;
3408  if (buf)
3409  {
3410  pph->dwType = TT_POLYGON_TYPE;
3411  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3412  }
3413  needed += sizeof(*pph);
3414  point++;
3415  while (point <= outline->contours[contour])
3416  {
3417  ppc = (TTPOLYCURVE *)(buf + needed);
3418  type = (outline->tags[point] & FT_Curve_Tag_On) ?
3420  cpfx = 0;
3421  do
3422  {
3423  if (buf)
3424  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3425  cpfx++;
3426  point++;
3427  } while (point <= outline->contours[contour] &&
3428  (outline->tags[point] & FT_Curve_Tag_On) ==
3429  (outline->tags[point-1] & FT_Curve_Tag_On));
3430  /* At the end of a contour Windows adds the start point, but
3431  only for Beziers */
3432  if (point > outline->contours[contour] &&
3433  !(outline->tags[point-1] & FT_Curve_Tag_On))
3434  {
3435  if (buf)
3436  FTVectorToPOINTFX(&outline->points[first_pt], &ppc->apfx[cpfx]);
3437  cpfx++;
3438  }
3439  else if (point <= outline->contours[contour] &&
3440  outline->tags[point] & FT_Curve_Tag_On)
3441  {
3442  /* add closing pt for bezier */
3443  if (buf)
3444  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3445  cpfx++;
3446  point++;
3447  }
3448  if (buf)
3449  {
3450  ppc->wType = type;
3451  ppc->cpfx = cpfx;
3452  }
3453  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3454  }
3455  if (buf)
3456  pph->cb = needed - pph_start;
3457  }
3458  return needed;
3459 }
#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 3087 of file freetype.c.

3093 {
3095  PFONT_ENTRY CurrentEntry;
3096  FONTGDI *FontGDI;
3097  FONTFAMILYINFO InfoEntry;
3098  LONG Count = *pCount;
3099 
3100  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
3101  {
3102  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
3103  FontGDI = CurrentEntry->Font;
3104  ASSERT(FontGDI);
3105 
3106  if (LogFont->lfCharSet != DEFAULT_CHARSET &&
3107  LogFont->lfCharSet != FontGDI->CharSet)
3108  {
3109  continue; /* charset mismatch */
3110  }
3111 
3112  /* get one info entry */
3113  FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
3114 
3115  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3116  {
3117  /* check name */
3118  if (_wcsnicmp(LogFont->lfFaceName,
3120  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
3121  _wcsnicmp(LogFont->lfFaceName,
3122  InfoEntry.EnumLogFontEx.elfFullName,
3123  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
3124  {
3125  continue;
3126  }
3127  }
3128 
3129  if (NominalName)
3130  {
3131  /* store the nominal name */
3133  sizeof(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
3134  NominalName);
3135  }
3136 
3137  /* store one entry to Info */
3138  if (0 <= Count && Count < MaxCount)
3139  {
3140  RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
3141  }
3142  Count++;
3143  }
3144 
3145  *pCount = Count;
3146 
3147  return TRUE;
3148 }
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:2903
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:117
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 3151 of file freetype.c.

3155 {
3156  PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
3157  PFONTSUBST_ENTRY pCurrentEntry;
3158  PUNICODE_STRING pFromW, pToW;
3159  LOGFONTW lf = *LogFont;
3161 
3162  for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
3163  {
3164  pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
3165 
3166  pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
3167  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3168  {
3169  /* check name */
3170  if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
3171  continue; /* mismatch */
3172  }
3173 
3174  pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
3175  if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
3176  pCurrentEntry->CharSets[FONTSUBST_FROM] ==
3177  pCurrentEntry->CharSets[FONTSUBST_TO])
3178  {
3179  /* identical mapping */
3180  continue;
3181  }
3182 
3183  /* substitute and get the real name */
3184  IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
3185  SubstituteFontRecurse(&lf);
3186  if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
3187  continue;
3188 
3189  /* search in global fonts */
3191  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
3193 
3194  /* search in private fonts */
3195  IntLockProcessPrivateFonts(Win32Process);
3196  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
3197  &Win32Process->PrivateFontListHead);
3198  IntUnLockProcessPrivateFonts(Win32Process);
3199 
3200  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3201  {
3202  /* it's already matched to the exact name and charset if the name
3203  was specified at here, then so don't scan more for another name */
3204  break;
3205  }
3206  }
3207 
3208  return TRUE;
3209 }
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:119
static BOOL SubstituteFontRecurse(LOGFONTW *pLogFont)
Definition: freetype.c:904
BYTE CharSets[FONTSUBST_FROM_AND_TO]
Definition: font.h:54
Definition: typedefs.h:117
#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:3087
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 4779 of file freetype.c.

4782 {
4783  ULONG Penalty = 0;
4784  BYTE Byte;
4785  LONG Long;
4786  BOOL fNeedScaling = FALSE;
4787  const BYTE UserCharSet = CharSetFromLangID(gusLanguageID);
4788  const TEXTMETRICW * TM = &Otm->otmTextMetrics;
4789  WCHAR* ActualNameW;
4790 
4791  ASSERT(Otm);
4792  ASSERT(LogFont);
4793 
4794  /* FIXME: IntSizeSynth Penalty 20 */
4795  /* FIXME: SmallPenalty Penalty 1 */
4796  /* FIXME: FaceNameSubst Penalty 500 */
4797 
4798  Byte = LogFont->lfCharSet;
4799 
4800  if (Byte != TM->tmCharSet)
4801  {
4802  if (Byte != DEFAULT_CHARSET && Byte != ANSI_CHARSET)
4803  {
4804  /* CharSet Penalty 65000 */
4805  /* Requested charset does not match the candidate's. */
4806  GOT_PENALTY("CharSet", 65000);
4807  }
4808  else
4809  {
4810  if (UserCharSet != TM->tmCharSet)
4811  {
4812  /* UNDOCUMENTED: Not user language */
4813  GOT_PENALTY("UNDOCUMENTED:NotUserLanguage", 100);
4814 
4815  if (ANSI_CHARSET != TM->tmCharSet)
4816  {
4817  /* UNDOCUMENTED: Not ANSI charset */
4818  GOT_PENALTY("UNDOCUMENTED:NotAnsiCharSet", 100);
4819  }
4820  }
4821  }
4822  }
4823 
4824  Byte = LogFont->lfOutPrecision;
4825  switch (Byte)
4826  {
4827  case OUT_DEFAULT_PRECIS:
4828  /* nothing to do */
4829  break;
4830  case OUT_DEVICE_PRECIS:
4831  if (!(TM->tmPitchAndFamily & TMPF_DEVICE) ||
4833  {
4834  /* OutputPrecision Penalty 19000 */
4835  /* Requested OUT_STROKE_PRECIS, but the device can't do it
4836  or the candidate is not a vector font. */
4837  GOT_PENALTY("OutputPrecision", 19000);
4838  }
4839  break;
4840  default:
4842  {
4843  /* OutputPrecision Penalty 19000 */
4844  /* Or OUT_STROKE_PRECIS not requested, and the candidate
4845  is a vector font that requires GDI support. */
4846  GOT_PENALTY("OutputPrecision", 19000);
4847  }
4848  break;
4849  }
4850 
4851  Byte = (LogFont->lfPitchAndFamily & 0x0F);
4852  if (Byte == DEFAULT_PITCH)
4853  Byte = VARIABLE_PITCH;
4854  if (Byte == FIXED_PITCH)
4855  {
4857  {
4858  /* FixedPitch Penalty 15000 */
4859  /* Requested a fixed pitch font, but the candidate is a
4860  variable pitch font. */
4861  GOT_PENALTY("FixedPitch", 15000);
4862  }
4863  }
4864  if (Byte == VARIABLE_PITCH)
4865  {
4867  {
4868  /* PitchVariable Penalty 350 */
4869  /* Requested a variable pitch font, but the candidate is not a
4870  variable pitch font. */
4871  GOT_PENALTY("PitchVariable", 350);
4872  }
4873  }
4874 
4875  Byte = (LogFont->lfPitchAndFamily & 0x0F);
4876  if (Byte == DEFAULT_PITCH)
4877  {
4879  {
4880  /* DefaultPitchFixed Penalty 1 */
4881  /* Requested DEFAULT_PITCH, but the candidate is fixed pitch. */
4882  GOT_PENALTY("DefaultPitchFixed", 1);
4883  }
4884  }
4885 
4886  ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
4887 
4888  if (LogFont->lfFaceName[0] != UNICODE_NULL)
4889  {
4890  BOOL Found = FALSE;
4891 
4892  /* localized family name */
4893  if (!Found)
4894  {
4895  Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
4896  }
4897  /* localized full name */
4898  if (!Found)
4899  {
4900  ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFaceName);
4901  Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
4902  }
4903  if (!Found)
4904  {
4905  /* FaceName Penalty 10000 */
4906  /* Requested a face name, but the candidate's face name
4907  does not match. */
4908  GOT_PENALTY("FaceName", 10000);
4909  }
4910  }
4911 
4912  Byte = (LogFont->lfPitchAndFamily & 0xF0);
4913  if (Byte != FF_DONTCARE)
4914  {
4915  if (Byte != (TM->tmPitchAndFamily & 0xF0))
4916  {
4917  /* Family Penalty 9000 */
4918  /* Requested a family, but the candidate's family is different. */
4919  GOT_PENALTY("Family", 9000);
4920  }
4921  }
4922 
4923  if ((TM->tmPitchAndFamily & 0xF0) == FF_DONTCARE)
4924  {
4925  /* FamilyUnknown Penalty 8000 */
4926  /* Requested a family, but the candidate has no family. */
4927  GOT_PENALTY("FamilyUnknown", 8000);
4928  }
4929 
4930  /* Is the candidate a non-vector font? */
4931  if (!(TM->tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)))
4932  {
4933  /* Is lfHeight specified? */
4934  if (LogFont->lfHeight != 0)
4935  {
4936  if (labs(LogFont->lfHeight) < TM->tmHeight)
4937  {
4938  /* HeightBigger Penalty 600 */
4939  /* The candidate is a nonvector font and is bigger than the
4940  requested height. */
4941  GOT_PENALTY("HeightBigger", 600);
4942  /* HeightBiggerDifference Penalty 150 */
4943  /* The candidate is a raster font and is larger than the
4944  requested height. Penalty * height difference */
4945  GOT_PENALTY("HeightBiggerDifference", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
4946 
4947  fNeedScaling = TRUE;
4948  }
4949  if (TM->tmHeight < labs(LogFont->lfHeight))
4950  {
4951  /* HeightSmaller Penalty 150 */
4952  /* The candidate is a raster font and is smaller than the
4953  requested height. Penalty * height difference */
4954  GOT_PENALTY("HeightSmaller", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
4955 
4956  fNeedScaling = TRUE;
4957  }
4958  }
4959  }
4960 
4961  switch (LogFont->lfPitchAndFamily & 0xF0)
4962  {
4963  case FF_ROMAN: case FF_MODERN: case FF_SWISS:
4964  switch (TM->tmPitchAndFamily & 0xF0)
4965  {
4966  case FF_DECORATIVE: case FF_SCRIPT:
4967  /* FamilyUnlikely Penalty 50 */
4968  /* Requested a roman/modern/swiss family, but the
4969  candidate is decorative/script. */
4970  GOT_PENALTY("FamilyUnlikely", 50);
4971  break;
4972  default:
4973  break;
4974  }
4975  break;
4976  case FF_DECORATIVE: case FF_SCRIPT:
4977  switch (TM->tmPitchAndFamily & 0xF0)
4978  {
4979  case FF_ROMAN: case FF_MODERN: case FF_SWISS:
4980  /* FamilyUnlikely Penalty 50 */
4981  /* Or requested decorative/script, and the candidate is
4982  roman/modern/swiss. */
4983  GOT_PENALTY("FamilyUnlikely", 50);
4984  break;
4985  default:
4986  break;
4987  }
4988  default:
4989  break;
4990  }
4991 
4992  if (LogFont->lfWidth != 0)
4993  {
4994  if (LogFont->lfWidth != TM->tmAveCharWidth)
4995  {
4996  /* Width Penalty 50 */
4997  /* Requested a nonzero width, but the candidate's width
4998  doesn't match. Penalty * width difference */
4999  GOT_PENALTY("Width", 50 * labs(LogFont->lfWidth - TM->tmAveCharWidth));
5000 
5001  if (!(TM->tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)))
5002  fNeedScaling = TRUE;
5003  }
5004  }
5005 
5006  if (fNeedScaling)
5007  {
5008  /* SizeSynth Penalty 50 */
5009  /* The candidate is a raster font that needs scaling by GDI. */
5010  GOT_PENALTY("SizeSynth", 50);
5011  }
5012 
5013  if (!LogFont->lfItalic && TM->tmItalic)
5014  {
5015  /* Italic Penalty 4 */
5016  /* Requested font and candidate font do not agree on italic status,
5017  and the desired result cannot be simulated. */
5018  /* Adjusted to 40 to satisfy (Oblique Penalty > Book Penalty). */
5019  GOT_PENALTY("Italic", 40);
5020  }
5021  else if (LogFont->lfItalic && !TM->tmItalic)
5022  {
5023  /* ItalicSim Penalty 1 */
5024  /* Requested italic font but the candidate is not italic,
5025  although italics can be simulated. */
5026  GOT_PENALTY("ItalicSim", 1);
5027  }
5028 
5029  if (LogFont->lfOutPrecision == OUT_TT_PRECIS)
5030  {
5031  if (!(TM->tmPitchAndFamily & TMPF_TRUETYPE))
5032  {
5033  /* NotTrueType Penalty 4 */
5034  /* Requested OUT_TT_PRECIS, but the candidate is not a
5035  TrueType font. */
5036  GOT_PENALTY("NotTrueType", 4);
5037  }
5038  }
5039 
5040  Long = LogFont->lfWeight;
5041  if (LogFont->lfWeight == FW_DONTCARE)
5042  Long = FW_NORMAL;
5043  if (Long != TM->tmWeight)
5044  {
5045  /* Weight Penalty 3 */
5046  /* The candidate's weight does not match the requested weight.
5047  Penalty * (weight difference/10) */
5048  GOT_PENALTY("Weight", 3 * (labs(Long - TM->tmWeight) / 10));
5049  }
5050 
5051  if (!LogFont->lfUnderline && TM->tmUnderlined)
5052  {
5053  /* Underline Penalty 3 */
5054  /* Requested font has no underline, but the candidate is
5055  underlined. */
5056  GOT_PENALTY("Underline", 3);
5057  }
5058 
5059  if (!LogFont->lfStrikeOut && TM->tmStruckOut)
5060  {
5061  /* StrikeOut Penalty 3 */
5062  /* Requested font has no strike-out, but the candidate is
5063  struck out. */
5064  GOT_PENALTY("StrikeOut", 3);
5065  }
5066 
5067  /* Is the candidate a non-vector font? */
5068  if (!(TM->tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)))
5069  {
5070  if (LogFont->lfHeight != 0 && TM->tmHeight < LogFont->lfHeight)
5071  {
5072  /* VectorHeightSmaller Penalty 2 */
5073  /* Candidate is a vector font that is smaller than the
5074  requested height. Penalty * height difference */
5075  GOT_PENALTY("VectorHeightSmaller", 2 * labs(TM->tmHeight - LogFont->lfHeight));
5076  }
5077  if (LogFont->lfHeight != 0 && TM->tmHeight > LogFont->lfHeight)
5078  {
5079  /* VectorHeightBigger Penalty 1 */
5080