1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2020 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "libpspp/hmap.h"
20 #include "tex-rendering.h"
21 #include "tex-glyphs.h"
28 tex_render (FILE *fp, const char *str)
34 static long macro_insertion_point = 0;
37 tex_preamble (FILE *fp, const char *str)
39 long where = ftell (fp);
40 fseek (fp, macro_insertion_point, SEEK_SET);
43 macro_insertion_point = ftell (fp);
44 fseek (fp, where, SEEK_SET);
49 main (int argc, char **argv)
53 fprintf (stderr, "Usage: tex-glyphs <file>\n");
57 FILE *fp = fopen (argv[1], "w");
60 perror ("Cannot open output file");
67 fseek (fp, 4096, SEEK_SET);
69 tex_render (fp, "\\raggedbottom");
71 tex_render (fp, "\\halign{{\\tt #}\\qquad&{\\font\\xx=cmr7 \\xx #}\\hfil&\\quad{\\rm #}");
72 tex_render (fp, "\\hfil&\\quad{\\sl #}");
73 tex_render (fp, "\\hfil&\\quad{\\it #}");
74 tex_render (fp, "\\hfil&\\quad{\\bf #}");
75 tex_render (fp, "\\hfil&\\quad{\\tt #}\\cr");
77 for (const struct glyph_block *gb = defined_blocks; gb->start; ++gb)
79 ucs4_t x = gb->start->code_point;
80 for (const struct glyph *g = gb->start; x < gb->n_glyphs + gb->start->code_point; ++g)
82 assert (g->code_point == x++);
83 fprintf (fp, "U+%04X&%s&M%sM", g->code_point, g->name,
84 code_point_to_tex (g->code_point, ¯os));
86 code_point_to_tex (g->code_point, ¯os));
88 code_point_to_tex (g->code_point, ¯os));
90 code_point_to_tex (g->code_point, ¯os));
91 fprintf (fp, "&M%sM\\cr\n",
92 code_point_to_tex (g->code_point, ¯os));
98 struct tex_macro *next;
99 HMAP_FOR_EACH_SAFE (m, next, struct tex_macro, node, ¯os)
101 tex_preamble (fp, tex_macro[m->index]);
105 hmap_destroy (¯os);
107 tex_render (fp, "}");
108 tex_render (fp, "\\bye");