ReactOS  0.4.14-dev-552-g2fad488
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 4771 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 6734 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 2681 of file freetype.c.

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

5430 {
5431  const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5432  const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5433  const LOGFONTW *plf1 = &pLog1->elfLogFont;
5434  const LOGFONTW *plf2 = &pLog2->elfLogFont;
5435 
5436  if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5437  {
5438  return FALSE;
5439  }
5440 
5441  if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5442  {
5443  return FALSE;
5444  }
5445 
5446  return TRUE;
5447 }
#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  if ((FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent == 0)
2276  {
2277  Ascent = pHori->Ascender;
2278  Descent = -pHori->Descender;
2279  }
2280  else
2281  {
2282  Ascent = (FT_Short)pOS2->usWinAscent;
2283  Descent = (FT_Short)pOS2->usWinDescent;
2284  }
2285 
2286  TM->tmAscent = FontGDI->tmAscent;
2287  TM->tmDescent = FontGDI->tmDescent;
2288  TM->tmHeight = TM->tmAscent + TM->tmDescent;
2289  TM->tmInternalLeading = FontGDI->tmInternalLeading;
2290 
2291  /* MSDN says:
2292  * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
2293  */
2294  TM->tmExternalLeading = max(0, (FT_MulFix(pHori->Line_Gap
2295  - ((Ascent + Descent)
2296  - (pHori->Ascender - pHori->Descender)),
2297  YScale) + 32) >> 6);
2298 
2299  TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
2300  if (TM->tmAveCharWidth == 0)
2301  {
2302  TM->tmAveCharWidth = 1;
2303  }
2304 
2305  /* Correct forumla to get the maxcharwidth from unicode and ansi font */
2306  TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
2307 
2308  if (FontGDI->OriginalWeight != FW_DONTCARE &&
2309  FontGDI->OriginalWeight != FW_NORMAL)
2310  {
2311  TM->tmWeight = FontGDI->OriginalWeight;
2312  }
2313  else
2314  {
2315  TM->tmWeight = FontGDI->RequestWeight;
2316  }
2317 
2318  TM->tmOverhang = 0;
2319  TM->tmDigitizedAspectX = 96;
2320  TM->tmDigitizedAspectY = 96;
2321  if (face_has_symbol_charmap(Face) ||
2322  (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
2323  {
2324  USHORT cpOEM, cpAnsi;
2325 
2326  EngGetCurrentCodePage(&cpOEM, &cpAnsi);
2327  TM->tmFirstChar = 0;
2328  switch(cpAnsi)
2329  {
2330  case 1257: /* Baltic */
2331  TM->tmLastChar = 0xf8fd;
2332  break;
2333  default:
2334  TM->tmLastChar = 0xf0ff;
2335  }
2336  TM->tmBreakChar = 0x20;
2337  TM->tmDefaultChar = 0x1f;
2338  }
2339  else
2340  {
2341  TM->tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
2342  TM->tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
2343 
2344  if(pOS2->usFirstCharIndex <= 1)
2345  TM->tmBreakChar = pOS2->usFirstCharIndex + 2;
2346  else if (pOS2->usFirstCharIndex > 0xff)
2347  TM->tmBreakChar = 0x20;
2348  else
2349  TM->tmBreakChar = pOS2->usFirstCharIndex;
2350  TM->tmDefaultChar = TM->tmBreakChar - 1;
2351  }
2352 
2353  if (FontGDI->OriginalItalic || FontGDI->RequestItalic)
2354  {
2355  TM->tmItalic = 0xFF;
2356  }
2357  else
2358  {
2359  TM->tmItalic = 0;
2360  }
2361  TM->tmUnderlined = (FontGDI->RequestUnderline ? 0xFF : 0);
2362  TM->tmStruckOut = (FontGDI->RequestStrikeOut ? 0xFF : 0);
2363 
2364  if (!FT_IS_FIXED_WIDTH(Face))
2365  {
2366  switch (pOS2->panose[PAN_PROPORTION_INDEX])
2367  {
2368  case PAN_PROP_MONOSPACED:
2369  TM->tmPitchAndFamily = 0;
2370  break;
2371  default:
2373  break;
2374  }
2375  }
2376  else
2377  {
2378  TM->tmPitchAndFamily = 0;
2379  }
2380 
2381  switch (pOS2->panose[PAN_FAMILYTYPE_INDEX])
2382  {
2383  case PAN_FAMILY_SCRIPT:
2384  TM->tmPitchAndFamily |= FF_SCRIPT;
2385  break;
2386  case PAN_FAMILY_DECORATIVE:
2388  break;
2389 
2390  case PAN_ANY:
2391  case PAN_NO_FIT:
2393  case PAN_FAMILY_PICTORIAL: /* Symbol fonts get treated as if they were text */
2394  /* Which is clearly not what the panose spec says. */
2395  if (TM->tmPitchAndFamily == 0) /* Fixed */
2396  {
2398  }
2399  else
2400  {
2401  switch (pOS2->panose[PAN_SERIFSTYLE_INDEX])
2402  {
2403  case PAN_ANY:
2404  case PAN_NO_FIT:
2405  default:
2407  break;
2408 
2409  case PAN_SERIF_COVE:
2410  case PAN_SERIF_OBTUSE_COVE:
2411  case PAN_SERIF_SQUARE_COVE:
2413  case PAN_SERIF_SQUARE:
2414  case PAN_SERIF_THIN:
2415  case PAN_SERIF_BONE:
2416  case PAN_SERIF_EXAGGERATED:
2417  case PAN_SERIF_TRIANGLE:
2418  TM->tmPitchAndFamily |= FF_ROMAN;
2419  break;
2420 
2421  case PAN_SERIF_NORMAL_SANS:
2422  case PAN_SERIF_OBTUSE_SANS:
2423  case PAN_SERIF_PERP_SANS:
2424  case PAN_SERIF_FLARED:
2425  case PAN_SERIF_ROUNDED:
2426  TM->tmPitchAndFamily |= FF_SWISS;
2427  break;
2428  }
2429  }
2430  break;
2431  default:
2433  }
2434 
2435  if (FT_IS_SCALABLE(Face))
2436  {
2438  }
2439  if (FT_IS_SFNT(Face))
2440  {
2442  }
2443 
2444  TM->tmCharSet = FontGDI->CharSet;
2445 }
#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
#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 5121 of file freetype.c.

5124 {
5125  ULONG Penalty;
5127  PFONT_ENTRY CurrentEntry;
5128  FONTGDI *FontGDI;
5129  OUTLINETEXTMETRICW *Otm = NULL;
5130  UINT OtmSize, OldOtmSize = 0;
5131  FT_Face Face;
5132 
5133  ASSERT(FontObj);
5134  ASSERT(MatchPenalty);
5135  ASSERT(LogFont);
5136  ASSERT(Head);
5137 
5138  /* Start with a pretty big buffer */
5139  OldOtmSize = 0x200;
5140  Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5141 
5142  /* get the FontObj of lowest penalty */
5143  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5144  {
5145  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5146 
5147  FontGDI = CurrentEntry->Font;
5148  ASSERT(FontGDI);
5149  Face = FontGDI->SharedFace->Face;
5150 
5151  /* get text metrics */
5152  OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
5153  if (OtmSize > OldOtmSize)
5154  {
5155  if (Otm)
5157  Otm = ExAllocatePoolWithTag(PagedPool, OtmSize, GDITAG_TEXT);
5158  }
5159 
5160  /* update FontObj if lowest penalty */
5161  if (Otm)
5162  {
5163  IntLockFreeType();
5164  IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5166 
5167  OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm);
5168  if (!OtmSize)
5169  continue;
5170 
5171  OldOtmSize = OtmSize;
5172 
5173  Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5174  if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty)
5175  {
5176  *FontObj = GDIToObj(FontGDI, FONT);
5177  *MatchPenalty = Penalty;
5178  }
5179  }
5180  }
5181 
5182  if (Otm)
5184 }
struct _Entry Entry
Definition: kefuncs.h:640
LONG lfHeight
Definition: dimm.idl:59
static UINT GetFontPenalty(const LOGFONTW *LogFont, const OUTLINETEXTMETRICW *Otm, const char *style_name)
Definition: freetype.c:4775
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2534
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:3582
#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 2899 of file freetype.c.

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

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

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

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

