Koboify Fonts by Sherman Perry

This is a script that takes one or more font files (of the same font family),
performs some modifications, and generates new TTF file(s). It uses FontForge
to perform the modifications.

It is provided AS-IS. This is very rough. I may or may not make improvements
in the future.
=========================================================================
CHANGELOG:
_0.3.1_2015-10-18_
- Fixed an error with the batch file where there was a problem if the path to
  the script file contained spaces.
- Changed how the script is called, from running "ffpython.exr" to 
  "fontforge.exe -script " 

_0.3_2015-09-29_
- Created a somewhat ugly workaround to handle fonts that will not rename
  properly. This is set in a new commandline option, [-n]
- Fixed a fairly major bug in the batch file--it would break if less than
  four files were dragged onto it.
- Moved font name processing to a seperate function

_0.2 2015-09-28_

Reworked a few internals, especially the layer curve type handling
Created a Drag'n'Drop batch file for Windows 7-10 users

_0.1_2015-09-27_
Initial release
=========================================================================
REQUIREMENTS:
FontForge must be installed on your system.
The script will not run using the system installed Python unless FontForge
was specifically compiled to allow this.

This script should now be called by using:
path/to/fontforge/fontforge(.exe) -script KoboifyFonts-0.3.1.py [OPTIONS]

FontForge is located (by default) in the following location on Windows 
64-bit systems:
"C:\Program Files (x86)\FontForgeBuilds\bin\fontforge.exe"

On Windows, the best way to run the script is to probably call it in a
batch file. As of version 0.2 I have created a batch file called 
'DragFontFilesHere.bat' Details on how to use this are below.

I reccommend running the script/batch in the same directory as the font
files you wish to convert.
=========================================================================
OSX INSTALLATION:

The following instructions were kindly provided by mobileread user 'GERGE':

Firstly, you can't use this by just installing FontForge from its page, you 
need command line version of FontForge. That version is much smaller 
(takes 30 MB or so) and needs to be compiled and installed with Homebrew. 
I am not going to explain to you how to use Homebrew, there are literally 
hundreds of guides out there. Just don't use HEAD version, brew install 
fonforge is the command you need to install it.

Secondly, you can't use it by internal Python of FontForge, you don't even 
have an internal Python. But OS X's own Python works perfectly well, just 
use versions of this command I used with EB Garamond:

python ./KoboifyFonts-0.3.py -r /Users/msimsek/Downloads/EBGaramond08-Regular.otf 
	-i /Users/msimsek/Downloads/EBGaramond08-Italic.otf -s -k -p -d . 'EB Garamond'
=========================================================================
USAGE: KoboifyFonts-0.3.1.py [-h] [-r REGULAR] [-i ITALIC] [-b BOLD]
                           [-B BOLDITALIC] [-s] [-k] [-d OUTPUTDIRECTORY]
                           [-w ADDWEIGHT] [-p] [-m] [-n]
                           fontname

positional arguments:
  fontname              Specify new font name

optional arguments:
  -h, --help            show this help message and exit
  -r REGULAR, --regular REGULAR
                        Regular font file
  -i ITALIC, --italic ITALIC
                        Italic font file
  -b BOLD, --bold BOLD  bold font file
  -B BOLDITALIC, --bolditalic BOLDITALIC
                        Bold Italic font file
  -s, --striphint       Strip hints from font
  -k, --legacykern      Include legacy kerning table
  -d OUTPUTDIRECTORY, --outputdirectory OUTPUTDIRECTORY
                        Output directory if set. Default is "./kobomodified/"
  -w ADDWEIGHT, --addweight ADDWEIGHT
                        Add weight to font. Values around 8-15 seems suitable.
                        50 is bold
  -p, --panosestrip     Strip PANOSE data from font
  -m, --modifybearings  Modify bearings when adding weight. This has no affect
                        when not adding weight. Only use it for subtle weight
                        changes
  -n, --namehack        If the fonts generated have internal names different
                        to what you specified, try this option to enable an
                        ugly workaround. It basically generates the font
                        twice.
============================================================================
USING INCLUDED BATCH FILE
-------------------------
The included batch file allows font files to be dragged onto it. The font files
should include anywhere in their filenames the following:
	regular
	bold
	italic
	bolditalic/bold italic/bold-italic etc.
This will tell the batch file how to feed the files to the python script.

When files are dragged onto the batch file, you will be asked a number of questions
about whether to enable the options (see above usage section).

Fonts will be generated in a 'koboified/' subdirectory where the original font
files are located.

The batch file is set to use the FontForge python binary 'ffpython.exe' in the
default FontForge installation directory. If FontForge is installed elsewhere,
you will need to change this in the batch file (variable %ffpythonpath%).

The batch file and the python script should be located in the same directory.
============================================================================
There has been stability issues observed with --modifybearings (Windows 10 x64). 

It seems to have happened more with longer output file paths

I have not determined the root cause of this, 
as the python interpreter crashes without 
providing a traceback
	This stability issue may be Windows related. 
Or (more likely) I've made a big mistake somewhere...
============================================================================