Index: reactos/win32ss/gdi/ntgdi/freetype.c =================================================================== --- reactos/win32ss/gdi/ntgdi/freetype.c (revision 75378) +++ reactos/win32ss/gdi/ntgdi/freetype.c (working copy) @@ -484,31 +484,37 @@ return TRUE; } -VOID -FtSetCoordinateTransform( - FT_Face face, - PMATRIX pmx) +static inline VOID +FT_MatrixFromMATRIX(FT_Matrix *matrix, const MATRIX *pmx) { - FT_Matrix ftmatrix; FLOATOBJ efTemp; /* Create a freetype matrix, by converting to 16.16 fixpoint format */ efTemp = pmx->efM11; FLOATOBJ_MulLong(&efTemp, 0x00010000); - ftmatrix.xx = FLOATOBJ_GetLong(&efTemp); + matrix->xx = FLOATOBJ_GetLong(&efTemp); efTemp = pmx->efM12; FLOATOBJ_MulLong(&efTemp, 0x00010000); - ftmatrix.xy = FLOATOBJ_GetLong(&efTemp); + matrix->xy = FLOATOBJ_GetLong(&efTemp); efTemp = pmx->efM21; FLOATOBJ_MulLong(&efTemp, 0x00010000); - ftmatrix.yx = FLOATOBJ_GetLong(&efTemp); + matrix->yx = FLOATOBJ_GetLong(&efTemp); efTemp = pmx->efM22; FLOATOBJ_MulLong(&efTemp, 0x00010000); - ftmatrix.yy = FLOATOBJ_GetLong(&efTemp); + matrix->yy = FLOATOBJ_GetLong(&efTemp); +} +static inline VOID +FtSetCoordinateTransform(FT_Face face, const MATRIX *pmx) +{ + FT_Matrix ftmatrix; + + /* Create a freetype matrix, by converting to 16.16 fixpoint format */ + FT_MatrixFromMATRIX(&ftmatrix, pmx); + /* Set the transformation matrix */ FT_Set_Transform(face, &ftmatrix, 0); } @@ -3183,27 +3189,11 @@ { FT_Matrix ftmatrix; - FLOATOBJ efTemp; + /* Create a freetype matrix, by converting to 16.16 fixpoint format */ PMATRIX pmx = DC_pmxWorldToDevice(dc); + FT_MatrixFromMATRIX(&ftmatrix, pmx); - /* 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); - FT_Matrix_Multiply(&ftmatrix, &transMat); needsTransform = TRUE; } @@ -5048,7 +5038,7 @@ FT_GlyphSlot glyph; FT_BitmapGlyph realglyph; LONGLONG TextLeft, RealXStart; - ULONG TextTop, previous, BackgroundLeft; + ULONG TextTop, previous; FT_Bool use_kerning; RECTL DestRect, MaskRect; POINTL SourcePoint, BrushOrigin; @@ -5071,6 +5061,7 @@ LOGFONTW *plf; BOOL EmuBold, EmuItalic; int thickness; + ULONGLONG TextWidth; // TODO: Write test-cases to exactly match real Windows in different // bad parameters (e.g. does Windows check the DC or the RECT first?). @@ -5157,7 +5148,7 @@ if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR)) { - IntUpdateBoundsRect(dc, &DestRect); + IntUpdateBoundsRect(dc, &DestRect); } DC_vPrepareDCsForBlit(dc, &DestRect, NULL, NULL); @@ -5248,26 +5239,26 @@ yoff = fixAscender >> 6; use_kerning = FT_HAS_KERNING(face); + + /* Get width of text and modify RealXStart accordingly. */ + TextWidth = 0; previous = 0; - - /* - * Process the horizontal alignment and modify XStart accordingly. - */ - - if (pdcattr->lTextAlign & (TA_RIGHT | TA_CENTER)) { - ULONGLONG TextWidth = 0; - LPCWSTR TempText = String; + LPCWSTR TempText; int iStart; - /* - * Calculate width of the text. - */ - if (NULL != Dx) { - iStart = Count < 2 ? 0 : Count - 2; - TextWidth = Count < 2 ? 0 : (Dx[(Count-2)<root.advance.x >> 10; + TextWidth += realglyph->root.advance.x; if (EmuBold || EmuItalic) { @@ -5340,18 +5330,15 @@ previous = glyph_index; TempText++; } - - previous = 0; - - if ((pdcattr->lTextAlign & TA_CENTER) == TA_CENTER) - { - RealXStart -= TextWidth / 2; - } - else - { - RealXStart -= TextWidth; - } } + if ((pdcattr->lTextAlign & TA_CENTER) == TA_CENTER) + { + RealXStart -= TextWidth / 2; + } + else if ((pdcattr->lTextAlign & TA_RIGHT) == TA_RIGHT) + { + RealXStart -= TextWidth; + } /* Lock blit with a dummy rect */ DC_vPrepareDCsForBlit(dc, NULL, NULL, NULL); @@ -5380,118 +5367,36 @@ thickness = 1; } - if ((fuOptions & ETO_OPAQUE) && plf->lfItalic) + /* Draw background box if opaque op */ + if (fuOptions & ETO_OPAQUE) { - /* Draw background */ - TextLeft = RealXStart; - TextTop = YStart; - BackgroundLeft = (RealXStart + 32) >> 6; - for (i = 0; i < Count; ++i) + DestRect.left = RealXStart >> 6; + DestRect.right = (RealXStart + TextWidth) >> 6; + DestRect.top = YStart + yoff - ((fixAscender + 32) >> 6); + DestRect.bottom = YStart + yoff + ((32 - fixDescender) >> 6); + + if (dc->fs & (DC_ACCUM_APP | DC_ACCUM_WMGR)) { - if (fuOptions & ETO_GLYPH_INDEX) - glyph_index = String[i]; - else - glyph_index = FT_Get_Char_Index(face, String[i]); + IntUpdateBoundsRect(dc, &DestRect); + } - error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); - if (error) - { - DPRINT1("Failed to load and render glyph! [index: %d]\n", glyph_index); - IntUnLockFreeType; - DC_vFinishBlit(dc, NULL); - goto fail2; - } + if (pdcattr->ulDirty_ & DIRTY_BACKGROUND) + DC_vUpdateBackgroundBrush(dc); - glyph = face->glyph; - 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); - IntUnLockFreeType; - DC_vFinishBlit(dc, NULL); - goto fail2; - } - - /* retrieve kerning distance and move pen position */ - if (use_kerning && previous && glyph_index && NULL == Dx) - { - FT_Vector delta; - FT_Get_Kerning(face, previous, glyph_index, 0, &delta); - TextLeft += delta.x; - } - 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 = TextTop + yoff + ((32 - 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) - { - TextLeft += realglyph->root.advance.x >> 10; - DPRINT("New TextLeft: %I64d\n", TextLeft); - } - else - { - // FIXME this should probably be a matrix transform with TextTop 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<ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom); + 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); } /* @@ -5499,7 +5404,7 @@ */ TextLeft = RealXStart; TextTop = YStart; - BackgroundLeft = (RealXStart + 32) >> 6; + previous = 0; for (i = 0; i < Count; ++i) { if (fuOptions & ETO_GLYPH_INDEX) @@ -5557,37 +5462,7 @@ FT_Get_Kerning(face, previous, glyph_index, 0, &delta); TextLeft += delta.x; } - DPRINT("TextLeft: %I64d\n", TextLeft); - DPRINT("TextTop: %lu\n", TextTop); - 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 = TextTop + yoff + ((32 - 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;