Import Tk 8.6.11
This commit is contained in:
@@ -12,15 +12,13 @@
|
||||
|
||||
#include "tkUnixInt.h"
|
||||
#include "tkFont.h"
|
||||
#include <netinet/in.h> /* for htons() prototype */
|
||||
#include <arpa/inet.h> /* inet_ntoa() */
|
||||
|
||||
/*
|
||||
* The preferred font encodings.
|
||||
*/
|
||||
|
||||
static const char *const encodingList[] = {
|
||||
"iso8859-1", "jis0208", "jis0212", NULL
|
||||
static const char encodingList[][10] = {
|
||||
"iso8859-1", "jis0208", "jis0212"
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -38,11 +36,12 @@ static const char *const encodingList[] = {
|
||||
#define FONTMAP_SHIFT 10
|
||||
|
||||
#define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
|
||||
#define FONTMAP_PAGES (0x30000 / FONTMAP_BITSPERPAGE)
|
||||
#define FONTMAP_NUMCHARS 0x40000
|
||||
#define FONTMAP_PAGES (FONTMAP_NUMCHARS / FONTMAP_BITSPERPAGE)
|
||||
|
||||
typedef struct FontFamily {
|
||||
struct FontFamily *nextPtr; /* Next in list of all known font families. */
|
||||
int refCount; /* How many SubFonts are referring to this
|
||||
size_t refCount; /* How many SubFonts are referring to this
|
||||
* FontFamily. When the refCount drops to
|
||||
* zero, this FontFamily may be freed. */
|
||||
/*
|
||||
@@ -63,7 +62,7 @@ typedef struct FontFamily {
|
||||
/* Two-level sparse table used to determine
|
||||
* quickly if the specified character exists.
|
||||
* As characters are encountered, more pages
|
||||
* in this table are dynamically alloced. The
|
||||
* in this table are dynamically allocated. The
|
||||
* contents of each page is a bitmask
|
||||
* consisting of FONTMAP_BITSPERPAGE bits,
|
||||
* representing whether this font can be used
|
||||
@@ -194,7 +193,7 @@ static const EncodingAlias encodingAliases[] = {
|
||||
* Functions used only in this file.
|
||||
*/
|
||||
|
||||
static void FontPkgCleanup(ClientData clientData);
|
||||
static void FontPkgCleanup(void *clientData);
|
||||
static FontFamily * AllocFontFamily(Display *display,
|
||||
XFontStruct *fontStructPtr, int base);
|
||||
static SubFont * CanUseFallback(UnixFont *fontPtr,
|
||||
@@ -204,7 +203,7 @@ static SubFont * CanUseFallbackWithAliases(UnixFont *fontPtr,
|
||||
const char *fallbackName, int ch,
|
||||
Tcl_DString *nameTriedPtr,
|
||||
SubFont **fixSubFontPtrPtr);
|
||||
static int ControlUtfProc(ClientData clientData, const char *src,
|
||||
static int ControlUtfProc(void *clientData, const char *src,
|
||||
int srcLen, int flags, Tcl_EncodingState*statePtr,
|
||||
char *dst, int dstLen, int *srcReadPtr,
|
||||
int *dstWrotePtr, int *dstCharsPtr);
|
||||
@@ -239,11 +238,11 @@ 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);
|
||||
static int Ucs2beToUtfProc(ClientData clientData, const char*src,
|
||||
static int Ucs2beToUtfProc(void *clientData, const char*src,
|
||||
int srcLen, int flags, Tcl_EncodingState*statePtr,
|
||||
char *dst, int dstLen, int *srcReadPtr,
|
||||
int *dstWrotePtr, int *dstCharsPtr);
|
||||
static int UtfToUcs2beProc(ClientData clientData, const char*src,
|
||||
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);
|
||||
@@ -268,9 +267,9 @@ static int UtfToUcs2beProc(ClientData clientData, const char*src,
|
||||
|
||||
static void
|
||||
FontPkgCleanup(
|
||||
ClientData clientData)
|
||||
TCL_UNUSED(void *))
|
||||
{
|
||||
ThreadSpecificData *tsdPtr =
|
||||
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
|
||||
if (tsdPtr->controlFamily.encoding != NULL) {
|
||||
@@ -307,9 +306,9 @@ FontPkgCleanup(
|
||||
|
||||
void
|
||||
TkpFontPkgInit(
|
||||
TkMainInfo *mainPtr) /* The application being created. */
|
||||
TCL_UNUSED(TkMainInfo *)) /* The application being created. */
|
||||
{
|
||||
ThreadSpecificData *tsdPtr =
|
||||
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
SubFont dummy;
|
||||
int i;
|
||||
@@ -363,11 +362,11 @@ TkpFontPkgInit(
|
||||
|
||||
static int
|
||||
ControlUtfProc(
|
||||
ClientData clientData, /* Not used. */
|
||||
TCL_UNUSED(void *), /* Not used. */
|
||||
const char *src, /* Source string in UTF-8. */
|
||||
int srcLen, /* Source string length in bytes. */
|
||||
int flags, /* Conversion control flags. */
|
||||
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
|
||||
TCL_UNUSED(int), /* Conversion control flags. */
|
||||
TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
|
||||
* information used during a piecewise
|
||||
* conversion. Contents of statePtr are
|
||||
* initialized and/or reset by conversion
|
||||
@@ -391,8 +390,8 @@ ControlUtfProc(
|
||||
const char *srcStart, *srcEnd;
|
||||
char *dstStart, *dstEnd;
|
||||
int ch, result;
|
||||
static char hexChars[] = "0123456789abcdef";
|
||||
static char mapChars[] = {
|
||||
static const char hexChars[] = "0123456789abcdef";
|
||||
static const char mapChars[] = {
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
'a', 'b', 't', 'n', 'v', 'f', 'r'
|
||||
};
|
||||
@@ -417,15 +416,15 @@ ControlUtfProc(
|
||||
dst += 2;
|
||||
} else if ((size_t)ch < 256) {
|
||||
dst[1] = 'x';
|
||||
dst[2] = hexChars[(ch >> 4) & 0xf];
|
||||
dst[3] = hexChars[ch & 0xf];
|
||||
dst[2] = hexChars[(ch >> 4) & 0xF];
|
||||
dst[3] = hexChars[ch & 0xF];
|
||||
dst += 4;
|
||||
} else if ((size_t)ch < 0x10000) {
|
||||
dst[1] = 'u';
|
||||
dst[2] = hexChars[(ch >> 12) & 0xf];
|
||||
dst[3] = hexChars[(ch >> 8) & 0xf];
|
||||
dst[4] = hexChars[(ch >> 4) & 0xf];
|
||||
dst[5] = hexChars[ch & 0xf];
|
||||
dst[2] = hexChars[(ch >> 12) & 0xF];
|
||||
dst[3] = hexChars[(ch >> 8) & 0xF];
|
||||
dst[4] = hexChars[(ch >> 4) & 0xF];
|
||||
dst[5] = hexChars[ch & 0xF];
|
||||
dst += 6;
|
||||
} else {
|
||||
/* TODO we can do better here */
|
||||
@@ -461,11 +460,11 @@ ControlUtfProc(
|
||||
|
||||
static int
|
||||
Ucs2beToUtfProc(
|
||||
ClientData clientData, /* Not used. */
|
||||
TCL_UNUSED(void *), /* Not used. */
|
||||
const char *src, /* Source string in Unicode. */
|
||||
int srcLen, /* Source string length in bytes. */
|
||||
int flags, /* Conversion control flags. */
|
||||
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
|
||||
TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
|
||||
* information used during a piecewise
|
||||
* conversion. Contents of statePtr are
|
||||
* initialized and/or reset by conversion
|
||||
@@ -487,9 +486,13 @@ Ucs2beToUtfProc(
|
||||
* output buffer. */
|
||||
{
|
||||
const char *srcStart, *srcEnd;
|
||||
char *dstEnd, *dstStart;
|
||||
int result, numChars;
|
||||
const char *dstEnd, *dstStart;
|
||||
int result, numChars, charLimit = INT_MAX;
|
||||
unsigned short ch;
|
||||
|
||||
if (flags & TCL_ENCODING_CHAR_LIMIT) {
|
||||
charLimit = *dstCharsPtr;
|
||||
}
|
||||
result = TCL_OK;
|
||||
|
||||
/* check alignment with ucs-2 (2 == sizeof(UCS-2)) */
|
||||
@@ -507,21 +510,26 @@ Ucs2beToUtfProc(
|
||||
srcEnd = src + srcLen;
|
||||
|
||||
dstStart = dst;
|
||||
dstEnd = dst + dstLen - TCL_UTF_MAX;
|
||||
dstEnd = dst + dstLen - 4;
|
||||
|
||||
for (numChars = 0; src < srcEnd; numChars++) {
|
||||
for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
|
||||
if (dst > dstEnd) {
|
||||
result = TCL_CONVERT_NOSPACE;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Need to swap byte-order on little-endian machines (x86) for
|
||||
* UCS-2BE. We know this is an LE->BE swap.
|
||||
*/
|
||||
ch = (src[0] & 0xFF) << 8 | (src[1] & 0xFF);
|
||||
src += 2 /* sizeof(UTF-16) */;
|
||||
|
||||
dst += TkUniCharToUtf(htons(*((short *)src)), dst);
|
||||
src += 2 /* sizeof(UCS-2) */;
|
||||
/*
|
||||
* Special case for 1-byte utf chars for speed. Make sure we work with
|
||||
* unsigned short-size data.
|
||||
*/
|
||||
if (ch && ch < 0x80) {
|
||||
*dst++ = (ch & 0xFF);
|
||||
} else {
|
||||
dst += Tcl_UniCharToUtf(ch, dst);
|
||||
}
|
||||
}
|
||||
|
||||
*srcReadPtr = src - srcStart;
|
||||
@@ -548,12 +556,12 @@ Ucs2beToUtfProc(
|
||||
|
||||
static int
|
||||
UtfToUcs2beProc(
|
||||
ClientData clientData, /* TableEncodingData that specifies
|
||||
TCL_UNUSED(void *), /* TableEncodingData that specifies
|
||||
* encoding. */
|
||||
const char *src, /* Source string in UTF-8. */
|
||||
int srcLen, /* Source string length in bytes. */
|
||||
int flags, /* Conversion control flags. */
|
||||
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
|
||||
TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
|
||||
* information used during a piecewise
|
||||
* conversion. Contents of statePtr are
|
||||
* initialized and/or reset by conversion
|
||||
@@ -576,17 +584,13 @@ UtfToUcs2beProc(
|
||||
{
|
||||
const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
|
||||
int result, numChars;
|
||||
Tcl_UniChar *chPtr = (Tcl_UniChar *)statePtr;
|
||||
|
||||
if (flags & TCL_ENCODING_START) {
|
||||
*statePtr = 0;
|
||||
}
|
||||
int ch;
|
||||
|
||||
srcStart = src;
|
||||
srcEnd = src + srcLen;
|
||||
srcClose = srcEnd;
|
||||
if (!(flags & TCL_ENCODING_END)) {
|
||||
srcClose -= TCL_UTF_MAX;
|
||||
srcClose -= 6;
|
||||
}
|
||||
|
||||
dstStart = dst;
|
||||
@@ -606,17 +610,17 @@ UtfToUcs2beProc(
|
||||
result = TCL_CONVERT_NOSPACE;
|
||||
break;
|
||||
}
|
||||
src += Tcl_UtfToUniChar(src, chPtr);
|
||||
src += TkUtfToUniChar(src, &ch);
|
||||
if (ch > 0xFFFF) {
|
||||
ch = 0xFFFD;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure big-endianness (store big bits first).
|
||||
* XXX: This hard-codes the assumed size of Tcl_UniChar as 2. Make
|
||||
* sure to work in char* for Tcl_UtfToUniChar alignment. [Bug 1122671]
|
||||
*/
|
||||
|
||||
|
||||
*dst++ = (char)(*chPtr >> 8);
|
||||
*dst++ = (char)*chPtr;
|
||||
*dst++ = (char)((ch >> 8) & 0xFF);
|
||||
*dst++ = (char)(ch & 0xFF);
|
||||
}
|
||||
*srcReadPtr = src - srcStart;
|
||||
*dstWrotePtr = dst - dstStart;
|
||||
@@ -701,7 +705,7 @@ TkpGetNativeFont(
|
||||
|
||||
if (name[0] == '-') {
|
||||
if (name[1] != '*') {
|
||||
char *dash;
|
||||
const char *dash;
|
||||
|
||||
dash = strchr(name + 1, '-');
|
||||
if ((dash == NULL) || (isspace(UCHAR(dash[-1])))) {
|
||||
@@ -716,7 +720,7 @@ TkpGetNativeFont(
|
||||
}
|
||||
fontStructPtr = CreateClosestFont(tkwin, &fa.fa, &fa.xa);
|
||||
}
|
||||
fontPtr = ckalloc(sizeof(UnixFont));
|
||||
fontPtr = (UnixFont *)ckalloc(sizeof(UnixFont));
|
||||
InitFont(tkwin, fontStructPtr, fontPtr);
|
||||
|
||||
return (TkFont *) fontPtr;
|
||||
@@ -772,7 +776,7 @@ TkpGetFontFromAttributes(
|
||||
|
||||
fontPtr = (UnixFont *) tkFontPtr;
|
||||
if (fontPtr == NULL) {
|
||||
fontPtr = ckalloc(sizeof(UnixFont));
|
||||
fontPtr = (UnixFont *)ckalloc(sizeof(UnixFont));
|
||||
} else {
|
||||
ReleaseFont(fontPtr);
|
||||
}
|
||||
@@ -835,7 +839,7 @@ TkpGetFontFamilies(
|
||||
Tcl_Interp *interp, /* Interp to hold result. */
|
||||
Tk_Window tkwin) /* For display to query. */
|
||||
{
|
||||
int i, new, numNames;
|
||||
int i, isNew, numNames;
|
||||
char *family, **nameList;
|
||||
Tcl_HashTable familyTable;
|
||||
Tcl_HashEntry *hPtr;
|
||||
@@ -864,14 +868,14 @@ TkpGetFontFamilies(
|
||||
continue; /* See comment above. */
|
||||
}
|
||||
*familyEnd = '\0';
|
||||
Tcl_CreateHashEntry(&familyTable, family, &new);
|
||||
Tcl_CreateHashEntry(&familyTable, family, &isNew);
|
||||
}
|
||||
XFreeFontNames(nameList);
|
||||
|
||||
hPtr = Tcl_FirstHashEntry(&familyTable, &search);
|
||||
resultPtr = Tcl_NewObj();
|
||||
while (hPtr != NULL) {
|
||||
strPtr = Tcl_NewStringObj(Tcl_GetHashKey(&familyTable, hPtr), -1);
|
||||
strPtr = Tcl_NewStringObj((const char *)Tcl_GetHashKey(&familyTable, hPtr), -1);
|
||||
Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
|
||||
hPtr = Tcl_NextHashEntry(&search);
|
||||
}
|
||||
@@ -1199,7 +1203,7 @@ 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. */
|
||||
int numBytes, /* Maximum number of bytes to consider from
|
||||
TCL_UNUSED(int), /* 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. */
|
||||
@@ -1221,7 +1225,6 @@ TkpMeasureCharsInContext(
|
||||
int *lengthPtr) /* Filled with x-location just after the
|
||||
* terminating character. */
|
||||
{
|
||||
(void) numBytes; /*unused*/
|
||||
return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength,
|
||||
maxLength, flags, lengthPtr);
|
||||
}
|
||||
@@ -1370,6 +1373,9 @@ Tk_DrawChars(
|
||||
* with access to all the characters on the line for context. On X11 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.
|
||||
*
|
||||
@@ -1393,7 +1399,7 @@ TkpDrawCharsInContext(
|
||||
* 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_UNUSED(int), /* Number of bytes in string. */
|
||||
int rangeStart, /* Index of first byte to draw. */
|
||||
int rangeLength, /* Length of range to draw in bytes. */
|
||||
int x, int y) /* Coordinates at which to place origin of the
|
||||
@@ -1402,13 +1408,43 @@ TkpDrawCharsInContext(
|
||||
{
|
||||
int widthUntilStart;
|
||||
|
||||
(void) numBytes; /*unused*/
|
||||
|
||||
Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
|
||||
Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart,
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
*-------------------------------------------------------------------------
|
||||
*
|
||||
@@ -1571,7 +1607,7 @@ InitFont(
|
||||
UnixFont *fontPtr) /* Filled with information constructed from
|
||||
* the above arguments. */
|
||||
{
|
||||
ThreadSpecificData *tsdPtr =
|
||||
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
unsigned long value;
|
||||
int minHi, maxHi, minLo, maxLo, fixed, width, limit, i, n;
|
||||
@@ -1677,7 +1713,7 @@ InitFont(
|
||||
* 1/3 the width of a capital I.
|
||||
*/
|
||||
|
||||
fontPtr->barHeight = fontPtr->widths['I'] / 3;
|
||||
fontPtr->barHeight = fontPtr->widths[(unsigned char)'I'] / 3;
|
||||
if (fontPtr->barHeight == 0) {
|
||||
fontPtr->barHeight = 1;
|
||||
}
|
||||
@@ -1818,13 +1854,13 @@ AllocFontFamily(
|
||||
Display *display, /* Display in which font will be used. */
|
||||
XFontStruct *fontStructPtr, /* Screen font whose FontFamily is to be
|
||||
* returned. */
|
||||
int base) /* Non-zero if this font family is to be used
|
||||
TCL_UNUSED(int)) /* Non-zero if this font family is to be used
|
||||
* in the base font of a font object. */
|
||||
{
|
||||
FontFamily *familyPtr;
|
||||
FontAttributes fa;
|
||||
Tcl_Encoding encoding;
|
||||
ThreadSpecificData *tsdPtr =
|
||||
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
|
||||
GetFontAttributes(display, fontStructPtr, &fa);
|
||||
@@ -1843,7 +1879,7 @@ AllocFontFamily(
|
||||
}
|
||||
}
|
||||
|
||||
familyPtr = ckalloc(sizeof(FontFamily));
|
||||
familyPtr = (FontFamily *)ckalloc(sizeof(FontFamily));
|
||||
memset(familyPtr, 0, sizeof(FontFamily));
|
||||
familyPtr->nextPtr = tsdPtr->fontFamilyList;
|
||||
tsdPtr->fontFamilyList = familyPtr;
|
||||
@@ -1900,15 +1936,14 @@ FreeFontFamily(
|
||||
FontFamily *familyPtr) /* The FontFamily to delete. */
|
||||
{
|
||||
FontFamily **familyPtrPtr;
|
||||
ThreadSpecificData *tsdPtr =
|
||||
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
int i;
|
||||
|
||||
if (familyPtr == NULL) {
|
||||
return;
|
||||
}
|
||||
familyPtr->refCount--;
|
||||
if (familyPtr->refCount > 0) {
|
||||
if (familyPtr->refCount-- > 1) {
|
||||
return;
|
||||
}
|
||||
if (familyPtr->encoding) {
|
||||
@@ -1976,8 +2011,8 @@ FindSubFontForChar(
|
||||
SubFont *subFontPtr;
|
||||
Tcl_DString ds;
|
||||
|
||||
if (ch < 0 || ch > 0x30000) {
|
||||
ch = 0xfffd;
|
||||
if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
|
||||
ch = 0xFFFD;
|
||||
}
|
||||
|
||||
for (i = 0; i < fontPtr->numSubFonts; i++) {
|
||||
@@ -2130,7 +2165,7 @@ FontMapLookup(
|
||||
{
|
||||
int row, bitOffset;
|
||||
|
||||
if (ch < 0 || ch >= 0x30000) {
|
||||
if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
|
||||
return 0;
|
||||
}
|
||||
row = ch >> FONTMAP_SHIFT;
|
||||
@@ -2173,7 +2208,7 @@ FontMapInsert(
|
||||
{
|
||||
int row, bitOffset;
|
||||
|
||||
if (ch >= 0 && ch < 0x30000) {
|
||||
if (ch >= 0 && ch < FONTMAP_NUMCHARS) {
|
||||
row = ch >> FONTMAP_SHIFT;
|
||||
if (subFontPtr->fontMap[row] == NULL) {
|
||||
FontMapLoadPage(subFontPtr, row);
|
||||
@@ -2214,10 +2249,10 @@ FontMapLoadPage(
|
||||
Tcl_Encoding encoding;
|
||||
XFontStruct *fontStructPtr;
|
||||
XCharStruct *widths;
|
||||
ThreadSpecificData *tsdPtr =
|
||||
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
|
||||
subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8);
|
||||
subFontPtr->fontMap[row] = (char *)ckalloc(FONTMAP_BITSPERPAGE / 8);
|
||||
memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8);
|
||||
|
||||
if (subFontPtr->familyPtr == &tsdPtr->controlFamily) {
|
||||
@@ -2455,7 +2490,7 @@ CanUseFallback(
|
||||
numEncodings = 0;
|
||||
Tcl_DStringInit(&dsEncodings);
|
||||
|
||||
charset = NULL; /* lint, since numNames must be > 0 to get here. */
|
||||
charset = NULL; /* numNames must be > 0 to get here. */
|
||||
|
||||
retry:
|
||||
bestIdx[0] = -1;
|
||||
@@ -2549,7 +2584,7 @@ CanUseFallback(
|
||||
* make a copy.
|
||||
*/
|
||||
|
||||
nameList = ckalloc(numNames * sizeof(char *));
|
||||
nameList = (char **)ckalloc(numNames * sizeof(char *));
|
||||
memcpy(nameList, nameListOrig, numNames * sizeof(char *));
|
||||
}
|
||||
nameList[nameIdx] = NULL;
|
||||
@@ -2594,11 +2629,11 @@ CanUseFallback(
|
||||
if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
|
||||
SubFont *newPtr;
|
||||
|
||||
newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
|
||||
newPtr = (SubFont *)ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
|
||||
memcpy(newPtr, fontPtr->subFontArray,
|
||||
fontPtr->numSubFonts * sizeof(SubFont));
|
||||
if (fixSubFontPtrPtr != NULL) {
|
||||
register SubFont *fixSubFontPtr = *fixSubFontPtrPtr;
|
||||
SubFont *fixSubFontPtr = *fixSubFontPtrPtr;
|
||||
|
||||
if (fixSubFontPtr != &fontPtr->controlSubFont) {
|
||||
*fixSubFontPtrPtr =
|
||||
@@ -2684,7 +2719,7 @@ RankAttributes(
|
||||
penalty += diff;
|
||||
}
|
||||
if (gotPtr->xa.charset != wantPtr->xa.charset) {
|
||||
int i;
|
||||
size_t i;
|
||||
const char *gotAlias, *wantAlias;
|
||||
|
||||
penalty += 65000;
|
||||
@@ -2692,7 +2727,7 @@ RankAttributes(
|
||||
wantAlias = GetEncodingAlias(wantPtr->xa.charset);
|
||||
if (strcmp(gotAlias, wantAlias) != 0) {
|
||||
penalty += 30000;
|
||||
for (i = 0; encodingList[i] != NULL; i++) {
|
||||
for (i = 0; i < sizeof(encodingList)/sizeof(encodingList[0]); i++) {
|
||||
if (strcmp(gotAlias, encodingList[i]) == 0) {
|
||||
penalty -= 30000;
|
||||
break;
|
||||
@@ -3063,29 +3098,31 @@ GetImageOfText(
|
||||
Pixmap bitmap;
|
||||
GC bitmapGC;
|
||||
XGCValues values;
|
||||
XImage *image;
|
||||
XImage *image = NULL;
|
||||
|
||||
(void) Tk_MeasureChars(tkfont, source, numBytes, -1, 0, &width);
|
||||
height = fontPtr->fm.ascent + fontPtr->fm.descent;
|
||||
|
||||
bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
|
||||
values.graphics_exposures = False;
|
||||
values.foreground = BlackPixel(display, DefaultScreen(display));
|
||||
bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
|
||||
&values);
|
||||
XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
|
||||
if ((width > 0) && (height > 0)) {
|
||||
bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
|
||||
values.graphics_exposures = False;
|
||||
values.foreground = BlackPixel(display, DefaultScreen(display));
|
||||
bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
|
||||
&values);
|
||||
XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
|
||||
|
||||
values.font = Tk_FontId(tkfont);
|
||||
values.foreground = WhitePixel(display, DefaultScreen(display));
|
||||
values.background = BlackPixel(display, DefaultScreen(display));
|
||||
XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
|
||||
Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
|
||||
fontPtr->fm.ascent);
|
||||
XFreeGC(display, bitmapGC);
|
||||
values.font = Tk_FontId(tkfont);
|
||||
values.foreground = WhitePixel(display, DefaultScreen(display));
|
||||
values.background = BlackPixel(display, DefaultScreen(display));
|
||||
XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
|
||||
Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
|
||||
fontPtr->fm.ascent);
|
||||
XFreeGC(display, bitmapGC);
|
||||
|
||||
image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
|
||||
ZPixmap);
|
||||
Tk_FreePixmap(display, bitmap);
|
||||
image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
|
||||
ZPixmap);
|
||||
Tk_FreePixmap(display, bitmap);
|
||||
}
|
||||
|
||||
*realWidthPtr = width;
|
||||
*realHeightPtr = height;
|
||||
@@ -3100,21 +3137,23 @@ InitDestImage(
|
||||
int height,
|
||||
Pixmap *bitmapPtr)
|
||||
{
|
||||
Pixmap bitmap;
|
||||
XImage *image;
|
||||
Pixmap bitmap = None;
|
||||
XImage *image = NULL;
|
||||
GC bitmapGC;
|
||||
XGCValues values;
|
||||
|
||||
bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
|
||||
values.graphics_exposures = False;
|
||||
values.foreground = BlackPixel(display, DefaultScreen(display));
|
||||
bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
|
||||
&values);
|
||||
XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
|
||||
XFreeGC(display, bitmapGC);
|
||||
if ((width > 0) && (height > 0)) {
|
||||
bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
|
||||
values.graphics_exposures = False;
|
||||
values.foreground = BlackPixel(display, DefaultScreen(display));
|
||||
bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
|
||||
&values);
|
||||
XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
|
||||
XFreeGC(display, bitmapGC);
|
||||
|
||||
image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
|
||||
ZPixmap);
|
||||
image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
|
||||
ZPixmap);
|
||||
}
|
||||
*bitmapPtr = bitmap;
|
||||
return image;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user