BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.bin / groff / libgroff / font.h
CommitLineData
af2a502e
C
1// -*- C++ -*-
2/* Copyright (C) 1989, 1990 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.uucp)
4
5This file is part of groff.
6
7groff is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 1, or (at your option) any later
10version.
11
12groff is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License along
18with groff; see the file LICENSE. If not, write to the Free Software
19Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21
22struct font_kern_list;
23struct font_char_metric;
24
25class font {
26public:
27 enum {
28 LIG_ff = 1,
29 LIG_fi = 2,
30 LIG_fl = 4,
31 LIG_ffi = 8,
32 LIG_ffl = 16
33 };
34
35 virtual ~font();
36 int contains(int index);
37 int is_special();
38 int get_width(int index, int point_size);
39 int get_height(int index, int point_size);
40 int get_depth(int index, int point_size);
41 int get_space_width(int point_size);
42 int get_character_type(int index);
43 int get_kern(int index1, int index2, int point_size);
44 int get_skew(int index, int point_size, int slant);
45 int has_ligature(int);
46 int get_italic_correction(int index, int point_size);
47 int get_left_italic_correction(int index, int point_size);
48 int get_subscript_correction(int index, int point_size);
49 unsigned char get_code(int i);
50 const char *get_name();
51 const char *get_internal_name();
52
53 static font *load_font(const char *);
54 static void command_line_font_dir(const char *path);
55 static void forget_command_line_font_dirs();
56 static void set_device_name(const char *);
57 static const char *get_device_name();
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(unsigned char);
62
63 static int res;
64 static int hor;
65 static int vert;
66 static int unitwidth;
67 static int paperwidth;
68 static int paperlength;
69 static int biggestfont;
70 static int spare2;
71 static int sizescale;
72 static int tcommand;
73
74 static const char **font_name_table;
75 static const char **style_table;
76 static const char *family;
77 static int *sizes;
78private:
79 unsigned ligatures;
80 font_kern_list **kern_hash_table;
81 int space_width;
82 short *ch_index;
83 int nindices;
84 font_char_metric *ch;
85 int ch_used;
86 int ch_size;
87 int special;
88 char *name;
89 char *internalname;
90 double slant;
91
92 static char *dev_name;
93 static char *cl_font_dirs;
94
95 enum { KERN_HASH_TABLE_SIZE = 503 };
96
97 void add_entry(int index, const font_char_metric &);
98 void copy_entry(int new_index, int old_index);
99 void add_kern(int index1, int index2, int amount);
100 static int hash_kern(int i1, int i2);
101 void alloc_ch_index(int);
102 void extend_ch();
103 void compact();
104
105 static int scale(int w, int pointsize);
106 virtual void handle_unknown_font_command(int argc, const char **argv);
107protected:
108 font(const char *);
109 int load();
110};