3210 {
3211  if ( lprs )
3212  {
3213  lprs->nSize = sizeof(RASTERIZER_STATUS);
3214  lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3215  lprs->nLanguageID = gusLanguageID;
3216  return TRUE;
3217  }
3219  return FALSE;
3220 }
#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 4456 of file freetype.c.

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

4640 {
4641  PDC dc;
4642  PDC_ATTR pdcattr;
4643  PTEXTOBJ TextObj;
4644  PFONTGDI FontGDI;
4645  FT_Face Face;
4646  TT_OS2 *pOS2;
4647  TT_HoriHeader *pHori;
4648  FT_WinFNT_HeaderRec Win;
4649  ULONG Error;
4651  LOGFONTW *plf;
4652 
4653  if (!ptmwi)
4654  {
4656  return FALSE;
4657  }
4658 
4659  if (!(dc = DC_LockDc(hDC)))
4660  {
4662  return FALSE;
4663  }
4664  pdcattr = dc->pdcattr;
4665  TextObj = RealizeFontInit(pdcattr->hlfntNew);
4666  if (NULL != TextObj)
4667  {
4668  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4669  FontGDI = ObjToGDI(TextObj->Font, FONT);
4670 
4671  Face = FontGDI->SharedFace->Face;
4672 
4673  IntLockFreeType();
4674  Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4677 
4678  if (0 != Error)
4679  {
4680  DPRINT1("Error in setting pixel sizes: %u\n", Error);
4682  }
4683  else
4684  {
4685  FT_Face Face = FontGDI->SharedFace->Face;
4687 
4688  IntLockFreeType();
4689  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4690  if (NULL == pOS2)
4691  {
4692  DPRINT1("Can't find OS/2 table - not TT font?\n");
4694  }
4695 
4696  pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
4697  if (NULL == pHori)
4698  {
4699  DPRINT1("Can't find HHEA table - not TT font?\n");
4701  }
4702 
4703  Error = FT_Get_WinFNT_Header(Face, &Win);
4704 
4705  if (NT_SUCCESS(Status) || !Error)
4706  {
4707  FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
4708 
4709  /* FIXME: Fill Diff member */
4710  RtlZeroMemory(&ptmwi->Diff, sizeof(ptmwi->Diff));
4711  }
4712 
4714  }
4715  TEXTOBJ_UnlockText(TextObj);
4716  }
4717  else
4718  {
4720  }
4721  DC_UnlockDc(dc);
4722 
4723  if (!NT_SUCCESS(Status))
4724  {
4726  return FALSE;
4727  }
4728  return TRUE;
4729 }
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:3582
#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 3235 of file freetype.c.

