From: ben Date: Tue, 13 Feb 2007 21:38:21 +0000 (+0000) Subject: Add a --list-fonts option, since getting PostScript names out of TrueType X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/commitdiff_plain/62a4b06bbf769ad4fad537a6facf9a23cecba1f8 Add a --list-fonts option, since getting PostScript names out of TrueType fonts is difficult. git-svn-id: svn://svn.tartarus.org/sgt/halibut@7281 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/bk_paper.c b/bk_paper.c index 2e0289c..531600c 100644 --- a/bk_paper.c +++ b/bk_paper.c @@ -1456,6 +1456,14 @@ static int utoglyph(font_info const *fi, wchar_t u) { return (u < 0 || u > 0xFFFF ? NOGLYPH : fi->bmp[u]); } +void listfonts(void) { + font_info const *fi; + + init_std_fonts(); + for (fi = all_fonts; fi; fi = fi->next) + printf("%s\n", fi->name); +} + static font_data *make_std_font(font_list *fontlist, char const *name) { font_info const *fi; diff --git a/doc/index.but b/doc/index.but index 351e3d2..af31cd8 100644 --- a/doc/index.but +++ b/doc/index.but @@ -656,6 +656,7 @@ directive \IM{-C} \c{-C} command-line option \IM{--input-charset} \c{--input-charset} command-line option \IM{--list-charsets} \c{--list-charsets} command-line option +\IM{--list-fonts} \c{--list-fonts} command-line option \IM{--help} \c{--help} command-line option \IM{--version} \c{--version} command-line option \IM{--licence} \c{--licence} command-line option diff --git a/doc/manpage.but b/doc/manpage.but index c39543e..5ce02eb 100644 --- a/doc/manpage.but +++ b/doc/manpage.but @@ -117,6 +117,11 @@ default of ASCII. \dd Makes Halibut list character sets known to it. +\dt \cw{--list-fonts} + +\dd Makes Halibut list fonts known to it, either intrinsically or +by being passed as input files. + \dt \cw{--precise} \dd Makes Halibut report the column number as well as the line diff --git a/doc/output.but b/doc/output.but index 1d9699b..7852692 100644 --- a/doc/output.but +++ b/doc/output.but @@ -1671,36 +1671,10 @@ The directives in this section control which fonts Halibut uses for various kinds of text. Directives for setting the font normally take three font names, the first of which is used for normal text, the second for emphasised text, and the third for code. Any fonts which -aren't specified are left unchanged. Fonts are named using their -PostScript names. +aren't specified are left unchanged. Halibut intrinsically knows about some fonts, and these fonts are also -built into all PDF and most PostScript implementations. These are: - -\b \cw{Times-Roman} - -\b \cw{Times-Italic} - -\b \cw{Times-Bold} - -\b \cw{Times-BoldItalic} - -\b \cw{Helvetica} - -\b \cw{Helvetica-Oblique} - -\b \cw{Helvetica-Bold} - -\b \cw{Helvetica-BoldOblique} - -\b \cw{Courier} - -\b \cw{Courier-Oblique} - -\b \cw{Courier-Bold} - -\b \cw{Courier-BoldOblique} - +built into all PDF and most PostScript implementations. These fonts can be used without further formality. To use any other font, Halibut needs at least to know its measurements, which are provided in an \i{Adobe Font Metrics} (\I{AFM files}AFM) file. @@ -1711,6 +1685,11 @@ an AFM, PFA, or PFB file to Halibut, simply name it on Halibut's command line. If a PFA or PFB file is specified, the corresponding AFM file must come first. +Fonts are specified using their PostScript names. Running Halibut with +the \i\cw{\-\-list-fonts} option causes it to display the PostScript +names of all the fonts it intrinsically knows about, along with any +fonts the were supplied as input files. + \ii{Font sizes} are specified in PostScript \i{points} (72 to the inch). \dt \I{\cw{\\cfg\{paper-title-fonts\}}}\cw{\\cfg\{paper-title-fonts\}\{}\e{normal-font}\cw{\}}[\cw{\{}\e{emph-font}\cw{\}}[\cw{\{}\e{code-font}\cw{\}}]] diff --git a/doc/running.but b/doc/running.but index 8574708..6d6cb7a 100644 --- a/doc/running.but +++ b/doc/running.but @@ -207,6 +207,11 @@ See \k{input-config} for more information about the input character set. \dd List character sets known to Halibut. +\dt \i\cw{--list-fonts} + +\dd List fonts known to Halibut, both those it intrinsically knows about +and those found in its input files. + \dt \i\cw{--help} \dd Print a brief help message and exit immediately. (Don't confuse diff --git a/halibut.h b/halibut.h index 6874bf0..183a0cb 100644 --- a/halibut.h +++ b/halibut.h @@ -527,6 +527,7 @@ paragraph *info_config_filename(char *filename); * bk_paper.c */ void *paper_pre_backend(paragraph *, keywordlist *, indexdata *); +void listfonts(void); /* * bk_ps.c diff --git a/help.c b/help.c index 8db2859..d65645d 100644 --- a/help.c +++ b/help.c @@ -17,6 +17,7 @@ static const char *const helptext[] = { " -Cfoo:bar:baz append \\cfg{foo}{bar}{baz} to input", " --input-charset=cs change default input file charset", " --list-charsets display supported character set names", + " --list-fonts display supported font names", " --precise report column numbers in error messages", " --help display this text", " --version display version number", diff --git a/input.c b/input.c index 337517d..6a53ebb 100644 --- a/input.c +++ b/input.c @@ -1586,6 +1586,7 @@ struct { { "StartFontMetrics", 16, &read_afm_file }, { "\x00\x01\x00\x00", 4, &read_sfnt_file }, { "true", 4, &read_sfnt_file }, + { "OTTO", 4, &read_sfnt_file }, }; paragraph *read_input(input *in, indexdata *idx) { diff --git a/main.c b/main.c index e291d06..60ad74f 100644 --- a/main.c +++ b/main.c @@ -43,6 +43,7 @@ int main(int argc, char **argv) { int nogo; int errs; int reportcols; + int list_fonts; int input_charset; int debug; int backendbits, prebackbits; @@ -68,6 +69,7 @@ int main(int argc, char **argv) { nfiles = 0; nogo = errs = FALSE; reportcols = 0; + list_fonts = 0; input_charset = CS_ASCII; debug = 0; backendbits = 0; @@ -148,6 +150,8 @@ int main(int argc, char **argv) { } else if (!strcmp(opt, "-list-charsets")) { listcharsets(); nogo = TRUE; + } else if (!strcmp(opt, "-list-fonts")) { + list_fonts = TRUE; } else if (!strcmp(opt, "-precise")) { reportcols = 1; } else { @@ -272,7 +276,7 @@ int main(int argc, char **argv) { /* * Do the work. */ - if (nfiles == 0) { + if (nfiles == 0 && !list_fonts) { error(err_noinput); usage(); exit(EXIT_FAILURE); @@ -297,6 +301,10 @@ int main(int argc, char **argv) { idx = make_index(); sourceform = read_input(&in, idx); + if (list_fonts) { + listfonts(); + exit(EXIT_SUCCESS); + } if (!sourceform) exit(EXIT_FAILURE);