summaryrefslogtreecommitdiffstats
path: root/win/tkWinFont.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinFont.c')
-rw-r--r--win/tkWinFont.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 75578de..50f2f3b 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -1361,7 +1361,10 @@ TkDrawAngledChars(
* Draw a string of characters on the screen like Tk_DrawChars(), but
* with access to all the characters on the line for context. On Windows
* this context isn't consulted, so we just call Tk_DrawChars().
- *
+ *
+ * Note: TK_DRAW_IN_CONTEXT being currently defined only on macOS, this
+ * function is unused (and possibly unfinished). See [7655f65ae7].
+*
* Results:
* None.
*
@@ -1399,6 +1402,37 @@ TkpDrawCharsInContext(
rangeLength, x+widthUntilStart, y);
}
+void
+TkpDrawAngledCharsInContext(
+ Display *display, /* Display on which to draw. */
+ Drawable drawable, /* Window or pixmap in which to draw. */
+ GC gc, /* Graphics context for drawing characters. */
+ Tk_Font tkfont, /* Font in which characters will be drawn; must
+ * be the same as font used in GC. */
+ const char * source, /* UTF-8 string to be displayed. Need not be
+ * '\0' terminated. All Tk meta-characters
+ * (tabs, control characters, and newlines)
+ * should be stripped out of the string that is
+ * passed to this function. If they are not
+ * stripped out, they will be displayed as
+ * regular printing characters. */
+ int numBytes, /* Number of bytes in string. */
+ int rangeStart, /* Index of first byte to draw. */
+ int rangeLength, /* Length of range to draw in bytes. */
+ double x, double y, /* Coordinates at which to place origin of the
+ * whole (not just the range) string when
+ * drawing. */
+ double angle) /* What angle to put text at, in degrees. */
+{
+ int widthUntilStart;
+ double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
+ (void) numBytes; /*unused*/
+
+ Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
+ TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart,
+ rangeLength, x+cosA*widthUntilStart, y-sinA*widthUntilStart, angle);
+}
+
/*
*-------------------------------------------------------------------------
*
@@ -1461,9 +1495,9 @@ MultiFontTextOut(
familyPtr = lastSubFontPtr->familyPtr;
Tcl_UtfToExternalDString(familyPtr->encoding, source,
(int) (p - source), &runString);
- familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y,
+ familyPtr->textOutProc(hdc, x-((double)tm.tmOverhang/2), y,
(WCHAR *)Tcl_DStringValue(&runString),
- Tcl_DStringLength(&runString)>>familyPtr->isWideFont);
+ Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
familyPtr->getTextExtentPoint32Proc(hdc,
(WCHAR *)Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
@@ -1483,7 +1517,7 @@ MultiFontTextOut(
familyPtr = lastSubFontPtr->familyPtr;
Tcl_UtfToExternalDString(familyPtr->encoding, source,
(int) (p - source), &runString);
- familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y,
+ familyPtr->textOutProc(hdc, x-((double)tm.tmOverhang/2), y,
(WCHAR *)Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
Tcl_DStringFree(&runString);