diff options
Diffstat (limited to 'unix/tkUnixRFont.c')
-rw-r--r-- | unix/tkUnixRFont.c | 93 |
1 files changed, 51 insertions, 42 deletions
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 2a3ecef..0d9dd8e 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -3,7 +3,7 @@ * * Alternate implementation of tkUnixFont.c using Xft. * - * Copyright (c) 2002-2003 Keith Packard + * Copyright © 2002-2003 Keith Packard * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -69,12 +69,25 @@ TCL_DECLARE_MUTEX(xftMutex); #define UNLOCK Tcl_MutexUnlock(&xftMutex) /* - * Package initialization: - * Nothing to do here except register the fact that we're using Xft in - * the TIP 59 configuration database. + *------------------------------------------------------------------------- + * + * TkpFontPkgInit -- + * + * This procedure is called when an application is created. It + * initializes all the structures that are used by the + * platform-dependant code on a per application basis. + * Note that this is called before TkpInit() ! + * + * Results: + * None. + * + * Side effects: + * None. + * + *------------------------------------------------------------------------- */ -static int utf8ToUcs4(const char *source, FcChar32 *c, int numBytes) +static Tcl_Size utf8ToUcs4(const char *source, FcChar32 *c, Tcl_Size numBytes) { if (numBytes >= 6) { return TkUtfToUniChar(source, (int *)c); @@ -84,14 +97,8 @@ static int utf8ToUcs4(const char *source, FcChar32 *c, int numBytes) void TkpFontPkgInit( - TkMainInfo *mainPtr) /* The application being created. */ + TCL_UNUSED(TkMainInfo *)) /* The application being created. */ { - static const Tcl_Config cfg[] = { - { "fontsystem", "xft" }, - { 0,0 } - }; - - Tcl_RegisterConfig(mainPtr->interp, "tk", cfg, "utf-8"); } static XftFont * @@ -279,7 +286,7 @@ FinishedWithFont( static int InitFontErrorProc( - ClientData clientData, + void *clientData, TCL_UNUSED(XErrorEvent *)) { int *errorFlagPtr = (int *)clientData; @@ -354,7 +361,7 @@ InitFont( errorFlag = 0; handler = Tk_CreateErrorHandler(Tk_Display(tkwin), - -1, -1, -1, InitFontErrorProc, (ClientData) &errorFlag); + -1, -1, -1, InitFontErrorProc, (void *) &errorFlag); ftFont = GetFont(fontPtr, 0, 0.0); if ((ftFont == NULL) || errorFlag) { Tk_DeleteErrorHandler(handler); @@ -396,7 +403,7 @@ InitFont( fPtr->underlinePos = fPtr->fm.descent / 2; handler = Tk_CreateErrorHandler(Tk_Display(tkwin), - -1, -1, -1, InitFontErrorProc, (ClientData) &errorFlag); + -1, -1, -1, InitFontErrorProc, (void *) &errorFlag); errorFlag = 0; Tk_MeasureChars((Tk_Font) fPtr, "I", 1, -1, 0, &iWidth); Tk_DeleteErrorHandler(handler); @@ -616,7 +623,7 @@ TkpGetFontFamilies( if (XftPatternGetString(list->fonts[i], XFT_FAMILY, 0, familyPtr) == XftResultMatch) { - Tcl_Obj *strPtr = Tcl_NewStringObj(family, -1); + Tcl_Obj *strPtr = Tcl_NewStringObj(family, TCL_INDEX_NONE); Tcl_ListObjAppendElement(NULL, resultPtr, strPtr); } @@ -664,9 +671,9 @@ TkpGetSubFonts( XftPatternGetString(pattern, XFT_FAMILY, 0, familyPtr); XftPatternGetString(pattern, XFT_FOUNDRY, 0, foundryPtr); XftPatternGetString(pattern, XFT_ENCODING, 0, encodingPtr); - objv[0] = Tcl_NewStringObj(family, -1); - objv[1] = Tcl_NewStringObj(foundry, -1); - objv[2] = Tcl_NewStringObj(encoding, -1); + objv[0] = Tcl_NewStringObj(family, TCL_INDEX_NONE); + objv[1] = Tcl_NewStringObj(foundry, TCL_INDEX_NONE); + objv[2] = Tcl_NewStringObj(encoding, TCL_INDEX_NONE); listPtr = Tcl_NewListObj(3, objv); Tcl_ListObjAppendElement(NULL, resultPtr, listPtr); } @@ -708,7 +715,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 @@ -730,7 +737,8 @@ Tk_MeasureChars( XftFont *ftFont; FcChar32 c; XGlyphInfo extents; - int clen, curX, newX, curByte, newByte, sawNonSpace; + Tcl_Size clen; + int curX, newX, curByte, newByte, sawNonSpace; int termByte = 0, termX = 0, errorFlag = 0; Tk_ErrorHandler handler; #if DEBUG_FONTSEL @@ -824,9 +832,9 @@ int TkpMeasureCharsInContext( Tk_Font tkfont, const char *source, - TCL_UNUSED(int), - int rangeStart, - int rangeLength, + TCL_UNUSED(Tcl_Size), + Tcl_Size rangeStart, + Tcl_Size rangeLength, int maxLength, int flags, int *lengthPtr) @@ -934,7 +942,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. */ { @@ -947,7 +955,7 @@ Tk_DrawChars( XftGlyphFontSpec specs[NUM_SPEC]; XGlyphInfo metrics; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (fontPtr->ftDraw == 0) { DEBUG(("Switch to drawable 0x%lx\n", drawable)); @@ -1068,7 +1076,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, /* Coordinates at which to place origin of * string when drawing. */ double angle) /* What angle to put text at, in degrees. */ @@ -1080,7 +1088,7 @@ TkDrawAngledChars( XftColor *xftcolor; int xStart = x, yStart = y; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); #ifdef XFT_HAS_FIXED_ROTATED_PLACEMENT int clen, nglyph; FT_UInt glyphs[NUM_SPEC]; @@ -1161,10 +1169,10 @@ TkDrawAngledChars( * at once (or whole blocks with same font), this requires a * dynamic 'glyphs' array. In case of overflow the array has to * be divided until the maximal string will fit. (GC) - * Given the resolution of current displays though, this should - * not be a huge issue since NUM_SPEC is 1024 and thus able to - * cover about 6000 pixels for a 6 pixel wide font (which is - * a very small barely readable font) + * Given the resolution of current displays though, this should + * not be a huge issue since NUM_SPEC is 1024 and thus able to + * cover about 6000 pixels for a 6 pixel wide font (which is + * a very small barely readable font) */ LOCK; @@ -1199,7 +1207,8 @@ TkDrawAngledChars( } } #else /* !XFT_HAS_FIXED_ROTATED_PLACEMENT */ - int clen, nspec; + Tcl_Size clen; + int nspec; XftGlyphFontSpec specs[NUM_SPEC]; XGlyphInfo metrics; double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); @@ -1370,9 +1379,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. */ @@ -1398,9 +1407,9 @@ 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 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. */ @@ -1416,12 +1425,12 @@ TkpDrawAngledCharsInContext( void TkUnixSetXftClipRegion( - TkRegion clipRegion) /* The clipping region to install. */ + Region clipRegion) /* The clipping region to install. */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - tsdPtr->clipRegion = (Region) clipRegion; + tsdPtr->clipRegion = clipRegion; } /* |