ReactOS  0.4.14-dev-49-gfb4591c
freetype.c File Reference
#include <win32k.h>
#include <gdi/eng/floatobj.h>
#include "font.h"
#include <debug.h>
Include dependency graph for freetype.c:

Go to the source code of this file.

Classes

struct  FONT_NAMES
 

Macros

#define FT_INTERNAL_INTERNAL_H   <freetype/internal/internal.h>
 
#define NDEBUG
 
#define _TMPF_VARIABLE_PITCH   TMPF_FIXED_PITCH
 
#define EMUBOLD_NEEDED(original, request)   ((request) != FW_DONTCARE) && ((request) - (original) >= FW_BOLD - FW_MEDIUM)
 
#define gmxWorldToDeviceDefault   gmxWorldToPageDefault
 
#define IntLockGlobalFonts()   ExEnterCriticalRegionAndAcquireFastMutexUnsafe(g_FontListLock)
 
#define IntUnLockGlobalFonts()   ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(g_FontListLock)
 
#define ASSERT_GLOBALFONTS_LOCK_HELD()   ASSERT(g_FontListLock->Owner == KeGetCurrentThread())
 
#define IntLockFreeType()   ExEnterCriticalRegionAndAcquireFastMutexUnsafe(g_FreeTypeLock)
 
#define IntUnLockFreeType()   ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(g_FreeTypeLock)
 
#define ASSERT_FREETYPE_LOCK_HELD()   ASSERT(g_FreeTypeLock->Owner == KeGetCurrentThread())
 
#define ASSERT_FREETYPE_LOCK_NOT_HELD()   ASSERT(g_FreeTypeLock->Owner != KeGetCurrentThread())
 
#define MAX_FONT_CACHE   256
 
#define CP_SYMBOL   42
 
#define MAXTCIINDEX   32
 
#define CP_OEMCP   1
 
#define CP_MACCP   2
 
#define PX2PT(pixels)   FT_MulDiv((pixels), 72, 96)
 
#define SCALE_X(value)   ((FT_MulFix((value), XScale) + 32) >> 6)
 
#define SCALE_Y(value)   ((FT_MulFix((value), YScale) + 32) >> 6)
 
#define FM_SEL_USE_TYPO_METRICS   0x80
 
#define GOT_PENALTY(name, value)   Penalty += (value)
 
#define VALIGN_MASK   (TA_TOP | TA_BASELINE | TA_BOTTOM)
 
#define STACK_TEXT_BUFFER_SIZE   100
 

Typedefs

typedef struct FONT_NAMES FONT_NAMES
 
typedef struct FONT_NAMESLPFONT_NAMES
 

Functions

BYTE FASTCALL IntCharSetFromCodePage (UINT uCodePage)
 
static RTL_STATIC_LIST_HEAD (g_FontSubstListHead)
 
static void SharedMem_AddRef (PSHARED_MEM Ptr)
 
static void SharedFaceCache_Init (PSHARED_FACE_CACHE Cache)
 
static PSHARED_FACE SharedFace_Create (FT_Face Face, PSHARED_MEM Memory)
 
static PSHARED_MEM SharedMem_Create (PBYTE Buffer, ULONG BufferSize, BOOL IsMapping)
 
static void SharedFace_AddRef (PSHARED_FACE Ptr)
 
static void RemoveCachedEntry (PFONT_CACHE_ENTRY Entry)
 
static void RemoveCacheEntries (FT_Face Face)
 
static void SharedMem_Release (PSHARED_MEM Ptr)
 
static void SharedFaceCache_Release (PSHARED_FACE_CACHE Cache)
 
static void SharedFace_Release (PSHARED_FACE Ptr)
 
static VOID FASTCALL CleanupFontEntryEx (PFONT_ENTRY FontEntry, PFONTGDI FontGDI)
 
static __inline VOID FASTCALL CleanupFontEntry (PFONT_ENTRY FontEntry)
 
static __inline void FTVectorToPOINTFX (FT_Vector *vec, POINTFX *pt)
 
static __inline FT_Fixed FT_FixedFromFIXED (FIXED f)
 
BOOL FASTCALL IntLoadFontSubstList (PLIST_ENTRY pHead)
 
BOOL FASTCALL InitFontSupport (VOID)
 
LONG FASTCALL IntWidthMatrix (FT_Face face, FT_Matrix *pmat, LONG lfWidth)
 
VOID FASTCALL IntEscapeMatrix (FT_Matrix *pmat, LONG lfEscapement)
 
VOID FASTCALL FtMatrixFromMx (FT_Matrix *pmat, PMATRIX pmx)
 
VOID FtSetCoordinateTransform (FT_Face face, PMATRIX pmx)
 
static BOOL SubstituteFontByList (PLIST_ENTRY pHead, PUNICODE_STRING pOutputName, PUNICODE_STRING pInputName, BYTE RequestedCharSet, BYTE CharSetMap[FONTSUBST_FROM_AND_TO])
 
static VOID IntUnicodeStringToBuffer (LPWSTR pszBuffer, SIZE_T cbBuffer, const UNICODE_STRING *pString)
 
static NTSTATUS DuplicateUnicodeString (PUNICODE_STRING Source, PUNICODE_STRING Destination)
 
static BOOL SubstituteFontRecurse (LOGFONTW *pLogFont)
 
VOID FASTCALL IntLoadSystemFonts (VOID)
 
static 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)
 
UINT FASTCALL IntGetCharSet (INT nIndex, FT_ULong CodePageRange1)
 
static INT FASTCALL IntGdiLoadFontsFromMemory (PGDI_LOAD_FONT pLoadFont)
 
static LPCWSTR FASTCALL NameFromCharSet (BYTE CharSet)
 
INT FASTCALL IntGdiAddFontResourceEx (PUNICODE_STRING FileName, DWORD Characteristics, DWORD dwFlags)
 
INT FASTCALL IntGdiAddFontResource (PUNICODE_STRING FileName, DWORD Characteristics)
 
BOOL WINAPI PathIsRelativeW (LPCWSTR lpszPath)
 
BOOL FASTCALL IntLoadFontsInRegistry (VOID)
 
HANDLE FASTCALL IntGdiAddFontMemResource (PVOID Buffer, DWORD dwSize, PDWORD pNumAdded)
 
VOID FASTCALL IntGdiCleanupMemEntry (PFONT_ENTRY_MEM Head)
 
static VOID FASTCALL UnlinkFontMemCollection (PFONT_ENTRY_COLL_MEM Collection)
 
BOOL FASTCALL IntGdiRemoveFontMemResource (HANDLE hMMFont)
 
VOID FASTCALL IntGdiCleanupPrivateFontsForProcess (VOID)
 
BOOL FASTCALL IntIsFontRenderingEnabled (VOID)
 
VOID FASTCALL IntEnableFontRendering (BOOL Enable)
 
FT_Render_Mode FASTCALL IntGetFontRenderMode (LOGFONTW *logfont)
 
NTSTATUS FASTCALL TextIntCreateFontIndirect (CONST LPLOGFONTW lf, HFONT *NewFont)
 
static BOOLEAN APIENTRY IntTranslateCharsetInfo (PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
 
static BOOL face_has_symbol_charmap (FT_Face ft_face)
 
static void FASTCALL 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 void FASTCALL FontFamilyFillInfo (PFONTFAMILYINFO Info, LPCWSTR FaceName, LPCWSTR FullName, PFONTGDI FontGDI)
 
static BOOLEAN FASTCALL GetFontFamilyInfoForList (const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LPCWSTR NominalName, LONG *pCount, LONG MaxCount, PLIST_ENTRY Head)
 
static BOOLEAN FASTCALL GetFontFamilyInfoForSubstitutes (const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LONG *pCount, LONG MaxCount)
 
BOOL FASTCALL ftGdiGetRasterizerCaps (LPRASTERIZER_STATUS lprs)
 
static BOOL SameScaleMatrix (PMATRIX pmx1, PMATRIX pmx2)
 
FT_BitmapGlyph APIENTRY ftGdiGlyphCacheGet (FT_Face Face, INT GlyphIndex, INT Height, FT_Render_Mode RenderMode, PMATRIX pmx)
 
FT_BitmapGlyph APIENTRY ftGdiGlyphSet (FT_Face Face, FT_GlyphSlot GlyphSlot, FT_Render_Mode RenderMode)
 
FT_BitmapGlyph APIENTRY ftGdiGlyphCacheSet (FT_Face Face, INT GlyphIndex, INT Height, PMATRIX pmx, FT_GlyphSlot GlyphSlot, FT_Render_Mode RenderMode)
 
static unsigned int get_native_glyph_outline (FT_Outline *outline, unsigned int buflen, char *buf)
 
static unsigned int get_bezier_glyph_outline (FT_Outline *outline, unsigned int buflen, char *buf)
 
BOOL FASTCALL TextIntUpdateSize (PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
 
static FT_UInt FASTCALL get_glyph_index_symbol (FT_Face ft_face, UINT glyph)
 
static FT_UInt FASTCALL get_glyph_index (FT_Face ft_face, UINT glyph)
 
static FT_UInt FASTCALL get_glyph_index_flagged (FT_Face face, FT_ULong code, DWORD indexed_flag, DWORD flags)
 
ULONG FASTCALL ftGdiGetGlyphOutline (PDC dc, WCHAR wch, UINT iFormat, LPGLYPHMETRICS pgm, ULONG cjBuf, PVOID pvBuf, LPMAT2 pmat2, BOOL bIgnoreRotation)
 
BOOL FASTCALL TextIntGetTextExtentPoint (PDC dc, PTEXTOBJ TextObj, LPCWSTR String, INT Count, ULONG MaxExtent, LPINT Fit, LPINT Dx, LPSIZE Size, FLONG fl)
 
INT FASTCALL ftGdiGetTextCharsetInfo (PDC Dc, LPFONTSIGNATURE lpSig, DWORD dwFlags)
 
DWORD FASTCALL ftGetFontUnicodeRanges (PFONTGDI Font, PGLYPHSET glyphset)
 
BOOL FASTCALL ftGdiGetTextMetricsW (HDC hDC, PTMW_INTERNAL ptmwi)
 
DWORD FASTCALL ftGdiGetFontData (PFONTGDI FontGdi, DWORD Table, DWORD Offset, PVOID Buffer, DWORD Size)
 
static UINT GetFontPenalty (const LOGFONTW *LogFont, const OUTLINETEXTMETRICW *Otm, const char *style_name)
 
static __inline VOID FindBestFontFromList (FONTOBJ **FontObj, ULONG *MatchPenalty, const LOGFONTW *LogFont, const PLIST_ENTRY Head)
 
static VOID FASTCALL IntFontType (PFONTGDI Font)
 
static BOOL MatchFontName (PSHARED_FACE SharedFace, LPCWSTR lfFaceName, FT_UShort NameID, FT_UShort LangID)
 
static BOOL MatchFontNames (PSHARED_FACE SharedFace, LPCWSTR lfFaceName)
 
NTSTATUS FASTCALL TextIntRealizeFont (HFONT FontHandle, PTEXTOBJ pTextObj)
 
static BOOL FASTCALL IntGetFullFileName (POBJECT_NAME_INFORMATION NameInfo, ULONG Size, PUNICODE_STRING FileName)
 
static BOOL EqualFamilyInfo (const FONTFAMILYINFO *pInfo1, const FONTFAMILYINFO *pInfo2)
 
static VOID IntAddNameFromFamInfo (LPWSTR psz, FONTFAMILYINFO *FamInfo)
 
BOOL FASTCALL IntGdiGetFontResourceInfo (PUNICODE_STRING FileName, PVOID pBuffer, DWORD *pdwBytes, DWORD dwType)
 
BOOL FASTCALL ftGdiRealizationInfo (PFONTGDI Font, PREALIZATION_INFO Info)
 
DWORD FASTCALL ftGdiGetKerningPairs (PFONTGDI Font, DWORD cPairs, LPKERNINGPAIR pKerningPair)
 
LONG FASTCALL IntGetFontFamilyInfo (HDC Dc, const LOGFONTW *SafeLogFont, PFONTFAMILYINFO SafeInfo, LONG InfoCount)
 
LONG NTAPI NtGdiGetFontFamilyInfo (HDC Dc, const LOGFONTW *UnsafeLogFont, PFONTFAMILYINFO UnsafeInfo, LPLONG UnsafeInfoCount)
 
FORCEINLINE LONG ScaleLong (LONG lValue, PFLOATOBJ pef)
 
BOOL APIENTRY IntExtTextOutW (IN PDC dc, IN INT XStart, IN INT YStart, IN UINT fuOptions, IN OPTIONAL PRECTL lprc, IN LPCWSTR String, IN INT Count, IN OPTIONAL LPINT Dx, IN DWORD dwCodePage)
 
BOOL APIENTRY GreExtTextOutW (IN HDC hDC, IN INT XStart, IN INT YStart, IN UINT fuOptions, IN OPTIONAL PRECTL lprc, IN LPCWSTR String, IN INT Count, IN OPTIONAL LPINT Dx, IN DWORD dwCodePage)
 
BOOL APIENTRY NtGdiExtTextOutW (IN HDC hDC, IN INT XStart, IN INT YStart, IN UINT fuOptions, IN OPTIONAL LPRECT UnsafeRect, IN LPWSTR UnsafeString, IN INT Count, IN OPTIONAL LPINT UnsafeDx, IN DWORD dwCodePage)
 
BOOL APIENTRY NtGdiGetCharABCWidthsW (IN HDC hDC, IN UINT FirstChar, IN ULONG Count, IN OPTIONAL PWCHAR UnSafepwch, IN FLONG fl, OUT PVOID Buffer)
 
BOOL APIENTRY NtGdiGetCharWidthW (IN HDC hDC, IN UINT FirstChar, IN UINT Count, IN OPTIONAL PWCHAR UnSafepwc, IN FLONG fl, OUT PVOID Buffer)
 
__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetGlyphIndicesW (_In_ HDC hdc, _In_reads_opt_(cwc) LPCWSTR pwc, _In_ INT cwc, _Out_writes_opt_(cwc) LPWORD pgi, _In_ DWORD iMode)
 

Variables

const MATRIX gmxWorldToDeviceDefault
 
const MATRIX gmxWorldToPageDefault
 
static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)}
 
