Add fonts.conf to OS X build to try to fix failure to synthesize v2.13.142
authorCarl Hetherington <cth@carlh.net>
Wed, 3 Apr 2019 21:58:44 +0000 (22:58 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 3 Apr 2019 21:58:44 +0000 (22:58 +0100)
bold/italic on 10.12 (Sierra) and earlier (#1524).

fonts/fonts.conf [deleted file]
fonts/fonts.conf.osx [new file with mode: 0644]
fonts/fonts.conf.windows [new file with mode: 0644]
platform/osx/make_dmg.sh
platform/windows/wscript
src/lib/util.cc

diff --git a/fonts/fonts.conf b/fonts/fonts.conf
deleted file mode 100644 (file)
index 2b1c0ae..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<fontconfig>
-<dir>C:\windows\fonts</dir>
-<cachedir>~/AppData/Local/Temp/fontconfig</cachedir>
-</fontconfig>
-
diff --git a/fonts/fonts.conf.osx b/fonts/fonts.conf.osx
new file mode 100644 (file)
index 0000000..4dc37c0
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+
+<cachedir>~/.fontconfig</cachedir>
+<cachedir prefix="xdg">fontconfig</cachedir>
+
+<!-- 
+ Artificial oblique for fonts without an italic or oblique version
+ -->
+       <match target="font">
+               <!-- check to see if the font is roman -->
+               <test name="slant">
+                       <const>roman</const>
+               </test>
+               <!-- check to see if the pattern requested non-roman -->
+               <test target="pattern" name="slant" compare="not_eq">
+                       <const>roman</const>
+               </test>
+               <!-- multiply the matrix to slant the font -->
+               <edit name="matrix" mode="assign">
+                       <times>
+                               <name>matrix</name>
+                               <matrix><double>1</double><double>0.2</double>
+                                       <double>0</double><double>1</double>
+                               </matrix>
+                       </times>
+               </edit>
+               <!-- pretend the font is oblique now -->
+               <edit name="slant" mode="assign">
+                       <const>oblique</const>
+               </edit>
+               <!-- and disable embedded bitmaps for artificial oblique -->
+               <edit name="embeddedbitmap" mode="assign">
+                       <bool>false</bool>
+               </edit>
+       </match>
+
+<!--
+ Synthetic emboldening for fonts that do not have bold face available
+ -->
+
+       <match target="font">
+               <!-- check to see if the font is just regular -->
+               <test name="weight" compare="less_eq">
+                       <const>medium</const>
+               </test>
+               <!-- check to see if the pattern requests bold -->
+               <test target="pattern" name="weight" compare="more">
+                       <const>medium</const>
+               </test>
+               <!--
+                 set the embolden flag
+                 needed for applications using cairo, e.g. gucharmap, gedit, ...
+               -->
+               <edit name="embolden" mode="assign">
+                       <bool>true</bool>
+               </edit>
+               <!--
+                set weight to bold
+                needed for applications using Xft directly, e.g. Firefox, ...
+               -->
+               <edit name="weight" mode="assign">
+                       <const>bold</const>
+               </edit>
+       </match>
+</fontconfig>
diff --git a/fonts/fonts.conf.windows b/fonts/fonts.conf.windows
new file mode 100644 (file)
index 0000000..2b1c0ae
--- /dev/null
@@ -0,0 +1,5 @@
+<fontconfig>
+<dir>C:\windows\fonts</dir>
+<cachedir>~/AppData/Local/Temp/fontconfig</cachedir>
+</fontconfig>
+
index b9cdaec..4afb547 100644 (file)
@@ -129,6 +129,7 @@ function copy_resources {
     cp $ROOT/32/src/dcpomatic/fonts/LiberationSans-Regular.ttf "$dest"
     cp $ROOT/32/src/dcpomatic/fonts/LiberationSans-Italic.ttf "$dest"
     cp $ROOT/32/src/dcpomatic/fonts/LiberationSans-Bold.ttf "$dest"
+    cp $ROOT/32/src/dcpomatic/fonts/fonts.conf.osx "$dest"/fonts.conf
     cp $ROOT/32/src/dcpomatic/graphics/splash.png "$dest"
     cp $ROOT/32/src/dcpomatic/graphics/zoom.png "$dest"
     cp $ROOT/32/src/dcpomatic/graphics/zoom_all.png "$dest"
index baca6b5..a6b7054 100644 (file)
@@ -294,7 +294,7 @@ SetOutPath "$INSTDIR"
 File "%resources%/../../fonts/LiberationSans-Regular.ttf"
 File "%resources%/../../fonts/LiberationSans-Italic.ttf"
 File "%resources%/../../fonts/LiberationSans-Bold.ttf"
-File "%resources%/../../fonts/fonts.conf"
+File /oname=fonts.conf "%resources%/../../fonts/fonts.conf.windows"
 File "%graphics%/splash.png"
 File "%graphics%/zoom.png"
 File "%graphics%/zoom_all.png"
index c208914..340af1e 100644 (file)
@@ -379,7 +379,7 @@ dcpomatic_setup ()
        Pango::init ();
        dcp::init ();
 
-#ifdef DCPOMATIC_WINDOWS
+#if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX)
        /* Render something to fontconfig to create its cache */
        list<StringText> subs;
        dcp::SubtitleString ss(