From 6850b8f755d6d109666c957fd3f375114fd09a36 Mon Sep 17 00:00:00 2001 From: Steffen Nurpmeso Date: Wed, 27 May 2015 14:49:40 +0200 Subject: [PATCH] Adapt src/ute-addftinfo (src/utils/addftinfo) --- .../addftinfo.man => man/ute-addftinfo.1.in | 29 ++++---- src/ute-addftinfo/addftinfo-config.h.in | 17 +++++ .../addftinfo => ute-addftinfo}/addftinfo.cpp | 81 ++++++++++------------ src/{utils/addftinfo => ute-addftinfo}/guess.cpp | 42 ++++++----- src/ute-addftinfo/guess.h | 50 +++++++++++++ src/utils/addftinfo/guess.h | 44 ------------ 6 files changed, 143 insertions(+), 120 deletions(-) rename src/utils/addftinfo/addftinfo.man => man/ute-addftinfo.1.in (83%) create mode 100644 src/ute-addftinfo/addftinfo-config.h.in rename src/{utils/addftinfo => ute-addftinfo}/addftinfo.cpp (75%) rename src/{utils/addftinfo => ute-addftinfo}/guess.cpp (91%) create mode 100644 src/ute-addftinfo/guess.h delete mode 100644 src/utils/addftinfo/guess.h diff --git a/src/utils/addftinfo/addftinfo.man b/man/ute-addftinfo.1.in similarity index 83% rename from src/utils/addftinfo/addftinfo.man rename to man/ute-addftinfo.1.in index a9b84551..3e28c061 100644 --- a/src/utils/addftinfo/addftinfo.man +++ b/man/ute-addftinfo.1.in @@ -1,5 +1,9 @@ .ig -Copyright (C) 1989-2000, 2001 Free Software Foundation, Inc. +@ @L_ADDFTINFO@.1 + +Copyright (c) 2014 Steffen (Daode) Nurpmeso . + +Copyright (C) 1989 - 2001 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -16,11 +20,11 @@ versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. .. -.TH ADDFTINFO @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +.TH @U_ADDFTINFO@ @MAN1EXT@ "@MDATE@" "@T_ROFF@ v@VERSION@" .SH NAME -addftinfo \- add information to troff font files for use with groff +@L_ADDFTINFO@ \- add information to troff font files for use with @T_ROFF@ .SH SYNOPSIS -.B addftinfo +.B @L_ADDFTINFO@ [ .B \-v ] @@ -31,13 +35,13 @@ addftinfo \- add information to troff font files for use with groff .I unitwidth .I font .SH DESCRIPTION -.B addftinfo +.B @L_ADDFTINFO@ reads a troff font file and adds some additional font-metric information that is used by the groff system. The font file with the information added is written on the standard output. -The information added is guessed using +The information added is guessed using some parametric information about the font and assumptions about the traditional troff names for characters. @@ -95,17 +99,16 @@ The depth of characters with descenders, such as p,q, or y. .B body-depth The depth of characters such as parentheses. .LP -.B addftinfo +.B @L_ADDFTINFO@ makes no attempt to use the specified parameters to guess the unspecified parameters. If a parameter is not specified the default will be used. The defaults are chosen to have the reasonable values for a Times font. +. .SH "SEE ALSO" -.BR groff_font (@MAN5EXT@), -.BR groff (@MAN1EXT@), -.BR groff_char (@MAN7EXT@) +.BR @L_ROFF@ (@MAN1EXT@), +.BR @L_ROFF@_font (@MAN5EXT@), +.BR @L_ROFF@_char (@MAN7EXT@) . -.\" Local Variables: -.\" mode: nroff -.\" End: +.\" s-ts-mode diff --git a/src/ute-addftinfo/addftinfo-config.h.in b/src/ute-addftinfo/addftinfo-config.h.in new file mode 100644 index 00000000..43345256 --- /dev/null +++ b/src/ute-addftinfo/addftinfo-config.h.in @@ -0,0 +1,17 @@ +/*@ Configurable stuff */ +#ifndef _ADDFTINFO_CONFIG_H +#define _ADDFTINFO_CONFIG_H + +// These are all in thousandths of an em. +// These values are correct for PostScript Times Roman. +#define DEFAULT_X_HEIGHT 448 +#define DEFAULT_FIG_HEIGHT 676 +#define DEFAULT_ASC_HEIGHT 682 +#define DEFAULT_BODY_HEIGHT 676 +#define DEFAULT_CAP_HEIGHT 662 +#define DEFAULT_COMMA_DEPTH 143 +#define DEFAULT_DESC_DEPTH 217 +#define DEFAULT_BODY_DEPTH 177 + +#endif // _ADDFTINFO_CONFIG_H +// s-it2-mode diff --git a/src/utils/addftinfo/addftinfo.cpp b/src/ute-addftinfo/addftinfo.cpp similarity index 75% rename from src/utils/addftinfo/addftinfo.cpp rename to src/ute-addftinfo/addftinfo.cpp index b2fd15db..fc505c29 100644 --- a/src/utils/addftinfo/addftinfo.cpp +++ b/src/ute-addftinfo/addftinfo.cpp @@ -1,36 +1,38 @@ -// -*- C++ -*- -/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.com) +/*@ + * Copyright (c) 2014 Steffen (Daode) Nurpmeso . + * + * Copyright (C) 1989 - 1992, 2000, 2001 Free Software Foundation, Inc. + * Written by James Clark (jjc@jclark.com) + * + * groff is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2, or (at your option) any later + * version. + * + * groff is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with groff; see the file COPYING. If not, write to the Free Software + * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "addftinfo-config.h" -This file is part of groff. - -groff is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -groff is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License along -with groff; see the file COPYING. If not, write to the Free Software -Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ - -#include "lib.h" - -#include #include -#include +#include #include +#include + +#include "cset.h" #include "errarg.h" #include "error.h" -#include "stringclass.h" -#include "cset.h" #include "guess.h" - -extern "C" const char *Version_string; +#include "lib.h" +#include "stringclass.h" static void usage(FILE *stream); static void usage(); @@ -42,7 +44,7 @@ typedef int font_params::*param_t; static struct { const char *name; param_t par; -} param_table[] = { +} param_table[] = { // FIXME const { "x-height", &font_params::x_height }, { "fig-height", &font_params::fig_height }, { "asc-height", &font_params::asc_height }, @@ -53,18 +55,6 @@ static struct { { "body-depth", &font_params::body_depth }, }; -// These are all in thousandths of an em. -// These values are correct for PostScript Times Roman. - -#define DEFAULT_X_HEIGHT 448 -#define DEFAULT_FIG_HEIGHT 676 -#define DEFAULT_ASC_HEIGHT 682 -#define DEFAULT_BODY_HEIGHT 676 -#define DEFAULT_CAP_HEIGHT 662 -#define DEFAULT_COMMA_DEPTH 143 -#define DEFAULT_DESC_DEPTH 217 -#define DEFAULT_BODY_DEPTH 177 - int main(int argc, char **argv) { program_name = argv[0]; @@ -110,7 +100,7 @@ int main(int argc, char **argv) usage(); size_t j; for (j = 0;; j++) { - if (j >= sizeof(param_table)/sizeof(param_table[0])) + if (j >= NELEM(param_table)) fatal("parameter `%1' not recognized", argv[i] + 1); if (strcmp(param_table[j].name, argv[i] + 1) == 0) break; @@ -118,7 +108,7 @@ int main(int argc, char **argv) if (sscanf(argv[i+1], "%d", &(param.*(param_table[j].par))) != 1) fatal("invalid argument `%1'", argv[i+1]); i++; - } + } if (argc - i != 3) usage(); errno = 0; @@ -131,7 +121,7 @@ int main(int argc, char **argv) static void usage(FILE *stream) { - fprintf(stream, "usage: %s [-v] [-param value] ... " + fprintf(stream, "Synopsis: %s [-v] [-param value] ... " "resolution unitwidth font\n", program_name); } @@ -143,7 +133,7 @@ static void usage() static void version() { - printf("GNU addftinfo (groff) version %s\n", Version_string); + printf(L_ADDFTINFO " (" T_ROFF ") v" VERSION); exit(0); } @@ -158,7 +148,7 @@ static int get_line(FILE *fp, string *p) } return p->length() > 0; } - + static void convert_font(const font_params ¶m, FILE *infp, FILE *outfp) { string s; @@ -216,3 +206,4 @@ static void convert_font(const font_params ¶m, FILE *infp, FILE *outfp) } } +// s-it2-mode diff --git a/src/utils/addftinfo/guess.cpp b/src/ute-addftinfo/guess.cpp similarity index 91% rename from src/utils/addftinfo/guess.cpp rename to src/ute-addftinfo/guess.cpp index 7ae36dcd..ede2b1a9 100644 --- a/src/utils/addftinfo/guess.cpp +++ b/src/ute-addftinfo/guess.cpp @@ -1,22 +1,26 @@ -// -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.com) +/*@ + * Copyright (c) 2014 Steffen (Daode) Nurpmeso . + * + * Copyright (C) 1989 - 1992 Free Software Foundation, Inc. + * Written by James Clark (jjc@jclark.com) + * + * groff is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2, or (at your option) any later + * version. + * + * groff is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with groff; see the file COPYING. If not, write to the Free Software + * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. + */ -This file is part of groff. - -groff is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -groff is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License along -with groff; see the file COPYING. If not, write to the Free Software -Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "config.h" +#include "addftinfo-config.h" #include "guess.h" @@ -488,3 +492,5 @@ void guess(const char *s, const font_params ¶m, char_metric *metric) #endif } } + +// s-it2-mode diff --git a/src/ute-addftinfo/guess.h b/src/ute-addftinfo/guess.h new file mode 100644 index 00000000..bfd90312 --- /dev/null +++ b/src/ute-addftinfo/guess.h @@ -0,0 +1,50 @@ +/*@ + * Copyright (c) 2014 Steffen (Daode) Nurpmeso . + * + * Copyright (C) 1989 - 1992 Free Software Foundation, Inc. + * Written by James Clark (jjc@jclark.com) + * + * groff is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2, or (at your option) any later + * version. + * + * groff is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with groff; see the file COPYING. If not, write to the Free Software + * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef _GUESS_H +#define _GUESS_H + +struct font_params { + int italic; + int em; + int x_height; + int fig_height; + int cap_height; + int asc_height; + int body_height; + int comma_depth; + int desc_depth; + int body_depth; +}; + +struct char_metric { + int width; + int type; + int height; + int depth; + int ic; + int left_ic; + int sk; +}; + +void guess(const char *s, const font_params ¶m, char_metric *metric); + +#endif // _GUESS_H +// s-it2-mode diff --git a/src/utils/addftinfo/guess.h b/src/utils/addftinfo/guess.h deleted file mode 100644 index 26f0883e..00000000 --- a/src/utils/addftinfo/guess.h +++ /dev/null @@ -1,44 +0,0 @@ -// -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.com) - -This file is part of groff. - -groff is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -groff is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License along -with groff; see the file COPYING. If not, write to the Free Software -Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ - -struct font_params { - int italic; - int em; - int x_height; - int fig_height; - int cap_height; - int asc_height; - int body_height; - int comma_depth; - int desc_depth; - int body_depth; -}; - -struct char_metric { - int width; - int type; - int height; - int depth; - int ic; - int left_ic; - int sk; -}; - -void guess(const char *s, const font_params ¶m, char_metric *metric); -- 2.11.4.GIT