[NTGDI][FREETYPE] lfEscapement for TextOut (#4920)

Rotation and shearing transformation of font/text is now available. Retrial of PR #1207.
- Rename ftGdiGetTextWidth as IntGetTextDisposition and add a Y parameter.
- Apply lfEscapement values (by multiplying matrices).
- Add IntEngFillPolygon and IntEngFillBox helper functions.
CORE-11848
This commit is contained in:
Katayama Hirofumi MZ 2022-12-03 13:03:28 +09:00 committed by GitHub
parent e7bbbf049e
commit e316d61215
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,6 +48,7 @@
extern const MATRIX gmxWorldToDeviceDefault; extern const MATRIX gmxWorldToDeviceDefault;
extern const MATRIX gmxWorldToPageDefault; extern const MATRIX gmxWorldToPageDefault;
static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)}; static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)};
static POINTL PointZero = { 0, 0 };
/* HACK!! Fix XFORMOBJ then use 1:16 / 16:1 */ /* HACK!! Fix XFORMOBJ then use 1:16 / 16:1 */
#define gmxWorldToDeviceDefault gmxWorldToPageDefault #define gmxWorldToDeviceDefault gmxWorldToPageDefault
@ -711,7 +712,7 @@ static LONG IntNormalizeAngle(LONG nTenthsOfDegrees)
return nTenthsOfDegrees + 360 * 10; return nTenthsOfDegrees + 360 * 10;
} }
VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement) static VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
{ {
FT_Vector vecAngle; FT_Vector vecAngle;
/* Convert the angle in tenths of degrees into degrees as a 16.16 fixed-point value */ /* Convert the angle in tenths of degrees into degrees as a 16.16 fixed-point value */
@ -723,7 +724,7 @@ VOID FASTCALL IntEscapeMatrix(FT_Matrix *pmat, LONG lfEscapement)
pmat->yy = pmat->xx; pmat->yy = pmat->xx;
} }
VOID FASTCALL static VOID FASTCALL
FtMatrixFromMx(FT_Matrix *pmat, const MATRIX *pmx) FtMatrixFromMx(FT_Matrix *pmat, const MATRIX *pmx)
{ {
FLOATOBJ ef; FLOATOBJ ef;
@ -3562,10 +3563,20 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
EmHeight = max(EmHeight, 1); EmHeight = max(EmHeight, 1);
EmHeight = min(EmHeight, USHORT_MAX); EmHeight = min(EmHeight, USHORT_MAX);
if (pOS2 && lfWidth > 0) #if 1
/* I think this is wrong implementation but its test result is better. */
if (lfWidth != 0)
Width64 = FT_MulDiv(lfWidth, face->units_per_EM, pOS2->xAvgCharWidth) << 6; Width64 = FT_MulDiv(lfWidth, face->units_per_EM, pOS2->xAvgCharWidth) << 6;
else else
Width64 = 0; Width64 = 0;
#else
/* I think this is correct implementation but it is mismatching to the
other metric functions. The test result is bad. */
if (lfWidth != 0)
Width64 = (FT_MulDiv(lfWidth, 96 * 5, 72 * 3) << 6); /* ??? FIXME */
else
Width64 = 0;
#endif
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = Width64; req.width = Width64;
@ -5855,17 +5866,22 @@ ScaleLong(LONG lValue, PFLOATOBJ pef)
return lValue; return lValue;
} }
/* Calculate width of the text. */ /*
* Calculate X and Y disposition of the text.
* NOTE: The disposition can be negative.
*/
static BOOL static BOOL
ftGdiGetTextWidth( IntGetTextDisposition(
LONGLONG *pTextWidth64, OUT LONGLONG *pX64,
LPCWSTR String, OUT LONGLONG *pY64,
INT Count, IN LPCWSTR String,
PFONT_CACHE_ENTRY Cache, IN INT Count,
UINT fuOptions) IN OPTIONAL LPINT Dx,
IN OUT PFONT_CACHE_ENTRY Cache,
IN UINT fuOptions)
{ {
LONGLONG TextLeft64 = 0; LONGLONG X64 = 0, Y64 = 0;
INT glyph_index; INT i, glyph_index;
FT_BitmapGlyph realglyph; FT_BitmapGlyph realglyph;
FT_Face face = Cache->Hashed.Face; FT_Face face = Cache->Hashed.Face;
BOOL use_kerning = FT_HAS_KERNING(face); BOOL use_kerning = FT_HAS_KERNING(face);
@ -5874,9 +5890,9 @@ ftGdiGetTextWidth(
ASSERT_FREETYPE_LOCK_HELD(); ASSERT_FREETYPE_LOCK_HELD();
while (Count-- > 0) for (i = 0; i < Count; ++i)
{ {
glyph_index = get_glyph_index_flagged(face, *String, ETO_GLYPH_INDEX, fuOptions); glyph_index = get_glyph_index_flagged(face, *String++, ETO_GLYPH_INDEX, fuOptions);
Cache->Hashed.GlyphIndex = glyph_index; Cache->Hashed.GlyphIndex = glyph_index;
realglyph = ftGdiGetRealGlyph(Cache); realglyph = ftGdiGetRealGlyph(Cache);
@ -5887,22 +5903,123 @@ ftGdiGetTextWidth(
if (use_kerning && previous && glyph_index) if (use_kerning && previous && glyph_index)
{ {
FT_Get_Kerning(face, previous, glyph_index, 0, &delta); FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
TextLeft64 += delta.x; X64 += delta.x;
Y64 -= delta.y;
} }
TextLeft64 += realglyph->root.advance.x >> 10; if (NULL == Dx)
{
X64 += realglyph->root.advance.x >> 10;
Y64 -= realglyph->root.advance.y >> 10;
}
else if (fuOptions & ETO_PDY)
{
FT_Vector vec = { Dx[2 * i + 0] << 6, Dx[2 * i + 1] << 6 };
FT_Vector_Transform(&vec, &Cache->Hashed.matTransform);
X64 += vec.x;
Y64 -= vec.y;
}
else
{
FT_Vector vec = { Dx[i] << 6, 0 };
FT_Vector_Transform(&vec, &Cache->Hashed.matTransform);
X64 += vec.x;
Y64 -= vec.y;
}
if (Cache->Hashed.Aspect.EmuBoldItalic) if (Cache->Hashed.Aspect.EmuBoldItalic)
FT_Done_Glyph((FT_Glyph)realglyph); FT_Done_Glyph((FT_Glyph)realglyph);
previous = glyph_index; previous = glyph_index;
String++;
} }
*pTextWidth64 = TextLeft64; *pX64 = X64;
*pY64 = Y64;
return TRUE; return TRUE;
} }
VOID APIENTRY
IntEngFillPolygon(
IN OUT PDC dc,
IN POINTL *pPoints,
IN UINT cPoints,
IN BRUSHOBJ *BrushObj)
{
SURFACE *psurf = dc->dclevel.pSurface;
RECT Rect;
UINT i;
INT x, y;
ASSERT_DC_PREPARED(dc);
ASSERT(psurf != NULL);
Rect.left = Rect.right = pPoints[0].x;
Rect.top = Rect.bottom = pPoints[0].y;
for (i = 1; i < cPoints; ++i)
{
x = pPoints[i].x;
if (x < Rect.left)
Rect.left = x;
else if (Rect.right < x)
Rect.right = x;
y = pPoints[i].y;
if (y < Rect.top)
Rect.top = y;
else if (Rect.bottom < y)
Rect.bottom = y;
}
IntFillPolygon(dc, dc->dclevel.pSurface, BrushObj, pPoints, cPoints, Rect, &PointZero);
}
VOID
FASTCALL
IntEngFillBox(
IN OUT PDC dc,
IN INT X,
IN INT Y,
IN INT Width,
IN INT Height,
IN BRUSHOBJ *BrushObj)
{
RECTL DestRect;
SURFACE *psurf = dc->dclevel.pSurface;
ASSERT_DC_PREPARED(dc);
ASSERT(psurf != NULL);
if (Width < 0)
{
X += Width;
Width = -Width;
}
if (Height < 0)
{
Y += Height;
Height = -Height;
}
DestRect.left = X;
DestRect.right = X + Width;
DestRect.top = Y;
DestRect.bottom = Y + Height;
IntEngBitBlt(&psurf->SurfObj,
NULL,
NULL,
(CLIPOBJ *)&dc->co,
NULL,
&DestRect,
NULL,
NULL,
BrushObj,
&PointZero,
ROP4_FROM_INDEX(R3_OPINDEX_PATCOPY));
}
BOOL BOOL
APIENTRY APIENTRY
IntExtTextOutW( IntExtTextOutW(
@ -5925,13 +6042,12 @@ IntExtTextOutW(
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
SURFOBJ *SurfObj, *SourceGlyphSurf; SURFOBJ *SurfObj, *SourceGlyphSurf;
SURFACE *psurf; SURFACE *psurf;
INT glyph_index, i, yoff; INT glyph_index, i;
FT_Face face; FT_Face face;
FT_BitmapGlyph realglyph; FT_BitmapGlyph realglyph;
LONGLONG TextLeft64, RealXStart64, TextWidth64; LONGLONG X64, Y64, RealXStart64, RealYStart64, DeltaX64, DeltaY64;
ULONG TextTop, previous; ULONG previous;
RECTL DestRect, MaskRect; RECTL DestRect, MaskRect;
POINTL SourcePoint, BrushOrigin;
HBITMAP HSourceGlyph; HBITMAP HSourceGlyph;
SIZEL bitSize; SIZEL bitSize;
FONTOBJ *FontObj; FONTOBJ *FontObj;
@ -5939,14 +6055,12 @@ IntExtTextOutW(
PTEXTOBJ TextObj; PTEXTOBJ TextObj;
EXLATEOBJ exloRGB2Dst, exloDst2RGB; EXLATEOBJ exloRGB2Dst, exloDst2RGB;
POINT Start; POINT Start;
USHORT DxShift;
PMATRIX pmxWorldToDevice; PMATRIX pmxWorldToDevice;
LONG fixAscender, fixDescender; FT_Vector delta, vecAscent64, vecDescent64;
FLOATOBJ Scale;
LOGFONTW *plf; LOGFONTW *plf;
BOOL use_kerning, bResult, DoBreak; BOOL use_kerning, bResult, DoBreak;
FT_Vector delta;
FONT_CACHE_ENTRY Cache; FONT_CACHE_ENTRY Cache;
FT_Matrix mat;
/* Check if String is valid */ /* Check if String is valid */
if (Count > 0xFFFF || (Count > 0 && String == NULL)) if (Count > 0xFFFF || (Count > 0 && String == NULL))
@ -5974,11 +6088,6 @@ IntExtTextOutW(
goto Cleanup; goto Cleanup;
} }
if (lprc && (fuOptions & (ETO_OPAQUE | ETO_CLIPPED)))
{
IntLPtoDP(dc, (POINT *)lprc, 2);
}
pdcattr = dc->pdcattr; pdcattr = dc->pdcattr;
if (pdcattr->flTextAlign & TA_UPDATECP) if (pdcattr->flTextAlign & TA_UPDATECP)
{ {
@ -5993,53 +6102,37 @@ IntExtTextOutW(
IntLPtoDP(dc, &Start, 1); IntLPtoDP(dc, &Start, 1);
RealXStart64 = ((LONGLONG)Start.x + dc->ptlDCOrig.x) << 6; RealXStart64 = ((LONGLONG)Start.x + dc->ptlDCOrig.x) << 6;
YStart = Start.y + dc->ptlDCOrig.y; RealYStart64 = ((LONGLONG)Start.y + dc->ptlDCOrig.y) << 6;
SourcePoint.x = 0;
SourcePoint.y = 0;
MaskRect.left = 0; MaskRect.left = 0;
MaskRect.top = 0; MaskRect.top = 0;
BrushOrigin.x = 0;
BrushOrigin.y = 0;
psurf = dc->dclevel.pSurface; psurf = dc->dclevel.pSurface;
SurfObj = &psurf->SurfObj; SurfObj = &psurf->SurfObj;
if (pdcattr->iGraphicsMode == GM_ADVANCED)
pmxWorldToDevice = DC_pmxWorldToDevice(dc);
else
pmxWorldToDevice = (PMATRIX)&gmxWorldToDeviceDefault;
if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
DC_vUpdateBackgroundBrush(dc);
if (lprc && (fuOptions & (ETO_CLIPPED | ETO_OPAQUE)))
{
IntLPtoDP(dc, (POINT*)lprc, 2);
lprc->left += dc->ptlDCOrig.x;
lprc->top += dc->ptlDCOrig.y;
lprc->right += dc->ptlDCOrig.x;
lprc->bottom += dc->ptlDCOrig.y;
}
if (lprc && (fuOptions & ETO_OPAQUE)) if (lprc && (fuOptions & ETO_OPAQUE))
{ {
RtlCopyMemory(&DestRect, lprc, sizeof(DestRect)); IntEngFillBox(dc,
lprc->left, lprc->top,
DestRect.left += dc->ptlDCOrig.x; lprc->right - lprc->left, lprc->bottom - lprc->top,
DestRect.top += dc->ptlDCOrig.y; &dc->eboBackground.BrushObject);
DestRect.right += dc->ptlDCOrig.x;
DestRect.bottom += dc->ptlDCOrig.y;
if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(dc, &DestRect);
}
if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
DC_vUpdateBackgroundBrush(dc);
if (dc->dctype == DCTYPE_DIRECT)
MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom);
IntEngBitBlt(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);
fuOptions &= ~ETO_OPAQUE; fuOptions &= ~ETO_OPAQUE;
} }
else else
@ -6083,36 +6176,41 @@ IntExtTextOutW(
goto Cleanup; goto Cleanup;
} }
/* NOTE: Don't trust face->size->metrics.ascender and descender values. */ /* Apply lfEscapement */
if (pdcattr->iGraphicsMode == GM_ADVANCED) if (FT_IS_SCALABLE(face) && plf->lfEscapement != 0)
{ IntEscapeMatrix(&Cache.Hashed.matTransform, plf->lfEscapement);
pmxWorldToDevice = DC_pmxWorldToDevice(dc);
FtMatrixFromMx(&Cache.Hashed.matTransform, pmxWorldToDevice);
FT_Set_Transform(face, &Cache.Hashed.matTransform, NULL);
fixAscender = ScaleLong(FontGDI->tmAscent, &pmxWorldToDevice->efM22) << 6;
fixDescender = ScaleLong(FontGDI->tmDescent, &pmxWorldToDevice->efM22) << 6;
}
else else
{ Cache.Hashed.matTransform = identityMat;
pmxWorldToDevice = (PMATRIX)&gmxWorldToDeviceDefault;
FtMatrixFromMx(&Cache.Hashed.matTransform, pmxWorldToDevice);
FT_Set_Transform(face, &Cache.Hashed.matTransform, NULL);
fixAscender = FontGDI->tmAscent << 6; /* Apply the world transformation */
fixDescender = FontGDI->tmDescent << 6; FtMatrixFromMx(&mat, pmxWorldToDevice);
} FT_Matrix_Multiply(&mat, &Cache.Hashed.matTransform);
FT_Set_Transform(face, &Cache.Hashed.matTransform, NULL);
/* /* Calculate the ascent point and the descent point */
* Process the vertical alignment and determine the yoff. vecAscent64.x = 0;
*/ vecAscent64.y = (FontGDI->tmAscent << 6);
FT_Vector_Transform(&vecAscent64, &Cache.Hashed.matTransform);
vecDescent64.x = 0;
vecDescent64.y = -(FontGDI->tmDescent << 6);
FT_Vector_Transform(&vecDescent64, &Cache.Hashed.matTransform);
/* Process the vertical alignment and fix the real starting point. */
#define VALIGN_MASK (TA_TOP | TA_BASELINE | TA_BOTTOM) #define VALIGN_MASK (TA_TOP | TA_BASELINE | TA_BOTTOM)
if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BASELINE) if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BASELINE)
yoff = 0; {
NOTHING;
}
else if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BOTTOM) else if ((pdcattr->flTextAlign & VALIGN_MASK) == TA_BOTTOM)
yoff = -(fixDescender >> 6); {
RealXStart64 -= vecDescent64.x;
RealYStart64 += vecDescent64.y;
}
else /* TA_TOP */ else /* TA_TOP */
yoff = fixAscender >> 6; {
RealXStart64 -= vecAscent64.x;
RealYStart64 += vecAscent64.y;
}
#undef VALIGN_MASK #undef VALIGN_MASK
use_kerning = FT_HAS_KERNING(face); use_kerning = FT_HAS_KERNING(face);
@ -6120,7 +6218,7 @@ IntExtTextOutW(
/* Calculate the text width if necessary */ /* Calculate the text width if necessary */
if ((fuOptions & ETO_OPAQUE) || (pdcattr->flTextAlign & (TA_CENTER | TA_RIGHT))) if ((fuOptions & ETO_OPAQUE) || (pdcattr->flTextAlign & (TA_CENTER | TA_RIGHT)))
{ {
if (!ftGdiGetTextWidth(&TextWidth64, String, Count, &Cache, fuOptions)) if (!IntGetTextDisposition(&DeltaX64, &DeltaY64, String, Count, Dx, &Cache, fuOptions))
{ {
IntUnLockFreeType(); IntUnLockFreeType();
bResult = FALSE; bResult = FALSE;
@ -6129,44 +6227,41 @@ IntExtTextOutW(
/* Adjust the horizontal position by horizontal alignment */ /* Adjust the horizontal position by horizontal alignment */
if ((pdcattr->flTextAlign & TA_CENTER) == TA_CENTER) if ((pdcattr->flTextAlign & TA_CENTER) == TA_CENTER)
RealXStart64 -= TextWidth64 / 2; {
RealXStart64 -= DeltaX64 / 2;
RealYStart64 -= DeltaY64 / 2;
}
else if ((pdcattr->flTextAlign & TA_RIGHT) == TA_RIGHT) else if ((pdcattr->flTextAlign & TA_RIGHT) == TA_RIGHT)
RealXStart64 -= TextWidth64; {
RealXStart64 -= DeltaX64;
RealYStart64 -= DeltaY64;
}
/* Fill background */ /* Fill background */
if (fuOptions & ETO_OPAQUE) if (fuOptions & ETO_OPAQUE)
{ {
DestRect.left = (RealXStart64 + 32) >> 6; INT X0 = (RealXStart64 + vecAscent64.x + 32) >> 6;
DestRect.right = (RealXStart64 + TextWidth64 + 32) >> 6; INT Y0 = (RealYStart64 - vecAscent64.y + 32) >> 6;
DestRect.top = YStart; INT DX = (DeltaX64 >> 6);
DestRect.bottom = YStart + ((fixAscender + fixDescender) >> 6); if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
if (dc->fs & (DC_ACCUM_APP | DC_ACCUM_WMGR))
IntUpdateBoundsRect(dc, &DestRect);
if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
DC_vUpdateBackgroundBrush(dc);
if (dc->dctype == DCTYPE_DIRECT)
{ {
MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, INT CY = (vecAscent64.y - vecDescent64.y + 32) >> 6;
DestRect.right, DestRect.bottom); IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboBackground.BrushObject);
}
else
{
INT DY = (DeltaY64 >> 6);
INT X1 = ((RealXStart64 + vecDescent64.x + 32) >> 6);
INT Y1 = ((RealYStart64 - vecDescent64.y + 32) >> 6);
POINT Points[4] =
{
{ X0, Y0 },
{ X0 + DX, Y0 + DY },
{ X1 + DX, Y1 + DY },
{ X1, Y1 },
};
IntEngFillPolygon(dc, Points, 4, &dc->eboBackground.BrushObject);
} }
IntEngBitBlt(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);
} }
} }
@ -6182,9 +6277,8 @@ IntExtTextOutW(
/* /*
* The main rendering loop. * The main rendering loop.
*/ */
TextLeft64 = RealXStart64; X64 = RealXStart64;
TextTop = YStart; Y64 = RealYStart64;
DxShift = (fuOptions & ETO_PDY) ? 1 : 0;
previous = 0; previous = 0;
DoBreak = FALSE; DoBreak = FALSE;
for (i = 0; i < Count; ++i) for (i = 0; i < Count; ++i)
@ -6203,12 +6297,12 @@ IntExtTextOutW(
if (use_kerning && previous && glyph_index && NULL == Dx) if (use_kerning && previous && glyph_index && NULL == Dx)
{ {
FT_Get_Kerning(face, previous, glyph_index, 0, &delta); FT_Get_Kerning(face, previous, glyph_index, 0, &delta);
TextLeft64 += delta.x; X64 += delta.x;
Y64 -= delta.y;
} }
DPRINT("TextLeft64: %I64d\n", TextLeft64); DPRINT("X64, Y64: %I64d, %I64d\n", X64, Y64);
DPRINT("TextTop: %lu\n", TextTop); DPRINT("Advance: %d, %d\n", realglyph->root.advance.x, realglyph->root.advance.y);
DPRINT("Advance: %d\n", realglyph->root.advance.x);
bitSize.cx = realglyph->bitmap.width; bitSize.cx = realglyph->bitmap.width;
bitSize.cy = realglyph->bitmap.rows; bitSize.cy = realglyph->bitmap.rows;
@ -6216,9 +6310,9 @@ IntExtTextOutW(
MaskRect.right = realglyph->bitmap.width; MaskRect.right = realglyph->bitmap.width;
MaskRect.bottom = realglyph->bitmap.rows; MaskRect.bottom = realglyph->bitmap.rows;
DestRect.left = ((TextLeft64 + 32) >> 6) + realglyph->left; DestRect.left = ((X64 + 32) >> 6) + realglyph->left;
DestRect.right = DestRect.left + bitSize.cx; DestRect.right = DestRect.left + bitSize.cx;
DestRect.top = TextTop + yoff - realglyph->top; DestRect.top = ((Y64 + 32) >> 6) - realglyph->top;
DestRect.bottom = DestRect.top + bitSize.cy; DestRect.bottom = DestRect.top + bitSize.cy;
/* Check if the bitmap has any pixels */ /* Check if the bitmap has any pixels */
@ -6261,21 +6355,18 @@ IntExtTextOutW(
// We do the check '>=' instead of '>' to possibly save an iteration // We do the check '>=' instead of '>' to possibly save an iteration
// through this loop, since it's breaking after the drawing is done, // through this loop, since it's breaking after the drawing is done,
// and x is always incremented. // and x is always incremented.
if (DestRect.right >= lprc->right + dc->ptlDCOrig.x) if (DestRect.right >= lprc->right)
{ {
DestRect.right = lprc->right + dc->ptlDCOrig.x; DestRect.right = lprc->right;
DoBreak = TRUE; DoBreak = TRUE;
} }
if (DestRect.bottom >= lprc->bottom + dc->ptlDCOrig.y) if (DestRect.bottom >= lprc->bottom)
{ {
DestRect.bottom = lprc->bottom + dc->ptlDCOrig.y; DestRect.bottom = lprc->bottom;
} }
} }
if (dc->dctype == DCTYPE_DIRECT)
MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom);
if (!IntEngMaskBlt(SurfObj, if (!IntEngMaskBlt(SurfObj,
SourceGlyphSurf, SourceGlyphSurf,
(CLIPOBJ *)&dc->co, (CLIPOBJ *)&dc->co,
@ -6284,14 +6375,11 @@ IntExtTextOutW(
&DestRect, &DestRect,
(PPOINTL)&MaskRect, (PPOINTL)&MaskRect,
&dc->eboText.BrushObject, &dc->eboText.BrushObject,
&BrushOrigin)) &PointZero))
{ {
DPRINT1("Failed to MaskBlt a glyph!\n"); DPRINT1("Failed to MaskBlt a glyph!\n");
} }
if (dc->dctype == DCTYPE_DIRECT)
MouseSafetyOnDrawEnd(dc->ppdev) ;
EngUnlockSurface(SourceGlyphSurf); EngUnlockSurface(SourceGlyphSurf);
EngDeleteSurface((HSURF)HSourceGlyph); EngDeleteSurface((HSURF)HSourceGlyph);
} }
@ -6305,26 +6393,25 @@ IntExtTextOutW(
if (NULL == Dx) if (NULL == Dx)
{ {
TextLeft64 += realglyph->root.advance.x >> 10; X64 += realglyph->root.advance.x >> 10;
DPRINT("New TextLeft64: %I64d\n", TextLeft64); Y64 -= realglyph->root.advance.y >> 10;
}
else if (fuOptions & ETO_PDY)
{
FT_Vector vec = { Dx[2 * i + 0] << 6, Dx[2 * i + 1] << 6 };
FT_Vector_Transform(&vec, &Cache.Hashed.matTransform);
X64 += vec.x;
Y64 -= vec.y;
} }
else else
{ {
// FIXME this should probably be a matrix transform with TextTop as well. FT_Vector vec = { Dx[i] << 6, 0 };
Scale = pdcattr->mxWorldToDevice.efM11; FT_Vector_Transform(&vec, &Cache.Hashed.matTransform);
if (FLOATOBJ_Equal0(&Scale)) X64 += vec.x;
FLOATOBJ_Set1(&Scale); Y64 -= vec.y;
/* do the shift before multiplying to preserve precision */
FLOATOBJ_MulLong(&Scale, Dx[i<<DxShift] << 6);
TextLeft64 += FLOATOBJ_GetLong(&Scale);
DPRINT("New TextLeft64 2: %I64d\n", TextLeft64);
} }
if (DxShift) DPRINT("New X64, New Y64: %I64d, %I64d\n", X64, Y64);
{
TextTop -= Dx[2 * i + 1] << 6;
}
previous = glyph_index; previous = glyph_index;
@ -6340,7 +6427,11 @@ IntExtTextOutW(
if (plf->lfUnderline || plf->lfStrikeOut) /* Underline or strike-out? */ if (plf->lfUnderline || plf->lfStrikeOut) /* Underline or strike-out? */
{ {
/* Calculate the position and the thickness */ /* Calculate the position and the thickness */
INT i, underline_position, thickness; INT underline_position, thickness;
FT_Vector vecA64, vecB64;
DeltaX64 = X64 - RealXStart64;
DeltaY64 = Y64 - RealYStart64;
if (!face->units_per_EM) if (!face->units_per_EM)
{ {
@ -6359,33 +6450,69 @@ IntExtTextOutW(
if (plf->lfUnderline) /* Draw underline */ if (plf->lfUnderline) /* Draw underline */
{ {
for (i = -thickness / 2; i < -thickness / 2 + thickness; ++i) vecA64.x = 0;
vecA64.y = (-underline_position - thickness / 2) << 6;
vecB64.x = 0;
vecB64.y = vecA64.y + (thickness << 6);
FT_Vector_Transform(&vecA64, &Cache.Hashed.matTransform);
FT_Vector_Transform(&vecB64, &Cache.Hashed.matTransform);
{ {
EngLineTo(SurfObj, INT X0 = (RealXStart64 - vecA64.x + 32) >> 6;
(CLIPOBJ *)&dc->co, INT Y0 = (RealYStart64 + vecA64.y + 32) >> 6;
&dc->eboText.BrushObject, INT DX = (DeltaX64 >> 6);
(RealXStart64 + 32) >> 6, if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
TextTop + yoff - underline_position + i, {
(TextLeft64 + 32) >> 6, INT CY = (vecB64.y - vecA64.y + 32) >> 6;
TextTop + yoff - underline_position + i, IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboText.BrushObject);
NULL, }
ROP2_TO_MIX(R2_COPYPEN)); else
{
INT DY = (DeltaY64 >> 6);
INT X1 = X0 + ((vecA64.x - vecB64.x + 32) >> 6);
INT Y1 = Y0 + ((vecB64.y - vecA64.y + 32) >> 6);
POINT Points[4] =
{
{ X0, Y0 },
{ X0 + DX, Y0 + DY },
{ X1 + DX, Y1 + DY },
{ X1, Y1 },
};
IntEngFillPolygon(dc, Points, 4, &dc->eboText.BrushObject);
}
} }
} }
if (plf->lfStrikeOut) /* Draw strike-out */ if (plf->lfStrikeOut) /* Draw strike-out */
{ {
for (i = -thickness / 2; i < -thickness / 2 + thickness; ++i) vecA64.x = 0;
vecA64.y = -(FontGDI->tmAscent << 6) / 3;
vecB64.x = 0;
vecB64.y = vecA64.y + (thickness << 6);
FT_Vector_Transform(&vecA64, &Cache.Hashed.matTransform);
FT_Vector_Transform(&vecB64, &Cache.Hashed.matTransform);
{ {
EngLineTo(SurfObj, INT X0 = (RealXStart64 - vecA64.x + 32) >> 6;
(CLIPOBJ *)&dc->co, INT Y0 = (RealYStart64 + vecA64.y + 32) >> 6;
&dc->eboText.BrushObject, INT DX = (DeltaX64 >> 6);
(RealXStart64 + 32) >> 6, if (Cache.Hashed.matTransform.xy == 0 && Cache.Hashed.matTransform.yx == 0)
TextTop + yoff - (fixAscender >> 6) / 3 + i, {
(TextLeft64 + 32) >> 6, INT CY = (vecB64.y - vecA64.y + 32) >> 6;
TextTop + yoff - (fixAscender >> 6) / 3 + i, IntEngFillBox(dc, X0, Y0, DX, CY, &dc->eboText.BrushObject);
NULL, }
ROP2_TO_MIX(R2_COPYPEN)); else
{
INT DY = (DeltaY64 >> 6);
INT X1 = X0 + ((vecA64.x - vecB64.x + 32) >> 6);
INT Y1 = Y0 + ((vecB64.y - vecA64.y + 32) >> 6);
POINT Points[4] =
{
{ X0, Y0 },
{ X0 + DX, Y0 + DY },
{ X1 + DX, Y1 + DY },
{ X1, Y1 },
};
IntEngFillPolygon(dc, Points, 4, &dc->eboText.BrushObject);
}
} }
} }
} }