ReactOS  0.4.13-dev-79-gcd489d8
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 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 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 __inline void FTVectorToPOINTFX (FT_Vector *vec, POINTFX *pt)
 
static __inline FT_Fixed FT_FixedFromFloat (FLOAT f)
 
static __inline FT_Fixed FT_FixedFromFIXED (FIXED f)
 
BOOL FASTCALL IntLoadFontSubstList (PLIST_ENTRY pHead)
 
BOOL FASTCALL InitFontSupport (VOID)
 
VOID 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)
 
FORCEINLINE VOID FASTCALL 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, USHORT cbBuffer, const UNICODE_STRING *pString)
 
static BOOL SubstituteFontRecurse (LOGFONTW *pLogFont)
 
VOID FASTCALL IntLoadSystemFonts (VOID)
 
static BYTE ItalicFromStyle (const char *style_name)
 
static LONG WeightFromStyle (const char *style_name)
 
static FT_Error IntRequestFontSize (PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
 
static INT FASTCALL IntGdiLoadFontsFromMemory (PGDI_LOAD_FONT pLoadFont, PSHARED_FACE SharedFace, FT_Long FontIndex, INT CharSetIndex)
 
INT FASTCALL IntGdiAddFontResource (PUNICODE_STRING FileName, DWORD Characteristics)
 
HANDLE FASTCALL IntGdiAddFontMemResource (PVOID Buffer, DWORD dwSize, PDWORD pNumAdded)
 
static VOID FASTCALL CleanupFontEntry (PFONT_ENTRY FontEntry)
 
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 FillTMEx (TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT, BOOL RealFont)
 
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 NTSTATUS DuplicateUnicodeString (PUNICODE_STRING Source, PUNICODE_STRING Destination)
 
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)
 
FORCEINLINE LONG FASTCALL IntNormalizeAngle (LONG nTenthAngle)
 
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 const UNICODE_STRING g_MarlettW = RTL_CONSTANT_STRING(L"Marlett")
 
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 84 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_NOT_HELD

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

Definition at line 87 of file freetype.c.

◆ ASSERT_GLOBALFONTS_LOCK_HELD

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

Definition at line 75 of file freetype.c.

◆ CP_MACCP

#define CP_MACCP   2

Definition at line 166 of file freetype.c.

◆ CP_OEMCP

#define CP_OEMCP   1

Definition at line 165 of file freetype.c.

◆ CP_SYMBOL

#define CP_SYMBOL   42

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

◆ GOT_PENALTY

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

Definition at line 4362 of file freetype.c.

◆ IntLockFreeType

Definition at line 78 of file freetype.c.

◆ IntLockGlobalFonts

Definition at line 69 of file freetype.c.

◆ IntUnLockFreeType

Definition at line 81 of file freetype.c.

◆ IntUnLockGlobalFonts

Definition at line 72 of file freetype.c.

◆ MAX_FONT_CACHE

#define MAX_FONT_CACHE   256

Definition at line 90 of file freetype.c.

◆ MAXTCIINDEX

#define MAXTCIINDEX   32

Definition at line 122 of file freetype.c.

◆ NDEBUG

#define NDEBUG

Definition at line 36 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 6366 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 2287 of file freetype.c.

2288 {
2289  /* FIXME: Add more and fix if wrong */
2290  switch (PRIMARYLANGID(LangID))
2291  {
2292  case LANG_CHINESE:
2293  switch (SUBLANGID(LangID))
2294  {
2296  return CHINESEBIG5_CHARSET;
2298  default:
2299  break;
2300  }
2301  return GB2312_CHARSET;
2302 
2303  case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
2304  case LANG_SLOVAK: case LANG_SLOVENIAN: case LANG_ROMANIAN:
2305  return EASTEUROPE_CHARSET;
2306 
2307  case LANG_RUSSIAN: case LANG_BULGARIAN: case LANG_MACEDONIAN:
2308  case LANG_SERBIAN: case LANG_UKRAINIAN:
2309  return RUSSIAN_CHARSET;
2310 
2311  case LANG_ARABIC: return ARABIC_CHARSET;
2312  case LANG_GREEK: return GREEK_CHARSET;
2313  case LANG_HEBREW: return HEBREW_CHARSET;
2314  case LANG_JAPANESE: return SHIFTJIS_CHARSET;
2315  case LANG_KOREAN: return JOHAB_CHARSET;
2316  case LANG_TURKISH: return TURKISH_CHARSET;
2317  case LANG_THAI: return THAI_CHARSET;
2318  case LANG_LATVIAN: return BALTIC_CHARSET;
2319  case LANG_VIETNAMESE: return VIETNAMESE_CHARSET;
2320 
2321  case LANG_ENGLISH: case LANG_BASQUE: case LANG_CATALAN:
2322  case LANG_DANISH: case LANG_DUTCH: case LANG_FINNISH:
2323  case LANG_FRENCH: case LANG_GERMAN: case LANG_ITALIAN:
2324  case LANG_NORWEGIAN: case LANG_PORTUGUESE: case LANG_SPANISH:
2325  case LANG_SWEDISH: default:
2326  return ANSI_CHARSET;
2327  }
2328 }
#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 VOID FASTCALL CleanupFontEntry ( PFONT_ENTRY  FontEntry)
static

Definition at line 1546 of file freetype.c.

1547 {
1548  PFONTGDI FontGDI = FontEntry->Font;
1549  PSHARED_FACE SharedFace = FontGDI->SharedFace;
1550 
1551  if (FontGDI->Filename)
1553 
1554  EngFreeMem(FontGDI);
1555  SharedFace_Release(SharedFace);
1556  ExFreePoolWithTag(FontEntry, TAG_FONT);
1557 }
#define EngFreeMem
Definition: polytest.cpp:56
static void SharedFace_Release(PSHARED_FACE Ptr)
Definition: freetype.c:317
#define TAG_FONT
Definition: tags.h:12
LPWSTR Filename
Definition: engobjects.h:148
PSHARED_FACE SharedFace
Definition: engobjects.h:142
FONTGDI * Font
Definition: font.h:7
#define GDITAG_PFF
Definition: tags.h:148
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by IntGdiCleanupMemEntry(), and IntGdiCleanupPrivateFontsForProcess().

◆ DuplicateUnicodeString()

static NTSTATUS DuplicateUnicodeString ( PUNICODE_STRING  Source,
PUNICODE_STRING  Destination 
)
static

Definition at line 2345 of file freetype.c.

2346 {
2348  UNICODE_STRING Tmp;
2349 
2350  Tmp.Buffer = ExAllocatePoolWithTag(PagedPool, Source->MaximumLength, TAG_USTR);
2351  if (Tmp.Buffer)
2352  {
2353  Tmp.MaximumLength = Source->MaximumLength;
2354  Tmp.Length = 0;
2356 
2358  Destination->Length = Tmp.Length;
2359  Destination->Buffer = Tmp.Buffer;
2360 
2362  }
2363 
2364  return Status;
2365 }
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:2875
#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:3149
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by IntGetFontLocalizedName().

◆ EqualFamilyInfo()

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

Definition at line 5043 of file freetype.c.

5044 {
5045  const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5046  const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5047  const LOGFONTW *plf1 = &pLog1->elfLogFont;
5048  const LOGFONTW *plf2 = &pLog2->elfLogFont;
5049 
5050  if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5051  {
5052  return FALSE;
5053  }
5054 
5055  if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5056  {
5057  return FALSE;
5058  }
5059 
5060  return TRUE;
5061 }
#define TRUE
Definition: types.h:120
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:2682
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
LOGFONTW elfLogFont
Definition: wingdi.h:2680
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 1799 of file freetype.c.

1800 {
1801  int i;
1802 
1803  for(i = 0; i < ft_face->num_charmaps; i++)
1804  {
1805  if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
1806  ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
1807  {
1808  return TRUE;
1809  }
1810  }
1811  return FALSE;
1812 }
#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 FillTMEx(), 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 2057 of file freetype.c.

2060 {
2061  FillTMEx(TM, FontGDI, pOS2, pHori, pFNT, FALSE);
2062 }
static void FASTCALL FillTMEx(TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT, BOOL RealFont)
Definition: freetype.c:1815

Referenced by ftGdiGetTextMetricsW(), and IntGetOutlineTextMetrics().

◆ FillTMEx()

static void FASTCALL FillTMEx ( TEXTMETRICW TM,
PFONTGDI  FontGDI,
TT_OS2 pOS2,
TT_HoriHeader pHori,
FT_WinFNT_HeaderRec pFNT,
BOOL  RealFont 
)
static

Definition at line 1815 of file freetype.c.

