Updated README, added LICENSE

This commit is contained in:
2025-08-22 11:37:35 +02:00
parent eee6b0d739
commit 507cb87fe1
2 changed files with 65 additions and 12 deletions

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 Nico Verbruggen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -2,7 +2,7 @@
## Overview
`kobofix.py` is a Python script designed to process TTF fonts for Kobo e-readers.
**`kobofix.py` is a Python script designed to process and adjust TTF fonts for Kobo e-readers for a better reading experience with the default `kepub` renderer.**
It generates a renamed font, fixes PANOSE information based on the filename, adjusts the baseline with the `font-line` utility, and adds a legacy `kern` table which allows the `kepub` engine for improved rendering of kerned pairs.
@@ -29,23 +29,51 @@ source ~/.zshrc
## Usage
1. Open a terminal and navigate to the directory containing your font files.
2. Run the script with a glob pattern to include all TTF files:
Open a terminal and navigate to the directory containing your font files. Make sure your font files are named correctly. The script will process files that contain the string:
```bash
python3 kobofix.py *.ttf
```
3. The default script will:
- `Regular`
- `Italic`
- `Bold`
- `BoldItalic`
* Validate the file names (must end with `-Regular`, `-Bold`, `-Italic` or `-BoldItalic` so they're valid for Kobo devices).
* Process each font (e.g. "Lora" becomes "KF Lora").
* Apply kerning, rename, PANOSE adjustments, and baseline shift.
* Save output as `KF_<original_filename>`.
This is the naming convention used on Kobo devices for proper compatibility with both the `epub` and `kepub` renderer.
You can customize what the script does.
You can then run:
```bash
python3 kobofix.py ./src/*.ttf
```
By default, the script will:
1. **Validate all filenames.** If there are any invalid filenames, you will be prompted and can continue with all valid filenames, but it is recommended that you fix the invalid files.
2. **Remove any WWS name metadata from the font.** This is done because the font is renamed afterwards.
3. **Modify the internal name of the font.** Unless a new name was specified, this is merely a prefix that is applied. (By default, this is `KF`.)
4. **PANOSE metadata is checked and fixed.** Sometimes, the PANOSE information does not match the font style. This is often an oversight but it causes issues on Kobo devices, so this fixes that.
5. **Font weight metadata is updated.** There's other metadata that is part of the font that reflects the weight of the font. In case this information needs to be modified, it is adjusted.
6. **Kern pairs from the GPOS table are copied to the legacy `kern` table.** This only applies to fonts that have a GPOS table, which is used for kerning in modern fonts.
7. **The `font-line` helper is used to apply a 20% line-height setting.** This generates a new file which is immediately renamed to the desired output format.
## Customization
You can customize what the script does. For more information, consult:
```bash
./kobofix.py -h
```
Given the right arguments, you can:
- Skip the `kern` step
- Use a custom name for a font
- Use a custom name for the prefix
- Remove the `GPOS` table entirely
- Adjust the percentage of the `font-line` setting
- Skip running `font-line` altogether
For debugging purposes, you can run the script with the `--verbose` flag.
## Examples
### Generating KF fonts
This applies the KF prefix, applies 20 percent line spacing and adds a Kobo `kern` table. Ideal if you have an existing TrueType font and you want it on your Kobo device.
@@ -81,3 +109,7 @@ Relaxed spacing, with a custom font family name:
```
You can play around with `--line-percent` to see what works for you.
## License
Licensed under the [MIT License](/LICENSE).