diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index 5275b36576..507df260af 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -815,9 +815,6 @@ WeightFromStyle(const char *style_name) return FW_NORMAL; } -static FT_Error -IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight); - static INT FASTCALL IntGdiLoadFontsFromMemory(PGDI_LOAD_FONT pLoadFont, PSHARED_FACE SharedFace, FT_Long FontIndex, INT CharSetIndex) @@ -1037,10 +1034,6 @@ IntGdiLoadFontsFromMemory(PGDI_LOAD_FONT pLoadFont, DPRINT("Num glyphs: %d\n", Face->num_glyphs); DPRINT("CharSet: %d\n", FontGDI->CharSet); - IntLockFreeType(); - IntRequestFontSize(NULL, FontGDI, 0, 0); - IntUnLockFreeType(); - /* Add this font resource to the font table */ Entry->Font = FontGDI; Entry->NotEnum = (Characteristics & FR_NOT_ENUM); @@ -1613,14 +1606,16 @@ FillTMEx(TEXTMETRICW *TM, PFONTGDI FontGDI, Descent = pOS2->usWinDescent; } - if (FontGDI->Magic != FONTGDI_MAGIC) - { - IntRequestFontSize(NULL, FontGDI, 0, 0); - } - TM->tmAscent = FontGDI->tmAscent; - TM->tmDescent = FontGDI->tmDescent; +#if 0 /* This (Wine) code doesn't seem to work correctly for us, cmd issue */ + TM->tmAscent = (FT_MulFix(Ascent, YScale) + 32) >> 6; + TM->tmDescent = (FT_MulFix(Descent, YScale) + 32) >> 6; +#else /* This (ros) code was previously affected by a FreeType bug, but it works now */ + TM->tmAscent = (Face->size->metrics.ascender + 32) >> 6; /* Units above baseline */ + TM->tmDescent = (32 - Face->size->metrics.descender) >> 6; /* Units below baseline */ +#endif + TM->tmInternalLeading = (FT_MulFix(Ascent + Descent - Face->units_per_EM, YScale) + 32) >> 6; + TM->tmHeight = TM->tmAscent + TM->tmDescent; - TM->tmInternalLeading = FontGDI->tmInternalLeading; /* MSDN says: * el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender))) @@ -3038,103 +3033,38 @@ static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int b } static FT_Error -IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight) +IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG Width, LONG Height) { - FT_Error error; FT_Size_RequestRec req; FT_Face face = FontGDI->SharedFace->Face; - TT_OS2 *pOS2; - TT_HoriHeader *pHori; - FT_WinFNT_HeaderRec WinFNT; - LONG Ascent, Descent, Sum, EmHeight64; - - lfWidth = abs(lfWidth); - if (lfHeight == 0) - { - if (lfWidth == 0) - { - DPRINT("lfHeight and lfWidth are zero.\n"); - lfHeight = -16; - } - else - { - lfHeight = lfWidth; - } - } - if (lfHeight == -1) - lfHeight = -2; + if (Width < 0) + Width = -Width; - ASSERT_FREETYPE_LOCK_HELD(); - pOS2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, FT_SFNT_OS2); - pHori = (TT_HoriHeader *)FT_Get_Sfnt_Table(face, FT_SFNT_HHEA); - - if (!pOS2 || !pHori) + if (Height < 0) { - error = FT_Get_WinFNT_Header(face, &WinFNT); - if (error) - return error; - - FontGDI->tmHeight = WinFNT.pixel_height; - FontGDI->tmAscent = WinFNT.ascent; - FontGDI->tmDescent = FontGDI->tmHeight - FontGDI->tmAscent; - FontGDI->tmInternalLeading = WinFNT.internal_leading; - FontGDI->EmHeight = FontGDI->tmHeight - FontGDI->tmInternalLeading; - FontGDI->EmHeight = max(FontGDI->EmHeight, 1); - FontGDI->EmHeight = min(FontGDI->EmHeight, USHORT_MAX); - FontGDI->Magic = FONTGDI_MAGIC; - - req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; - req.width = 0; - req.height = (FT_Long)(FontGDI->EmHeight << 6); - req.horiResolution = 0; - req.vertResolution = 0; - return FT_Request_Size(face, &req); + Height = -Height; } - - if (lfHeight > 0) + if (Height == 0) { - /* case (A): lfHeight is positive */ - Sum = pOS2->usWinAscent + pOS2->usWinDescent; - if (Sum == 0) - { - Ascent = pHori->Ascender; - Descent = -pHori->Descender; - Sum = Ascent + Descent; - } - else - { - Ascent = pOS2->usWinAscent; - Descent = pOS2->usWinDescent; - } - - FontGDI->tmAscent = FT_MulDiv(lfHeight, Ascent, Sum); - FontGDI->tmDescent = FT_MulDiv(lfHeight, Descent, Sum); - FontGDI->tmHeight = FontGDI->tmAscent + FontGDI->tmDescent; - FontGDI->tmInternalLeading = FontGDI->tmHeight - FT_MulDiv(lfHeight, face->units_per_EM, Sum); + Height = dc->ppdev->devinfo.lfDefaultFont.lfHeight; } - else if (lfHeight < 0) + if (Height == 0) { - /* case (B): lfHeight is negative */ - FontGDI->tmAscent = FT_MulDiv(-lfHeight, pOS2->usWinAscent, face->units_per_EM); - FontGDI->tmDescent = FT_MulDiv(-lfHeight, pOS2->usWinDescent, face->units_per_EM); - FontGDI->tmHeight = FontGDI->tmAscent + FontGDI->tmDescent; - FontGDI->tmInternalLeading = FontGDI->tmHeight + lfHeight; + Height = Width; } - FontGDI->EmHeight = FontGDI->tmHeight - FontGDI->tmInternalLeading; - FontGDI->EmHeight = max(FontGDI->EmHeight, 1); - FontGDI->EmHeight = min(FontGDI->EmHeight, USHORT_MAX); - FontGDI->Magic = FONTGDI_MAGIC; + if (Height < 1) + Height = 1; - if (lfHeight > 0) - EmHeight64 = (FontGDI->EmHeight << 6) + 31; - else - EmHeight64 = (FontGDI->EmHeight << 6); + if (Width > 0xFFFFU) + Width = 0xFFFFU; + if (Height > 0xFFFFU) + Height = 0xFFFFU; req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; - req.width = 0; - req.height = EmHeight64; + req.width = (FT_Long)(Width << 6); + req.height = (FT_Long)(Height << 6); req.horiResolution = 0; req.vertResolution = 0; return FT_Request_Size(face, &req); @@ -3385,19 +3315,6 @@ ftGdiGetGlyphOutline( IntLockFreeType(); - /* Width scaling transform */ - if (widthRatio != 1.0) - { - FT_Matrix scaleMat; - scaleMat.xx = FT_FixedFromFloat(widthRatio); - scaleMat.xy = 0; - scaleMat.yx = 0; - scaleMat.yy = FT_FixedFromFloat(1.0); - - FT_Matrix_Multiply(&scaleMat, &transMat); - needsTransform = TRUE; - } - /* World transform */ { FT_Matrix ftmatrix; @@ -3859,9 +3776,8 @@ TextIntGetTextExtentPoint(PDC dc, previous = glyph_index; String++; } - ASSERT(FontGDI->Magic == FONTGDI_MAGIC); - ascender = FontGDI->tmAscent; /* Units above baseline */ - descender = FontGDI->tmDescent; /* Units below baseline */ + ascender = (face->size->metrics.ascender + 32) >> 6; /* Units above baseline */ + descender = (32 - face->size->metrics.descender) >> 6; /* Units below baseline */ IntUnLockFreeType(); Size->cx = (TotalWidth + 32) >> 6; @@ -4612,10 +4528,6 @@ FindBestFontFromList(FONTOBJ **FontObj, ULONG *MatchPenalty, /* update FontObj if lowest penalty */ if (Otm) { - IntLockFreeType(); - IntRequestFontSize(NULL, FontGDI, LogFont->lfWidth, LogFont->lfHeight); - IntUnLockFreeType(); - OtmSize = IntGetOutlineTextMetrics(FontGDI, OtmSize, Otm); if (!OtmSize) continue; @@ -4731,23 +4643,8 @@ TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj) } else { - UNICODE_STRING FaceName; PFONTGDI FontGdi = ObjToGDI(TextObj->Font, FONT); - IntLockFreeType(); - IntRequestFontSize(NULL, FontGdi, pLogFont->lfWidth, pLogFont->lfHeight); - IntUnLockFreeType(); - - RtlInitUnicodeString(&FaceName, NULL); - IntGetFontLocalizedName(&FaceName, FontGdi->SharedFace, TT_NAME_ID_FONT_FAMILY, gusLanguageID); - - /* truncated copy */ - FaceName.Length = (USHORT)min(FaceName.Length, (LF_FACESIZE - 1) * sizeof(WCHAR)); - FaceName.MaximumLength = (USHORT)(FaceName.Length + sizeof(UNICODE_NULL)); - RtlCopyMemory(TextObj->FaceName, FaceName.Buffer, FaceName.MaximumLength); - - RtlFreeUnicodeString(&FaceName); - // Need hdev, when freetype is loaded need to create DEVOBJ for // Consumer and Producer. TextObj->Font->iUniq = 1; // Now it can be cached. @@ -5505,29 +5402,27 @@ GreExtTextOutW( pmxWorldToDevice = DC_pmxWorldToDevice(dc); FtSetCoordinateTransform(face, pmxWorldToDevice); - fixAscender = ScaleLong(FontGDI->tmAscent, &pmxWorldToDevice->efM22) << 6; - fixDescender = ScaleLong(FontGDI->tmDescent, &pmxWorldToDevice->efM22) << 6; + fixAscender = ScaleLong(face->size->metrics.ascender, &pmxWorldToDevice->efM22); + fixDescender = ScaleLong(face->size->metrics.descender, &pmxWorldToDevice->efM22); } else { pmxWorldToDevice = (PMATRIX)&gmxWorldToDeviceDefault; FtSetCoordinateTransform(face, pmxWorldToDevice); - fixAscender = FontGDI->tmAscent << 6; - fixDescender = FontGDI->tmDescent << 6; + fixAscender = face->size->metrics.ascender; + fixDescender = face->size->metrics.descender; } /* * Process the vertical alignment and determine the yoff. */ -#define VALIGN_MASK (TA_TOP | TA_BASELINE | TA_BOTTOM) - if ((pdcattr->lTextAlign & VALIGN_MASK) == TA_BASELINE) + if (pdcattr->lTextAlign & TA_BASELINE) yoff = 0; - else if ((pdcattr->lTextAlign & VALIGN_MASK) == TA_BOTTOM) - yoff = -(fixDescender >> 6); + else if (pdcattr->lTextAlign & TA_BOTTOM) + yoff = -fixDescender >> 6; else /* TA_TOP */ yoff = fixAscender >> 6; -#undef VALIGN_MASK use_kerning = FT_HAS_KERNING(face); previous = 0; @@ -5698,7 +5593,7 @@ GreExtTextOutW( 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); + 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)) { @@ -5835,7 +5730,7 @@ GreExtTextOutW( 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); + DestRect.bottom = TextTop + yoff + ((32 - fixDescender) >> 6); if (dc->dctype == DCTYPE_DIRECT) MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom); diff --git a/win32ss/gdi/ntgdi/text.c b/win32ss/gdi/ntgdi/text.c index ec0503fa46..5c7e3664f2 100644 --- a/win32ss/gdi/ntgdi/text.c +++ b/win32ss/gdi/ntgdi/text.c @@ -513,12 +513,12 @@ NtGdiGetTextFaceW( TextObj = RealizeFontInit(hFont); ASSERT(TextObj != NULL); - fLen = wcslen(TextObj->FaceName) + 1; + fLen = wcslen(TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName) + 1; if (FaceName != NULL) { Count = min(Count, fLen); - Status = MmCopyToCaller(FaceName, TextObj->FaceName, Count * sizeof(WCHAR)); + Status = MmCopyToCaller(FaceName, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName, Count * sizeof(WCHAR)); if (!NT_SUCCESS(Status)) { TEXTOBJ_UnlockText(TextObj); diff --git a/win32ss/user/ntuser/painting.c b/win32ss/user/ntuser/painting.c index c1f7cad77a..6053da757b 100644 --- a/win32ss/user/ntuser/painting.c +++ b/win32ss/user/ntuser/painting.c @@ -2150,7 +2150,7 @@ UserDrawCaptionText( { // Faster while in setup. UserExtTextOutW( hDc, lpRc->left, - lpRc->top + (lpRc->bottom - lpRc->top - Size.cy) / 2, // DT_SINGLELINE && DT_VCENTER + lpRc->top + (lpRc->bottom - lpRc->top) / 2 - Size.cy / 2, // DT_SINGLELINE && DT_VCENTER ETO_CLIPPED, (RECTL *)lpRc, Text->Buffer, diff --git a/win32ss/user/rtl/text.c b/win32ss/user/rtl/text.c index 7670e2e595..9f52d3c941 100644 --- a/win32ss/user/rtl/text.c +++ b/win32ss/user/rtl/text.c @@ -1262,27 +1262,26 @@ INT WINAPI DrawTextExWorker( HDC hdc, if (flags & DT_SINGLELINE) { + if (flags & DT_VCENTER) #ifdef __REACTOS__ - if (flags & DT_VCENTER) - { - if (flags & DT_CALCRECT) - { - if (rect->bottom - rect->top < size.cy / 2) - y = rect->top + (invert_y ? size.cy : -size.cy) / 2; - } - else { - y = rect->top + (rect->bottom - rect->top + (invert_y ? size.cy : -size.cy)) / 2; - } - } - else if (flags & DT_BOTTOM) - y = rect->bottom + (invert_y ? 0 : -size.cy); + if (((rect->bottom - rect->top) < (invert_y ? -size.cy : size.cy)) && (flags & DT_CALCRECT)) + { + y = rect->top + (invert_y ? -size.cy : size.cy); + } + else + { + y = rect->top + (rect->bottom - rect->top + (invert_y ? size.cy : -size.cy)) / 2; #else - if (flags & DT_VCENTER) y = rect->top + - (rect->bottom - rect->top) / 2 - size.cy / 2; - else if (flags & DT_BOTTOM) y = rect->bottom - size.cy; + y = rect->top + (rect->bottom - rect->top) / 2 + (invert_y ? (size.cy / 2) : (-size.cy / 2)); #endif - } +#ifdef __REACTOS__ + } + } +#endif + else if (flags & DT_BOTTOM) + y = rect->bottom + (invert_y ? 0 : -size.cy); + } if (!(flags & DT_CALCRECT)) {