FT_Library g_FreeTypeLibrary
 
static UNICODE_STRING g_FontRegPath
 
static PFAST_MUTEX g_FreeTypeLock
 
static LIST_ENTRY g_FontListHead
 
static PFAST_MUTEX g_FontListLock
 
static BOOL g_RenderingEnabled = TRUE
 
static LIST_ENTRY g_FontCacheListHead
 
static UINT g_FontCacheNumEntries
 
static PWCHAR g_ElfScripts [32]
 
static const CHARSETINFO g_FontTci [MAXTCIINDEX]
 

Macro Definition Documentation

◆ _TMPF_VARIABLE_PITCH

#define _TMPF_VARIABLE_PITCH   TMPF_FIXED_PITCH

Definition at line 41 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_HELD

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

Definition at line 85 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_NOT_HELD

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

Definition at line 88 of file freetype.c.

◆ ASSERT_GLOBALFONTS_LOCK_HELD

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

Definition at line 76 of file freetype.c.

◆ CP_MACCP

#define CP_MACCP   2

Definition at line 167 of file freetype.c.

◆ CP_OEMCP

#define CP_OEMCP   1

Definition at line 166 of file freetype.c.

◆ CP_SYMBOL

#define CP_SYMBOL   42

Definition at line 122 of file freetype.c.

◆ EMUBOLD_NEEDED

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

Definition at line 45 of file freetype.c.

◆ FM_SEL_USE_TYPO_METRICS

#define FM_SEL_USE_TYPO_METRICS   0x80

◆ FT_INTERNAL_INTERNAL_H

#define FT_INTERNAL_INTERNAL_H   <freetype/internal/internal.h>

Includes

Definition at line 28 of file freetype.c.

◆ gmxWorldToDeviceDefault

#define gmxWorldToDeviceDefault   gmxWorldToPageDefault

Definition at line 53 of file freetype.c.

◆ GOT_PENALTY

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

Definition at line 4838 of file freetype.c.

◆ IntLockFreeType

Definition at line 79 of file freetype.c.

◆ IntLockGlobalFonts

Definition at line 70 of file freetype.c.

◆ IntUnLockFreeType

Definition at line 82 of file freetype.c.

◆ IntUnLockGlobalFonts

Definition at line 73 of file freetype.c.

◆ MAX_FONT_CACHE

#define MAX_FONT_CACHE   256

Definition at line 91 of file freetype.c.

◆ MAXTCIINDEX

#define MAXTCIINDEX   32

Definition at line 123 of file freetype.c.

◆ NDEBUG

#define NDEBUG

Definition at line 36 of file freetype.c.

◆ PX2PT

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

Definition at line 1133 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 6803 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 2751 of file freetype.c.

2752 {
2753  /* FIXME: Add more and fix if wrong */
2754  switch (PRIMARYLANGID(LangID))
2755  {
2756  case LANG_CHINESE:
2757  switch (SUBLANGID(LangID))
2758  {
2760  return CHINESEBIG5_CHARSET;
2762  default:
2763  break;
2764  }
2765  return GB2312_CHARSET;
2766 
2767  case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
2768  case LANG_SLOVAK: case LANG_SLOVENIAN: case LANG_ROMANIAN:
2769  return EASTEUROPE_CHARSET;
2770 
2771  case LANG_RUSSIAN: case LANG_BULGARIAN: case LANG_MACEDONIAN:
2772  case LANG_SERBIAN: case LANG_UKRAINIAN:
2773  return RUSSIAN_CHARSET;
2774 
2775  case LANG_ARABIC: return ARABIC_CHARSET;
2776  case LANG_GREEK: return GREEK_CHARSET;
2777  case LANG_HEBREW: return HEBREW_CHARSET;
2778  case LANG_JAPANESE: return SHIFTJIS_CHARSET;
2779  case LANG_KOREAN: return JOHAB_CHARSET;
2780  case LANG_TURKISH: return TURKISH_CHARSET;
2781  case LANG_THAI: return THAI_CHARSET;
2782  case LANG_LATVIAN: return BALTIC_CHARSET;
2783  case LANG_VIETNAMESE: return VIETNAMESE_CHARSET;
2784 
2785  case LANG_ENGLISH: case LANG_BASQUE: case LANG_CATALAN:
2786  case LANG_DANISH: case LANG_DUTCH: case LANG_FINNISH:
2787  case LANG_FRENCH: case LANG_GERMAN: case LANG_ITALIAN:
2788  case LANG_NORWEGIAN: case LANG_PORTUGUESE: case LANG_SPANISH:
2789  case LANG_SWEDISH: default:
2790  return ANSI_CHARSET;
2791  }
2792 }
#define LANG_BASQUE
Definition: nls.h:34
#define SUBLANG_CHINESE_TRADITIONAL
Definition: nls.h:208
#define EASTEUROPE_CHARSET
Definition: wingdi.h:398
#define LANG_THAI
Definition: nls.h:132
#define LANG_HUNGARIAN
Definition: nls.h:69
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:389
#define LANG_DUTCH
Definition: nls.h:51
#define LANG_CZECH
Definition: nls.h:47
#define LANG_ARABIC
Definition: nls.h:29
#define LANG_ROMANIAN
Definition: nls.h:111
#define LANG_HEBREW
Definition: nls.h:67
#define LANG_SERBIAN
Definition: nls.h:116
#define LANG_MACEDONIAN
Definition: nls.h:91
#define LANG_SLOVAK
Definition: nls.h:120
#define LANG_BULGARIAN
Definition: nls.h:40
#define LANG_JAPANESE
Definition: nls.h:76
#define LANG_TURKISH
Definition: nls.h:136
#define LANG_NORWEGIAN
Definition: nls.h:102
#define LANG_ITALIAN
Definition: nls.h:75
#define TURKISH_CHARSET
Definition: wingdi.h:391
#define LANG_SLOVENIAN
Definition: nls.h:121
#define LANG_PORTUGUESE
Definition: nls.h:108
#define LANG_LATVIAN
Definition: nls.h:87
#define THAI_CHARSET
Definition: wingdi.h:396
#define SHIFTJIS_CHARSET
Definition: wingdi.h:385
#define LANG_DANISH
Definition: nls.h:48
#define LANG_RUSSIAN
Definition: nls.h:113
#define RUSSIAN_CHARSET
Definition: wingdi.h:395
#define LANG_ENGLISH
Definition: nls.h:52
#define GB2312_CHARSET
Definition: wingdi.h:388
#define SUBLANG_CHINESE_SIMPLIFIED
Definition: nls.h:209
#define LANG_FRENCH
Definition: nls.h:58
#define LANG_VIETNAMESE
Definition: nls.h:143
#define LANG_GERMAN
Definition: nls.h:62
#define VIETNAMESE_CHARSET
Definition: wingdi.h:401
#define HEBREW_CHARSET
Definition: wingdi.h:392
#define LANG_UKRAINIAN
Definition: nls.h:139
#define ARABIC_CHARSET
Definition: wingdi.h:393
#define LANG_CHINESE
Definition: nls.h:42
#define LANG_SWEDISH
Definition: nls.h:125
#define LANG_KOREAN
Definition: nls.h:84
#define LANG_POLISH
Definition: nls.h:107
#define ANSI_CHARSET
Definition: wingdi.h:382
#define JOHAB_CHARSET
Definition: wingdi.h:400
#define BALTIC_CHARSET
Definition: wingdi.h:394
#define GREEK_CHARSET
Definition: wingdi.h:390
#define LANG_FINNISH
Definition: nls.h:57
#define LANG_SPANISH
Definition: nls.h:123
#define LANG_GREEK
Definition: nls.h:63
#define LANG_CATALAN
Definition: nls.h:41
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define SUBLANGID(l)
Definition: nls.h:17

Referenced by GetFontPenalty().

◆ CleanupFontEntry()

static __inline VOID FASTCALL CleanupFontEntry ( PFONT_ENTRY  FontEntry)
static

Definition at line 362 of file freetype.c.

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

Referenced by IntGdiCleanupMemEntry(), IntGdiCleanupPrivateFontsForProcess(), and IntGdiLoadFontsFromMemory().

◆ CleanupFontEntryEx()

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

Definition at line 342 of file freetype.c.

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

Referenced by CleanupFontEntry(), and IntGdiLoadFontsFromMemory().

◆ DuplicateUnicodeString()

static NTSTATUS DuplicateUnicodeString ( PUNICODE_STRING  Source,
PUNICODE_STRING  Destination 
)
static

Definition at line 881 of file freetype.c.

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

Referenced by IntGdiAddFontResourceEx(), and IntGetFontLocalizedName().

◆ EqualFamilyInfo()

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

Definition at line 5507 of file freetype.c.

5508 {
5509  const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5510  const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5511  const LOGFONTW *plf1 = &pLog1->elfLogFont;
5512  const LOGFONTW *plf2 = &pLog2->elfLogFont;
5513 
5514  if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5515  {
5516  return FALSE;
5517  }
5518 
5519  if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5520  {
5521  return FALSE;
5522  }
5523 
5524  return TRUE;
5525 }
#define TRUE
Definition: types.h:120
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:2699
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
LOGFONTW elfLogFont
Definition: wingdi.h:2697
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 2256 of file freetype.c.

2257 {
2258  int i;
2259 
2260  for(i = 0; i < ft_face->num_charmaps; i++)
2261  {
2262  if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
2263  ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
2264  {
2265  return TRUE;
2266  }
2267  }
2268  return FALSE;
2269 }
#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 2510 of file freetype.c.

2513 {
2514  FillTMEx(TM, FontGDI, pOS2, pHori, pFNT, FALSE);
2515 }
static void FASTCALL FillTMEx(TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT, BOOL RealFont)
Definition: freetype.c:2272

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

2275 {
2276  FT_Fixed XScale, YScale;
2277  int Ascent, Descent;
2278  FT_Face Face = FontGDI->SharedFace->Face;
2279 
2281 
2282  XScale = Face->size->metrics.x_scale;
2283  YScale = Face->size->metrics.y_scale;
2284 
2285  if (pFNT)
2286  {
2287  TM->tmHeight = pFNT->pixel_height;
2288  TM->tmAscent = pFNT->ascent;
2289  TM->tmDescent = TM->tmHeight - TM->tmAscent;
2290  TM->tmInternalLeading = pFNT->internal_leading;
2291  TM->tmExternalLeading = pFNT->external_leading;
2292  TM->tmAveCharWidth = pFNT->avg_width;
2293  TM->tmMaxCharWidth = pFNT->max_width;
2294  TM->tmOverhang = 0;
2297  TM->tmFirstChar = pFNT->first_char;
2298  TM->tmLastChar = pFNT->last_char;
2299  TM->tmDefaultChar = pFNT->default_char + pFNT->first_char;
2300  TM->tmBreakChar = pFNT->break_char + pFNT->first_char;
2301  TM->tmPitchAndFamily = pFNT->pitch_and_family;
2302  if (RealFont)
2303  {
2304  TM->tmWeight = FontGDI->OriginalWeight;
2305  TM->tmItalic = FontGDI->OriginalItalic;
2306  TM->tmUnderlined = pFNT->underline;
2307  TM->tmStruckOut = pFNT->strike_out;
2308  TM->tmCharSet = pFNT->charset;
2309  }
2310  else
2311  {
2312  TM->tmWeight = FontGDI->RequestWeight;
2313  TM->tmItalic = FontGDI->RequestItalic;
2314  TM->tmUnderlined = FontGDI->RequestUnderline;
2315  TM->tmStruckOut = FontGDI->RequestStrikeOut;
2316  TM->tmCharSet = FontGDI->CharSet;
2317  }
2318  return;
2319  }
2320 
2321  if ((FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent == 0)
2322  {
2323  Ascent = pHori->Ascender;
2324  Descent = -pHori->Descender;
2325  }
2326  else
2327  {
2328  Ascent = (FT_Short)pOS2->usWinAscent;
2329  Descent = (FT_Short)pOS2->usWinDescent;
2330  }
2331 
2332  TM->tmAscent = FontGDI->tmAscent;
2333  TM->tmDescent = FontGDI->tmDescent;
2334  TM->tmHeight = TM->tmAscent + TM->tmDescent;
2335  TM->tmInternalLeading = FontGDI->tmInternalLeading;
2336 
2337  /* MSDN says:
2338  * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
2339  */
2340  TM->tmExternalLeading = max(0, (FT_MulFix(pHori->Line_Gap
2341  - ((Ascent + Descent)
2342  - (pHori->Ascender - pHori->Descender)),
2343  YScale) + 32) >> 6);
2344 
2345  TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
2346  if (TM->tmAveCharWidth == 0)
2347  {
2348  TM->tmAveCharWidth = 1;
2349  }
2350 
2351  /* Correct forumla to get the maxcharwidth from unicode and ansi font */
2352  TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
2353 
2354  if (RealFont)
2355  {
2356  TM->tmWeight = FontGDI->OriginalWeight;
2357  }
2358  else
2359  {
2360  if (FontGDI->OriginalWeight != FW_DONTCARE &&
2361  FontGDI->OriginalWeight != FW_NORMAL)
2362  {
2363  TM->tmWeight = FontGDI->OriginalWeight;
2364  }
2365  else
2366  {
2367  TM->tmWeight = FontGDI->RequestWeight;
2368  }
2369  }
2370 
2371  TM->tmOverhang = 0;
2372  TM->tmDigitizedAspectX = 96;
2373  TM->tmDigitizedAspectY = 96;
2374  if (face_has_symbol_charmap(Face) ||
2375  (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
2376  {
2377  USHORT cpOEM, cpAnsi;
2378 
2379  EngGetCurrentCodePage(&cpOEM, &cpAnsi);
2380  TM->tmFirstChar = 0;
2381  switch(cpAnsi)
2382  {
2383  case 1257: /* Baltic */
2384  TM->tmLastChar = 0xf8fd;
2385  break;
2386  default:
2387  TM->tmLastChar = 0xf0ff;
2388  }
2389  TM->tmBreakChar = 0x20;
2390  TM->tmDefaultChar = 0x1f;
2391  }
2392  else
2393  {
2394  TM->tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
2395  TM->tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
2396 
2397  if(pOS2->usFirstCharIndex <= 1)
2398  TM->tmBreakChar = pOS2->usFirstCharIndex + 2;
2399  else if (pOS2->usFirstCharIndex > 0xff)
2400  TM->tmBreakChar = 0x20;
2401  else
2402  TM->tmBreakChar = pOS2->usFirstCharIndex;
2403  TM->tmDefaultChar = TM->tmBreakChar - 1;
2404  }
2405 
2406  if (RealFont)
2407  {
2408  TM->tmItalic = FontGDI->OriginalItalic;
2409  TM->tmUnderlined = FALSE;
2410  TM->tmStruckOut = FALSE;
2411  }
2412  else
2413  {
2414  if (FontGDI->OriginalItalic || FontGDI->RequestItalic)
2415  {
2416  TM->tmItalic = 0xFF;
2417  }
2418  else
2419  {
2420  TM->tmItalic = 0;
2421  }
2422  TM->tmUnderlined = (FontGDI->RequestUnderline ? 0xFF : 0);
2423  TM->tmStruckOut = (FontGDI->RequestStrikeOut ? 0xFF : 0);
2424  }
2425 
2426  if (!FT_IS_FIXED_WIDTH(Face))
2427  {
2428  switch (pOS2->panose[PAN_PROPORTION_INDEX])
2429  {
2430  case PAN_PROP_MONOSPACED:
2431  TM->tmPitchAndFamily = 0;
2432  break;
2433  default:
2435  break;
2436  }
2437  }
2438  else
2439  {
2440  TM->tmPitchAndFamily = 0;
2441  }
2442 
2443  switch (pOS2->panose[PAN_FAMILYTYPE_INDEX])
2444  {
2445  case PAN_FAMILY_SCRIPT:
2446  TM->tmPitchAndFamily |= FF_SCRIPT;
2447  break;
2448  case PAN_FAMILY_DECORATIVE:
2450  break;
2451 
2452  case PAN_ANY:
2453  case PAN_NO_FIT:
2455  case PAN_FAMILY_PICTORIAL: /* Symbol fonts get treated as if they were text */
2456  /* Which is clearly not what the panose spec says. */
2457  if (TM->tmPitchAndFamily == 0) /* Fixed */
2458  {
2460  }
2461  else
2462  {
2463  switch (pOS2->panose[PAN_SERIFSTYLE_INDEX])
2464  {
2465  case PAN_ANY:
2466  case PAN_NO_FIT:
2467  default:
2469  break;
2470 
2471  case PAN_SERIF_COVE:
2472  case PAN_SERIF_OBTUSE_COVE:
2473  case PAN_SERIF_SQUARE_COVE:
2475  case PAN_SERIF_SQUARE:
2476  case PAN_SERIF_THIN:
2477  case PAN_SERIF_BONE:
2478  case PAN_SERIF_EXAGGERATED:
2479  case PAN_SERIF_TRIANGLE:
2480  TM->tmPitchAndFamily |= FF_ROMAN;
2481  break;
2482 
2483  case PAN_SERIF_NORMAL_SANS:
2484  case PAN_SERIF_OBTUSE_SANS:
2485  case PAN_SERIF_PERP_SANS:
2486  case PAN_SERIF_FLARED:
2487  case PAN_SERIF_ROUNDED:
2488  TM->tmPitchAndFamily |= FF_SWISS;
2489  break;
2490  }
2491  }
2492  break;
2493  default:
2495  }
2496 
2497  if (FT_IS_SCALABLE(Face))
2498  {
2500  }
2501  if (FT_IS_SFNT(Face))
2502  {
2504  }
2505 
2506  TM->tmCharSet = FontGDI->CharSet;
2507 }
#define PAN_SERIF_NORMAL_SANS
Definition: wingdi.h:479
LONG tmMaxCharWidth
Definition: wingdi.h:2384
LONG tmAscent
Definition: engobjects.h:159
#define max(a, b)
Definition: svc.c:63
BYTE tmUnderlined
Definition: wingdi.h:2394
#define PAN_FAMILY_DECORATIVE
Definition: wingdi.h:468
#define FF_DONTCARE
Definition: wingdi.h:447
LONG tmExternalLeading
Definition: wingdi.h:2382
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:2383
LONG tmDescent
Definition: wingdi.h:2380
LONG tmAscent
Definition: wingdi.h:2379
LONG tmInternalLeading
Definition: wingdi.h:2381
#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:2256
#define PAN_ANY
Definition: wingdi.h:464
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
LONG tmDescent
Definition: engobjects.h:160
#define PAN_SERIF_FLARED
Definition: wingdi.h:482
#define TMPF_TRUETYPE
Definition: wingdi.h:1312
FT_UShort vertical_resolution
Definition: ftwinfnt.h:191
FT_Short xAvgCharWidth
Definition: tttables.h:383
#define PAN_SERIF_SQUARE
Definition: wingdi.h:474
FT_UShort internal_leading
Definition: ftwinfnt.h:194
FT_UShort ascent
Definition: ftwinfnt.h:193
FT_UShort usWinDescent
Definition: tttables.h:415
BYTE OriginalItalic
Definition: engobjects.h:153
BYTE tmPitchAndFamily
Definition: wingdi.h:2396
#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:2392
#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:2395
FT_UShort max_width
Definition: ftwinfnt.h:205
#define PAN_SERIF_PERP_SANS
Definition: wingdi.h:481
#define PAN_FAMILYTYPE_INDEX
Definition: wingdi.h:453
#define PAN_SERIF_OBTUSE_SQUARE_COVE
Definition: wingdi.h:473
#define PAN_NO_FIT
Definition: wingdi.h:465
FT_UShort avg_width
Definition: ftwinfnt.h:204
LONG OriginalWeight
Definition: engobjects.h:154
#define PAN_FAMILY_SCRIPT
Definition: wingdi.h:467
LONG tmInternalLeading
Definition: engobjects.h:161
FT_Short Line_Gap
Definition: tttables.h:204
#define PAN_FAMILY_PICTORIAL
Definition: wingdi.h:469
LONG tmOverhang
Definition: wingdi.h:2386
#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:2397
#define PAN_PROPORTION_INDEX
Definition: wingdi.h:456
FT_Size_Metrics metrics
Definition: freetype.h:1677
signed short FT_Short
Definition: fttypes.h:198
LONG tmDigitizedAspectY
Definition: wingdi.h:2388
#define FF_ROMAN
Definition: wingdi.h:449
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
#define TMPF_VECTOR
Definition: wingdi.h:1311
BYTE RequestUnderline
Definition: engobjects.h:149
FT_Short max_advance_width
Definition: freetype.h:1099
ENGAPI VOID APIENTRY EngGetCurrentCodePage(_Out_ PUSHORT OemCodePage, _Out_ PUSHORT AnsiCodePage)
Definition: engmisc.c:232
#define FW_DONTCARE
Definition: wingdi.h:367
#define FF_SWISS
Definition: wingdi.h:451
signed long FT_Fixed
Definition: fttypes.h:288
FT_Byte pitch_and_family
Definition: ftwinfnt.h:203
PSHARED_FACE SharedFace
Definition: engobjects.h:142
FT_Fixed x_scale
Definition: freetype.h:1643
unsigned short USHORT
Definition: pedump.c:61
FT_Byte default_char
Definition: ftwinfnt.h:208
LONG RequestWeight
Definition: engobjects.h:152
#define FF_MODERN
Definition: wingdi.h:448
FT_UShort usWinAscent
Definition: tttables.h:414
WCHAR tmDefaultChar
Definition: wingdi.h:2391
#define FF_SCRIPT
Definition: wingdi.h:450
#define FW_NORMAL
Definition: wingdi.h:372
BYTE RequestItalic
Definition: engobjects.h:151
LONG tmWeight
Definition: wingdi.h:2385
#define PAN_SERIF_SQUARE_COVE
Definition: wingdi.h:472
LONG tmHeight
Definition: wingdi.h:2378
#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:2393
WCHAR tmFirstChar
Definition: wingdi.h:2389
#define PAN_FAMILY_TEXT_DISPLAY
Definition: wingdi.h:466
FT_Byte panose[10]
Definition: tttables.h:399
WCHAR tmLastChar
Definition: wingdi.h:2390
LONG tmDigitizedAspectX
Definition: wingdi.h:2387

Referenced by FillTM().

◆ FindBestFontFromList()

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

Definition at line 5191 of file freetype.c.

5194 {
5195  ULONG Penalty;
5197  PFONT_ENTRY CurrentEntry;
5198  FONTGDI *FontGDI;
5199  OUTLINETEXTMETRICW *Otm = NULL;
5200  UINT OtmSize, OldOtmSize = 0;
5201  FT_Face Face;
5202 
5203  ASSERT(FontObj);
5204  ASSERT(MatchPenalty);
5205  ASSERT(LogFont);
5206  ASSERT(Head);
5207 
5208  /* Start with a pretty big buffer */
5209  OldOtmSize = 0x200;
5210  Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5211 
5212  /* get the FontObj of lowest penalty */
5213  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5214  {
5215  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5216 
5217  FontGDI = CurrentEntry->Font;
5218  ASSERT(FontGDI);
5219  Face = FontGDI->SharedFace->Face;
5220 
5221  /* get text metrics */
5222  OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
5223  if (OtmSize > OldOtmSize)
5224  {
5225  if (Otm)
5227  Otm = ExAllocatePoolWithTag(PagedPool, OtmSize, GDITAG_TEXT);
5228  }
5229 
5230  /* update FontObj if lowest penalty */
5231  if (Otm)
5232  {
5233  IntLockFreeType();
5234  IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5236 
5237  OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm);
5238  if (!OtmSize)
5239  continue;
5240 
5241  OldOtmSize = OtmSize;
5242 
5243  Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5244  if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty)
5245  {
5246  *FontObj = GDIToObj(FontGDI, FONT);
5247  *MatchPenalty = Penalty;
5248  }
5249  }
5250  }
5251 
5252  if (Otm)
5254 }
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:4842
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2604
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:3652
#define IntUnLockFreeType()
Definition: freetype.c:82
FT_Face Face
Definition: engobjects.h:129
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IntLockFreeType()
Definition: freetype.c:79
Definition: typedefs.h:117
#define GDITAG_TEXT
Definition: tags.h:171
PSHARED_FACE SharedFace
Definition: engobjects.h:142
FONTGDI * Font
Definition: font.h:7
unsigned int UINT
Definition: ndis.h:50
FT_String * style_name
Definition: freetype.h:1079
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
base of all file and directory entries
Definition: entries.h:82
#define GDIToObj(ClipGDI, Type)
Definition: engobjects.h:181

Referenced by TextIntRealizeFont().

◆ FontFamilyFillInfo()

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

Definition at line 2969 of file freetype.c.

2971 {
2972  ANSI_STRING StyleA;
2973  UNICODE_STRING StyleW;
2974  TT_OS2 *pOS2;
2975  FONTSIGNATURE fs;
2976  CHARSETINFO CharSetInfo;
2977  unsigned i, Size;
2978  OUTLINETEXTMETRICW *Otm;
2979  LOGFONTW *Lf;
2980  TEXTMETRICW *TM;
2981  NEWTEXTMETRICW *Ntm;
2982  DWORD fs0;
2983  NTSTATUS status;
2984  PSHARED_FACE SharedFace = FontGDI->SharedFace;
2985  FT_Face Face = SharedFace->Face;
2986  UNICODE_STRING NameW;
2987 
2988  RtlInitUnicodeString(&NameW, NULL);
2989  RtlZeroMemory(Info, sizeof(FONTFAMILYINFO));
2990  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
2992  if (!Otm)
2993  {
2994  return;
2995  }
2996  Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm);
2997  if (!Size)
2998  {
3000  return;
3001  }
3002 
3003  Lf = &Info->EnumLogFontEx.elfLogFont;
3004  TM = &Otm->otmTextMetrics;
3005 
3006  Lf->lfHeight = TM->tmHeight;
3007  Lf->lfWidth = TM->tmAveCharWidth;
3008  Lf->lfWeight = TM->tmWeight;
3009  Lf->lfItalic = TM->tmItalic;
3010  Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
3011  Lf->lfCharSet = TM->tmCharSet;
3014  Lf->lfQuality = PROOF_QUALITY;
3015 
3016  Ntm = &Info->NewTextMetricEx.ntmTm;
3017  Ntm->tmHeight = TM->tmHeight;
3018  Ntm->tmAscent = TM->tmAscent;
3019  Ntm->tmDescent = TM->tmDescent;
3022  Ntm->tmAveCharWidth = TM->tmAveCharWidth;
3023  Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
3024  Ntm->tmWeight = TM->tmWeight;
3025  Ntm->tmOverhang = TM->tmOverhang;
3028  Ntm->tmFirstChar = TM->tmFirstChar;
3029  Ntm->tmLastChar = TM->tmLastChar;
3030  Ntm->tmDefaultChar = TM->tmDefaultChar;
3031  Ntm->tmBreakChar = TM->tmBreakChar;
3032  Ntm->tmItalic = TM->tmItalic;
3033  Ntm->tmUnderlined = TM->tmUnderlined;
3034  Ntm->tmStruckOut = TM->tmStruckOut;
3036  Ntm->tmCharSet = TM->tmCharSet;
3037  Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
3038 
3039  if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
3040 
3041  if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
3042 
3043  Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
3044  ? TRUETYPE_FONTTYPE : 0);
3045 
3046  if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
3047  Info->FontType |= RASTER_FONTTYPE;
3048 
3049 
3050  /* face name */
3051  if (!FaceName)
3052  FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
3053 
3054  RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
3055 
3056  /* full name */
3057  if (!FullName)
3058  FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
3059 
3060  RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
3061  sizeof(Info->EnumLogFontEx.elfFullName),
3062  FullName);
3063 
3064  RtlInitAnsiString(&StyleA, Face->style_name);
3065  StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
3066  StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
3067  status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
3068  if (!NT_SUCCESS(status))
3069  {
3071  return;
3072  }
3073  Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
3074 
3075  IntLockFreeType();
3076  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
3077 
3078  if (!pOS2)
3079  {
3082  return;
3083  }
3084 
3085  Ntm->ntmSizeEM = Otm->otmEMSquare;
3086  Ntm->ntmCellHeight = (FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent;
3087  Ntm->ntmAvgWidth = 0;
3088 
3090 
3091  fs.fsCsb[0] = pOS2->ulCodePageRange1;
3092  fs.fsCsb[1] = pOS2->ulCodePageRange2;
3093  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
3094  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
3095  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
3096  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
3097 
3098  if (0 == pOS2->version)
3099  {
3100  FT_UInt Dummy;
3101 
3102  if (FT_Get_First_Char(Face, &Dummy) < 0x100)
3103  fs.fsCsb[0] |= FS_LATIN1;
3104  else
3105  fs.fsCsb[0] |= FS_SYMBOL;
3106  }
3108 
3109  if (fs.fsCsb[0] == 0)
3110  {
3111  /* Let's see if we can find any interesting cmaps */
3112  for (i = 0; i < (UINT)Face->num_charmaps; i++)
3113  {
3114  switch (Face->charmaps[i]->encoding)
3115  {
3116  case FT_ENCODING_UNICODE:
3117  case FT_ENCODING_APPLE_ROMAN:
3118  fs.fsCsb[0] |= FS_LATIN1;
3119  break;
3120  case FT_ENCODING_MS_SYMBOL:
3121  fs.fsCsb[0] |= FS_SYMBOL;
3122  break;
3123  default:
3124  break;
3125  }
3126  }
3127  }
3128 
3129  for (i = 0; i < MAXTCIINDEX; i++)
3130  {
3131  fs0 = 1L << i;
3132  if (fs.fsCsb[0] & fs0)
3133  {
3134  if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
3135  {
3136  CharSetInfo.ciCharset = DEFAULT_CHARSET;
3137  }
3138  if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
3139  {
3140  if (g_ElfScripts[i])
3141  wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
3142  else
3143  {
3144  DPRINT1("Unknown elfscript for bit %u\n", i);
3145  }
3146  }
3147  }
3148  }
3149  Info->NewTextMetricEx.ntmFontSig = fs;
3150 }
WCHAR tmFirstChar
Definition: wingdi.h:2650
LONG tmMaxCharWidth
Definition: wingdi.h:2384
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
BYTE tmUnderlined
Definition: wingdi.h:2394
FT_CharMap * charmaps
Definition: freetype.h:1085
BYTE lfPitchAndFamily
Definition: dimm.idl:71
LONG tmExternalLeading
Definition: wingdi.h:2382
#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:2383
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
BYTE lfCharSet
Definition: dimm.idl:67
LONG tmDigitizedAspectX
Definition: wingdi.h:2648
BYTE lfClipPrecision
Definition: dimm.idl:69
WCHAR tmDefaultChar
Definition: wingdi.h:2652
#define NTM_BOLD
Definition: wingdi.h:1315
LONG tmDescent
Definition: wingdi.h:2380
LONG tmAscent
Definition: wingdi.h:2379
LONG tmInternalLeading
Definition: wingdi.h:2381
Definition: fs.h:235
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define PROOF_QUALITY
Definition: wingdi.h:437
LONG tmDigitizedAspectY
Definition: wingdi.h:2649
#define MAXTCIINDEX
Definition: freetype.c:123
struct TraceInfo Info
static PWCHAR g_ElfScripts[32]
Definition: freetype.c:96
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
#define UNICODE_NULL
#define TMPF_TRUETYPE
Definition: wingdi.h:1312
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
FT_UShort usWinDescent
Definition: tttables.h:415
UINT ciCharset
Definition: wingdi.h:1541
BYTE tmPitchAndFamily
Definition: wingdi.h:2396
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2604
LONG lfWidth
Definition: dimm.idl:60
smooth NULL
Definition: ftsmooth.c:416
WCHAR tmBreakChar
Definition: wingdi.h:2392
FT_UShort version
Definition: tttables.h:382
BYTE tmStruckOut
Definition: wingdi.h:2395
BYTE lfOutPrecision
Definition: dimm.idl:68
LONG tmMaxCharWidth
Definition: wingdi.h:2645
#define OUT_OUTLINE_PRECIS
Definition: wingdi.h:422
static BOOLEAN APIENTRY IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2209
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FS_SYMBOL
Definition: wingdi.h:574
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
WCHAR tmLastChar
Definition: wingdi.h:2651
BYTE tmPitchAndFamily
Definition: wingdi.h:2657
LONG tmOverhang
Definition: wingdi.h:2386
FT_Face Face
Definition: engobjects.h:129
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RASTER_FONTTYPE
Definition: wingdi.h:1106
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
FT_Encoding encoding
Definition: freetype.h:843
BYTE tmCharSet
Definition: wingdi.h:2397
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BYTE lfQuality
Definition: dimm.idl:70
#define NTM_REGULAR
Definition: wingdi.h:1316
static const WCHAR L[]
Definition: oid.c:1250
#define IntLockFreeType()
Definition: freetype.c:79
signed short FT_Short
Definition: fttypes.h:198
LONG tmInternalLeading
Definition: wingdi.h:2642
LONG tmDigitizedAspectY
Definition: wingdi.h:2388
LONG tmExternalLeading
Definition: wingdi.h:2643
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
FT_Int num_charmaps
Definition: freetype.h:1084
#define TMPF_VECTOR
Definition: wingdi.h:1311
FT_ULong ulCodePageRange1
Definition: tttables.h:419
#define GDITAG_TEXT
Definition: tags.h:171
UINT ntmCellHeight
Definition: wingdi.h:2661
PSHARED_FACE SharedFace
Definition: engobjects.h:142
WCHAR tmBreakChar
Definition: wingdi.h:2653
#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:2509
FT_UShort usWinAscent
Definition: tttables.h:414
WCHAR tmDefaultChar
Definition: wingdi.h:2391
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:2644
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG tmWeight
Definition: wingdi.h:2385
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:2378
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
LONG lfWeight
Definition: dimm.idl:63
#define NTM_ITALIC
Definition: wingdi.h:1314
static SERVICE_STATUS status
Definition: service.c:31
BYTE tmItalic
Definition: wingdi.h:2393
WCHAR tmFirstChar
Definition: wingdi.h:2389
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1108
FT_ULong ulUnicodeRange2
Definition: tttables.h:402
WCHAR tmLastChar
Definition: wingdi.h:2390
LONG tmDigitizedAspectX
Definition: wingdi.h:2387
Definition: ps.c:97

Referenced by GetFontFamilyInfoForList(), and IntGdiGetFontResourceInfo().

◆ FT_FixedFromFIXED()

static __inline FT_Fixed FT_FixedFromFIXED ( FIXED  f)
static

Definition at line 382 of file freetype.c.

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

Referenced by ftGdiGetGlyphOutline().

◆ ftGdiGetFontData()

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

Definition at line 4800 of file freetype.c.

4806 {
4808  FT_Face Face = FontGdi->SharedFace->Face;
4809 
4810  IntLockFreeType();
4811 
4812  if (FT_IS_SFNT(Face))
4813  {
4814  if (Table)
4815  Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
4816  (Table << 8 & 0xFF0000);
4817 
4818  if (!Buffer) Size = 0;
4819 
4820  if (Buffer && Size)
4821  {
4822  FT_Error Error;
4823  FT_ULong Needed = 0;
4824 
4825  Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
4826 
4827  if ( !Error && Needed < Size) Size = Needed;
4828  }
4829  if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
4830  Result = Size;
4831  }
4832 
4834 
4835  return Result;
4836 }
int FT_Error
Definition: fttypes.h:300
ASMGENDATA Table[]
Definition: genincdata.c:61
unsigned long FT_ULong
Definition: fttypes.h:253
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bufpool.h:45
FT_Load_Sfnt_Table(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte *buffer, FT_ULong *length)
Definition: ftobjs.c:4134
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
#define FT_IS_SFNT(face)
Definition: freetype.h:1331
FT_Face Face
Definition: engobjects.h:129
#define IntLockFreeType()
Definition: freetype.c:79
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
PSHARED_FACE SharedFace
Definition: engobjects.h:142
#define GDI_ERROR
Definition: wingdi.h:1308

Referenced by NtGdiGetFontData().

◆ ftGdiGetGlyphOutline()

ULONG FASTCALL ftGdiGetGlyphOutline ( PDC  dc,
WCHAR  wch,
UINT  iFormat,
LPGLYPHMETRICS  pgm,
ULONG  cjBuf,
PVOID  pvBuf,
LPMAT2  pmat2,
BOOL  bIgnoreRotation 
)

Definition at line 3908 of file freetype.c.

