#!/bin/sh

license_file=1Part/DanielByLDCO/OFL.txt
copyright_prefix="Copyright (c)"
rfn_prefix="with Reserved Font Name"

# FIXME: replacing '<dates>' with 2016. Correct for up to part 3

for dir in ?Part/*; do
	dirname=${dir##*/}
	name=${dirname%FontByLDCO}
	lic_file="$dir/OFL.txt"
	# Note the extra space left at the beginning:
	copyright=`grep "^$copyright_prefix" "$lic_file" | \
		sed -e "s/^$copyright_prefix//" -e 's/<dates>/<2016>/' -e 's/\r$//'`
	rfns=`grep "^$rfn_prefix" "$lic_file" | sed -e 's/^/ /'  -e 's/\r$//'`
	
	cat <<EOF
Files: $dir/*
Copyright:
$copyright
Comment:
$rfns
License: OFL-1.1

EOF
done

echo License: OFL-1.1
cat "$license_file" | sed -n -e '/^This Font Software/,$p' \
	| sed -e 's/\r$//' -e '/^$/s/^/./' -e 's/^/ /'