2 /* Copyright (C) 1989-2020 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
5 This file is part of groff.
7 groff is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 void guess(const char *s, const font_params ¶m, char_metric *metric)
24 int &height = metric->height;
25 int &depth = metric->depth;
32 if (s[0] == '\0' || (s[1] != '\0' && s[2] != '\0'))
34 #define HASH(c1, c2) (((unsigned char)(c1) << 8) | (unsigned char)(c2))
35 switch (HASH(s[0], s[1])) {
38 if (metric->type & 01)
39 depth = param.desc_depth;
40 if (metric->type & 02)
41 height = param.asc_height;
43 height = param.x_height;
48 // these have zero height and depth
51 height = param.asc_height;
53 depth = param.desc_depth;
68 height = param.x_height;
71 height = param.x_height;
83 height = param.asc_height;
86 height = param.asc_height;
92 height = param.x_height;
93 depth = param.desc_depth;
96 height = param.x_height;
97 depth = param.desc_depth;
125 height = param.cap_height;
151 height = param.cap_height;
166 height = param.fig_height;
174 height = param.body_height;
175 depth = param.body_depth;
178 height = (param.em*3)/4;
192 height = param.x_height;
196 height = param.asc_height;
204 height = param.x_height;
205 depth = param.desc_depth;
212 height = param.asc_height;
213 depth = param.desc_depth;
216 height = param.x_height;
217 depth = param.desc_depth;
228 height = param.asc_height;
232 height = param.asc_height;
238 height = param.asc_height;
244 depth = param.comma_depth;
250 height = param.x_height;
253 height = param.x_height;
256 height = param.x_height;
257 depth = param.comma_depth;
261 height = param.x_height;
271 height = param.asc_height;
275 case HASH('\\', '_'):
279 height = (param.em*3)/4;
282 height = (param.em*3)/4;
327 height = param.asc_height;
340 height = (param.em*3)/4;
379 case HASH('\\', '-'):
461 case HASH('\'', 'A'):
462 case HASH('\'', 'C'):
463 case HASH('\'', 'E'):
464 case HASH('\'', 'I'):
465 case HASH('\'', 'O'):
466 case HASH('\'', 'U'):
467 case HASH('\'', 'a'):
468 case HASH('\'', 'c'):
469 case HASH('\'', 'e'):
470 case HASH('\'', 'i'):
471 case HASH('\'', 'o'):