1818 {
1819  FT_Fixed XScale, YScale;
1820  int Ascent, Descent;
1821  FT_Face Face = FontGDI->SharedFace->Face;
1822 
1824 
1825  XScale = Face->size->metrics.x_scale;
1826  YScale = Face->size->metrics.y_scale;
1827 
1828  if (pFNT)
1829  {
1830  TM->tmHeight = pFNT->pixel_height;
1831  TM->tmAscent = pFNT->ascent;
1832  TM->tmDescent = TM->tmHeight - TM->tmAscent;
1833  TM->tmInternalLeading = pFNT->internal_leading;
1834  TM->tmExternalLeading = pFNT->external_leading;
1835  TM->tmAveCharWidth = pFNT->avg_width;
1836  TM->tmMaxCharWidth = pFNT->max_width;
1837  TM->tmOverhang = 0;
1840  TM->tmFirstChar = pFNT->first_char;
1841  TM->tmLastChar = pFNT->last_char;
1842  TM->tmDefaultChar = pFNT->default_char + pFNT->first_char;
1843  TM->tmBreakChar = pFNT->break_char + pFNT->first_char;
1844  TM->tmPitchAndFamily = pFNT->pitch_and_family;
1845  if (RealFont)
1846  {
1847  TM->tmWeight = FontGDI->OriginalWeight;
1848  TM->tmItalic = FontGDI->OriginalItalic;
1849  TM->tmUnderlined = pFNT->underline;
1850  TM->tmStruckOut = pFNT->strike_out;
1851  TM->tmCharSet = pFNT->charset;
1852  }
1853  else
1854  {
1855  TM->tmWeight = FontGDI->RequestWeight;
1856  TM->tmItalic = FontGDI->RequestItalic;
1857  TM->tmUnderlined = FontGDI->RequestUnderline;
1858  TM->tmStruckOut = FontGDI->RequestStrikeOut;
1859  TM->tmCharSet = FontGDI->CharSet;
1860  }
1861  return;
1862  }
1863 
1864  if (pOS2->usWinAscent + pOS2->usWinDescent == 0)
1865  {
1866  Ascent = pHori->Ascender;
1867  Descent = -pHori->Descender;
1868  }
1869  else
1870  {
1871  Ascent = pOS2->usWinAscent;
1872  Descent = pOS2->usWinDescent;
1873  }
1874 
1875  if (FontGDI->Magic != FONTGDI_MAGIC)
1876  {
1877  IntRequestFontSize(NULL, FontGDI, 0, 0);
1878  }
1879  TM->tmAscent = FontGDI->tmAscent;
1880  TM->tmDescent = FontGDI->tmDescent;
1881  TM->tmHeight = TM->tmAscent + TM->tmDescent;
1882  TM->tmInternalLeading = FontGDI->tmInternalLeading;
1883 
1884  /* MSDN says:
1885  * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
1886  */
1887  TM->tmExternalLeading = max(0, (FT_MulFix(pHori->Line_Gap
1888  - ((Ascent + Descent)
1889  - (pHori->Ascender - pHori->Descender)),
1890  YScale) + 32) >> 6);
1891 
1892  TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
1893  if (TM->tmAveCharWidth == 0)
1894  {
1895  TM->tmAveCharWidth = 1;
1896  }
1897 
1898  /* Correct forumla to get the maxcharwidth from unicode and ansi font */
1899  TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
1900 
1901  if (RealFont)
1902  {
1903  TM->tmWeight = FontGDI->OriginalWeight;
1904  }
1905  else
1906  {
1907  if (FontGDI->OriginalWeight != FW_DONTCARE &&
1908  FontGDI->OriginalWeight != FW_NORMAL)
1909  {
1910  TM->tmWeight = FontGDI->OriginalWeight;
1911  }
1912  else
1913  {
1914  TM->tmWeight = FontGDI->RequestWeight;
1915  }
1916  }
1917 
1918  TM->tmOverhang = 0;
1919  TM->tmDigitizedAspectX = 96;
1920  TM->tmDigitizedAspectY = 96;
1921  if (face_has_symbol_charmap(Face) ||
1922  (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
1923  {
1924  USHORT cpOEM, cpAnsi;
1925 
1926  EngGetCurrentCodePage(&cpOEM, &cpAnsi);
1927  TM->tmFirstChar = 0;
1928  switch(cpAnsi)
1929  {
1930  case 1257: /* Baltic */
1931  TM->tmLastChar = 0xf8fd;
1932  break;
1933  default:
1934  TM->tmLastChar = 0xf0ff;
1935  }
1936  TM->tmBreakChar = 0x20;
1937  TM->tmDefaultChar = 0x1f;
1938  }
1939  else
1940  {
1941  TM->tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
1942  TM->tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
1943 
1944  if(pOS2->usFirstCharIndex <= 1)
1945  TM->tmBreakChar = pOS2->usFirstCharIndex + 2;
1946  else if (pOS2->usFirstCharIndex > 0xff)
1947  TM->tmBreakChar = 0x20;
1948  else
1949  TM->tmBreakChar = pOS2->usFirstCharIndex;
1950  TM->tmDefaultChar = TM->tmBreakChar - 1;
1951  }
1952 
1953  if (RealFont)
1954  {
1955  TM->tmItalic = FontGDI->OriginalItalic;
1956  TM->tmUnderlined = FALSE;
1957  TM->tmStruckOut = FALSE;
1958  }
1959  else
1960  {
1961  if (FontGDI->OriginalItalic || FontGDI->RequestItalic)
1962  {
1963  TM->tmItalic = 0xFF;
1964  }
1965  else
1966  {
1967  TM->tmItalic = 0;
1968  }
1969  TM->tmUnderlined = (FontGDI->RequestUnderline ? 0xFF : 0);
1970  TM->tmStruckOut = (FontGDI->RequestStrikeOut ? 0xFF : 0);
1971  }
1972 
1973  if (!FT_IS_FIXED_WIDTH(Face))
1974  {
1975  switch (pOS2->panose[PAN_PROPORTION_INDEX])
1976  {
1977  case PAN_PROP_MONOSPACED:
1978  TM->tmPitchAndFamily = 0;
1979  break;
1980  default:
1982  break;
1983  }
1984  }
1985  else
1986  {
1987  TM->tmPitchAndFamily = 0;
1988  }
1989 
1990  switch (pOS2->panose[PAN_FAMILYTYPE_INDEX])
1991  {
1992  case PAN_FAMILY_SCRIPT:
1993  TM->tmPitchAndFamily |= FF_SCRIPT;
1994  break;
1995  case PAN_FAMILY_DECORATIVE:
1997  break;
1998 
1999  case PAN_ANY:
2000  case PAN_NO_FIT:
2002  case PAN_FAMILY_PICTORIAL: /* Symbol fonts get treated as if they were text */
2003  /* Which is clearly not what the panose spec says. */
2004  if (TM->tmPitchAndFamily == 0) /* Fixed */
2005  {
2007  }
2008  else
2009  {
2010  switch (pOS2->panose[PAN_SERIFSTYLE_INDEX])
2011  {
2012  case PAN_ANY:
2013  case PAN_NO_FIT:
2014  default:
2016  break;
2017 
2018  case PAN_SERIF_COVE:
2019  case PAN_SERIF_OBTUSE_COVE:
2020  case PAN_SERIF_SQUARE_COVE:
2022  case PAN_SERIF_SQUARE:
2023  case PAN_SERIF_THIN:
2024  case PAN_SERIF_BONE:
2025  case PAN_SERIF_EXAGGERATED:
2026  case PAN_SERIF_TRIANGLE:
2027  TM->tmPitchAndFamily |= FF_ROMAN;
2028  break;
2029 
2030  case PAN_SERIF_NORMAL_SANS:
2031  case PAN_SERIF_OBTUSE_SANS:
2032  case PAN_SERIF_PERP_SANS:
2033  case PAN_SERIF_FLARED:
2034  case PAN_SERIF_ROUNDED:
2035  TM->tmPitchAndFamily |= FF_SWISS;
2036  break;
2037  }
2038  }
2039  break;
2040  default:
2042  }
2043 
2044  if (FT_IS_SCALABLE(Face))
2045  {
2047  }
2048  if (FT_IS_SFNT(Face))
2049  {
2051  }
2052 
2053  TM->tmCharSet = FontGDI->CharSet;
2054 }
#define PAN_SERIF_NORMAL_SANS
Definition: wingdi.h:479
LONG tmMaxCharWidth
Definition: wingdi.h:2367
LONG tmAscent
Definition: engobjects.h:159
#define max(a, b)
Definition: svc.c:63
BYTE tmUnderlined
Definition: wingdi.h:2377
#define PAN_FAMILY_DECORATIVE
Definition: wingdi.h:468
#define FF_DONTCARE
Definition: wingdi.h:447
LONG tmExternalLeading
Definition: wingdi.h:2365
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:2366
LONG tmDescent
Definition: wingdi.h:2363
LONG tmAscent
Definition: wingdi.h:2362
LONG tmInternalLeading
Definition: wingdi.h:2364
#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:1799
#define PAN_ANY
Definition: wingdi.h:464
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:84
LONG tmDescent
Definition: engobjects.h:160
#define PAN_SERIF_FLARED
Definition: wingdi.h:482
#define TMPF_TRUETYPE
Definition: wingdi.h:1295
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:2379
smooth NULL
Definition: ftsmooth.c:416
#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:2375
#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:2378
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
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3205
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:2369
#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:2380
#define PAN_PROPORTION_INDEX
Definition: wingdi.h:456
FT_Size_Metrics metrics
Definition: freetype.h:1677
LONG tmDigitizedAspectY
Definition: wingdi.h:2371
#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:1294
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:2374
#define FF_SCRIPT
Definition: wingdi.h:450
#define FW_NORMAL
Definition: wingdi.h:372
BYTE RequestItalic
Definition: engobjects.h:151
LONG Magic
Definition: engobjects.h:163
#define FONTGDI_MAGIC
Definition: engobjects.h:167
LONG tmWeight
Definition: wingdi.h:2368
#define PAN_SERIF_SQUARE_COVE
Definition: wingdi.h:472
LONG tmHeight
Definition: wingdi.h:2361
#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:2376
WCHAR tmFirstChar
Definition: wingdi.h:2372
#define PAN_FAMILY_TEXT_DISPLAY
Definition: wingdi.h:466
FT_Byte panose[10]
Definition: tttables.h:399
WCHAR tmLastChar
Definition: wingdi.h:2373
LONG tmDigitizedAspectX
Definition: wingdi.h:2370

Referenced by FillTM().

◆ FindBestFontFromList()

static __inline VOID FindBestFontFromList ( FONTOBJ **  FontObj,
ULONG MatchPenalty,
const LOGFONTW LogFont,
const PLIST_ENTRY  Head 
)
static

Definition at line 4727 of file freetype.c.

4730 {
4731  ULONG Penalty;
4733  PFONT_ENTRY CurrentEntry;
4734  FONTGDI *FontGDI;
4735  OUTLINETEXTMETRICW *Otm = NULL;
4736  UINT OtmSize, OldOtmSize = 0;
4737  FT_Face Face;
4738 
4739  ASSERT(FontObj);
4740  ASSERT(MatchPenalty);
4741  ASSERT(LogFont);
4742  ASSERT(Head);
4743 
4744  /* Start with a pretty big buffer */
4745  OldOtmSize = 0x200;
4746  Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
4747 
4748  /* get the FontObj of lowest penalty */
4749  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
4750  {
4751  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
4752 
4753  FontGDI = CurrentEntry->Font;
4754  ASSERT(FontGDI);
4755  Face = FontGDI->SharedFace->Face;
4756 
4757  /* get text metrics */
4758  OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
4759  if (OtmSize > OldOtmSize)
4760  {
4761  if (Otm)
4763  Otm = ExAllocatePoolWithTag(PagedPool, OtmSize, GDITAG_TEXT);
4764  }
4765 
4766  /* update FontObj if lowest penalty */
4767  if (Otm)
4768  {
4769  IntLockFreeType();
4770  IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
4772 
4773  OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm);
4774  if (!OtmSize)
4775  continue;
4776 
4777  OldOtmSize = OtmSize;
4778 
4779  Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
4780  if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty)
4781  {
4782  *FontObj = GDIToObj(FontGDI, FONT);
4783  *MatchPenalty = Penalty;
4784  }
4785  }
4786  }
4787 
4788  if (Otm)
4790 }
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:4366
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2151
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:3205
#define IntUnLockFreeType()
Definition: freetype.c:81
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:78
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 2528 of file freetype.c.

