install: default ${AFMFILES}
${INSTALL} -u ${SYSUSER} -g ${SYSGROUP} -m ${DIRMODE} \
- -idb hylafax.sw.afm -dir ${AFMDIR}
+ -idb hylafax.sw.afm -dir ${FONTPATH}
for i in ${AFMFILES}; do \
- ${INSTALL} -F ${AFMDIR} -m 444 -idb ${PRODUCT}.sw.afm \
+ ${INSTALL} -F ${FONTPATH} -m 444 -idb ${PRODUCT}.sw.afm \
-src ${SRCDIR}/$$i -O `echo $$i | ${SED} s/\.afm//`; \
done
#endif
/*
- * The default pathname for the Adobe Font Metric files
+ * The default pathname for the Fontmap(s) file
* is compiled into util/TextFmt.o but can be overridden
* through configuration files.
*/
-#ifndef _PATH_AFMDIR
-#define _PATH_AFMDIR "@AFMDIR@" /* directory with AFM files */
+#ifndef _PATH_FONTMAP
+#define _PATH_FONTMAP "@FONTMAP@" /* location of Fontmap(s) */
+#endif
+
+/*
+ * The default pathname for the location of the fonts
+ * is compiled into util/TextFmt.o but can be overridden
+ * through configuration files.
+ */
+#ifndef _PATH_AFM
+#define _PATH_AFM "@FONTPATH@" /* location of Fonts */
#endif
/*
#
# Directory parameters.
#
-#DIR_AFM="/usr/lib/DPS/AFM" # directory for AFM files
#DIR_BIN="/usr/local/bin" # directory for client apps
#DIR_LIBDATA="/usr/lib/fax" # directory for client data
#DIR_LIBEXEC="/usr/lib/fax" # directory for libraries&hidden apps
#DIR_SPOOL="/var/spool/fax" # directory for spooling area
#DIR_SBIN="/var/spool/fax/bin" # directory for system apps
#DIR_LOCKS="/usr/spool/locks" # directory for UUCP lock files
+#FONTMAP="/usr/share/ghostscript/3.33" # directorys containing Fontmap files
+#PATH_AFM="/usr/lib/DPS/AFM" # directorys for AFM files
#
# HTML-specific parameters; only used when the
ZLIBINC"
VAR2="AFM
-AFMDIR DIR_AFM
AWK
BIN DIR_BIN
CAT
FAXGID
FAXUID
FILLORDER
+FONTMAP
+FONTPATH PATH_AFM
GETTY
GREP
GSRIP PATH_GSRIP
Note "Looks like UUCP lock files go in $DIR_LOCKS."
fi
-#
-# Location of Adobe Font Metric files.
-#
-if [ -z "$DIR_AFM" ]; then
- DIR_AFMS="
- /usr/lib/afm
- /usr/local/lib/afm
- /usr/local/share/ghostscript/fonts
- /usr/local/lib/ghostscript/fonts
- /usr/gnu/lib/ghostscript/fonts
- /opt/gnu/lib/ghostscript/fonts
- /usr/lib/ghostscript/fonts
- /usr/lib/gnu/ghostscript/fonts
- "
- case $TARGET in
- *-irix*) DIR_AFMS="/usr/lib/DPS/AFM $DIR_AFMS";;
- *-bsdi*) DIR_AFMS="/usr/contrib/lib/flexfax/afm $DIR_AFMS";;
- *-sunos*) DIR_AFMS="/usr/openwin/lib/fonts/afm $DIR_AFMS";;
- esac
- DIR_AFM=
- for i in $DIR_AFMS; do
- test -d $i && { DIR_AFM=$i; break; }
- done
-fi
-if [ -z "$DIR_AFM" ]; then
- # put it where ghostscript normally puts things
- DIR_AFM=/usr/local/lib/ghostscript/fonts
- Note "WARNING, could not locate a directory with font metric information,"
- Note "guessing that font metric information goes in $DIR_AFM."
-else
- Note "Looks like font metric information goes in $DIR_AFM."
-fi
-
bitchExecutable()
{
echo ""
Note "Looks like $PATH_PSRIP is the PostScript RIP to use."
CheckRIP
+#
+# Ghostscript Fontmap File
+#
+
+getGSFonts()
+{
+ if [ ! "$PS" = gs -a -n $PATH_PSRIP ];then
+ return 1
+ fi
+ $PATH_PSRIP -h | awk -F '[ ]' '
+ BEGIN { start = 0; }
+ /Search path:/ { start = 1 }
+ {
+ if (start == 1) {
+ if ($1 == "") {
+ gsub(" ","")
+ gsub("^[.]","")
+ gsub("^:","")
+ printf "%s", $0
+ } else if ($1 != "Search") start = 0
+ }
+ }
+ '
+ return 0
+}
+
+if [ -z "$FONTMAP" ]; then
+ FONTMAP=`getGSFonts`
+ if [ -n "$FONTMAP" ]; then
+ AFM="no"
+ fi
+fi
+Note "Setting the Fontmap path to $FONTMAP"
+
+#
+# Location of Adobe Font Metric files.
+#
+if [ -z "$PATH_AFM" ]; then
+ # if the fontmap path is available use that
+ # else just guess
+ if [ -n "$FONTMAP" ]; then
+ PATH_AFM=$FONTMAP
+ else
+ DIR_AFMS="
+ /usr/lib/afm
+ /usr/local/lib/afm
+ /usr/local/share/ghostscript/fonts
+ /usr/local/lib/ghostscript/fonts
+ /usr/gnu/lib/ghostscript/fonts
+ /opt/gnu/lib/ghostscript/fonts
+ /usr/lib/ghostscript/fonts
+ /usr/lib/gnu/ghostscript/fonts
+ "
+ case $TARGET in
+ *-irix*) DIR_AFMS="/usr/lib/DPS/AFM $DIR_AFMS";;
+ *-bsdi*) DIR_AFMS="/usr/contrib/lib/flexfax/afm $DIR_AFMS";;
+ *-sunos*) DIR_AFMS="/usr/openwin/lib/fonts/afm $DIR_AFMS";;
+ esac
+ PATH_AFM=
+ for i in $DIR_AFMS; do
+ test -d $i && { PATH_AFM=$i; break; }
+ done
+ fi
+fi
+if [ -z "$PATH_AFM" ]; then
+ # put it where ghostscript normally puts things
+ PATH_AFM=/usr/local/lib/ghostscript/fonts
+ Note "WARNING, could not locate a directory with font metric information,"
+ Note "guessing that font metric information goes in $PATH_AFM."
+else
+ Note "Looks like font metric information goes in $PATH_AFM."
+fi
+
#
# Setup manual page-related stuff.
#
[ 5] Directory for manual pages: $DIR_MAN
[ 6] Directory for HTML documentation: $DIR_HTML
[ 7] Directory for spooling: $DIR_SPOOL
-[ 8] Directory for font metrics: $DIR_AFM
-[ 9] Directory for uucp lock files: $DIR_LOCKS
-[10] Uucp lock file scheme: $LOCKS
-[11] PostScript imager package: $PS
-[12] PostScript imager program: $PATH_PSRIP
-[13] Manual page installation scheme: $MANSCHEME
-[14] Default page size: $PAGESIZE
-[15] Default vertical res (lpi): $DEFVRES
-[16] Location of getty program: $PATH_GETTY
-[17] Location of voice getty program: $PATH_VGETTY
-[18] Location of sendmail program: $PATH_SENDMAIL
-[19] Location of TIFF tools: $TIFFBIN
+[ 8] Path for fontmap files: $FONTMAP
+[ 9] Path for font metrics: $PATH_AFM
+[10] Directory for uucp lock files: $DIR_LOCKS
+[11] Uucp lock file scheme: $LOCKS
+[12] PostScript imager package: $PS
+[13] PostScript imager program: $PATH_PSRIP
+[14] Manual page installation scheme: $MANSCHEME
+[15] Default page size: $PAGESIZE
+[16] Default vertical res (lpi): $DEFVRES
+[17] Location of getty program: $PATH_GETTY
+[18] Location of voice getty program: $PATH_VGETTY
+[19] Location of sendmail program: $PATH_SENDMAIL
+[20] Location of TIFF tools: $TIFFBIN
EOF
}
7) promptForNonNullStringParameter "$DIR_SPOOL" \
"Directory to setup server spooling area"; DIR_SPOOL="$param"
;;
- 8) promptForNonNullStringParameter "$DIR_AFM" \
- "Directory to find Adobe font metrics"; DIR_AFM="$param"
+ 8) promptForNonNullStringParameter "$FONTMAP" \
+ "Path for gs Fontmap files"; FONTMAP="$param"
+ ;;
+ 9) promptForNonNullStringParameter "$PATH_AFM" \
+ "Path for font metric files"; PATH_AFM="$param"
;;
- 9) promptForNonNullStringParameter "$DIR_LOCKS" \
+ 10) promptForNonNullStringParameter "$DIR_LOCKS" \
"Directory for uucp lock files"; DIR_LOCKS="$param"
;;
- 10) promptForUUCPLockScheme;;
- 11) promptForImagerPackage; PickRIP; CheckRIP;;
- 12) promptForNonNullStringParameter "$PATH_PSRIP" \
+ 11) promptForUUCPLockScheme;;
+ 12) promptForImagerPackage; PickRIP; CheckRIP;;
+ 13) promptForNonNullStringParameter "$PATH_PSRIP" \
"PostScript imager program"; PATH_PSRIP="$param"
case "$PS" in
dps) PATH_DPSRIP=$PATH_PSRIP;;
gs) PATH_GSRIP=$PATH_PSRIP;;
esac
;;
- 13) promptForManPageScheme;;
- 14) promptForPageSize $SRCDIR/util/pagesizes.in;;
- 15) promptForVRes;;
- 16) promptForNonNullStringParameter "$PATH_GETTY" \
+ 14) promptForManPageScheme;;
+ 15) promptForPageSize $SRCDIR/util/pagesizes.in;;
+ 16) promptForVRes;;
+ 17) promptForNonNullStringParameter "$PATH_GETTY" \
"Location of getty program"; PATH_GETTY="$param"
;;
- 17) promptForNonNullStringParameter "$PATH_VGETTY" \
+ 18) promptForNonNullStringParameter "$PATH_VGETTY" \
"Location of vgetty program"; PATH_VGETTY="$param"
;;
- 18) promptForNonNullStringParameter "$PATH_SENDMAIL" \
+ 19) promptForNonNullStringParameter "$PATH_SENDMAIL" \
"Location of sendmail program"; PATH_SENDMAIL="$param"
;;
- 19) promptForNonNullStringParameter "$TIFFBIN" \
+ 20) promptForNonNullStringParameter "$TIFFBIN" \
"Location of TIFF tools"; TIFFBIN="$param"
esac
}
ok=skip
while [ "$ok" != y ] && [ "$ok" != yes ]; do
if [ "$ok" != skip ]; then
- for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
+ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
promptForParameter $i;
done
fi
prompt "Are these ok [yes]?"; read ok
test -z "$ok" && ok=yes
case "$ok" in
- [1-9]|1[0-9]) promptForParameter $ok;;
+ [1-9]|1[0-9]|20) promptForParameter $ok;;
[yY]*|[nN]*) continue;;
?*)
echo ""
}
fi
if [ "$AFM" = auto ]; then
- if [ ! -f $DIR_AFM/Courier -a ! -f $DIR_AFM/Courier.afm ]; then
+ if [ ! -f $PATH_AFM/Courier -a ! -f $PATH_AFM/Courier.afm ]; then
Note ""
Note "WARNING, no font metric files appear to be installed on your system, enabling"
Note "installation of the default set of metric files included with this software."
LIBDATA = @LIBDATA@
LIBEXEC = @LIBEXEC@
HTMLDIR = @HTMLDIR@
-AFMDIR = @AFMDIR@
+FONTMAP = @FONTMAP@
+FONTPATH = @FONTPATH@
#
TOPSRCDIR = @SRCDIR@
PORT = ${DEPTH}/port
DATE="@DATE@" # data software was configured
TARGET="@TARGET@" # configured target
-DIR_AFM=@AFMDIR@ # directory for Adobe Font Metric files
+PATH_AFM=@FONTPATH@ # directory for Adobe Font Metric files
DIR_BIN=@BIN@ # directory for client applications
DIR_LIBDATA=@LIBDATA@ # directory for client data files
DIR_LIBEXEC=@LIBEXEC@ # directory where servers are located
# (but some confusion within this script).
#
VARS="SCRIPT_SH
-AFMDIR DIR_AFM
+FONTPATH PATH_AFM
AWK
BIN DIR_BIN
CAT
# Installation of Adobe Font Metric files
#
if onClient; then
- if [ -d $DIR_AFM ]; then
- if [ ! -f $DIR_AFM/Courier ] && [ ! -f $DIR_AFM/Courier.afm ]; then
- cat >&4 <<EOF
-
-
-Warning: Font metric information files were not found!
-
-The font metric information file for the Courier font was not found in
-the $DIR_AFM directory. This means that client HylaFAX applications
-that use this information to format ASCII text for submission as fax will
-use incorrect information and generate potentially illegible facsimile.
-
-If font metric information is present on your system in a directory other
-than $DIR_AFM then you can setup a symbolic link to the appropriate
-directory or you can specify the appropriate pathname in the configuration
-file $DIR_LIBDATA/hyla.conf with a line of the form:
-
-FontDir: someplace_unexpected
-
-If you do not have the font metric information files loaded on your system
-system you can obtain them by public FTP from the place where you obtained
-the HylaFAX software or from the master FTP site at ftp.sgi.com.
-EOF
+ FDIRS=`echo $PATH_AFM | sed "s/:/ /g"`
+ MATCH=
+ for FDIR in $FDIRS; do
+ if [ -d $FDIR ]; then
+ cd $FDIR
+ if [ -n "`ls | grep '.afm'`" ] || [ -f Courier ]; then
+ MATCH=$FDIR
+ break
fi
else
cat >&4 <<EOF
-Warning: $DIR_AFM does not exist or is not a directory!
+Warning: $FDIR does not exist or is not a directory!
-The directory $DIR_AFM does not exist or this file is not a directory.
+The directory $FDIR does not exist or this file is not a directory.
This is the directory where the HylaFAX client applications expect to
locate font metric information to use in formatting ASCII text for
submission as facsimile. Without this information HylaFAX may generate
illegible facsimile from ASCII text.
+EOF
+ fi
+ done
+ if [ -z "$MATCH" ];then
+ cat >&4 <<EOF
+
+
+Warning: Font metric information files were not found!
+
+The font metric information file for the Courier font was not found in
+the $PATH_AFM path. This means that client HylaFAX applications
+that use this information to format ASCII text for submission as fax will
+use incorrect information and generate potentially illegible facsimile.
+
If font metric information is present on your system in a directory other
-than $DIR_AFM then you can setup a symbolic link to the appropriate
+than $PATH_AFM then you can setup a symbolic link to the appropriate
directory or you can specify the appropriate pathname in the configuration
file $DIR_LIBDATA/hyla.conf with a line of the form:
-FontDir: someplace_unexpected
+FontPath: someplace_unexpected
If you do not have the font metric information files loaded on your system
system you can obtain them by public FTP from the place where you obtained
the HylaFAX software or from the master FTP site at ftp.sgi.com.
EOF
- fi
+ fi
fi
#
-e 's;\$${SBIN};${SBIN};g' \
-e 's;\$${LIBDATA};${LIBDATA};g' \
-e 's;\$${LIBEXEC};${LIBEXEC};g' \
- -e 's;\$${AFMDIR};${AFMDIR};g' ${MANSEDLOCAL}
+ -e 's;\$${FONTPATH};${FONTPATH};g' ${MANSEDLOCAL}
default all targets:: ${TARGETS}
BoldFont string \s-1Helvetica-Bold\s+1 font for setting header tags
Columns integer \s-11\s+1 number of columns in formatted output
DigestDivider string \- multipart/digest divider \*(Ps command
-FontDir string \s-1\fIsee below\fP\s+1 directory for font metric files
+FontPath string \s-1\fIsee below\fP\s+1 directory for font metric files
GaudyHeaders boolean \s-1No\s+1 enable/disable gaudy page headers
Headers string \s-1\fIsee below\fP\s+1 headers to retain in envelope
ISO8859 boolean \s-1Yes\s+1 use ISO 8859-1 character encoding
Dividers are expected to use no more vertical space on the
output page than a line of text.
.TP 15
-.B FontDir
-The directory where Adobe Font Metric (\s-1AFM\s+1) files are
-located; by default ${AFMDIR}.
+.B FontPath
+The path where Adobe Font Metric (\s-1AFM\s+1) files are
+located; by default ${FONTPATH}.
.TP 15
.B GaudyHeaders
Control whether or not to use a gaudy-style page header.
${LIBDATA}/faxmail.conf system-wide configuration file
${LIBDATA}/sendfax.conf system-wide configuration file for direct delivery
${LIBEXEC}/faxmail hierarchy for external \s-1MIME\s+1 converters
-${AFMDIR} for font metrics
+${FONTPATH} for font metrics
/usr/tmp/faxmailXXXXXX temporary files
.fi
.SH "SEE ALSO"
.PP
By default,
.I textfmt
-will generate an output document that is formtted with a single
+will generate an output document that is formatted with a single
vertical column of text, set in a 10 point fixed width font, and
with a simple page header that consists of the file name, last
modification date, and the page number.
Set text using the \*(Ps font named
.IR font .
.TP
+.BI \-F " fontdir(s)"
+.IR Path(s)
+to \s-1afm\s+1 font files.
+.TP
.B \-G
Use a gaudy-style page header.
.TP
The following configuration parameters are recognized:
.sp .5
.nf
-.ta \w'TextLineHeight 'u +\w'boolean 'u +\w'\s-1\fIsee below\fP\s+1 'u
\fBTag Type Default Description\fP
Columns integer \s-11\s+1 number of columns in formatted output
-FontDir string \s-1\fIsee below\fP\s+1 directory for font metric files
GaudyHeaders boolean \s-1No\s+1 enable/disable guady page headers
+FontMap string \s-1\fIsee below\fP\s+1 location of ghostscript Fontmap file
+FontPath string \s-1\fIsee below\fP\s+1 directory for font metric files
ISO8859 boolean \s-1Yes\s+1 use ISO 8859-1 character encoding
LineWrap boolean \s-1Yes\s+1 wrap/truncate text lines
Orientation string \s-1portrait\s+1 orientation of text on page
.B \-m
option.)
.TP 15
-.B FontDir
-The directory where Adobe Font Metric (\s-1AFM\s+1) files are
-located; by default ${AFMDIR}.
+.B FontMap
+The directory or directories where the ghostscript Fontmap file(s)
+are located; multiple paths are seperated by a colon (":"). The
+Fontmap table allows the translation of the descriptive name of the
+font (as used by the
+.IR TextFont
+parameter) to the ghostscript font filenames. Setting the value to ""
+(zero length string) disables this translation and provides functionality
+with RIPs other than ghostscript.
+.TP 15
+.B FontPath
+The path where Adobe Font Metric (\s-1AFM\s+1) files are
+located; by default ${FONTPATH}. (Equivalent to the
+.B \-F
+option.)
.TP 15
.B GaudyHeaders
Control whether or not to use a gaudy-style page header.
Set the tab stop distance; in characters.
.TP 15
.B TextFont
-Set the name of font to use for setting text.
+Set the descriptive name of font to use for setting text.
(Equivalent to the
.B \-f
option.)
${LIBDATA}/hyla.conf system-wide configuration file
~/.hylarc per-user configuration file
${LIBDATA}/pagesizes page size database
-${AFMDIR} font metric files
+${FONTPATH} font metric files
.fi
.SH "SEE ALSO"
.IR hylafax (1),
void TextFmt::setFont(TextFont* f) { curFont = f; }
void TextFmt::setFont(const char* name) { curFont = (*fonts)[name]; }
+void TextFmt::setFontPath(const char* path) { TextFont::fontPath = path; }
void TextFmt::setOutputFile(FILE* f) { output = f; }
void TextFmt::setNumberOfColumns(u_int n) { numcol = n; }
setTextLineHeight(inch(value));
else if (streq(tag, "tabstop"))
tabStop = getNumber(value);
- else if (streq(tag, "fontdir")) // XXX
- TextFont::fontDir = value;
+ else if (streq(tag, "fontmap")) // XXX
+ TextFont::fontMap = value;
+ else if (streq(tag, "fontpath"))
+ setFontPath(value);
else
return (FALSE);
return (TRUE);
#define NCHARS (sizeof (widths) / sizeof (widths[0]))
-fxStr TextFont::fontDir = _PATH_AFMDIR;
+fxStr TextFont::fontMap = _PATH_FONTMAP;
+fxStr TextFont::fontPath = _PATH_AFM;
u_int TextFont::fontID = 0;
TextFont::TextFont(const char* cp) : family(cp)
TextFont::~TextFont() {}
fxBool
-TextFont::findFont(const char* name)
+TextFont::decodeFontName(const char* name, fxStr& filename, fxStr& emsg)
{
- fxBool ok = FALSE;
- DIR* dir = Sys::opendir(fontDir);
- if (dir) {
- int len = strlen(name);
- dirent* dp;
- while ((dp = readdir(dir)) != NULL) {
- int l = strlen(dp->d_name); // XXX should d_namlen
- if (l < len)
- continue;
- if (strcasecmp(name, dp->d_name) == 0) {
- ok = TRUE;
- break;
- }
- // check for .afm suffix
- if (l-4 != len || strcmp(&dp->d_name[len], ".afm"))
- continue;
- if (strncasecmp(name, dp->d_name, len) == 0) {
- ok = TRUE;
- break;
- }
- }
- closedir(dir);
+ struct stat junk;
+ fxStr path = fontMap;
+ u_int index = path.next(0, ':');
+ while (index > 0) {
+ fxStr fontMapFile = path.head(index) | "/" | "Fontmap";
+ path.remove(0, index);
+ if (path.length() > 0) path.remove(0, 1);
+ FILE* fd = Sys::fopen(fontMapFile, "r");
+ if (fd != NULL && fontMapFile[0] == '/') {
+ fxStr key = name;
+ char buf[1024];
+ int aliascount = maxaliases;
+ while (fgets(buf, sizeof(buf), fd) != NULL &&
+ aliascount > 0) {
+ int len = strcspn(buf, "%\n");
+ if (len == strlen(buf)) {
+ emsg = fxStr::format(
+ "Warning:%s - line too long.", (const char*)fontMapFile);
+ break;
+ }
+ if (len == 0) continue;
+ *(buf + len) = '\0';
+ char* tmp = buf + strcspn(buf, ") \t");
+ *tmp++ = '\0';
+ tmp += strspn(tmp, " \t");
+ if (strcmp(key, buf + 1) == 0) {
+ //match - now ensure it is the last one in the file
+ // for gs compatibility
+ *(tmp + strcspn(tmp, ") \t;")) = '\0';
+ fxStr val = tmp;
+ while (fgets(buf, sizeof(buf), fd) != NULL) {
+ len = strcspn(buf, "%\n");
+ *(buf + len) = '\0';
+ if (len == strlen(buf)) {
+ emsg = fxStr::format(
+ "Warning: %s - line too long.", (const char*) fontMapFile);
+ break;
+ }
+ if (len == 0) continue;
+ tmp = buf + strcspn(buf, ") \t");
+ *tmp++ = '\0';
+ tmp += strspn(tmp, " \t");
+ if (strcmp(key, buf + 1) == 0) {
+ *(tmp + strcspn(tmp, ") \t;")) = '\0';
+ val = tmp;
+ }
+ }
+ if (val[0] == '/') {
+ //alias
+ aliascount--;
+ val.remove(0);
+ key = val;
+ fseek(fd, 0L, SEEK_SET);
+ } else {
+ //real file
+ fclose(fd);
+ val.remove(0);
+ int pos = val.next(0, '.');
+ val.remove(pos, val.length() - pos);
+ val.append(".afm");
+ //move through dirs looking for font
+ fxStr fpath = fontPath;
+ int index2 = fpath.next(0, ':');
+ filename = fpath.head(index2) | "/" | val;
+ fpath.remove(0, index2);
+ if (fpath.length() > 0) fpath.remove(0, 1);
+ while (stat(filename, &junk) != 0 && index2 > 0) {
+ index2 = fpath.next(0, ':');
+ filename = fpath.head(index2) | "/" | val;
+ fpath.remove(0, index2);
+ if (fpath.length() > 0) fpath.remove(0, 1);
+ }
+ fxBool result = stat(filename, &junk) ? FALSE : TRUE;
+ if (!result)
+ emsg = fxStr::format(
+ "Warning: %s invalid Fontmap entry - no filename present", (const char*)val);
+ return result;
+ }
+ }
+ }
+ fclose(fd);
+ }
+ index = path.next(0, ':');
+ }
+ //decoding using fontmap has failed
+ //now try plain filename with/without afm extension
+ path = fontPath;
+ index = path.next(0, ':');
+ while (index > 0) {
+ filename = path.head(index) | "/" | name | ".afm";
+ path.remove(0, index);
+ if (path.length() > 0) path.remove(0, 1);
+ if (stat(filename, &junk) == 0) return TRUE;
+ filename.resize(filename.length()-4); // strip ``.afm''
+ if (stat(filename, &junk) == 0) return TRUE;
+ index = path.next(0, ':');
}
- return (ok);
+ return FALSE;
+}
+
+fxBool
+TextFont::findFont(const char* name)
+{
+ fxStr myname, emsg;
+ return decodeFontName(name, myname, emsg);
}
static const char* defISOFont = "\
}
FILE*
-TextFont::openAFMFile(fxStr& fontPath)
+TextFont::openAFMFile(fxStr& fontpath)
{
- fontPath = fontDir | "/" | family | ".afm";
- FILE* fd = Sys::fopen(fontPath, "r");
- if (fd == NULL && errno == ENOENT) {
- fontPath.resize(fontPath.length()-4); // strip ``.afm''
- fd = Sys::fopen(fontPath, "r");
- }
- return (fd);
+ fxStr emsg;
+ if (!decodeFontName(family, fontpath, emsg)) {
+ fprintf(stderr,emsg);
+ return NULL;
+ }
+ return Sys::fopen(fontpath, "r");
}
fxBool
class TextFont {
private:
+ enum { maxaliases = 10 }; // max no of aliases to find a font
fxStr family; // font family name
fxStr setproc; // PostScript setfont procedure
fxStr showproc; // PostScript show procedure
TextCoord widths[256]; // width table
- static fxStr fontDir; // directory for metric files
+ static fxStr fontMap; // location of Fontmap file
+ static fxStr fontPath; // path for afm files
static u_int fontID; // font identifier number
friend class TextFmt;
void loadFixedMetrics(TextCoord w);
FILE* openAFMFile(fxStr& pathname);
fxBool getAFMLine(FILE* fp, char* buf, int bsize);
+ static fxBool decodeFontName(const char*, fxStr&, fxStr&);
public:
TextFont(const char*);
~TextFont();
const TextFont* getFont(const char* name) const;
void setFont(TextFont*);
void setFont(const char*);
+ void setFontPath(const char*);
void hrMove(TextCoord);
TextCoord getXOff(void) const;
" [-c]"
" [-D]"
" [-f fontname]"
+ " [-F fontdir(s)]"
" [-m N]"
" [-o #]"
" [-p #]"
fmt.readConfig(FAX_USERCONF);
prog = argv[0];
- while ((c = getopt(argc, argv, "f:m:M:o:p:s:V:12BcDGrRU")) != -1)
+ while ((c = getopt(argc, argv, "f:F:m:M:o:p:s:V:12BcDGrRU")) != -1)
switch(c) {
case '1': // 1-column output
case '2': // 2-column output
usage();
}
break;
+ case 'F': // set Font path
+ fmt.setFontPath(optarg);
+ break;
case 'G': // gaudy mode
fmt.setGaudyHeaders(TRUE);
break;