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

Go to the source code of this file.

Classes

struct  FONT_NAMES
 

Macros

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

Typedefs

typedef struct FONT_NAMES FONT_NAMES
 
typedef struct FONT_NAMESLPFONT_NAMES
 

Functions

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

Variables

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

Macro Definition Documentation

◆ _TMPF_VARIABLE_PITCH

#define _TMPF_VARIABLE_PITCH   TMPF_FIXED_PITCH

Definition at line 41 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_HELD

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

Definition at line 85 of file freetype.c.

◆ ASSERT_FREETYPE_LOCK_NOT_HELD

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

Definition at line 88 of file freetype.c.

◆ ASSERT_GLOBALFONTS_LOCK_HELD

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

Definition at line 76 of file freetype.c.

◆ CP_MACCP

#define CP_MACCP   2

Definition at line 167 of file freetype.c.

◆ CP_OEMCP

#define CP_OEMCP   1

Definition at line 166 of file freetype.c.

◆ CP_SYMBOL

#define CP_SYMBOL   42

Definition at line 122 of file freetype.c.

◆ EMUBOLD_NEEDED

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

Definition at line 45 of file freetype.c.

◆ FM_SEL_USE_TYPO_METRICS

#define FM_SEL_USE_TYPO_METRICS   0x80

◆ FT_INTERNAL_INTERNAL_H

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

Includes

Definition at line 28 of file freetype.c.

◆ gmxWorldToDeviceDefault

#define gmxWorldToDeviceDefault   gmxWorldToPageDefault

Definition at line 53 of file freetype.c.

◆ GOT_PENALTY

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

Definition at line 4700 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 1101 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 6663 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 2604 of file freetype.c.

2605 {
2606  /* FIXME: Add more and fix if wrong */
2607  switch (PRIMARYLANGID(LangID))
2608  {
2609  case LANG_CHINESE:
2610  switch (SUBLANGID(LangID))
2611  {
2613  return CHINESEBIG5_CHARSET;
2615  default:
2616  break;
2617  }
2618  return GB2312_CHARSET;
2619 
2620  case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
2621  case LANG_SLOVAK: case LANG_SLOVENIAN: case LANG_ROMANIAN:
2622  return EASTEUROPE_CHARSET;
2623 
2624  case LANG_RUSSIAN: case LANG_BULGARIAN: case LANG_MACEDONIAN:
2625  case LANG_SERBIAN: case LANG_UKRAINIAN:
2626  return RUSSIAN_CHARSET;
2627 
2628  case LANG_ARABIC: return ARABIC_CHARSET;
2629  case LANG_GREEK: return GREEK_CHARSET;
2630  case LANG_HEBREW: return HEBREW_CHARSET;
2631  case LANG_JAPANESE: return SHIFTJIS_CHARSET;
2632  case LANG_KOREAN: return JOHAB_CHARSET;
2633  case LANG_TURKISH: return TURKISH_CHARSET;
2634  case LANG_THAI: return THAI_CHARSET;
2635  case LANG_LATVIAN: return BALTIC_CHARSET;
2636  case LANG_VIETNAMESE: return VIETNAMESE_CHARSET;
2637 
2638  case LANG_ENGLISH: case LANG_BASQUE: case LANG_CATALAN:
2639  case LANG_DANISH: case LANG_DUTCH: case LANG_FINNISH:
2640  case LANG_FRENCH: case LANG_GERMAN: case LANG_ITALIAN:
2641  case LANG_NORWEGIAN: case LANG_PORTUGUESE: case LANG_SPANISH:
2642  case LANG_SWEDISH: default:
2643  return ANSI_CHARSET;
2644  }
2645 }
#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
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define BALTIC_CHARSET
Definition: wingdi.h:394
#define GREEK_CHARSET
Definition: wingdi.h:390
#define LANG_FINNISH
Definition: nls.h:57
#define LANG_SPANISH
Definition: nls.h:123
#define LANG_GREEK
Definition: nls.h:63
#define LANG_CATALAN
Definition: nls.h:41
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define SUBLANGID(l)
Definition: nls.h:17

Referenced by GetFontPenalty().

◆ CleanupFontEntry()

static __inline VOID FASTCALL CleanupFontEntry ( PFONT_ENTRY  FontEntry)
static

Definition at line 362 of file freetype.c.

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

Referenced by IntGdiCleanupMemEntry(), and IntGdiCleanupPrivateFontsForProcess().

◆ CleanupFontEntryEx()

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

Definition at line 342 of file freetype.c.

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

Referenced by CleanupFontEntry().

◆ DuplicateUnicodeString()

static NTSTATUS DuplicateUnicodeString ( PUNICODE_STRING  Source,
PUNICODE_STRING  Destination 
)
static

Definition at line 881 of file freetype.c.

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

Referenced by IntGdiAddFontResourceEx(), and IntGetFontLocalizedName().

◆ EqualFamilyInfo()

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

Definition at line 5358 of file freetype.c.

5359 {
5360  const ENUMLOGFONTEXW *pLog1 = &pInfo1->EnumLogFontEx;
5361  const ENUMLOGFONTEXW *pLog2 = &pInfo2->EnumLogFontEx;
5362  const LOGFONTW *plf1 = &pLog1->elfLogFont;
5363  const LOGFONTW *plf2 = &pLog2->elfLogFont;
5364 
5365  if (_wcsicmp(plf1->lfFaceName, plf2->lfFaceName) != 0)
5366  {
5367  return FALSE;
5368  }
5369 
5370  if (_wcsicmp(pLog1->elfStyle, pLog2->elfStyle) != 0)
5371  {
5372  return FALSE;
5373  }
5374 
5375  return TRUE;
5376 }
#define TRUE
Definition: types.h:120
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:2703
#define FALSE
Definition: types.h:117
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
LOGFONTW elfLogFont
Definition: wingdi.h:2701
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by IntGdiGetFontResourceInfo().

◆ face_has_symbol_charmap()

static BOOL face_has_symbol_charmap ( FT_Face  ft_face)
static

Definition at line 2140 of file freetype.c.

2141 {
2142  int i;
2143 
2144  for(i = 0; i < ft_face->num_charmaps; i++)
2145  {
2146  if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT &&
2147  ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
2148  {
2149  return TRUE;
2150  }
2151  }
2152  return FALSE;
2153 }
FT_CharMap * charmaps
Definition: freetype.h:1085
#define TRUE
Definition: types.h:120
#define TT_PLATFORM_MICROSOFT
Definition: font.c:1174
#define FALSE
Definition: types.h:117
FT_Encoding encoding
Definition: freetype.h:843
FT_Int num_charmaps
Definition: freetype.h:1084
FT_UShort platform_id
Definition: freetype.h:844
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

Referenced by FillTM(), and get_glyph_index().

◆ FillTM()

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

Definition at line 2156 of file freetype.c.

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

Referenced by ftGdiGetTextMetricsW(), and IntGetOutlineTextMetrics().

◆ FindBestFontFromList()

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

Definition at line 5050 of file freetype.c.

5053 {
5054  ULONG Penalty;
5056  PFONT_ENTRY CurrentEntry;
5057  FONTGDI *FontGDI;
5058  OUTLINETEXTMETRICW *Otm = NULL;
5059  UINT OtmSize, OldOtmSize = 0;
5060  FT_Face Face;
5061 
5062  ASSERT(FontObj);
5063  ASSERT(MatchPenalty);
5064  ASSERT(LogFont);
5065  ASSERT(Head);
5066 
5067  /* Start with a pretty big buffer */
5068  OldOtmSize = 0x200;
5069  Otm = ExAllocatePoolWithTag(PagedPool, OldOtmSize, GDITAG_TEXT);
5070 
5071  /* get the FontObj of lowest penalty */
5072  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
5073  {
5074  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
5075 
5076  FontGDI = CurrentEntry->Font;
5077  ASSERT(FontGDI);
5078  Face = FontGDI->SharedFace->Face;
5079 
5080  /* get text metrics */
5081  OtmSize = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
5082  if (OtmSize > OldOtmSize)
5083  {
5084  if (Otm)
5086  Otm = ExAllocatePoolWithTag(PagedPool, OtmSize, GDITAG_TEXT);
5087  }
5088 
5089  /* update FontObj if lowest penalty */
5090  if (Otm)
5091  {
5092  IntLockFreeType();
5093  IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight);
5095 
5096  OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm);
5097  if (!OtmSize)
5098  continue;
5099 
5100  OldOtmSize = OtmSize;
5101 
5102  Penalty = GetFontPenalty(LogFont, Otm, Face->style_name);
5103  if (*MatchPenalty == 0xFFFFFFFF || Penalty < *MatchPenalty)
5104  {
5105  *FontObj = GDIToObj(FontGDI, FONT);
5106  *MatchPenalty = Penalty;
5107  }
5108  }
5109  }
5110 
5111  if (Otm)
5113 }
struct _Entry Entry
Definition: kefuncs.h:627
LONG lfHeight
Definition: dimm.idl:59
static UINT GetFontPenalty(const LOGFONTW *LogFont, const OUTLINETEXTMETRICW *Otm, const char *style_name)
Definition: freetype.c:4704
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2457
LONG lfWidth
Definition: dimm.idl:60
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:121
#define ASSERT(a)
Definition: mode.c:44
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3505
#define IntUnLockFreeType()
Definition: freetype.c:82
FT_Face Face
Definition: engobjects.h:129
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IntLockFreeType()
Definition: freetype.c:79
Definition: typedefs.h:119
#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
#define NULL
Definition: types.h:112
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 2822 of file freetype.c.

