From cd9039d9babbcd0d2ce4ec26cd2c205d9288e2b8 Mon Sep 17 00:00:00 2001 From: Steffen Nurpmeso Date: Thu, 2 Oct 2014 20:58:33 +0200 Subject: [PATCH] Adapt src/ute-tfmtodit (src/utils/tfmtodit) --- .../tfmtodit/tfmtodit.man => man/ute-tfmtodit.1.in | 58 +++---- src/ute-tfmtodit/tfmtodit-config.h | 9 ++ src/{utils/tfmtodit => ute-tfmtodit}/tfmtodit.cpp | 180 +++++++++++---------- 3 files changed, 136 insertions(+), 111 deletions(-) rename src/utils/tfmtodit/tfmtodit.man => man/ute-tfmtodit.1.in (79%) create mode 100644 src/ute-tfmtodit/tfmtodit-config.h rename src/{utils/tfmtodit => ute-tfmtodit}/tfmtodit.cpp (85%) diff --git a/src/utils/tfmtodit/tfmtodit.man b/man/ute-tfmtodit.1.in similarity index 79% rename from src/utils/tfmtodit/tfmtodit.man rename to man/ute-tfmtodit.1.in index 51f806d0..2f122b6c 100644 --- a/src/utils/tfmtodit/tfmtodit.man +++ b/man/ute-tfmtodit.1.in @@ -1,5 +1,9 @@ .ig -Copyright (C) 1989-2000, 2001, 2002 Free Software Foundation, Inc. +@ @L_TFMTODIT@.1 + +Copyright (c) 2014 Steffen (Daode) Nurpmeso . + +Copyright (C) 1989 - 2002 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -24,16 +28,17 @@ the original English. .ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP .el .TP "\\$1" .. -.TH TFMTODIT @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +.TH @U_TFMTODIT@ @MAN1EXT@ "@MDATE@" "@T_ROFF@ v@VERSION@" +. .SH NAME -tfmtodit \- create font files for use with groff \-Tdvi +@L_TFMTODIT@ \- create font files for use with @L_ROFF@ \-Tdvi .SH SYNOPSIS .nr a \n(.j .ad l .nr i \n(.i -.in +\w'\fBtfmtodit 'u +.in +\w'\fB@L_TFMTODIT@ 'u .ti \niu -.B tfmtodit +.B @L_TFMTODIT@ .de OP .ie \\n(.$-1 .RI "[\ \fB\\$1\fP" "\\$2" "\ ]" .el .RB "[\ " "\\$1" "\ ]" @@ -50,14 +55,14 @@ tfmtodit \- create font files for use with groff \-Tdvi It is possible to have whitespace between a command line option and its parameter. .SH DESCRIPTION -.B tfmtodit +.B @L_TFMTODIT@ creates a font file for use with .B -groff \-Tdvi\fR. +@L_ROFF@ \-Tdvi\fR. .I tfm_file is the name of the \*(tx font metric file for the font. .I map_file -is a file giving the groff names for characters in the font; +is a file giving the roff names for characters in the font; this file should consist of a sequence of lines of the form: .IP .I @@ -69,12 +74,12 @@ is a decimal integer giving the position of the character in the font, and .IR c1 , .IR c2 ,.\|.\|. -are the groff names of the character. -If a character has no groff names but exists in the tfm file, -then it will be put in the groff font file as an unnamed character. +are the roff names of the character. +If a character has no roff names but exists in the tfm file, +then it will be put in the roff font file as an unnamed character. .I font -is the name of the groff font file. -The groff font file is written to +is the name of the roff font file. +The roff font file is written to .IR font . .LP The @@ -91,14 +96,14 @@ it should be listed in the .B fonts command in the DESC file; if it is not special, there is no need to list it, since -.B troff +.B @L_TROFF@ can automatically mount it when it's first used. .LP -To do a good job of math typesetting, groff requires +To do a good job of math typesetting, @L_ROFF@ requires font metric information not present in the tfm file. The reason for this is that \*(tx has separate math italic fonts -whereas groff uses normal italic fonts for math. -The additional information required by groff is given by the +whereas @L_ROFF@ uses normal italic fonts for math. +The additional information required by @L_ROFF@ is given by the two arguments to the .B math_fit macro in the Metafont programs for the Computer Modern fonts. @@ -166,7 +171,7 @@ The skewchar of this font is at position .I n should be an integer; it may be given in decimal, -or with a leading +or with a leading .B 0 in octal, or with a leading @@ -180,18 +185,17 @@ is the specified character. is a gf file produced by Metafont containing special and numspecial commands giving additional font metric information. .SH FILES -.Tp \w'\fB@FONTDIR@/devdvi/DESC'u+2n -.B @FONTDIR@/devdvi/DESC +.Tp \w'\fB@FONTDIR@/dev-dvi/DESC'u+2n +.B @FONTDIR@/dev-dvi/DESC Device description file. .TP -.BI @FONTDIR@/devdvi/ F +.BI @FONTDIR@/dev-dvi/ F Font description file for font .IR F . +. .SH "SEE ALSO" -.BR groff (@MAN1EXT@), -.BR grodvi (@MAN1EXT@), -.BR groff_font (@MAN5EXT@) +.BR @L_ROFF@ (@MAN1EXT@), +.BR @L_D_DVI@ (@MAN1EXT@), +.BR @L_ROFF@_font (@MAN5EXT@) . -.\" Local Variables: -.\" mode: nroff -.\" End: +.\" s-ts-mode diff --git a/src/ute-tfmtodit/tfmtodit-config.h b/src/ute-tfmtodit/tfmtodit-config.h new file mode 100644 index 00000000..2f12330b --- /dev/null +++ b/src/ute-tfmtodit/tfmtodit-config.h @@ -0,0 +1,9 @@ +/*@ Configurable stuff */ +#ifndef _TFMTODIT_CONFIG_H +#define _TFMTODIT_CONFIG_H + +// Values in the tfm file should be multiplied by this. +#define MULTIPLIER 1 + +#endif // _TFMTODIT_CONFIG_H +// s-it2-mode diff --git a/src/utils/tfmtodit/tfmtodit.cpp b/src/ute-tfmtodit/tfmtodit.cpp similarity index 85% rename from src/utils/tfmtodit/tfmtodit.cpp rename to src/ute-tfmtodit/tfmtodit.cpp index ccf995a3..7b15df58 100644 --- a/src/utils/tfmtodit/tfmtodit.cpp +++ b/src/ute-tfmtodit/tfmtodit.cpp @@ -1,69 +1,69 @@ -// -*- C++ -*- -/* Copyright (C) 1989-1992, 2000, 2001, 2004 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. */ - -/* I have tried to incorporate the changes needed for TeX 3.0 tfm files, -but I haven't tested them. */ - -/* Groff requires more font metric information than TeX. The reason -for this is that TeX has separate Math Italic fonts, whereas groff -uses normal italic fonts for math. The two additional pieces of -information required by groff correspond to the two arguments to the -math_fit() macro in the Metafont programs for the CM fonts. In the -case of a font for which math_fitting is false, these two arguments -are normally ignored by Metafont. We need to get hold of these two -parameters and put them in the groff font file. - -We do this by loading this definition after cmbase when creating cm.base. - -def ignore_math_fit(expr left_adjustment,right_adjustment) = - special "adjustment"; - numspecial left_adjustment*16/designsize; - numspecial right_adjustment*16/designsize; - enddef; - -This puts the two arguments to the math_fit macro into the gf file. -(They will appear in the gf file immediately before the character to -which they apply.) We then create a gf file using this cm.base. Then -we run tfmtodit and specify this gf file with the -g option. - -This need only be done for a font for which math_fitting is false; -When it's true, the left_correction and subscript_correction should -both be zero. */ - -#include "lib.h" - -#include -#include +/*@ + * Copyright (c) 2014 Steffen (Daode) Nurpmeso . + * + * Copyright (C) 1989 - 1992, 2000, 2001, 2004 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. + */ + +/* + * I have tried to incorporate the changes needed for TeX 3.0 tfm files, + * but I haven't tested them. + * + * Groff requires more font metric information than TeX. The reason + * for this is that TeX has separate Math Italic fonts, whereas groff + * uses normal italic fonts for math. The two additional pieces of + * information required by groff correspond to the two arguments to the + * math_fit() macro in the Metafont programs for the CM fonts. In the + * case of a font for which math_fitting is false, these two arguments + * are normally ignored by Metafont. We need to get hold of these two + * parameters and put them in the groff font file. + * + * We do this by loading this definition after cmbase when creating cm.base. + * + * def ignore_math_fit(expr left_adjustment,right_adjustment) = + * special "adjustment"; + * numspecial left_adjustment*16/designsize; + * numspecial right_adjustment*16/designsize; + * enddef; + * + * This puts the two arguments to the math_fit macro into the gf file. + * (They will appear in the gf file immediately before the character to + * which they apply.) We then create a gf file using this cm.base. Then + * we run tfmtodit and specify this gf file with the -g option. + * + * This need only be done for a font for which math_fitting is false; + * When it's true, the left_correction and subscript_correction should + * both be zero. + */ + +#include "config.h" +#include "tfmtodit-config.h" + +#include #include +#include +#include + +#include "cset.h" #include "errarg.h" #include "error.h" -#include "assert.h" -#include "cset.h" +#include "lib.h" #include "nonposix.h" -extern "C" const char *Version_string; - -/* Values in the tfm file should be multiplied by this. */ - -#define MULTIPLIER 1 - struct char_info_word { unsigned char width_index; char height_index; @@ -80,7 +80,10 @@ struct lig_kern_command { unsigned char remainder; }; -class tfm { +class tfm +{ + friend class kern_iterator; + int bc; int ec; int nw; @@ -100,6 +103,7 @@ class tfm { lig_kern_command *lig_kern; int *kern; int *param; + public: tfm(); ~tfm(); @@ -113,13 +117,14 @@ public: int get_checksum(); int get_design_size(); int get_lig(unsigned char, unsigned char, unsigned char *); - friend class kern_iterator; }; -class kern_iterator { +class kern_iterator +{ tfm *t; int c; int i; + public: kern_iterator(tfm *); int next(unsigned char *c1, unsigned char *c2, int *k); @@ -164,7 +169,7 @@ int kern_iterator::next(unsigned char *c1, unsigned char *c2, int *k) } return 0; } - + tfm::tfm() : char_info(0), width(0), height(0), depth(0), italic(0), lig_kern(0), kern(0), param(0) @@ -252,7 +257,7 @@ tfm::~tfm() a_delete kern; a_delete param; } - + int read2(unsigned char *&s) { int n; @@ -271,7 +276,6 @@ int read4(unsigned char *&s) return n; } - int tfm::load(const char *file) { errno = 0; @@ -373,13 +377,16 @@ int tfm::load(const char *file) return 1; } -class gf { - int left[256]; - int right[256]; +class gf +{ static int sread4(int *p, FILE *fp); static int uread3(int *p, FILE *fp); static int uread2(int *p, FILE *fp); static int skip(int n, FILE *fp); + + int left[256]; + int right[256]; + public: gf(); int load(const char *file); @@ -586,10 +593,12 @@ int gf::skip(int n, FILE *fp) return 1; } - -struct char_list { +class char_list +{ +public: char *ch; char_list *next; + char_list(const char *, char_list * = 0); }; @@ -597,7 +606,6 @@ char_list::char_list(const char *s, char_list *p) : ch(strsave(s)), next(p) { } - int read_map(const char *file, char_list **table) { errno = 0; @@ -644,16 +652,17 @@ int read_map(const char *file, char_list **table) return 1; } - -/* Every character that can participate in a ligature appears in the -lig_chars table. `ch' gives the full-name of the character, `name' -gives the groff name of the character, `i' gives its index in -the encoding, which is filled in later (-1 if it does not appear). */ +/* + * Every character that can participate in a ligature appears in the + * lig_chars table. `ch' gives the full-name of the character, `name' + * gives the groff name of the character, `i' gives its index in + * the encoding, which is filled in later (-1 if it does not appear). + */ struct S { const char *ch; int i; -} lig_chars[] = { +} lig_chars[] = { // FIXME const { "f", -1 }, { "i", -1 }, { "l", -1 }, @@ -673,7 +682,7 @@ enum { CH_f, CH_i, CH_l, CH_ff, CH_fi, CH_fl, CH_ffi, CH_ffl }; struct S2 { unsigned char c1, c2, res; const char *ch; -} lig_table[] = { +} lig_table[] = { // FIXME const { CH_f, CH_f, CH_ff, "ff" }, { CH_f, CH_i, CH_fi, "fi" }, { CH_f, CH_l, CH_fl, "fl" }, @@ -682,7 +691,7 @@ struct S2 { }; static void usage(FILE *stream); - + int main(int argc, char **argv) { program_name = argv[0]; @@ -718,7 +727,7 @@ int main(int argc, char **argv) } case 'v': { - printf("GNU tfmtodit (groff) version %s\n", Version_string); + printf(L_TFMTODIT " (" T_ROFF ") v" VERSION); exit(0); break; } @@ -838,7 +847,7 @@ int main(int argc, char **argv) } printf("charset\n"); char_list unnamed("---"); - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) if (t.contains(i)) { char_list *p = table[i] ? table[i] : &unnamed; int m[6]; @@ -869,6 +878,9 @@ int main(int argc, char **argv) static void usage(FILE *stream) { - fprintf(stream, "usage: %s [-sv] [-g gf_file] [-k skewchar] tfm_file map_file font\n", + fprintf(stream, + "Synopsis: %s [-sv] [-g gf_file] [-k skewchar] tfm_file map_file font\n", program_name); } + +// s-it2-mode -- 2.11.4.GIT