Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu committed Nov 18, 2024
2 parents 60aa620 + 36f4151 commit 165440b
Show file tree
Hide file tree
Showing 23 changed files with 601 additions and 5 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,22 @@ All notable changes to this project will be documented in this file. Take a look
* `Publication.localizedTitle` is now optional, as we cannot guarantee a publication will always have a title.


## [2.7.4]

### Fixed

* [#489](https://github.com/readium/swift-toolkit/issues/489) Fix crash related to Fuzi when compiling with Xcode 16 in release mode.

#### Navigator

* [#502](https://github.com/readium/swift-toolkit/issues/502) Fixed accessibility editing actions on iOS 18.


## [2.7.3]

* [#483](https://github.com/readium/swift-toolkit/issues/483) Fix build on Xcode 16.
### Fixed

* [#483](https://github.com/readium/swift-toolkit/issues/483) Fixed build on Xcode 16.


## [2.7.2]
Expand Down Expand Up @@ -774,6 +787,7 @@ progression. Now if no reading progression is set, the `effectiveReadingProgress
[2.7.1]: https://github.com/readium/swift-toolkit/compare/2.7.0...2.7.1
[2.7.2]: https://github.com/readium/swift-toolkit/compare/2.7.1...2.7.2
[2.7.3]: https://github.com/readium/swift-toolkit/compare/2.7.2...2.7.3
[2.7.4]: https://github.com/readium/swift-toolkit/compare/2.7.3...2.7.4
[3.0.0-alpha.1]: https://github.com/readium/swift-toolkit/compare/2.7.1...3.0.0-alpha.1
[3.0.0-alpha.2]: https://github.com/readium/swift-toolkit/compare/3.0.0-alpha.1...3.0.0-alpha.2
[3.0.0-alpha.3]: https://github.com/readium/swift-toolkit/compare/3.0.0-alpha.2...3.0.0-alpha.3
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github "cezheng/Fuzi" ~> 3.1.0
github "dexman/Minizip" ~> 1.4.0
github "krzyzanowskim/CryptoSwift" ~> 1.8.0
github "ra1028/DifferenceKit" ~> 1.3.0
github "readium/Fuzi" ~> 3.1.4
github "readium/GCDWebServer" ~> 4.0.0
# There's a regression with 2.7.4 in SwiftSoup, because they used iOS 13 APIs without bumping the deployment target.
github "scinfu/SwiftSoup" == 2.7.1
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ let package = Package(
.library(name: "ReadiumAdapterLCPSQLite", targets: ["ReadiumAdapterLCPSQLite"]),
],
dependencies: [
.package(url: "https://github.com/cezheng/Fuzi.git", from: "3.1.0"),
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.8.0"),
.package(url: "https://github.com/marmelroy/Zip.git", from: "2.1.0"),
.package(url: "https://github.com/ra1028/DifferenceKit.git", from: "1.3.0"),
.package(url: "https://github.com/readium/Fuzi.git", from: "3.1.4"),
.package(url: "https://github.com/readium/GCDWebServer.git", from: "4.0.0"),
.package(url: "https://github.com/scinfu/SwiftSoup.git", from: "2.7.0"),
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.15.0"),
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Readium Mobile](https://github.com/readium/mobile) is a toolkit for ebooks, audiobooks and comics written in Swift & Kotlin.

:point_up: **Take a look at the [guide to get started](Documentation/Guides/Getting%20Started.md).** A [Test App](TestApp) demonstrates how to integrate the Readium Swift toolkit in your own reading app.
:point_up: **Take a look at the [guide to get started](docs/Guides/Getting%20Started.md).** A [Test App](TestApp) demonstrates how to integrate the Readium Swift toolkit in your own reading app.

This toolkit is a modular project, which follows the [Readium Architecture](https://github.com/readium/architecture).

Expand Down Expand Up @@ -78,6 +78,7 @@ pod 'ReadiumNavigator', podspec: 'https://raw.githubusercontent.com/readium/swif
pod 'ReadiumOPDS', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/3.0.0-alpha.3/Support/CocoaPods/ReadiumOPDS.podspec'
pod 'ReadiumLCP', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/3.0.0-alpha.3/Support/CocoaPods/ReadiumLCP.podspec'
pod 'ReadiumInternal', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/3.0.0-alpha.3/Support/CocoaPods/ReadiumInternal.podspec'
pod 'Fuzi', podspec: 'https://raw.githubusercontent.com/readium/Fuzi/refs/heads/master/Fuzi.podspec'
# Required if you use ReadiumAdapterGCDWebServer.
pod 'ReadiumGCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/4.0.0/GCDWebServer.podspec'
Expand Down
6 changes: 6 additions & 0 deletions Sources/Navigator/EditingAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ final class EditingActionsController {
}

func canPerformAction(_ selector: Selector) -> Bool {
// Accessibility editing actions (e.g. Spoken Option in Accessibility
// system settings) cannot be properly disabled.
guard !selector.description.hasPrefix("_accessibility") else {
return true
}

guard
isEnabled,
let selection = selection,
Expand Down
1 change: 1 addition & 0 deletions TestApp/Integrations/CocoaPods/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target 'TestApp' do
pod 'ReadiumAdapterGCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/VERSION/Support/CocoaPods/ReadiumAdapterGCDWebServer.podspec'
pod 'ReadiumOPDS', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/VERSION/Support/CocoaPods/ReadiumOPDS.podspec'
pod 'ReadiumInternal', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/VERSION/Support/CocoaPods/ReadiumInternal.podspec'
pod 'Fuzi', podspec: 'https://raw.githubusercontent.com/readium/Fuzi/refs/heads/master/Fuzi.podspec'

# Required for R2Streamer and ReadiumAdapterGCDWebServer.
pod 'ReadiumGCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/master/GCDWebServer.podspec'
Expand Down
1 change: 1 addition & 0 deletions TestApp/Integrations/CocoaPods/Podfile+lcp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target 'TestApp' do
pod 'ReadiumOPDS', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/VERSION/Support/CocoaPods/ReadiumOPDS.podspec'
pod 'ReadiumLCP', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/VERSION/Support/CocoaPods/ReadiumLCP.podspec'
pod 'ReadiumInternal', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/VERSION/Support/CocoaPods/ReadiumInternal.podspec'
pod 'Fuzi', podspec: 'https://raw.githubusercontent.com/readium/Fuzi/refs/heads/master/Fuzi.podspec'
pod 'R2LCPClient', podspec: 'LCP_URL'

# Required for ReadiumStreamer and ReadiumAdapterGCDWebServer.
Expand Down
2 changes: 1 addition & 1 deletion Tests/LCPTests/Content Protection/LCPDecryptorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ class LCPDecryptorTests: XCTestCase {
completionExpectation.fulfill()
}

waitForExpectations(timeout: 10, handler: nil)
waitForExpectations(timeout: 30, handler: nil)
}
}
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions docs/Guides/Navigator/Assets/settings-flow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 119 additions & 0 deletions docs/Guides/Navigator/EPUB Fonts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Font families in the EPUB navigator

Readium allows users to customize the font family used to render a reflowable EPUB, by changing the [EPUB navigator preferences](Navigator%20Preferences.md).

:warning: You cannot change the default font family of a fixed-layout EPUB (with zoomable pages), as it is similar to a PDF or a comic book.

## Available font families

iOS ships with a large collection of font families that you can use directly in the EPUB preferences. [Take a look at the Apple catalog of System Fonts](https://developer.apple.com/fonts/system-fonts/).

To improve readability, Readium embeds three additional font families designed for accessibility:

* [OpenDyslexic](https://opendyslexic.org/)
* [AccessibleDfA](https://github.com/Orange-OpenSource/font-accessible-dfa), by Orange
* [iA Writer Duospace](https://github.com/iaolo/iA-Fonts/tree/master/iA%20Writer%20Duospace), by iA

You can use all the iOS System Fonts out of the box with the EPUB navigator:

```swift
epubNavigator.submitPreferences(EPUBPreferences(
fontFamily: "Palatino"
))
```

Alternatively, extend `FontFamily` to benefit from the compiler type safety:

```swift
extension FontFamily {
public static let palatino: FontFamily = "Palatino"
}

epubNavigator.submitPreferences(EPUBPreferences(
fontFamily: .palatino
))
```

For your convenience, a number of [recommended fonts](https://readium.org/readium-css/docs/CSS09-default_fonts) are pre-declared in the `FontFamily` type: Iowan Old Style, Palatino, Athelas, Georgia, Helvetica Neue, Seravek and Arial.

## Setting the available font families in the user interface

If you build your settings user interface with the EPUB Preferences Editor, you can customize the list of available font families using `with(supportedValues:)`.

```swift
epubPreferencesEditor.fontFamily.with(supportedValues: [
nil, // A `nil` value means that the original author font will be used.
.palatino,
.helveticaNeue,
.iaWriterDuospace,
.accessibleDfA,
.openDyslexic
])
```

## How to add custom font families?

To offer more choices to your users, you must embed and declare custom font families. Use the following steps:

1. Get the font files in the desired format, such as .ttf and .otf. [Google Fonts](https://fonts.google.com/) is a good source of free fonts.
2. Add the files to your app target from Xcode.
3. Declare new extensions for your custom font families to make them first-class citizens. This is optional but convenient.
```swift
extension FontFamily {
public static let literata: FontFamily = "Literata"
public static let atkinsonHyperlegible: FontFamily = "Atkinson Hyperlegible"
}
```
4. Configure the EPUB navigator with a declaration of the font faces for all the additional font families.
```swift
let resources = Bundle.main.resourceURL!
let navigator = try EPUBNavigatorViewController(
publication: publication,
initialLocation: locator,
config: .init(
fontFamilyDeclarations: [
CSSFontFamilyDeclaration(
fontFamily: .literata,
fontFaces: [
// Literata is a variable font family, so we can provide a font weight range.
// https://fonts.google.com/knowledge/glossary/variable_fonts
CSSFontFace(
file: resources.appendingPathComponent("Literata-VariableFont_opsz,wght.ttf"),
style: .normal, weight: .variable(200...900)
),
CSSFontFace(
file: resources.appendingPathComponent("Literata-Italic-VariableFont_opsz,wght.ttf"),
style: .italic, weight: .variable(200...900)
)
]
).eraseToAnyHTMLFontFamilyDeclaration(),

CSSFontFamilyDeclaration(
fontFamily: .atkinsonHyperlegible,
fontFaces: [
CSSFontFace(
file: resources.appendingPathComponent("Atkinson-Hyperlegible-Regular.ttf"),
style: .normal, weight: .standard(.normal)
),
CSSFontFace(
file: resources.appendingPathComponent("Atkinson-Hyperlegible-Italic.ttf"),
style: .italic, weight: .standard(.normal)
),
CSSFontFace(
file: resources.appendingPathComponent("Atkinson-Hyperlegible-Bold.ttf"),
style: .normal, weight: .standard(.bold)
),
CSSFontFace(
file: resources.appendingPathComponent("Atkinson-Hyperlegible-BoldItalic.ttf"),
style: .italic, weight: .standard(.bold)
),
]
).eraseToAnyHTMLFontFamilyDeclaration()
]
),
httpServer: GCDHTTPServer.shared
)
```

You are now ready to use your custom font families.

File renamed without changes.
Loading

0 comments on commit 165440b

Please sign in to comment.