2824 {
2825  ANSI_STRING StyleA;
2826  UNICODE_STRING StyleW;
2827  TT_OS2 *pOS2;
2828  FONTSIGNATURE fs;
2829  CHARSETINFO CharSetInfo;
2830  unsigned i, Size;
2831  OUTLINETEXTMETRICW *Otm;
2832  LOGFONTW *Lf;
2833  TEXTMETRICW *TM;
2834  NEWTEXTMETRICW *Ntm;
2835  DWORD fs0;
2836  NTSTATUS status;
2837  PSHARED_FACE SharedFace = FontGDI->SharedFace;
2838  FT_Face Face = SharedFace->Face;
2839  UNICODE_STRING NameW;
2840 
2841  RtlInitUnicodeString(&NameW, NULL);
2842  RtlZeroMemory(Info, sizeof(FONTFAMILYINFO));
2843  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
2845  if (!Otm)
2846  {
2847  return;
2848  }
2849  Size = IntGetOutlineTextMetrics(FontGDI, Size, Otm);
2850  if (!Size)
2851  {
2853  return;
2854  }
2855 
2856  Lf = &Info->EnumLogFontEx.elfLogFont;
2857  TM = &Otm->otmTextMetrics;
2858 
2859  Lf->lfHeight = TM->tmHeight;
2860  Lf->lfWidth = TM->tmAveCharWidth;
2861  Lf->lfWeight = TM->tmWeight;
2862  Lf->lfItalic = TM->tmItalic;
2863  Lf->lfPitchAndFamily = (TM->tmPitchAndFamily & 0xf1) + 1;
2864  Lf->lfCharSet = TM->tmCharSet;
2867  Lf->lfQuality = PROOF_QUALITY;
2868 
2869  Ntm = &Info->NewTextMetricEx.ntmTm;
2870  Ntm->tmHeight = TM->tmHeight;
2871  Ntm->tmAscent = TM->tmAscent;
2872  Ntm->tmDescent = TM->tmDescent;
2875  Ntm->tmAveCharWidth = TM->tmAveCharWidth;
2876  Ntm->tmMaxCharWidth = TM->tmMaxCharWidth;
2877  Ntm->tmWeight = TM->tmWeight;
2878  Ntm->tmOverhang = TM->tmOverhang;
2881  Ntm->tmFirstChar = TM->tmFirstChar;
2882  Ntm->tmLastChar = TM->tmLastChar;
2883  Ntm->tmDefaultChar = TM->tmDefaultChar;
2884  Ntm->tmBreakChar = TM->tmBreakChar;
2885  Ntm->tmItalic = TM->tmItalic;
2886  Ntm->tmUnderlined = TM->tmUnderlined;
2887  Ntm->tmStruckOut = TM->tmStruckOut;
2889  Ntm->tmCharSet = TM->tmCharSet;
2890  Ntm->ntmFlags = TM->tmItalic ? NTM_ITALIC : 0;
2891 
2892  if (550 < TM->tmWeight) Ntm->ntmFlags |= NTM_BOLD;
2893 
2894  if (0 == Ntm->ntmFlags) Ntm->ntmFlags = NTM_REGULAR;
2895 
2896  Info->FontType = (0 != (TM->tmPitchAndFamily & TMPF_TRUETYPE)
2897  ? TRUETYPE_FONTTYPE : 0);
2898 
2899  if (0 == (TM->tmPitchAndFamily & TMPF_VECTOR))
2900  Info->FontType |= RASTER_FONTTYPE;
2901 
2902 
2903  /* face name */
2904  if (!FaceName)
2905  FaceName = (WCHAR*)((ULONG_PTR)Otm + (ULONG_PTR)Otm->otmpFamilyName);
2906 
2907  RtlStringCbCopyW(Lf->lfFaceName, sizeof(Lf->lfFaceName), FaceName);
2908 
2909  /* full name */
2910  if (!FullName)
2911  FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
2912 
2913  RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
2914  sizeof(Info->EnumLogFontEx.elfFullName),
2915  FullName);
2916 
2917  RtlInitAnsiString(&StyleA, Face->style_name);
2918  StyleW.Buffer = Info->EnumLogFontEx.elfStyle;
2919  StyleW.MaximumLength = sizeof(Info->EnumLogFontEx.elfStyle);
2920  status = RtlAnsiStringToUnicodeString(&StyleW, &StyleA, FALSE);
2921  if (!NT_SUCCESS(status))
2922  {
2924  return;
2925  }
2926  Info->EnumLogFontEx.elfScript[0] = UNICODE_NULL;
2927 
2928  IntLockFreeType();
2929  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
2930 
2931  if (!pOS2)
2932  {
2935  return;
2936  }
2937 
2938  Ntm->ntmSizeEM = Otm->otmEMSquare;
2939  Ntm->ntmCellHeight = (FT_Short)pOS2->usWinAscent + (FT_Short)pOS2->usWinDescent;
2940  Ntm->ntmAvgWidth = 0;
2941 
2943 
2944  fs.fsCsb[0] = pOS2->ulCodePageRange1;
2945  fs.fsCsb[1] = pOS2->ulCodePageRange2;
2946  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
2947  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
2948  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
2949  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
2950 
2951  if (0 == pOS2->version)
2952  {
2953  FT_UInt Dummy;
2954 
2955  if (FT_Get_First_Char(Face, &Dummy) < 0x100)
2956  fs.fsCsb[0] |= FS_LATIN1;
2957  else
2958  fs.fsCsb[0] |= FS_SYMBOL;
2959  }
2961 
2962  if (fs.fsCsb[0] == 0)
2963  {
2964  /* Let's see if we can find any interesting cmaps */
2965  for (i = 0; i < (UINT)Face->num_charmaps; i++)
2966  {
2967  switch (Face->charmaps[i]->encoding)
2968  {
2969  case FT_ENCODING_UNICODE:
2970  case FT_ENCODING_APPLE_ROMAN:
2971  fs.fsCsb[0] |= FS_LATIN1;
2972  break;
2973  case FT_ENCODING_MS_SYMBOL:
2974  fs.fsCsb[0] |= FS_SYMBOL;
2975  break;
2976  default:
2977  break;
2978  }
2979  }
2980  }
2981 
2982  for (i = 0; i < MAXTCIINDEX; i++)
2983  {
2984  fs0 = 1L << i;
2985  if (fs.fsCsb[0] & fs0)
2986  {
2987  if (!IntTranslateCharsetInfo(&fs0, &CharSetInfo, TCI_SRCFONTSIG))
2988  {
2989  CharSetInfo.ciCharset = DEFAULT_CHARSET;
2990  }
2991  if (DEFAULT_CHARSET != CharSetInfo.ciCharset)
2992  {
2993  if (g_ElfScripts[i])
2994  wcscpy(Info->EnumLogFontEx.elfScript, g_ElfScripts[i]);
2995  else
2996  {
2997  DPRINT1("Unknown elfscript for bit %u\n", i);
2998  }
2999  }
3000  }
3001  }
3002  Info->NewTextMetricEx.ntmFontSig = fs;
3003 }
WCHAR tmFirstChar
Definition: wingdi.h:2654
LONG tmMaxCharWidth
Definition: wingdi.h:2388
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
BYTE tmUnderlined
Definition: wingdi.h:2398
FT_CharMap * charmaps
Definition: freetype.h:1085
BYTE lfPitchAndFamily
Definition: dimm.idl:71
LONG tmExternalLeading
Definition: wingdi.h:2386
#define ft_sfnt_os2
Definition: tttables.h:631
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TCI_SRCFONTSIG
Definition: wingdi.h:962
LONG tmAveCharWidth
Definition: wingdi.h:2387
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
BYTE lfCharSet
Definition: dimm.idl:67
LONG tmDigitizedAspectX
Definition: wingdi.h:2652
BYTE lfClipPrecision
Definition: dimm.idl:69
WCHAR tmDefaultChar
Definition: wingdi.h:2656
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define NTM_BOLD
Definition: wingdi.h:1315
LONG tmDescent
Definition: wingdi.h:2384
LONG tmAscent
Definition: wingdi.h:2383
LONG tmInternalLeading
Definition: wingdi.h:2385
if(dx==0 &&dy==0)
Definition: linetemp.h:174
Definition: ffs.h:70
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define PROOF_QUALITY
Definition: wingdi.h:437
LONG tmDigitizedAspectY
Definition: wingdi.h:2653
#define MAXTCIINDEX
Definition: freetype.c:123
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:65
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define TMPF_TRUETYPE
Definition: wingdi.h:1312
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
FT_UShort usWinDescent
Definition: tttables.h:415
UINT ciCharset
Definition: wingdi.h:1545
BYTE tmPitchAndFamily
Definition: wingdi.h:2400
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2457
LONG lfWidth
Definition: dimm.idl:60
WCHAR tmBreakChar
Definition: wingdi.h:2396
FT_UShort version
Definition: tttables.h:382
BYTE tmStruckOut
Definition: wingdi.h:2399
BYTE lfOutPrecision
Definition: dimm.idl:68
LONG tmMaxCharWidth
Definition: wingdi.h:2649
#define OUT_OUTLINE_PRECIS
Definition: wingdi.h:422
#define fs
Definition: i386-dis.c:437
static BOOLEAN APIENTRY IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2093
__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:1648
WCHAR tmLastChar
Definition: wingdi.h:2655
BYTE tmPitchAndFamily
Definition: wingdi.h:2661
LONG tmOverhang
Definition: wingdi.h:2390
FT_Face Face
Definition: engobjects.h:129
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RASTER_FONTTYPE
Definition: wingdi.h:1106
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
FT_Encoding encoding
Definition: freetype.h:843
BYTE tmCharSet
Definition: wingdi.h:2401
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BYTE lfQuality
Definition: dimm.idl:70
#define NTM_REGULAR
Definition: wingdi.h:1316
static const WCHAR L[]
Definition: oid.c:1250
#define IntLockFreeType()
Definition: freetype.c:79
signed short FT_Short
Definition: fttypes.h:198
LONG tmInternalLeading
Definition: wingdi.h:2646
LONG tmDigitizedAspectY
Definition: wingdi.h:2392
LONG tmExternalLeading
Definition: wingdi.h:2647
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
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
UINT ntmCellHeight
Definition: wingdi.h:2665
PSHARED_FACE SharedFace
Definition: engobjects.h:142
WCHAR tmBreakChar
Definition: wingdi.h:2657
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
#define NULL
Definition: types.h:112
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2513
FT_UShort usWinAscent
Definition: tttables.h:414
WCHAR tmDefaultChar
Definition: wingdi.h:2395
FT_String * style_name
Definition: freetype.h:1079
FT_ULong ulCodePageRange2
Definition: tttables.h:420
#define DPRINT1
Definition: precomp.h:8
FT_ULong ulUnicodeRange3
Definition: tttables.h:403
#define FS_LATIN1
Definition: wingdi.h:559
LONG tmAveCharWidth
Definition: wingdi.h:2648
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG tmWeight
Definition: wingdi.h:2389
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
LONG tmHeight
Definition: wingdi.h:2382
LONG lfWeight
Definition: dimm.idl:63
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define NTM_ITALIC
Definition: wingdi.h:1314
static SERVICE_STATUS status
Definition: service.c:31
BYTE tmItalic
Definition: wingdi.h:2397
WCHAR tmFirstChar
Definition: wingdi.h:2393
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1108
FT_ULong ulUnicodeRange2
Definition: tttables.h:402
WCHAR tmLastChar
Definition: wingdi.h:2394
LONG tmDigitizedAspectX
Definition: wingdi.h:2391
Definition: ps.c:97

