#!/usr/bin/python
# bdflib-embolden, a tool to embolden a BDF font file
# Copyright (C) 2009, Timothy Alle
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
from optparse import OptionParser
from bdflib import reader, writer, effects

parser = OptionParser(usage="usage: %prog [options] input.bdf output.bdf")
parser.add_option("--maintain-spacing",
		dest="maintain_spacing", action="store_true", default="True",
		help="Expand each character's spacing to account for emboldening "
			"(default)",
	)
parser.add_option("--ignore-spacing",
		dest="maintain_spacing", action="store_false",
		help="Let bold characters use their original spacing",
	)

options, args = parser.parse_args()

if len(args) != 2:
	print >> sys.stderr, "Must supply exactly two filenames."
	parser.print_help()
	sys.exit(1)

input = open(args[0], 'r')
output = open(args[1], 'w+')

# Make a bold version of the input font.
bold = effects.embolden(reader.read_bdf(input), options.maintain_spacing)

# Write out the new font.
writer.write_bdf(bold, output)

input.close()
output.close()
