1 /*************************************************************************
2 ** VFReader.h                                                           **
3 **                                                                      **
4 ** This file is part of dvisvgm -- the DVI to SVG converter             **
5 ** Copyright (C) 2005-2015 Martin Gieseking <martin.gieseking@uos.de>   **
6 **                                                                      **
7 ** This program is free software; you can redistribute it and/or        **
8 ** modify it under the terms of the GNU General Public License as       **
9 ** published by the Free Software Foundation; either version 3 of       **
10 ** the License, or (at your option) any later version.                  **
11 **                                                                      **
12 ** This program is distributed in the hope that it will be useful, but  **
13 ** WITHOUT ANY WARRANTY; without even the implied warranty of           **
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         **
15 ** GNU General Public License for more details.                         **
16 **                                                                      **
17 ** You should have received a copy of the GNU General Public License    **
18 ** along with this program; if not, see <http://www.gnu.org/licenses/>. **
19 *************************************************************************/
20 
21 #ifndef DVISVGM_VFREADER_H
22 #define DVISVGM_VFREADER_H
23 
24 #include "MessageException.h"
25 #include "StreamReader.h"
26 #include "types.h"
27 
28 
29 struct VFException : public MessageException
30 {
VFExceptionVFException31 	VFException (const std::string &msg) : MessageException(msg) {}
32 };
33 
34 
35 struct VFActions;
36 
37 
38 class VFReader : public StreamReader
39 {
40 	typedef bool (*ApproveAction)(int);
41 	public:
42 		VFReader (std::istream &is);
43 		virtual ~VFReader ();
44 		VFActions* replaceActions (VFActions *a);
45 		bool executeAll ();
46 		bool executePreambleAndFontDefs ();
47 		bool executeCharDefs ();
48 
49 	protected:
50 		int executeCommand (ApproveAction approve=0);
51 
52 		// the following methods represent the VF commands
53 		// they are called by executeCommand and should not be used directly
54 		void cmdPre ();
55 		void cmdPost ();
56 		void cmdShortChar (int pl);
57 		void cmdLongChar ();
58 		void cmdFontDef (int len);
59 
60 	private:
61 		VFActions *_actions; ///< actions to execute when reading a VF command
62 		double _designSize; ///< design size of currently read VF
63 };
64 
65 #endif
66