1
/* This file is part of the GNU plotutils package. Copyright (C) 1995,
2
1996, 1997, 1998, 1999, 2000, 2005, Free Software Foundation, Inc.
4
The GNU plotutils package is free software. You may redistribute it
5
and/or modify it under the terms of the GNU General Public License as
6
published by the Free Software foundation; either version 2, or (at your
7
option) any later version.
9
The GNU plotutils package is distributed in the hope that it will be
10
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
General Public License for more details.
14
You should have received a copy of the GNU General Public License along
15
with the GNU plotutils package; see the file COPYING. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
17
Boston, MA 02110-1301, USA. */
1
19
/* This file contains the Fig-driver-specific version of the low-level
2
20
paint_text_string() method, which is called to plot a label in the
3
21
current PS font, at the current fontsize and textangle. The label is
23
41
#define FIG_ALIGN_LEFT 0
24
42
#define FIG_ALIGN_CENTER 1
25
43
#define FIG_ALIGN_RIGHT 2
26
static const int _fig_horizontal_alignment_style[] =
44
static const int fig_horizontal_alignment_style[PL_NUM_HORIZ_JUST_TYPES] =
27
45
{ FIG_ALIGN_LEFT, FIG_ALIGN_CENTER, FIG_ALIGN_RIGHT };
29
47
/* This prints a single-font, single-font-size label. When this is called,
30
48
the current point is on the intended baseline of the label. */
50
/* ARGS: h_just,v_just are PL_JUST_{LEFT|CENTER|RIGHT}, PL_JUST_{TOP etc.} */
34
_f_paint_text_string (R___(Plotter *_plotter) const unsigned char *s, int h_just, int v_just)
36
_f_paint_text_string (R___(_plotter) s, h_just, v_just)
37
S___(Plotter *_plotter;)
38
const unsigned char *s;
39
int h_just; /* horizontal justification: JUST_LEFT, CENTER, or RIGHT */
40
int v_just; /* vertical justification: JUST_TOP, HALF, BASE, BOTTOM */
52
_pl_f_paint_text_string (R___(Plotter *_plotter) const unsigned char *s, int h_just, int v_just)
43
54
int len, master_font_index;
44
55
unsigned char *ptr, *t;
52
63
double angle_device;
55
if (_plotter->drawstate->font_type != F_POSTSCRIPT)
66
if (_plotter->drawstate->font_type != PL_F_POSTSCRIPT)
58
69
/* sanity check; this routine supports only baseline positioning */
59
if (v_just != JUST_BASE)
70
if (v_just != PL_JUST_BASE)
62
73
/* if empty string, nothing to do */
77
88
/* compute index of font in master table of PS fonts, in g_fontdb.h */
78
89
master_font_index =
79
(_ps_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
90
(_pl_g_ps_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
81
92
/* compute label height and width, in user units */
82
93
label_width = _plotter->get_text_width (R___(_plotter) s);
83
label_ascent = _plotter->drawstate->true_font_size * (_ps_font_info[master_font_index]).font_ascent / 1000.0;
94
label_ascent = _plotter->drawstate->true_font_size * (_pl_g_ps_font_info[master_font_index]).font_ascent / 1000.0;
85
96
/* vector along baseline of label, and an orthogonal vector which is the
86
97
other side of a rectangle containing the portion of the string above
129
140
initial_y = YD((_plotter->drawstate->pos).x, (_plotter->drawstate->pos).y);
131
142
/* evaluate fig colors lazily, i.e. only when needed */
132
_f_set_pen_color (S___(_plotter));
143
_pl_f_set_pen_color (S___(_plotter));
134
145
/* escape all backslashes in the text string, before output */
135
146
len = strlen ((char *)s);
136
ptr = (unsigned char *)_plot_xmalloc ((4 * len + 1) * sizeof(char));
147
ptr = (unsigned char *)_pl_xmalloc ((4 * len + 1) * sizeof(char));
165
176
"#TEXT\n%d %d %d %d %d %d %.3f %.3f %d %.3f %.3f %d %d %s\\001\n",
166
177
4, /* text object */
167
178
/* xfig supports 3 justification types: left, center, or right. */
168
_fig_horizontal_alignment_style[h_just],/* horizontal just. type */
179
fig_horizontal_alignment_style[h_just],/* horizontal just. type */
169
180
_plotter->drawstate->fig_fgcolor, /* pen color */
170
181
_plotter->fig_drawing_depth, /* depth */
171
182
0, /* pen style, ignored */
172
_ps_font_info[master_font_index].fig_id, /* Fig font id */
183
_pl_g_ps_font_info[master_font_index].fig_id, /* Fig font id */
173
184
(double)_plotter->drawstate->fig_font_point_size, /* point size (float) */
174
185
angle_device, /* text rotation in radians (float) */
175
186
FONT_TYPE_PS, /* Fig font type */