16#include FT_TYPE1_TABLES_H
17#include FT_TRUETYPE_TABLES_H
18#include FT_TRUETYPE_TAGS_H
19#include FT_TRIGONOMETRY_H
23#include FT_SFNT_NAMES_H
24#include FT_SYNTHESIS_H
25#include FT_TRUETYPE_IDS_H
27#ifndef FT_INTERNAL_INTERNAL_H
28 #define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h>
29 #include FT_INTERNAL_INTERNAL_H
31#include FT_INTERNAL_TRUETYPE_TYPES_H
40#ifndef _TMPF_VARIABLE_PITCH
41 #define _TMPF_VARIABLE_PITCH TMPF_FIXED_PITCH
45#define EMUBOLD_NEEDED(original, request) \
46 (((request) != FW_DONTCARE) && ((request) - (original) >= FW_BOLD - FW_MEDIUM))
54#define gmxWorldToDeviceDefault gmxWorldToPageDefault
60 RTL_CONSTANT_STRING(
L"\\REGISTRY\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
71#define IntLockGlobalFonts() \
72 ExEnterCriticalRegionAndAcquireFastMutexUnsafe(g_FontListLock)
74#define IntUnLockGlobalFonts() \
75 ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(g_FontListLock)
77#define ASSERT_GLOBALFONTS_LOCK_HELD() \
78 ASSERT(g_FontListLock->Owner == KeGetCurrentThread())
80#define IntLockFreeType() \
81 ExEnterCriticalRegionAndAcquireFastMutexUnsafe(g_FreeTypeLock)
83#define IntUnLockFreeType() \
84 ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(g_FreeTypeLock)
86#define ASSERT_FREETYPE_LOCK_HELD() \
87 ASSERT(g_FreeTypeLock->Owner == KeGetCurrentThread())
89#define ASSERT_FREETYPE_LOCK_NOT_HELD() \
90 ASSERT(g_FreeTypeLock->Owner != KeGetCurrentThread())
92#define MAX_FONT_CACHE 256
124#define MAXTCIINDEX 32
209 Cache->OutlineRequiredSize = 0;
243 Ptr->IsMapping = IsMapping;
244 DPRINT(
"Creating SharedMem for %p (%i, %p)\n",
Buffer, IsMapping,
Ptr);
279 CurrentEntry = NextEntry)
282 NextEntry = CurrentEntry->
Flink;
296 if (
Ptr->RefCount <= 0)
300 if (
Ptr->RefCount == 0)
302 DPRINT(
"Releasing SharedMem for %p (%i, %p)\n",
Ptr->Buffer,
Ptr->IsMapping,
Ptr);
324 if (
Ptr->RefCount <= 0)
328 if (
Ptr->RefCount == 0)
330 DPRINT(
"Releasing SharedFace for %s\n",
Ptr->Face->family_name ?
Ptr->Face->family_name :
"<NULL>");
372 pt->x.fract = (
vec->
x & 0x3f) << 10;
373 pt->x.fract |= ((
pt->x.fract >> 6) | (
pt->x.fract >> 12));
375 pt->y.fract = (
vec->
y & 0x3f) << 10;
376 pt->y.fract |= ((
pt->y.fract >> 6) | (
pt->y.fract >> 12));
393 const char *style_name;
412 style_name =
"<invalid>";
415 DPRINT(
"family_name '%s', style_name '%s', FaceName '%wZ', StyleName '%wZ', FontGDI %p, "
416 "FontObj %p, iUnique %lu, SharedFace %p, Face %p, CharSet %u, Filename '%S'\n",
435 DPRINT(
"## DumpFontList(%p)\n", Head);
440 DumpFontEntry(CurrentEntry);
446 DPRINT(
"%wZ,%u -> %wZ,%u\n",
459 DPRINT(
"## DumpFontSubstList\n");
461 for (pListEntry = pHead->
Flink;
463 pListEntry = pListEntry->
Flink)
468 DumpFontSubstEntry(pSubstEntry);
472VOID DumpPrivateFontList(
BOOL bDoLock)
488VOID DumpGlobalFontList(
BOOL bDoLock)
501 DumpGlobalFontList(bDoLock);
502 DumpPrivateFontList(bDoLock);
519 BYTE InfoBuffer[128];
529 L"Microsoft\\Windows NT\\CurrentVersion\\"
545 &KeyFullInfo,
sizeof(KeyFullInfo), &
Length);
558 InfoBuffer,
sizeof(InfoBuffer), &
Length);
573 DPRINT(
"RtlCreateUnicodeString failed\n");
579 InfoBuffer,
sizeof(InfoBuffer), &
Length);
596 DPRINT(
"RtlCreateUnicodeString failed\n");
638 DPRINT(
"ExAllocatePoolWithTag failed\n");
686 DPRINT1(
"FT_Init_FreeType failed with error code 0x%x\n", ulError);
692 DPRINT1(
"Fonts registry is empty.\n");
709 nTenthsOfDegrees %= 360 * 10;
710 if (nTenthsOfDegrees >= 0)
711 return nTenthsOfDegrees;
712 return nTenthsOfDegrees + 360 * 10;
721 pmat->
xx = vecAngle.
x;
722 pmat->
xy = -vecAngle.
y;
723 pmat->
yx = -pmat->
xy;
760 BYTE RequestedCharSet,
771 for (pListEntry = pHead->
Flink;
773 pListEntry = pListEntry->
Flink)
859 UINT RecurseCount = 5;
870 while (RecurseCount-- > 0)
873 &OutputNameW, &InputNameW,
944 if (DirInfoBuffer ==
NULL)
962 Status = ZwQueryDirectoryFile(
1013 bRestartScan =
FALSE;
1029 if (CodePageRange1 == 0)
1034 for (BitIndex = 0; BitIndex <
MAXTCIINDEX; ++BitIndex)
1036 if (CodePageRange1 & (1 << BitIndex))
1039 if ((nIndex >= 0) && (nCount == (
UINT)nIndex))
1051#define PX2PT(pixels) FT_MulDiv((pixels), 72, 96)
1075 if (SharedFace ==
NULL && CharSetIndex == -1)
1083 ((FontIndex != -1) ? FontIndex : 0),
1099 if (
Error == FT_Err_Unknown_File_Format)
1100 DPRINT1(
"Unknown font file format\n");
1102 DPRINT1(
"Error reading font (error code: %d)\n",
Error);
1108 Face = SharedFace->
Face;
1256 if (pOS2 && os2_version >= 1)
1263 for (BitIndex = 0; BitIndex <
MAXTCIINDEX; ++BitIndex)
1265 if (os2_ulCodePageRange1 & (1 << BitIndex))
1270 if ((CharSetIndex == -1 && CharSetCount == 0) ||
1271 CharSetIndex == CharSetCount)
1296 DPRINT(
"Font loaded: %s (%s)\n",
1303 Entry->Font = FontGDI;
1304 Entry->NotEnum = (Characteristics & FR_NOT_ENUM);
1306 if (Characteristics & FR_PRIVATE)
1322 if (FontIndex == -1)
1339 if (CharSetIndex == -1)
1344 if (
Entry->StyleName.Length)
1345 NameLength +=
Entry->StyleName.Length +
sizeof(
WCHAR);
1373 *pValueName = NewString;
1375 if (
Entry->StyleName.Length)
1381 for (
i = 1;
i < CharSetCount; ++
i)
1415 default:
return L"Unknown";
1454 RtlInitEmptyUnicodeString(&PathName, pszBuffer,
Length);
1477 DPRINT1(
"Could not load font file: %wZ\n", &PathName);
1486 DPRINT1(
"ObReferenceObjectByHandle failed.\n");
1499 DPRINT1(
"Could not map file: %wZ\n", &PathName);
1510 DPRINT1(
"Could not map file: %wZ\n", &PathName);
1519 LoadFont.Characteristics = Characteristics;
1549 RtlInitEmptyUnicodeString(&NewString, pszBuffer,
Length);
1572 RtlInitEmptyUnicodeString(&NewString, pszBuffer,
Length);
1598 pFileName = PathName.
Buffer;
1633 if (!lpszPath || !*lpszPath)
1635 if (*lpszPath ==
L'\\' || (*lpszPath && lpszPath[1] ==
L':'))
1671 &KeyFullInfo,
sizeof(KeyFullInfo), &
Length);
1684 DPRINT1(
"ExAllocatePoolWithTag failed\n");
1690 for (
i = 0;
i < KeyFullInfo.
Values; ++
i)
1694 InfoBuffer, InfoSize, &
Length);
1703 DPRINT1(
"ExAllocatePoolWithTag failed\n");
1708 InfoBuffer, InfoSize, &
Length);
1724 DPRINT1(
"RtlCreateUnicodeString failed\n");
1730 InfoBuffer, InfoSize, &
Length);
1739 DPRINT1(
"ExAllocatePoolWithTag failed\n");
1744 InfoBuffer, InfoSize, &
Length);
1764 L"\\SystemRoot\\Fonts\\%s", pchPath);
1791 return (KeyFullInfo.
Values != 0 && nFontCount != 0);
1812 LoadFont.Characteristics = FR_PRIVATE | FR_NOT_ENUM;
1828 if (EntryCollection)
1836 Ret = EntryCollection->
Handle;
1897 if (CurrentEntry->
Handle == hMMFont)
1899 EntryCollection = CurrentEntry;
1906 if (EntryCollection)
1923 DPRINT(
"IntGdiCleanupPrivateFontsForProcess()\n");
1926 EntryCollection =
NULL;
1937 if (EntryCollection)
2013 if (lf->lfEscapement != lf->lfOrientation)
2107 int Ascent, Descent;
2164 - ((Ascent + Descent)
2166 YScale) + 32) >> 6);
2355 Names->OtmSize = OtmSize;
2429 if (
Size == 0 &&
Cache->OutlineRequiredSize > 0)
2432 return Cache->OutlineRequiredSize;
2442 return Cache->OutlineRequiredSize;
2447 if (Size < Cache->OutlineRequiredSize)
2449 DPRINT1(
"Size %u < OutlineRequiredSize %u\n",
Size,
2450 Cache->OutlineRequiredSize);
2468 DPRINT1(
"Can't find OS/2 table - not TT font?\n");
2476 DPRINT1(
"Can't find HHEA table - not TT font?\n");
2497#define SCALE_X(value) ((FT_MulFix((value), XScale) + 32) >> 6)
2498#define SCALE_Y(value) ((FT_MulFix((value), YScale) + 32) >> 6)
2546 return Cache->OutlineRequiredSize;
2613 INT i,
Count, BestIndex, Score, BestScore;
2654 if (
Name.name_id != NameID)
2667 (
Name.string[0] == 0 &&
Name.string[1] == 0))
2691 if (Score > BestScore)
2751 if (!
Cache->FontFamily.Buffer)
2759 if (!
Cache->FullName.Buffer)
2803 Lf = &
Info->EnumLogFontEx.elfLogFont;
2816 Ntm = &
Info->NewTextMetricEx.ntmTm;
2861 sizeof(
Info->EnumLogFontEx.elfFullName),
2865 StyleW.
Buffer =
Info->EnumLogFontEx.elfStyle;
2909 if (
fs.fsCsb[0] == 0)
2916 case FT_ENCODING_UNICODE:
2917 case FT_ENCODING_APPLE_ROMAN:
2920 case FT_ENCODING_MS_SYMBOL:
2932 if (
fs.fsCsb[0] & fs0)
2944 DPRINT1(
"Unknown elfscript for bit %u\n",
i);
2949 Info->NewTextMetricEx.ntmFontSig =
fs;
2969 FontGDI = CurrentEntry->
Font;
3096 const DWORD *pdw = pv;
3112 DWORD dwHash = pCache->dwHash;
3118 CurrentEntry = CurrentEntry->
Flink)
3121 if (FontEntry->
dwHash == dwHash &&
3123 FontEntry->
Hashed.
Face == pCache->Hashed.Face &&
3161 DPRINT1(
"Failure getting glyph.\n");
3169 DPRINT1(
"Failure rendering glyph.\n");
3177 DPRINT1(
"Conversion failed\n");
3183 BitmapGlyph->
bitmap = AlignedBitmap;
3204 DPRINT1(
"Failure caching glyph.\n");
3212 DPRINT1(
"Failure rendering glyph.\n");
3219 DPRINT1(
"Alloc failure caching glyph.\n");
3228 DPRINT1(
"Conversion failed\n");
3236 BitmapGlyph->
bitmap = AlignedBitmap;
3257 int needed = 0,
point = 0, contour, first_pt;
3258 unsigned int pph_start, cpfx;
3261 for (contour = 0; contour <
outline->n_contours; contour++)
3278 needed +=
sizeof(*pph);
3280 while (point <= outline->contours[contour])
3292 }
while (point <= outline->contours[contour] &&
3304 else if (point <= outline->contours[contour] &&
3318 needed +=
sizeof(*ppc) + (cpfx - 1) *
sizeof(
POINTFX);
3321 pph->
cb = needed - pph_start;
3344 int contour,
point = 0, first_pt;
3349 unsigned int needed = 0;
3351 for (contour = 0; contour <
outline->n_contours; contour++)
3361 needed +=
sizeof(*pph);
3363 while (point <= outline->contours[contour])
3390 cubic_control[0].
x >>= 1;
3391 cubic_control[0].
y >>= 1;
3394 cubic_control[3] =
outline->points[first_pt];
3402 cubic_control[3].
x >>= 1;
3403 cubic_control[3].
y >>= 1;
3408 cubic_control[1].
x = (2 *
outline->points[
point].x + 1) / 3;
3409 cubic_control[1].
y = (2 *
outline->points[
point].y + 1) / 3;
3410 cubic_control[2] = cubic_control[1];
3411 cubic_control[1].
x += (cubic_control[0].
x + 1) / 3;
3412 cubic_control[1].
y += (cubic_control[0].
y + 1) / 3;
3413 cubic_control[2].
x += (cubic_control[3].
x + 1) / 3;
3414 cubic_control[2].
y += (cubic_control[3].
y + 1) / 3;
3424 }
while (point <= outline->contours[contour] &&
3430 if (point <= outline->contours[contour] &&
3442 needed +=
sizeof(*ppc) + (cpfx - 1) *
sizeof(
POINTFX);
3445 pph->
cb = needed - pph_start;
3459 LONG Ascent, Descent, Sum, EmHeight, Width64;
3461 lfWidth =
abs(lfWidth);
3466 DPRINT(
"lfHeight and lfWidth are zero.\n");
3489 if (!pOS2 || !pHori)
3494 DPRINT1(
"%s: Failed to request font size.\n",
face->family_name);
3518#define FM_SEL_USE_TYPO_METRICS 0x80
3527 Sum = Ascent + Descent;
3540 else if (lfHeight < 0)
3556#undef FM_SEL_USE_TYPO_METRICS
3563 EmHeight =
max(EmHeight, 1);
3576 Width64 = (
FT_MulDiv(lfWidth, 96 * 5, 72 * 3) << 6);
3582 req.
width = Width64;
3583 req.
height = (EmHeight << 6);
3607 DPRINT(
"WARNING: No charmap selected!\n");
3608 DPRINT(
"This font face has %d charmaps\n",
face->num_charmaps);
3611 for (
n = 0;
n <
face->num_charmaps;
n++)
3613 charmap =
face->charmaps[
n];
3614 if (charmap->
encoding == FT_ENCODING_UNICODE)
3622 for (
n = 0;
n <
face->num_charmaps;
n++)
3624 charmap =
face->charmaps[
n];
3634 for (
n = 0;
n <
face->num_charmaps;
n++)
3636 charmap =
face->charmaps[
n];
3637 if (charmap->
encoding == FT_ENCODING_MS_SYMBOL)
3644 if (!found &&
face->num_charmaps > 0)
3646 found =
face->charmaps[0];
3650 DPRINT1(
"WARNING: Could not find desired charmap!\n");
3658 DPRINT1(
"WARNING: Could not set the charmap!\n");
3684 if (glyph < 0x100) glyph += 0xf000;
3712 if (
flags & indexed_flag)
3737 BOOL bIgnoreRotation)
3764 cjBuf, pvBuf, pmat2);
3766 pdcattr =
dc->pdcattr;
3826 DPRINT1(
"WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
3834 if (aveWidth && potm)
3863 DPRINT(
"Advance = %d, lsb = %d, bbx = %d\n",adv, lsb, bbx);
3880 needsTransform =
TRUE;
3894 needsTransform =
TRUE;
3902 DPRINT(
"Rotation Trans!\n");
3905 needsTransform =
TRUE;
3912 DPRINT(
"MAT2 Matrix Trans!\n");
3918 needsTransform =
TRUE;
3923 if (!needsTransform)
3925 DPRINT(
"No Need to be Transformed!\n");
3936 for (xc = 0; xc < 2; xc++)
3938 for (yc = 0; yc < 2; yc++)
3946 if (xc == 0 && yc == 0)
3977 DPRINT(
"CX %d CY %d BBX %u BBY %u GOX %d GOY %d\n",
3987 DPRINT(
"GGO_METRICS Exit!\n");
4004 pitch = ((
width + 31) >> 5) << 2;
4007 if (!pvBuf || !
cjBuf)
break;
4032 ft_bitmap.
pitch = pitch;
4034 ft_bitmap.
buffer = pvBuf;
4061 unsigned int mult,
row, col;
4066 pitch = (
width + 3) / 4 * 4;
4069 if (!pvBuf || !
cjBuf)
break;
4083 for (
x = 0; (
UINT)
x < pitch;
x++)
4085 if (x < ft_face->glyph->bitmap.width)
4086 dst[
x] = (
src[
x / 8] & (1 << ( (7 - (
x % 8))))) ? 0xff : 0;
4099 ft_bitmap.
pitch = pitch;
4101 ft_bitmap.
buffer = pvBuf;
4128 for (col = 0; col <
width; col++,
ptr++)
4130 *
ptr = (((
int)*
ptr) * mult + 128) / 256;
4156 if (!pvBuf || !
cjBuf)
4176 if (needsTransform && pvBuf)
4184 if (!pvBuf || !
cjBuf)
4198 DPRINT(
"ftGdiGetGlyphOutline END and needed %lu\n", needed);
4219 if (
Cache->Hashed.Aspect.EmuBoldItalic)
4224 DPRINT1(
"WARNING: Failed to load and render glyph! [index: %d]\n",
4225 Cache->Hashed.GlyphIndex);
4229 glyph =
Cache->Hashed.Face->glyph;
4231 if (
Cache->Hashed.Aspect.Emu.Bold)
4233 if (
Cache->Hashed.Aspect.Emu.Italic)
4248 DPRINT1(
"WARNING: Failed to load and render glyph! [index: %d]\n",
Cache->Hashed.GlyphIndex);
4252 glyph =
Cache->Hashed.Face->glyph;
4257 DPRINT1(
"Failed to render glyph! [index: %d]\n",
Cache->Hashed.GlyphIndex);
4276 INT glyph_index,
i, previous, nTenthsOfDegrees;
4279 BOOL use_kerning, bVerticalWriting;
4280 LONG ascender, descender;
4299 bVerticalWriting = ((nTenthsOfDegrees == 90 * 10) || (nTenthsOfDegrees == 270 * 10));
4318 Cache.Hashed.GlyphIndex = glyph_index;
4325 if (use_kerning && previous && glyph_index)
4329 TotalWidth64 += delta.
x;
4334 if (((TotalWidth64 + 32) >> 6) <= MaxExtent &&
NULL != Fit)