2530 {
2531  ANSI_STRING StyleA;
2532  UNICODE_STRING StyleW;
2533  TT_OS2 *pOS2;
2534  FONTSIGNATURE fs;
2535  CHARSETINFO CharSetInfo;
2536  unsigned i, Size;
2537  OUTLINETEXTMETRICW *Otm;
2538  LOGFONTW *Lf;
2539  TEXTMETRICW *TM;
2540  NEWTEXTMETRICW *Ntm;
2541  DWORD fs0;
2542  NTSTATUS status;
2543  PSHARED_FACE SharedFace = FontGDI->SharedFace;
2544  FT_Face Face = SharedFace->Face;
2545  UNICODE_STRING NameW;
2546 
2547  RtlInitUnicodeString(&NameW, NULL);
2548  RtlZeroMemory(Info, sizeof(FONTFAMILYINFO));
2549  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
2551  if (!Otm)
2552  {
2553  return;
2554  }
2555  Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm);
2556  if (!Size)
2557  {
2559  return;
2560  }
2561 
2562  Lf = &Info->EnumLogFontEx.elfLogFont;
2563  TM = &Otm->otmTextMetrics;
2564 
2565  Lf->lfHeight = TM->tmHeight;
2566  Lf->lfWidth = TM->tmAveCharWidth;
2567  Lf->lfWeight = TM->tmWeight;
2568  Lf->lfItalic = TM->tmItalic;
2569  Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
2570  Lf->lfCharSet = TM->tmCharSet;
2573  Lf->lfQuality = PROOF_QUALITY;
2574 
2575  Ntm = &Info->NewTextMetricEx.ntmTm;
2576  Ntm->tmHeight = TM->tmHeight;
2577  Ntm->tmAscent = TM->tmAscent;
2578  Ntm->tmDescent = TM->tmDescent;
2581  Ntm->tmAveCharWidth = TM->tmAveCharWidth;
2582  Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
2583  Ntm->tmWeight = TM->tmWeight;
2584  Ntm->tmOverhang = TM->tmOverhang;
2587  Ntm->tmFirstChar = TM->tmFirstChar;
2588  Ntm->tmLastChar = TM->tmLastChar;
2589  Ntm->tmDefaultChar = TM->tmDefaultChar;
2590  Ntm->tmBreakChar = TM->tmBreakChar;
2591  Ntm->tmItalic = TM->tmItalic;
2592  Ntm->tmUnderlined = TM->tmUnderlined;
2593  Ntm->tmStruckOut = TM->tmStruckOut;
2595  Ntm->tmCharSet = TM->tmCharSet;
2596  Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
2597 
2598  if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
2599 
2600  if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
2601 
2602  Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
2603  ? TRUETYPE_FONTTYPE : 0);
2604 
2605  if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
2606  Info->FontType |= RASTER_FONTTYPE;
2607 
2608 
2609  /* face name */
2610  if (!FaceName)
2611  FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
2612 
2613  RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
2614 
2615  /* full name */
2616  if (!FullName)
2617  FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
2618 
2619  RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
2620  sizeof(Info->EnumLogFontEx.elfFullName),
2621  FullName);
2622 
2623  RtlInitAnsiString(&StyleA, Face->style_name);
2624  StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
2625  StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
2626  status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
2627  if (!NT_SUCCESS(status))
2628  {
2630  return;
2631  }
2632  Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
2633 
2634  IntLockFreeType();
2635  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
2636 
2637  if (!pOS2)
2638  {
2641  return;
2642  }
2643 
2644  Ntm->ntmSizeEM = Otm->otmEMSquare;
2645  Ntm->ntmCellHeight = pOS2->usWinAscent + pOS2->usWinDescent;
2646  Ntm->ntmAvgWidth = 0;
2647 
2649 
2650  fs.fsCsb[0] = pOS2->ulCodePageRange1;
2651  fs.fsCsb[1] = pOS2->ulCodePageRange2;
2652  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
2653  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
2654  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
2655  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
2656 
2657  if (0 == pOS2->version)
2658  {
2659  FT_UInt Dummy;
2660 
2661  if (FT_Get_First_Char(Face, &Dummy) < 0x100)
2662  fs.fsCsb[0] |= FS_LATIN1;
2663  else
2664  fs.fsCsb[0] |= FS_SYMBOL;
2665  }
2667 
2668  if (fs.fsCsb[0] == 0)
2669  {
2670  /* Let's see if we can find any interesting cmaps */
2671  for (i = 0; i < (UINT)Face->num_charmaps; i++)
2672  {
2673  switch (Face->charmaps[i]->encoding)
2674  {
2675  case FT_ENCODING_UNICODE:
2676  case FT_ENCODING_APPLE_ROMAN:
2677  fs.fsCsb[0] |= FS_LATIN1;
2678  break;
2679  case FT_ENCODING_MS_SYMBOL:
2680  fs.fsCsb[0] |= FS_SYMBOL;
2681  break;
2682  default:
2683  break;
2684  }
2685  }
2686  }
2687 
2688  for (i = 0; i < MAXTCIINDEX; i++)
2689  {
2690  fs0 = 1L << i;
2691  if (fs.fsCsb[0] & fs0)
2692  {
2693  if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
2694  {
2695  CharSetInfo.ciCharset = DEFAULT_CHARSET;
2696  }
2697  if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
2698  {
2699  if (g_ElfScripts[i])
2700  wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
2701  else
2702  {
2703  DPRINT1("Unknown elfscript for bit %u\n", i);
2704  }
2705  }
2706  }
2707  }
2708  Info->NewTextMetricEx.ntmFontSig = fs;
2709 }
WCHAR tmFirstChar
Definition: wingdi.h:2633
LONG tmMaxCharWidth
Definition: wingdi.h:2367
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:179
BYTE tmUnderlined
Definition: wingdi.h:2377
FT_CharMap * charmaps
Definition: freetype.h:1085
BYTE lfPitchAndFamily
Definition: dimm.idl:71
LONG tmExternalLeading
Definition: wingdi.h:2365
#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:2366
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
BYTE lfCharSet
Definition: dimm.idl:67
LONG tmDigitizedAspectX
Definition: wingdi.h:2631
BYTE lfClipPrecision
Definition: dimm.idl:69
WCHAR tmDefaultChar
Definition: wingdi.h:2635
#define NTM_BOLD
Definition: wingdi.h:1298
LONG tmDescent
Definition: wingdi.h:2363
LONG tmAscent
Definition: wingdi.h:2362
LONG tmInternalLeading
Definition: wingdi.h:2364
Definition: fs.h:235
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define PROOF_QUALITY
Definition: wingdi.h:437
LONG tmDigitizedAspectY
Definition: wingdi.h:2632
#define MAXTCIINDEX
Definition: freetype.c:122
struct TraceInfo Info
static PWCHAR g_ElfScripts[32]
Definition: freetype.c:95
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:1295
#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:1524
BYTE tmPitchAndFamily
Definition: wingdi.h:2379
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2151
LONG lfWidth
Definition: dimm.idl:60
smooth NULL
Definition: ftsmooth.c:416
WCHAR tmBreakChar
Definition: wingdi.h:2375
FT_UShort version
Definition: tttables.h:382
BYTE tmStruckOut
Definition: wingdi.h:2378
BYTE lfOutPrecision
Definition: dimm.idl:68
LONG tmMaxCharWidth
Definition: wingdi.h:2628
#define OUT_OUTLINE_PRECIS
Definition: wingdi.h:422
static BOOLEAN APIENTRY IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:1752
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:81
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
WCHAR tmLastChar
Definition: wingdi.h:2634
BYTE tmPitchAndFamily
Definition: wingdi.h:2640
LONG tmOverhang
Definition: wingdi.h:2369
FT_Face Face
Definition: engobjects.h:129
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RASTER_FONTTYPE
Definition: wingdi.h:1089
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:2380
_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:1299
static const WCHAR L[]
Definition: oid.c:1250
#define IntLockFreeType()
Definition: freetype.c:78
LONG tmInternalLeading
Definition: wingdi.h:2625
LONG tmDigitizedAspectY
Definition: wingdi.h:2371
LONG tmExternalLeading
Definition: wingdi.h:2626
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:1294
FT_ULong ulCodePageRange1
Definition: tttables.h:419
#define GDITAG_TEXT
Definition: tags.h:171
UINT ntmCellHeight
Definition: wingdi.h:2644
PSHARED_FACE SharedFace
Definition: engobjects.h:142
WCHAR tmBreakChar
Definition: wingdi.h:2636
#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:2492
FT_UShort usWinAscent
Definition: tttables.h:414
WCHAR tmDefaultChar
Definition: wingdi.h:2374
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:2627
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG tmWeight
Definition: wingdi.h:2368
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:2361
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
LONG lfWeight
Definition: dimm.idl:63
#define NTM_ITALIC
Definition: wingdi.h:1297
static SERVICE_STATUS status
Definition: service.c:31
BYTE tmItalic
Definition: wingdi.h:2376
WCHAR tmFirstChar
Definition: wingdi.h:2372
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1091
FT_ULong ulUnicodeRange2
Definition: tttables.h:402
WCHAR tmLastChar
Definition: wingdi.h:2373
LONG tmDigitizedAspectX
Definition: wingdi.h:2370
Definition: ps.c:97

Referenced by GetFontFamilyInfoForList(), and IntGdiGetFontResourceInfo().

◆ FT_FixedFromFIXED()

static __inline FT_Fixed FT_FixedFromFIXED ( FIXED  f)
static

Definition at line 366 of file freetype.c.

367 {
368  return (FT_Fixed)((long)f.value << 16 | (unsigned long)f.fract);
369 }
GLfloat f
Definition: glext.h:7540
signed long FT_Fixed
Definition: fttypes.h:288
#define long
Definition: qsort.c:33

Referenced by ftGdiGetGlyphOutline().

◆ FT_FixedFromFloat()

static __inline FT_Fixed FT_FixedFromFloat ( FLOAT  f)
static

Definition at line 355 of file freetype.c.

356 {
357  short value = f;
358  unsigned short fract = (f - value) * 0xFFFF;
359  return (FT_Fixed)((long)value << 16 | (unsigned long)fract);
360 }
GLfloat f
Definition: glext.h:7540
GLsizei const GLfloat * value
Definition: glext.h:6069
signed long FT_Fixed
Definition: fttypes.h:288
#define f
Definition: ke_i.h:83
#define long
Definition: qsort.c:33

Referenced by ftGdiGetGlyphOutline(), and IntEscapeMatrix().

◆ ftGdiGetFontData()

DWORD FASTCALL ftGdiGetFontData ( PFONTGDI  FontGdi,
DWORD  Table,
DWORD  Offset,
PVOID  Buffer,
DWORD  Size 
)

Definition at line 4324 of file freetype.c.

4330 {
4332  FT_Face Face = FontGdi->SharedFace->Face;
4333 
4334  IntLockFreeType();
4335 
4336  if (FT_IS_SFNT(Face))
4337  {
4338  if (Table)
4339  Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
4340  (Table << 8 & 0xFF0000);
4341 
4342  if (!Buffer) Size = 0;
4343 
4344  if (Buffer && Size)
4345  {
4346  FT_Error Error;
4347  FT_ULong Needed = 0;
4348 
4349  Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
4350 
4351  if ( !Error && Needed < Size) Size = Needed;
4352  }
4353  if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
4354  Result = Size;
4355  }
4356 
4358 
4359  return Result;
4360 }
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:81
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:78
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:1291

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

3455 {
3456  PDC_ATTR pdcattr;
3457  PTEXTOBJ TextObj;
3458  PFONTGDI FontGDI;
3459  HFONT hFont = 0;
3460  GLYPHMETRICS gm;
3461  ULONG Size;
3462  FT_Face ft_face;
3463  FT_UInt glyph_index;
3464  DWORD width, height, pitch, needed = 0;
3465  FT_Bitmap ft_bitmap;
3466  FT_Error error;
3467  INT left, right, top = 0, bottom = 0;
3468  FT_Angle angle = 0;
3470  FLOAT eM11, widthRatio = 1.0;
3471  FT_Matrix transMat = identityMat;
3472  BOOL needsTransform = FALSE;
3473  INT orientation;
3474  LONG aveWidth;
3475  INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
3476  OUTLINETEXTMETRICW *potm;
3477  XFORM xForm;
3478  LOGFONTW *plf;
3479 
3480  DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
3481  cjBuf, pvBuf, pmat2);
3482 
3483  pdcattr = dc->pdcattr;
3484 
3485  MatrixS2XForm(&xForm, &dc->pdcattr->mxWorldToDevice);
3486  eM11 = xForm.eM11;
3487 
3488  hFont = pdcattr->hlfntNew;
3489  TextObj = RealizeFontInit(hFont);
3490 
3491  if (!TextObj)
3492  {
3494  return GDI_ERROR;
3495  }
3496  FontGDI = ObjToGDI(TextObj->Font, FONT);
3497  ft_face = FontGDI->SharedFace->Face;
3498 
3499  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
3500  aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
3501  orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
3502 
3503  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
3505  if (!potm)
3506  {
3508  TEXTOBJ_UnlockText(TextObj);
3509  return GDI_ERROR;
3510  }
3511  Size = IntGetOutlineTextMetrics(FontGDI, Size, potm);
3512  if (!Size)
3513  {
3514  /* FIXME: last error? */
3516  TEXTOBJ_UnlockText(TextObj);
3517  return GDI_ERROR;
3518  }
3519 
3520  IntLockFreeType();
3521  TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
3523 
3524  TEXTOBJ_UnlockText(TextObj);
3525 
3526  glyph_index = get_glyph_index_flagged(ft_face, wch, GGO_GLYPH_INDEX, iFormat);
3528 
3529  if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
3530  load_flags |= FT_LOAD_NO_BITMAP;
3531 
3532  if (iFormat & GGO_UNHINTED)
3533  {
3534  load_flags |= FT_LOAD_NO_HINTING;
3535  iFormat &= ~GGO_UNHINTED;
3536  }
3537 
3538  error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
3539  if (error)
3540  {
3541  DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
3543  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
3544  return GDI_ERROR;
3545  }
3547 
3548  if (aveWidth && potm)
3549  {
3550  widthRatio = (FLOAT)aveWidth * eM11 /
3552  }
3553 
3554  left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
3555  right = (INT)((ft_face->glyph->metrics.horiBearingX +
3556  ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
3557 
3558  adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
3559  lsb = left >> 6;
3560  bbx = (right - left) >> 6;
3561 
3562  DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
3563 
3564  IntLockFreeType();
3565 
3566  /* Width scaling transform */
3567  if (widthRatio != 1.0)
3568  {
3569  FT_Matrix scaleMat;
3570  scaleMat.xx = FT_FixedFromFloat(widthRatio);
3571  scaleMat.xy = 0;
3572  scaleMat.yx = 0;
3573  scaleMat.yy = FT_FixedFromFloat(1.0);
3574 
3575  FT_Matrix_Multiply(&scaleMat, &transMat);
3576  needsTransform = TRUE;
3577  }
3578 
3579  /* World transform */
3580  {
3581  FT_Matrix ftmatrix;
3583 
3584  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
3585  FtMatrixFromMx(&ftmatrix, pmx);
3586 
3587  if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
3588  {
3589  FT_Matrix_Multiply(&ftmatrix, &transMat);
3590  needsTransform = TRUE;
3591  }
3592  }
3593 
3594  /* Rotation transform */
3595  if (orientation)
3596  {
3597  FT_Matrix rotationMat;
3598  FT_Vector vecAngle;
3599  DPRINT("Rotation Trans!\n");
3600  angle = FT_FixedFromFloat((FLOAT)orientation / 10.0);
3601  FT_Vector_Unit(&vecAngle, angle);
3602  rotationMat.xx = vecAngle.x;
3603  rotationMat.xy = -vecAngle.y;
3604  rotationMat.yx = -rotationMat.xy;
3605  rotationMat.yy = rotationMat.xx;
3606  FT_Matrix_Multiply(&rotationMat, &transMat);
3607  needsTransform = TRUE;
3608  }
3609 
3610  /* Extra transformation specified by caller */
3611  if (pmat2)
3612  {
3613  FT_Matrix extraMat;
3614  DPRINT("MAT2 Matrix Trans!\n");
3615  extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
3616  extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
3617  extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
3618  extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
3619  FT_Matrix_Multiply(&extraMat, &transMat);
3620  needsTransform = TRUE;
3621  }
3622 
3623  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
3624 
3625  if (!needsTransform)
3626  {
3627  DPRINT("No Need to be Transformed!\n");
3628  top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
3629  bottom = (ft_face->glyph->metrics.horiBearingY -
3630  ft_face->glyph->metrics.height) & -64;
3631  gm.gmCellIncX = adv;
3632  gm.gmCellIncY = 0;
3633  }
3634  else
3635  {
3636  INT xc, yc;
3637  FT_Vector vec;
3638  for (xc = 0; xc < 2; xc++)
3639  {
3640  for (yc = 0; yc < 2; yc++)
3641  {
3642  vec.x = (ft_face->glyph->metrics.horiBearingX +
3643  xc * ft_face->glyph->metrics.width);
3644  vec.y = ft_face->glyph->metrics.horiBearingY -
3645  yc * ft_face->glyph->metrics.height;
3646  DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
3647  FT_Vector_Transform(&vec, &transMat);
3648  if (xc == 0 && yc == 0)
3649  {
3650  left = right = vec.x;
3651  top = bottom = vec.y;
3652  }
3653  else
3654  {
3655  if (vec.x < left) left = vec.x;
3656  else if (vec.x > right) right = vec.x;
3657  if (vec.y < bottom) bottom = vec.y;
3658  else if (vec.y > top) top = vec.y;
3659  }
3660  }
3661  }
3662  left = left & -64;
3663  right = (right + 63) & -64;
3664  bottom = bottom & -64;
3665  top = (top + 63) & -64;
3666 
3667  DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
3668  vec.x = ft_face->glyph->metrics.horiAdvance;
3669  vec.y = 0;
3670  FT_Vector_Transform(&vec, &transMat);
3671  gm.gmCellIncX = (vec.x+63) >> 6;
3672  gm.gmCellIncY = -((vec.y+63) >> 6);
3673  }
3674  gm.gmBlackBoxX = (right - left) >> 6;
3675  gm.gmBlackBoxY = (top - bottom) >> 6;
3676  gm.gmptGlyphOrigin.x = left >> 6;
3677  gm.gmptGlyphOrigin.y = top >> 6;
3678 
3679  DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
3680  gm.gmCellIncX, gm.gmCellIncY,
3681  gm.gmBlackBoxX, gm.gmBlackBoxY,
3683 
3685 
3686 
3687  if (iFormat == GGO_METRICS)
3688  {
3689  DPRINT("GGO_METRICS Exit!\n");
3690  *pgm = gm;
3691  return 1; /* FIXME */
3692  }
3693 
3694  if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
3695  {
3696  DPRINT1("Loaded a bitmap\n");
3697  return GDI_ERROR;
3698  }
3699 
3700  switch (iFormat)
3701  {
3702  case GGO_BITMAP:
3703  {
3704  width = gm.gmBlackBoxX;
3705  height = gm.gmBlackBoxY;
3706  pitch = ((width + 31) >> 5) << 2;
3707  needed = pitch * height;
3708 
3709  if (!pvBuf || !cjBuf) break;
3710  if (!needed) return GDI_ERROR; /* empty glyph */
3711  if (needed > cjBuf)
3712  return GDI_ERROR;
3713 
3714  switch (ft_face->glyph->format)
3715  {
3717  {
3718  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
3719  INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
3720  INT h = min( height, ft_face->glyph->bitmap.rows );
3721  while (h--)
3722  {
3723  RtlCopyMemory(dst, src, w);
3724  src += ft_face->glyph->bitmap.pitch;
3725  dst += pitch;
3726  }
3727  break;
3728  }
3729 
3731  {
3732  ft_bitmap.width = width;
3733  ft_bitmap.rows = height;
3734  ft_bitmap.pitch = pitch;
3735  ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
3736  ft_bitmap.buffer = pvBuf;
3737 
3738  IntLockFreeType();
3739  if (needsTransform)
3740  {
3741  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
3742  }
3743  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
3744  /* Note: FreeType will only set 'black' bits for us. */
3745  RtlZeroMemory(pvBuf, needed);
3746  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
3748  break;
3749  }
3750 
3751  default:
3752  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
3753  return GDI_ERROR;
3754  }
3755 
3756  break;
3757  }
3758 
3759  case GGO_GRAY2_BITMAP:
3760  case GGO_GRAY4_BITMAP:
3761  case GGO_GRAY8_BITMAP:
3762  {
3763  unsigned int mult, row, col;
3764  BYTE *start, *ptr;
3765 
3766  width = gm.gmBlackBoxX;
3767  height = gm.gmBlackBoxY;
3768  pitch = (width + 3) / 4 * 4;
3769  needed = pitch * height;
3770 
3771  if (!pvBuf || !cjBuf) break;
3772  if (!needed) return GDI_ERROR; /* empty glyph */
3773  if (needed > cjBuf)
3774  return GDI_ERROR;
3775 
3776  switch (ft_face->glyph->format)
3777  {
3779  {
3780  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
3781  INT h = min( height, ft_face->glyph->bitmap.rows );
3782  INT x;
3783  while (h--)
3784  {
3785  for (x = 0; (UINT)x < pitch; x++)
3786  {
3787  if (x < ft_face->glyph->bitmap.width)
3788  dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
3789  else
3790  dst[x] = 0;
3791  }
3792  src += ft_face->glyph->bitmap.pitch;
3793  dst += pitch;
3794  }
3795  break;
3796  }
3798  {
3799  ft_bitmap.width = width;
3800  ft_bitmap.rows = height;
3801  ft_bitmap.pitch = pitch;
3802  ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
3803  ft_bitmap.buffer = pvBuf;
3804 
3805  IntLockFreeType();
3806  if (needsTransform)
3807  {
3808  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
3809  }
3810  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
3811  RtlZeroMemory(ft_bitmap.buffer, cjBuf);
3812  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
3814 
3815  if (iFormat == GGO_GRAY2_BITMAP)
3816  mult = 4;
3817  else if (iFormat == GGO_GRAY4_BITMAP)
3818  mult = 16;
3819  else if (iFormat == GGO_GRAY8_BITMAP)
3820  mult = 64;
3821  else
3822  {
3823  return GDI_ERROR;
3824  }
3825 
3826  start = pvBuf;
3827  for (row = 0; row < height; row++)
3828  {
3829  ptr = start;
3830  for (col = 0; col < width; col++, ptr++)
3831  {
3832  *ptr = (((int)*ptr) * mult + 128) / 256;
3833  }
3834  start += pitch;
3835  }
3836 
3837  break;
3838  }
3839  default:
3840  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
3841  return GDI_ERROR;
3842  }
3843 
3844  break;
3845  }
3846 
3847  case GGO_NATIVE:
3848  {
3849  FT_Outline *outline = &ft_face->glyph->outline;
3850 
3851  if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
3852 
3853  IntLockFreeType();
3854  if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
3855 
3857 
3858  if (!pvBuf || !cjBuf)
3859  {
3861  break;
3862  }
3863  if (needed > cjBuf)
3864  {
3866  return GDI_ERROR;
3867  }
3870  break;
3871  }
3872 
3873  case GGO_BEZIER:
3874  {
3875  FT_Outline *outline = &ft_face->glyph->outline;
3876  if (cjBuf == 0) pvBuf = NULL;
3877 
3878  if (needsTransform && pvBuf)
3879  {
3880  IntLockFreeType();
3881  FT_Outline_Transform(outline, &transMat);
3883  }
3885 
3886  if (!pvBuf || !cjBuf)
3887  break;
3888  if (needed > cjBuf)
3889  return GDI_ERROR;
3890 
3892  break;
3893  }
3894 
3895  default:
3896  DPRINT1("Unsupported format %u\n", iFormat);
3897  return GDI_ERROR;
3898  }
3899 
3900  DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
3901  *pgm = gm;
3902  return needed;
3903 }
#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)
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
#define FLOAT
Definition: i386-dis.c:516
long x
Definition: polytest.cpp:48
FT_Pos x
Definition: ftimage.h:76
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
signed int FT_Int
Definition: fttypes.h:220
FT_Glyph_Metrics metrics
Definition: freetype.h:1916
LONG tmAveCharWidth
Definition: wingdi.h:2366
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INT
Definition: polytest.cpp:20
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3010
static __inline FT_Fixed FT_FixedFromFIXED(FIXED f)
Definition: freetype.c:366
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned char * buffer
Definition: ftimage.h:266
#define GGO_GRAY4_BITMAP
Definition: wingdi.h:852
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC dc
Definition: cylfrac.c:34
short gmCellIncY
Definition: wingdi.h:2424
FT_Matrix_Multiply(const FT_Matrix *a, FT_Matrix *b)
Definition: ftcalc.c:661
GLfloat angle
Definition: glext.h:10853
#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
FT_Fixed xx
Definition: fttypes.h:387
BOOL FASTCALL TextIntUpdateSize(PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:3324
Definition: text.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
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:327
static PVOID ptr
Definition: dispmode.c:27
#define GGO_NATIVE
Definition: wingdi.h:849
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2151
LONG lfWidth
Definition: dimm.idl:60
smooth NULL
Definition: ftsmooth.c:416
FT_Library g_FreeTypeLibrary
Definition: freetype.c:51
void DPRINT(...)
Definition: polytest.cpp:61
GLint GLint bottom
Definition: glext.h:7726
FIXED eM22
Definition: wingdi.h:2454
FIXED eM11
Definition: wingdi.h:2451
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
FIXED eM21
Definition: wingdi.h:2453
static __inline FT_Fixed FT_FixedFromFloat(FLOAT f)
Definition: freetype.c:355
#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:731
POINT gmptGlyphOrigin
Definition: wingdi.h:2422
#define IntUnLockFreeType()
Definition: freetype.c:81
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
Definition: fttrigon.h:52
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:3007
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
#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:3080
FLOAT eM11
Definition: wingdi.h:1699
#define IntLockFreeType()
Definition: freetype.c:78
#define MatrixS2XForm(x, m)
Definition: coord.h:19
FT_Outline outline
Definition: freetype.h:1927
FT_Vector_Unit(FT_Vector *vec, FT_Angle angle)
Definition: fttrigon.c:361
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:3426
FIXED eM12
Definition: wingdi.h:2452
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:2423
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
FT_Glyph_Format format
Definition: freetype.h:1921
FONTOBJ * Font
Definition: text.h:66
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:2421
#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:2492
#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:46
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:2680
UINT gmBlackBoxX
Definition: wingdi.h:2420
float FLOAT
Definition: typedefs.h:67
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:96
#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:2757
FT_Fixed yy
Definition: fttypes.h:388
FORCEINLINE VOID FASTCALL FtSetCoordinateTransform(FT_Face face, PMATRIX pmx)
Definition: freetype.c:754
#define GDI_ERROR
Definition: wingdi.h:1291
#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 5364 of file freetype.c.

5367 {
5368  DWORD Count = 0;
5369  INT i = 0;
5370  FT_Face face = Font->SharedFace->Face;
5371 
5372  if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
5373  {
5374  FT_UInt previous_index = 0, glyph_index = 0;
5375  FT_ULong char_code, char_previous;
5376  FT_Vector delta;
5377 
5378  char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
5379 
5380  IntLockFreeType();
5381 
5382  while (glyph_index)
5383  {
5384  if (previous_index && glyph_index)
5385  {
5386  FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
5387 
5388  if (pKerningPair && cPairs)
5389  {
5390  pKerningPair[i].wFirst = char_previous;
5391  pKerningPair[i].wSecond = char_code;
5392  pKerningPair[i].iKernAmount = delta.x;
5393  i++;
5394  if (i == cPairs) break;
5395  }
5396  Count++;
5397  }
5398  previous_index = glyph_index;
5399  char_previous = char_code;
5400  char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
5401  }
5403  }
5404  return Count;
5405 }
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:2443
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:2444
#define IntUnLockFreeType()
Definition: freetype.c:81
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:78
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 2832 of file freetype.c.

2833 {
2834  if ( lprs )
2835  {
2836  lprs->nSize = sizeof(RASTERIZER_STATUS);
2837  lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
2838  lprs->nLanguageID = gusLanguageID;
2839  return TRUE;
2840  }
2842  return FALSE;
2843 }
#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
SHORT 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 4047 of file freetype.c.

4051 {
4052  PDC_ATTR pdcattr;
4053  UINT Ret = DEFAULT_CHARSET;
4054  INT i;
4055  HFONT hFont;
4056  PTEXTOBJ TextObj;
4057  PFONTGDI FontGdi;
4058  FONTSIGNATURE fs;
4059  TT_OS2 *pOS2;
4060  FT_Face Face;
4061  CHARSETINFO csi;
4062  DWORD cp, fs0;
4063  USHORT usACP, usOEM;
4064 
4065  pdcattr = Dc->pdcattr;
4066  hFont = pdcattr->hlfntNew;
4067  TextObj = RealizeFontInit(hFont);
4068 
4069  if (!TextObj)
4070  {
4072  return Ret;
4073  }
4074  FontGdi = ObjToGDI(TextObj->Font, FONT);
4075  Face = FontGdi->SharedFace->Face;
4076  TEXTOBJ_UnlockText(TextObj);
4077 
4078  memset(&fs, 0, sizeof(FONTSIGNATURE));
4079  IntLockFreeType();
4080  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4081  if (NULL != pOS2)
4082  {
4083  fs.fsCsb[0] = pOS2->ulCodePageRange1;
4084  fs.fsCsb[1] = pOS2->ulCodePageRange2;
4085  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
4086  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
4087  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
4088  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
4089  if (pOS2->version == 0)
4090  {
4091  FT_UInt dummy;
4092 
4093  if (FT_Get_First_Char( Face, &dummy ) < 0x100)
4094  fs.fsCsb[0] |= FS_LATIN1;
4095  else
4096  fs.fsCsb[0] |= FS_SYMBOL;
4097  }
4098  }
4099  pOS2 = NULL;
4101  DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
4102  if (fs.fsCsb[0] == 0)
4103  { /* Let's see if we can find any interesting cmaps */
4104  for (i = 0; i < Face->num_charmaps; i++)
4105  {
4106  switch (Face->charmaps[i]->encoding)
4107  {
4108  case FT_ENCODING_UNICODE:
4109  case FT_ENCODING_APPLE_ROMAN:
4110  fs.fsCsb[0] |= FS_LATIN1;
4111  break;
4112  case FT_ENCODING_MS_SYMBOL:
4113  fs.fsCsb[0] |= FS_SYMBOL;
4114  break;
4115  default:
4116  break;
4117  }
4118  }
4119  }
4120  if (lpSig)
4121  {
4122  RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
4123  }
4124 
4125  RtlGetDefaultCodePage(&usACP, &usOEM);
4126  cp = usACP;
4127 
4129  if (csi.fs.fsCsb[0] & fs.fsCsb[0])
4130  {
4131  DPRINT("Hit 1\n");
4132  Ret = csi.ciCharset;
4133  goto Exit;
4134  }
4135 
4136  for (i = 0; i < MAXTCIINDEX; i++)
4137  {
4138  fs0 = 1L << i;
4139  if (fs.fsCsb[0] & fs0)
4140  {
4141  if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
4142  {
4143  // *cp = csi.ciACP;
4144  DPRINT("Hit 2\n");
4145  Ret = csi.ciCharset;
4146  goto Exit;
4147  }
4148  else
4149  DPRINT1("TCI failing on %x\n", fs0);
4150  }
4151  }
4152 Exit:
4153  DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
4154  return (MAKELONG(csi.ciACP, csi.ciCharset));
4155 }
FONTSIGNATURE fs
Definition: wingdi.h:1526
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:122
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:327
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
UINT ciCharset
Definition: wingdi.h:1524
#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:1752
#define FS_SYMBOL
Definition: wingdi.h:574
static void Exit(void)
Definition: sock.c:1331
#define IntUnLockFreeType()
Definition: freetype.c:81
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:78
FT_Int num_charmaps
Definition: freetype.h:1084
FONTOBJ * Font
Definition: text.h:66
DWORD fsCsb[2]
Definition: wingdi.h:1521
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:60
#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 4228 of file freetype.c.

4231 {
4232  PDC dc;
4233  PDC_ATTR pdcattr;
4234  PTEXTOBJ TextObj;
4235  PFONTGDI FontGDI;
4236  FT_Face Face;
4237  TT_OS2 *pOS2;
4238  TT_HoriHeader *pHori;
4239  FT_WinFNT_HeaderRec Win;
4240  ULONG Error;
4242  LOGFONTW *plf;
4243 
4244  if (!ptmwi)
4245  {
4247  return FALSE;
4248  }
4249 
4250  if (!(dc = DC_LockDc(hDC)))
4251  {
4253  return FALSE;
4254  }
4255  pdcattr = dc->pdcattr;
4256  TextObj = RealizeFontInit(pdcattr->hlfntNew);
4257  if (NULL != TextObj)
4258  {
4259  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4260  FontGDI = ObjToGDI(TextObj->Font, FONT);
4261 
4262  Face = FontGDI->SharedFace->Face;
4263 
4264  IntLockFreeType();
4265  Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4268 
4269  if (0 != Error)
4270  {
4271  DPRINT1("Error in setting pixel sizes: %u\n", Error);
4273  }
4274  else
4275  {
4276  FT_Face Face = FontGDI->SharedFace->Face;
4278 
4279  IntLockFreeType();
4280  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4281  if (NULL == pOS2)
4282  {
4283  DPRINT1("Can't find OS/2 table - not TT font?\n");
4285  }
4286 
4287  pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
4288  if (NULL == pHori)
4289  {
4290  DPRINT1("Can't find HHEA table - not TT font?\n");
4292  }
4293 
4294  Error = FT_Get_WinFNT_Header(Face, &Win);
4295 
4296  if (NT_SUCCESS(Status))
4297  {
4298  FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
4299 
4300  /* FIXME: Fill Diff member */
4301  RtlZeroMemory(&ptmwi->Diff, sizeof(ptmwi->Diff));
4302  }
4303 
4305  }
4306  TEXTOBJ_UnlockText(TextObj);
4307  }
4308  else
4309  {
4311  }
4312  DC_UnlockDc(dc);
4313 
4314  if (!NT_SUCCESS(Status))
4315  {
4317  return FALSE;
4318  }
4319  return TRUE;
4320 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:364
#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
HDC dc
Definition: cylfrac.c:34
#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:327
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:2057
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:3205
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IntUnLockFreeType()
Definition: freetype.c:81
BOOL Error
Definition: chkdsk.c:66
FT_Face Face
Definition: engobjects.h:129
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define IntLockFreeType()
Definition: freetype.c:78
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:365
LOGFONTW elfLogFont
Definition: wingdi.h:2680
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:96
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2757
FORCEINLINE VOID FASTCALL FtSetCoordinateTransform(FT_Face face, PMATRIX pmx)
Definition: freetype.c:754
return STATUS_SUCCESS
Definition: btrfs.c:2725
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 2858 of file freetype.c.

2864 {
2865  PLIST_ENTRY CurrentEntry;
2866  PFONT_CACHE_ENTRY FontEntry;
2867 
2869 
2870  for (CurrentEntry = g_FontCacheListHead.Flink;
2871  CurrentEntry != &g_FontCacheListHead;
2872  CurrentEntry = CurrentEntry->Flink)
2873  {
2874  FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
2875  if ((FontEntry->Face == Face) &&
2876  (FontEntry->GlyphIndex == GlyphIndex) &&
2877  (FontEntry->Height == Height) &&
2878  (FontEntry->RenderMode == RenderMode) &&
2879  (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx)))
2880  break;
2881  }
2882 
2883  if (CurrentEntry == &g_FontCacheListHead)
2884  {
2885  return NULL;
2886  }
2887 
2888  RemoveEntryList(CurrentEntry);
2889  InsertHeadList(&g_FontCacheListHead, CurrentEntry);
2890  return FontEntry->BitmapGlyph;
2891 }
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:84
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:34
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
static BOOL SameScaleMatrix(PMATRIX pmx1, PMATRIX pmx2)
Definition: freetype.c:2847
int Height
Definition: font.h:32
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:92
Definition: font.h:26
Definition: typedefs.h:117
FT_Render_Mode RenderMode
Definition: font.h:33

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

2943 {
2944  FT_Glyph GlyphCopy;
2945  INT error;
2946  PFONT_CACHE_ENTRY NewEntry;
2947  FT_Bitmap AlignedBitmap;
2948  FT_BitmapGlyph BitmapGlyph;
2949 
2951 
2952  error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
2953  if (error)
2954  {
2955  DPRINT1("Failure caching glyph.\n");
2956  return NULL;
2957  };
2958 
2959  error = FT_Glyph_To_Bitmap(&GlyphCopy, RenderMode, 0, 1);
2960  if (error)
2961  {
2962  FT_Done_Glyph(GlyphCopy);
2963  DPRINT1("Failure rendering glyph.\n");
2964  return NULL;
2965  };
2966 
2968  if (!NewEntry)
2969  {
2970  DPRINT1("Alloc failure caching glyph.\n");
2971  FT_Done_Glyph(GlyphCopy);
2972  return NULL;
2973  }
2974 
2975  BitmapGlyph = (FT_BitmapGlyph)GlyphCopy;
2976  FT_Bitmap_New(&AlignedBitmap);
2977  if(FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
2978  {
2979  DPRINT1("Conversion failed\n");
2980  ExFreePoolWithTag(NewEntry, TAG_FONT);
2981  FT_Bitmap_Done(GlyphSlot->library, &AlignedBitmap);
2982  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
2983  return NULL;
2984  }
2985 
2986  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
2987  BitmapGlyph->bitmap = AlignedBitmap;
2988 
2989  NewEntry->GlyphIndex = GlyphIndex;
2990  NewEntry->Face = Face;
2991  NewEntry->BitmapGlyph = BitmapGlyph;
2992  NewEntry->Height = Height;
2993  NewEntry->RenderMode = RenderMode;
2994  NewEntry->mxWorldToDevice = *pmx;
2995 
2998  {
3000  RemoveCachedEntry(NewEntry);
3001  }
3002 
3003  return BitmapGlyph;
3004 }
FT_Bitmap bitmap
Definition: ftglyph.h:165
#define error(str)
Definition: mkdosfs.c:1605
static UINT g_FontCacheNumEntries
Definition: freetype.c:93
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:84
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:90
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:34
static void RemoveCachedEntry(PFONT_CACHE_ENTRY Entry)
Definition: freetype.c:256
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:92
#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:33
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 2895 of file freetype.c.

2899 {
2900  FT_Glyph Glyph;
2901  INT error;
2902  FT_Bitmap AlignedBitmap;
2903  FT_BitmapGlyph BitmapGlyph;
2904 
2905  error = FT_Get_Glyph(GlyphSlot, &Glyph);
2906  if (error)
2907  {
2908  DPRINT1("Failure getting glyph.\n");
2909  return NULL;
2910  }
2911 
2912  error = FT_Glyph_To_Bitmap(&Glyph, RenderMode, 0, 1);
2913  if (error)
2914  {
2915  FT_Done_Glyph(Glyph);
2916  DPRINT1("Failure rendering glyph.\n");
2917  return NULL;
2918  }
2919 
2920  BitmapGlyph = (FT_BitmapGlyph)Glyph;
2921  FT_Bitmap_New(&AlignedBitmap);
2922  if (FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
2923  {
2924  DPRINT1("Conversion failed\n");
2925  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
2926  return NULL;
2927  }
2928 
2929  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
2930  BitmapGlyph->bitmap = AlignedBitmap;
2931 
2932  return BitmapGlyph;
2933 }
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 5345 of file freetype.c.

5346 {
5347  if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
5348  Info->iTechnology = RI_TECH_BITMAP;
5349  else
5350  {
5351  if (FT_IS_SCALABLE(Font->SharedFace->Face))
5352  Info->iTechnology = RI_TECH_SCALABLE;
5353  else
5354  Info->iTechnology = RI_TECH_FIXED;
5355  }
5356  Info->iUniq = Font->FontObj.iUniq;
5357  Info->dwUnknown = -1;
5358  return TRUE;
5359 }
#define TRUE
Definition: types.h:120
#define RI_TECH_BITMAP
Definition: ntgdityp.h:265
struct TraceInfo Info
#define RI_TECH_SCALABLE
Definition: ntgdityp.h:267
#define FT_HAS_FIXED_SIZES(face)
Definition: freetype.h:1361
#define RI_TECH_FIXED
Definition: ntgdityp.h:266
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312

Referenced by NtGdiGetRealizationInfo().

◆ ftGetFontUnicodeRanges()

DWORD FASTCALL ftGetFontUnicodeRanges ( PFONTGDI  Font,
PGLYPHSET  glyphset 
)

Definition at line 4160 of file freetype.c.

4161 {
4162  DWORD size = 0;
4163  DWORD num_ranges = 0;
4164  FT_Face face = Font->SharedFace->Face;
4165 
4166  if (face->charmap->encoding == FT_ENCODING_UNICODE)
4167  {
4168  FT_UInt glyph_code = 0;
4169  FT_ULong char_code, char_code_prev;
4170 
4171  char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
4172 
4173  DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
4174  face->num_glyphs, glyph_code, char_code);
4175 
4176  if (!glyph_code) return 0;
4177 
4178  if (glyphset)
4179  {
4180  glyphset->ranges[0].wcLow = (USHORT)char_code;
4181  glyphset->ranges[0].cGlyphs = 0;
4182  glyphset->cGlyphsSupported = 0;
4183  }
4184 
4185  num_ranges = 1;
4186  while (glyph_code)
4187  {
4188  if (char_code < char_code_prev)
4189  {
4190  DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
4191  return 0;
4192  }
4193  if (char_code - char_code_prev > 1)
4194  {
4195  num_ranges++;
4196  if (glyphset)
4197  {
4198  glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
4199  glyphset->ranges[num_ranges - 1].cGlyphs = 1;
4200  glyphset->cGlyphsSupported++;
4201  }
4202  }
4203  else if (glyphset)
4204  {
4205  glyphset->ranges[num_ranges - 1].cGlyphs++;
4206  glyphset->cGlyphsSupported++;
4207  }
4208  char_code_prev = char_code;
4209  char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
4210  }
4211  }
4212  else
4213  DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
4214 
4215  size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
4216  if (glyphset)
4217  {
4218  glyphset->cbThis = size;
4219  glyphset->cRanges = num_ranges;
4220  glyphset->flAccel = 0;
4221  }
4222  return size;
4223 }
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 731 of file freetype.c.

732 {
733  FLOATOBJ ef;
734 
735  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
736  ef = pmx->efM11;
737  FLOATOBJ_MulLong(&ef, 0x00010000);
738  pmat->xx = FLOATOBJ_GetLong(&ef);
739 
740  ef = pmx->efM21;
741  FLOATOBJ_MulLong(&ef, 0x00010000);
742  pmat->xy = FLOATOBJ_GetLong(&ef);
743 
744  ef = pmx->efM12;
745  FLOATOBJ_MulLong(&ef, 0x00010000);
746  pmat->yx = FLOATOBJ_GetLong(&ef);
747 
748  ef = pmx->efM22;
749  FLOATOBJ_MulLong(&ef, 0x00010000);
750  pmat->yy = FLOATOBJ_GetLong(&ef);
751 }
FLOATOBJ efM21
Definition: ntgdityp.h:408
#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:407
FLOATOBJ efM22
Definition: ntgdityp.h:409
FT_Fixed xy
Definition: fttypes.h:387
FLOATOBJ efM11
Definition: ntgdityp.h:406
FT_Fixed yx
Definition: fttypes.h:388
FT_Fixed yy
Definition: fttypes.h:388

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

◆ FtSetCoordinateTransform()

FORCEINLINE VOID FASTCALL FtSetCoordinateTransform ( FT_Face  face,
PMATRIX  pmx 
)

Definition at line 754 of file freetype.c.

757 {
758  FT_Matrix mat;
759  FtMatrixFromMx(&mat, pmx);
760 
761  /* Set the transformation matrix */
762  FT_Set_Transform(face, &mat, 0);
763 }
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:653
static const MAT2 mat
Definition: font.c:66
VOID FASTCALL FtMatrixFromMx(FT_Matrix *pmat, PMATRIX pmx)
Definition: freetype.c:731
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

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

◆ FTVectorToPOINTFX()

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

Definition at line 340 of file freetype.c.

341 {
342  pt->x.value = vec->x >> 6;
343  pt->x.fract = (vec->x & 0x3f) << 10;
344  pt->x.fract |= ((pt->x.fract >> 6) | (pt->x.fract >> 12));
345  pt->y.value = vec->y >> 6;
346  pt->y.fract = (vec->y & 0x3f) << 10;
347  pt->y.fract |= ((pt->y.fract >> 6) | (pt->y.fract >> 12));
348 }
FT_Pos y
Definition: ftimage.h:77
FT_Pos x
Definition: ftimage.h:76
#define pt(x, y)
Definition: drawing.c:79
char * value
Definition: wpp.c:37
FT_Vector * vec
Definition: ftbbox.c:448

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

3081 {
3082  /* Convert the quadratic Beziers to cubic Beziers.
3083  The parametric eqn for a cubic Bezier is, from PLRM:
3084  r(t) = at^3 + bt^2 + ct + r0
3085  with the control points:
3086  r1 = r0 + c/3
3087  r2 = r1 + (c + b)/3
3088  r3 = r0 + c + b + a
3089 
3090  A quadratic Bezier has the form:
3091  p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
3092 
3093  So equating powers of t leads to:
3094  r1 = 2/3 p1 + 1/3 p0
3095  r2 = 2/3 p1 + 1/3 p2
3096  and of course r0 = p0, r3 = p2
3097  */
3098  int contour, point = 0, first_pt;
3099  TTPOLYGONHEADER *pph;
3100  TTPOLYCURVE *ppc;
3101  DWORD pph_start, cpfx, type;
3102  FT_Vector cubic_control[4];
3103  unsigned int needed = 0;
3104 
3105  for (contour = 0; contour < outline->n_contours; contour++)
3106  {
3107  pph_start = needed;
3108  pph = (TTPOLYGONHEADER *)(buf + needed);
3109  first_pt = point;
3110  if (buf)
3111  {
3112  pph->dwType = TT_POLYGON_TYPE;
3113  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3114  }
3115  needed += sizeof(*pph);
3116  point++;
3117  while (point <= outline->contours[contour])
3118  {
3119  ppc = (TTPOLYCURVE *)(buf + needed);
3120  type = outline->tags[point] & FT_Curve_Tag_On ?
3122  cpfx = 0;
3123  do
3124  {
3125  if (type == TT_PRIM_LINE)
3126  {
3127  if (buf)
3128  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3129  cpfx++;
3130  point++;
3131  }
3132  else
3133  {
3134  /* Unlike QSPLINEs, CSPLINEs always have their endpoint
3135  so cpfx = 3n */
3136 
3137  /* FIXME: Possible optimization in endpoint calculation
3138  if there are two consecutive curves */
3139  cubic_control[0] = outline->points[point-1];
3140  if (!(outline->tags[point-1] & FT_Curve_Tag_On))
3141  {
3142  cubic_control[0].x += outline->points[point].x + 1;
3143  cubic_control[0].y += outline->points[point].y + 1;
3144  cubic_control[0].x >>= 1;
3145  cubic_control[0].y >>= 1;
3146  }
3147  if (point+1 > outline->contours[contour])
3148  cubic_control[3] = outline->points[first_pt];
3149  else
3150  {
3151  cubic_control[3] = outline->points[point+1];
3152  if (!(outline->tags[point+1] & FT_Curve_Tag_On))
3153  {
3154  cubic_control[3].x += outline->points[point].x + 1;
3155  cubic_control[3].y += outline->points[point].y + 1;
3156  cubic_control[3].x >>= 1;
3157  cubic_control[3].y >>= 1;
3158  }
3159  }
3160  /* r1 = 1/3 p0 + 2/3 p1
3161  r2 = 1/3 p2 + 2/3 p1 */
3162  cubic_control[1].x = (2 * outline->points[point].x + 1) / 3;
3163  cubic_control[1].y = (2 * outline->points[point].y + 1) / 3;
3164  cubic_control[2] = cubic_control[1];
3165  cubic_control[1].x += (cubic_control[0].x + 1) / 3;
3166  cubic_control[1].y += (cubic_control[0].y + 1) / 3;
3167  cubic_control[2].x += (cubic_control[3].x + 1) / 3;
3168  cubic_control[2].y += (cubic_control[3].y + 1) / 3;
3169  if (buf)
3170  {
3171  FTVectorToPOINTFX(&cubic_control[1], &ppc->apfx[cpfx]);
3172  FTVectorToPOINTFX(&cubic_control[2], &ppc->apfx[cpfx+1]);
3173  FTVectorToPOINTFX(&cubic_control[3], &ppc->apfx[cpfx+2]);
3174  }
3175  cpfx += 3;
3176  point++;
3177  }
3178  } while (point <= outline->contours[contour] &&
3179  (outline->tags[point] & FT_Curve_Tag_On) ==
3180  (outline->tags[point-1] & FT_Curve_Tag_On));
3181  /* At the end of a contour Windows adds the start point,
3182  but only for Beziers and we've already done that.
3183  */
3184  if (point <= outline->contours[contour] &&
3185  outline->tags[point] & FT_Curve_Tag_On)
3186  {
3187  /* This is the closing pt of a bezier, but we've already
3188  added it, so just inc point and carry on */
3189  point++;
3190  }
3191  if (buf)
3192  {
3193  ppc->wType = type;
3194  ppc->cpfx = cpfx;
3195  }
3196  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3197  }
3198  if (buf)
3199  pph->cb = needed - pph_start;
3200  }
3201  return needed;
3202 }
#define FT_Curve_Tag_On
Definition: ftimage.h:465
FT_Pos y
Definition: ftimage.h:77
#define TT_POLYGON_TYPE
Definition: wingdi.h:1300
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:340
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:1303
POINTFX apfx[1]
Definition: wingdi.h:2692
unsigned long DWORD
Definition: ntddk_ex.h:95
POINTFX pfxStart
Definition: wingdi.h:2697
Definition: mesh.c:5329
#define TT_PRIM_LINE
Definition: wingdi.h:1301

Referenced by ftGdiGetGlyphOutline().

◆ get_glyph_index()

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

Definition at line 3411 of file freetype.c.

3412 {
3413  FT_UInt ret;
3414 
3415  if (face_has_symbol_charmap(ft_face))
3416  {
3417  ret = get_glyph_index_symbol(ft_face, glyph);
3418  if (ret != 0)
3419  return ret;
3420  }
3421 
3422  return FT_Get_Char_Index(ft_face, glyph);
3423 }
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:1799
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:3397
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 3426 of file freetype.c.

3427 {
3428  FT_UInt glyph_index;
3429  if (flags & indexed_flag)
3430  {
3431  glyph_index = code;
3432  }
3433  else
3434  {
3435  glyph_index = get_glyph_index(face, code);
3436  }
3437  return glyph_index;
3438 }
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3411
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 3397 of file freetype.c.

3398 {
3399  FT_UInt ret;
3400 
3401  if (glyph < 0x100) glyph += 0xf000;
3402  /* there are a number of old pre-Unicode "broken" TTFs, which
3403  do have symbols at U+00XX instead of U+f0XX */
3404  if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
3405  ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
3406 
3407  return ret;
3408 }
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 3007 of file freetype.c.

3008 {
3009  TTPOLYGONHEADER *pph;
3010  TTPOLYCURVE *ppc;
3011  int needed = 0, point = 0, contour, first_pt;
3012  unsigned int pph_start, cpfx;
3013  DWORD type;
3014 
3015  for (contour = 0; contour < outline->n_contours; contour++)
3016  {
3017  /* Ignore contours containing one point */
3018  if (point == outline->contours[contour])
3019  {
3020  point++;
3021  continue;
3022  }
3023 
3024  pph_start = needed;
3025  pph = (TTPOLYGONHEADER *)(buf + needed);
3026  first_pt = point;
3027  if (buf)
3028  {
3029  pph->dwType = TT_POLYGON_TYPE;
3030  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3031  }
3032  needed += sizeof(*pph);
3033  point++;
3034  while (point <= outline->contours[contour])
3035  {
3036  ppc = (TTPOLYCURVE *)(buf + needed);
3037  type = outline->tags[point] & FT_Curve_Tag_On ?
3039  cpfx = 0;
3040  do
3041  {
3042  if (buf)
3043  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3044  cpfx++;
3045  point++;
3046  } while (point <= outline->contours[contour] &&
3047  (outline->tags[point] & FT_Curve_Tag_On) ==
3048  (outline->tags[point-1] & FT_Curve_Tag_On));
3049  /* At the end of a contour Windows adds the start point, but
3050  only for Beziers */
3051  if (point > outline->contours[contour] &&
3052  !(outline->tags[point-1] & FT_Curve_Tag_On))
3053  {
3054  if (buf)
3055  FTVectorToPOINTFX(&outline->points[first_pt], &ppc->apfx[cpfx]);
3056  cpfx++;
3057  }
3058  else if (point <= outline->contours[contour] &&
3059  outline->tags[point] & FT_Curve_Tag_On)
3060  {
3061  /* add closing pt for bezier */
3062  if (buf)
3063  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3064  cpfx++;
3065  point++;
3066  }
3067  if (buf)
3068  {
3069  ppc->wType = type;
3070  ppc->cpfx = cpfx;
3071  }
3072  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3073  }
3074  if (buf)
3075  pph->cb = needed - pph_start;
3076  }
3077  return needed;
3078 }
#define FT_Curve_Tag_On
Definition: ftimage.h:465
#define TT_POLYGON_TYPE
Definition: wingdi.h:1300
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:340
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
POINTL point
Definition: edittest.c:50
#define TT_PRIM_QSPLINE
Definition: wingdi.h:1302
POINTFX apfx[1]
Definition: wingdi.h:2692
unsigned long DWORD
Definition: ntddk_ex.h:95
POINTFX pfxStart
Definition: wingdi.h:2697
Definition: mesh.c:5329
#define TT_PRIM_LINE
Definition: wingdi.h:1301

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

2718 {
2720  PFONT_ENTRY CurrentEntry;
2721  FONTGDI *FontGDI;
2722  FONTFAMILYINFO InfoEntry;
2723  LONG Count = *pCount;
2724 
2725  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
2726  {
2727  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
2728  FontGDI = CurrentEntry->Font;
2729  ASSERT(FontGDI);
2730 
2731  if (LogFont->lfCharSet != DEFAULT_CHARSET &&
2732  LogFont->lfCharSet != FontGDI->CharSet)
2733  {
2734  continue; /* charset mismatch */
2735  }
2736 
2737  /* get one info entry */
2738  FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
2739 
2740  if (LogFont->lfFaceName[0] != UNICODE_NULL)
2741  {
2742  /* check name */
2743  if (_wcsnicmp(LogFont->lfFaceName,
2745  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
2746  _wcsnicmp(LogFont->lfFaceName,
2747  InfoEntry.EnumLogFontEx.elfFullName,
2748  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
2749  {
2750  continue;
2751  }
2752  }
2753 
2754  if (NominalName)
2755  {
2756  /* store the nominal name */
2758  sizeof(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
2759  NominalName);
2760  }
2761 
2762  /* store one entry to Info */
2763  if (0 <= Count && Count < MaxCount)
2764  {
2765  RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
2766  }
2767  Count++;
2768  }
2769 
2770  *pCount = Count;
2771 
2772  return TRUE;
2773 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:179
#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:2681
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:2528
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:2680
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 2776 of file freetype.c.

2780 {
2781  PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
2782  PFONTSUBST_ENTRY pCurrentEntry;
2783  PUNICODE_STRING pFromW, pToW;
2784  LOGFONTW lf = *LogFont;
2786 
2787  for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
2788  {
2789  pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
2790 
2791  pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
2792  if (LogFont->lfFaceName[0] != UNICODE_NULL)
2793  {
2794  /* check name */
2795  if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
2796  continue; /* mismatch */
2797  }
2798 
2799  pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
2800  if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
2801  pCurrentEntry->CharSets[FONTSUBST_FROM] ==
2802  pCurrentEntry->CharSets[FONTSUBST_TO])
2803  {
2804  /* identical mapping */
2805  continue;
2806  }
2807 
2808  /* substitute and get the real name */
2809  IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
2810  SubstituteFontRecurse(&lf);
2811  if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
2812  continue;
2813 
2814  /* search in global fonts */
2816  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
2818 
2819  /* search in private fonts */
2820  IntLockProcessPrivateFonts(Win32Process);
2821  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
2822  &Win32Process->PrivateFontListHead);
2823  IntUnLockProcessPrivateFonts(Win32Process);
2824  break;
2825  }
2826 
2827  return TRUE;
2828 }
static LIST_ENTRY g_FontListHead
Definition: freetype.c:65
#define FONTSUBST_FROM
Definition: font.h:41
#define TRUE
Definition: types.h:120
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:143
BYTE lfCharSet
Definition: dimm.idl:67
static VOID IntUnicodeStringToBuffer(LPWSTR pszBuffer, USHORT cbBuffer, const UNICODE_STRING *pString)
Definition: freetype.c:828
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define IntUnLockGlobalFonts()
Definition: freetype.c:72
struct TraceInfo Info
#define UNICODE_NULL
#define FONTSUBST_TO
Definition: font.h:42
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:843
BYTE CharSets[FONTSUBST_FROM_AND_TO]
Definition: font.h:52
Definition: typedefs.h:117
#define IntLockGlobalFonts()
Definition: freetype.c:69
static BOOLEAN FASTCALL GetFontFamilyInfoForList(const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LPCWSTR NominalName, LONG *pCount, LONG MaxCount, PLIST_ENTRY Head)
Definition: freetype.c:2712
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
Definition: font.h:48
UNICODE_STRING FontNames[FONTSUBST_FROM_AND_TO]
Definition: font.h:51
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:140
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 4366 of file freetype.c.

4369 {
4370  ULONG Penalty = 0;
4371  BYTE Byte;
4372  LONG Long;
4373  BOOL fNeedScaling = FALSE;
4374  const BYTE UserCharSet = CharSetFromLangID(gusLanguageID);
4375  const TEXTMETRICW * TM = &Otm->otmTextMetrics;
4376  WCHAR* ActualNameW;
4377 
4378  ASSERT(Otm);
4379  ASSERT(LogFont);
4380 
4381  /* FIXME: IntSizeSynth Penalty 20 */
4382  /* FIXME: SmallPenalty Penalty 1 */
4383  /* FIXME: FaceNameSubst Penalty 500 */
4384 
4385  Byte = LogFont->lfCharSet;
4386  if (Byte == DEFAULT_CHARSET)
4387  {
4388  if (_wcsicmp(LogFont->lfFaceName, L"Marlett") == 0)
4389  {
4390  if (Byte == ANSI_CHARSET)
4391  {
4392  DPRINT("Warning: FIXME: It's Marlett but ANSI_CHARSET.\n");
4393  }
4394  /* We assume SYMBOL_CHARSET for "Marlett" font */
4395  Byte = SYMBOL_CHARSET;
4396  }
4397  }
4398 
4399  if (Byte != TM->tmCharSet)
4400  {
4401  if (Byte != DEFAULT_CHARSET && Byte != ANSI_CHARSET)
4402  {
4403  /* CharSet Penalty 65000 */
4404  /* Requested charset does not match the candidate's. */
4405  GOT_PENALTY("CharSet", 65000);
4406  }
4407  else
4408  {
4409  if (UserCharSet != TM->tmCharSet)
4410  {
4411  /* UNDOCUMENTED: Not user language */
4412  GOT_PENALTY("UNDOCUMENTED:NotUserLanguage", 100);
4413 
4414  if (ANSI_CHARSET != TM->tmCharSet)
4415  {
4416  /* UNDOCUMENTED: Not ANSI charset */
4417  GOT_PENALTY("UNDOCUMENTED:NotAnsiCharSet", 100);
4418  }
4419  }
4420  }
4421  }
4422 
4423  Byte = LogFont->lfOutPrecision;
4424  switch (Byte)
4425  {
4426  case OUT_DEFAULT_PRECIS:
4427  /* nothing to do */
4428  break;
4429  case OUT_DEVICE_PRECIS:
4430  if (!(TM->tmPitchAndFamily & TMPF_DEVICE) ||
4432  {
4433  /* OutputPrecision Penalty 19000 */
4434  /* Requested OUT_STROKE_PRECIS, but the device can't do it
4435  or the candidate is not a vector font. */
4436  GOT_PENALTY("OutputPrecision", 19000);
4437  }
4438  break;
4439  default:
4441  {
4442  /* OutputPrecision Penalty 19000 */
4443  /* Or OUT_STROKE_PRECIS not requested, and the candidate
4444  is a vector font that requires GDI support. */
4445  GOT_PENALTY("OutputPrecision", 19000);
4446  }
4447  break;
4448  }
4449 
4450  Byte = (LogFont->lfPitchAndFamily & 0x0F);
4451  if (Byte == DEFAULT_PITCH)
4452  Byte = VARIABLE_PITCH;
4453  if (Byte == FIXED_PITCH)
4454  {
4456  {
4457  /* FixedPitch Penalty 15000 */
4458  /* Requested a fixed pitch font, but the candidate is a
4459  variable pitch font. */
4460  GOT_PENALTY("FixedPitch", 15000);
4461  }
4462  }
4463  if (Byte == VARIABLE_PITCH)
4464  {
4466  {
4467  /* PitchVariable Penalty 350 */
4468  /* Requested a variable pitch font, but the candidate is not a
4469  variable pitch font. */
4470  GOT_PENALTY("PitchVariable", 350);
4471  }
4472  }
4473 
4474  Byte = (LogFont->lfPitchAndFamily & 0x0F);
4475  if (Byte == DEFAULT_PITCH)
4476  {
4478  {
4479  /* DefaultPitchFixed Penalty 1 */
4480  /* Requested DEFAULT_PITCH, but the candidate is fixed pitch. */
4481  GOT_PENALTY("DefaultPitchFixed", 1);
4482  }
4483  }
4484 
4485  ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
4486 
4487  if (LogFont->lfFaceName[0])
4488  {
4489  BOOL Found = FALSE;
4490 
4491  /* localized family name */
4492  if (!Found)
4493  {
4494  Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
4495  }
4496  /* localized full name */
4497  if (!Found)
4498  {
4499  ActualNameW = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFaceName);
4500  Found = (_wcsicmp(LogFont->lfFaceName, ActualNameW) == 0);
4501  }
4502  if (!Found)
4503  {
4504  /* FaceName Penalty 10000 */
4505  /* Requested a face name, but the candidate's face name
4506  does not match. */
4507  GOT_PENALTY("FaceName", 10000);
4508  }
4509  }
4510 
4511  Byte = (LogFont->lfPitchAndFamily & 0xF0);
4512  if (Byte != FF_DONTCARE)
4513  {
4514  if (Byte != (TM->tmPitchAndFamily & 0xF0))
4515  {
4516  /* Family Penalty 9000 */
4517  /* Requested a family, but the candidate's family is different. */
4518  GOT_PENALTY("Family", 9000);
4519  }
4520  }
4521 
4522  if ((TM->tmPitchAndFamily & 0xF0) == FF_DONTCARE)
4523  {
4524  /* FamilyUnknown Penalty 8000 */
4525  /* Requested a family, but the candidate has no family. */
4526  GOT_PENALTY("FamilyUnknown", 8000);
4527  }
4528 
4529  /* Is the candidate a non-vector font? */
4530  if (!(TM->tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)))
4531  {
4532  /* Is lfHeight specified? */
4533  if (LogFont->lfHeight != 0)
4534  {
4535  if (labs(LogFont->lfHeight) < TM->tmHeight)
4536  {
4537  /* HeightBigger Penalty 600 */
4538  /* The candidate is a nonvector font and is bigger than the
4539  requested height. */
4540  GOT_PENALTY("HeightBigger", 600);
4541  /* HeightBiggerDifference Penalty 150 */
4542  /* The candidate is a raster font and is larger than the
4543  requested height. Penalty * height difference */
4544  GOT_PENALTY("HeightBiggerDifference", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
4545 
4546  fNeedScaling = TRUE;
4547  }
4548  if (TM->tmHeight < labs(LogFont->lfHeight))
4549  {
4550  /* HeightSmaller Penalty 150 */
4551  /* The candidate is a raster font and is smaller than the
4552  requested height. Penalty * height difference */
4553  GOT_PENALTY("HeightSmaller", 150 * labs(TM->tmHeight - labs(LogFont->lfHeight)));
4554 
4555  fNeedScaling = TRUE;
4556  }
4557  }
4558  }
4559 
4560  switch (LogFont->lfPitchAndFamily & 0xF0)
4561  {
4562  case FF_ROMAN: case FF_MODERN: case FF_SWISS:
4563  switch (TM->tmPitchAndFamily & 0xF0)
4564  {
4565  case FF_DECORATIVE: case FF_SCRIPT:
4566  /* FamilyUnlikely Penalty 50 */
4567  /* Requested a roman/modern/swiss family, but the
4568  candidate is decorative/script. */
4569  GOT_PENALTY("FamilyUnlikely", 50);
4570  break;
4571  default:
4572  break;
4573  }
4574  break;
4575  case FF_DECORATIVE: case FF_SCRIPT:
4576  switch (TM->tmPitchAndFamily & 0xF0)
4577  {
4578  case FF_ROMAN: case FF_MODERN: case FF_SWISS:
4579  /* FamilyUnlikely Penalty 50 */
4580  /* Or requested decorative/script, and the candidate is
4581  roman/modern/swiss. */
4582  GOT_PENALTY("FamilyUnlikely", 50);
4583  break;
4584  default:
4585  break;
4586  }
4587  default:
4588  break;
4589  }
4590 
4591  if (LogFont->lfWidth != 0)
4592  {
4593  if (LogFont->lfWidth != TM->tmAveCharWidth)
4594  {
4595  /* Width Penalty 50 */
4596  /* Requested a nonzero width, but the candidate's width
4597  doesn't match. Penalty * width difference */
4598  GOT_PENALTY("Width", 50 * labs(LogFont->lfWidth - TM->tmAveCharWidth));
4599 
4600  if (!(TM->tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)))
4601  fNeedScaling = TRUE;
4602  }
4603  }
4604 
4605  if (fNeedScaling)
4606  {
4607  /* SizeSynth Penalty 50 */
4608  /* The candidate is a raster font that needs scaling by GDI. */
4609  GOT_PENALTY("SizeSynth", 50);
4610  }
4611 
4612  if (!!LogFont->lfItalic != !!TM->tmItalic)
4613  {
4614  if (!LogFont->lfItalic && ItalicFromStyle(style_name))
4615  {
4616  /* Italic Penalty 4 */
4617  /* Requested font and candidate font do not agree on italic status,
4618  and the desired result cannot be simulated. */
4619  /* Adjusted to 40 to satisfy (Oblique Penalty > Book Penalty). */
4620  GOT_PENALTY("Italic", 40);
4621  }
4622  else if (LogFont->lfItalic && !ItalicFromStyle(style_name))
4623  {
4624  /* ItalicSim Penalty 1 */
4625  /* Requested italic font but the candidate is not italic,
4626  although italics can be simulated. */
4627  GOT_PENALTY("ItalicSim", 1);
4628  }
4629  }
4630 
4631  if (LogFont->lfOutPrecision == OUT_TT_PRECIS)
4632  {
4633  if (!(TM->tmPitchAndFamily & TMPF_TRUETYPE))
4634  {
4635  /* NotTrueType Penalty 4 */
4636  /* Requested OUT_TT_PRECIS, but the candidate is not a
4637  TrueType font. */
4638  GOT_PENALTY("NotTrueType", 4);
4639  }
4640  }
4641 
4642  Long = LogFont->lfWeight;
4643  if (LogFont->lfWeight == FW_DONTCARE)
4644  Long = FW_NORMAL;
4645  if (Long != TM->tmWeight)
4646  {
4647  /* Weight Penalty 3 */
4648  /* The candidate's weight does not match the requested weight.
4649  Penalty * (weight difference/10) */
4650  GOT_PENALTY("Weight", 3 * (labs(Long - TM->tmWeight) / 10));
4651  }
4652 
4653  if (!LogFont->lfUnderline && TM->tmUnderlined)
4654  {
4655  /* Underline Penalty 3 */
4656  /* Requested font has no underline, but the candidate is
4657  underlined. */
4658  GOT_PENALTY("Underline", 3);
4659  }
4660 
4661  if (!LogFont->lfStrikeOut && TM->tmStruckOut)
4662  {
4663  /* StrikeOut Penalty 3 */
4664  /* Requested font has no strike-out, but the candidate is
4665  struck out. */
4666  GOT_PENALTY("StrikeOut", 3);
4667  }
4668 
4669  /* Is the candidate a non-vector font? */
4670  if (!(TM->tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)))
4671  {
4672  if (LogFont->lfHeight != 0 && TM->tmHeight < LogFont->lfHeight)
4673  {
4674  /* VectorHeightSmaller Penalty 2 */
4675  /* Candidate is a vector font that is smaller than the
4676  requested height. Penalty * height difference */
4677  GOT_PENALTY("VectorHeightSmaller", 2 * labs(TM->tmHeight - LogFont->lfHeight));
4678  }
4679  if (LogFont->lfHeight != 0 && TM->tmHeight > LogFont->lfHeight)
4680  {
4681  /* VectorHeightBigger Penalty 1 */
4682  /* Candidate is a vector font that is bigger than the
4683  requested height. Penalty * height difference */
4684  GOT_PENALTY("VectorHeightBigger", 1 * labs(TM->tmHeight - LogFont->lfHeight));
4685  }
4686  }
4687 
4688  if (!(TM->tmPitchAndFamily & TMPF_DEVICE))
4689  {
4690  /* DeviceFavor Penalty 2 */
4691  /* Extra penalty for all nondevice fonts. */
4692  GOT_PENALTY("DeviceFavor", 2);
4693  }
4694 
4695  if (TM->tmAveCharWidth >= 5 && TM->tmHeight >= 5)
4696  {
4697  if (TM->tmAveCharWidth / TM->tmHeight >= 3)
4698  {
4699  /* Aspect Penalty 30 */
4700