groff before CVS: release 1.15
[s-roff.git] / include / font.h
blobe981bc1d0680cedd61d91294b5eb307c45709d58
1 // -*- C++ -*-
2 /* Copyright (C) 1989, 1990, 1991, 1992 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 2, or (at your option) any later
10 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
15 for more details.
17 You should have received a copy of the GNU General Public License along
18 with groff; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 typedef void (*FONT_COMMAND_HANDLER)(const char *, const char *,
22 const char *, int);
24 struct font_kern_list;
25 struct font_char_metric;
26 struct font_widths_cache;
28 class font {
29 public:
30 enum {
31 LIG_ff = 1,
32 LIG_fi = 2,
33 LIG_fl = 4,
34 LIG_ffi = 8,
35 LIG_ffl = 16
38 virtual ~font();
39 int contains(int index);
40 int is_special();
41 int get_width(int index, int point_size);
42 int get_height(int index, int point_size);
43 int get_depth(int index, int point_size);
44 int get_space_width(int point_size);
45 int get_character_type(int index);
46 int get_kern(int index1, int index2, int point_size);
47 int get_skew(int index, int point_size, int slant);
48 int has_ligature(int);
49 int get_italic_correction(int index, int point_size);
50 int get_left_italic_correction(int index, int point_size);
51 int get_subscript_correction(int index, int point_size);
52 int get_code(int i);
53 const char *get_name();
54 const char *get_internal_name();
56 static font *load_font(const char *, int *not_found = 0);
57 static void command_line_font_dir(const char *path);
58 static FILE *open_file(const char *name, char **pathp);
59 static int load_desc();
60 static int name_to_index(const char *);
61 static int number_to_index(int);
62 static FONT_COMMAND_HANDLER
63 set_unknown_desc_command_handler(FONT_COMMAND_HANDLER);
65 static int res;
66 static int hor;
67 static int vert;
68 static int unitwidth;
69 static int paperwidth;
70 static int paperlength;
71 static int biggestfont;
72 static int spare2;
73 static int sizescale;
74 static int tcommand;
76 static const char **font_name_table;
77 static const char **style_table;
78 static const char *family;
79 static int *sizes;
80 private:
81 unsigned ligatures;
82 font_kern_list **kern_hash_table;
83 int space_width;
84 short *ch_index;
85 int nindices;
86 font_char_metric *ch;
87 int ch_used;
88 int ch_size;
89 int special;
90 char *name;
91 char *internalname;
92 double slant;
93 font_widths_cache *widths_cache;
94 static FONT_COMMAND_HANDLER unknown_desc_command_handler;
96 enum { KERN_HASH_TABLE_SIZE = 503 };
98 void add_entry(int index, const font_char_metric &);
99 void copy_entry(int new_index, int old_index);
100 void add_kern(int index1, int index2, int amount);
101 static int hash_kern(int i1, int i2);
102 void alloc_ch_index(int);
103 void extend_ch();
104 void compact();
106 static int scale(int w, int pointsize);
107 virtual void handle_unknown_font_command(const char *command,
108 const char *arg,
109 const char *file, int lineno);
110 protected:
111 font(const char *);
112 int load(int *not_found = 0);