font.h revision 75584
1// -*- C++ -*- 2/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. 3 Written by James Clark (jjc@jclark.com) 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 2, 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 COPYING. If not, write to the Free Software 19Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 20 21typedef void (*FONT_COMMAND_HANDLER)(const char *, const char *, 22 const char *, int); 23 24struct font_kern_list; 25struct font_char_metric; 26struct font_widths_cache; 27 28class font { 29public: 30 enum { 31 LIG_ff = 1, 32 LIG_fi = 2, 33 LIG_fl = 4, 34 LIG_ffi = 8, 35 LIG_ffl = 16 36 }; 37 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_special_device_encoding(int index); 54 const char *get_name(); 55 const char *get_internal_name(); 56 57 static font *load_font(const char *, int *not_found = 0); 58 static void command_line_font_dir(const char *path); 59 static FILE *open_file(const char *name, char **pathp); 60 static int load_desc(); 61 static int name_to_index(const char *); 62 static int number_to_index(int); 63 static FONT_COMMAND_HANDLER 64 set_unknown_desc_command_handler(FONT_COMMAND_HANDLER); 65 66 static int res; 67 static int hor; 68 static int vert; 69 static int unitwidth; 70 static int paperwidth; 71 static int paperlength; 72 static int biggestfont; 73 static int spare2; 74 static int sizescale; 75 static int tcommand; 76 static int pass_filenames; 77 static int use_charnames_in_special; 78 79 static const char **font_name_table; 80 static const char **style_table; 81 static const char *family; 82 static int *sizes; 83private: 84 unsigned ligatures; 85 font_kern_list **kern_hash_table; 86 int space_width; 87 short *ch_index; 88 int nindices; 89 font_char_metric *ch; 90 int ch_used; 91 int ch_size; 92 int special; 93 char *name; 94 char *internalname; 95 double slant; 96 font_widths_cache *widths_cache; 97 static FONT_COMMAND_HANDLER unknown_desc_command_handler; 98 99 enum { KERN_HASH_TABLE_SIZE = 503 }; 100 101 void add_entry(int index, const font_char_metric &); 102 void copy_entry(int new_index, int old_index); 103 void add_kern(int index1, int index2, int amount); 104 static int hash_kern(int i1, int i2); 105 void alloc_ch_index(int); 106 void extend_ch(); 107 void compact(); 108 109 static int scale(int w, int pointsize); 110 virtual void handle_unknown_font_command(const char *command, 111 const char *arg, 112 const char *file, int lineno); 113protected: 114 font(const char *); 115 int load(int *not_found = 0); 116}; 117