Hey Doug,
author of the script here. William and David already explained the idea
of the script very well, I have not much to add. It is basically a
wrapper around ttf2pt1 which automates the whole chain of preparation
for using a TTF/OTF font within Lout. The Readme on GitHub [1] gives
some more details, but you know it probably already.
I used the script successful on MacOS and Linux but have no experience
with it on Windows. To directly use it, you could try to install Cygwin
[2] or MSYS2 [3], install the required programs and follow the steps
from the Readme. The dependencies are a bunch of GNU Unix/Linux tools
which should come out-of-the box in Cygwin (bash, sed, grep, tee, ...) and
the ttf2pt1 program [4]. Compilation requires specific development
headers, e.g. Freetype 2 [5] and build essential tools like make and
gcc. Although all those resource should be accessible by Cygwin's
package system, I have to admit, this is not an easy path if you are
completely new to GNU/Linux/Unix. To cut a long story short, I cannot
guarantee it will work this way but if you are ambitious and eager to
learn something new, just give it a try. (Alternatively, you could
install a Linux VM using Virtualbox [6] but this would make your task
even bigger…)
If there is another, easier way (Windows or Linux), I would be also very
happy to learn about it from the community.
−Martin
[1]
https://github.com/smartmic/addfonts
[2]
https://www.cygwin.com/
[3]
https://www.msys2.org/
[4]
http://ttf2pt1.sourceforge.net/
[5]
https://www.freetype.org/
[6]
https://www.virtualbox.org/
On Tue, Jan 28, 2020 at 05:33:49PM -0500, douglas mcallaster wrote:
> Folks,
>
> Can lout use the truetype fonts which come with Windows 10?
> (And I am using Adobe Distiller to make pdf from the lout generated postscript.)
>
> I found an explanation for using non standard fonts from 20 years ago (using PFA or PFB and AFM files),
> but I assume truetype fonts would provide much higher quality.
>
> I discovered (on git hub) a script from Martin Michel from 2014 but it is for Linux and ghostscript.
> Has someone made a Windows powershell script which could perform this magic for me?
>
> Or perhaps someone could explain the script (copied next under) so that I could try to its steps manually.
>
> As I understand it, I would have to set up lout to find the AFM file via a myfonts.ld file.
>
> If someone could reply with the requisite (I assume) AFM file (based on some Windows10 truetype font),
> and a myfonts.ld file (with the correct matching @name, @family, @face, @tag, @metrics, @mapping info)
> what would be really great. (An early success would keep me going, as I have a day job.)
>
> Also, if folks have done this and can suggest a nice Windows Monospace, Serif, and San Serif font, I welcome it.
>
> Finally, my thoughts go out to Dr Kingston, who enjoyed hiking in Australia,
> as I wonder how much of his treasured woodlands are now destroyed.
>
> Thanks, Doug
>
> #!/bin/bash
> #
> # addfonts.sh
> # Converts True Type or Open Type Fonts to Postscript Type1 Fonts and populates
> # the Ghostscript Fontmap file and the Basser Lout FontDef databases for local
> # users.
> #
> # Depends on non-standard commands: ttfpt1 (compiled against Freetype)
> #
> #
> # Copyright 2014 Martin Michel
> #
> # Licensed under the Apache License, Version 2.0 (the "License"); you may not
> # use this file except in compliance with the License. You may obtain a copy
> # of the License at
> #
> #
http://www.apache.org/licenses/LICENSE-2.0
> #
> # Unless required by applicable law or agreed to in writing, software
> # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
> # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
> # License for the specific language governing permissions and limitations
> # under the License.
>
> shfile=$(sed 's/^.*\///' <<< $0)
> logfile=$(sed -e 's/\.sh/\.log/; s/^.*\///' <<< $0)
> #echo $0 $shfile $logfile
>
> usage="Usage: ./$shfile
> No arguments applicable. This script scans for new True Type or Open Type Font
> files, converts them to Postscript Type1 Fonts and updates the Fontmap
> (Ghostscript) and @FontDef (Lout) databases. The script and all associated input
> and output files must be in the local user ghostscript font path."
>
> echo "*****************************************************************"\
> >>$logfile
> echo "LOG ENTRY from '$shfile'">>$logfile
> echo -e "Run by $USER on $HOSTNAME at $(date) \n ">>$logfile
>
> if [ $# -gt 0 ] ; then
> echo -e "TERMINATION: Wrong number of arguments. \n" |tee -a $logfile
> echo -e "$usage\n"
> exit 1
> fi
>
> if [[ "$GS_FONTPATH" != "$(pwd)" ]] ; then
> echo -e "TERMINATION: Wrong working directory or GS_FONTPATH not set.\n" |tee -a $logfile
> echo -e "Current directory: $(pwd)" |tee -a $logfile
> echo -e "GS_FONTPATH: $GS_FONTPATH" |tee -a $logfile
> echo -e "$usage\n"
> exit 2
> fi
>
> [ ! -f Fontmap ] && echo -e "INFO: Ghostscripts local 'Fontmap' file missing, will
> be created.\n" |tee -a $logfile && touch Fontmap
>
> ls *.[oOtT][tT][fF] 2>/dev/null 1>&2
> if [ $? -ne 0 ] ; then
> echo -e "TERMINATION: No True or Open Type Font files (.ttf,.otf) in directory." |tee -a $logfile
> echo -e "$usage\n"
> exit 3
> fi
>
> availableTTF=( $(ls -1 *.[oOtT][tT][fF] | sed 's/\.otf\|\.ttf//i') )
> installedPFB=( $(grep -e '^/' Fontmap | sed 's/^.*(\|\.pfb.*$//g') )
>
> typeset -i counter
> typeset -i numTTF
> typeset -i numInstalled
> typeset -i numPFB
> numTTF=${#availableTTF[*]}
> numInstalled=${#installedPFB[*]}
> counter=$numInstalled
> numPT1=$(ls -1 *.[aApP][fF][bBmM] 2>/dev/null | wc -l )
>
> let z=numPT1/2
> let m=numPT1%2
>
> if (( $numInstalled < z && m == 0 )) ; then
> echo -e "WARNING: There are unregistered PS Type1 font files.\n" |tee -a $logfile
> elif (( $numInstalled > z || m > 0 )) ; then
> echo -e "TERMINATION: There are missing PS Type1 font files. It is recommend to
> syncronize all files and databases in this directory (delete Fontmap and rerun
> $0)\n" |tee -a $logfile
> exit 4
> fi
>
> echo -e "STATUS: There are $numInstalled installed Postscript Type1 Fonts out of $numTTF
> available True Type or Open Type Fonts for user $USER. \n" >>$logfile
>
> if (( $numTTF != $numInstalled ))
> then
> for ii in ${availableTTF[*]}; do
> for jj in ${installedPFB[*]}; do
> if [[ "$ii" != "$jj" ]]; then
> counter=$counter-1
> fi
> done
> if (( $counter == 0 )) ; then
> queueFonts=("${queueFonts[@]}" "$ii")
> fi
> counter=$numInstalled
> done
> else
> echo "INFO: Font database is up-to-date if you have not fiddled with the
> contents of this directory or the local Fontmap file manually after the
> last run of this script. Consult the log file for history.
>
> Nothing to do. No new fonts installed." |tee -a $logfile
> exit 0
> fi
>
> for ff in ${queueFonts[@]}; do
> echo "-----------------------------------------------------------------"\
> >>$logfile
> echo "START OF TTF2PT1 LOG ENTRY FOR '$ff'" >>$logfile
> echo $(date) >>$logfile
> echo "-----------------------------------------------------------------"\
> >>$logfile
>
> ttf2pt1 -b $ff.[oOtT][tT][fF] >>$logfile 2>&1
>
> fontNames=("${fontNames[@]}" "$(grep FontName $ff.afm | cut -d' ' -f2-)")
> familyNames=("${familyNames[@]}" \
> "$(grep FamilyName $ff.afm | cut -d' ' -f2- | sed 's/ /_/g')")
> faceNames=("${faceNames[@]}" \
> "$(grep Weight $ff.afm | cut -d' ' -f2- | \
> sed -e' s/^./\U&/g; s/ *//g; s/Regular/Base/i; s/Italic/Slope/i ')")
> tagNames=("${tagNames[@]}" "${familyNames[@]:(-1)}-${faceNames[@]:(-1)}")
>
> echo "/${fontNames[@]:(-1)} ($ff.pfb);" >>Fontmap
>
> if [[ -z `cat myfontdefs.ld | sed -n '/'"$ff"'.afm/p'` ]] ; then
> cat >>myfontdefs.ld<<LOUT_ENTRY
> { @FontDef
> @Tag { ${tagNames[@]:(-1)} }
> @Family { ${familyNames[@]:(-1)} }
> @Face { ${faceNames[@]:(-1)} }
> @Name { ${fontNames[@]:(-1)} }
> @Metrics { $ff.afm }
> @Mapping { LtLatin1.LCM }
> }
>
> LOUT_ENTRY
> fi
>
> # Correct for whitespace error in afm files
> sed -i 's/.null/space/' $ff.afm
>
> echo "*****************************************************************"\
> >>$logfile
> echo -e "Font: ${fontNames[@]:(-1)}; Tag: ${tagNames[@]:(-1)} (has been \
> installed.)" |tee -a $logfile
> done