extern const MATRIX gmxWorldToDeviceDefault;
extern const MATRIX gmxWorldToPageDefault;
+static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)};
/* HACK!! Fix XFORMOBJ then use 1:16 / 16:1 */
#define gmxWorldToDeviceDefault gmxWorldToPageDefault
FT_Library g_FreeTypeLibrary;
+typedef struct
+{
+ FT_Int major;
+ FT_Int minor;
+ FT_Int patch;
+} FT_Version_t;
+static FT_Version_t FT_Version;
+static DWORD FT_SimpleVersion;
+#define FT_VERSION_VALUE(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
+
/* special font names */
static const UNICODE_STRING g_MarlettW = RTL_CONSTANT_STRING(L"Marlett");
return FALSE;
}
+ FT_Library_Version(g_FreeTypeLibrary,&FT_Version.major,&FT_Version.minor,&FT_Version.patch);
+
+ DPRINT1("FreeType version is %d.%d.%d\n",FT_Version.major,FT_Version.minor,FT_Version.patch);
+ FT_SimpleVersion = ((FT_Version.major << 16) & 0xff0000) |
+ ((FT_Version.minor << 8) & 0x00ff00) |
+ ((FT_Version.patch ) & 0x0000ff);
+
IntLoadSystemFonts();
IntLoadFontSubstList(&g_FontSubstListHead);
return TRUE;
}
-VOID
-FtSetCoordinateTransform(
- FT_Face face,
- PMATRIX pmx)
+VOID FASTCALL IntWidthMatrix(FT_Face face, FT_Matrix *pmat, LONG lfWidth)
{
- FT_Matrix ftmatrix;
- FLOATOBJ efTemp;
+ LONG tmAveCharWidth;
+ TT_OS2 *pOS2;
+ FT_Fixed XScale;
+
+ *pmat = identityMat;
+
+ if (lfWidth == 0)
+ return;
+
+ ASSERT_FREETYPE_LOCK_HELD();
+ pOS2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, FT_SFNT_OS2);
+ if (!pOS2)
+ return;
+
+ XScale = face->size->metrics.x_scale;
+ tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
+ if (tmAveCharWidth == 0)
+ {
+ tmAveCharWidth = 1;
+ }
+
+ if (lfWidth == tmAveCharWidth)
+ return;
+
+ pmat->xx = (FT_Fixed)((1 << 16) * lfWidth / tmAveCharWidth);
+ pmat->xy = 0;
+ pmat->yx = 0;
+ pmat->yy = (FT_Fixed)(1 << 16);
+}
+
+VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
+{
+ double radian = (lfEscapement * M_PI) / 180 / 10;
+
+ pmat->xx = (FT_Fixed)(cos(radian) * (1 << 16));
+ pmat->xy = (FT_Fixed)(-sin(radian) * (1 << 16));
+ pmat->yx = -pmat->xy;
+ pmat->yy = pmat->xx;
+}
+
+VOID FASTCALL
+FtMatrixFromMx(FT_Matrix *pmat, PMATRIX pmx)
+{
+ FLOATOBJ ef;
/* Create a freetype matrix, by converting to 16.16 fixpoint format */
- efTemp = pmx->efM11;
- FLOATOBJ_MulLong(&efTemp, 0x00010000);
- ftmatrix.xx = FLOATOBJ_GetLong(&efTemp);
+ ef = pmx->efM11;
+ FLOATOBJ_MulLong(&ef, 0x00010000);
+ pmat->xx = FLOATOBJ_GetLong(&ef);
- efTemp = pmx->efM12;
- FLOATOBJ_MulLong(&efTemp, 0x00010000);
- ftmatrix.xy = FLOATOBJ_GetLong(&efTemp);
+ ef = pmx->efM21;
+ FLOATOBJ_MulLong(&ef, 0x00010000);
+ pmat->xy = FLOATOBJ_GetLong(&ef);
- efTemp = pmx->efM21;
- FLOATOBJ_MulLong(&efTemp, 0x00010000);
- ftmatrix.yx = FLOATOBJ_GetLong(&efTemp);
+ ef = pmx->efM12;
+ FLOATOBJ_MulLong(&ef, 0x00010000);
+ pmat->yx = FLOATOBJ_GetLong(&ef);
- efTemp = pmx->efM22;
- FLOATOBJ_MulLong(&efTemp, 0x00010000);
- ftmatrix.yy = FLOATOBJ_GetLong(&efTemp);
+ ef = pmx->efM22;
+ FLOATOBJ_MulLong(&ef, 0x00010000);
+ pmat->yy = FLOATOBJ_GetLong(&ef);
+}
+
+FORCEINLINE VOID FASTCALL
+FtSetCoordinateTransform(
+ FT_Face face,
+ PMATRIX pmx)
+{
+ FT_Matrix mat;
+ FtMatrixFromMx(&mat, pmx);
/* Set the transformation matrix */
- FT_Set_Transform(face, &ftmatrix, 0);
+ FT_Set_Transform(face, &mat, 0);
}
static BOOL
Status = RtlAnsiStringToUnicodeString(&Entry->FaceName, &AnsiString, TRUE);
if (NT_SUCCESS(Status))
{
- if (Face->style_name[0] && strcmp(Face->style_name, "Regular"))
+ if (Face->style_name && Face->style_name[0] &&
+ strcmp(Face->style_name, "Regular") != 0)
{
RtlInitAnsiString(&AnsiString, Face->style_name);
Status = RtlAnsiStringToUnicodeString(&Entry->StyleName, &AnsiString, TRUE);
} while (Entry);
}
-BOOL FASTCALL
-IntIsFontRenderingEnabled(VOID)
+static BOOL is_hinting_enabled(void)
{
- BOOL Ret = g_RenderingEnabled;
- HDC hDC;
+ static int enabled = -1;
- hDC = IntGetScreenDC();
- if (hDC)
- Ret = (NtGdiGetDeviceCaps(hDC, BITSPIXEL) > 8) && g_RenderingEnabled;
+ if (enabled == -1)
+ {
+ /* Use the >= 2.2.0 function if available */
+ FT_TrueTypeEngineType type = FT_Get_TrueType_Engine_Type(g_FreeTypeLibrary);
+ enabled = (type == FT_TRUETYPE_ENGINE_TYPE_PATENTED);
- return Ret;
+ DPRINT1("hinting is %senabled\n", enabled ? "" : "NOT ");
+ }
+ return enabled;
+}
+
+static BOOL is_subpixel_rendering_enabled( void )
+{
+ static int enabled = -1;
+ if (enabled == -1)
+ {
+ /* FreeType >= 2.8.1 offers LCD-optimezed rendering without lcd filters. */
+ if (FT_SimpleVersion >= FT_VERSION_VALUE(2, 8, 1))
+ enabled = TRUE;
+ else enabled = FALSE;
+
+ DPRINT1("subpixel rendering is %senabled\n", enabled ? "" : "NOT ");
+ }
+ return enabled;
+}
+
+BOOL FASTCALL
+IntIsFontRenderingEnabled(VOID)
+{
+ return is_hinting_enabled() && is_subpixel_rendering_enabled() && g_RenderingEnabled;
}
VOID FASTCALL
PLFONT plfont;
LOGFONTW *plf;
+ ASSERT(lf);
plfont = LFONT_AllocFontWithHandle();
if (!plfont)
{
return Cache->OutlineRequiredSize;
}
-static PFONTGDI FASTCALL
-FindFaceNameInList(PUNICODE_STRING FaceName, PLIST_ENTRY Head)
-{
- PLIST_ENTRY Entry;
- PFONT_ENTRY CurrentEntry;
- ANSI_STRING EntryFaceNameA;
- UNICODE_STRING EntryFaceNameW;
- FONTGDI *FontGDI;
- NTSTATUS status;
-
- for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink)
- {
- CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
-
- FontGDI = CurrentEntry->Font;
- ASSERT(FontGDI);
-
- RtlInitAnsiString(&EntryFaceNameA, FontGDI->SharedFace->Face->family_name);
- status = RtlAnsiStringToUnicodeString(&EntryFaceNameW, &EntryFaceNameA, TRUE);
- if (!NT_SUCCESS(status))
- {
- break;
- }
-
- if ((LF_FACESIZE - 1) * sizeof(WCHAR) < EntryFaceNameW.Length)
- {
- EntryFaceNameW.Length = (LF_FACESIZE - 1) * sizeof(WCHAR);
- EntryFaceNameW.Buffer[LF_FACESIZE - 1] = L'\0';
- }
-
- if (RtlEqualUnicodeString(FaceName, &EntryFaceNameW, TRUE))
- {
- RtlFreeUnicodeString(&EntryFaceNameW);
- return FontGDI;
- }
-
- RtlFreeUnicodeString(&EntryFaceNameW);
- }
-
- return NULL;
-}
-
-static PFONTGDI FASTCALL
-FindFaceNameInLists(PUNICODE_STRING FaceName)
-{
- PPROCESSINFO Win32Process;
- PFONTGDI Font;
-
- /* Search the process local list.
- We do not have to search the 'Mem' list, since those fonts are linked in the PrivateFontListHead */
- Win32Process = PsGetCurrentProcessWin32Process();
- IntLockProcessPrivateFonts(Win32Process);
- Font = FindFaceNameInList(FaceName, &Win32Process->PrivateFontListHead);
- IntUnLockProcessPrivateFonts(Win32Process);
- if (NULL != Font)
- {
- return Font;
- }
-
- /* Search the global list */
- IntLockGlobalFonts();
- Font = FindFaceNameInList(FaceName, &g_FontListHead);
- IntUnLockGlobalFonts();
-
- return Font;
-}
-
/* See https://msdn.microsoft.com/en-us/library/bb165625(v=vs.90).aspx */
static BYTE
CharSetFromLangID(LANGID LangID)
Info->NewTextMetricEx.ntmFontSig = fs;
}
-static int FASTCALL
-FindFaceNameInInfo(PUNICODE_STRING FaceName, PFONTFAMILYINFO Info, DWORD InfoEntries)
-{
- DWORD i;
- UNICODE_STRING InfoFaceName;
-
- for (i = 0; i < InfoEntries; i++)
- {
- RtlInitUnicodeString(&InfoFaceName, Info[i].EnumLogFontEx.elfLogFont.lfFaceName);
- if (RtlEqualUnicodeString(&InfoFaceName, FaceName, TRUE))
- {
- return i;
- }
- }
-
- return -1;
-}
-
-static BOOLEAN FASTCALL
-FontFamilyInclude(LPLOGFONTW LogFont, PUNICODE_STRING FaceName,
- PFONTFAMILYINFO Info, DWORD InfoEntries)
-{
- UNICODE_STRING LogFontFaceName;
-
- RtlInitUnicodeString(&LogFontFaceName, LogFont->lfFaceName);
- if (0 != LogFontFaceName.Length &&
- !RtlEqualUnicodeString(&LogFontFaceName, FaceName, TRUE))
- {
- return FALSE;
- }
-
- return FindFaceNameInInfo(FaceName, Info, InfoEntries) < 0;
-}
-
-static BOOL FASTCALL
-FontFamilyFound(PFONTFAMILYINFO InfoEntry,
- PFONTFAMILYINFO Info, DWORD InfoCount)
-{
- LPLOGFONTW plf1 = &InfoEntry->EnumLogFontEx.elfLogFont;
- LPWSTR pFullName1 = InfoEntry->EnumLogFontEx.elfFullName;
- LPWSTR pFullName2;
- DWORD i;
-
- for (i = 0; i < InfoCount; ++i)
- {
- LPLOGFONTW plf2 = &Info[i].EnumLogFontEx.elfLogFont;
- if (plf1->lfCharSet != plf2->lfCharSet)
- continue;
-
- pFullName2 = Info[i].EnumLogFontEx.elfFullName;
- if (_wcsicmp(pFullName1, pFullName2) != 0)
- continue;
-
- return TRUE;
- }
- return FALSE;
-}
-
static BOOLEAN FASTCALL
GetFontFamilyInfoForList(LPLOGFONTW LogFont,
PFONTFAMILYINFO Info,
+ LPCWSTR NominalName,
DWORD *pCount,
DWORD MaxCount,
PLIST_ENTRY Head)
{
if (Count < MaxCount)
{
- FontFamilyFillInfo(&Info[Count], NULL, NULL, FontGDI);
+ FontFamilyFillInfo(&Info[Count], NominalName, NULL, FontGDI);
}
Count++;
continue;
}
- FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI);
+ FontFamilyFillInfo(&InfoEntry, NominalName, NULL, FontGDI);
- if (_wcsnicmp(LogFont->lfFaceName, InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName, RTL_NUMBER_OF(LogFont->lfFaceName)-1) != 0 &&
- _wcsnicmp(LogFont->lfFaceName, InfoEntry.EnumLogFontEx.elfFullName, RTL_NUMBER_OF(LogFont->lfFaceName)-1) != 0)
+ if (NominalName)
{
- continue;
+ RtlStringCchCopyW(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName,
+ RTL_NUMBER_OF(InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName),
+ NominalName);
}
-
- if (!FontFamilyFound(&InfoEntry, Info, min(Count, MaxCount)))
+ else
{
- if (Count < MaxCount)
+ if (_wcsnicmp(LogFont->lfFaceName,
+ InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName,
+ RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0 &&
+ _wcsnicmp(LogFont->lfFaceName,
+ InfoEntry.EnumLogFontEx.elfFullName,
+ RTL_NUMBER_OF(LogFont->lfFaceName) - 1) != 0)
{
- RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
+ continue;
}
- Count++;
}
+
+ if (Count < MaxCount)
+ {
+ RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry));
+ }
+ Count++;
}
*pCount = Count;
{
PLIST_ENTRY pEntry, pHead = &g_FontSubstListHead;
PFONTSUBST_ENTRY pCurrentEntry;
- PUNICODE_STRING pFromW;
- FONTGDI *FontGDI;
+ PUNICODE_STRING pFromW, pToW;
LOGFONTW lf = *LogFont;
- UNICODE_STRING NameW;
+ PPROCESSINFO Win32Process = PsGetCurrentProcessWin32Process();
for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
{
pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
if (LogFont->lfFaceName[0] != UNICODE_NULL)
{
- if (!FontFamilyInclude(LogFont, pFromW, Info, min(*pCount, MaxCount)))
+ if (_wcsicmp(LogFont->lfFaceName, pFromW->Buffer) != 0)
continue; /* mismatch */
}
+ pToW = &pCurrentEntry->FontNames[FONTSUBST_TO];
+ if (RtlEqualUnicodeString(pFromW, pToW, TRUE) &&
+ pCurrentEntry->CharSets[FONTSUBST_FROM] ==
+ pCurrentEntry->CharSets[FONTSUBST_TO])
+ {
+ continue;
+ }
+
IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
SubstituteFontRecurse(&lf);
+ if (LogFont->lfCharSet != DEFAULT_CHARSET && LogFont->lfCharSet != lf.lfCharSet)
+ continue;
- RtlInitUnicodeString(&NameW, lf.lfFaceName);
- FontGDI = FindFaceNameInLists(&NameW);
- if (FontGDI == NULL)
- {
- continue; /* no real font */
- }
+ IntLockGlobalFonts();
+ GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount, &g_FontListHead);
+ IntUnLockGlobalFonts();
- if (*pCount < MaxCount)
- {
- FontFamilyFillInfo(&Info[*pCount], pFromW->Buffer, NULL, FontGDI);
- }
- (*pCount)++;
+ IntLockProcessPrivateFonts(Win32Process);
+ GetFontFamilyInfoForList(&lf, Info, pFromW->Buffer, pCount, MaxCount,
+ &Win32Process->PrivateFontListHead);
+ IntUnLockProcessPrivateFonts(Win32Process);
+ break;
}
return TRUE;
LPMAT2 pmat2,
BOOL bIgnoreRotation)
{
- static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)};
PDC_ATTR pdcattr;
PTEXTOBJ TextObj;
PFONTGDI FontGDI;
/* World transform */
{
FT_Matrix ftmatrix;
- FLOATOBJ efTemp;
PMATRIX pmx = DC_pmxWorldToDevice(dc);
/* Create a freetype matrix, by converting to 16.16 fixpoint format */
- efTemp = pmx->efM11;
- FLOATOBJ_MulLong(&efTemp, 0x00010000);
- ftmatrix.xx = FLOATOBJ_GetLong(&efTemp);
-
- efTemp = pmx->efM12;
- FLOATOBJ_MulLong(&efTemp, 0x00010000);
- ftmatrix.xy = FLOATOBJ_GetLong(&efTemp);
-
- efTemp = pmx->efM21;
- FLOATOBJ_MulLong(&efTemp, 0x00010000);
- ftmatrix.yx = FLOATOBJ_GetLong(&efTemp);
-
- efTemp = pmx->efM22;
- FLOATOBJ_MulLong(&efTemp, 0x00010000);
- ftmatrix.yy = FLOATOBJ_GetLong(&efTemp);
+ FtMatrixFromMx(&ftmatrix, pmx);
if (memcmp(&ftmatrix, &identityMat, sizeof(identityMat)) != 0)
{
FT_GlyphSlot glyph;
FT_BitmapGlyph realglyph;
INT error, glyph_index, i, previous;
- ULONGLONG TotalWidth = 0;
+ ULONGLONG TotalWidth64 = 0;
BOOL use_kerning;
FT_Render_Mode RenderMode;
BOOLEAN Render;
{
FT_Vector delta;
FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
- TotalWidth += delta.x;
+ TotalWidth64 += delta.x;
}
- TotalWidth += realglyph->root.advance.x >> 10;
+ TotalWidth64 += realglyph->root.advance.x >> 10;
- if (((TotalWidth + 32) >> 6) <= MaxExtent && NULL != Fit)
+ if (((TotalWidth64 + 32) >> 6) <= MaxExtent && NULL != Fit)
{
*Fit = i + 1;
}
if (NULL != Dx)
{
- Dx[i] = (TotalWidth + 32) >> 6;
+ Dx[i] = (TotalWidth64 + 32) >> 6;
}
+ /* Bold and italic do not use the cache */
if (EmuBold || EmuItalic)
{
FT_Done_Glyph((FT_Glyph)realglyph);
- realglyph = NULL;
}
previous = glyph_index;
descender = FontGDI->tmDescent; /* Units below baseline */
IntUnLockFreeType();
- Size->cx = (TotalWidth + 32) >> 6;
+ Size->cx = (TotalWidth64 + 32) >> 6;
Size->cy = ascender + descender;
return TRUE;
Face = FontGdi->SharedFace->Face;
TEXTOBJ_UnlockText(TextObj);
+ memset(&fs, 0, sizeof(FONTSIGNATURE));
IntLockFreeType();
pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
- IntUnLockFreeType();
- memset(&fs, 0, sizeof(FONTSIGNATURE));
if (NULL != pOS2)
{
fs.fsCsb[0] = pOS2->ulCodePageRange1;
fs.fsCsb[0] |= FS_SYMBOL;
}
}
+ pOS2 = NULL;
+ IntUnLockFreeType();
DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]);
if (fs.fsCsb[0] == 0)
{ /* Let's see if we can find any interesting cmaps */
FT_ULong tmp_size = 0;
FT_Face Face = Font->SharedFace->Face;
+ ASSERT_FREETYPE_LOCK_NOT_HELD();
+ IntLockFreeType();
+
if (FT_HAS_MULTIPLE_MASTERS(Face))
Font->FontObj.flFontType |= FO_MULTIPLEMASTER;
if (FT_HAS_VERTICAL(Face))
{
Font->FontObj.flFontType |= (FO_CFF|FO_POSTSCRIPT);
}
+
+ IntUnLockFreeType();
}
static BOOL
/* Enumerate font families in the global list */
IntLockGlobalFonts();
Count = 0;
- if (! GetFontFamilyInfoForList(&LogFont, Info, &Count, Size, &g_FontListHead) )
+ if (! GetFontFamilyInfoForList(&LogFont, Info, NULL, &Count, Size, &g_FontListHead) )
{
IntUnLockGlobalFonts();
ExFreePoolWithTag(Info, GDITAG_TEXT);
/* Enumerate font families in the process local list */
Win32Process = PsGetCurrentProcessWin32Process();
IntLockProcessPrivateFonts(Win32Process);
- if (! GetFontFamilyInfoForList(&LogFont, Info, &Count, Size,
+ if (! GetFontFamilyInfoForList(&LogFont, Info, NULL, &Count, Size,
&Win32Process->PrivateFontListHead))
{
IntUnLockProcessPrivateFonts(Win32Process);
return lValue;
}
+FORCEINLINE LONG FASTCALL
+IntNormalizeAngle(LONG nTenthAngle)
+{
+ const LONG nFullAngle = 360 * 10;
+ nTenthAngle %= nFullAngle;
+ return (nTenthAngle + nFullAngle) % nFullAngle;
+}
+
BOOL
APIENTRY
-GreExtTextOutW(
- IN HDC hDC,
+IntExtTextOutW(
+ IN PDC dc,
IN INT XStart,
IN INT YStart,
IN UINT fuOptions,
* appropriate)
*/
- DC *dc;
PDC_ATTR pdcattr;
SURFOBJ *SurfObj;
SURFACE *psurf = NULL;
FT_Face face;
FT_GlyphSlot glyph;
FT_BitmapGlyph realglyph;
- LONGLONG TextLeft, RealXStart;
- ULONG TextTop, previous, BackgroundLeft;
+ LONGLONG TextLeft64, TextTop64, DeltaX64, DeltaY64, XStart64, YStart64;
+ ULONG previous;
FT_Bool use_kerning;
RECTL DestRect, MaskRect;
POINTL SourcePoint, BrushOrigin;
HBITMAP HSourceGlyph;
SURFOBJ *SourceGlyphSurf;
SIZEL bitSize;
- INT yoff;
FONTOBJ *FontObj;
PFONTGDI FontGDI;
PTEXTOBJ TextObj = NULL;
BOOL DoBreak = FALSE;
USHORT DxShift;
PMATRIX pmxWorldToDevice;
- LONG fixAscender, fixDescender;
+ LONG lfEscapement, lfWidth;
FLOATOBJ Scale;
LOGFONTW *plf;
BOOL EmuBold, EmuItalic;
int thickness;
BOOL bResult;
+ FT_Matrix mat = identityMat, matWidth, matEscape, matWorld;
+ FT_Vector vecs[9];
/* Check if String is valid */
if ((Count > 0xFFFF) || (Count > 0 && String == NULL))
return FALSE;
}
- /* NOTE: This function locks the screen DC, so it must never be called
- with a DC already locked */
Render = IntIsFontRenderingEnabled();
- // TODO: Write test-cases to exactly match real Windows in different
- // bad parameters (e.g. does Windows check the DC or the RECT first?).
- dc = DC_LockDc(hDC);
- if (!dc)
- {
- EngSetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
if (PATH_IsPathOpen(dc->dclevel))
{
bResult = PATH_ExtTextOut(dc,
IntLPtoDP(dc, (POINT *)lprc, 2);
}
- if (pdcattr->lTextAlign & TA_UPDATECP)
+ if (pdcattr->flTextAlign & TA_UPDATECP)
{
Start.x = pdcattr->ptlCurrent.x;
Start.y = pdcattr->ptlCurrent.y;
Start.y = YStart;
}
- IntLPtoDP(dc, &Start, 1);
- RealXStart = ((LONGLONG)Start.x + dc->ptlDCOrig.x) << 6;
- YStart = Start.y + dc->ptlDCOrig.y;
-
SourcePoint.x = 0;
SourcePoint.y = 0;
MaskRect.left = 0;
plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont;
EmuBold = (plf->lfWeight >= FW_BOLD && FontGDI->OriginalWeight <= FW_NORMAL);
EmuItalic = (plf->lfItalic && !FontGDI->OriginalItalic);
+ if (FT_IS_SCALABLE(face))
+ {
+ lfEscapement = IntNormalizeAngle(plf->lfEscapement);
+ lfWidth = labs(plf->lfWidth);
+ }
+ else
+ {
+ lfEscapement = lfWidth = 0;
+ }
if (Render)
RenderMode = IntGetFontRenderMode(plf);
}
/* NOTE: Don't trust face->size->metrics.ascender and descender values. */
+ DC_vUpdateWorldToDevice(dc);
if (dc->pdcattr->iGraphicsMode == GM_ADVANCED)
{
pmxWorldToDevice = DC_pmxWorldToDevice(dc);
- FtSetCoordinateTransform(face, pmxWorldToDevice);
-
- fixAscender = ScaleLong(FontGDI->tmAscent, &pmxWorldToDevice->efM22) << 6;
- fixDescender = ScaleLong(FontGDI->tmDescent, &pmxWorldToDevice->efM22) << 6;
}
else
{
pmxWorldToDevice = (PMATRIX)&gmxWorldToDeviceDefault;
- FtSetCoordinateTransform(face, pmxWorldToDevice);
-
- fixAscender = FontGDI->tmAscent << 6;
- fixDescender = FontGDI->tmDescent << 6;
- }
-
- /*
- * Process the vertical alignment and determine the yoff.
- */
-#define VALIGN_MASK (TA_TOP | TA_BASELINE | TA_BOTTOM)
- if ((pdcattr->lTextAlign & VALIGN_MASK) == TA_BASELINE)
- yoff = 0;
- else if ((pdcattr->lTextAlign & VALIGN_MASK) == TA_BOTTOM)
- yoff = -(fixDescender >> 6);
- else /* TA_TOP */
- yoff = fixAscender >> 6;
-#undef VALIGN_MASK
-
- use_kerning = FT_HAS_KERNING(face);
- previous = 0;
-
- /*
- * Process the horizontal alignment and modify XStart accordingly.
- */
- DxShift = fuOptions & ETO_PDY ? 1 : 0;
- if (pdcattr->lTextAlign & (TA_RIGHT | TA_CENTER))
- {
- ULONGLONG TextWidth = 0;
- LPCWSTR TempText = String;
- int iStart;
-
- /*
- * Calculate width of the text.
- */
-
- if (NULL != Dx)
- {
- iStart = Count < 2 ? 0 : Count - 2;
- TextWidth = Count < 2 ? 0 : (Dx[(Count-2)<<DxShift] << 6);
- }
- else
- {
- iStart = 0;
- }
- TempText = String + iStart;
-
- for (i = iStart; i < Count; i++)
- {
- glyph_index = get_glyph_index_flagged(face, *TempText, ETO_GLYPH_INDEX, fuOptions);
-
- if (EmuBold || EmuItalic)
- realglyph = NULL;
- else
- realglyph = ftGdiGlyphCacheGet(face, glyph_index, plf->lfHeight,
- RenderMode, pmxWorldToDevice);
- if (!realglyph)
- {
- error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
- if (error)
- {
- DPRINT1("WARNING: Failed to load and render glyph! [index: %d]\n", glyph_index);
- }
-
- glyph = face->glyph;
- if (EmuBold || EmuItalic)
- {
- if (EmuBold)
- FT_GlyphSlot_Embolden(glyph);
- if (EmuItalic)
- FT_GlyphSlot_Oblique(glyph);
- realglyph = ftGdiGlyphSet(face, glyph, RenderMode);
- }
- else
- {
- realglyph = ftGdiGlyphCacheSet(face,
- glyph_index,
- plf->lfHeight,
- pmxWorldToDevice,
- glyph,
- RenderMode);
- }
- if (!realglyph)
- {
- DPRINT1("Failed to render glyph! [index: %d]\n", glyph_index);
- IntUnLockFreeType();
- goto Cleanup;
- }
-
- }
- /* Retrieve kerning distance */
- if (use_kerning && previous && glyph_index)
- {
- FT_Vector delta;
- FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
- TextWidth += delta.x;
- }
-
- TextWidth += realglyph->root.advance.x >> 10;
-
- if (EmuBold || EmuItalic)
- {
- FT_Done_Glyph((FT_Glyph)realglyph);
- realglyph = NULL;
- }
-
- previous = glyph_index;
- TempText++;
- }
-
- previous = 0;
-
- if ((pdcattr->lTextAlign & TA_CENTER) == TA_CENTER)
- {
- RealXStart -= TextWidth / 2;
- }
- else
- {
- RealXStart -= TextWidth;
- }
}
- psurf = dc->dclevel.pSurface;
- SurfObj = &psurf->SurfObj ;
+ IntWidthMatrix(face, &matWidth, lfWidth);
+ FT_Matrix_Multiply(&matWidth, &mat);
- if ((fuOptions & ETO_OPAQUE) && (dc->pdcattr->ulDirty_ & DIRTY_BACKGROUND))
- DC_vUpdateBackgroundBrush(dc) ;
+ IntEscapeMatrix(&matEscape, lfEscapement);
+ FT_Matrix_Multiply(&matEscape, &mat);
- if(dc->pdcattr->ulDirty_ & DIRTY_TEXT)
- DC_vUpdateTextBrush(dc) ;
+ FtMatrixFromMx(&matWorld, pmxWorldToDevice);
+ matWorld.yx = -matWorld.yx;
+ matWorld.xy = -matWorld.xy;
+ FT_Matrix_Multiply(&matWorld, &mat);
- if (!face->units_per_EM)
- {
- thickness = 1;
- }
- else
- {
- thickness = face->underline_thickness *
- face->size->metrics.y_ppem / face->units_per_EM;
- if (thickness <= 0)
- thickness = 1;
- }
+ FT_Set_Transform(face, &mat, NULL);
- if ((fuOptions & ETO_OPAQUE) && plf->lfItalic)
+ // Calculate displacement of the text.
+ DeltaX64 = DeltaY64 = 0;
+ DxShift = fuOptions & ETO_PDY ? 1 : 0;
+ use_kerning = FT_HAS_KERNING(face);
+ previous = 0;
+ if ((fuOptions & ETO_OPAQUE) ||
+ (pdcattr->flTextAlign & (TA_CENTER | TA_RIGHT)) ||
+ memcmp(&mat, &identityMat, sizeof(mat)) != 0 ||
+ plf->lfUnderline || plf->lfStrikeOut)
{
- /* Draw background */
- TextLeft = RealXStart;
- TextTop = YStart;
- BackgroundLeft = (RealXStart + 32) >> 6;
for (i = 0; i < Count; ++i)
{
glyph_index = get_glyph_index_flagged(face, String[i], ETO_GLYPH_INDEX, fuOptions);
+ // FIXME: Use FT_LOAD_BITMAP_METRICS_ONLY or cache.
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
if (error)
{
- DPRINT1("Failed to load and render glyph! [index: %d]\n", glyph_index);
+ DPRINT1("Failed to load glyph! [index: %d]\n", glyph_index);
IntUnLockFreeType();
+ bResult = FALSE;
goto Cleanup;
}
{
DPRINT1("Failed to render glyph! [index: %d]\n", glyph_index);
IntUnLockFreeType();
+ bResult = FALSE;
goto Cleanup;
}
/* retrieve kerning distance and move pen position */
- if (use_kerning && previous && glyph_index && NULL == Dx)
+ if (use_kerning && previous && glyph_index && Dx == NULL)
{
FT_Vector delta;
FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
- TextLeft += delta.x;
+ DeltaX64 += delta.x;
+ DeltaY64 -= delta.y;
}
- DPRINT("TextLeft: %I64d\n", TextLeft);
- DPRINT("TextTop: %lu\n", TextTop);
- DPRINT("Advance: %d\n", realglyph->root.advance.x);
-
- DestRect.left = BackgroundLeft;
- DestRect.right = (TextLeft + (realglyph->root.advance.x >> 10) + 32) >> 6;
- DestRect.top = TextTop + yoff - ((fixAscender + 32) >> 6);
- DestRect.bottom = DestRect.top + ((fixAscender + fixDescender) >> 6);
- MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom);
- if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
- {
- IntUpdateBoundsRect(dc, &DestRect);
- }
- IntEngBitBlt(
- &psurf->SurfObj,
- NULL,
- NULL,
- (CLIPOBJ *)&dc->co,
- NULL,
- &DestRect,
- &SourcePoint,
- &SourcePoint,
- &dc->eboBackground.BrushObject,
- &BrushOrigin,
- ROP4_FROM_INDEX(R3_OPINDEX_PATCOPY));
- MouseSafetyOnDrawEnd(dc->ppdev);
- BackgroundLeft = DestRect.right;
-
- DestRect.left = ((TextLeft + 32) >> 6) + realglyph->left;
- DestRect.right = DestRect.left + realglyph->bitmap.width;
- DestRect.top = TextTop + yoff - realglyph->top;
- DestRect.bottom = DestRect.top + realglyph->bitmap.rows;
-
- bitSize.cx = realglyph->bitmap.width;
- bitSize.cy = realglyph->bitmap.rows;
- MaskRect.right = realglyph->bitmap.width;
- MaskRect.bottom = realglyph->bitmap.rows;
- if (NULL == Dx)
+ if (Dx == NULL)
{
- TextLeft += realglyph->root.advance.x >> 10;
- DPRINT("New TextLeft: %I64d\n", TextLeft);
+ DeltaX64 += realglyph->root.advance.x >> 10;
+ DeltaY64 -= realglyph->root.advance.y >> 10;
}
else
{
- // FIXME this should probably be a matrix transform with TextTop as well.
+ // FIXME this should probably be a matrix transform with DeltaY64 as well.
Scale = pdcattr->mxWorldToDevice.efM11;
if (FLOATOBJ_Equal0(&Scale))
FLOATOBJ_Set1(&Scale);
/* do the shift before multiplying to preserve precision */
- FLOATOBJ_MulLong(&Scale, Dx[i<<DxShift] << 6);
- TextLeft += FLOATOBJ_GetLong(&Scale);
- DPRINT("New TextLeft2: %I64d\n", TextLeft);
+ FLOATOBJ_MulLong(&Scale, Dx[i << DxShift] << 6);
+ DeltaX64 += FLOATOBJ_GetLong(&Scale);
}
if (DxShift)
{
- TextTop -= Dx[2 * i + 1] << 6;
+ DeltaY64 -= Dx[2 * i + 1] << 6;
}
previous = glyph_index;
- if (EmuBold || EmuItalic)
+ FT_Done_Glyph((FT_Glyph)realglyph);
+ }
+ }
+
+ // Process the X and Y alignments.
+ if ((pdcattr->flTextAlign & TA_CENTER) == TA_CENTER)
+ {
+ XStart64 = -DeltaX64 / 2;
+ YStart64 = -DeltaY64 / 2;
+ }
+ else if ((pdcattr->flTextAlign & TA_RIGHT) == TA_RIGHT)
+ {
+ XStart64 = -DeltaX64;
+ YStart64 = -DeltaY64;
+ }
+ else
+ {
+ XStart64 = YStart64 = 0;
+ }
+
+ psurf = dc->dclevel.pSurface;
+ SurfObj = &psurf->SurfObj ;
+
+ if ((fuOptions & ETO_OPAQUE) && (dc->pdcattr->ulDirty_ & DIRTY_BACKGROUND))
+ DC_vUpdateBackgroundBrush(dc) ;
+
+ if(dc->pdcattr->ulDirty_ & DIRTY_TEXT)
+ DC_vUpdateTextBrush(dc) ;
+
+ thickness = 1;
+ if (face->units_per_EM)
+ {
+ thickness = face->underline_thickness *
+ face->size->metrics.y_ppem / face->units_per_EM;
+ if (thickness <= 0)
+ thickness = 1;
+ }
+
+ /* Process the vertical alignment */
+#define VALIGN_MASK (TA_TOP | TA_BASELINE | TA_BOTTOM)
+ RtlZeroMemory(vecs, sizeof(vecs));
+ if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BASELINE)
+ {
+ vecs[1].y = -FontGDI->tmAscent << 16; // upper left
+ vecs[4].y = 0; // baseline
+ vecs[0].y = FontGDI->tmDescent << 16; // lower left
+ }
+ else if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BOTTOM)
+ {
+ vecs[1].y = -FontGDI->tmHeight << 16; // upper left
+ vecs[4].y = -FontGDI->tmDescent << 16; // baseline
+ vecs[0].y = 0; // lower left
+ }
+ else /* TA_TOP */
+ {
+ vecs[1].y = 0; // upper left
+ vecs[4].y = FontGDI->tmAscent << 16; // baseline
+ vecs[0].y = FontGDI->tmHeight << 16; // lower left
+ }
+ vecs[2] = vecs[1]; // upper right
+ vecs[3] = vecs[0]; // lower right
+#undef VALIGN_MASK
+
+ // underline
+ if (plf->lfUnderline)
+ {
+ int position = 0;
+ if (face->units_per_EM)
+ {
+ position = face->underline_position *
+ face->size->metrics.y_ppem / face->units_per_EM;
+ }
+ vecs[5].y = vecs[6].y = vecs[4].y - (position << 16);
+ }
+
+ // strike through
+ if (plf->lfStrikeOut)
+ {
+ vecs[7].y = vecs[8].y = vecs[4].y - ((FontGDI->tmAscent / 3) << 16);
+ }
+
+ // invert y axis
+ IntEscapeMatrix(&matEscape, -lfEscapement);
+
+ // convert vecs
+ for (i = 0; i < 9; ++i)
+ {
+ POINT pt;
+ FT_Vector_Transform(&vecs[i], &matWidth);
+ FT_Vector_Transform(&vecs[i], &matEscape);
+ vecs[i].x += (Start.x << 16) + (XStart64 << 10);
+ vecs[i].y += (Start.y << 16) + (YStart64 << 10);
+ pt.x = vecs[i].x >> 16;
+ pt.y = vecs[i].y >> 16;
+ IntLPtoDP(dc, &pt, 1);
+ vecs[i].x = pt.x + dc->ptlDCOrig.x;
+ vecs[i].y = pt.y + dc->ptlDCOrig.y;
+ }
+ vecs[2].x += DeltaX64 >> 6;
+ vecs[2].y += DeltaY64 >> 6; // upper right
+ vecs[3].x += DeltaX64 >> 6;
+ vecs[3].y += DeltaY64 >> 6; // lower right
+ vecs[6].x += DeltaX64 >> 6;
+ vecs[6].y += DeltaY64 >> 6; // underline right
+ vecs[8].x += DeltaX64 >> 6;
+ vecs[8].y += DeltaY64 >> 6; // strike through right
+
+ if (fuOptions & ETO_OPAQUE)
+ {
+ /* Draw background */
+ RECTL Rect;
+ RtlZeroMemory(&Rect, sizeof(Rect));
+
+ if ((mat.xy == 0 && mat.yx == 0) || (mat.xx == 0 && mat.yy == 0))
+ {
+ Rect.left = Rect.top = MAXLONG;
+ Rect.right = Rect.bottom = MINLONG;
+ for (i = 0; i < 4; ++i)
{
- FT_Done_Glyph((FT_Glyph)realglyph);
- realglyph = NULL;
+ Rect.left = min(Rect.left, vecs[i].x);
+ Rect.top = min(Rect.top, vecs[i].y);
+ Rect.right = max(Rect.right, vecs[i].x);
+ Rect.bottom = max(Rect.bottom, vecs[i].y);
}
}
+ else
+ {
+ // FIXME: Use vecs[0] ... vecs[3] and EngFillPath
+ }
+
+ if (dc->fs & (DC_ACCUM_APP | DC_ACCUM_WMGR))
+ {
+ IntUpdateBoundsRect(dc, &Rect);
+ }
+
+ if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
+ DC_vUpdateBackgroundBrush(dc);
+ if (dc->dctype == DCTYPE_DIRECT)
+ MouseSafetyOnDrawStart(dc->ppdev, Rect.left, Rect.top, Rect.right, Rect.bottom);
+
+ SourcePoint.x = SourcePoint.y = 0;
+ BrushOrigin.x = BrushOrigin.y = 0;
+
+ psurf = dc->dclevel.pSurface;
+ IntEngBitBlt(
+ &psurf->SurfObj,
+ NULL,
+ NULL,
+ (CLIPOBJ *)&dc->co,
+ NULL,
+ &Rect,
+ &SourcePoint,
+ &SourcePoint,
+ &dc->eboBackground.BrushObject,
+ &BrushOrigin,
+ ROP4_FROM_INDEX(R3_OPINDEX_PATCOPY));
+
+ if (dc->dctype == DCTYPE_DIRECT)
+ MouseSafetyOnDrawEnd(dc->ppdev);
}
EXLATEOBJ_vInitialize(&exloRGB2Dst, &gpalRGB, psurf->ppal, 0, 0, 0);
EXLATEOBJ_vInitialize(&exloDst2RGB, psurf->ppal, &gpalRGB, 0, 0, 0);
- /* Assume success */
+ // The main rendering loop.
bResult = TRUE;
-
- /*
- * The main rendering loop.
- */
- TextLeft = RealXStart;
- TextTop = YStart;
- BackgroundLeft = (RealXStart + 32) >> 6;
+ TextLeft64 = vecs[4].x << 6;
+ TextTop64 = vecs[4].y << 6;
+ previous = 0;
for (i = 0; i < Count; ++i)
{
+ BOOL bNeedCache = (!EmuBold && !EmuItalic &&
+ memcmp(&mat, &identityMat, sizeof(mat)) == 0);
glyph_index = get_glyph_index_flagged(face, String[i], ETO_GLYPH_INDEX, fuOptions);
-
- if (EmuBold || EmuItalic)
- realglyph = NULL;
- else
+ realglyph = NULL;
+ if (bNeedCache)
+ {
realglyph = ftGdiGlyphCacheGet(face, glyph_index, plf->lfHeight,
RenderMode, pmxWorldToDevice);
+ }
if (!realglyph)
{
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
bResult = FALSE;
break;
}
-
glyph = face->glyph;
- if (EmuBold || EmuItalic)
- {
- if (EmuBold)
- FT_GlyphSlot_Embolden(glyph);
- if (EmuItalic)
- FT_GlyphSlot_Oblique(glyph);
- realglyph = ftGdiGlyphSet(face, glyph, RenderMode);
- }
- else
+ if (bNeedCache)
{
realglyph = ftGdiGlyphCacheSet(face,
glyph_index,
glyph,
RenderMode);
}
+ else
+ {
+ if (EmuBold)
+ FT_GlyphSlot_Embolden(glyph);
+ if (EmuItalic)
+ FT_GlyphSlot_Oblique(glyph);
+ realglyph = ftGdiGlyphSet(face, glyph, RenderMode);
+ }
if (!realglyph)
{
DPRINT1("Failed to render glyph! [index: %d]\n", glyph_index);
{
FT_Vector delta;
FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
- TextLeft += delta.x;
+ TextLeft64 += delta.x;
+ TextTop64 -= delta.y;
}
- DPRINT("TextLeft: %I64d\n", TextLeft);
- DPRINT("TextTop: %lu\n", TextTop);
+ DPRINT("TextLeft64: %I64d\n", TextLeft64);
+ DPRINT("TextTop64: %I64d\n", TextTop64);
DPRINT("Advance: %d\n", realglyph->root.advance.x);
- if ((fuOptions & ETO_OPAQUE) && !plf->lfItalic)
- {
- DestRect.left = BackgroundLeft;
- DestRect.right = (TextLeft + (realglyph->root.advance.x >> 10) + 32) >> 6;
- DestRect.top = TextTop + yoff - ((fixAscender + 32) >> 6);
- DestRect.bottom = DestRect.top + ((fixAscender + fixDescender) >> 6);
-
- if (dc->dctype == DCTYPE_DIRECT)
- MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom);
-
- if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
- {
- IntUpdateBoundsRect(dc, &DestRect);
- }
- IntEngBitBlt(
- &psurf->SurfObj,
- NULL,
- NULL,
- (CLIPOBJ *)&dc->co,
- NULL,
- &DestRect,
- &SourcePoint,
- &SourcePoint,
- &dc->eboBackground.BrushObject,
- &BrushOrigin,
- ROP4_FROM_INDEX(R3_OPINDEX_PATCOPY));
-
- if (dc->dctype == DCTYPE_DIRECT)
- MouseSafetyOnDrawEnd(dc->ppdev);
-
- BackgroundLeft = DestRect.right;
- }
-
- DestRect.left = ((TextLeft + 32) >> 6) + realglyph->left;
+ DestRect.left = ((TextLeft64 + 32) >> 6) + realglyph->left;
DestRect.right = DestRect.left + realglyph->bitmap.width;
- DestRect.top = TextTop + yoff - realglyph->top;
+ DestRect.top = ((TextTop64 + 32) >> 6) - realglyph->top;
DestRect.bottom = DestRect.top + realglyph->bitmap.rows;
bitSize.cx = realglyph->bitmap.width;
if ( !HSourceGlyph )
{
DPRINT1("WARNING: EngCreateBitmap() failed!\n");
- // FT_Done_Glyph(realglyph);
bResult = FALSE;
+ if (EmuBold || EmuItalic)
+ {
+ FT_Done_Glyph((FT_Glyph)realglyph);
+ }
+
break;
}
SourceGlyphSurf = EngLockSurface((HSURF)HSourceGlyph);
EngDeleteSurface((HSURF)HSourceGlyph);
DPRINT1("WARNING: EngLockSurface() failed!\n");
bResult = FALSE;
+ if (EmuBold || EmuItalic)
+ {
+ FT_Done_Glyph((FT_Glyph)realglyph);
+ }
+
break;
}
if (DoBreak)
{
- break;
- }
-
- if (plf->lfUnderline)
- {
- int i, position;
- if (!face->units_per_EM)
- {
- position = 0;
- }
- else
- {
- position = face->underline_position *
- face->size->metrics.y_ppem / face->units_per_EM;
- }
- for (i = -thickness / 2; i < -thickness / 2 + thickness; ++i)
- {
- EngLineTo(SurfObj,
- (CLIPOBJ *)&dc->co,
- &dc->eboText.BrushObject,
- (TextLeft >> 6),
- TextTop + yoff - position + i,
- ((TextLeft + (realglyph->root.advance.x >> 10)) >> 6),
- TextTop + yoff - position + i,
- NULL,
- ROP2_TO_MIX(R2_COPYPEN));
- }
- }
- if (plf->lfStrikeOut)
- {
- int i;
- for (i = -thickness / 2; i < -thickness / 2 + thickness; ++i)
+ if (EmuBold || EmuItalic)
{
- EngLineTo(SurfObj,
- (CLIPOBJ *)&dc->co,
- &dc->eboText.BrushObject,
- (TextLeft >> 6),
- TextTop + yoff - (fixAscender >> 6) / 3 + i,
- ((TextLeft + (realglyph->root.advance.x >> 10)) >> 6),
- TextTop + yoff - (fixAscender >> 6) / 3 + i,
- NULL,
- ROP2_TO_MIX(R2_COPYPEN));
+ FT_Done_Glyph((FT_Glyph)realglyph);
}
+
+ break;
}
if (NULL == Dx)
{
- TextLeft += realglyph->root.advance.x >> 10;
- DPRINT("New TextLeft: %I64d\n", TextLeft);
+ TextLeft64 += realglyph->root.advance.x >> 10;
+ TextTop64 -= realglyph->root.advance.y >> 10;
+ DPRINT("New TextLeft64: %I64d\n", TextLeft64);
+ DPRINT("New TextTop64: %I64d\n", TextTop64);
}
else
{
- // FIXME this should probably be a matrix transform with TextTop as well.
+ // FIXME this should probably be a matrix transform with TextTop64 as well.
Scale = pdcattr->mxWorldToDevice.efM11;
if (FLOATOBJ_Equal0(&Scale))
FLOATOBJ_Set1(&Scale);
/* do the shift before multiplying to preserve precision */
FLOATOBJ_MulLong(&Scale, Dx[i<<DxShift] << 6);
- TextLeft += FLOATOBJ_GetLong(&Scale);
- DPRINT("New TextLeft2: %I64d\n", TextLeft);
+ TextLeft64 += FLOATOBJ_GetLong(&Scale);
+ DPRINT("New TextLeft64 2: %I64d\n", TextLeft64);
}
if (DxShift)
{
- TextTop -= Dx[2 * i + 1] << 6;
+ TextTop64 -= Dx[2 * i + 1] << 6;
}
previous = glyph_index;
- if (EmuBold || EmuItalic)
+ /* No cache, so clean up */
+ if (!bNeedCache)
{
FT_Done_Glyph((FT_Glyph)realglyph);
- realglyph = NULL;
}
}
- if (pdcattr->lTextAlign & TA_UPDATECP) {
+ if (plf->lfUnderline || plf->lfStrikeOut)
+ {
+ INT x0 = min(vecs[0].x, vecs[2].x);
+ INT y0 = min(vecs[0].y, vecs[2].y);
+ INT x1 = max(vecs[0].x, vecs[2].x);
+ INT y1 = max(vecs[0].y, vecs[2].y);
+ if (dc->dctype == DCTYPE_DIRECT)
+ MouseSafetyOnDrawStart(dc->ppdev, x0, y0, x1, y1);
+ }
+
+ if (plf->lfUnderline)
+ {
+ for (i = -thickness / 2; i < -thickness / 2 + thickness; ++i)
+ {
+ LONG dx = (LONG)(DeltaX64 >> 6), dy = (LONG)(DeltaY64 >> 6);
+ if (labs(dx) > labs(dy))
+ {
+ // move vertical
+ EngLineTo(SurfObj, (CLIPOBJ *)&dc->co,
+ &dc->eboText.BrushObject,
+ vecs[5].x, vecs[5].y + i,
+ vecs[6].x, vecs[6].y + i,
+ NULL, ROP2_TO_MIX(R2_COPYPEN));
+ }
+ else
+ {
+ // move horizontal
+ EngLineTo(SurfObj, (CLIPOBJ *)&dc->co,
+ &dc->eboText.BrushObject,
+ vecs[5].x + i, vecs[5].y,
+ vecs[6].x + i, vecs[6].y,
+ NULL, ROP2_TO_MIX(R2_COPYPEN));
+ }
+ }
+ }
+
+ if (plf->lfStrikeOut)
+ {
+ for (i = -thickness / 2; i < -thickness / 2 + thickness; ++i)
+ {
+ LONG dx = (LONG)(DeltaX64 >> 6), dy = (LONG)(DeltaY64 >> 6);
+ if (labs(dx) > labs(dy))
+ {
+ // move vertical
+ EngLineTo(SurfObj, (CLIPOBJ *)&dc->co,
+ &dc->eboText.BrushObject,
+ vecs[7].x, vecs[7].y + i,
+ vecs[8].x, vecs[8].y + i,
+ NULL, ROP2_TO_MIX(R2_COPYPEN));
+ }
+ else
+ {
+ // move horizontal
+ EngLineTo(SurfObj, (CLIPOBJ *)&dc->co,
+ &dc->eboText.BrushObject,
+ vecs[7].x + i, vecs[7].y,
+ vecs[8].x + i, vecs[8].y,
+ NULL, ROP2_TO_MIX(R2_COPYPEN));
+ }
+ }
+ }
+
+ if (plf->lfUnderline || plf->lfStrikeOut)
+ {
+ if (dc->dctype == DCTYPE_DIRECT)
+ MouseSafetyOnDrawEnd(dc->ppdev);
+ }
+
+ if (pdcattr->flTextAlign & TA_UPDATECP) {
pdcattr->ptlCurrent.x = DestRect.right - dc->ptlDCOrig.x;
}
if (TextObj != NULL)
TEXTOBJ_UnlockText(TextObj);
+ return bResult;
+}
+
+
+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 bResult;
+ DC *dc;
+
+ // TODO: Write test-cases to exactly match real Windows in different
+ // bad parameters (e.g. does Windows check the DC or the RECT first?).
+ dc = DC_LockDc(hDC);
+ if (!dc)
+ {
+ EngSetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ bResult = IntExtTextOutW( dc,
+ XStart,
+ YStart,
+ fuOptions,
+ lprc,
+ String,
+ Count,
+ Dx,
+ dwCodePage );
+
DC_UnlockDc(dc);
return bResult;
FT_Face Face = FontGDI->SharedFace->Face;
if (FT_IS_SFNT(Face))
{
- TT_OS2 *pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
+ TT_OS2 *pOS2;
+
+ IntLockFreeType();
+ pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2);
DefChar = (pOS2->usDefaultChar ? get_glyph_index(Face, pOS2->usDefaultChar) : 0);
+ IntUnLockFreeType();
}
else
{