@@ -58,12 +58,15 @@ final class EPUBNavigatorViewModel: Loggable {
5858 )
5959 }
6060
61+ let resourceURL = Bundle . module. resourceURL!. fileURL!
62+
6163 // FIXME: Remove in Readium 3.0
6264 // Serve the fonts under the /fonts endpoint as the Streamer's
6365 // EPUBHTMLInjector is expecting it there.
64- if let fontsURL = ( Bundle . module. resourceURL? . appendingPathComponent ( " Assets/Static/fonts " ) ) . flatMap ( FileURL . init ( url: ) ) {
65- try httpServer. serve ( at: " fonts " , contentsOf: fontsURL)
66- }
66+ try httpServer. serve (
67+ at: " fonts " ,
68+ contentsOf: resourceURL. appendingPath ( " Assets/Static/fonts " , isDirectory: true )
69+ )
6770
6871 try self . init (
6972 publication: publication,
@@ -73,7 +76,7 @@ final class EPUBNavigatorViewModel: Loggable {
7376 publicationBaseURL: baseURL,
7477 assetsURL: httpServer. serve (
7578 at: " readium " ,
76- contentsOf: FileURL ( url : Bundle . module . resourceURL! . appendingPathComponent ( " Assets/Static " ) ) !
79+ contentsOf: resourceURL. appendingPath ( " Assets/Static " , isDirectory : true )
7780 ) ,
7881 useLegacySettings: false
7982 )
@@ -105,25 +108,25 @@ final class EPUBNavigatorViewModel: Loggable {
105108 ) {
106109 var config = config
107110
108- if let fontsDir = Bundle . module. resourceURL. flatMap ( FileURL . init ( url : ) ) ? . appendingPath ( " Assets/Static/fonts " ) {
111+ if let fontsDir = Bundle . module. resourceURL? . fileURL ? . appendingPath ( " Assets/Static/fonts " , isDirectory : true ) {
109112 config. fontFamilyDeclarations. append (
110113 CSSFontFamilyDeclaration (
111114 fontFamily: . openDyslexic,
112115 fontFaces: [
113116 CSSFontFace (
114- file: fontsDir. appendingPath ( " OpenDyslexic-Regular.otf " ) ! ,
117+ file: fontsDir. appendingPath ( " OpenDyslexic-Regular.otf " , isDirectory : false ) ,
115118 style: . normal, weight: . standard( . normal)
116119 ) ,
117120 CSSFontFace (
118- file: fontsDir. appendingPath ( " OpenDyslexic-Italic.otf " ) ! ,
121+ file: fontsDir. appendingPath ( " OpenDyslexic-Italic.otf " , isDirectory : false ) ,
119122 style: . italic, weight: . standard( . normal)
120123 ) ,
121124 CSSFontFace (
122- file: fontsDir. appendingPath ( " OpenDyslexic-Bold.otf " ) ! ,
125+ file: fontsDir. appendingPath ( " OpenDyslexic-Bold.otf " , isDirectory : false ) ,
123126 style: . normal, weight: . standard( . bold)
124127 ) ,
125128 CSSFontFace (
126- file: fontsDir. appendingPath ( " OpenDyslexic-BoldItalic.otf " ) ! ,
129+ file: fontsDir. appendingPath ( " OpenDyslexic-BoldItalic.otf " , isDirectory : false ) ,
127130 style: . italic, weight: . standard( . bold)
128131 ) ,
129132 ]
@@ -150,7 +153,7 @@ final class EPUBNavigatorViewModel: Loggable {
150153 css = ReadiumCSS (
151154 layout: CSSLayout ( ) ,
152155 rsProperties: config. readiumCSSRSProperties,
153- baseURL: assetsURL. appendingPath ( " readium-css/ " ) ! ,
156+ baseURL: assetsURL. appendingPath ( " readium-css " , isDirectory : true ) ,
154157 fontFamilyDeclarations: config. fontFamilyDeclarations
155158 )
156159
0 commit comments