3917 {
3918  PDC_ATTR pdcattr;
3919  PTEXTOBJ TextObj;
3920  PFONTGDI FontGDI;
3921  HFONT hFont = 0;
3922  GLYPHMETRICS gm;
3923  ULONG Size;
3924  FT_Face ft_face;
3925  FT_UInt glyph_index;
3926  DWORD width, height, pitch, needed = 0;
3927  FT_Bitmap ft_bitmap;
3928  FT_Error error;
3929  INT left, right, top = 0, bottom = 0;
3931  FLOATOBJ eM11, widthRatio, eTemp;
3932  FT_Matrix transMat = identityMat;
3933  BOOL needsTransform = FALSE;
3934  INT orientation;
3935  LONG aveWidth;
3936  INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
3937  OUTLINETEXTMETRICW *potm;
3938  XFORMOBJ xo;
3939  XFORML xform;
3940  LOGFONTW *plf;
3941 
3942  DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
3943  cjBuf, pvBuf, pmat2);
3944 
3945  pdcattr = dc->pdcattr;
3946 
3947  XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
3948  XFORMOBJ_iGetXform(&xo, &xform);
3949  FLOATOBJ_SetFloat(&eM11, xform.eM11);
3950 
3951  hFont = pdcattr->hlfntNew;
3952  TextObj = RealizeFontInit(hFont);
3953 
3954  if (!TextObj)
3955  {
3957  return GDI_ERROR;
3958  }
3959  FontGDI = ObjToGDI(TextObj->Font, FONT);
3960  ft_face = FontGDI->SharedFace->Face;
3961 
3962  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
3963  aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
3964  orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
3965 
3966  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
3968  if (!potm)
3969  {
3971  TEXTOBJ_UnlockText(TextObj);
3972  return GDI_ERROR;
3973  }
3974  Size = IntGetOutlineTextMetrics(FontGDI, Size, potm);
3975  if (!Size)
3976  {
3977  /* FIXME: last error? */
3979  TEXTOBJ_UnlockText(TextObj);
3980  return GDI_ERROR;
3981  }
3982 
3983  IntLockFreeType();
3984  TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
3986 
3987  TEXTOBJ_UnlockText(TextObj);
3988 
3989  glyph_index = get_glyph_index_flagged(ft_face, wch, GGO_GLYPH_INDEX, iFormat);
3991 
3992  if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
3993  load_flags |= FT_LOAD_NO_BITMAP;
3994 
3995  if (iFormat & GGO_UNHINTED)
3996  {
3997  load_flags |= FT_LOAD_NO_HINTING;
3998  iFormat &= ~GGO_UNHINTED;
3999  }
4000 
4001  error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
4002  if (error)
4003  {
4004  DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
4006  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
4007  return GDI_ERROR;
4008  }
4010 
4011  FLOATOBJ_Set1(&widthRatio);
4012  if (aveWidth && potm)
4013  {
4014  // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
4015  FLOATOBJ_SetLong(&widthRatio, aveWidth);
4016  FLOATOBJ_Mul(&widthRatio, &eM11);
4017  FLOATOBJ_DivLong(&widthRatio, potm->otmTextMetrics.tmAveCharWidth);
4018  }
4019 
4020  //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
4021  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
4022  FLOATOBJ_Mul(&eTemp, &widthRatio);
4023  left = FLOATOBJ_GetLong(&eTemp) & -64;
4024 
4025  //right = (INT)((ft_face->glyph->metrics.horiBearingX +
4026  // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
4027  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
4028  FLOATOBJ_Mul(&eTemp, &widthRatio);
4029  FLOATOBJ_AddLong(&eTemp, 63);
4030  right = FLOATOBJ_GetLong(&eTemp) & -64;
4031 
4032  //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
4033  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
4034  FLOATOBJ_Mul(&eTemp, &widthRatio);
4035  FLOATOBJ_AddLong(&eTemp, 63);
4036  adv = FLOATOBJ_GetLong(&eTemp) >> 6;
4037 
4038  lsb = left >> 6;
4039  bbx = (right - left) >> 6;
4040 
4041  DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
4042 
4043  IntLockFreeType();
4044 
4045  /* Width scaling transform */
4046  if (!FLOATOBJ_Equal1(&widthRatio))
4047  {
4048  FT_Matrix scaleMat;
4049 
4050  eTemp = widthRatio;
4051  FLOATOBJ_MulLong(&eTemp, 1 << 16);
4052 
4053  scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
4054  scaleMat.xy = 0;
4055  scaleMat.yx = 0;
4056  scaleMat.yy = INT_TO_FIXED(1);
4057  FT_Matrix_Multiply(&scaleMat, &transMat);
4058  needsTransform = TRUE;
4059  }
4060 
4061  /* World transform */
4062  {
4063  FT_Matrix ftmatrix;
4065 
4066  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
4067  FtMatrixFromMx(&ftmatrix, pmx);
4068 
4069  if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
4070  {
4071  FT_Matrix_Multiply(&ftmatrix, &transMat);
4072  needsTransform = TRUE;
4073  }
4074  }
4075 
4076  /* Rotation transform */
4077  if (orientation)
4078  {
4079  FT_Matrix rotationMat;
4080  DPRINT("Rotation Trans!\n");
4081  IntEscapeMatrix(&rotationMat, orientation);
4082  FT_Matrix_Multiply(&rotationMat, &transMat);
4083  needsTransform = TRUE;
4084  }
4085 
4086  /* Extra transformation specified by caller */
4087  if (pmat2)
4088  {
4089  FT_Matrix extraMat;
4090  DPRINT("MAT2 Matrix Trans!\n");
4091  extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
4092  extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
4093  extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
4094  extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
4095  FT_Matrix_Multiply(&extraMat, &transMat);
4096  needsTransform = TRUE;
4097  }
4098 
4099  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
4100 
4101  if (!needsTransform)
4102  {
4103  DPRINT("No Need to be Transformed!\n");
4104  top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
4105  bottom = (ft_face->glyph->metrics.horiBearingY -
4106  ft_face->glyph->metrics.height) & -64;
4107  gm.gmCellIncX = adv;
4108  gm.gmCellIncY = 0;
4109  }
4110  else
4111  {
4112  INT xc, yc;
4113  FT_Vector vec;
4114  for (xc = 0; xc < 2; xc++)
4115  {
4116  for (yc = 0; yc < 2; yc++)
4117  {
4118  vec.x = (ft_face->glyph->metrics.horiBearingX +
4119  xc * ft_face->glyph->metrics.width);
4120  vec.y = ft_face->glyph->metrics.horiBearingY -
4121  yc * ft_face->glyph->metrics.height;
4122  DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
4123  FT_Vector_Transform(&vec, &transMat);
4124  if (xc == 0 && yc == 0)
4125  {
4126  left = right = vec.x;
4127  top = bottom = vec.y;
4128  }
4129  else
4130  {
4131  if (vec.x < left) left = vec.x;
4132  else if (vec.x > right) right = vec.x;
4133  if (vec.y < bottom) bottom = vec.y;
4134  else if (vec.y > top) top = vec.y;
4135  }
4136  }
4137  }
4138  left = left & -64;
4139  right = (right + 63) & -64;
4140  bottom = bottom & -64;
4141  top = (top + 63) & -64;
4142 
4143  DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
4144  vec.x = ft_face->glyph->metrics.horiAdvance;
4145  vec.y = 0;
4146  FT_Vector_Transform(&vec, &transMat);
4147  gm.gmCellIncX = (vec.x+63) >> 6;
4148  gm.gmCellIncY = -((vec.y+63) >> 6);
4149  }
4150  gm.gmBlackBoxX = (right - left) >> 6;
4151  gm.gmBlackBoxY = (top - bottom) >> 6;
4152  gm.gmptGlyphOrigin.x = left >> 6;
4153  gm.gmptGlyphOrigin.y = top >> 6;
4154 
4155  DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
4156  gm.gmCellIncX, gm.gmCellIncY,
4157  gm.gmBlackBoxX, gm.gmBlackBoxY,
4159 
4161 
4162 
4163  if (iFormat == GGO_METRICS)
4164  {
4165  DPRINT("GGO_METRICS Exit!\n");
4166  *pgm = gm;
4167  return 1; /* FIXME */
4168  }
4169 
4170  if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
4171  {
4172  DPRINT1("Loaded a bitmap\n");
4173  return GDI_ERROR;
4174  }
4175 
4176  switch (iFormat)
4177  {
4178  case GGO_BITMAP:
4179  {
4180  width = gm.gmBlackBoxX;
4181  height = gm.gmBlackBoxY;
4182  pitch = ((width + 31) >> 5) << 2;
4183  needed = pitch * height;
4184 
4185  if (!pvBuf || !cjBuf) break;
4186  if (!needed) return GDI_ERROR; /* empty glyph */
4187  if (needed > cjBuf)
4188  return GDI_ERROR;
4189 
4190  switch (ft_face->glyph->format)
4191  {
4193  {
4194  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4195  INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4196  INT h = min( height, ft_face->glyph->bitmap.rows );
4197  while (h--)
4198  {
4199  RtlCopyMemory(dst, src, w);
4200  src += ft_face->glyph->bitmap.pitch;
4201  dst += pitch;
4202  }
4203  break;
4204  }
4205 
4207  {
4208  ft_bitmap.width = width;
4209  ft_bitmap.rows = height;
4210  ft_bitmap.pitch = pitch;
4211  ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4212  ft_bitmap.buffer = pvBuf;
4213 
4214  IntLockFreeType();
4215  if (needsTransform)
4216  {
4217  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4218  }
4219  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4220  /* Note: FreeType will only set 'black' bits for us. */
4221  RtlZeroMemory(pvBuf, needed);
4222  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4224  break;
4225  }
4226 
4227  default:
4228  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4229  return GDI_ERROR;
4230  }
4231 
4232  break;
4233  }
4234 
4235  case GGO_GRAY2_BITMAP:
4236  case GGO_GRAY4_BITMAP:
4237  case GGO_GRAY8_BITMAP:
4238  {
4239  unsigned int mult, row, col;
4240  BYTE *start, *ptr;
4241 
4242  width = gm.gmBlackBoxX;
4243  height = gm.gmBlackBoxY;
4244  pitch = (width + 3) / 4 * 4;
4245  needed = pitch * height;
4246 
4247  if (!pvBuf || !cjBuf) break;
4248  if (!needed) return GDI_ERROR; /* empty glyph */
4249  if (needed > cjBuf)
4250  return GDI_ERROR;
4251 
4252  switch (ft_face->glyph->format)
4253  {
4255  {
4256  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4257  INT h = min( height, ft_face->glyph->bitmap.rows );
4258  INT x;
4259  while (h--)
4260  {
4261  for (x = 0; (UINT)x < pitch; x++)
4262  {
4263  if (x < ft_face->glyph->bitmap.width)
4264  dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4265  else
4266  dst[x] = 0;
4267  }
4268  src += ft_face->glyph->bitmap.pitch;
4269  dst += pitch;
4270  }
4271  break;
4272  }
4274  {
4275  ft_bitmap.width = width;
4276  ft_bitmap.rows = height;
4277  ft_bitmap.pitch = pitch;
4278  ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4279  ft_bitmap.buffer = pvBuf;
4280 
4281  IntLockFreeType();
4282  if (needsTransform)
4283  {
4284  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4285  }
4286  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4287  RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4288  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4290 
4291  if (iFormat == GGO_GRAY2_BITMAP)
4292  mult = 4;
4293  else if (iFormat == GGO_GRAY4_BITMAP)
4294  mult = 16;
4295  else if (iFormat == GGO_GRAY8_BITMAP)
4296  mult = 64;
4297  else
4298  {
4299  return GDI_ERROR;
4300  }
4301 
4302  start = pvBuf;
4303  for (row = 0; row < height; row++)
4304  {
4305  ptr = start;
4306  for (col = 0; col < width; col++, ptr++)
4307  {
4308  *ptr = (((int)*ptr) * mult + 128) / 256;
4309  }
4310  start += pitch;
4311  }
4312 
4313  break;
4314  }
4315  default:
4316  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4317  return GDI_ERROR;
4318  }
4319 
4320  break;
4321  }
4322 
4323  case GGO_NATIVE:
4324  {
4325  FT_Outline *outline = &ft_face->glyph->outline;
4326 
4327  if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4328 
4329  IntLockFreeType();
4330  if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4331 
4333 
4334  if (!pvBuf || !cjBuf)
4335  {
4337  break;
4338  }
4339  if (needed > cjBuf)
4340  {
4342  return GDI_ERROR;
4343  }
4346  break;
4347  }
4348 
4349  case GGO_BEZIER:
4350  {
4351  FT_Outline *outline = &ft_face->glyph->outline;
4352  if (cjBuf == 0) pvBuf = NULL;
4353 
4354  if (needsTransform && pvBuf)
4355  {
4356  IntLockFreeType();
4357  FT_Outline_Transform(outline, &transMat);
4359  }
4361 
4362  if (!pvBuf || !cjBuf)
4363  break;
4364  if (needed > cjBuf)
4365  return GDI_ERROR;
4366 
4368  break;
4369  }
4370 
4371  default:
4372  DPRINT1("Unsupported format %u\n", iFormat);
4373  return GDI_ERROR;
4374  }
4375 
4376  DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4377  *pgm = gm;
4378  return needed;
4379 }
#define abs(i)
Definition: fconv.c:206
int FT_Error
Definition: fttypes.h:300
GLint GLint GLsizei width
Definition: gl.h:1546
FT_Pos y
Definition: ftimage.h:77
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FLOATL eM11
Definition: winddi.h:1234
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define GGO_METRICS
Definition: wingdi.h:847
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
unsigned char pixel_mode
Definition: ftimage.h:268
long y
Definition: polytest.cpp:48
unsigned int rows
Definition: ftimage.h:263
#define error(str)
Definition: mkdosfs.c:1605
long x
Definition: polytest.cpp:48
FT_Pos x
Definition: ftimage.h:76
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define FLOATOBJ_Set1(fo)
Definition: floatobj.h:120
signed int FT_Int
Definition: fttypes.h:220
#define FLOATOBJ_DivLong(pf, l)
Definition: winddi.h:2829
FT_Glyph_Metrics metrics
Definition: freetype.h:1916
LONG tmAveCharWidth
Definition: wingdi.h:2383
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3010
static __inline FT_Fixed FT_FixedFromFIXED(FIXED f)
Definition: freetype.c:382
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned char * buffer
Definition: ftimage.h:266
#define FLOATOBJ_GetLong(pf)
Definition: winddi.h:2817
#define GGO_GRAY4_BITMAP
Definition: wingdi.h:852
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC dc
Definition: cylfrac.c:34
short gmCellIncY
Definition: wingdi.h:2441
FT_Matrix_Multiply(const FT_Matrix *a, FT_Matrix *b)
Definition: ftcalc.c:661
FORCEINLINE VOID XFORMOBJ_vInit(OUT XFORMOBJ *pxo, IN MATRIX *pmx)
Definition: xformobj.h:21
#define FT_LOAD_DEFAULT
Definition: freetype.h:3008
int32_t INT
Definition: typedefs.h:56
HFONT hFont
Definition: main.c:53
#define GGO_BITMAP
Definition: wingdi.h:848
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
FT_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap *abitmap)
Definition: ftoutln.c:661
#define GGO_GRAY8_BITMAP
Definition: wingdi.h:853
#define GGO_BEZIER
Definition: wingdi.h:850
#define FLOATOBJ_SetFloat(pf, f)
Definition: winddi.h:2814
FT_Fixed xx
Definition: fttypes.h:387
BOOL FASTCALL TextIntUpdateSize(PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:3770
Definition: text.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
#define XFORMOBJ_iGetXform
Definition: xformobj.h:9
long LONG
Definition: pedump.c:60
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:760
LONG lfOrientation
Definition: dimm.idl:62
HANDLE hlfntNew
Definition: ntgdihdl.h:334
static PVOID ptr
Definition: dispmode.c:27
#define GGO_NATIVE
Definition: wingdi.h:849
#define FLOATOBJ_AddLong(pf, l)
Definition: winddi.h:2820
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2604
LONG lfWidth
Definition: dimm.idl:60
smooth NULL
Definition: ftsmooth.c:416
FT_Library g_FreeTypeLibrary
Definition: freetype.c:55
void DPRINT(...)
Definition: polytest.cpp:61
GLint GLint bottom
Definition: glext.h:7726
FIXED eM22
Definition: wingdi.h:2471
FIXED eM11
Definition: wingdi.h:2468
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
FIXED eM21
Definition: wingdi.h:2470
#define ft_glyph_format_outline
Definition: ftimage.h:732
#define ft_glyph_format_bitmap
Definition: ftimage.h:731
VOID FASTCALL FtMatrixFromMx(FT_Matrix *pmat, PMATRIX pmx)
Definition: freetype.c:752
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
POINT gmptGlyphOrigin
Definition: wingdi.h:2439
FLOAT FLOATOBJ
Definition: winddi.h:677
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
static unsigned int get_native_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3454
FT_Face Face
Definition: engobjects.h:129
FT_Vector * vec
Definition: ftbbox.c:448
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define GGO_UNHINTED
Definition: wingdi.h:855
VOID FtSetCoordinateTransform(FT_Face face, PMATRIX pmx)
Definition: freetype.c:775
#define GGO_GLYPH_INDEX
Definition: wingdi.h:854
_In_ DWORD cjBuf
Definition: winddi.h:3827
static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3527
#define IntLockFreeType()
Definition: freetype.c:79
FT_Outline outline
Definition: freetype.h:1927
unsigned char BYTE
Definition: mem.h:68
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, DWORD indexed_flag, DWORD flags)
Definition: freetype.c:3888
FIXED eM12
Definition: wingdi.h:2469
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:2440
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3467
FT_GlyphSlot glyph
Definition: freetype.h:1105
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
FT_Glyph_Format format
Definition: freetype.h:1921
FONTOBJ * Font
Definition: text.h:66
VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
Definition: freetype.c:739
FT_Vector_Transform(FT_Vector *vec, const FT_Matrix *matrix)
Definition: ftoutln.c:688
#define GDITAG_TEXT
Definition: tags.h:171
PSHARED_FACE SharedFace
Definition: engobjects.h:142
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
unsigned int FT_UInt
Definition: fttypes.h:231
GLuint start
Definition: gl.h:1545
FT_Fixed xy
Definition: fttypes.h:387
GLenum GLenum dst
Definition: glext.h:6340
UINT gmBlackBoxY
Definition: wingdi.h:2438
#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:2509
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
Definition: freetype.h:3017
int pitch
Definition: ftimage.h:265
#define DPRINT1
Definition: precomp.h:8
static const FT_Matrix identityMat
Definition: freetype.c:50
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:528
LOGFONTW elfLogFont
Definition: wingdi.h:2697
UINT gmBlackBoxX
Definition: wingdi.h:2437
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:107
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:98
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3012
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
FT_Fixed yx
Definition: fttypes.h:388
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2774
FT_Fixed yy
Definition: fttypes.h:388
#define INT_TO_FIXED(x)
Definition: ftcalc.h:404
#define FLOATOBJ_Mul(pf, pf1)
Definition: winddi.h:2824
#define GDI_ERROR
Definition: wingdi.h:1308
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
unsigned int width
Definition: ftimage.h:264
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by NtGdiGetGlyphOutline(), and PATH_ExtTextOut().

◆ ftGdiGetKerningPairs()

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

Definition at line 5828 of file freetype.c.

5831 {
5832  DWORD Count = 0;
5833  INT i = 0;
5834  FT_Face face = Font->SharedFace->Face;
5835 
5836  if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
5837  {
5838  FT_UInt previous_index = 0, glyph_index = 0;
5839  FT_ULong char_code, char_previous;
5840  FT_Vector delta;
5841 
5842  char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
5843 
5844  IntLockFreeType();
5845 
5846  while (glyph_index)
5847  {
5848  if (previous_index && glyph_index)
5849  {
5850  FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
5851 
5852  if (pKerningPair && cPairs)
5853  {
5854  pKerningPair[i].wFirst = char_previous;
5855  pKerningPair[i].wSecond = char_code;
5856  pKerningPair[i].iKernAmount = delta.x;
5857  i++;
5858  if (i == cPairs) break;
5859  }
5860  Count++;
5861  }
5862  previous_index = glyph_index;
5863  char_previous = char_code;
5864  char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
5865  }
5867  }
5868  return Count;
5869 }
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:2460
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:2461
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
#define IntLockFreeType()
Definition: freetype.c:79
unsigned int FT_UInt
Definition: fttypes.h:231
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by GreGetKerningPairs(), and NtGdiGetKerningPairs().

◆ ftGdiGetRasterizerCaps()

BOOL FASTCALL ftGdiGetRasterizerCaps ( LPRASTERIZER_STATUS  lprs)

Definition at line 3279 of file freetype.c.