Referenced by GetFontFamilyInfoForList(), and IntGdiGetFontResourceInfo().

◆ FT_FixedFromFIXED()

static __inline FT_Fixed FT_FixedFromFIXED ( FIXED  f)
static

Definition at line 382 of file freetype.c.

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

Referenced by ftGdiGetGlyphOutline().

◆ ftGdiGetFontData()

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

Definition at line 4662 of file freetype.c.

4668 {
4670  FT_Face Face = FontGdi->SharedFace->Face;
4671 
4672  IntLockFreeType();
4673 
4674  if (FT_IS_SFNT(Face))
4675  {
4676  if (Table)
4677  Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
4678  (Table << 8 & 0xFF0000);
4679 
4680  if (!Buffer) Size = 0;
4681 
4682  if (Buffer && Size)
4683  {
4684  FT_Error Error;
4685  FT_ULong Needed = 0;
4686 
4687  Error = FT_Load_Sfnt_Table(Face, Table, Offset, NULL, &Needed);
4688 
4689  if ( !Error && Needed < Size) Size = Needed;
4690  }
4691  if (!FT_Load_Sfnt_Table(Face, Table, Offset, Buffer, &Size))
4692  Result = Size;
4693  }
4694 
4696 
4697  return Result;
4698 }
int FT_Error
Definition: fttypes.h:300
ASMGENDATA Table[]
Definition: genincdata.c:61
unsigned long FT_ULong
Definition: fttypes.h:253
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_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_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PSHARED_FACE SharedFace
Definition: engobjects.h:142
#define NULL
Definition: types.h:112
#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 3761 of file freetype.c.

