Commit acd45283 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Font.c: cleanup

reformat, whitespace, code simplification, FIXMEs
parent 92589f41
...@@ -205,12 +205,6 @@ void nxagentFreeFontCache(void) ...@@ -205,12 +205,6 @@ void nxagentFreeFontCache(void)
void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) void nxagentListRemoteFonts(const char *searchPattern, const int maxNames)
{ {
char **xList;
int xLen = 0;
const char *patterns[] = {"*", "-*-*-*-*-*-*-*-*-*-*-*-*-*-*"};
int patternsQt = 2;
if (NXDisplayError(nxagentDisplay) == 1) if (NXDisplayError(nxagentDisplay) == 1)
{ {
return; return;
...@@ -233,9 +227,13 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) ...@@ -233,9 +227,13 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames)
* select the 'real' fonts. * select the 'real' fonts.
*/ */
for (int p = 0; p < patternsQt; p++) const char *patterns[] = {"*", "-*-*-*-*-*-*-*-*-*-*-*-*-*-*"};
const int numPatterns = 2;
for (int p = 0; p < numPatterns; p++)
{ {
xList = XListFonts(nxagentDisplay, patterns[p], maxNames, &xLen); int xLen = 0;
char **xList = XListFonts(nxagentDisplay, patterns[p], maxNames, &xLen);
#ifdef NXAGENT_FONTMATCH_DEBUG #ifdef NXAGENT_FONTMATCH_DEBUG
fprintf(stderr, "nxagentListRemoteFonts: NXagent remote list [%s] has %d elements.\n", patterns[p], xLen); fprintf(stderr, "nxagentListRemoteFonts: NXagent remote list [%s] has %d elements.\n", patterns[p], xLen);
...@@ -282,7 +280,8 @@ void nxagentListRemoteAddName(const char *name, int status) ...@@ -282,7 +280,8 @@ void nxagentListRemoteAddName(const char *name, int status)
#ifdef NXAGENT_FONTMATCH_DEBUG #ifdef NXAGENT_FONTMATCH_DEBUG
fprintf(stderr, "Font: Font# %d, [%s] change status to %s\n", fprintf(stderr, "Font: Font# %d, [%s] change status to %s\n",
pos, nxagentRemoteFontList.list[pos]->name,nxagentRemoteFontList.list[pos]->status?"OK":"deleted"); pos, nxagentRemoteFontList.list[pos]->name,
nxagentRemoteFontList.list[pos]->status ? "OK" : "deleted");
#endif #endif
} }
return; return;
...@@ -290,6 +289,7 @@ void nxagentListRemoteAddName(const char *name, int status) ...@@ -290,6 +289,7 @@ void nxagentListRemoteAddName(const char *name, int status)
if (nxagentRemoteFontList.length == nxagentRemoteFontList.listSize) if (nxagentRemoteFontList.length == nxagentRemoteFontList.listSize)
{ {
/* FIXME: if realloc fails the pointer is lost! */
nxagentRemoteFontList.list = realloc(nxagentRemoteFontList.list, sizeof(nxagentFontRecPtr) nxagentRemoteFontList.list = realloc(nxagentRemoteFontList.list, sizeof(nxagentFontRecPtr)
* (nxagentRemoteFontList.listSize + 1000)); * (nxagentRemoteFontList.listSize + 1000));
...@@ -365,6 +365,7 @@ Bool nxagentFontFind(const char *name, int *pos) ...@@ -365,6 +365,7 @@ Bool nxagentFontFind(const char *name, int *pos)
*pos=0; *pos=0;
return False; return False;
} }
int low = 0; int low = 0;
int high = nxagentRemoteFontList.length - 1; int high = nxagentRemoteFontList.length - 1;
int iter = 0; int iter = 0;
...@@ -389,7 +390,7 @@ Bool nxagentFontFind(const char *name, int *pos) ...@@ -389,7 +390,7 @@ Bool nxagentFontFind(const char *name, int *pos)
} }
break; break;
} }
*pos = (res == 0)?*pos:lpos; *pos = (res == 0) ? *pos : lpos;
#ifdef NXAGENT_FONTMATCH_DEBUG #ifdef NXAGENT_FONTMATCH_DEBUG
if (res == 0) if (res == 0)
...@@ -399,14 +400,13 @@ Bool nxagentFontFind(const char *name, int *pos) ...@@ -399,14 +400,13 @@ Bool nxagentFontFind(const char *name, int *pos)
#endif #endif
return (res == 0); return (res == 0);
} }
Bool nxagentFontLookUp(const char *name) Bool nxagentFontLookUp(const char *name)
{ {
int i; int i;
if (name != NULL && strlen(name) == 0) if (name && strlen(name) == 0)
{ {
return 0; return 0;
} }
...@@ -455,49 +455,47 @@ Bool nxagentFontLookUp(const char *name) ...@@ -455,49 +455,47 @@ Bool nxagentFontLookUp(const char *name)
Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
{ {
void * priv;
Atom name_atom, value_atom;
int nprops;
FontPropPtr props;
int i;
const char *name;
char *origName = (char*) pScreen;
#ifdef HAS_XFONT2 #ifdef HAS_XFONT2
xfont2_font_set_private(pFont, nxagentFontPrivateIndex, NULL); xfont2_font_set_private(pFont, nxagentFontPrivateIndex, NULL);
#else #else
FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL); FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL);
#endif /* HAS_XFONT2 */ #endif /* HAS_XFONT2 */
name_atom = MakeAtom("FONT", 4, True); Atom name_atom = MakeAtom("FONT", 4, True);
value_atom = 0L; Atom value_atom = 0L;
nprops = pFont->info.nprops; int nprops = pFont->info.nprops;
props = pFont->info.props; FontPropPtr props = pFont->info.props;
for (i = 0; i < nprops; i++) for (int i = 0; i < nprops; i++)
if ((Atom)props[i].name == name_atom) { {
if ((Atom)props[i].name == name_atom)
{
value_atom = props[i].value; value_atom = props[i].value;
break; break;
} }
}
if (!value_atom) return False; if (!value_atom)
return False;
name = NameForAtom(value_atom); const char *name = NameForAtom(value_atom);
#ifdef NXAGENT_FONTCACHE_DEBUG #ifdef NXAGENT_FONTCACHE_DEBUG
fprintf(stderr, "Font: nxagentRealizeFont, realizing font: %s\n", validateString(name)); fprintf(stderr, "Font: nxagentRealizeFont, realizing font: %s\n", validateString(name));
fprintf(stderr, " atom: %ld\n", value_atom); fprintf(stderr, " atom: %ld\n", value_atom);
fprintf(stderr, "Font: Cache dump:\n"); fprintf(stderr, "Font: Cache dump:\n");
for (i = 0; i < CACHE_INDEX; i++) for (int i = 0; i < CACHE_INDEX; i++)
{ {
fprintf(stderr, "nxagentFontCache.entry[%d]->name: %s font_struct at %p\n", fprintf(stderr, "nxagentFontCache.entry[%d]->name: %s font_struct at %p\n",
i, CACHE_NAME(i), CACHE_FSTRUCT(i)); i, CACHE_NAME(i), CACHE_FSTRUCT(i));
} }
#endif #endif
if (!name) return False; if (!name)
return False;
char *origName = (char*) pScreen;
if ((strcasecmp(origName, name) != 0) && !strchr(origName,'*')) if ((strcasecmp(origName, name) != 0) && !strchr(origName,'*'))
{ {
#ifdef NXAGENT_FONTMATCH_DEBUG #ifdef NXAGENT_FONTMATCH_DEBUG
...@@ -508,7 +506,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -508,7 +506,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
name = origName; name = origName;
} }
priv = (void *)malloc(sizeof(nxagentPrivFont)); void *priv = (void *)malloc(sizeof(nxagentPrivFont));
#ifdef HAS_XFONT2 #ifdef HAS_XFONT2
xfont2_font_set_private(pFont, nxagentFontPrivateIndex, priv); xfont2_font_set_private(pFont, nxagentFontPrivateIndex, priv);
#else #else
...@@ -517,22 +515,23 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -517,22 +515,23 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
nxagentFontPriv(pFont) -> mirrorID = 0; nxagentFontPriv(pFont) -> mirrorID = 0;
for (i = 0; i < nxagentFontCache.index; i++) int fci;
for (fci = 0; fci < nxagentFontCache.index; fci++)
{ {
/* if (value_atom == CACHE_ATOM(i))*/ /* if (value_atom == CACHE_ATOM(i))*/
if (strcasecmp(CACHE_NAME(i), name) == 0) if (strcasecmp(CACHE_NAME(fci), name) == 0)
{ {
#ifdef NXAGENT_FONTCACHE_DEBUG #ifdef NXAGENT_FONTCACHE_DEBUG
fprintf(stderr, "Font: nxagentFontCache hit [%s] = [%s]!\n", CACHE_NAME(i), validateString(name)); fprintf(stderr, "Font: nxagentFontCache hit [%s] = [%s]!\n", CACHE_NAME(fci), validateString(name));
#endif #endif
break; break;
} }
} }
if (i < CACHE_INDEX) if (fci < CACHE_INDEX)
{ {
nxagentFontPriv(pFont)->font_struct = CACHE_FSTRUCT(i); nxagentFontPriv(pFont)->font_struct = CACHE_FSTRUCT(fci);
strcpy(nxagentFontPriv(pFont)->fontName, name); strcpy(nxagentFontPriv(pFont)->fontName, name);
} }
else else
...@@ -543,6 +542,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -543,6 +542,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
if (CACHE_INDEX == CACHE_SIZE) if (CACHE_INDEX == CACHE_SIZE)
{ {
/* FIXME: if realloc fails the pointer is lost */
CACHE_ENTRY_PTR = realloc(CACHE_ENTRY_PTR, sizeof(nxCacheFontEntryRecPtr) * (CACHE_SIZE + 100)); CACHE_ENTRY_PTR = realloc(CACHE_ENTRY_PTR, sizeof(nxCacheFontEntryRecPtr) * (CACHE_SIZE + 100));
if (CACHE_ENTRY_PTR == NULL) if (CACHE_ENTRY_PTR == NULL)
...@@ -580,9 +580,9 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -580,9 +580,9 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
strcpy(nxagentFontPriv(pFont)->fontName, name); strcpy(nxagentFontPriv(pFont)->fontName, name);
if (nxagentFontPriv(pFont)->font_struct != NULL) if (nxagentFontPriv(pFont)->font_struct != NULL)
{ {
CACHE_ATOM(i) = value_atom; CACHE_ATOM(fci) = value_atom;
strcpy(CACHE_NAME(i), name); strcpy(CACHE_NAME(fci), name);
CACHE_FSTRUCT(i) = nxagentFontPriv(pFont)->font_struct; CACHE_FSTRUCT(fci) = nxagentFontPriv(pFont)->font_struct;
CACHE_INDEX++; CACHE_INDEX++;
nxagentFontPriv(pFont) -> mirrorID = FakeClientID(serverClient -> index); nxagentFontPriv(pFont) -> mirrorID = FakeClientID(serverClient -> index);
...@@ -611,8 +611,10 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -611,8 +611,10 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
} }
} }
else else
{
fprintf(stderr, "Font: nxagentRealizeFont OK realizing font Font=%s\n", fprintf(stderr, "Font: nxagentRealizeFont OK realizing font Font=%s\n",
validateString(name)); validateString(name));
}
#endif #endif
...@@ -627,11 +629,11 @@ Bool nxagentUnrealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -627,11 +629,11 @@ Bool nxagentUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
{ {
if (nxagentFontStruct(pFont)) if (nxagentFontStruct(pFont))
{ {
int i; int fci;
for (i = 0; i < CACHE_INDEX; i++) for (fci = 0; fci < CACHE_INDEX; fci++)
{ {
if (CACHE_FSTRUCT(i) == nxagentFontStruct(pFont)) if (CACHE_FSTRUCT(fci) == nxagentFontStruct(pFont))
{ {
#ifdef NXAGENT_FONTCACHE_DEBUG #ifdef NXAGENT_FONTCACHE_DEBUG
fprintf(stderr, "nxagentUnrealizeFont: Not freeing the font in cache.\n"); fprintf(stderr, "nxagentUnrealizeFont: Not freeing the font in cache.\n");
...@@ -641,7 +643,7 @@ Bool nxagentUnrealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -641,7 +643,7 @@ Bool nxagentUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
} }
} }
if (i == CACHE_INDEX) if (fci == CACHE_INDEX)
{ {
/* /*
* This font is not in the cache. * This font is not in the cache.
...@@ -649,7 +651,7 @@ Bool nxagentUnrealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -649,7 +651,7 @@ Bool nxagentUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
#ifdef NXAGENT_FONTCACHE_DEBUG #ifdef NXAGENT_FONTCACHE_DEBUG
fprintf(stderr, "nxagentUnrealizeFont: Freeing font not found in cache '%d'\n", fprintf(stderr, "nxagentUnrealizeFont: Freeing font not found in cache '%d'\n",
CACHE_ATOM(i)); CACHE_ATOM(fci));
#endif #endif
XFreeFont(nxagentDisplay, nxagentFontStruct(pFont)); XFreeFont(nxagentDisplay, nxagentFontStruct(pFont));
...@@ -737,7 +739,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -737,7 +739,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
#ifdef WARNING #ifdef WARNING
if (nxagentVerbose == 1) if (nxagentVerbose == 1)
{ {
fprintf(stderr, "nxagentLoadBestQueryFont: WARNING! Font name in non standard format. \n"); fprintf(stderr, "nxagentLoadBestQueryFont: WARNING! Font name in non standard format.\n");
} }
#endif #endif
} }
...@@ -765,7 +767,6 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -765,7 +767,6 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
if (numSearchFields > FIELDS) if (numSearchFields > FIELDS)
{ {
tempWeight = 0; tempWeight = 0;
for (int j = 0; j < FIELDS; j++) for (int j = 0; j < FIELDS; j++)
...@@ -781,7 +782,6 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -781,7 +782,6 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
tempWeight <<= 1; tempWeight <<= 1;
} }
} }
if (tempWeight > weight) if (tempWeight > weight)
...@@ -870,7 +870,8 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id) ...@@ -870,7 +870,8 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id)
nxagentFailedToReconnectFonts.font = malloc(nxagentFailedToReconnectFonts.size * nxagentFailedToReconnectFonts.font = malloc(nxagentFailedToReconnectFonts.size *
sizeof(FontPtr)); sizeof(FontPtr));
nxagentFailedToReconnectFonts.id = malloc(nxagentFailedToReconnectFonts.size * sizeof(XID)); nxagentFailedToReconnectFonts.id = malloc(nxagentFailedToReconnectFonts.size *
sizeof(XID));
if (nxagentFailedToReconnectFonts.font == NULL || nxagentFailedToReconnectFonts.id == NULL) if (nxagentFailedToReconnectFonts.font == NULL || nxagentFailedToReconnectFonts.id == NULL)
{ {
...@@ -889,6 +890,7 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id) ...@@ -889,6 +890,7 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id)
{ {
nxagentFailedToReconnectFonts.size *= 2; nxagentFailedToReconnectFonts.size *= 2;
/* FIXME: if realloc fails the pointer is lost */
nxagentFailedToReconnectFonts.font = realloc(nxagentFailedToReconnectFonts.font, nxagentFailedToReconnectFonts.font = realloc(nxagentFailedToReconnectFonts.font,
nxagentFailedToReconnectFonts.size * nxagentFailedToReconnectFonts.size *
sizeof(FontPtr)); sizeof(FontPtr));
...@@ -1029,7 +1031,7 @@ static void nxagentCleanCacheAfterReconnect(void) ...@@ -1029,7 +1031,7 @@ static void nxagentCleanCacheAfterReconnect(void)
for (int i = 0; i < CACHE_INDEX; i++) for (int i = 0; i < CACHE_INDEX; i++)
{ {
if(CACHE_FSTRUCT(i) == NULL) if (CACHE_FSTRUCT(i) == NULL)
{ {
SAFE_XFree(CACHE_NAME(i)); SAFE_XFree(CACHE_NAME(i));
real_size--; real_size--;
...@@ -1042,7 +1044,8 @@ static void nxagentCleanCacheAfterReconnect(void) ...@@ -1042,7 +1044,8 @@ static void nxagentCleanCacheAfterReconnect(void)
nxCacheFontEntryRecPtr swapEntryPtr; nxCacheFontEntryRecPtr swapEntryPtr;
/* Find - first bad occurrence if exist. */ /* Find - first bad occurrence if exist. */
while ((i < real_size) && CACHE_FSTRUCT(i)) i++; while ((i < real_size) && CACHE_FSTRUCT(i))
i++;
/* Really nothing more to do. */ /* Really nothing more to do. */
if (i == real_size) if (i == real_size)
...@@ -1123,13 +1126,12 @@ Bool nxagentReconnectAllFonts(void *p0) ...@@ -1123,13 +1126,12 @@ Bool nxagentReconnectAllFonts(void *p0)
static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2) static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2)
{ {
int i; int i;
nxagentPrivFont *privFont;
Bool *pBool = (Bool*)param2; Bool *pBool = (Bool*)param2;
if (pFont == NULL) if (pFont == NULL)
return; return;
privFont = nxagentFontPriv(pFont); nxagentPrivFont *privFont = nxagentFontPriv(pFont);
#ifdef NXAGENT_RECONNECT_FONT_DEBUG #ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf(stderr, "nxagentFailedFontReconnect: pFont %p - XID %lx - name %s\n", fprintf(stderr, "nxagentFailedFontReconnect: pFont %p - XID %lx - name %s\n",
...@@ -1211,15 +1213,7 @@ static void nxagentFreeFailedToReconnectFonts(void) ...@@ -1211,15 +1213,7 @@ static void nxagentFreeFailedToReconnectFonts(void)
Bool nxagentReconnectFailedFonts(void *p0) Bool nxagentReconnectFailedFonts(void *p0)
{ {
int attempt = 1;
const int maxAttempt = 5;
char **fontPaths, **localFontPaths, **newFontPaths;
char fontServerPath[256] = ""; char fontServerPath[256] = "";
int nPaths = 0;
Bool repeat = True;
Bool fontSuccess = True;
reconnectFlexibility = *((int *) p0); reconnectFlexibility = *((int *) p0);
...@@ -1239,20 +1233,25 @@ Bool nxagentReconnectFailedFonts(void *p0) ...@@ -1239,20 +1233,25 @@ Bool nxagentReconnectFailedFonts(void *p0)
fprintf(stderr, "nxagentReconnectFailedFonts: font server path [%s]\n", fontServerPath); fprintf(stderr, "nxagentReconnectFailedFonts: font server path [%s]\n", fontServerPath);
#endif #endif
fontPaths = XGetFontPath(nxagentDisplay, &nPaths); int nPaths = 0;
char **fontPaths = XGetFontPath(nxagentDisplay, &nPaths);
char **newFontPaths = malloc((nPaths + 1) * sizeof(char *));
if ((newFontPaths = malloc((nPaths + 1) * sizeof(char *))) == NULL) if (newFontPaths == NULL)
{ {
FatalError("nxagentReconnectFailedFonts: malloc failed."); FatalError("nxagentReconnectFailedFonts: malloc failed.");
} }
memcpy(newFontPaths, fontPaths, nPaths * sizeof(char*)); memcpy(newFontPaths, fontPaths, nPaths * sizeof(char*));
localFontPaths = newFontPaths; char **localFontPaths = newFontPaths;
localFontPaths += nPaths; localFontPaths += nPaths;
*localFontPaths = fontServerPath; *localFontPaths = fontServerPath;
while(repeat) int attempt = 1;
const int maxAttempt = 5;
Bool repeat = True;
while (repeat)
{ {
#ifdef NXAGENT_RECONNECT_FONT_DEBUG #ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf(stderr, "nxagentReconnectFailedFonts: attempt [%d].\n", attempt); fprintf(stderr, "nxagentReconnectFailedFonts: attempt [%d].\n", attempt);
...@@ -1264,11 +1263,11 @@ Bool nxagentReconnectFailedFonts(void *p0) ...@@ -1264,11 +1263,11 @@ Bool nxagentReconnectFailedFonts(void *p0)
nxagentFreeRemoteFontList(&nxagentRemoteFontList); nxagentFreeRemoteFontList(&nxagentRemoteFontList);
nxagentListRemoteFonts("*", nxagentMaxFontNames); nxagentListRemoteFonts("*", nxagentMaxFontNames);
for(int i = 0; i < nxagentFailedToReconnectFonts.index; i++) for (int i = 0; i < nxagentFailedToReconnectFonts.index; i++)
{ {
fontSuccess = True; Bool fontSuccess = True;
if(nxagentFailedToReconnectFonts.font[i]) if (nxagentFailedToReconnectFonts.font[i])
{ {
nxagentFailedFontReconnect(nxagentFailedToReconnectFonts.font[i], nxagentFailedFontReconnect(nxagentFailedToReconnectFonts.font[i],
nxagentFailedToReconnectFonts.id[i], nxagentFailedToReconnectFonts.id[i],
...@@ -1282,7 +1281,6 @@ Bool nxagentReconnectFailedFonts(void *p0) ...@@ -1282,7 +1281,6 @@ Bool nxagentReconnectFailedFonts(void *p0)
{ {
repeat = True; repeat = True;
} }
} }
} }
...@@ -1334,9 +1332,9 @@ Bool nxagentDisconnectAllFonts(void) ...@@ -1334,9 +1332,9 @@ Bool nxagentDisconnectAllFonts(void)
FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT,
(FindResType) nxagentFontDisconnect, &fontSuccess); (FindResType) nxagentFontDisconnect, &fontSuccess);
for(int cid = 0; cid < MAXCLIENTS; cid++) for (int cid = 0; cid < MAXCLIENTS; cid++)
{ {
if( clients[cid] && fontSuccess ) if (clients[cid] && fontSuccess)
{ {
FindClientResourcesByType(clients[cid], RT_FONT, FindClientResourcesByType(clients[cid], RT_FONT,
(FindResType) nxagentFontDisconnect, &fontSuccess); (FindResType) nxagentFontDisconnect, &fontSuccess);
...@@ -1505,10 +1503,7 @@ void nxagentVerifyDefaultFontPath(void) ...@@ -1505,10 +1503,7 @@ void nxagentVerifyDefaultFontPath(void)
XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFont) XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFont)
{ {
XFontStruct* fs; XFontStruct* fs = (XFontStruct *) malloc (sizeof (XFontStruct));
xCharInfo *xcip;
fs = (XFontStruct *) malloc (sizeof (XFontStruct));
if (fs == NULL) if (fs == NULL)
{ {
...@@ -1552,7 +1547,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo ...@@ -1552,7 +1547,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo
if (fs -> n_properties > 0) if (fs -> n_properties > 0)
{ {
register long nbytes; long nbytes;
nbytes = pFont -> info.nprops * sizeof(XFontProp); nbytes = pFont -> info.nprops * sizeof(XFontProp);
fs -> properties = (XFontProp *) malloc((unsigned) nbytes); fs -> properties = (XFontProp *) malloc((unsigned) nbytes);
...@@ -1570,7 +1565,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo ...@@ -1570,7 +1565,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo
memmove(fs -> properties, pFont -> info.props, nbytes); memmove(fs -> properties, pFont -> info.props, nbytes);
} }
xcip = (xCharInfo *) &pFont -> info.ink_minbounds; xCharInfo *xcip = (xCharInfo *) &pFont -> info.ink_minbounds;
fs -> min_bounds.lbearing = cvtINT16toShort(xcip -> leftSideBearing); fs -> min_bounds.lbearing = cvtINT16toShort(xcip -> leftSideBearing);
fs -> min_bounds.rbearing = cvtINT16toShort(xcip -> rightSideBearing); fs -> min_bounds.rbearing = cvtINT16toShort(xcip -> rightSideBearing);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment