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