175584Sru// -*- C++ -*-
275584Sru
3104862Sru// <groff_src_dir>/src/include/printer.h
475584Sru
5151497Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004
6104862Sru   Free Software Foundation, Inc.
775584Sru
8104862Sru   Written by James Clark (jjc@jclark.com)
975584Sru
10151497Sru   Last update: 15 Dec 2004
1175584Sru
12104862Sru   This file is part of groff.
13104862Sru
14104862Sru   groff is free software; you can redistribute it and/or modify it
15104862Sru   under the terms of the GNU General Public License as published by
16104862Sru   the Free Software Foundation; either version 2, or (at your option)
17104862Sru   any later version.
18104862Sru
19104862Sru   groff is distributed in the hope that it will be useful, but
20104862Sru   WITHOUT ANY WARRANTY; without even the implied warranty of
21104862Sru   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22104862Sru   General Public License for more details.
23104862Sru
24104862Sru   You should have received a copy of the GNU General Public License
25104862Sru   along with groff; see the file COPYING.  If not, write to the Free
26151497Sru   Software Foundation, 51 Franklin St - Fifth Floor, Boston, MA
27151497Sru   02110-1301, USA.
28104862Sru*/
29104862Sru
30104862Sru/* Description
31104862Sru
32104862Sru   The class `printer' performs the postprocessing.  Each
33114402Sru   postprocessor only needs to implement a derived class of `printer' and
34104862Sru   a suitable function `make_printer' for the device-dependent tasks.
35104862Sru   Then the methods of class `printer' are called automatically by
36114402Sru   `do_file()' in `input.cpp'.
37104862Sru*/
38104862Sru
39104862Sru#include "color.h"
40104862Sru
4175584Srustruct environment {
4275584Sru  int fontno;
4375584Sru  int size;
4475584Sru  int hpos;
4575584Sru  int vpos;
4675584Sru  int height;
4775584Sru  int slant;
48104862Sru  color *col;
49104862Sru  color *fill;
5075584Sru};
5175584Sru
52151497Sruclass font;
5375584Sru
5475584Srustruct font_pointer_list {
5575584Sru  font *p;
5675584Sru  font_pointer_list *next;
5775584Sru
5875584Sru  font_pointer_list(font *, font_pointer_list *);
5975584Sru};
6075584Sru
6175584Sruclass printer {
6275584Srupublic:
6375584Sru  printer();
6475584Sru  virtual ~printer();
6575584Sru  void load_font(int i, const char *name);
6675584Sru  void set_ascii_char(unsigned char c, const environment *env,
6775584Sru		      int *widthp = 0);
6875584Sru  void set_special_char(const char *nm, const environment *env,
6975584Sru			int *widthp = 0);
70114402Sru  virtual void set_numbered_char(int n, const environment *env,
71114402Sru				 int *widthp = 0);
7275584Sru  int set_char_and_width(const char *nm, const environment *env,
7375584Sru			 int *widthp, font **f);
7475584Sru  font *get_font_from_index(int fontno);
7575584Sru  virtual void draw(int code, int *p, int np, const environment *env);
76104862Sru  // perform change of line color (text, outline) in the print-out
77104862Sru  virtual void change_color(const environment * const env);
78104862Sru  // perform change of fill color in the print-out
79104862Sru  virtual void change_fill_color(const environment * const env);
8075584Sru  virtual void begin_page(int) = 0;
8175584Sru  virtual void end_page(int page_length) = 0;
8275584Sru  virtual font *make_font(const char *nm);
8375584Sru  virtual void end_of_line();
84104862Sru  virtual void special(char *arg, const environment *env,
85104862Sru		       char type = 'p');
86151497Sru  virtual void devtag(char *arg, const environment *env,
87151497Sru		      char type = 'p');
88151497Sru
8975584Sruprotected:
9075584Sru  font_pointer_list *font_list;
91114402Sru  font **font_table;
92114402Sru  int nfonts;
9375584Sru
9475584Sru  // information about named characters
9575584Sru  int is_char_named;
9675584Sru  int is_named_set;
9775584Sru  char named_command;
9875584Sru  const char *named_char_s;
9975584Sru  int named_char_n;
10075584Sru
10175584Sruprivate:
10275584Sru  font *find_font(const char *);
10375584Sru  virtual void set_char(int index, font *f, const environment *env,
10475584Sru			int w, const char *name) = 0;
10575584Sru};
10675584Sru
10775584Sruprinter *make_printer();
108