3280 {
3281  if ( lprs )
3282  {
3283  lprs->nSize = sizeof(RASTERIZER_STATUS);
3284  lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3285  lprs->nLanguageID = gusLanguageID;
3286  return TRUE;
3287  }
3289  return FALSE;
3290 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
struct _RASTERIZER_STATUS RASTERIZER_STATUS
#define TT_AVAILABLE
Definition: wingdi.h:887
USHORT gusLanguageID
Definition: main.c:29
#define TT_ENABLED
Definition: wingdi.h:888
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by NtGdiGetRasterizerCaps().

◆ ftGdiGetTextCharsetInfo()

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

Definition at line 4523 of file freetype.c.

4527 {
4528  PDC_ATTR pdcattr;
4529  UINT Ret = DEFAULT_CHARSET;
4530  INT i;
4531  HFONT hFont;
4532  PTEXTOBJ TextObj;
4533  PFONTGDI FontGdi;
4534  FONTSIGNATURE fs;
4535  TT_OS2 *pOS2;
4536  FT_Face Face;
4537  CHARSETINFO csi;
4538  DWORD cp, fs0;
4539  USHORT usACP, usOEM;
4540 
4541  pdcattr = Dc->pdcattr;
4542  hFont = pdcattr->hlfntNew;
4543  TextObj = RealizeFontInit(hFont);
4544 
4545  if (!TextObj)
4546  {
4548  return Ret;
4549  }
4550  FontGdi = ObjToGDI(TextObj->Font, FONT);
4551  Face = FontGdi->SharedFace->Face;
4552  TEXTOBJ_UnlockText(TextObj);
4553 
4554  memset(&fs, 0, sizeof(FONTSIGNATURE));
4555  IntLockFreeType();
4556  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4557  if (NULL != pOS2)
4558  {
4559  fs.fsCsb[0] = pOS2->ulCodePageRange1;
4560  fs.fsCsb[1] = pOS2->ulCodePageRange2;
4561  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
4562  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
4563  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
4564  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
4565  if (pOS2->version == 0)
4566  {
4567  FT_UInt dummy;
4568 
4569  if (FT_Get_First_Char( Face, &dummy ) < 0x100)
4570  fs.fsCsb[0] |= FS_LATIN1;
4571  else
4572  fs.fsCsb[0] |= FS_SYMBOL;
4573  }
4574  }
4575  pOS2 = NULL;
4577  DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
4578  if (fs.fsCsb[0] == 0)
4579  { /* Let's see if we can find any interesting cmaps */
4580  for (i = 0; i < Face->num_charmaps; i++)
4581  {
4582  switch (Face->charmaps[i]->encoding)
4583  {
4584  case FT_ENCODING_UNICODE:
4585  case FT_ENCODING_APPLE_ROMAN:
4586  fs.fsCsb[0] |= FS_LATIN1;
4587  break;
4588  case FT_ENCODING_MS_SYMBOL:
4589  fs.fsCsb[0] |= FS_SYMBOL;
4590  break;
4591  default:
4592  break;
4593  }
4594  }
4595  }
4596  if (lpSig)
4597  {
4598  RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
4599  }
4600 
4601  RtlGetDefaultCodePage(&usACP, &usOEM);
4602  cp = usACP;
4603 
4605  if (csi.fs.fsCsb[0] & fs.fsCsb[0])
4606  {
4607  DPRINT("Hit 1\n");
4608  Ret = csi.ciCharset;
4609  goto Exit;
4610  }
4611 
4612  for (i = 0; i < MAXTCIINDEX; i++)
4613  {
4614  fs0 = 1L << i;
4615  if (fs.fsCsb[0] & fs0)
4616  {
4617  if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
4618  {
4619  // *cp = csi.ciACP;
4620  DPRINT("Hit 2\n");
4621  Ret = csi.ciCharset;
4622  goto Exit;
4623  }
4624  else
4625  DPRINT1("TCI failing on %x\n", fs0);
4626  }
4627  }
4628 Exit:
4629  DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
4630  return (MAKELONG(csi.ciACP, csi.ciCharset));
4631 }
FONTSIGNATURE fs
Definition: wingdi.h:1543
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FT_CharMap * charmaps
Definition: freetype.h:1085
#define ft_sfnt_os2
Definition: tttables.h:631
#define TCI_SRCFONTSIG
Definition: wingdi.h:962
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
Definition: fs.h:235
#define DEFAULT_CHARSET
Definition: wingdi.h:383
int32_t INT
Definition: typedefs.h:56
#define MAXTCIINDEX
Definition: freetype.c:123
HFONT hFont
Definition: main.c:53
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:334
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
UINT ciCharset
Definition: wingdi.h:1541
#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:2209
#define FS_SYMBOL
Definition: wingdi.h:574
static void Exit(void)
Definition: sock.c:1331
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
FT_Face Face
Definition: engobjects.h:129
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
FT_Encoding encoding
Definition: freetype.h:843
static const WCHAR L[]
Definition: oid.c:1250
#define IntLockFreeType()
Definition: freetype.c:79
FT_Int num_charmaps
Definition: freetype.h:1084
FONTOBJ * Font
Definition: text.h:66
DWORD fsCsb[2]
Definition: wingdi.h:1538
FT_ULong ulCodePageRange1
Definition: tttables.h:419
PSHARED_FACE SharedFace
Definition: engobjects.h:142
unsigned short USHORT
Definition: pedump.c:61
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
#define fs
Definition: i386-dis.c:435
unsigned int FT_UInt
Definition: fttypes.h:231
unsigned char dummy
Definition: maze.c:118
FT_ULong ulUnicodeRange4
Definition: tttables.h:404
unsigned int UINT
Definition: ndis.h:50
FT_ULong ulCodePageRange2
Definition: tttables.h:420
#define DPRINT1
Definition: precomp.h:8
FT_ULong ulUnicodeRange3
Definition: tttables.h:403
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define TCI_SRCCODEPAGE
Definition: wingdi.h:961
#define FS_LATIN1
Definition: wingdi.h:559
POINT cp
Definition: magnifier.c:59
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define memset(x, y, z)
Definition: compat.h:39
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
FT_ULong ulUnicodeRange2
Definition: tttables.h:402

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

◆ ftGdiGetTextMetricsW()

BOOL FASTCALL ftGdiGetTextMetricsW ( HDC  hDC,
PTMW_INTERNAL  ptmwi 
)

Definition at line 4704 of file freetype.c.

4707 {
4708  PDC dc;
4709  PDC_ATTR pdcattr;
4710  PTEXTOBJ TextObj;
4711  PFONTGDI FontGDI;
4712  FT_Face Face;
4713  TT_OS2 *pOS2;
4714  TT_HoriHeader *pHori;
4715  FT_WinFNT_HeaderRec Win;
4716  ULONG Error;
4718  LOGFONTW *plf;
4719 
4720  if (!ptmwi)
4721  {
4723  return FALSE;
4724  }
4725 
4726  if (!(dc = DC_LockDc(hDC)))
4727  {
4729  return FALSE;
4730  }
4731  pdcattr = dc->pdcattr;
4732  TextObj = RealizeFontInit(pdcattr->hlfntNew);
4733  if (NULL != TextObj)
4734  {
4735  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4736  FontGDI = ObjToGDI(TextObj->Font, FONT);
4737 
4738  Face = FontGDI->SharedFace->Face;
4739 
4740  IntLockFreeType();
4741  Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4744 
4745  if (0 != Error)
4746  {
4747  DPRINT1("Error in setting pixel sizes: %u\n", Error);
4749  }
4750  else
4751  {
4752  FT_Face Face = FontGDI->SharedFace->Face;
4754 
4755  IntLockFreeType();
4756  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4757  if (NULL == pOS2)
4758  {
4759  DPRINT1("Can't find OS/2 table - not TT font?\n");
4761  }
4762 
4763  pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
4764  if (NULL == pHori)
4765  {
4766  DPRINT1("Can't find HHEA table - not TT font?\n");
4768  }
4769 
4770  Error = FT_Get_WinFNT_Header(Face, &Win);
4771 
4772  if (NT_SUCCESS(Status) || !Error)
4773  {
4774  FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
4775 
4776  /* FIXME: Fill Diff member */
4777  RtlZeroMemory(&ptmwi->Diff, sizeof(ptmwi->Diff));
4778  }
4779 
4781  }
4782  TEXTOBJ_UnlockText(TextObj);
4783  }
4784  else
4785  {
4787  }
4788  DC_UnlockDc(dc);
4789 
4790  if (!NT_SUCCESS(Status))
4791  {
4793  return FALSE;
4794  }
4795  return TRUE;
4796 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:369
#define TRUE
Definition: types.h:120
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FT_Get_WinFNT_Header(FT_Face face, FT_WinFNT_HeaderRec *aheader)
Definition: ftwinfnt.c:29
#define ft_sfnt_os2
Definition: tttables.h:631
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
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:334
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
static void FASTCALL FillTM(TEXTMETRICW *TM, PFONTGDI FontGDI, TT_OS2 *pOS2, TT_HoriHeader *pHori, FT_WinFNT_HeaderRec *pFNT)
Definition: freetype.c:2510
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:3652
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IntUnLockFreeType()
Definition: freetype.c:82
BOOL Error
Definition: chkdsk.c:66
FT_Face Face
Definition: engobjects.h:129
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID FtSetCoordinateTransform(FT_Face face, PMATRIX pmx)
Definition: freetype.c:775
#define IntLockFreeType()
Definition: freetype.c:79
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
Status
Definition: gdiplustypes.h:24
static HDC hDC
Definition: 3dtext.c:33
FONTOBJ * Font
Definition: text.h:66
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PSHARED_FACE SharedFace
Definition: engobjects.h:142
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
#define DPRINT1
Definition: precomp.h:8
TMDIFF Diff
Definition: ntgdityp.h:370
LOGFONTW elfLogFont
Definition: wingdi.h:2697
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:98
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2774
return STATUS_SUCCESS
Definition: btrfs.c:2966
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 3305 of file freetype.c.

3311 {
3312  PLIST_ENTRY CurrentEntry;
3313  PFONT_CACHE_ENTRY FontEntry;
3314 
3316 
3317  for (CurrentEntry = g_FontCacheListHead.Flink;
3318  CurrentEntry != &g_FontCacheListHead;
3319  CurrentEntry = CurrentEntry->Flink)
3320  {
3321  FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
3322  if ((FontEntry->Face == Face) &&
3323  (FontEntry->GlyphIndex == GlyphIndex) &&
3324  (FontEntry->Height == Height) &&
3325  (FontEntry->RenderMode == RenderMode) &&
3326  (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx)))
3327  break;
3328  }
3329 
3330  if (CurrentEntry == &g_FontCacheListHead)
3331  {
3332  return NULL;
3333  }
3334 
3335  RemoveEntryList(CurrentEntry);
3336  InsertHeadList(&g_FontCacheListHead, CurrentEntry);
3337  return FontEntry->BitmapGlyph;
3338 }
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FT_BitmapGlyph BitmapGlyph
Definition: font.h:31
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
int GlyphIndex
Definition: font.h:29
smooth NULL
Definition: ftsmooth.c:416
FT_Face Face
Definition: font.h:30
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
MATRIX mxWorldToDevice
Definition: font.h:36
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
static BOOL SameScaleMatrix(PMATRIX pmx1, PMATRIX pmx2)
Definition: freetype.c:3294
int Height
Definition: font.h:32
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:93
Definition: font.h:26
Definition: typedefs.h:117
FT_Render_Mode RenderMode
Definition: font.h:35

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ ftGdiGlyphCacheSet()

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

Definition at line 3383 of file freetype.c.

3390 {
3391  FT_Glyph GlyphCopy;
3392  INT error;
3393  PFONT_CACHE_ENTRY NewEntry;
3394  FT_Bitmap AlignedBitmap;
3395  FT_BitmapGlyph BitmapGlyph;
3396 
3398 
3399  error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
3400  if (error)
3401  {
3402  DPRINT1("Failure caching glyph.\n");
3403  return NULL;
3404  };
3405 
3406  error = FT_Glyph_To_Bitmap(&GlyphCopy, RenderMode, 0, 1);
3407  if (error)
3408  {
3409  FT_Done_Glyph(GlyphCopy);
3410  DPRINT1("Failure rendering glyph.\n");
3411  return NULL;
3412  };
3413 
3415  if (!NewEntry)
3416  {
3417  DPRINT1("Alloc failure caching glyph.\n");
3418  FT_Done_Glyph(GlyphCopy);
3419  return NULL;
3420  }
3421 
3422  BitmapGlyph = (FT_BitmapGlyph)GlyphCopy;
3423  FT_Bitmap_New(&AlignedBitmap);
3424  if(FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3425  {
3426  DPRINT1("Conversion failed\n");
3427  ExFreePoolWithTag(NewEntry, TAG_FONT);
3428  FT_Bitmap_Done(GlyphSlot->library, &AlignedBitmap);
3429  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3430  return NULL;
3431  }
3432 
3433  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3434  BitmapGlyph->bitmap = AlignedBitmap;
3435 
3436  NewEntry->GlyphIndex = GlyphIndex;
3437  NewEntry->Face = Face;
3438  NewEntry->BitmapGlyph = BitmapGlyph;
3439  NewEntry->Height = Height;
3440  NewEntry->RenderMode = RenderMode;
3441  NewEntry->mxWorldToDevice = *pmx;
3442 
3445  {
3447  RemoveCachedEntry(NewEntry);
3448  }
3449 
3450  return BitmapGlyph;
3451 }
FT_Bitmap bitmap
Definition: ftglyph.h:165
#define error(str)
Definition: mkdosfs.c:1605
static UINT g_FontCacheNumEntries
Definition: freetype.c:94
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FT_BitmapGlyph BitmapGlyph
Definition: font.h:31
#define TAG_FONT
Definition: tags.h:12
FT_Bitmap_Done(FT_Library library, FT_Bitmap *bitmap)
Definition: ftbitmap.c:826
int32_t INT
Definition: typedefs.h:56
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:127
#define ASSERT_FREETYPE_LOCK_HELD()
Definition: freetype.c:85
int GlyphIndex
Definition: font.h:29
FT_Bitmap_Convert(FT_Library library, const FT_Bitmap *source, FT_Bitmap *target, FT_Int alignment)
Definition: ftbitmap.c:504
smooth NULL
Definition: ftsmooth.c:416
#define MAX_FONT_CACHE
Definition: freetype.c:91
FT_Face Face
Definition: font.h:30
FT_Bitmap_New(FT_Bitmap *abitmap)
Definition: ftbitmap.c:44
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
MATRIX mxWorldToDevice
Definition: font.h:36
static void RemoveCachedEntry(PFONT_CACHE_ENTRY Entry)
Definition: freetype.c:257
LIST_ENTRY ListEntry
Definition: font.h:28
int Height
Definition: font.h:32
FT_Glyph_To_Bitmap(FT_Glyph *the_glyph, FT_Render_Mode render_mode, FT_Vector *origin, FT_Bool destroy)
Definition: ftglyph.c:527
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:93
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: font.h:26
FT_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph)
Definition: ftglyph.c:363
FT_Render_Mode RenderMode
Definition: font.h:35
FT_Library library
Definition: freetype.h:1910
#define DPRINT1
Definition: precomp.h:8
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ ftGdiGlyphSet()

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

Definition at line 3342 of file freetype.c.

3346 {
3347  FT_Glyph Glyph;
3348  INT error;
3349  FT_Bitmap AlignedBitmap;
3350  FT_BitmapGlyph BitmapGlyph;
3351 
3352  error = FT_Get_Glyph(GlyphSlot, &Glyph);
3353  if (error)
3354  {
3355  DPRINT1("Failure getting glyph.\n");
3356  return NULL;
3357  }
3358 
3359  error = FT_Glyph_To_Bitmap(&Glyph, RenderMode, 0, 1);
3360  if (error)
3361  {
3362  FT_Done_Glyph(Glyph);
3363  DPRINT1("Failure rendering glyph.\n");
3364  return NULL;
3365  }
3366 
3367  BitmapGlyph = (FT_BitmapGlyph)Glyph;
3368  FT_Bitmap_New(&AlignedBitmap);
3369  if (FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3370  {
3371  DPRINT1("Conversion failed\n");
3372  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3373  return NULL;
3374  }
3375 
3376  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3377  BitmapGlyph->bitmap = AlignedBitmap;
3378 
3379  return BitmapGlyph;
3380 }
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 5809 of file freetype.c.

5810 {
5811  if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
5812  Info->iTechnology = RI_TECH_BITMAP;
5813  else
5814  {
5815  if (FT_IS_SCALABLE(Font->SharedFace->Face))
5816  Info->iTechnology = RI_TECH_SCALABLE;
5817  else
5818  Info->iTechnology = RI_TECH_FIXED;
5819  }
5820  Info->iUniq = Font->FontObj.iUniq;
5821  Info->dwUnknown = -1;
5822  return TRUE;
5823 }
#define TRUE
Definition: types.h:120
#define RI_TECH_BITMAP
Definition: ntgdityp.h:270
struct TraceInfo Info
#define RI_TECH_SCALABLE
Definition: ntgdityp.h:272
#define FT_HAS_FIXED_SIZES(face)
Definition: freetype.h:1361
#define RI_TECH_FIXED
Definition: ntgdityp.h:271
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312

Referenced by NtGdiGetRealizationInfo().

◆ ftGetFontUnicodeRanges()

DWORD FASTCALL ftGetFontUnicodeRanges ( PFONTGDI  Font,
PGLYPHSET  glyphset 
)

Definition at line 4636 of file freetype.c.

4637 {
4638  DWORD size = 0;
4639  DWORD num_ranges = 0;
4640  FT_Face face = Font->SharedFace->Face;
4641 
4642  if (face->charmap->encoding == FT_ENCODING_UNICODE)
4643  {
4644  FT_UInt glyph_code = 0;
4645  FT_ULong char_code, char_code_prev;
4646 
4647  char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
4648 
4649  DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
4650  face->num_glyphs, glyph_code, char_code);
4651 
4652  if (!glyph_code) return 0;
4653 
4654  if (glyphset)
4655  {
4656  glyphset->ranges[0].wcLow = (USHORT)char_code;
4657  glyphset->ranges[0].cGlyphs = 0;
4658  glyphset->cGlyphsSupported = 0;
4659  }
4660 
4661  num_ranges = 1;
4662  while (glyph_code)
4663  {
4664  if (char_code < char_code_prev)
4665  {
4666  DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
4667  return 0;
4668  }
4669  if (char_code - char_code_prev > 1)
4670  {
4671  num_ranges++;
4672  if (glyphset)
4673  {
4674  glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
4675  glyphset->ranges[num_ranges - 1].cGlyphs = 1;
4676  glyphset->cGlyphsSupported++;
4677  }
4678  }
4679  else if (glyphset)
4680  {
4681  glyphset->ranges[num_ranges - 1].cGlyphs++;
4682  glyphset->cGlyphsSupported++;
4683  }
4684  char_code_prev = char_code;
4685  char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
4686  }
4687  }
4688  else
4689  DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
4690 
4691  size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
4692  if (glyphset)
4693  {
4694  glyphset->cbThis = size;
4695  glyphset->cRanges = num_ranges;
4696  glyphset->flAccel = 0;
4697  }
4698  return size;
4699 }
unsigned long FT_ULong
Definition: fttypes.h:253
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3722
void DPRINT(...)
Definition: polytest.cpp:61
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
unsigned short USHORT
Definition: pedump.c:61
unsigned int FT_UInt
Definition: fttypes.h:231
#define DPRINT1
Definition: precomp.h:8
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by NtGdiGetFontUnicodeRanges().

◆ FtMatrixFromMx()

VOID FASTCALL FtMatrixFromMx ( FT_Matrix pmat,
PMATRIX  pmx 
)

Definition at line 752 of file freetype.c.

753 {
754  FLOATOBJ ef;
755 
756  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
757  ef = pmx->efM11;
758  FLOATOBJ_MulLong(&ef, 0x00010000);
759  pmat->xx = FLOATOBJ_GetLong(&ef);
760 
761  ef = pmx->efM21;
762  FLOATOBJ_MulLong(&ef, 0x00010000);
763  pmat->xy = FLOATOBJ_GetLong(&ef);
764 
765  ef = pmx->efM12;
766  FLOATOBJ_MulLong(&ef, 0x00010000);
767  pmat->yx = FLOATOBJ_GetLong(&ef);
768 
769  ef = pmx->efM22;
770  FLOATOBJ_MulLong(&ef, 0x00010000);
771  pmat->yy = FLOATOBJ_GetLong(&ef);
772 }
FLOATOBJ efM21
Definition: ntgdityp.h:413
#define FLOATOBJ_GetLong(pf)
Definition: winddi.h:2817
FT_Fixed xx
Definition: fttypes.h:387
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
FLOAT FLOATOBJ
Definition: winddi.h:677
FLOATOBJ efM12
Definition: ntgdityp.h:412
FLOATOBJ efM22
Definition: ntgdityp.h:414
FT_Fixed xy
Definition: fttypes.h:387
FLOATOBJ efM11
Definition: ntgdityp.h:411
FT_Fixed yx
Definition: fttypes.h:388
FT_Fixed yy
Definition: fttypes.h:388

Referenced by ftGdiGetGlyphOutline().

◆ FtSetCoordinateTransform()

VOID FtSetCoordinateTransform ( FT_Face  face,
PMATRIX  pmx 
)

Definition at line 775 of file freetype.c.

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

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

◆ FTVectorToPOINTFX()

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

Definition at line 368 of file freetype.c.

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

3528 {
3529  /* Convert the quadratic Beziers to cubic Beziers.
3530  The parametric eqn for a cubic Bezier is, from PLRM:
3531  r(t) = at^3 + bt^2 + ct + r0
3532  with the control points:
3533  r1 = r0 + c/3
3534  r2 = r1 + (c + b)/3
3535  r3 = r0 + c + b + a
3536 
3537  A quadratic Bezier has the form:
3538  p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
3539 
3540  So equating powers of t leads to:
3541  r1 = 2/3 p1 + 1/3 p0
3542  r2 = 2/3 p1 + 1/3 p2
3543  and of course r0 = p0, r3 = p2
3544  */
3545  int contour, point = 0, first_pt;
3546  TTPOLYGONHEADER *pph;
3547  TTPOLYCURVE *ppc;
3548  DWORD pph_start, cpfx, type;
3549  FT_Vector cubic_control[4];
3550  unsigned int needed = 0;
3551 
3552  for (contour = 0; contour < outline->n_contours; contour++)
3553  {
3554  pph_start = needed;
3555  pph = (TTPOLYGONHEADER *)(buf + needed);
3556  first_pt = point;
3557  if (buf)
3558  {
3559  pph->dwType = TT_POLYGON_TYPE;
3560  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3561  }
3562  needed += sizeof(*pph);
3563  point++;
3564  while (point <= outline->contours[contour])
3565  {
3566  ppc = (TTPOLYCURVE *)(buf + needed);
3567  type = outline->tags[point] & FT_Curve_Tag_On ?
3569  cpfx = 0;
3570  do
3571  {
3572  if (type == TT_PRIM_LINE)
3573  {
3574  if (buf)
3575  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3576  cpfx++;
3577  point++;
3578  }
3579  else
3580  {
3581  /* Unlike QSPLINEs, CSPLINEs always have their endpoint
3582  so cpfx = 3n */
3583 
3584  /* FIXME: Possible optimization in endpoint calculation
3585  if there are two consecutive curves */
3586  cubic_control[0] = outline->points[point-1];
3587  if (!(outline->tags[point-1] & FT_Curve_Tag_On))
3588  {
3589  cubic_control[0].x += outline->points[point].x + 1;
3590  cubic_control[0].y += outline->points[point].y + 1;
3591  cubic_control[0].x >>= 1;
3592  cubic_control[0].y >>= 1;
3593  }
3594  if (point+1 > outline->contours[contour])
3595  cubic_control[3] = outline->points[first_pt];
3596  else
3597  {
3598  cubic_control[3] = outline->points[point+1];
3599  if (!(outline->tags[point+1] & FT_Curve_Tag_On))
3600  {
3601  cubic_control[3].x += outline->points[point].x + 1;
3602  cubic_control[3].y += outline->points[point].y + 1;
3603  cubic_control[3].x >>= 1;
3604  cubic_control[3].y >>= 1;
3605  }
3606  }
3607  /* r1 = 1/3 p0 + 2/3 p1
3608  r2 = 1/3 p2 + 2/3 p1 */
3609  cubic_control[1].x = (2 * outline->points[point].x + 1) / 3;
3610  cubic_control[1].y = (2 * outline->points[point].y + 1) / 3;
3611  cubic_control[2] = cubic_control[1];
3612  cubic_control[1].x += (cubic_control[0].x + 1) / 3;
3613  cubic_control[1].y += (cubic_control[0].y + 1) / 3;
3614  cubic_control[2].x += (cubic_control[3].x + 1) / 3;
3615  cubic_control[2].y += (cubic_control[3].y + 1) / 3;
3616  if (buf)
3617  {
3618  FTVectorToPOINTFX(&cubic_control[1], &ppc->apfx[cpfx]);
3619  FTVectorToPOINTFX(&cubic_control[2], &ppc->apfx[cpfx+1]);
3620  FTVectorToPOINTFX(&cubic_control[3], &ppc->apfx[cpfx+2]);
3621  }
3622  cpfx += 3;
3623  point++;
3624  }
3625  } while (point <= outline->contours[contour] &&
3626  (outline->tags[point] & FT_Curve_Tag_On) ==
3627  (outline->tags[point-1] & FT_Curve_Tag_On));
3628  /* At the end of a contour Windows adds the start point,
3629  but only for Beziers and we've already done that.
3630  */
3631  if (point <= outline->contours[contour] &&
3632  outline->tags[point] & FT_Curve_Tag_On)
3633  {
3634  /* This is the closing pt of a bezier, but we've already
3635  added it, so just inc point and carry on */
3636  point++;
3637  }
3638  if (buf)
3639  {
3640  ppc->wType = type;
3641  ppc->cpfx = cpfx;
3642  }
3643  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3644  }
3645  if (buf)
3646  pph->cb = needed - pph_start;
3647  }
3648  return needed;
3649 }
#define FT_Curve_Tag_On
Definition: ftimage.h:465
FT_Pos y
Definition: ftimage.h:77
#define TT_POLYGON_TYPE
Definition: wingdi.h:1317
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:368
FT_Pos x
Definition: ftimage.h:76
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
POINTL point
Definition: edittest.c:50
#define TT_PRIM_CSPLINE
Definition: wingdi.h:1320
POINTFX apfx[1]
Definition: wingdi.h:2709
unsigned long DWORD
Definition: ntddk_ex.h:95
POINTFX pfxStart
Definition: wingdi.h:2714
Definition: mesh.c:5329
#define TT_PRIM_LINE
Definition: wingdi.h:1318

Referenced by ftGdiGetGlyphOutline().

◆ get_glyph_index()

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

Definition at line 3873 of file freetype.c.

3874 {
3875  FT_UInt ret;
3876 
3877  if (face_has_symbol_charmap(ft_face))
3878  {
3879  ret = get_glyph_index_symbol(ft_face, glyph);
3880  if (ret != 0)
3881  return ret;
3882  }
3883 
3884  return FT_Get_Char_Index(ft_face, glyph);
3885 }
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2256
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:3859
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 3888 of file freetype.c.

3889 {
3890  FT_UInt glyph_index;
3891  if (flags & indexed_flag)
3892  {
3893  glyph_index = code;
3894  }
3895  else
3896  {
3897  glyph_index = get_glyph_index(face, code);
3898  }
3899  return glyph_index;
3900 }
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3873
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 3859 of file freetype.c.

3860 {
3861  FT_UInt ret;
3862 
3863  if (glyph < 0x100) glyph += 0xf000;
3864  /* there are a number of old pre-Unicode "broken" TTFs, which
3865  do have symbols at U+00XX instead of U+f0XX */
3866  if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
3867  ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
3868 
3869  return ret;
3870 }
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 3454 of file freetype.c.

3455 {
3456  TTPOLYGONHEADER *pph;
3457  TTPOLYCURVE *ppc;
3458  int needed = 0, point = 0, contour, first_pt;
3459  unsigned int pph_start, cpfx;
3460  DWORD type;
3461 
3462  for (contour = 0; contour < outline->n_contours; contour++)
3463  {
3464  /* Ignore contours containing one point */
3465  if (point == outline->contours[contour])
3466  {
3467  point++;
3468  continue;
3469  }
3470 
3471  pph_start = needed;
3472  pph = (TTPOLYGONHEADER *)(buf + needed);
3473  first_pt = point;
3474  if (buf)
3475  {
3476  pph->dwType = TT_POLYGON_TYPE;
3477  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3478  }
3479  needed += sizeof(*pph);
3480  point++;
3481  while (point <= outline->contours[contour])
3482  {
3483  ppc = (TTPOLYCURVE *)(buf + needed);
3484  type = outline->tags[point] & FT_Curve_Tag_On ?
3486  cpfx = 0;
3487  do
3488  {
3489  if (buf)
3490  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3491  cpfx++;
3492  point++;
3493  } while (point <= outline->contours[contour] &&
3494  (outline->tags[point] & FT_Curve_Tag_On) ==
3495  (outline->tags[point-1] & FT_Curve_Tag_On));
3496  /* At the end of a contour Windows adds the start point, but
3497  only for Beziers */
3498  if (point > outline->contours[contour] &&
3499  !(outline->tags[point-1] & FT_Curve_Tag_On))
3500  {
3501  if (buf)
3502  FTVectorToPOINTFX(&outline->points[first_pt], &ppc->apfx[cpfx]);
3503  cpfx++;
3504  }
3505  else if (point <= outline->contours[contour] &&
3506  outline->tags[point] & FT_Curve_Tag_On)
3507  {
3508  /* add closing pt for bezier */
3509  if (buf)
3510  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3511  cpfx++;
3512  point++;
3513  }
3514  if (buf)
3515  {
3516  ppc->wType = type;
3517  ppc->cpfx = cpfx;
3518  }
3519  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3520  }
3521  if (buf)
3522  pph->cb = needed - pph_start;
3523  }
3524  return needed;
3525 }
#define FT_Curve_Tag_On
Definition: ftimage.h:465
#define TT_POLYGON_TYPE
Definition: wingdi.h:1317
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:368
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
POINTL point
Definition: edittest.c:50
#define TT_PRIM_QSPLINE
Definition: wingdi.h:1319
POINTFX apfx[1]
Definition: wingdi.h:2709
unsigned long DWORD
Definition: ntddk_ex.h:95
POINTFX pfxStart
Definition: wingdi.h:2714
Definition: mesh.c:5329
#define TT_PRIM_LINE
Definition: wingdi.h:1318

Referenced by ftGdiGetGlyphOutline().

◆ GetFontFamilyInfoForList()

static BOOLEAN FASTCALL GetFontFamilyInfoForList ( const LOGFONTW LogFont,
PFONTFAMILYINFO  Info,
LPCWSTR  NominalName,
LONG pCount,
LONG  MaxCount,
PLIST_ENTRY  Head 
)
static

Definition at line 3153 of file freetype.c.

3159 {
3161  PFONT_ENTRY CurrentEntry;
3162  FONTGDI *FontGDI;
3163  FONTFAMILYINFO InfoEntry;
3164  LONG Count = *pCount;
3165 
3166  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
3167  {
3168  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
3169  FontGDI = CurrentEntry->Font;
3170  ASSERT(FontGDI);
3171 
3172  if (LogFont->lfCharSet != DEFAULT_CHARSET &&
3173  LogFont->lfCharSet != FontGDI->CharSet)
3174  {
3175  continue; /* charset mismatch */
3176  }
3177 
3178  /* get one info entry */
3179  FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
3180 
3181  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3182  {
3183  /* check name */
3184  if (_wcsnicmp(LogFont->lfFaceName,
3186  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
3187  _wcsnicmp(LogFont->lfFaceName,
3188  InfoEntry.EnumLogFontEx.elfFullName,
3189  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
3190  {
3191  continue;
3192  }
3193  }
3194 
3195  if (NominalName)
3196  {
3197  /* store the nominal name */
3199  sizeof(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
3200  NominalName);
3201  }
3202 
3203  /* store one entry to Info */
3204  if (0 <= Count && Count < MaxCount)
3205  {
3206  RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
3207  }
3208  Count++;
3209  }
3210 
3211  *pCount = Count;
3212 
3213  return TRUE;
3214 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2698
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:2969
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:2697
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 3217 of file freetype.c.

3221 {
3222  PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
3223  PFONTSUBST_ENTRY pCurrentEntry;
3224  PUNICODE_STRING pFromW, pToW;
3225  LOGFONTW lf = *LogFont;
3227 
3228  for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
3229  {
3230  pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
3231 
3232  pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
3233  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3234  {
3235  /* check name */
3236  if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
3237  continue; /* mismatch */
3238  }
3239 
3240  pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
3241  if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
3242  pCurrentEntry->CharSets[FONTSUBST_FROM] ==
3243  pCurrentEntry->CharSets[FONTSUBST_TO])
3244  {
3245  /* identical mapping */
3246  continue;
3247  }
3248 
3249  /* substitute and get the real name */
3250  IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
3251  SubstituteFontRecurse(&lf);
3252  if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
3253  continue;
3254 
3255  /* search in global fonts */
3257  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
3259 
3260  /* search in private fonts */
3261  IntLockProcessPrivateFonts(Win32Process);
3262  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
3263  &Win32Process->PrivateFontListHead);
3264  IntUnLockProcessPrivateFonts(Win32Process);
3265 
3266  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3267  {
3268  /* it's already matched to the exact name and charset if the name
3269  was specified at here, then so don't scan more for another name */
3270  break;
3271  }
3272  }
3273 
3274  return TRUE;
3275 }
static LIST_ENTRY g_FontListHead
Definition: freetype.c:66
#define FONTSUBST_FROM
Definition: font.h:43
#define TRUE
Definition: types.h:120
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:150
BYTE lfCharSet
Definition: dimm.idl:67
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define IntUnLockGlobalFonts()
Definition: freetype.c:73
struct TraceInfo Info
#define UNICODE_NULL
#define FONTSUBST_TO
Definition: font.h:44
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
static BOOL SubstituteFontRecurse(LOGFONTW *pLogFont)
Definition: freetype.c:904
BYTE CharSets[FONTSUBST_FROM_AND_TO]
Definition: font.h:54
Definition: typedefs.h:117
#define IntLockGlobalFonts()
Definition: freetype.c:70
static BOOLEAN FASTCALL GetFontFamilyInfoForList(const LOGFONTW *LogFont, PFONTFAMILYINFO Info, LPCWSTR NominalName, LONG *pCount, LONG MaxCount, PLIST_ENTRY Head)
Definition: freetype.c:3153
static VOID IntUnicodeStringToBuffer(LPWSTR pszBuffer, SIZE_T cbBuffer, const UNICODE_STRING *pString)
Definition: freetype.c:866
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
Definition: font.h:50
UNICODE_STRING FontNames[FONTSUBST_FROM_AND_TO]
Definition: font.h:53
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IntLockProcessPrivateFonts(W32Process)
Definition: text.h:147
LIST_ENTRY PrivateFontListHead
Definition: win32.h:275

Referenced by IntGetFontFamilyInfo().

◆ GetFontPenalty()

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

Definition at line 4842 of file freetype.c.

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