https://github.com/bradsec/fontconvert
A bash shell script for batch conversion of font files using fontforge. Supports both TrueType Font (TTF) and OpenType Font (OTF). Convert from either format.
https://github.com/bradsec/fontconvert
bash-script batch-processing conversion converter fontforge otf-fonts shell-script ttf-fonts
Last synced: about 1 year ago
JSON representation
A bash shell script for batch conversion of font files using fontforge. Supports both TrueType Font (TTF) and OpenType Font (OTF). Convert from either format.
- Host: GitHub
- URL: https://github.com/bradsec/fontconvert
- Owner: bradsec
- License: mit
- Created: 2022-11-03T23:26:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-04T07:44:47.000Z (almost 3 years ago)
- Last Synced: 2025-04-03T06:06:09.588Z (about 1 year ago)
- Topics: bash-script, batch-processing, conversion, converter, fontforge, otf-fonts, shell-script, ttf-fonts
- Language: Shell
- Homepage:
- Size: 6.84 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FONTCONVERT
A bash shell script for batch conversion of font files using fontforge. Supports both TrueType Font (TTF) and OpenType Font (OTF). Convert from either format.
`.ttf` files will be converted to `.otf`
`.otf` files will be converted to `.ttf`
By default new converted file names will be changed to lowercase and cleaned up to include only alpha-numeric characters. If you don't want the filename changed set `config[cleanName]=false` in the config array.
Any font files which cannot be converted due to being invalid, bad or corrupt files will be moved to the configured `config[badDir]` directory which by default is `./bad`.
To enable a recursive search of the source directory increase the `config[maxDepth]` from 1.
### Usage
```terminal
FONTCONVERT (for use with fontforge)
Usage:
Run script using: ./fontconvert.sh or bash fontconvert.sh
Source files to be converted need to be in [.../fontconvert/src].
.ttf files will be converted to .otf
.otf files will be converted to .ttf
New files will be saved in [.../fontconvert/dst].
Bad or corrupt source files will be moved to [.../fontconvert/bad].
```
### Script Setup
1. Clone the repo
```terminal
cd ~
git clone https://github.com/bradsec/fontconvert.git
cd fontconvert
```
2. Make script executable
```terminal
chmod +x fontconvert.sh
```
3. **Copy fonts to be converted into the `/fontconvert/src` directory.**
4. Run the script
```terminal
./fontconvert.sh
```
The files will be converted and saved in the `/fontconvert/dst` directory.
### Requirements
The fontforge package must be installed. Visit https://fontforge.org or https://github.com/fontforge/fontforge for more information.
- Debian/Ubuntu Linux install
```terminal
sudo apt install fontforge
```
- macOS install (using homebrew)
```terminal
brew install fontforge
```
- macOS may also require bash to be upgraded if running < bash v4
```terminal
brew install bash
exec bash
```
### Troubleshooting
Corrupt or bad font files will be prefixed by [FAIL]. The script will continue to process any remaining files. To view the full error of a failed file try running fontforge manually on the problem font file with the command below. Change the last two names `fontin.ttf` and `fontout.otf` to the applicable file name.
```terminal
fontforge -lang=ff -c 'Open($1); Generate($2); Close();' fontin.ttf fontout.otf
```