From 4665e91c605a6ae30ea0f579f1e4481f9494fe40 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 22 Apr 2020 21:39:03 +0000 Subject: Fix [cd8714756c]: Long lines of rotated text not printing correctly - MultiFontTextOut. Patch from Christopher Chavez. --- win/tkWinFont.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/win/tkWinFont.c b/win/tkWinFont.c index cef505a..63ca37a 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -215,8 +215,8 @@ static int LoadFontRanges(HDC hdc, HFONT hFont, USHORT **startCount, USHORT **endCount, int *symbolPtr); static void MultiFontTextOut(HDC hdc, WinFont *fontPtr, - const char *source, int numBytes, int x, int y, - double angle); + const char *source, int numBytes, + double x, double y, double angle); static void ReleaseFont(WinFont *fontPtr); static inline void ReleaseSubFont(SubFont *subFontPtr); static int SeenName(const char *name, Tcl_DString *dsPtr); @@ -1429,7 +1429,7 @@ MultiFontTextOut( * following string. */ const char *source, /* Potentially multilingual UTF-8 string. */ int numBytes, /* Length of string in bytes. */ - int x, int y, /* Coordinates at which to place origin of + double x, double y, /* Coordinates at which to place origin of * string when drawing. */ double angle) { @@ -1441,6 +1441,7 @@ MultiFontTextOut( const char *p, *end, *next; SubFont *lastSubFontPtr, *thisSubFontPtr; TEXTMETRICW tm; + double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); lastSubFontPtr = &fontPtr->subFontArray[0]; oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle); @@ -1470,7 +1471,8 @@ MultiFontTextOut( (WCHAR *)Tcl_DStringValue(&runString), Tcl_DStringLength(&runString) >> familyPtr->isWideFont, &size); - x += size.cx; + x += cosA*size.cx; + y -= sinA*size.cx; Tcl_DStringFree(&runString); } lastSubFontPtr = thisSubFontPtr; -- cgit v0.12