Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b6c548b
Minor changes
mickael-menu Nov 29, 2022
cc35ad4
Deprecate `VisualNavigator.readingProgression`
mickael-menu Nov 29, 2022
68159d7
Adjust EPUB preferences editor
mickael-menu Nov 29, 2022
7852b35
Remove `SwitchPreference`
mickael-menu Nov 30, 2022
ac0516f
Add `Preference<T>.toggle(T?)`, which is useful for button groups
mickael-menu Nov 30, 2022
3d09140
Add mapping capabilities
mickael-menu Dec 3, 2022
64b5f96
Add more font weight variants
mickael-menu Dec 3, 2022
7cb5935
Font family is not an enum anymore
mickael-menu Dec 3, 2022
1889e9c
Fix coercion of range preference
mickael-menu Dec 3, 2022
b092343
Combine preferences filter
mickael-menu Dec 4, 2022
0e4c75f
Improve background color support
mickael-menu Dec 4, 2022
9d0de3e
Remove preferences editor configurations
mickael-menu Dec 5, 2022
dceec90
Allow preloading of font faces
mickael-menu Dec 5, 2022
94b4aa6
Restore text zoom when restoring the EPUB navigator
mickael-menu Dec 5, 2022
6c4dbf1
Fix parsing legacy advanced settings flag
mickael-menu Dec 6, 2022
17465fc
Remove Either.listOf()
mickael-menu Dec 7, 2022
ebcd29e
Merge branch 'develop' into fix/settings
mickael-menu Dec 7, 2022
b3ee7d5
Merge branch 'develop' of github.com:readium/kotlin-toolkit into fix/…
mickael-menu Dec 8, 2022
3247e1a
Fix changelog
mickael-menu Dec 9, 2022
9544f14
Add `fontWeight` preference
mickael-menu Dec 9, 2022
5311857
Enable variable fonts
mickael-menu Dec 9, 2022
ce62c48
Make most EPUB settings nullable
mickael-menu Dec 12, 2022
0584b07
Add per setting clear button
mickael-menu Dec 12, 2022
64c131b
Fix `StepsProgression.decrement()`
mickael-menu Dec 12, 2022
1628073
Merge branch 'develop' into fix/settings
mickael-menu Dec 13, 2022
a123252
Make `spread` a publication preference
mickael-menu Dec 14, 2022
1108cf8
Fix floating points comparisons with `StepsProgression`
mickael-menu Dec 14, 2022
1c31203
Fix applying the background color to the resource pager
mickael-menu Dec 14, 2022
9f13b9e
Disable edge taps in scroll mode
mickael-menu Dec 15, 2022
b0234b9
Fix memory leak when invalidating the resource pager
mickael-menu Dec 15, 2022
2e32a6b
Disable edge tap navigation when using the new settings API
mickael-menu Dec 19, 2022
44070ec
Apply suggestions from code review
mickael-menu Dec 19, 2022
4825e14
Merge branch 'fix/settings' of github.com:readium/kotlin-toolkit into…
mickael-menu Dec 19, 2022
8b7fba3
Add vararg variants
mickael-menu Dec 19, 2022
ecb032b
Make `resourceAtUrl` optional
mickael-menu Dec 19, 2022
462e0fa
Remove non embedded `FontFamily` and fix `alternate`
mickael-menu Dec 20, 2022
4e5fbd7
Improve the configuration API
mickael-menu Dec 20, 2022
d0b35b6
Update font guide
mickael-menu Dec 20, 2022
8eb980f
Clean up user preferences view model
mickael-menu Dec 21, 2022
a74850a
Alternate way to update the Compose UI
mickael-menu Dec 21, 2022
e259544
Fix GitHub workflows
mickael-menu Dec 21, 2022
d4769e9
Disable checks for draft PRs
mickael-menu Dec 21, 2022
265a6b5
Various fixes
mickael-menu Dec 22, 2022
e96f412
Edit navigator settings guide
mickael-menu Dec 22, 2022
cfccf62
Document preferences constraints
mickael-menu Dec 22, 2022
8fb59ab
Expand documentation comments in the editors
mickael-menu Dec 22, 2022
27e21ee
Update migration guide
mickael-menu Dec 22, 2022
d776fae
More changes
mickael-menu Dec 22, 2022
b042932
Merge branch 'develop' into fix/settings
mickael-menu Dec 25, 2022
1b197bb
Adjust GH action triggers
mickael-menu Dec 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
name: Build and test
runs-on: ubuntu-latest

