pprdrv.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. class TTDictionaryCallback
  44. {
  45. private:
  46. // Private copy and assignment
  47. TTDictionaryCallback& operator=(const TTStreamWriter& other);
  48. TTDictionaryCallback(const TTStreamWriter& other);
  49. public:
  50. TTDictionaryCallback() { }
  51. virtual ~TTDictionaryCallback() { }
  52. virtual void add_pair(const char* key, const char* value) = 0;
  53. };
  54. void replace_newlines_with_spaces(char* a);
  55. /*
  56. * A simple class for all ttconv exceptions.
  57. */
  58. class TTException
  59. {
  60. const char* message;
  61. TTException& operator=(const TTStreamWriter& other);
  62. TTException(const TTStreamWriter& other);
  63. public:
  64. TTException(const char* message_) : message(message_) { }
  65. const char* getMessage()
  66. {
  67. return message;
  68. }
  69. };
  70. /*
  71. ** No debug code will be included if this
  72. ** is not defined:
  73. */
  74. /* #define DEBUG 1 */
  75. /*
  76. ** Uncomment the defines for the debugging
  77. ** code you want to have included.
  78. */
  79. #ifdef DEBUG
  80. #define DEBUG_TRUETYPE /* truetype fonts, conversion to Postscript */
  81. #endif
  82. /* Do not change anything below this line. */
  83. enum font_type_enum
  84. {
  85. PS_TYPE_3 = 3,
  86. PS_TYPE_42 = 42,
  87. PS_TYPE_42_3_HYBRID = 43,
  88. PDF_TYPE_3 = -3
  89. };
  90. /* routines in pprdrv_tt.c */
  91. void insert_ttfont(const char *filename, TTStreamWriter& stream, font_type_enum target_type, std::vector<int>& glyph_ids);
  92. void get_pdf_charprocs(const char *filename, std::vector<int>& glyph_ids, TTDictionaryCallback& dict);
  93. /* end of file */