~ubuntu-branches/ubuntu/gutsy/plotutils/gutsy

« back to all changes in this revision

Viewing changes to libplot/g_font.c

  • Committer: Bazaar Package Importer
  • Author(s): Floris Bruynooghe
  • Date: 2007-05-10 19:48:54 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070510194854-mrr3lgwzpxd8hovo
Tags: 2.5-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the GNU plotutils package.  Copyright (C) 1995,
 
2
   1996, 1997, 1998, 1999, 2000, 2005, Free Software Foundation, Inc.
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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. */
 
18
 
1
19
/* This file contains the fontname, fontsize, and textangle methods, which
2
20
   are a GNU extension to libplot.  They set drawing attributes: the name
3
21
   of the font used for text subsequent drawn on the graphics device, the
22
40
#include "extern.h"
23
41
 
24
42
double
25
 
#ifdef _HAVE_PROTOS
26
43
_API_ffontname (R___(Plotter *_plotter) const char *s)
27
 
#else
28
 
_API_ffontname (R___(_plotter) s)
29
 
     S___(Plotter *_plotter;) 
30
 
     const char *s;
31
 
#endif
32
44
{
33
45
  char *font_name;
34
46
 
44
56
  if ((s == NULL) || (*s == '\0') || !strcmp(s, "(null)"))
45
57
    switch (_plotter->data->default_font_type)
46
58
      {
47
 
      case F_HERSHEY:
 
59
      case PL_F_HERSHEY:
48
60
      default:
49
 
        s = DEFAULT_HERSHEY_FONT;
50
 
        break;
51
 
      case F_POSTSCRIPT:
52
 
        s = DEFAULT_POSTSCRIPT_FONT;
53
 
        break;
54
 
      case F_PCL:
55
 
        s = DEFAULT_PCL_FONT;
56
 
        break;
57
 
      case F_STICK:
58
 
        s = DEFAULT_STICK_FONT;
 
61
        s = PL_DEFAULT_HERSHEY_FONT;
 
62
        break;
 
63
      case PL_F_POSTSCRIPT:
 
64
        s = PL_DEFAULT_POSTSCRIPT_FONT;
 
65
        break;
 
66
      case PL_F_PCL:
 
67
        s = PL_DEFAULT_PCL_FONT;
 
68
        break;
 
69
      case PL_F_STICK:
 
70
        s = PL_DEFAULT_STICK_FONT;
59
71
        break;
60
72
      }
61
73
 
62
74
  /* save new font name */
63
75
  free ((char *)_plotter->drawstate->font_name);
64
 
  font_name = (char *)_plot_xmalloc (strlen (s) + 1);
 
76
  font_name = (char *)_pl_xmalloc (strlen (s) + 1);
65
77
  strcpy (font_name, s);
66
78
  _plotter->drawstate->font_name = font_name;
67
79
 
68
80
  /* retrieve font and metrics; compute `true' font size (may differ) */
69
 
  _set_font (S___(_plotter));
 
81
  _pl_g_set_font (S___(_plotter));
70
82
 
71
83
  /* return value is size in user units */
72
84
  return _plotter->drawstate->true_font_size;
73
85
}
74
86
 
75
87
double
76
 
#ifdef _HAVE_PROTOS
77
88
_API_ffontsize (R___(Plotter *_plotter) double size)
78
 
#else
79
 
_API_ffontsize (R___(_plotter) size)
80
 
     S___(Plotter *_plotter;) 
81
 
     double size;
82
 
#endif
83
89
{
84
90
  if (!_plotter->data->open)
85
91
    {
100
106
  _plotter->drawstate->font_size = size;
101
107
 
102
108
  /* retrieve font and metrics; compute `true' font size (may differ) */
103
 
  _set_font (S___(_plotter));
 
109
  _pl_g_set_font (S___(_plotter));
104
110
  
105
111
  /* flag fontsize as having been invoked (so that fsetmatrix will no
106
112
     longer automatically adjust the font size to a reasonable value) */
111
117
}
112
118
 
113
119
double
114
 
#ifdef _HAVE_PROTOS
115
120
_API_ftextangle (R___(Plotter *_plotter) double angle)
116
 
#else
117
 
_API_ftextangle (R___(_plotter) angle)
118
 
     S___(Plotter *_plotter;)
119
 
     double angle;
120
 
#endif
121
121
{
122
122
  if (!_plotter->data->open)
123
123
    {
130
130
  _plotter->drawstate->text_rotation = angle;
131
131
  
132
132
  /* retrieve font and metrics; compute `true' font size (may differ) */
133
 
  _set_font (S___(_plotter));
 
133
  _pl_g_set_font (S___(_plotter));
134
134
  
135
135
  /* return quantized user-specified font size */
136
136
  return _plotter->drawstate->true_font_size;
144
144
   These should be replaced by a properly crafted API for querying font
145
145
   names, font metrics, etc. */
146
146
 
147
 
voidptr_t
148
 
#ifdef _HAVE_PROTOS
149
 
pl_get_hershey_font_info (S___(Plotter *_plotter))
150
 
#else
151
 
pl_get_hershey_font_info (S___(_plotter))
152
 
     S___(Plotter *_plotter;) 
153
 
#endif
154
 
{
155
 
  return (voidptr_t)_hershey_font_info;
156
 
}
157
 
 
158
 
voidptr_t
159
 
#ifdef _HAVE_PROTOS
160
 
pl_get_ps_font_info (S___(Plotter *_plotter))
161
 
#else
162
 
pl_get_ps_font_info (S___(_plotter))
163
 
     S___(Plotter *_plotter;) 
164
 
#endif
165
 
{
166
 
  return (voidptr_t)_ps_font_info;
167
 
}
168
 
 
169
 
voidptr_t
170
 
#ifdef _HAVE_PROTOS
171
 
pl_get_pcl_font_info (S___(Plotter *_plotter))
172
 
#else
173
 
pl_get_pcl_font_info (S___(_plotter))
174
 
     S___(Plotter *_plotter;) 
175
 
#endif
176
 
{
177
 
  return (voidptr_t)_pcl_font_info;
178
 
}
179
 
 
180
 
voidptr_t
181
 
#ifdef _HAVE_PROTOS
182
 
pl_get_stick_font_info (S___(Plotter *_plotter))
183
 
#else
184
 
pl_get_stick_font_info (S___(_plotter))
185
 
     S___(Plotter *_plotter;) 
186
 
#endif
187
 
{
188
 
  return (voidptr_t)_stick_font_info;
 
147
void *
 
148
_pl_get_hershey_font_info (S___(Plotter *_plotter))
 
149
{
 
150
  return (void *)_pl_g_hershey_font_info;
 
151
}
 
152
 
 
153
void *
 
154
_pl_get_ps_font_info (S___(Plotter *_plotter))
 
155
{
 
156
  return (void *)_pl_g_ps_font_info;
 
157
}
 
158
 
 
159
void *
 
160
_pl_get_pcl_font_info (S___(Plotter *_plotter))
 
161
{
 
162
  return (void *)_pl_g_pcl_font_info;
 
163
}
 
164
 
 
165
void *
 
166
_pl_get_stick_font_info (S___(Plotter *_plotter))
 
167
{
 
168
  return (void *)_pl_g_stick_font_info;
189
169
}
190
170