No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / groff / src / include / font.h
blob9eb5ab8f9f7031cf4dabd97244a7e2b8010b46e8
1 /* $NetBSD$ */
3 // -*- C++ -*-
4 /* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
5 Free Software Foundation, Inc.
6 Written by James Clark (jjc@jclark.com)
8 This file is part of groff.
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
13 version.
15 groff is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 for more details.
20 You should have received a copy of the GNU General Public License along
21 with groff; see the file COPYING. If not, write to the Free Software
22 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
24 typedef void (*FONT_COMMAND_HANDLER)(const char *, const char *,
25 const char *, int);
27 struct font_kern_list;
28 struct font_char_metric;
29 struct font_widths_cache;
31 class font {
32 public:
33 enum {
34 LIG_ff = 1,
35 LIG_fi = 2,
36 LIG_fl = 4,
37 LIG_ffi = 8,
38 LIG_ffl = 16
41 virtual ~font();
42 int contains(int index);
43 int is_special();
44 int get_width(int index, int point_size);
45 int get_height(int index, int point_size);
46 int get_depth(int index, int point_size);
47 int get_space_width(int point_size);
48 int get_character_type(int index);
49 int get_kern(int index1, int index2, int point_size);
50 int get_skew(int index, int point_size, int slant);
51 int has_ligature(int);
52 int get_italic_correction(int index, int point_size);
53 int get_left_italic_correction(int index, int point_size);
54 int get_subscript_correction(int index, int point_size);
55 int get_code(int i);
56 const char *get_special_device_encoding(int index);
57 const char *get_name();
58 const char *get_internal_name();
59 const char *get_image_generator();
61 static int scan_papersize(const char *, const char **, double *, double *);
63 static font *load_font(const char *, int * = 0, int = 0);
64 static void command_line_font_dir(const char *path);
65 static FILE *open_file(const char *name, char **pathp);
66 static int load_desc();
67 static int name_to_index(const char *);
68 static int number_to_index(int);
69 static FONT_COMMAND_HANDLER
70 set_unknown_desc_command_handler(FONT_COMMAND_HANDLER);
72 static int res;
73 static int hor;
74 static int vert;
75 static int unitwidth;
76 static int paperwidth;
77 static int paperlength;
78 static const char *papersize;
79 static int biggestfont;
80 static int spare2;
81 static int sizescale;
82 static int tcommand;
83 static int unscaled_charwidths;
84 static int pass_filenames;
85 static int use_charnames_in_special;
86 static const char *image_generator;
88 static const char **font_name_table;
89 static const char **style_table;
90 static const char *family;
91 static int *sizes;
92 private:
93 unsigned ligatures;
94 font_kern_list **kern_hash_table;
95 int space_width;
96 int *ch_index;
97 int nindices;
98 font_char_metric *ch;
99 int ch_used;
100 int ch_size;
101 int special;
102 char *name;
103 char *internalname;
104 double slant;
105 font_widths_cache *widths_cache;
106 static FONT_COMMAND_HANDLER unknown_desc_command_handler;
108 enum { KERN_HASH_TABLE_SIZE = 503 };
110 void add_entry(int index, const font_char_metric &);
111 void copy_entry(int new_index, int old_index);
112 void add_kern(int index1, int index2, int amount);
113 static int hash_kern(int i1, int i2);
114 void alloc_ch_index(int);
115 void extend_ch();
116 void compact();
118 static int scale(int w, int pointsize);
119 static int unit_scale(double *value, char unit);
120 virtual void handle_unknown_font_command(const char *command,
121 const char *arg,
122 const char *file, int lineno);
123 protected:
124 font(const char *);
125 int load(int * = 0, int = 0);