Permalink
Browse files

Force fontconfig configuration on Mac OSX.

Somewhere along the line fontconfig stopped looking in the current
directory for the "fonts" directory that was packaged with PMS on
Mac OSX. Also, Apple stopped shipping X11 by default which changed
the font directories. As a result of both, fontconfig could no
longer find any fonts on Mac OSX.
  • Loading branch information...
1 parent 1f2a72e commit dc28a19d26aec33e462391e53046bd924e2c2b3c @Raptor399 Raptor399 committed Feb 10, 2013
@@ -23,6 +23,8 @@
<!-- Font directory list -->
+ <dir>/Library/Fonts</dir>
+ <dir>/opt/X11/share/fonts</dir>
<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>~/.fonts</dir>
@@ -24,6 +24,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.sun.jna.Platform;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -33,6 +35,10 @@
public class ProcessWrapperImpl extends Thread implements ProcessWrapper {
private static final Logger LOGGER = LoggerFactory.getLogger(ProcessWrapperImpl.class);
+
+ /** FONTCONFIG_PATH environment variable name */
+ private static final String FONTCONFIG_PATH = "FONTCONFIG_PATH";
+
private String cmdLine;
private Process process;
private OutputConsumer stdoutConsumer;
@@ -128,8 +134,13 @@ public void run() {
pb.directory(params.workDir);
}
+ // Retrieve all environment variables of the process
+ Map<String,String> environment = pb.environment();
+
+ // The variable params.env is initialized to null in the OutputParams
+ // constructor and never set to another value in PMS code. Plugins
+ // might use it?
if (params.env != null && !params.env.isEmpty()) {
- Map<String,String> environment = pb.environment();
// actual name of system path var is case-sensitive
String sysPathKey = PMS.get().isWindows() ? "Path" : "PATH";
// as is Map
@@ -148,6 +159,21 @@ public void run() {
}
}
+ // Fontconfig on Mac OSX may have problems locating fonts. As a result
+ // subtitles may be rendered invisible. Force feed fontconfig the
+ // FONTCONFIG_PATH environment variable to the prepackaged fontconfig
+ // configuration directory that comes with PMS on Mac OSX to make
+ // sure it has sensible defaults.
+ if (Platform.isMac()) {
+ // Do not overwrite the variable if it already exists.
+ if (!environment.containsKey(FONTCONFIG_PATH)) {
+ String pmsWorkingDirectory = new File("").getAbsolutePath();
+ String fontconfigFontsPath = pmsWorkingDirectory + "/fonts";
+ LOGGER.trace("Setting FONTCONFIG_PATH to \"" + fontconfigFontsPath + "\"");
+ environment.put(FONTCONFIG_PATH, fontconfigFontsPath);
+ }
+ }
+
// XXX A cleaner way to execute short-running commands (e.g. vlc -version)
// is being developed. When that's done, this class can be used solely
// for the long-running tasks i.e. transcodes. At that point, we won't need

0 comments on commit dc28a19

Please sign in to comment.