3770 {
3771  PDC_ATTR pdcattr;
3772  PTEXTOBJ TextObj;
3773  PFONTGDI FontGDI;
3774  HFONT hFont = 0;
3775  GLYPHMETRICS gm;
3776  ULONG Size;
3777  FT_Face ft_face;
3778  FT_UInt glyph_index;
3779  DWORD width, height, pitch, needed = 0;
3780  FT_Bitmap ft_bitmap;
3781  FT_Error error;
3782  INT left, right, top = 0, bottom = 0;
3784  FLOATOBJ eM11, widthRatio, eTemp;
3785  FT_Matrix transMat = identityMat;
3786  BOOL needsTransform = FALSE;
3787  INT orientation;
3788  LONG aveWidth;
3789  INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */
3790  OUTLINETEXTMETRICW *potm;
3791  XFORMOBJ xo;
3792  XFORML xform;
3793  LOGFONTW *plf;
3794 
3795  DPRINT("%u, %08x, %p, %08lx, %p, %p\n", wch, iFormat, pgm,
3796  cjBuf, pvBuf, pmat2);
3797 
3798  pdcattr = dc->pdcattr;
3799 
3800  XFORMOBJ_vInit(&xo, &dc->pdcattr->mxWorldToDevice);
3801  XFORMOBJ_iGetXform(&xo, &xform);
3802  FLOATOBJ_SetFloat(&eM11, xform.eM11);
3803 
3804  hFont = pdcattr->hlfntNew;
3805  TextObj = RealizeFontInit(hFont);
3806 
3807  if (!TextObj)
3808  {
3810  return GDI_ERROR;
3811  }
3812  FontGDI = ObjToGDI(TextObj->Font, FONT);
3813  ft_face = FontGDI->SharedFace->Face;
3814 
3815  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
3816  aveWidth = FT_IS_SCALABLE(ft_face) ? abs(plf->lfWidth) : 0;
3817  orientation = FT_IS_SCALABLE(ft_face) ? plf->lfOrientation : 0;
3818 
3819  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
3821  if (!potm)
3822  {
3824  TEXTOBJ_UnlockText(TextObj);
3825  return GDI_ERROR;
3826  }
3827  Size = IntGetOutlineTextMetrics(FontGDI, Size, potm);
3828  if (!Size)
3829  {
3830  /* FIXME: last error? */
3832  TEXTOBJ_UnlockText(TextObj);
3833  return GDI_ERROR;
3834  }
3835 
3836  IntLockFreeType();
3837  TextIntUpdateSize(dc, TextObj, FontGDI, FALSE);
3839 
3840  TEXTOBJ_UnlockText(TextObj);
3841 
3842  glyph_index = get_glyph_index_flagged(ft_face, wch, GGO_GLYPH_INDEX, iFormat);
3844 
3845  if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2)
3846  load_flags |= FT_LOAD_NO_BITMAP;
3847 
3848  if (iFormat & GGO_UNHINTED)
3849  {
3850  load_flags |= FT_LOAD_NO_HINTING;
3851  iFormat &= ~GGO_UNHINTED;
3852  }
3853 
3854  error = FT_Load_Glyph(ft_face, glyph_index, load_flags);
3855  if (error)
3856  {
3857  DPRINT1("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
3859  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT);
3860  return GDI_ERROR;
3861  }
3863 
3864  FLOATOBJ_Set1(&widthRatio);
3865  if (aveWidth && potm)
3866  {
3867  // widthRatio = aveWidth * eM11 / potm->otmTextMetrics.tmAveCharWidth
3868  FLOATOBJ_SetLong(&widthRatio, aveWidth);
3869  FLOATOBJ_Mul(&widthRatio, &eM11);
3870  FLOATOBJ_DivLong(&widthRatio, potm->otmTextMetrics.tmAveCharWidth);
3871  }
3872 
3873  //left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
3874  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX);
3875  FLOATOBJ_Mul(&eTemp, &widthRatio);
3876  left = FLOATOBJ_GetLong(&eTemp) & -64;
3877 
3878  //right = (INT)((ft_face->glyph->metrics.horiBearingX +
3879  // ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
3880  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiBearingX * ft_face->glyph->metrics.width);
3881  FLOATOBJ_Mul(&eTemp, &widthRatio);
3882  FLOATOBJ_AddLong(&eTemp, 63);
3883  right = FLOATOBJ_GetLong(&eTemp) & -64;
3884 
3885  //adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
3886  FLOATOBJ_SetLong(&eTemp, ft_face->glyph->metrics.horiAdvance);
3887  FLOATOBJ_Mul(&eTemp, &widthRatio);
3888  FLOATOBJ_AddLong(&eTemp, 63);
3889  adv = FLOATOBJ_GetLong(&eTemp) >> 6;
3890 
3891  lsb = left >> 6;
3892  bbx = (right - left) >> 6;
3893 
3894  DPRINT("Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
3895 
3896  IntLockFreeType();
3897 
3898  /* Width scaling transform */
3899  if (!FLOATOBJ_Equal1(&widthRatio))
3900  {
3901  FT_Matrix scaleMat;
3902 
3903  eTemp = widthRatio;
3904  FLOATOBJ_MulLong(&eTemp, 1 << 16);
3905 
3906  scaleMat.xx = FLOATOBJ_GetLong(&eTemp);
3907  scaleMat.xy = 0;
3908  scaleMat.yx = 0;
3909  scaleMat.yy = INT_TO_FIXED(1);
3910  FT_Matrix_Multiply(&scaleMat, &transMat);
3911  needsTransform = TRUE;
3912  }
3913 
3914  /* World transform */
3915  {
3916  FT_Matrix ftmatrix;
3918 
3919  /* Create a freetype matrix, by converting to 16.16 fixpoint format */
3920  FtMatrixFromMx(&ftmatrix, pmx);
3921 
3922  if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
3923  {
3924  FT_Matrix_Multiply(&ftmatrix, &transMat);
3925  needsTransform = TRUE;
3926  }
3927  }
3928 
3929  /* Rotation transform */
3930  if (orientation)
3931  {
3932  FT_Matrix rotationMat;
3933  DPRINT("Rotation Trans!\n");
3934  IntEscapeMatrix(&rotationMat, orientation);
3935  FT_Matrix_Multiply(&rotationMat, &transMat);
3936  needsTransform = TRUE;
3937  }
3938 
3939  /* Extra transformation specified by caller */
3940  if (pmat2)
3941  {
3942  FT_Matrix extraMat;
3943  DPRINT("MAT2 Matrix Trans!\n");
3944  extraMat.xx = FT_FixedFromFIXED(pmat2->eM11);
3945  extraMat.xy = FT_FixedFromFIXED(pmat2->eM21);
3946  extraMat.yx = FT_FixedFromFIXED(pmat2->eM12);
3947  extraMat.yy = FT_FixedFromFIXED(pmat2->eM22);
3948  FT_Matrix_Multiply(&extraMat, &transMat);
3949  needsTransform = TRUE;
3950  }
3951 
3952  if (potm) ExFreePoolWithTag(potm, GDITAG_TEXT); /* It looks like we are finished with potm ATM. */
3953 
3954  if (!needsTransform)
3955  {
3956  DPRINT("No Need to be Transformed!\n");
3957  top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
3958  bottom = (ft_face->glyph->metrics.horiBearingY -
3959  ft_face->glyph->metrics.height) & -64;
3960  gm.gmCellIncX = adv;
3961  gm.gmCellIncY = 0;
3962  }
3963  else
3964  {
3965  INT xc, yc;
3966  FT_Vector vec;
3967  for (xc = 0; xc < 2; xc++)
3968  {
3969  for (yc = 0; yc < 2; yc++)
3970  {
3971  vec.x = (ft_face->glyph->metrics.horiBearingX +
3972  xc * ft_face->glyph->metrics.width);
3973  vec.y = ft_face->glyph->metrics.horiBearingY -
3974  yc * ft_face->glyph->metrics.height;
3975  DPRINT("Vec %ld,%ld\n", vec.x, vec.y);
3976  FT_Vector_Transform(&vec, &transMat);
3977  if (xc == 0 && yc == 0)
3978  {
3979  left = right = vec.x;
3980  top = bottom = vec.y;
3981  }
3982  else
3983  {
3984  if (vec.x < left) left = vec.x;
3985  else if (vec.x > right) right = vec.x;
3986  if (vec.y < bottom) bottom = vec.y;
3987  else if (vec.y > top) top = vec.y;
3988  }
3989  }
3990  }
3991  left = left & -64;
3992  right = (right + 63) & -64;
3993  bottom = bottom & -64;
3994  top = (top + 63) & -64;
3995 
3996  DPRINT("Transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
3997  vec.x = ft_face->glyph->metrics.horiAdvance;
3998  vec.y = 0;
3999  FT_Vector_Transform(&vec, &transMat);
4000  gm.gmCellIncX = (vec.x+63) >> 6;
4001  gm.gmCellIncY = -((vec.y+63) >> 6);
4002  }
4003  gm.gmBlackBoxX = (right - left) >> 6;
4004  gm.gmBlackBoxY = (top - bottom) >> 6;
4005  gm.gmptGlyphOrigin.x = left >> 6;
4006  gm.gmptGlyphOrigin.y = top >> 6;
4007 
4008  DPRINT("CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
4009  gm.gmCellIncX, gm.gmCellIncY,
4010  gm.gmBlackBoxX, gm.gmBlackBoxY,
4012 
4014 
4015 
4016  if (iFormat == GGO_METRICS)
4017  {
4018  DPRINT("GGO_METRICS Exit!\n");
4019  *pgm = gm;
4020  return 1; /* FIXME */
4021  }
4022 
4023  if (ft_face->glyph->format != ft_glyph_format_outline && iFormat != GGO_BITMAP)
4024  {
4025  DPRINT1("Loaded a bitmap\n");
4026  return GDI_ERROR;
4027  }
4028 
4029  switch (iFormat)
4030  {
4031  case GGO_BITMAP:
4032  {
4033  width = gm.gmBlackBoxX;
4034  height = gm.gmBlackBoxY;
4035  pitch = ((width + 31) >> 5) << 2;
4036  needed = pitch * height;
4037 
4038  if (!pvBuf || !cjBuf) break;
4039  if (!needed) return GDI_ERROR; /* empty glyph */
4040  if (needed > cjBuf)
4041  return GDI_ERROR;
4042 
4043  switch (ft_face->glyph->format)
4044  {
4046  {
4047  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4048  INT w = min( pitch, (ft_face->glyph->bitmap.width + 7) >> 3 );
4049  INT h = min( height, ft_face->glyph->bitmap.rows );
4050  while (h--)
4051  {
4052  RtlCopyMemory(dst, src, w);
4053  src += ft_face->glyph->bitmap.pitch;
4054  dst += pitch;
4055  }
4056  break;
4057  }
4058 
4060  {
4061  ft_bitmap.width = width;
4062  ft_bitmap.rows = height;
4063  ft_bitmap.pitch = pitch;
4064  ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
4065  ft_bitmap.buffer = pvBuf;
4066 
4067  IntLockFreeType();
4068  if (needsTransform)
4069  {
4070  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4071  }
4072  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4073  /* Note: FreeType will only set 'black' bits for us. */
4074  RtlZeroMemory(pvBuf, needed);
4075  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4077  break;
4078  }
4079 
4080  default:
4081  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4082  return GDI_ERROR;
4083  }
4084 
4085  break;
4086  }
4087 
4088  case GGO_GRAY2_BITMAP:
4089  case GGO_GRAY4_BITMAP:
4090  case GGO_GRAY8_BITMAP:
4091  {
4092  unsigned int mult, row, col;
4093  BYTE *start, *ptr;
4094 
4095  width = gm.gmBlackBoxX;
4096  height = gm.gmBlackBoxY;
4097  pitch = (width + 3) / 4 * 4;
4098  needed = pitch * height;
4099 
4100  if (!pvBuf || !cjBuf) break;
4101  if (!needed) return GDI_ERROR; /* empty glyph */
4102  if (needed > cjBuf)
4103  return GDI_ERROR;
4104 
4105  switch (ft_face->glyph->format)
4106  {
4108  {
4109  BYTE *src = ft_face->glyph->bitmap.buffer, *dst = pvBuf;
4110  INT h = min( height, ft_face->glyph->bitmap.rows );
4111  INT x;
4112  while (h--)
4113  {
4114  for (x = 0; (UINT)x < pitch; x++)
4115  {
4116  if (x < ft_face->glyph->bitmap.width)
4117  dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
4118  else
4119  dst[x] = 0;
4120  }
4121  src += ft_face->glyph->bitmap.pitch;
4122  dst += pitch;
4123  }
4124  break;
4125  }
4127  {
4128  ft_bitmap.width = width;
4129  ft_bitmap.rows = height;
4130  ft_bitmap.pitch = pitch;
4131  ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
4132  ft_bitmap.buffer = pvBuf;
4133 
4134  IntLockFreeType();
4135  if (needsTransform)
4136  {
4137  FT_Outline_Transform(&ft_face->glyph->outline, &transMat);
4138  }
4139  FT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
4140  RtlZeroMemory(ft_bitmap.buffer, cjBuf);
4141  FT_Outline_Get_Bitmap(g_FreeTypeLibrary, &ft_face->glyph->outline, &ft_bitmap);
4143 
4144  if (iFormat == GGO_GRAY2_BITMAP)
4145  mult = 4;
4146  else if (iFormat == GGO_GRAY4_BITMAP)
4147  mult = 16;
4148  else if (iFormat == GGO_GRAY8_BITMAP)
4149  mult = 64;
4150  else
4151  {
4152  return GDI_ERROR;
4153  }
4154 
4155  start = pvBuf;
4156  for (row = 0; row < height; row++)
4157  {
4158  ptr = start;
4159  for (col = 0; col < width; col++, ptr++)
4160  {
4161  *ptr = (((int)*ptr) * mult + 128) / 256;
4162  }
4163  start += pitch;
4164  }
4165 
4166  break;
4167  }
4168  default:
4169  DPRINT1("Loaded glyph format %x\n", ft_face->glyph->format);
4170  return GDI_ERROR;
4171  }
4172 
4173  break;
4174  }
4175 
4176  case GGO_NATIVE:
4177  {
4178  FT_Outline *outline = &ft_face->glyph->outline;
4179 
4180  if (cjBuf == 0) pvBuf = NULL; /* This is okay, need cjBuf to allocate. */
4181 
4182  IntLockFreeType();
4183  if (needsTransform && pvBuf) FT_Outline_Transform(outline, &transMat);
4184 
4186 
4187  if (!pvBuf || !cjBuf)
4188  {
4190  break;
4191  }
4192  if (needed > cjBuf)
4193  {
4195  return GDI_ERROR;
4196  }
4199  break;
4200  }
4201 
4202  case GGO_BEZIER:
4203  {
4204  FT_Outline *outline = &ft_face->glyph->outline;
4205  if (cjBuf == 0) pvBuf = NULL;
4206 
4207  if (needsTransform && pvBuf)
4208  {
4209  IntLockFreeType();
4210  FT_Outline_Transform(outline, &transMat);
4212  }
4214 
4215  if (!pvBuf || !cjBuf)
4216  break;
4217  if (needed > cjBuf)
4218  return GDI_ERROR;
4219 
4221  break;
4222  }
4223 
4224  default:
4225  DPRINT1("Unsupported format %u\n", iFormat);
4226  return GDI_ERROR;
4227  }
4228 
4229  DPRINT("ftGdiGetGlyphOutline END and needed %lu\n", needed);
4230 
4231  if (gm.gmBlackBoxX == 0)
4232  gm.gmBlackBoxX = 1;
4233  if (gm.gmBlackBoxY == 0)
4234  gm.gmBlackBoxY = 1;
4235 
4236  *pgm = gm;
4237  return needed;
4238 }
#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
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
#define TRUE
Definition: types.h:120
#define FLOATOBJ_Set1(fo)
Definition: floatobj.h:119
signed int FT_Int
Definition: fttypes.h:220
#define FLOATOBJ_DivLong(pf, l)
Definition: winddi.h:2829
FT_Glyph_Metrics metrics
Definition: freetype.h:1916
LONG tmAveCharWidth
Definition: wingdi.h:2387
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#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
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
unsigned char * buffer
Definition: ftimage.h:266
#define GGO_GRAY4_BITMAP
Definition: wingdi.h:852
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
short gmCellIncY
Definition: wingdi.h:2445
FT_Matrix_Multiply(const FT_Matrix *a, FT_Matrix *b)
Definition: ftcalc.c:661
FORCEINLINE VOID XFORMOBJ_vInit(OUT XFORMOBJ *pxo, IN MATRIX *pmx)
Definition: xformobj.h:21
#define FT_LOAD_DEFAULT
Definition: freetype.h:3008
int32_t INT
Definition: typedefs.h:58
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
#define FALSE
Definition: types.h:117
BOOL FASTCALL TextIntUpdateSize(PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:3623
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:343
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:2457
LONG lfWidth
Definition: dimm.idl:60
FT_Library g_FreeTypeLibrary
Definition: freetype.c:55
GLint GLint bottom
Definition: glext.h:7726
FIXED eM22
Definition: wingdi.h:2475
FIXED eM11
Definition: wingdi.h:2472
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
FIXED eM21
Definition: wingdi.h:2474
#define ft_glyph_format_outline
Definition: ftimage.h:732
#define ft_glyph_format_bitmap
Definition: ftimage.h:731
VOID FASTCALL FtMatrixFromMx(FT_Matrix *pmat, PMATRIX pmx)
Definition: freetype.c:752
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826
POINT gmptGlyphOrigin
Definition: wingdi.h:2443
FLOAT FLOATOBJ
Definition: winddi.h:677
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
static unsigned int get_native_glyph_outline(FT_Outline *outline, unsigned int buflen, char *buf)
Definition: freetype.c:3307
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:3380
#define IntLockFreeType()
Definition: freetype.c:79
FT_Outline outline
Definition: freetype.h:1927
static FT_UInt FASTCALL get_glyph_index_flagged(FT_Face face, FT_ULong code, DWORD indexed_flag, DWORD flags)
Definition: freetype.c:3741
FIXED eM12
Definition: wingdi.h:2473
GLenum src
Definition: glext.h:6340
FT_Bitmap bitmap
Definition: freetype.h:1923
LONG APIENTRY FLOATOBJ_GetLong(FLOATOBJ *pf)
Definition: floatobj.c:17
Definition: mesh.c:5329
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
unsigned char BYTE
Definition: xxhash.c:193
short gmCellIncX
Definition: wingdi.h:2444
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3467
FT_GlyphSlot glyph
Definition: freetype.h:1105
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
FT_Glyph_Format format
Definition: freetype.h:1921
FONTOBJ * Font
Definition: text.h:66
VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
Definition: freetype.c:739
FT_Vector_Transform(FT_Vector *vec, const FT_Matrix *matrix)
Definition: ftoutln.c:688
#define GDITAG_TEXT
Definition: tags.h:171
PSHARED_FACE SharedFace
Definition: engobjects.h:142
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
unsigned int FT_UInt
Definition: fttypes.h:231
GLuint start
Definition: gl.h:1545
FT_Fixed xy
Definition: fttypes.h:387
GLenum GLenum dst
Definition: glext.h:6340
UINT gmBlackBoxY
Definition: wingdi.h:2442
#define min(a, b)
Definition: monoChain.cc:55
#define GGO_GRAY2_BITMAP
Definition: wingdi.h:851
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2513
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
Definition: freetype.h:3017
int pitch
Definition: ftimage.h:265
#define DPRINT1
Definition: precomp.h:8
static const FT_Matrix identityMat
Definition: freetype.c:50
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:528
LOGFONTW elfLogFont
Definition: wingdi.h:2701
UINT gmBlackBoxX
Definition: wingdi.h:2441
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:105
static const WCHAR dc[]
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:135
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3012
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
FT_Fixed yx
Definition: fttypes.h:388
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2778
FT_Fixed yy
Definition: fttypes.h:388
#define DPRINT
Definition: sndvol32.h:71
#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
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
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 5679 of file freetype.c.

5682 {
5683  DWORD Count = 0;
5684  INT i = 0;
5685  FT_Face face = Font->SharedFace->Face;
5686 
5687  if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
5688  {
5689  FT_UInt previous_index = 0, glyph_index = 0;
5690  FT_ULong char_code, char_previous;
5691  FT_Vector delta;
5692 
5693  char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
5694 
5695  IntLockFreeType();
5696 
5697  while (glyph_index)
5698  {
5699  if (previous_index && glyph_index)
5700  {
5701  FT_Get_Kerning(face, previous_index, glyph_index, FT_KERNING_DEFAULT, &delta);
5702 
5703  if (pKerningPair && cPairs)
5704  {
5705  pKerningPair[i].wFirst = char_previous;
5706  pKerningPair[i].wSecond = char_code;
5707  pKerningPair[i].iKernAmount = delta.x;
5708  i++;
5709  if (i == cPairs) break;
5710  }
5711  Count++;
5712  }
5713  previous_index = glyph_index;
5714  char_previous = char_code;
5715  char_code = FT_Get_Next_Char(face, char_code, &glyph_index);
5716  }
5718  }
5719  return Count;
5720 }
FT_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning)
Definition: ftobjs.c:3347
unsigned long FT_ULong
Definition: fttypes.h:253
WORD wSecond
Definition: wingdi.h:2464
FT_Pos x
Definition: ftimage.h:76
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3722
int32_t INT
Definition: typedefs.h:58
#define FT_HAS_KERNING(face)
Definition: freetype.h:1297
int Count
Definition: noreturn.cpp:7
int iKernAmount
Definition: wingdi.h:2465
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
#define IntLockFreeType()
Definition: freetype.c:79
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
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 3132 of file freetype.c.

3133 {
3134  if ( lprs )
3135  {
3136  lprs->nSize = sizeof(RASTERIZER_STATUS);
3137  lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
3138  lprs->nLanguageID = gusLanguageID;
3139  return TRUE;
3140  }
3142  return FALSE;
3143 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define TRUE
Definition: types.h:120
struct _RASTERIZER_STATUS RASTERIZER_STATUS
#define FALSE
Definition: types.h:117
#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 4385 of file freetype.c.

4389 {
4390  PDC_ATTR pdcattr;
4391  UINT Ret = DEFAULT_CHARSET;
4392  INT i;
4393  HFONT hFont;
4394  PTEXTOBJ TextObj;
4395  PFONTGDI FontGdi;
4396  FONTSIGNATURE fs;
4397  TT_OS2 *pOS2;
4398  FT_Face Face;
4399  CHARSETINFO csi;
4400  DWORD cp, fs0;
4401  USHORT usACP, usOEM;
4402 
4403  pdcattr = Dc->pdcattr;
4404  hFont = pdcattr->hlfntNew;
4405  TextObj = RealizeFontInit(hFont);
4406 
4407  if (!TextObj)
4408  {
4410  return Ret;
4411  }
4412  FontGdi = ObjToGDI(TextObj->Font, FONT);
4413  Face = FontGdi->SharedFace->Face;
4414  TEXTOBJ_UnlockText(TextObj);
4415 
4416  memset(&fs, 0, sizeof(FONTSIGNATURE));
4417  IntLockFreeType();
4418  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4419  if (NULL != pOS2)
4420  {
4421  fs.fsCsb[0] = pOS2->ulCodePageRange1;
4422  fs.fsCsb[1] = pOS2->ulCodePageRange2;
4423  fs.fsUsb[0] = pOS2->ulUnicodeRange1;
4424  fs.fsUsb[1] = pOS2->ulUnicodeRange2;
4425  fs.fsUsb[2] = pOS2->ulUnicodeRange3;
4426  fs.fsUsb[3] = pOS2->ulUnicodeRange4;
4427  if (pOS2->version == 0)
4428  {
4429  FT_UInt dummy;
4430 
4431  if (FT_Get_First_Char( Face, &dummy ) < 0x100)
4432  fs.fsCsb[0] |= FS_LATIN1;
4433  else
4434  fs.fsCsb[0] |= FS_SYMBOL;
4435  }
4436  }
4437  pOS2 = NULL;
4439  DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
4440  if (fs.fsCsb[0] == 0)
4441  { /* Let's see if we can find any interesting cmaps */
4442  for (i = 0; i < Face->num_charmaps; i++)
4443  {
4444  switch (Face->charmaps[i]->encoding)
4445  {
4446  case FT_ENCODING_UNICODE:
4447  case FT_ENCODING_APPLE_ROMAN:
4448  fs.fsCsb[0] |= FS_LATIN1;
4449  break;
4450  case FT_ENCODING_MS_SYMBOL:
4451  fs.fsCsb[0] |= FS_SYMBOL;
4452  break;
4453  default:
4454  break;
4455  }
4456  }
4457  }
4458  if (lpSig)
4459  {
4460  RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE));
4461  }
4462 
4463  RtlGetDefaultCodePage(&usACP, &usOEM);
4464  cp = usACP;
4465 
4467  if (csi.fs.fsCsb[0] & fs.fsCsb[0])
4468  {
4469  DPRINT("Hit 1\n");
4470  Ret = csi.ciCharset;
4471  goto Exit;
4472  }
4473 
4474  for (i = 0; i < MAXTCIINDEX; i++)
4475  {
4476  fs0 = 1L << i;
4477  if (fs.fsCsb[0] & fs0)
4478  {
4479  if (IntTranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG))
4480  {
4481  // *cp = csi.ciACP;
4482  DPRINT("Hit 2\n");
4483  Ret = csi.ciCharset;
4484  goto Exit;
4485  }
4486  else
4487  DPRINT1("TCI failing on %x\n", fs0);
4488  }
4489  }
4490 Exit:
4491  DPRINT("CharSet %u CodePage %u\n", csi.ciCharset, csi.ciACP);
4492  return (MAKELONG(csi.ciACP, csi.ciCharset));
4493 }
FONTSIGNATURE fs
Definition: wingdi.h:1547
FT_CharMap * charmaps
Definition: freetype.h:1085
#define ft_sfnt_os2
Definition: tttables.h:631
#define TCI_SRCFONTSIG
Definition: wingdi.h:962
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
Definition: ffs.h:70
#define DEFAULT_CHARSET
Definition: wingdi.h:383
int32_t INT
Definition: typedefs.h:58
#define MAXTCIINDEX
Definition: freetype.c:123
HFONT hFont
Definition: main.c:53
FT_ULong ulUnicodeRange1
Definition: tttables.h:401
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:343
FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag)
Definition: ftobjs.c:4113
UINT ciCharset
Definition: wingdi.h:1545
#define MAKELONG(a, b)
Definition: typedefs.h:249
FT_UShort version
Definition: tttables.h:382
NTSYSAPI VOID NTAPI RtlGetDefaultCodePage(_Out_ PUSHORT AnsiCodePage, _Out_ PUSHORT OemCodePage)
#define fs
Definition: i386-dis.c:437
static BOOLEAN APIENTRY IntTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO Cs, DWORD Flags)
Definition: freetype.c:2093
#define FS_SYMBOL
Definition: wingdi.h:574
static void Exit(void)
Definition: sock.c:1331
#define IntUnLockFreeType()
Definition: freetype.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
FT_Face Face
Definition: engobjects.h:129
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3697
FT_Encoding encoding
Definition: freetype.h:843
static const WCHAR L[]
Definition: oid.c:1250
#define IntLockFreeType()
Definition: freetype.c:79
FT_Int num_charmaps
Definition: freetype.h:1084
FONTOBJ * Font
Definition: text.h:66
DWORD fsCsb[2]
Definition: wingdi.h:1542
FT_ULong ulCodePageRange1
Definition: tttables.h:419
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
PSHARED_FACE SharedFace
Definition: engobjects.h:142
unsigned short USHORT
Definition: pedump.c:61
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
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
#define NULL
Definition: types.h:112
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 RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define DPRINT
Definition: sndvol32.h:71
#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 4566 of file freetype.c.

4569 {
4570  PDC dc;
4571  PDC_ATTR pdcattr;
4572  PTEXTOBJ TextObj;
4573  PFONTGDI FontGDI;
4574  FT_Face Face;
4575  TT_OS2 *pOS2;
4576  TT_HoriHeader *pHori;
4577  FT_WinFNT_HeaderRec Win;
4578  ULONG Error;
4580  LOGFONTW *plf;
4581 
4582  if (!ptmwi)
4583  {
4585  return FALSE;
4586  }
4587  RtlZeroMemory(ptmwi, sizeof(TMW_INTERNAL));
4588 
4589  if (!(dc = DC_LockDc(hDC)))
4590  {
4592  return FALSE;
4593  }
4594  pdcattr = dc->pdcattr;
4595  TextObj = RealizeFontInit(pdcattr->hlfntNew);
4596  if (NULL != TextObj)
4597  {
4598  plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
4599  FontGDI = ObjToGDI(TextObj->Font, FONT);
4600 
4601  Face = FontGDI->SharedFace->Face;
4602 
4603  IntLockFreeType();
4604  Error = IntRequestFontSize(dc, FontGDI, plf->lfWidth, plf->lfHeight);
4607 
4608  if (0 != Error)
4609  {
4610  DPRINT1("Error in setting pixel sizes: %u\n", Error);
4612  }
4613  else
4614  {
4615  FT_Face Face = FontGDI->SharedFace->Face;
4617 
4618  IntLockFreeType();
4619  pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
4620  if (NULL == pOS2)
4621  {
4622  DPRINT1("Can't find OS/2 table - not TT font?\n");
4624  }
4625 
4626  pHori = FT_Get_Sfnt_Table(Face, ft_sfnt_hhea);
4627  if (NULL == pHori)
4628  {
4629  DPRINT1("Can't find HHEA table - not TT font?\n");
4631  }
4632 
4633  Error = FT_Get_WinFNT_Header(Face, &Win);
4634 
4635  if (NT_SUCCESS(Status) || !Error)
4636  {
4637  FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0);
4638 
4639  /* FIXME: Fill Diff member */
4640  }
4641 
4643  }
4644  TEXTOBJ_UnlockText(TextObj);
4645  }
4646  else
4647  {
4649  }
4650  DC_UnlockDc(dc);
4651 
4652  if (!NT_SUCCESS(Status))
4653  {
4655  return FALSE;
4656  }
4657  return TRUE;
4658 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
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
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LONG lfHeight
Definition: dimm.idl:59
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define FALSE
Definition: types.h:117
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:343
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:2156
LONG lfWidth
Definition: dimm.idl:60
#define ft_sfnt_hhea
Definition: tttables.h:632
Status
Definition: gdiplustypes.h:24
Definition: polytest.cpp:40
static FT_Error IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
Definition: freetype.c:3505
#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
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 NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
LOGFONTW elfLogFont
Definition: wingdi.h:2701
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
static const WCHAR dc[]
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:135
#define STATUS_SUCCESS
Definition: shellext.h:65
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2778
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 3158 of file freetype.c.

