summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixFont.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tkUnixFont.c')
-rw-r--r--unix/tkUnixFont.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 5e14eea..2ded5d9 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -4,7 +4,7 @@
* Contains the Unix implementation of the platform-independent font
* package interface.
*
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -238,6 +238,7 @@ static unsigned RankAttributes(FontAttributes *wantPtr,
static void ReleaseFont(UnixFont *fontPtr);
static void ReleaseSubFont(Display *display, SubFont *subFontPtr);
static int SeenName(const char *name, Tcl_DString *dsPtr);
+#if TCL_MAJOR_VERSION < 9
static int Ucs2beToUtfProc(void *clientData, const char*src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
@@ -246,6 +247,7 @@ static int UtfToUcs2beProc(void *clientData, const char*src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
int *dstWrotePtr, int *dstCharsPtr);
+#endif
/*
*-------------------------------------------------------------------------
@@ -312,7 +314,9 @@ TkpFontPkgInit(
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
SubFont dummy;
int i;
+#if TCL_MAJOR_VERSION < 9
Tcl_Encoding ucs2;
+#endif
if (tsdPtr->controlFamily.encoding == NULL) {
@@ -333,6 +337,7 @@ TkpFontPkgInit(
* if it doesn't exist yet. It is used in iso10646 fonts.
*/
+#if TCL_MAJOR_VERSION < 9
ucs2 = Tcl_GetEncoding(NULL, "ucs-2be");
if (ucs2 == NULL) {
Tcl_EncodingType ucs2type = {"ucs-2be", Ucs2beToUtfProc, UtfToUcs2beProc, NULL, NULL, 2};
@@ -340,6 +345,7 @@ TkpFontPkgInit(
} else {
Tcl_FreeEncoding(ucs2);
}
+#endif
Tcl_CreateThreadExitHandler(FontPkgCleanup, NULL);
}
}
@@ -390,7 +396,7 @@ ControlUtfProc(
const char *srcStart, *srcEnd;
char *dstStart, *dstEnd;
int ch, result;
- static const char hexChars[] = "0123456789abcdef";
+ static const char hexChars[] = "0123456789ABCDEF";
static const char mapChars[] = {
0, 0, 0, 0, 0, 0, 0,
'a', 'b', 't', 'n', 'v', 'f', 'r'
@@ -429,10 +435,10 @@ ControlUtfProc(
} else {
/* TODO we can do better here */
dst[1] = 'u';
- dst[2] = 'f';
- dst[3] = 'f';
- dst[4] = 'f';
- dst[5] = 'd';
+ dst[2] = 'F';
+ dst[3] = 'F';
+ dst[4] = 'F';
+ dst[5] = 'D';
dst += 6;
}
}
@@ -458,6 +464,7 @@ ControlUtfProc(
*-------------------------------------------------------------------------
*/
+#if TCL_MAJOR_VERSION < 9
static int
Ucs2beToUtfProc(
TCL_UNUSED(void *), /* Not used. */
@@ -635,6 +642,7 @@ UtfToUcs2beProc(
*dstCharsPtr = numChars;
return result;
}
+#endif
/*
*---------------------------------------------------------------------------
@@ -883,7 +891,7 @@ TkpGetFontFamilies(
hPtr = Tcl_FirstHashEntry(&familyTable, &search);
resultPtr = Tcl_NewObj();
while (hPtr != NULL) {
- strPtr = Tcl_NewStringObj((const char *)Tcl_GetHashKey(&familyTable, hPtr), -1);
+ strPtr = Tcl_NewStringObj((const char *)Tcl_GetHashKey(&familyTable, hPtr), TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
hPtr = Tcl_NextHashEntry(&search);
}
@@ -924,10 +932,10 @@ TkpGetSubFonts(
fontPtr = (UnixFont *) tkfont;
for (i = 0; i < fontPtr->numSubFonts; i++) {
familyPtr = fontPtr->subFontArray[i].familyPtr;
- objv[0] = Tcl_NewStringObj(familyPtr->faceName, -1);
- objv[1] = Tcl_NewStringObj(familyPtr->foundry, -1);
+ objv[0] = Tcl_NewStringObj(familyPtr->faceName, TCL_INDEX_NONE);
+ objv[1] = Tcl_NewStringObj(familyPtr->foundry, TCL_INDEX_NONE);
objv[2] = Tcl_NewStringObj(
- Tcl_GetEncodingName(familyPtr->encoding), -1);
+ Tcl_GetEncodingName(familyPtr->encoding), TCL_INDEX_NONE);
listPtr = Tcl_NewListObj(3, objv);
Tcl_ListObjAppendElement(NULL, resultPtr, listPtr);
}
@@ -999,7 +1007,7 @@ Tk_MeasureChars(
Tk_Font tkfont, /* Font in which characters will be drawn. */
const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. */
- int numBytes, /* Maximum number of bytes to consider from
+ Tcl_Size numBytes, /* Maximum number of bytes to consider from
* source string. */
int maxLength, /* If >= 0, maxLength specifies the longest
* permissible line length in pixels; don't
@@ -1019,7 +1027,8 @@ Tk_MeasureChars(
{
UnixFont *fontPtr;
SubFont *lastSubFontPtr;
- int curX, curByte, ch;
+ Tcl_Size curByte;
+ int curX, ch;
/*
* Unix does not use kerning or fractional character widths when
@@ -1113,7 +1122,7 @@ Tk_MeasureChars(
} else {
lastSubFontPtr = FindSubFontForChar(fontPtr, ch, NULL);
familyPtr = lastSubFontPtr->familyPtr;
- Tcl_UtfToExternal(NULL, familyPtr->encoding, p, next - p, 0, NULL,
+ Tcl_UtfToExternal(NULL, familyPtr->encoding, p, next - p, TCL_ENCODING_PROFILE_TCL8, NULL,
(char *)&buf[0].byte1, sizeof(buf), NULL, &dstWrote, NULL);
if (familyPtr->isTwoByteFont) {
newX += XTextWidth16(lastSubFontPtr->fontStructPtr,
@@ -1211,10 +1220,10 @@ TkpMeasureCharsInContext(
Tk_Font tkfont, /* Font in which characters will be drawn. */
const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. */
- TCL_UNUSED(int), /* Maximum number of bytes to consider from
+ TCL_UNUSED(Tcl_Size), /* Maximum number of bytes to consider from
* source string in all. */
- int rangeStart, /* Index of first byte to measure. */
- int rangeLength, /* Length of range to measure in bytes. */
+ Tcl_Size rangeStart, /* Index of first byte to measure. */
+ Tcl_Size rangeLength, /* Length of range to measure in bytes. */
int maxLength, /* If >= 0, maxLength specifies the longest
* permissible line length; don't consider any
* character that would cross this x-position.
@@ -1268,7 +1277,7 @@ Tk_DrawChars(
* 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. */
+ Tcl_Size numBytes, /* Number of bytes in string. */
int x, int y) /* Coordinates at which to place origin of
* string when drawing. */
{
@@ -1407,9 +1416,9 @@ TkpDrawCharsInContext(
* is passed to this function. If they are not
* stripped out, they will be displayed as
* regular printing characters. */
- TCL_UNUSED(int), /* Number of bytes in string. */
- int rangeStart, /* Index of first byte to draw. */
- int rangeLength, /* Length of range to draw in bytes. */
+ TCL_UNUSED(Tcl_Size), /* Number of bytes in string. */
+ Tcl_Size rangeStart, /* Index of first byte to draw. */
+ Tcl_Size rangeLength, /* Length of range to draw in bytes. */
int x, int y) /* Coordinates at which to place origin of the
* whole (not just the range) string when
* drawing. */
@@ -1435,14 +1444,15 @@ TkpDrawAngledCharsInContext(
* passed to this function. If they are not
* stripped out, they will be displayed as
* regular printing characters. */
- TCL_UNUSED(int), /* Number of bytes in string. */
- int rangeStart, /* Index of first byte to draw. */
- int rangeLength, /* Length of range to draw in bytes. */
+ TCL_UNUSED(Tcl_Size), /* Number of bytes in string. */
+ Tcl_Size rangeStart, /* Index of first byte to draw. */
+ Tcl_Size rangeLength1, /* 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 rangeLength = rangeLength1;
int widthUntilStart;
double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
@@ -3096,7 +3106,7 @@ GetImageOfText(
* 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. */
+ Tcl_Size numBytes, /* Number of bytes in string. */
int *realWidthPtr, int *realHeightPtr)
{
int width, height;
@@ -3178,7 +3188,7 @@ TkDrawAngledChars(
* 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. */
+ Tcl_Size numBytes, /* Number of bytes in string. */
double x, double y,
double angle)
{