|
From: | William Bader |
Subject: | Re: use windows fonts and adobe distiller and lout |
Date: | Wed, 29 Jan 2020 01:44:16 +0000 |
>perhaps someone could explain the script (copied next under) so that I could try to its steps manually.
I think that it looks for TTF and OTF files in the current directory and checks to enter them in ghostscript's Fontmap file (no longer necessary with recent versions of ghostscript that can search directories for font files that match their postscript
name) and in a font definition file for lout.
The core of the script runs the open source ttf2pt1 program to convert TrueType and OpenType fonts to Type 1 fonts. http://ttf2pt1.sourceforge.net/
If you have TTF or OTF font files, you can run ttf2pt1 on them manually to create Type 1 fonts. It looks like the script generates PFB files = Postscript (Type 1) Font Binary.
On my laptop, I have a big directory with all of my fonts as PFA (Postscript Type 1 Font Ascii) with the font file called the same as the name of the font it contains so ghostscript and other applications can find it automatically as long as the directory is
on their font search path.
The end of the script updates the font definition in a file similar to Lout's data/fontdefs.ld
It is a text file with a simple format that you can edit manually.
You also might need to copy the font metrics to Lout's font directory.
Font metrics usually come in a separate AFM (Adobe Font Metrics) file.
It looks like you can just pick a name (following the pattern to avoid conflicts) and copy the AFM directly.
The fontdefs.ld file needs to mention the name in the @Metrics section.
The font metrics files are text files a few lines to identify the font and then a line for each character with its width (I think in thousandths of points).
If you don't have an AFM, if you have ghostscript, if you place the font somewhere that ghostscript can find it, you can use the 'printafm' script to have ghostscript generate an AFM.
I think that Lout reads the font metrics file but does not read the postscript font file. When you print the output postscript from Lout, you need to have the fonts available on your printer. If you view the fonts with ghostscript or if you use ghostscript
ps2pdf to convert the postscript to a PDF, ghostscript will use the fonts on your computer if it can find them.
I hope that helps you get started.
Regards, William
From: Lout-users <lout-users-bounces+williambader=address@hidden> on behalf of douglas mcallaster <address@hidden>
Sent: Tuesday, January 28, 2020 5:33 PM To: address@hidden <address@hidden> Subject: use windows fonts and adobe distiller and lout 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 |
[Prev in Thread] | Current Thread | [Next in Thread] |