3164 {
3165  PLIST_ENTRY CurrentEntry;
3166  PFONT_CACHE_ENTRY FontEntry;
3167 
3169 
3170  for (CurrentEntry = g_FontCacheListHead.Flink;
3171  CurrentEntry != &g_FontCacheListHead;
3172  CurrentEntry = CurrentEntry->Flink)
3173  {
3174  FontEntry = CONTAINING_RECORD(CurrentEntry, FONT_CACHE_ENTRY, ListEntry);
3175  if ((FontEntry->Face == Face) &&
3176  (FontEntry->GlyphIndex == GlyphIndex) &&
3177  (FontEntry->Height == Height) &&
3178  (FontEntry->RenderMode == RenderMode) &&
3179  (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx)))
3180  break;
3181  }
3182 
3183  if (CurrentEntry == &g_FontCacheListHead)
3184  {
3185  return NULL;
3186  }
3187 
3188  RemoveEntryList(CurrentEntry);
3189  InsertHeadList(&g_FontCacheListHead, CurrentEntry);
3190  return FontEntry->BitmapGlyph;
3191 }
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
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:121
static BOOL SameScaleMatrix(PMATRIX pmx1, PMATRIX pmx2)
Definition: freetype.c:3147
int Height
Definition: font.h:32
static LIST_ENTRY g_FontCacheListHead
Definition: freetype.c:93
Definition: font.h:26
Definition: typedefs.h:119
FT_Render_Mode RenderMode
Definition: font.h:35
#define NULL
Definition: types.h:112

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

