From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/win32u/font.c | 56 +++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 41 deletions(-)
diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c index 96f091ff77c..6e7cef3daa2 100644 --- a/dlls/win32u/font.c +++ b/dlls/win32u/font.c @@ -224,32 +224,6 @@ static inline int facename_compare( const WCHAR *str1, const WCHAR *str2, SIZE_T
/* Device -> World size conversion */
-/* Performs a device to world transformation on the specified width (which - * is in integer format). - */ -static inline INT INTERNAL_XDSTOWS(DC *dc, INT width) -{ - double floatWidth; - - /* Perform operation with floating point */ - floatWidth = (double)width * dc->xformVport2World.eM11; - /* Round to integers */ - return GDI_ROUND(floatWidth); -} - -/* Performs a device to world transformation on the specified size (which - * is in integer format). - */ -static inline INT INTERNAL_YDSTOWS(DC *dc, INT height) -{ - double floatHeight; - - /* Perform operation with floating point */ - floatHeight = (double)height * dc->xformVport2World.eM22; - /* Round to integers */ - return GDI_ROUND(floatHeight); -} - /* scale width and height but don't mirror them */
static inline INT width_to_LP( DC *dc, INT width ) @@ -262,7 +236,7 @@ static inline INT height_to_LP( DC *dc, INT height ) return GDI_ROUND( (double)height * fabs( dc->xformVport2World.eM22 )); }
-static inline INT INTERNAL_XWSTODS(DC *dc, INT width) +static inline INT width_to_DP(DC *dc, INT width) { POINT pt[2]; pt[0].x = pt[0].y = 0; @@ -272,7 +246,7 @@ static inline INT INTERNAL_XWSTODS(DC *dc, INT width) return pt[1].x - pt[0].x; }
-static inline INT INTERNAL_YWSTODS(DC *dc, INT height) +static inline INT height_to_DP(DC *dc, INT height) { POINT pt[2]; pt[0].x = pt[0].y = 0; @@ -5258,7 +5232,7 @@ BOOL WINAPI NtGdiGetTextExtentExW( HDC hdc, const WCHAR *str, INT count, INT max { for (i = 0; i < count; i++) { - unsigned int dx = abs( INTERNAL_XDSTOWS( dc, pos[i] )) + + unsigned int dx = abs( width_to_LP( dc, pos[i] )) + (i + 1) * dc->attr->char_extra; if (nfit && dx > (unsigned int)max_ext) break; if (dxs) dxs[i] = dx; @@ -5266,8 +5240,8 @@ BOOL WINAPI NtGdiGetTextExtentExW( HDC hdc, const WCHAR *str, INT count, INT max if (nfit) *nfit = i; }
- size->cx = abs( INTERNAL_XDSTOWS( dc, size->cx )) + count * dc->attr->char_extra; - size->cy = abs( INTERNAL_YDSTOWS( dc, size->cy )); + size->cx = abs( width_to_LP( dc, size->cx )) + count * dc->attr->char_extra; + size->cy = abs( height_to_LP( dc, size->cy )); }
if (pos != buffer && pos != dxs) free( pos ); @@ -5371,16 +5345,16 @@ UINT WINAPI NtGdiGetOutlineTextMetricsInternalW( HDC hdc, UINT cbData, output->otmTextMetrics.tmOverhang = width_to_LP( dc, output->otmTextMetrics.tmOverhang ); output->otmAscent = height_to_LP( dc, output->otmAscent); output->otmDescent = height_to_LP( dc, output->otmDescent); - output->otmLineGap = INTERNAL_YDSTOWS(dc, output->otmLineGap); - output->otmsCapEmHeight = INTERNAL_YDSTOWS(dc, output->otmsCapEmHeight); - output->otmsXHeight = INTERNAL_YDSTOWS(dc, output->otmsXHeight); + output->otmLineGap = height_to_LP(dc, output->otmLineGap); + output->otmsCapEmHeight = height_to_LP(dc, output->otmsCapEmHeight); + output->otmsXHeight = height_to_LP(dc, output->otmsXHeight); output->otmrcFontBox.top = height_to_LP( dc, output->otmrcFontBox.top); output->otmrcFontBox.bottom = height_to_LP( dc, output->otmrcFontBox.bottom); output->otmrcFontBox.left = width_to_LP( dc, output->otmrcFontBox.left); output->otmrcFontBox.right = width_to_LP( dc, output->otmrcFontBox.right); output->otmMacAscent = height_to_LP( dc, output->otmMacAscent); output->otmMacDescent = height_to_LP( dc, output->otmMacDescent); - output->otmMacLineGap = INTERNAL_YDSTOWS(dc, output->otmMacLineGap); + output->otmMacLineGap = height_to_LP(dc, output->otmMacLineGap); output->otmptSubscriptSize.x = width_to_LP( dc, output->otmptSubscriptSize.x); output->otmptSubscriptSize.y = height_to_LP( dc, output->otmptSubscriptSize.y); output->otmptSubscriptOffset.x = width_to_LP( dc, output->otmptSubscriptOffset.x); @@ -5389,7 +5363,7 @@ UINT WINAPI NtGdiGetOutlineTextMetricsInternalW( HDC hdc, UINT cbData, output->otmptSuperscriptSize.y = height_to_LP( dc, output->otmptSuperscriptSize.y); output->otmptSuperscriptOffset.x = width_to_LP( dc, output->otmptSuperscriptOffset.x); output->otmptSuperscriptOffset.y = height_to_LP( dc, output->otmptSuperscriptOffset.y); - output->otmsStrikeoutSize = INTERNAL_YDSTOWS(dc, output->otmsStrikeoutSize); + output->otmsStrikeoutSize = height_to_LP(dc, output->otmsStrikeoutSize); output->otmsStrikeoutPosition = height_to_LP( dc, output->otmsStrikeoutPosition); output->otmsUnderscoreSize = height_to_LP( dc, output->otmsUnderscoreSize); output->otmsUnderscorePosition = height_to_LP( dc, output->otmsUnderscorePosition); @@ -5751,7 +5725,7 @@ BOOL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect */ static inline int get_line_width( DC *dc, int metric_size ) { - int width = abs( INTERNAL_XWSTODS( dc, metric_size )); + int width = abs( width_to_DP( dc, metric_size )); if (width == 0) width = 1; if (metric_size < 0) width = -width; return width; @@ -5982,8 +5956,8 @@ BOOL WINAPI NtGdiExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *lpr width = desired[1]; }
- tm.tmAscent = abs(INTERNAL_YWSTODS(dc, tm.tmAscent)); - tm.tmDescent = abs(INTERNAL_YWSTODS(dc, tm.tmDescent)); + tm.tmAscent = abs(height_to_DP(dc, tm.tmAscent)); + tm.tmDescent = abs(height_to_DP(dc, tm.tmDescent)); switch( align & (TA_LEFT | TA_RIGHT | TA_CENTER) ) { case TA_LEFT: @@ -6080,10 +6054,10 @@ done: { otm = malloc( size ); NtGdiGetOutlineTextMetricsInternalW( hdc, size, otm, 0 ); - underlinePos = abs( INTERNAL_YWSTODS( dc, otm->otmsUnderscorePosition )); + underlinePos = abs( height_to_DP( dc, otm->otmsUnderscorePosition )); if (otm->otmsUnderscorePosition < 0) underlinePos = -underlinePos; underlineWidth = get_line_width( dc, otm->otmsUnderscoreSize ); - strikeoutPos = abs( INTERNAL_YWSTODS( dc, otm->otmsStrikeoutPosition )); + strikeoutPos = abs( height_to_DP( dc, otm->otmsStrikeoutPosition )); if (otm->otmsStrikeoutPosition < 0) strikeoutPos = -strikeoutPos; strikeoutWidth = get_line_width( dc, otm->otmsStrikeoutSize ); free( otm );