Jacek Caban : gdi32: Use NtGdiGetTextMetricsW for GetTextMetrics.
Alexandre Julliard
julliard at winehq.org
Fri Aug 20 16:12:55 CDT 2021
Module: wine
Branch: master
Commit: 6caf861a63403dd2a0b58237271d89cbc58af171
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6caf861a63403dd2a0b58237271d89cbc58af171
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Aug 20 10:42:10 2021 +0200
gdi32: Use NtGdiGetTextMetricsW for GetTextMetrics.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/font.c | 16 ++-------------
dlls/gdi32/text.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 14 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 029990bf847..bfb27ccd1af 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -4820,21 +4820,9 @@ BOOL WINAPI NtGdiGetTextExtentExW( HDC hdc, const WCHAR *str, INT count, INT max
}
/***********************************************************************
- * GetTextMetricsA (GDI32.@)
+ * NtGdiGetTextMetricsW (win32u.@)
*/
-BOOL WINAPI GetTextMetricsA( HDC hdc, TEXTMETRICA *metrics )
-{
- TEXTMETRICW tm32;
-
- if (!GetTextMetricsW( hdc, &tm32 )) return FALSE;
- FONT_TextMetricWToA( &tm32, metrics );
- return TRUE;
-}
-
-/***********************************************************************
- * GetTextMetricsW (GDI32.@)
- */
-BOOL WINAPI GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
+BOOL WINAPI NtGdiGetTextMetricsW( HDC hdc, TEXTMETRICW *metrics, ULONG flags )
{
PHYSDEV physdev;
BOOL ret = FALSE;
diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c
index 86b58555ad5..2d3902d2433 100644
--- a/dlls/gdi32/text.c
+++ b/dlls/gdi32/text.c
@@ -699,6 +699,44 @@ static WCHAR *text_mbtowc( HDC hdc, const char *str, INT count, INT *plenW, UINT
return strW;
}
+static void text_metric_WtoA( const TEXTMETRICW *tmW, TEXTMETRICA *tmA )
+{
+ tmA->tmHeight = tmW->tmHeight;
+ tmA->tmAscent = tmW->tmAscent;
+ tmA->tmDescent = tmW->tmDescent;
+ tmA->tmInternalLeading = tmW->tmInternalLeading;
+ tmA->tmExternalLeading = tmW->tmExternalLeading;
+ tmA->tmAveCharWidth = tmW->tmAveCharWidth;
+ tmA->tmMaxCharWidth = tmW->tmMaxCharWidth;
+ tmA->tmWeight = tmW->tmWeight;
+ tmA->tmOverhang = tmW->tmOverhang;
+ tmA->tmDigitizedAspectX = tmW->tmDigitizedAspectX;
+ tmA->tmDigitizedAspectY = tmW->tmDigitizedAspectY;
+ tmA->tmFirstChar = min( tmW->tmFirstChar, 255 );
+ if (tmW->tmCharSet == SYMBOL_CHARSET)
+ {
+ tmA->tmFirstChar = 0x1e;
+ tmA->tmLastChar = 0xff; /* win9x behaviour - we need the OS2 table data to calculate correctly */
+ }
+ else if (tmW->tmPitchAndFamily & TMPF_TRUETYPE)
+ {
+ tmA->tmFirstChar = tmW->tmDefaultChar - 1;
+ tmA->tmLastChar = min( tmW->tmLastChar, 0xff );
+ }
+ else
+ {
+ tmA->tmFirstChar = min( tmW->tmFirstChar, 0xff );
+ tmA->tmLastChar = min( tmW->tmLastChar, 0xff );
+ }
+ tmA->tmDefaultChar = tmW->tmDefaultChar;
+ tmA->tmBreakChar = tmW->tmBreakChar;
+ tmA->tmItalic = tmW->tmItalic;
+ tmA->tmUnderlined = tmW->tmUnderlined;
+ tmA->tmStruckOut = tmW->tmStruckOut;
+ tmA->tmPitchAndFamily = tmW->tmPitchAndFamily;
+ tmA->tmCharSet = tmW->tmCharSet;
+}
+
/***********************************************************************
* ExtTextOutW (GDI32.@)
*/
@@ -1183,3 +1221,23 @@ BOOL WINAPI GetTextExtentPointW( HDC hdc, const WCHAR *str, INT count, SIZE *siz
{
return GetTextExtentPoint32W( hdc, str, count, size );
}
+
+/***********************************************************************
+ * GetTextMetricsW (GDI32.@)
+ */
+BOOL WINAPI GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
+{
+ return NtGdiGetTextMetricsW( hdc, metrics, 0 );
+}
+
+/***********************************************************************
+ * GetTextMetricsA (GDI32.@)
+ */
+BOOL WINAPI GetTextMetricsA( HDC hdc, TEXTMETRICA *metrics )
+{
+ TEXTMETRICW tm32;
+
+ if (!GetTextMetricsW( hdc, &tm32 )) return FALSE;
+ text_metric_WtoA( &tm32, metrics );
+ return TRUE;
+}
More information about the wine-cvs
mailing list