Commit 8029141e authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Font.c: build the font paths at runtime

Drop the font path defines and build the path strings at runtime instead.
parent bcb5c796
...@@ -76,21 +76,13 @@ is" without express or implied warranty. ...@@ -76,21 +76,13 @@ is" without express or implied warranty.
#define NXAGENT_ALTERNATE_FONT_DIR_2 "/usr/share/fonts/X11" #define NXAGENT_ALTERNATE_FONT_DIR_2 "/usr/share/fonts/X11"
#define NXAGENT_ALTERNATE_FONT_DIR_3 "/usr/X11R6/lib/X11/fonts" #define NXAGENT_ALTERNATE_FONT_DIR_3 "/usr/X11R6/lib/X11/fonts"
#define NXAGENT_DEFAULT_FONT_PATH \ const char * nxagentFontSubdirs[] = {
"/usr/share/nx/fonts/Type1/,/usr/share/nx/fonts/75dpi/,\ "Type1",
/usr/share/nx/fonts/100dpi/,/usr/share/nx/fonts/TTF/" "75dpi",
"100dpi",
#define NXAGENT_ALTERNATE_FONT_PATH \ "TTF",
"/usr/share/X11/fonts/Type1/,/usr/share/X11/fonts/75dpi/,\ NULL
/usr/share/X11/fonts/100dpi/,/usr/share/X11/fonts/TTF/" };
#define NXAGENT_ALTERNATE_FONT_PATH_2 \
"/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,\
/usr/share/fonts/X11/100dpi/,/usr/share/fonts/X11/TTF/"
#define NXAGENT_ALTERNATE_FONT_PATH_3 \
"/usr/X11R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/75dpi/,\
/usr/X11R6/lib/X11/fonts/100dpi/,/usr/X11R6/lib/X11/fonts/TTF/"
#undef NXAGENT_FONTCACHE_DEBUG #undef NXAGENT_FONTCACHE_DEBUG
#undef NXAGENT_RECONNECT_FONT_DEBUG #undef NXAGENT_RECONNECT_FONT_DEBUG
...@@ -1439,10 +1431,9 @@ static Bool nxagentGetFontServerPath(char * fontServerPath, int size) ...@@ -1439,10 +1431,9 @@ static Bool nxagentGetFontServerPath(char * fontServerPath, int size)
return True; return True;
} }
void nxagentVerifySingleFontPath(char **dest, const char *fontDir, const char *fontPath) void nxagentVerifySingleFontPath(char **dest, const char *fontDir)
{ {
struct stat dirStat; struct stat dirStat;
char * newdest = NULL;
if (!dest || !*dest) if (!dest || !*dest)
return; return;
...@@ -1455,22 +1446,32 @@ void nxagentVerifySingleFontPath(char **dest, const char *fontDir, const char *f ...@@ -1455,22 +1446,32 @@ void nxagentVerifySingleFontPath(char **dest, const char *fontDir, const char *f
validateString(fontDir)); validateString(fontDir));
#endif #endif
if (**dest != '\0') for (int i = 0; ; i++)
{ {
newdest = realloc(*dest, strlen(*dest) + strlen(fontPath) + 2); char *tmppath = NULL;
if (newdest == NULL) int rc;
const char *subdir = nxagentFontSubdirs[i];
if (subdir == NULL)
return; return;
strcat(newdest, ",");
if (**dest != '\0')
{
rc = asprintf(&tmppath, "%s,%s/%s", *dest, fontDir, subdir);
} }
else else
{ {
newdest = realloc(*dest, strlen(*dest) + strlen(fontPath) + 1); rc = asprintf(&tmppath, "%s/%s", fontDir, subdir);
if (newdest == NULL)
return;
} }
strcat(newdest, fontPath); if (rc == -1)
*dest = newdest; return;
free(*dest);
*dest = tmppath;
tmppath = NULL;
}
} }
} }
...@@ -1496,10 +1497,10 @@ void nxagentVerifyDefaultFontPath(void) ...@@ -1496,10 +1497,10 @@ void nxagentVerifyDefaultFontPath(void)
return; return;
} }
nxagentVerifySingleFontPath(&fontPath, NXAGENT_DEFAULT_FONT_DIR, NXAGENT_DEFAULT_FONT_PATH); nxagentVerifySingleFontPath(&fontPath, NXAGENT_DEFAULT_FONT_DIR);
nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR, NXAGENT_ALTERNATE_FONT_PATH); nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR);
nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR_2, NXAGENT_ALTERNATE_FONT_PATH_2); nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR_2);
nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR_3, NXAGENT_ALTERNATE_FONT_PATH_3); nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR_3);
if (*fontPath == '\0') if (*fontPath == '\0')
{ {
......
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