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