11
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gdevpdts.c 8022 2007-06-05 22:23:38Z giles $ */
14
/* $Id: gdevpdts.c 8265 2007-10-02 07:31:58Z ken $ */
15
15
/* Text state management for pdfwrite */
17
17
#include "memory_.h"
80
81
gs_point line_start;
81
82
gs_point out_pos; /* output position */
83
private const pdf_text_state_t ts_default = {
84
static const pdf_text_state_t ts_default = {
84
85
/* State as seen by client */
85
86
{ TEXT_STATE_VALUES_DEFAULT }, /* in */
86
87
{ 0, 0 }, /* start */
109
110
* direction, return <0 and do nothing. (This is different from
110
111
* pdf_append_chars.) Requires pts->buffer.count_chars > 0.
113
114
append_text_move(pdf_text_state_t *pts, floatp dw)
115
116
int count = pts->buffer.count_moves;
144
145
* Set *pdist to the distance (dx,dy), in the space defined by *pmat.
147
148
set_text_distance(gs_point *pdist, floatp dx, floatp dy, const gs_matrix *pmat)
149
150
int code = gs_distance_transform_inverse(dx, dy, pmat, pdist);
181
182
* Try to handle a change of text position with TJ or a space
182
183
* character. If successful, return >=0, if not, return <0.
185
186
add_text_delta_move(gx_device_pdf *pdev, const gs_matrix *pmat)
187
188
pdf_text_state_t *const pts = pdev->text->text_state;
246
247
* a Y translation, set use_leading so the next text string will be written
247
248
* with ' rather than Tj; otherwise, write a Td command.
250
251
pdf_set_text_matrix(gx_device_pdf * pdev)
252
253
pdf_text_state_t *pts = pdev->text->text_state;
653
654
pts->out_pos.y += wy;
658
/* Check a new piece of charpath text to see if its safe to combine
659
* with a previous text operation using text rendering modes.
661
bool pdf_compare_text_state_for_charpath(pdf_text_state_t *pts, gx_device_pdf *pdev,
662
gs_imager_state *pis, gs_font *font,
663
const gs_text_params_t *text)
667
gs_matrix smat, tmat;
668
struct pdf_font_resource_s *pdfont;
670
/* check to ensure the new text has the same length as the saved text */
671
if(text->size != pts->buffer.count_chars)
674
if(font->FontType == ft_user_defined)
677
/* check to ensure the new text has the same data as the saved text */
678
if(memcmp(text->data.bytes, &pts->buffer.chars, text->size))
681
/* See if the same font is in use by checking the attahced pdfont resource for
682
* the currrent font and comparing with the saved text state
684
code = pdf_attached_font_resource(pdev, font, &pdfont, NULL, NULL, NULL, NULL);
688
if(!pdfont || pdfont != pts->in.pdfont)
691
/* Check to see the new text starts at the same point as the saved text.
692
* NB! only check 2 decimal places, allow some slack in the match. This
693
* still may prove to be too tight a requirement.
695
if((int)(pts->start.x * 100) != (int)(pis->current_point.x * 100) ||
696
(int)(pts->start.y * 100) != (int)(pis->current_point.y * 100))
699
size = pdf_calculate_text_size(pis, pdfont, &font->FontMatrix, &smat, &tmat, font, pdev);
701
/* Finally, check the calculated size against the size stored in
704
if(size != pts->in.size)
710
/* Add a render mode to the rendering mode of the current text.
714
* If the modes are not compatible returns 0. NB currently only
715
* a stroke rendering mode is supported.
717
int pdf_modify_text_render_mode(pdf_text_state_t *pts, int render_mode)
719
switch (pts->in.render_mode) {
721
if (render_mode == 1) {
722
pts->in.render_mode = 2;
727
if (render_mode == 1)
731
if (render_mode == 1)
735
if (render_mode == 1) {
736
pts->in.render_mode = 1;
741
if (render_mode == 1) {
742
pts->in.render_mode = 6;
747
if (render_mode == 1)
751
if (render_mode == 1)
755
if (render_mode == 1) {
756
pts->in.render_mode = 5;