gdevpdts.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* Copyright (C) 2002 Aladdin Enterprises. All rights reserved.
  2. This software is provided AS-IS with no warranty, either express or
  3. implied.
  4. This software is distributed under license and may not be copied,
  5. modified or distributed except as expressly authorized under the terms
  6. of the license contained in the file LICENSE in this distribution.
  7. For more information about licensing, please refer to
  8. http://www.ghostscript.com/licensing/. For information on
  9. commercial licensing, go to http://www.artifex.com/licensing/ or
  10. contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. */
  13. /* $Id: gdevpdts.h,v 1.7 2003/04/08 16:31:56 igor Exp $ */
  14. /* Text state structure and API for pdfwrite */
  15. #ifndef gdevpdts_INCLUDED
  16. # define gdevpdts_INCLUDED
  17. #include "gsmatrix.h"
  18. /*
  19. * See gdevpdtt.h for a discussion of the multiple coordinate systems that
  20. * the text code must use.
  21. */
  22. /* ================ Types and structures ================ */
  23. #ifndef pdf_text_state_DEFINED
  24. # define pdf_text_state_DEFINED
  25. typedef struct pdf_text_state_s pdf_text_state_t;
  26. #endif
  27. /*
  28. * Clients pass in the text state values; the implementation decides when
  29. * (and, in the case of text positioning, how) to emit PDF commands to
  30. * set them in the output.
  31. */
  32. typedef struct pdf_text_state_values_s {
  33. float character_spacing; /* Tc */
  34. pdf_font_resource_t *pdfont; /* for Tf */
  35. double size; /* for Tf */
  36. /*
  37. * The matrix is the transformation from text space to user space, which
  38. * in pdfwrite text output is the same as device space. Thus this
  39. * matrix combines the effect of the PostScript CTM and the FontMatrix,
  40. * scaled by the inverse of the font size value.
  41. */
  42. gs_matrix matrix; /* Tm et al */
  43. int render_mode; /* Tr */
  44. float word_spacing; /* Tw */
  45. } pdf_text_state_values_t;
  46. #define TEXT_STATE_VALUES_DEFAULT\
  47. 0, /* character_spacing */\
  48. NULL, /* font */\
  49. 0, /* size */\
  50. { identity_matrix_body }, /* matrix */\
  51. 0, /* render_mode */\
  52. 0 /* word_spacing */
  53. /* ================ Procedures ================ */
  54. /* ------ Exported for gdevpdfu.c ------ */
  55. /*
  56. * Transition from stream context to text context.
  57. */
  58. int pdf_from_stream_to_text(gx_device_pdf *pdev);
  59. /*
  60. * Transition from string context to text context.
  61. */
  62. int pdf_from_string_to_text(gx_device_pdf *pdev);
  63. /*
  64. * Close the text aspect of the current contents part.
  65. */
  66. void pdf_close_text_contents(gx_device_pdf *pdev); /* gdevpdts.h */
  67. /* ------ Used only within the text code ------ */
  68. /*
  69. * Test whether a change in render_mode requires resetting the stroke
  70. * parameters.
  71. */
  72. bool pdf_render_mode_uses_stroke(const gx_device_pdf *pdev,
  73. const pdf_text_state_values_t *ptsv);
  74. /*
  75. * Read the stored client view of text state values.
  76. */
  77. void pdf_get_text_state_values(gx_device_pdf *pdev,
  78. pdf_text_state_values_t *ptsv);
  79. /*
  80. * Set wmode to text state.
  81. */
  82. void pdf_set_text_wmode(gx_device_pdf *pdev, int wmode);
  83. /*
  84. * Set the stored client view of text state values.
  85. */
  86. int pdf_set_text_state_values(gx_device_pdf *pdev,
  87. const pdf_text_state_values_t *ptsv);
  88. /*
  89. * Transform a distance from unscaled text space (text space ignoring the
  90. * scaling implied by the font size) to device space.
  91. */
  92. int pdf_text_distance_transform(floatp wx, floatp wy,
  93. const pdf_text_state_t *pts,
  94. gs_point *ppt);
  95. /*
  96. * Return the current (x,y) text position as seen by the client, in
  97. * unscaled text space.
  98. */
  99. void pdf_text_position(const gx_device_pdf *pdev, gs_point *ppt);
  100. /*
  101. * Append characters to text being accumulated, giving their advance width
  102. * in device space.
  103. */
  104. int pdf_append_chars(gx_device_pdf * pdev, const byte * str, uint size,
  105. floatp wx, floatp wy, bool nobreak);
  106. #endif /* gdevpdts_INCLUDED */