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 a low-level method for adjusting the font of an HP-GL
2
20
or PCL device to agree with an HPGL or PCL Plotter's notion of what it
3
21
should be, prior to plotting a label. Note: The `PCL 5' output by any
64
77
double base_native_len, up_native_len, tan_slant;
66
79
/* sanity check, should be unnecessary */
67
if (_plotter->drawstate->font_type == F_HERSHEY)
80
if (_plotter->drawstate->font_type == PL_F_HERSHEY)
70
if (_plotter->drawstate->font_type == F_STICK)
83
if (_plotter->drawstate->font_type == PL_F_STICK)
71
84
/* check whether obliquing of this font is called for */
73
86
int master_font_index;
75
88
/* compute index of font in master table of fonts, in g_fontdb.c */
76
89
master_font_index =
77
(_stick_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
78
oblique = _stick_font_info[master_font_index].obliquing;
90
(_pl_g_stick_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
91
oblique = _pl_g_stick_font_info[master_font_index].obliquing;
115
128
/* emit command to select new font, if needed (see below) */
116
129
if (_plotter->hpgl_version == 2)
117
font_changed = _hpgl2_maybe_update_font (S___(_plotter));
130
font_changed = _pl_h_hpgl2_maybe_update_font (S___(_plotter));
118
131
else /* 0 or 1, i.e. generic HP-GL or HP7550A */
119
font_changed = _hpgl_maybe_update_font (S___(_plotter));
132
font_changed = _pl_h_hpgl_maybe_update_font (S___(_plotter));
121
134
/* Compute image, in the device frame, of a so-called `up vector': a
122
135
vector which in the user frame is perpendicular to the above `base'
266
274
switch (_plotter->drawstate->font_type)
270
278
/* compute index of font in master table of fonts, in g_fontdb.c */
271
279
master_font_index =
272
(_pcl_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
275
symbol_set = _pcl_font_info[master_font_index].hpgl_symbol_set;
277
spacing = _pcl_font_info[master_font_index].hpgl_spacing;
278
/* #3, #4 are pitch and height (we use defaults) */
280
posture = _pcl_font_info[master_font_index].hpgl_posture;
281
/* #6: stroke weight */
282
stroke_weight = _pcl_font_info[master_font_index].hpgl_stroke_weight;
284
typeface = _pcl_font_info[master_font_index].pcl_typeface;
285
/* ISO-Latin-1 after reencoding (if any)? */
286
font_is_iso_latin_1 = _pcl_font_info[master_font_index].iso8859_1;
289
/* compute index of font in master table of fonts, in g_fontdb.c */
291
(_ps_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
294
symbol_set = _ps_font_info[master_font_index].hpgl_symbol_set;
296
spacing = _ps_font_info[master_font_index].hpgl_spacing;
297
/* #3, #4 are pitch and height (we use defaults) */
299
posture = _ps_font_info[master_font_index].hpgl_posture;
300
/* #6: stroke weight */
301
stroke_weight = _ps_font_info[master_font_index].hpgl_stroke_weight;
303
typeface = _ps_font_info[master_font_index].pcl_typeface;
304
/* ISO-Latin-1 after reencoding (if any)? */
305
font_is_iso_latin_1 = _ps_font_info[master_font_index].iso8859_1;
308
/* compute index of font in master table of fonts, in g_fontdb.c */
310
(_stick_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
313
symbol_set = _stick_font_info[master_font_index].hpgl_symbol_set;
315
spacing = _stick_font_info[master_font_index].hpgl_spacing;
316
/* #3, #4 are pitch and height (we use defaults) */
318
posture = _stick_font_info[master_font_index].hpgl_posture;
319
/* #6: stroke weight */
320
stroke_weight = _stick_font_info[master_font_index].hpgl_stroke_weight;
322
typeface = _stick_font_info[master_font_index].pcl_typeface;
323
/* ISO-Latin-1 after reencoding (if any)? */
324
font_is_iso_latin_1 = _stick_font_info[master_font_index].iso8859_1;
280
(_pl_g_pcl_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
283
symbol_set = _pl_g_pcl_font_info[master_font_index].hpgl_symbol_set;
285
spacing = _pl_g_pcl_font_info[master_font_index].hpgl_spacing;
286
/* #3, #4 are pitch and height (we use defaults) */
288
posture = _pl_g_pcl_font_info[master_font_index].hpgl_posture;
289
/* #6: stroke weight */
290
stroke_weight = _pl_g_pcl_font_info[master_font_index].hpgl_stroke_weight;
292
typeface = _pl_g_pcl_font_info[master_font_index].pcl_typeface;
293
/* ISO-Latin-1 after reencoding (if any)? */
294
font_is_iso_latin_1 = _pl_g_pcl_font_info[master_font_index].iso8859_1;
296
case PL_F_POSTSCRIPT:
297
/* compute index of font in master table of fonts, in g_fontdb.c */
299
(_pl_g_ps_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
302
symbol_set = _pl_g_ps_font_info[master_font_index].hpgl_symbol_set;
304
spacing = _pl_g_ps_font_info[master_font_index].hpgl_spacing;
305
/* #3, #4 are pitch and height (we use defaults) */
307
posture = _pl_g_ps_font_info[master_font_index].hpgl_posture;
308
/* #6: stroke weight */
309
stroke_weight = _pl_g_ps_font_info[master_font_index].hpgl_stroke_weight;
311
typeface = _pl_g_ps_font_info[master_font_index].pcl_typeface;
312
/* ISO-Latin-1 after reencoding (if any)? */
313
font_is_iso_latin_1 = _pl_g_ps_font_info[master_font_index].iso8859_1;
316
/* compute index of font in master table of fonts, in g_fontdb.c */
318
(_pl_g_stick_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
321
symbol_set = _pl_g_stick_font_info[master_font_index].hpgl_symbol_set;
323
spacing = _pl_g_stick_font_info[master_font_index].hpgl_spacing;
324
/* #3, #4 are pitch and height (we use defaults) */
326
posture = _pl_g_stick_font_info[master_font_index].hpgl_posture;
327
/* #6: stroke weight */
328
stroke_weight = _pl_g_stick_font_info[master_font_index].hpgl_stroke_weight;
330
typeface = _pl_g_stick_font_info[master_font_index].pcl_typeface;
331
/* ISO-Latin-1 after reencoding (if any)? */
332
font_is_iso_latin_1 = _pl_g_stick_font_info[master_font_index].iso8859_1;
337
if (spacing == FIXED_SPACING)
345
if (spacing == HPGL2_FIXED_SPACING)
338
346
/* fixed-width font */
339
347
sprintf (_plotter->data->page->point,
340
348
/* #4 (nominal point size) not needed but included anyway */
341
349
"SD1,%d,2,%d,3,%.3f,4,%.3f,5,%d,6,%d,7,%d;",
342
350
symbol_set, spacing,
343
(double)NOMINAL_CHARS_PER_INCH, (double)NOMINAL_POINT_SIZE,
351
(double)HPGL2_NOMINAL_CHARS_PER_INCH, (double)HPGL2_NOMINAL_POINT_SIZE,
344
352
posture, stroke_weight, typeface);
346
354
/* variable-width font */
348
356
/* #3 (nominal chars per inch) not needed but incl'd anyway */
349
357
"SD1,%d,2,%d,3,%.3f,4,%.3f,5,%d,6,%d,7,%d;",
350
358
symbol_set, spacing,
351
(double)NOMINAL_CHARS_PER_INCH, (double)NOMINAL_POINT_SIZE,
359
(double)HPGL2_NOMINAL_CHARS_PER_INCH, (double)HPGL2_NOMINAL_POINT_SIZE,
352
360
posture, stroke_weight, typeface);
353
361
_update_buffer (_plotter->data->page);
359
367
encoding. We implement this by using two fonts: standard and
360
368
alternative. See h_text.c for the DFA that switches back and
361
369
forth (if necessary) when the label is rendered. */
362
if (_plotter->drawstate->font_type == F_PCL
370
if (_plotter->drawstate->font_type == PL_F_PCL
363
371
&& font_is_iso_latin_1
364
372
&& symbol_set == PCL_ROMAN_8)
366
if (spacing == FIXED_SPACING)
374
if (spacing == HPGL2_FIXED_SPACING)
367
375
/* fixed-width font */
368
376
sprintf (_plotter->data->page->point,
369
377
/* #4 (nominal point size) not needed but included anyway */
370
378
"AD1,%d,2,%d,3,%.3f,4,%.3f,5,%d,6,%d,7,%d;",
371
379
PCL_ISO_8859_1, spacing,
372
(double)NOMINAL_CHARS_PER_INCH, (double)NOMINAL_POINT_SIZE,
380
(double)HPGL2_NOMINAL_CHARS_PER_INCH, (double)HPGL2_NOMINAL_POINT_SIZE,
373
381
posture, stroke_weight, typeface);
375
383
/* variable-width font */
377
385
/* #3 (nominal chars per inch) not needed but included anyway */
378
386
"AD1,%d,2,%d,3,%.3f,4,%.3f,5,%d,6,%d,7,%d;",
379
387
PCL_ISO_8859_1, spacing,
380
(double)NOMINAL_CHARS_PER_INCH, (double)NOMINAL_POINT_SIZE,
388
(double)HPGL2_NOMINAL_CHARS_PER_INCH, (double)HPGL2_NOMINAL_POINT_SIZE,
381
389
posture, stroke_weight, typeface);
382
390
_update_buffer (_plotter->data->page);
399
407
pre-HP/GL-2 HP-GL devices had.) */
403
_hpgl_maybe_update_font (S___(Plotter *_plotter))
405
_hpgl_maybe_update_font (S___(_plotter))
406
S___(Plotter *_plotter;)
410
_pl_h_hpgl_maybe_update_font (S___(Plotter *_plotter))
409
412
bool font_change = false;
410
413
int new_hpgl_charset_lower, new_hpgl_charset_upper, master_font_index;
412
415
/* compute index of font in master table of fonts, in g_fontdb.c */
413
416
master_font_index =
414
(_stick_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
417
(_pl_g_stick_typeface_info[_plotter->drawstate->typeface_index].fonts)[_plotter->drawstate->font_index];
416
419
/* determine HP character set numbers (old style, pre-HP-GL/2) */
417
new_hpgl_charset_lower = _stick_font_info[master_font_index].hpgl_charset_lower;
418
new_hpgl_charset_upper = _stick_font_info[master_font_index].hpgl_charset_upper;
420
new_hpgl_charset_lower = _pl_g_stick_font_info[master_font_index].hpgl_charset_lower;
421
new_hpgl_charset_upper = _pl_g_stick_font_info[master_font_index].hpgl_charset_upper;
420
423
/* using `CS', select charset for lower half of font */
421
424
if (new_hpgl_charset_lower != _plotter->hpgl_charset_lower)