Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
dff2e0a0
You need to sign in or sign up before continuing.
Commit
dff2e0a0
authored
Apr 03, 2019
by
Ulrich Sibiller
Committed by
Mike Gabriel
May 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Font.c: factor out font checks
parent
d94e9ba2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
92 deletions
+34
-92
Font.c
nx-X11/programs/Xserver/hw/nxagent/Font.c
+34
-92
No files found.
nx-X11/programs/Xserver/hw/nxagent/Font.c
View file @
dff2e0a0
...
...
@@ -1443,128 +1443,68 @@ static Bool nxagentGetFontServerPath(char * fontServerPath, int size)
return
True
;
}
void
nxagentVerify
DefaultFontPath
(
void
)
void
nxagentVerify
SingleFontPath
(
char
**
dest
,
const
char
*
fontDir
,
const
char
*
fontPath
)
{
struct
stat
dirStat
;
static
char
*
fontPath
;
#ifdef TEST
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Going to search for one or more valid font paths.
\n
"
);
#endif
/*
* Set the default font path as the first choice.
*/
if
((
fontPath
=
strdup
(
defaultFontPath
))
==
NULL
)
{
#ifdef WARNING
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: WARNING! Unable to allocate memory for a new font path. "
"Using the default font path [%s].
\n
"
,
validateString
(
defaultFontPath
));
#endif
char
*
newdest
=
NULL
;
if
(
!
dest
||
!*
dest
)
return
;
}
if
(
stat
(
NXAGENT_DEFAULT_FONT_DIR
,
&
dirStat
)
==
0
&&
if
(
stat
(
fontDir
,
&
dirStat
)
==
0
&&
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
{
/*
* Let's use the old "/usr/share/nx/fonts" style.
*/
#ifdef TEST
fprintf
(
stderr
,
"
nxagentVerifyDefaultFontPath: Assuming fonts in directory [%s].
\n
"
,
validateString
(
NXAGENT_DEFAULT_FONT_DIR
));
fprintf
(
stderr
,
"
%s: Assuming fonts in directory [%s].
\n
"
,
__func__
,
validateString
(
fontDir
));
#endif
if
(
*
fontPath
!=
'\0'
)
if
(
*
*
dest
!=
'\0'
)
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_DEFAULT_FONT_PATH
)
+
2
);
strcat
(
fontPath
,
","
);
newdest
=
realloc
(
*
dest
,
strlen
(
*
dest
)
+
strlen
(
fontPath
)
+
2
);
if
(
newdest
==
NULL
)
return
;
strcat
(
newdest
,
","
);
}
else
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_DEFAULT_FONT_PATH
)
+
1
);
newdest
=
realloc
(
*
dest
,
strlen
(
*
dest
)
+
strlen
(
fontPath
)
+
1
);
if
(
newdest
==
NULL
)
return
;
}
strcat
(
fontPath
,
NXAGENT_DEFAULT_FONT_PATH
);
strcat
(
newdest
,
fontPath
);
*
dest
=
newdest
;
}
}
if
(
stat
(
NXAGENT_ALTERNATE_FONT_DIR
,
&
dirStat
)
==
0
&&
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
{
/*
* Let's use the new "/usr/share/X11/fonts" path.
*/
void
nxagentVerifyDefaultFontPath
(
void
)
{
static
char
*
fontPath
;
#ifdef TEST
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Assuming fonts in directory [%s].
\n
"
,
validateString
(
NXAGENT_ALTERNATE_FONT_DIR
));
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Going to search for one or more valid font paths.
\n
"
);
#endif
if
(
*
fontPath
!=
'\0'
)
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH
)
+
2
);
strcat
(
fontPath
,
","
);
}
else
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH
)
+
1
);
}
strcat
(
fontPath
,
NXAGENT_ALTERNATE_FONT_PATH
);
}
if
(
stat
(
NXAGENT_ALTERNATE_FONT_DIR_2
,
&
dirStat
)
==
0
&&
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
{
/*
* Let's use the "/usr/share/fonts/X11" path
.
* Set the default font path as the first choice
.
*/
#ifdef TEST
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Assuming fonts in directory [%s].
\n
"
,
validateString
(
NXAGENT_ALTERNATE_FONT_DIR_2
));
#endif
if
(
*
fontPath
!=
'\0'
)
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH_2
)
+
2
);
strcat
(
fontPath
,
","
);
}
else
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH_2
)
+
1
);
}
strcat
(
fontPath
,
NXAGENT_ALTERNATE_FONT_PATH_2
);
}
if
(
stat
(
NXAGENT_ALTERNATE_FONT_DIR_3
,
&
dirStat
)
==
0
&&
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
if
((
fontPath
=
strdup
(
defaultFontPath
))
==
NULL
)
{
/*
* Let's use the "/usr/X11R6/lib/X11/fonts" path.
*/
#ifdef TEST
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Assuming fonts in directory [%s].
\n
"
,
validateString
(
NXAGENT_ALTERNATE_FONT_DIR_3
));
#ifdef WARNING
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: WARNING! Unable to allocate memory for a new font path. "
"Using the default font path [%s].
\n
"
,
validateString
(
defaultFontPath
));
#endif
if
(
*
fontPath
!=
'\0'
)
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH_3
)
+
2
);
strcat
(
fontPath
,
","
);
}
else
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH_3
)
+
1
);
return
;
}
strcat
(
fontPath
,
NXAGENT_ALTERNATE_FONT_PATH_3
);
}
nxagentVerifySingleFontPath
(
&
fontPath
,
NXAGENT_DEFAULT_FONT_DIR
,
NXAGENT_DEFAULT_FONT_PATH
);
nxagentVerifySingleFontPath
(
&
fontPath
,
NXAGENT_ALTERNATE_FONT_DIR
,
NXAGENT_ALTERNATE_FONT_PATH
);
nxagentVerifySingleFontPath
(
&
fontPath
,
NXAGENT_ALTERNATE_FONT_DIR_2
,
NXAGENT_ALTERNATE_FONT_PATH_2
);
nxagentVerifySingleFontPath
(
&
fontPath
,
NXAGENT_ALTERNATE_FONT_DIR_3
,
NXAGENT_ALTERNATE_FONT_PATH_3
);
if
(
*
fontPath
==
'\0'
)
{
#ifdef WARNING
...
...
@@ -1576,6 +1516,8 @@ void nxagentVerifyDefaultFontPath(void)
}
else
{
/* do _not_ free defaultFontPath here - it's either set at compile time or
part of argv */
defaultFontPath
=
fontPath
;
#ifdef TEST
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment