1 // -*- C++ -*- 2 3 // <groff_src_dir>/src/include/printer.h 4 5 /* Copyright (C) 1989-2018 Free Software Foundation, Inc. 6 7 Written by James Clark (jjc@jclark.com) 8 9 This file is part of groff. 10 11 groff is free software; you can redistribute it and/or modify it 12 under the terms of the GNU General Public License as published by 13 the Free Software Foundation, either version 3 of the License, or 14 (at your option) any later version. 15 16 groff is distributed in the hope that it will be useful, but 17 WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 General Public License for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with this program. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 25 /* Description 26 27 The class 'printer' performs the postprocessing. Each 28 postprocessor only needs to implement a derived class of 'printer' and 29 a suitable function 'make_printer' for the device-dependent tasks. 30 Then the methods of class 'printer' are called automatically by 31 'do_file()' in 'input.cpp'. 32 */ 33 34 #include "color.h" 35 36 struct environment { 37 int fontno; 38 int size; 39 int hpos; 40 int vpos; 41 int height; 42 int slant; 43 color *col; 44 color *fill; 45 }; 46 47 class font; 48 49 struct font_pointer_list { 50 font *p; 51 font_pointer_list *next; 52 53 font_pointer_list(font *, font_pointer_list *); 54 }; 55 56 class printer { 57 public: 58 printer(); 59 virtual ~printer(); 60 void load_font(int, const char *); 61 void set_ascii_char(unsigned char, const environment *, int * = 0); 62 void set_special_char(const char *, const environment *, int * = 0); 63 virtual void set_numbered_char(int, const environment *, int * = 0); 64 glyph *set_char_and_width(const char *, const environment *, 65 int *, font **); 66 font *get_font_from_index(int); 67 virtual void draw(int, int *, int, const environment *); 68 // perform change of line color (text, outline) in the print-out 69 virtual void change_color(const environment * const); 70 // perform change of fill color in the print-out 71 virtual void change_fill_color(const environment * const); 72 virtual void begin_page(int) = 0; 73 virtual void end_page(int) = 0; 74 virtual font *make_font(const char *); 75 virtual void end_of_line(); 76 virtual void special(char *, const environment *, char = 'p'); 77 virtual void devtag(char *, const environment *, char = 'p'); 78 79 protected: 80 font_pointer_list *font_list; 81 font **font_table; 82 int nfonts; 83 84 // information about named characters 85 int is_char_named; 86 int is_named_set; 87 char named_command; 88 const char *named_char_s; 89 int named_char_n; 90 91 private: 92 font *find_font(const char *); 93 virtual void set_char(glyph *, font *, const environment *, int, 94 const char *) = 0; 95 }; 96 97 printer *make_printer(); 98