You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Guides/Navigator/EPUB Fonts.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Font families in the EPUB navigator
2
2
3
-
Readium allows users to customize the font family used to render a reflowable EPUB, by changing the [EPUB navigator preferences](Navigator%20Preferences.md).
3
+
Readium allows users to customize the font family used to render a reflowable EPUB, by changing the [EPUB navigator preferences](Preferences.md).
4
4
5
5
> [!NOTE]
6
6
> 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.
return"Total progression in the publication: \(progression)%"
120
+
print("Total progression in the publication: \(totalProgression.formatted(.percent))")
121
121
}
122
122
123
123
// Save the position in your bookshelf database
@@ -151,8 +151,8 @@ To display a percentage-based progression slider, use the `locations.totalProgre
151
151
Given a progression from 0 to 1, you can obtain a `Locator` object from the `Publication`. This can be used to navigate to a specific percentage within the publication.
@@ -161,9 +161,7 @@ if let locator = publication.locate(progression: 0.5) {
161
161
> [!NOTE]
162
162
> Readium does not have the concept of pages, as they are not useful when dealing with reflowable publications across different screen sizes. Instead, we use [**positions**](https://readium.org/architecture/models/locators/positions/) which remain stable even when the user changes the font size or device.
163
163
164
-
Not all Navigators provide positions, but most `VisualNavigator` implementations do. Verify if `publication.positions` is not empty to determine if it is supported.
165
-
166
-
To find the total positions in the publication, use `publication.positions.count`. You can get the current position with `navigator.currentLocation?.locations.position`.
164
+
Not all Navigators provide positions, but most `VisualNavigator` implementations do. To find the total positions in the publication, use `try await publication.positions().get().count`. You can get the current position with `navigator.currentLocation?.locations.position`.
Copy file name to clipboardExpand all lines: docs/Guides/Readium LCP.md
+42-53Lines changed: 42 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -224,30 +224,25 @@ Users need to import a License Document into your application to download the pr
224
224
The `LCPService` offers an API to retrieve the full publication from an LCPL on the filesystem.
225
225
226
226
```swift
227
-
letacquisition = lcpService.acquirePublication(
228
-
from: lcplURL,
227
+
letresult =await lcpService.acquirePublication(
228
+
from: .file(lcplURL),
229
229
onProgress: { progress in
230
230
switch progress {
231
231
case .indefinite:
232
232
// Display an activity indicator.
233
233
case .percent(let percent):
234
234
// Display a progress bar with percent from 0 to 1.
235
235
}
236
-
},
237
-
completion: { result in
238
-
switch result {
239
-
caselet .success(publication):
240
-
// Import the `publication.localURL` file as any publication.
241
-
caselet .failure(error):
242
-
// Display the error message
243
-
case .cancelled:
244
-
// The acquisition was cancelled before completion.
245
-
}
246
236
}
247
237
)
248
-
```
249
238
250
-
If the user wants to cancel the download, call `cancel()` on the object returned by `LCPService.acquirePublication()`.
239
+
switch result {
240
+
caselet .success(publication):
241
+
// Import the `publication.localURL` file as any publication.
242
+
caselet .failure(error):
243
+
// Display the error message.
244
+
}
245
+
```
251
246
252
247
After the download is completed, import the `publication.localURL` file into the bookshelf like any other publication file.
253
248
@@ -308,7 +303,7 @@ The `allowUserInteraction` and `sender` arguments are forwarded to the `LCPAuthe
308
303
When importing the publication to the bookshelf, set `allowUserInteraction` to `false` as you don't need the passphrase for accessing the publication metadata and cover. If you intend to present the publication using a Navigator, set `allowUserInteraction` to `true` as decryption will be required.
309
304
310
305
> [!TIP]
311
-
> To check if a publication is protected with LCP before opening it, you can use `LCPService.isLCPProtected()`.
306
+
> To check if an asset is protected with LCP before opening it, you can use `asset.format.conformsTo(.lcp)`.
312
307
313
308
### Using the opened `Publication`
314
309
@@ -370,36 +365,30 @@ An LCP License Document contains metadata such as its expiration date, the remai
370
365
Use the `LCPService` to retrieve the `LCPLicense` instance for a publication.
You need to support both interactions by implementing the `LCPRenewDelegate` protocol. A default implementation is available with `LCPDefaultRenewDelegate`.
432
421
433
422
```swift
434
-
lcpLicense.renewLoan(
423
+
let result =awaitlcpLicense.renewLoan(
435
424
with: LCPDefaultRenewDelegate(
436
425
presentingViewController: hostViewController
437
426
)
438
-
) { result in
439
-
switch result {
440
-
case .success, .cancelled:
441
-
// The publication was renewed.
442
-
caselet .failure(error):
443
-
// Display the error.
444
-
}
427
+
)
428
+
429
+
switch result {
430
+
case .success:
431
+
// The publication was renewed.
432
+
caselet .failure(error):
433
+
// Display the error.
445
434
}
446
435
```
447
436
@@ -453,7 +442,7 @@ For an example, [take a look at the Test App](https://github.com/readium/swift-t
453
442
454
443
## Using the SwiftUI LCP Authentication dialog
455
444
456
-
If your application is built using SwiftUI, you cannot use `LCPAuthenticationDialog` because it requires a UIKit view controller as its host. Instead, use an `LCPObservableAuthentication` combined with our SwiftUI `LCPDialog` presented as a sheet.
445
+
If your application is built using SwiftUI, you cannot use `LCPDialogAuthentication` because it requires a UIKit view controller as its host. Instead, use an `LCPObservableAuthentication` combined with our SwiftUI `LCPDialog` presented as a sheet.
Copy file name to clipboardExpand all lines: docs/Migration Guide.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -435,16 +435,16 @@ let navigator = try EPUBNavigatorViewController(
435
435
436
436
### Upgrading to the new Preferences API
437
437
438
-
The 2.5.0 release introduces a brand new user preferences API for configuring the EPUB and PDF Navigators. This new API is easier and safer to use. To learn how to integrate it in your app, [please refer to the user guide](Guides/Navigator%20Preferences.md).
438
+
The 2.5.0 release introduces a brand new user preferences API for configuring the EPUB and PDF Navigators. This new API is easier and safer to use. To learn how to integrate it in your app, [please refer to the user guide](Guides/Navigator/Preferences.md).
439
439
440
440
If you integrated the EPUB navigator from a previous version, follow these steps to migrate:
441
441
442
-
1. Get familiar with [the concepts of this new API](Guides/Navigator%20Preferences.md#overview).
442
+
1. Get familiar with [the concepts of this new API](Guides/Navigator/Preferences.md#overview).
443
443
2. Migrate the local HTTP server from your app, [as explained in the previous section](#migrating-the-http-server).
444
-
3. Adapt your user settings interface to the new API using preferences editors. The [Test App](https://github.com/readium/swift-toolkit/blob/2.5.0/TestApp/Sources/Reader/Common/Preferences/UserPreferences.swift) and the [user guide](Guides/Navigator%20Preferences.md#build-a-user-settings-interface) contain examples using SwiftUI.
445
-
4.[Handle the persistence of the user preferences](Guides/Navigator%20Preferences.md#save-and-restore-the-user-preferences). The settings are not stored in the User Defaults by the toolkit anymore. Instead, you are responsible for persisting and restoring the user preferences as you see fit (e.g. as a JSON file).
444
+
3. Adapt your user settings interface to the new API using preferences editors. The [Test App](https://github.com/readium/swift-toolkit/blob/2.5.0/TestApp/Sources/Reader/Common/Preferences/UserPreferences.swift) and the [user guide](Guides/Navigator/Preferences.md#build-a-user-settings-interface) contain examples using SwiftUI.
445
+
4.[Handle the persistence of the user preferences](Guides/Navigator/Preferences.md#save-and-restore-the-user-preferences). The settings are not stored in the User Defaults by the toolkit anymore. Instead, you are responsible for persisting and restoring the user preferences as you see fit (e.g. as a JSON file).
446
446
* If you want to migrate the legacy EPUB settings, you can use the helper `EPUBPreferences.fromLegacyPreferences()` which will create a new `EPUBPreferences` object after translating the existing user settings.
447
-
5. Make sure you [restore the stored user preferences](Guides/Navigator%20Preferences.md#setting-the-initial-navigator-preferences-and-app-defaults) when initializing the EPUB navigator.
447
+
5. Make sure you [restore the stored user preferences](Guides/Navigator/Preferences.md#setting-the-initial-navigator-preferences-and-app-defaults) when initializing the EPUB navigator.
448
448
449
449
Please refer to the following table for the correspondence between legacy settings (from `UserSettings`) and new ones (`EPUBPreferences`).
0 commit comments