pprdrv.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* -*- mode: c++; c-basic-offset: 4 -*- */
  2. /*
  3. * Modified for use within matplotlib
  4. * 5 July 2007
  5. * Michael Droettboom
  6. */
  7. /*
  8. ** ~ppr/src/include/pprdrv.h
  9. ** Copyright 1995, Trinity College Computing Center.
  10. ** Written by David Chappell.
  11. **
  12. ** Permission to use, copy, modify, and distribute this software and its
  13. ** documentation for any purpose and without fee is hereby granted, provided
  14. ** that the above copyright notice appear in all copies and that both that
  15. ** copyright notice and this permission notice appear in supporting
  16. ** documentation. This software is provided "as is" without express or
  17. ** implied warranty.
  18. **
  19. ** This file last revised 5 December 1995.
  20. */
  21. #include <vector>
  22. #include <cassert>
  23. /*
  24. * Encapsulates all of the output to write to an arbitrary output
  25. * function. This both removes the hardcoding of output to go to stdout
  26. * and makes output thread-safe. Michael Droettboom [06-07-07]
  27. */
  28. class TTStreamWriter
  29. {
  30. private:
  31. // Private copy and assignment
  32. TTStreamWriter& operator=(const TTStreamWriter& other);
  33. TTStreamWriter(const TTStreamWriter& other);
  34. public:
  35. TTStreamWriter() { }
  36. virtual ~TTStreamWriter() { }
  37. virtual void write(const char*) = 0;
  38. virtual void printf(const char* format, ...);
  39. virtual void put_char(int val);
  40. virtual void puts(const char* a);
  41. virtual void putline(const char* a);
  42. };
  43. void replace_newlines_with_spaces(char* a);
  44. /*
  45. * A simple class for all ttconv exceptions.
  46. */
  47. class TTException
  48. {
  49. const char* message;
  50. TTException& operator=(const TTStreamWriter& other);
  51. TTException(const TTStreamWriter& other);
  52. public:
  53. TTException(const char* message_) : message(message_) { }
  54. const char* getMessage()
  55. {
  56. return message;
  57. }
  58. };
  59. /*
  60. ** No debug code will be included if this
  61. ** is not defined:
  62. */
  63. /* #define DEBUG 1 */
  64. /*
  65. ** Uncomment the defines for the debugging
  66. ** code you want to have included.
  67. */
  68. #ifdef DEBUG
  69. #define DEBUG_TRUETYPE /* truetype fonts, conversion to Postscript */
  70. #endif
  71. #if DEBUG_TRUETYPE
  72. #define debug(...) printf(__VA_ARGS__)
  73. #else
  74. #define debug(...)
  75. #endif
  76. /* Do not change anything below this line. */
  77. enum font_type_enum
  78. {
  79. PS_TYPE_3 = 3,
  80. PS_TYPE_42 = 42,
  81. PS_TYPE_42_3_HYBRID = 43,
  82. };
  83. /* routines in pprdrv_tt.c */
  84. void insert_ttfont(const char *filename, TTStreamWriter& stream, font_type_enum target_type, std::vector<int>& glyph_ids);
  85. /* end of file */