if: ${{ !github.event.pull_request.draft }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -19,31 +19,45 @@ jobs:
java-version: '11'
distribution: 'adopt'
- name: Build
run: ./gradlew clean build -x test
run: ./gradlew clean build -x test -x ktlintMainSourceSetCheck
- name: Test
run: ./gradlew test --continue

lint:
name: Lint
lint-kt:
name: Lint Kotlin
runs-on: macos-latest
if: ${{ !github.event.pull_request.draft }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Lint
run: ./gradlew ktlintCheck

lint-js:
name: Lint JavaScript
runs-on: macos-latest
if: ${{ !github.event.pull_request.draft }}
defaults:
run:
working-directory: readium/navigator
env:
scripts: ${{ 'src/main/assets/_scripts' }}

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: make install
- name: Lint JavaScript
- name: Lint
run: yarn --cwd "$scripts" run lint
- name: Check JavaScript formatting
- name: Check formatting
run: yarn --cwd "$scripts" run checkformat
# FIXME: This suddenly stopped working even though the toolchain versions seem identical.
# - name: Check if bundled scripts are up-to-date
# run: |
# make scripts
# git diff --exit-code --name-only src/main/assets/readium/scripts/*.js

13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ All notable changes to this project will be documented in this file. Take a look
#### Shared

* Extract the raw content (text, images, etc.) of a publication. [Take a look at the user guide](docs/guides/content.md).
* Add support for unsafe HTTP redirections with `HttpDefaultClient`.
* You will need to opt-in explicitly by implementing `HttpDefaultClient.Callback.onFollowUnsafeRedirect`.
* Add support for unsafe HTTP redirections with `DefaultHttpClient`.
* You will need to opt-in explicitly by implementing `DefaultHttpClient.Callback.onFollowUnsafeRedirect`.

#### Navigator

Expand Down Expand Up @@ -42,11 +42,12 @@ All notable changes to this project will be documented in this file. Take a look
```
* New [PSPDFKit](readium/adapters/pspdfkit) adapter for rendering PDF documents. [Take a look at the user guide](docs/guides/pdf.md).
* [A brand new text-to-speech implementation](docs/guides/tts.md).
* [Support for custom fonts with the EPUB navigator](docs/guides/epub-custom-fonts.md).
* New EPUB user settings, as part of [the revamped Settings API](docs/guides/navigator-settings.md):
* [Support for custom fonts with the EPUB navigator](docs/guides/epub-fonts.md).
* New EPUB user preferences, as part of [the revamped Settings API](docs/guides/navigator-preferences.md):
* `backgroundColor` - Default page background color.
* `fontWeight` - Base text font weight.
* `textColor` - Default page text color.
* `textNormalization` - Normalize font style, weight and variants using a specific strategy (force bold, accessibility).
* `textNormalization` - Normalize font style, weight and variants, which improves accessibility.
* `imageFilter` - Filter applied to images in dark theme (darken, invert colors)
* `language` - Language of the publication content.
* `readingProgression` - Direction of the reading progression across resources, e.g. RTL.
Expand All @@ -66,7 +67,7 @@ All notable changes to this project will be documented in this file. Take a look

#### Navigator

* The EPUB user settings API got revamped. [Take a look at the user guide](docs/guides/navigator-settings.md) and the [migration guide](docs/migration-guide.md#230) to learn how to use it.
* The EPUB and PDF user preferences API got revamped. [Take a look at the user guide](docs/guides/navigator-preferences.md) and the [migration guide](docs/migration-guide.md#230) to learn how to use it.
* `Decoration.extras` is now a `Map<String, Any>` instead of `Bundle`. You will need to update your app if you were storing custom data in `extras`, for example:
```kotlin
val decoration = Decoration(...,
Expand Down
60 changes: 0 additions & 60 deletions docs/guides/epub-custom-fonts.md

This file was deleted.

125 changes: 125 additions & 0 deletions docs/guides/epub-fonts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# 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-preferences.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

Android does not ship with any font families except the generic ones: `sans-serif`, `serif`, `cursive` and `monospace`. As a result, the default selection of typefaces with the Readium Kotlin toolkit is quite limited.

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 these font families out of the box with the EPUB navigator:

```kotlin
// Set the current font family.
epubNavigator.submitPreferences(EpubPreferences(
fontFamily = FontFamily.OPEN_DYSLEXIC
))
```

```kotlin
// To customize the list of available font families with the preferences editor:
epubPreferencesEditor.fontFamily
.withSupportedValues(
FontFamily.SANS_SERIF,
FontFamily.SERIF,
FontFamily.CURSIVE,
FontFamily.MONOSPACE,
FontFamily.OPEN_DYSLEXIC,
FontFamily.ACCESSIBLE_DFA,
FontFamily.IA_WRITER_DUOSPACE
)
```

## 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. Copy the files to a subdirectory of your [app `assets`](https://developer.android.com/guide/topics/resources/providing-resources), such as `src/main/assets/fonts`.
3. Declare new extensions for your custom font families to make them first-class citizens. This is optional but convenient.
```kotlin
val FontFamily.Companion.ATKINSON_HYPERLEGIBLE get() = FontFamily("Atkinson Hyperlegible")
val FontFamily.Companion.LITERATA: FontFamily get() = FontFamily("Literata")
```
4. Configure the EPUB navigator with:
* `servedAssets` - An asset path pattern to serve your font files in the navigator.
* A declaration of the font faces for all the additional font families.
```kotlin
EpubNavigatorFactory(...).createFragmentFactory(
...,
configuration = EpubNavigatorFactory.Configuration {
// Add the assets folder which contains the font files to authorize the navigator to access it.
servedAssets += "fonts/.*"

// Declare a font family with a file per style.
addFontFamilyDeclaration(FontFamily.ATKINSON_HYPERLEGIBLE) {
addFontFace {
addSource("fonts/AtkinsonHyperlegible-Regular.ttf", preload = true)
setFontStyle(FontStyle.NORMAL)
setFontWeight(FontWeight.NORMAL)
}
addFontFace {
addSource("fonts/AtkinsonHyperlegible-Bold.ttf")
setFontStyle(FontStyle.NORMAL)
setFontWeight(FontWeight.BOLD)
}
addFontFace {
addSource("fonts/AtkinsonHyperlegible-Italic.ttf")
setFontStyle(FontStyle.ITALIC)
setFontWeight(FontWeight.NORMAL)
}
addFontFace {
addSource("fonts/AtkinsonHyperlegible-BoldItalic.ttf")
setFontStyle(FontStyle.ITALIC)
setFontWeight(FontWeight.BOLD)
}
}

// Declare a variable font family.
// See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide
addFontFamilyDeclaration(FontFamily.LITERATA) {
addFontFace {
addSource("fonts/Literata-VariableFont_opsz,wght.ttf")
setFontStyle(FontStyle.NORMAL)
setFontWeightRange(200..900)
}
addFontFace {
addSource("fonts/Literata-Italic-VariableFont_opsz,wght.ttf")
setFontStyle(FontStyle.ITALIC)
setFontWeightRange(200..900)
}
}
}
)
```

You are now ready to use your custom font families.

```kotlin
// Set the current font family.
epubNavigator.submitPreferences(EpubPreferences(
fontFamily = FontFamily.LITERATA
))
```

```kotlin
// To customize the list of available font families with the preferences editor:
epubPreferencesEditor.fontFamily
.withSupportedValues(
FontFamily.ATKINSON_HYPERLEGIBLE,
FontFamily.LITERATA,
FontFamily.OPEN_DYSLEXIC,
)
```

## Android Downloadable Fonts

Android [Downloadable Fonts](https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts) are not yet supported. Please open a new issue if you want to contribute this feature to Readium.

Loading