3241 {
3242  PLIST_ENTRY CurrentEntry;
3243  PFONT_CACHE_ENTRY FontEntry;
3244 
3246 
3247  for (CurrentEntry = g_FontCacheListHead.Flink;
3248  CurrentEntry != &g_FontCacheListHead;
3249  CurrentEntry = CurrentEntry->Flink)
3250  {
3251  FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
3252  if ((FontEntry->Face == Face) &&
3253  (FontEntry->GlyphIndex == GlyphIndex) &&
3254  (FontEntry->Height == Height) &&
3255  (FontEntry->RenderMode == RenderMode) &&
3256  (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx)))
3257  break;
3258  }
3259 
3260  if (CurrentEntry == &g_FontCacheListHead)
3261  {
3262  return NULL;
3263  }
3264 
3265  RemoveEntryList(CurrentEntry);
3266  InsertHeadList(&g_FontCacheListHead, CurrentEntry);
3267  return FontEntry->BitmapGlyph;
3268 }
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:3224
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 3313 of file freetype.c.

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

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

5732 {
5733  if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
5734  Info->iTechnology = RI_TECH_BITMAP;
5735  else
5736  {
5737  if (FT_IS_SCALABLE(Font->SharedFace->Face))
5738  Info->iTechnology = RI_TECH_SCALABLE;
5739  else
5740  Info->iTechnology = RI_TECH_FIXED;
5741  }
5742  Info->iUniq = Font->FontObj.iUniq;
5743  Info->dwUnknown = -1;
5744  return TRUE;
5745 }
#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 4569 of file freetype.c.

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

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

3804 {
3805  FT_UInt ret;
3806 
3807  if (face_has_symbol_charmap(ft_face))
3808  {
3809  ret = get_glyph_index_symbol(ft_face, glyph);
3810  if (ret != 0)
3811  return ret;
3812  }
3813 
3814  return FT_Get_Char_Index(ft_face, glyph);
3815 }
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:3789
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 3818 of file freetype.c.

3819 {
3820  FT_UInt glyph_index;
3821  if (flags & indexed_flag)
3822  {
3823  glyph_index = code;
3824  }
3825  else
3826  {
3827  glyph_index = get_glyph_index(face, code);
3828  }
3829  return glyph_index;
3830 }
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3803
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 3789 of file freetype.c.

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

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

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

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

Referenced by IntGetFontFamilyInfo().

◆ GetFontPenalty()

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

Definition at line 4775 of file freetype.c.

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