3243 {
3244  FT_Glyph GlyphCopy;
3245  INT error;
3246  PFONT_CACHE_ENTRY NewEntry;
3247  FT_Bitmap AlignedBitmap;
3248  FT_BitmapGlyph BitmapGlyph;
3249 
3251 
3252  error = FT_Get_Glyph(GlyphSlot, &GlyphCopy);
3253  if (error)
3254  {
3255  DPRINT1("Failure caching glyph.\n");
3256  return NULL;
3257  };
3258 
3259  error = FT_Glyph_To_Bitmap(&GlyphCopy, RenderMode, 0, 1);
3260  if (error)
3261  {
3262  FT_Done_Glyph(GlyphCopy);
3263  DPRINT1("Failure rendering glyph.\n");
3264  return NULL;
3265  };
3266 
3268  if (!NewEntry)
3269  {
3270  DPRINT1("Alloc failure caching glyph.\n");
3271  FT_Done_Glyph(GlyphCopy);
3272  return NULL;
3273  }
3274 
3275  BitmapGlyph = (FT_BitmapGlyph)GlyphCopy;
3276  FT_Bitmap_New(&AlignedBitmap);
3277  if(FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3278  {
3279  DPRINT1("Conversion failed\n");
3280  ExFreePoolWithTag(NewEntry, TAG_FONT);
3281  FT_Bitmap_Done(GlyphSlot->library, &AlignedBitmap);
3282  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3283  return NULL;
3284  }
3285 
3286  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3287  BitmapGlyph->bitmap = AlignedBitmap;
3288 
3289  NewEntry->GlyphIndex = GlyphIndex;
3290  NewEntry->Face = Face;
3291  NewEntry->BitmapGlyph = BitmapGlyph;
3292  NewEntry->Height = Height;
3293  NewEntry->RenderMode = RenderMode;
3294  NewEntry->mxWorldToDevice = *pmx;
3295 
3298  {
3300  RemoveCachedEntry(NewEntry);
3301  }
3302 
3303  return BitmapGlyph;
3304 }
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:122
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:58
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
#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 NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by IntExtTextOutW(), and TextIntGetTextExtentPoint().

◆ ftGdiGlyphSet()

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

Definition at line 3195 of file freetype.c.

3199 {
3200  FT_Glyph Glyph;
3201  INT error;
3202  FT_Bitmap AlignedBitmap;
3203  FT_BitmapGlyph BitmapGlyph;
3204 
3205  error = FT_Get_Glyph(GlyphSlot, &Glyph);
3206  if (error)
3207  {
3208  DPRINT1("Failure getting glyph.\n");
3209  return NULL;
3210  }
3211 
3212  error = FT_Glyph_To_Bitmap(&Glyph, RenderMode, 0, 1);
3213  if (error)
3214  {
3215  FT_Done_Glyph(Glyph);
3216  DPRINT1("Failure rendering glyph.\n");
3217  return NULL;
3218  }
3219 
3220  BitmapGlyph = (FT_BitmapGlyph)Glyph;
3221  FT_Bitmap_New(&AlignedBitmap);
3222  if (FT_Bitmap_Convert(GlyphSlot->library, &BitmapGlyph->bitmap, &AlignedBitmap, 4))
3223  {
3224  DPRINT1("Conversion failed\n");
3225  FT_Done_Glyph((FT_Glyph)BitmapGlyph);
3226  return NULL;
3227  }
3228 
3229  FT_Bitmap_Done(GlyphSlot->library, &BitmapGlyph->bitmap);
3230  BitmapGlyph->bitmap = AlignedBitmap;
3231 
3232  return BitmapGlyph;
3233 }
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:58
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
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 NULL
Definition: types.h:112
#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 5660 of file freetype.c.

5661 {
5662  if (FT_HAS_FIXED_SIZES(Font->SharedFace->Face))
5663  Info->iTechnology = RI_TECH_BITMAP;
5664  else
5665  {
5666  if (FT_IS_SCALABLE(Font->SharedFace->Face))
5667  Info->iTechnology = RI_TECH_SCALABLE;
5668  else
5669  Info->iTechnology = RI_TECH_FIXED;
5670  }
5671  Info->iUniq = Font->FontObj.iUniq;
5672  Info->dwUnknown = -1;
5673  return TRUE;
5674 }
#define RI_TECH_BITMAP
Definition: ntgdityp.h:271
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define RI_TECH_SCALABLE
Definition: ntgdityp.h:273
#define FT_HAS_FIXED_SIZES(face)
Definition: freetype.h:1361
#define RI_TECH_FIXED
Definition: ntgdityp.h:272
#define FT_IS_SCALABLE(face)
Definition: freetype.h:1312

Referenced by NtGdiGetRealizationInfo().

◆ ftGetFontUnicodeRanges()

DWORD FASTCALL ftGetFontUnicodeRanges ( PFONTGDI  Font,
PGLYPHSET  glyphset 
)

Definition at line 4498 of file freetype.c.

4499 {
4500  DWORD size = 0;
4501  DWORD num_ranges = 0;
4502  FT_Face face = Font->SharedFace->Face;
4503 
4504  if (face->charmap->encoding == FT_ENCODING_UNICODE)
4505  {
4506  FT_UInt glyph_code = 0;
4507  FT_ULong char_code, char_code_prev;
4508 
4509  char_code_prev = char_code = FT_Get_First_Char(face, &glyph_code);
4510 
4511  DPRINT("Face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
4512  face->num_glyphs, glyph_code, char_code);
4513 
4514  if (!glyph_code) return 0;
4515 
4516  if (glyphset)
4517  {
4518  glyphset->ranges[0].wcLow = (USHORT)char_code;
4519  glyphset->ranges[0].cGlyphs = 0;
4520  glyphset->cGlyphsSupported = 0;
4521  }
4522 
4523  num_ranges = 1;
4524  while (glyph_code)
4525  {
4526  if (char_code < char_code_prev)
4527  {
4528  DPRINT1("Expected increasing char code from FT_Get_Next_Char\n");
4529  return 0;
4530  }
4531  if (char_code - char_code_prev > 1)
4532  {
4533  num_ranges++;
4534  if (glyphset)
4535  {
4536  glyphset->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
4537  glyphset->ranges[num_ranges - 1].cGlyphs = 1;
4538  glyphset->cGlyphsSupported++;
4539  }
4540  }
4541  else if (glyphset)
4542  {
4543  glyphset->ranges[num_ranges - 1].cGlyphs++;
4544  glyphset->cGlyphsSupported++;
4545  }
4546  char_code_prev = char_code;
4547  char_code = FT_Get_Next_Char(face, char_code, &glyph_code);
4548  }
4549  }
4550  else
4551  DPRINT1("Encoding %i not supported\n", face->charmap->encoding);
4552 
4553  size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
4554  if (glyphset)
4555  {
4556  glyphset->cbThis = size;
4557  glyphset->cRanges = num_ranges;
4558  glyphset->flAccel = 0;
4559  }
4560  return size;
4561 }
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
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
#define DPRINT
Definition: sndvol32.h:71
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by NtGdiGetFontUnicodeRanges().

◆ FtMatrixFromMx()

VOID FASTCALL FtMatrixFromMx ( FT_Matrix pmat,
PMATRIX  pmx 
)

Definition at line 752 of file freetype.c.

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

Referenced by ftGdiGetGlyphOutline().

◆ FtSetCoordinateTransform()

VOID FtSetCoordinateTransform ( FT_Face  face,
PMATRIX  pmx 
)

Definition at line 775 of file freetype.c.

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

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

◆ FTVectorToPOINTFX()

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

Definition at line 368 of file freetype.c.

369 {
370  pt->x.value = vec->x >> 6;
371  pt->x.fract = (vec->x & 0x3f) << 10;
372  pt->x.fract |= ((pt->x.fract >> 6) | (pt->x.fract >> 12));
373  pt->y.value = vec->y >> 6;
374  pt->y.fract = (vec->y & 0x3f) << 10;
375  pt->y.fract |= ((pt->y.fract >> 6) | (pt->y.fract >> 12));
376 }
FT_Pos y
Definition: ftimage.h:77
FT_Pos x
Definition: ftimage.h:76
#define pt(x, y)
Definition: drawing.c:79
FT_Vector * vec
Definition: ftbbox.c:448
char * value
Definition: compiler.c:67

Referenced by get_bezier_glyph_outline(), and get_native_glyph_outline().

◆ get_bezier_glyph_outline()

static unsigned int get_bezier_glyph_outline ( FT_Outline outline,
unsigned int  buflen,
char buf 
)
static

Definition at line 3380 of file freetype.c.

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

3727 {
3728  FT_UInt ret;
3729 
3730  if (face_has_symbol_charmap(ft_face))
3731  {
3732  ret = get_glyph_index_symbol(ft_face, glyph);
3733  if (ret != 0)
3734  return ret;
3735  }
3736 
3737  return FT_Get_Char_Index(ft_face, glyph);
3738 }
static BOOL face_has_symbol_charmap(FT_Face ft_face)
Definition: freetype.c:2140
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:3712
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 3741 of file freetype.c.

3742 {
3743  FT_UInt glyph_index;
3744  if (flags & indexed_flag)
3745  {
3746  glyph_index = code;
3747  }
3748  else
3749  {
3750  glyph_index = get_glyph_index(face, code);
3751  }
3752  return glyph_index;
3753 }
static FT_UInt FASTCALL get_glyph_index(FT_Face ft_face, UINT glyph)
Definition: freetype.c:3726
GLbitfield flags
Definition: glext.h:7161
Definition: inflate.c:139
int code
Definition: main.c:75
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 3712 of file freetype.c.

3713 {
3714  FT_UInt ret;
3715 
3716  if (glyph < 0x100) glyph += 0xf000;
3717  /* there are a number of old pre-Unicode "broken" TTFs, which
3718  do have symbols at U+00XX instead of U+f0XX */
3719  if (!(ret = FT_Get_Char_Index(ft_face, glyph)))
3720  ret = FT_Get_Char_Index(ft_face, glyph - 0xf000);
3721 
3722  return ret;
3723 }
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 3307 of file freetype.c.

3308 {
3309  TTPOLYGONHEADER *pph;
3310  TTPOLYCURVE *ppc;
3311  int needed = 0, point = 0, contour, first_pt;
3312  unsigned int pph_start, cpfx;
3313  DWORD type;
3314 
3315  for (contour = 0; contour < outline->n_contours; contour++)
3316  {
3317  /* Ignore contours containing one point */
3318  if (point == outline->contours[contour])
3319  {
3320  point++;
3321  continue;
3322  }
3323 
3324  pph_start = needed;
3325  pph = (TTPOLYGONHEADER *)(buf + needed);
3326  first_pt = point;
3327  if (buf)
3328  {
3329  pph->dwType = TT_POLYGON_TYPE;
3330  FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
3331  }
3332  needed += sizeof(*pph);
3333  point++;
3334  while (point <= outline->contours[contour])
3335  {
3336  ppc = (TTPOLYCURVE *)(buf + needed);
3337  type = (outline->tags[point] & FT_Curve_Tag_On) ?
3339  cpfx = 0;
3340  do
3341  {
3342  if (buf)
3343  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3344  cpfx++;
3345  point++;
3346  } while (point <= outline->contours[contour] &&
3347  (outline->tags[point] & FT_Curve_Tag_On) ==
3348  (outline->tags[point-1] & FT_Curve_Tag_On));
3349  /* At the end of a contour Windows adds the start point, but
3350  only for Beziers */
3351  if (point > outline->contours[contour] &&
3352  !(outline->tags[point-1] & FT_Curve_Tag_On))
3353  {
3354  if (buf)
3355  FTVectorToPOINTFX(&outline->points[first_pt], &ppc->apfx[cpfx]);
3356  cpfx++;
3357  }
3358  else if (point <= outline->contours[contour] &&
3359  outline->tags[point] & FT_Curve_Tag_On)
3360  {
3361  /* add closing pt for bezier */
3362  if (buf)
3363  FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
3364  cpfx++;
3365  point++;
3366  }
3367  if (buf)
3368  {
3369  ppc->wType = type;
3370  ppc->cpfx = cpfx;
3371  }
3372  needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
3373  }
3374  if (buf)
3375  pph->cb = needed - pph_start;
3376  }
3377  return needed;
3378 }
#define FT_Curve_Tag_On
Definition: ftimage.h:465
#define TT_POLYGON_TYPE
Definition: wingdi.h:1317
static __inline void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
Definition: freetype.c:368
POINTL point
Definition: edittest.c:50
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TT_PRIM_QSPLINE
Definition: wingdi.h:1319
POINTFX apfx[1]
Definition: wingdi.h:2713
unsigned long DWORD
Definition: ntddk_ex.h:95
POINTFX pfxStart
Definition: wingdi.h:2718
Definition: mesh.c:5329
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#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 3006 of file freetype.c.

3012 {
3014  PFONT_ENTRY CurrentEntry;
3015  FONTGDI *FontGDI;
3016  FONTFAMILYINFO InfoEntry;
3017  LONG Count = *pCount;
3018 
3019  for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
3020  {
3021  CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
3022  FontGDI = CurrentEntry->Font;
3023  ASSERT(FontGDI);
3024 
3025  if (LogFont->lfCharSet != DEFAULT_CHARSET &&
3026  LogFont->lfCharSet != FontGDI->CharSet)
3027  {
3028  continue; /* charset mismatch */
3029  }
3030 
3031  /* get one info entry */
3032  FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
3033 
3034  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3035  {
3036  /* check name */
3037  if (_wcsnicmp(LogFont->lfFaceName,
3039  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
3040  _wcsnicmp(LogFont->lfFaceName,
3041  InfoEntry.EnumLogFontEx.elfFullName,
3042  RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
3043  {
3044  continue;
3045  }
3046  }
3047 
3048  if (NominalName)
3049  {
3050  /* store the nominal name */
3052  sizeof(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
3053  NominalName);
3054  }
3055 
3056  /* store one entry to Info */
3057  if (0 <= Count && Count < MaxCount)
3058  {
3059  RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
3060  }
3061  Count++;
3062  }
3063 
3064  *pCount = Count;
3065 
3066  return TRUE;
3067 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2702
struct _Entry Entry
Definition: kefuncs.h:627
#define TRUE
Definition: types.h:120
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)
#define DEFAULT_CHARSET
Definition: wingdi.h:383
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
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:2822
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
int Count
Definition: noreturn.cpp:7
#define ASSERT(a)
Definition: mode.c:44
Definition: typedefs.h:119
ENUMLOGFONTEXW EnumLogFontEx
Definition: ntgdibad.h:47
FONTGDI * Font
Definition: font.h:7
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define NULL
Definition: types.h:112
LOGFONTW elfLogFont
Definition: wingdi.h:2701
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
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 3070 of file freetype.c.

3074 {
3075  PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
3076  PFONTSUBST_ENTRY pCurrentEntry;
3077  PUNICODE_STRING pFromW, pToW;
3078  LOGFONTW lf = *LogFont;
3080 
3081  for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
3082  {
3083  pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
3084 
3085  pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
3086  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3087  {
3088  /* check name */
3089  if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
3090  continue; /* mismatch */
3091  }
3092 
3093  pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
3094  if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
3095  pCurrentEntry->CharSets[FONTSUBST_FROM] ==
3096  pCurrentEntry->CharSets[FONTSUBST_TO])
3097  {
3098  /* identical mapping */
3099  continue;
3100  }
3101 
3102  /* substitute and get the real name */
3103  IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
3104  SubstituteFontRecurse(&lf);
3105  if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
3106  continue;
3107 
3108  /* search in global fonts */
3110  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
3112 
3113  /* search in private fonts */
3114  IntLockProcessPrivateFonts(Win32Process);
3115  GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
3116  &Win32Process->PrivateFontListHead);
3117  IntUnLockProcessPrivateFonts(Win32Process);
3118 
3119  if (LogFont->lfFaceName[0] != UNICODE_NULL)
3120  {
3121  /* it's already matched to the exact name and charset if the name
3122  was specified at here, then so don't scan more for another name */
3123  break;
3124  }
3125  }
3126 
3127  return TRUE;
3128 }
static LIST_ENTRY g_FontListHead
Definition: freetype.c:66
#define FONTSUBST_FROM
Definition: font.h:43
#define IntLockProcessPrivateFonts(W32Process)
Definition: text.h:147
#define TRUE
Definition: types.h:120
BYTE lfCharSet
Definition: dimm.idl:67
#define IntUnLockProcessPrivateFonts(W32Process)
Definition: text.h:150
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define IntUnLockGlobalFonts()
Definition: freetype.c:73
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#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:121
static BOOL SubstituteFontRecurse(LOGFONTW *pLogFont)
Definition: freetype.c:904
BYTE CharSets[FONTSUBST_FROM_AND_TO]
Definition: font.h:54
Definition: typedefs.h:119
#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:3006
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
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
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)
LIST_ENTRY PrivateFontListHead
Definition: win32.h:282

Referenced by IntGetFontFamilyInfo().

◆ GetFontPenalty()

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

Definition at line 4704 of file freetype.c.

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