summaryrefslogtreecommitdiffstats
path: root/win/tkWinFont.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2020-04-22 21:39:03 (GMT)
committerfvogel <fvogelnew1@free.fr>2020-04-22 21:39:03 (GMT)
commit4665e91c605a6ae30ea0f579f1e4481f9494fe40 (patch)
tree4b1e7ff20160607eaf6df4d5efb903abdff25552 /win/tkWinFont.c
parent0cd29bb998be0312bd2230570521fa68c55fc6fa (diff)
downloadtk-4665e91c605a6ae30ea0f579f1e4481f9494fe40.zip
tk-4665e91c605a6ae30ea0f579f1e4481f9494fe40.tar.gz
tk-4665e91c605a6ae30ea0f579f1e4481f9494fe40.tar.bz2
Fix [cd8714756c]: Long lines of rotated text not printing correctly - MultiFontTextOut. Patch from Christopher Chavez.
Diffstat (limited to 'win/tkWinFont.c')
-rw-r--r--win/tkWinFont.c10
1 files 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;