summaryrefslogtreecommitdiff
path: root/Build/source/libs/t1lib/t1trans.c
blob: 998c4bd16c56740252fe2230b44c334244fa5ea0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
/*--------------------------------------------------------------------------
  ----- File:        t1trans.c 
  ----- Author:      Rainer Menzner (Rainer.Menzner@web.de)
  ----- Date:        2003-01-04
  ----- Description: This file is part of the t1-library. It contains
                     functions for transforming fonts and setting
		     line-parameters.
  ----- Copyright:   t1lib is copyrighted (c) Rainer Menzner, 1996-2003.
                     As of version 0.5, t1lib is distributed under the
		     GNU General Public Library Lincense. The
		     conditions can be found in the files LICENSE and
		     LGPL, which should reside in the toplevel
		     directory of the distribution.  Please note that 
		     there are parts of t1lib that are subject to
		     other licenses:
		     The parseAFM-package is copyrighted by Adobe Systems
		     Inc.
		     The type1 rasterizer is copyrighted by IBM and the
		     X11-consortium.
  ----- Warranties:  Of course, there's NO WARRANTY OF ANY KIND :-)
  ----- Credits:     I want to thank IBM and the X11-consortium for making
                     their rasterizer freely available.
		     Also thanks to Piet Tutelaers for his ps2pk, from
		     which I took the rasterizer sources in a format
		     independent from X11.
                     Thanks to all people who make free software living!
--------------------------------------------------------------------------*/
  
#define T1TRANS_C


#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#if defined(_MSC_VER)
# include <io.h>
# include <sys/types.h>
# include <sys/stat.h>
#else
# include <unistd.h>
#endif
#include <stdlib.h>
#include <math.h>
#include <string.h>

#include "../type1/ffilest.h"
#include "../type1/types.h"
#include "parseAFM.h" 
#include "../type1/objects.h"
#include "../type1/spaces.h"
#include "../type1/util.h"
#include "../type1/fontfcn.h"
#include "../type1/regions.h"


#include "t1types.h"
#include "t1extern.h"
#include "t1trans.h"
#include "t1base.h"


/* T1_ExtendFont(): Extend the font referenced by FontID by the factor
   extend. This is only allowed if no size dependent data exists.
   Of course, the font must already have been loaded.
   Returns 0 for success and -1 otherwise.
   */
int T1_ExtendFont( int FontID, double extend)
{
  
  /* First, check for font residing in memory: */
  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(-1);
  }
  
  /* Second, check whether size-dependent data exists: */
  if (pFontBase->pFontArray[FontID].pFontSizeDeps != NULL){
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1); 
  }
  
  pFontBase->pFontArray[FontID].extend=extend;
  pFontBase->pFontArray[FontID].FontTransform[0] = extend;
  return(0);
}



/* T1_GetExtend(): Return the current extension factor of the
   font FontID
   Return: 0.0                    if font not loaded
           current extent         otherwise
*/
double T1_GetExtend( int FontID)
{
  /* First, check for font residing in memory: */
  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(0.0);
  }

  return( pFontBase->pFontArray[FontID].extend);
}




/* T1_SlantFont(): Slant the font referenced by FontID by the factor
   extend. This is only allowed if no size dependent data exists.
   Of course, the font must already have been loaded.
   Returns 0 for success and -1 otherwise.
   */
int T1_SlantFont( int FontID, double slant)
{
  
  /* First, check for font residing in memory: */
  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(-1);
  }
  
  /* Second, check whether size-dependent data exists: */
  if (pFontBase->pFontArray[FontID].pFontSizeDeps != NULL){
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1); 
  }
  
  pFontBase->pFontArray[FontID].slant=slant;
  pFontBase->pFontArray[FontID].FontTransform[2] = slant;
  return(0);
}



/* T1_GetSlant(): Return the current slanting factor of the
   font FontID
   Return: 0.0                    if font not loaded
           current slant          otherwise (may also be 0.0!)
*/
double T1_GetSlant( int FontID)
{
  /* First, check for font residing in memory: */
  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(0.0);
  }

  return( pFontBase->pFontArray[FontID].slant);
}



/* T1_TransformFont(): Transform the font referenced by FontID according
   to the transform matrix.  This is only allowed if no size dependent
   data exists.  Of course, the font must already have been loaded.
   Returns 0 for success and -1 otherwise.
   */
int T1_TransformFont( int FontID, T1_TMATRIX *matrix)
{
  
  /* First, check for font residing in memory: */
  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(-1);
  }
  
  /* Second, check whether size-dependent data exists: */
  if (pFontBase->pFontArray[FontID].pFontSizeDeps != NULL){
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1); 
  }
  
  pFontBase->pFontArray[FontID].FontTransform[0] = matrix->cxx;
  pFontBase->pFontArray[FontID].FontTransform[1] = matrix->cxy;
  pFontBase->pFontArray[FontID].FontTransform[2] = matrix->cyx;
  pFontBase->pFontArray[FontID].FontTransform[3] = matrix->cyy;
  return(0);
}



/* T1_GetTransform(): Return the current transformation matrix for the
   font FontID
   Return: [0.0, 0.0, 0.0, 0.0]    if font not loaded
           current tmatrix         otherwise 
*/
T1_TMATRIX T1_GetTransform( int FontID)
{
  T1_TMATRIX tmatrix={0.0, 0.0, 0.0, 0.0};
  
  /* First, check for font residing in memory: */
  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(tmatrix);
  }

  tmatrix.cxx=pFontBase->pFontArray[FontID].FontTransform[0];
  tmatrix.cxy=pFontBase->pFontArray[FontID].FontTransform[1];
  tmatrix.cyx=pFontBase->pFontArray[FontID].FontTransform[2];
  tmatrix.cyy=pFontBase->pFontArray[FontID].FontTransform[3];
  
  return( tmatrix);
}



/* Functions for setting line-parameters:
   linetypeis expected to be an OR'ed combination of
   T1_UNDERLINE, T1_OVERLINE and T1_OVERSTRIKE.
 */
int T1_SetLinePosition( int FontID, int linetype, float value)
{

  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(-1);
  }

  if (linetype & T1_UNDERLINE){
    pFontBase->pFontArray[FontID].UndrLnPos=value;
    return( 0);
  }
  if (linetype & T1_OVERLINE){
    pFontBase->pFontArray[FontID].OvrLnPos=value;
    return( 0);
  }
  if (linetype & T1_OVERSTRIKE){
    pFontBase->pFontArray[FontID].OvrStrkPos=value;
    return( 0);
  }
    
  /* The linetype was bad */
  T1_errno=T1ERR_INVALID_PARAMETER;
  return( -1);
  
}



int T1_SetLineThickness( int FontID, int linetype, float value)
{

  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(-1);
  }

  if (linetype & T1_UNDERLINE){
    pFontBase->pFontArray[FontID].UndrLnThick=value;
    return( 0);
  }
  if (linetype & T1_OVERLINE){
    pFontBase->pFontArray[FontID].OvrLnThick=value;
    return( 0);
  }
  if (linetype & T1_OVERSTRIKE){
    pFontBase->pFontArray[FontID].OvrStrkThick=value;
    return( 0);
  }
    
  /* The linetype was bad */
  T1_errno=T1ERR_INVALID_PARAMETER;
  return( -1);
  
}


float T1_GetLinePosition( int FontID, int linetype)
{

  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(0.0);
  }

  if (linetype & T1_UNDERLINE)
    return( pFontBase->pFontArray[FontID].UndrLnPos);
  if (linetype & T1_OVERLINE)
    return( pFontBase->pFontArray[FontID].OvrLnPos);
  if (linetype & T1_OVERSTRIKE)
    return( pFontBase->pFontArray[FontID].OvrStrkPos);
  
  /* The linetype was bad */
  T1_errno=T1ERR_INVALID_PARAMETER;
  return( 0.0);
  
}



float T1_GetLineThickness( int FontID, int linetype)
{

  if (T1_CheckForFontID(FontID)!=1){
    T1_errno=T1ERR_INVALID_FONTID;
    return(0.0);
  }

  if (linetype & T1_UNDERLINE)
    return( pFontBase->pFontArray[FontID].UndrLnThick);
  if (linetype & T1_OVERLINE)
    return( pFontBase->pFontArray[FontID].OvrLnThick);
  if (linetype & T1_OVERSTRIKE)
    return( pFontBase->pFontArray[FontID].OvrStrkThick);
  
  /* The linetype was bad */
  T1_errno=T1ERR_INVALID_PARAMETER;
  return( 0.0);

}


/* Functions for intuitively transforming matrices. All function operate on their
   original objects. In case NULL is specified, a unity-matrix is allocated by
   the function and then tranformed appropriately. Note that in order to concatenate
   transformation in the sense of t1lib the current transformation matrix must be
   left-multiplied by the trnasformation to be applied! */
/* Rotation:
            ( x11'  x21' )   ( cos(a)    -sin(a) )   ( x11  x21 ) 
	    (            ) = (                   ) * (          ) 
            ( x12'  x22' )   ( sin(a)     cos(a) )   ( x12  x22 ) 
*/
T1_TMATRIX *T1_RotateMatrix( T1_TMATRIX *matrix, double angle)
{
  T1_TMATRIX tmat;
  
  if (matrix==NULL){
    if ((matrix=(T1_TMATRIX *)malloc( sizeof(T1_TMATRIX)))==NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      return( NULL);
    }
    matrix->cxx=1.0;
    matrix->cyx=0.0;
    matrix->cxy=0.0;
    matrix->cyy=1.0;
  }
  memcpy( &tmat, matrix, sizeof(T1_TMATRIX));
  /* Convert angle to radians: */
  angle=angle*PI/180.0;
  /* multiply matrices */
  matrix->cxx=cos((double)angle) * tmat.cxx - sin((double)angle) * tmat.cxy;
  matrix->cyx=cos((double)angle) * tmat.cyx - sin((double)angle) * tmat.cyy;
  matrix->cxy=sin((double)angle) * tmat.cxx + cos((double)angle) * tmat.cxy;
  matrix->cyy=sin((double)angle) * tmat.cyx + cos((double)angle) * tmat.cyy;
  return( matrix);
}


/* Horizontal mirroring */
/* H-Mirror:
            ( x11'  x21' )   ( -1    0 )   ( x11  x21 )   ( -x11   -x21 ) 
	    (            ) = (         ) * (          ) = (             ) 
            ( x12'  x22' )   (  0    1 )   ( x12  x22 )   (  x12    x22 ) 
*/
T1_TMATRIX *T1_MirrorHMatrix( T1_TMATRIX *matrix)
{
  
  if (matrix==NULL){
    if ((matrix=(T1_TMATRIX *)malloc( sizeof(T1_TMATRIX)))==NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      return( NULL);
    }
    matrix->cxx=1.0;
    matrix->cyx=0.0;
    matrix->cxy=0.0;
    matrix->cyy=1.0;
  }
  matrix->cxx *=-1.0;
  matrix->cyx *=-1.0;
  return( matrix);
}


/* Vertical mirroring */
/* V-Mirror:
            ( x11'  x21' )   ( 1    0 )   ( x11  x21 )   (  x11    x21 )
	    (            ) = (        ) * (          ) = (             )
            ( x12'  x22' )   ( 0   -1 )   ( x12  x22 )   ( -x12   -x22 )
*/
T1_TMATRIX *T1_MirrorVMatrix( T1_TMATRIX *matrix)
{
  
  if (matrix==NULL){
    if ((matrix=(T1_TMATRIX *)malloc( sizeof(T1_TMATRIX)))==NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      return( NULL);
    }
    matrix->cxx=1.0;
    matrix->cyx=0.0;
    matrix->cxy=0.0;
    matrix->cyy=1.0;
  }
  matrix->cxy *=-1.0;
  matrix->cyy *=-1.0;
  return( matrix);
  
}


/* Horizontal shearing */
/* H-Shearing:
            ( x11'  x21' )   ( 1    f )   ( x11  x21 )   ( x11+f*x12   x21+f*x22 ) 
	    (            ) = (        ) * (          ) = (                       ) 
            ( x12'  x22' )   ( 0    1 )   ( x12  x22 )   ( x12         x22       ) 
*/
T1_TMATRIX *T1_ShearHMatrix( T1_TMATRIX *matrix, double shear)
{
  
  if (matrix==NULL){
    if ((matrix=(T1_TMATRIX *)malloc( sizeof(T1_TMATRIX)))==NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      return( NULL);
    }
    matrix->cxx=1.0;
    matrix->cyx=0.0;
    matrix->cxy=0.0;
    matrix->cyy=1.0;
  }
  matrix->cxx +=shear*matrix->cxy;
  matrix->cyx +=shear*matrix->cyy;
  return( matrix);
  
}


/* Vertical shearing */
/* V-Shearing:
            ( x11'  x21' )   ( 1    0 )   ( x11  x21 )   ( x11         x21       ) 
	    (            ) = (        ) * (          ) = (                       ) 
            ( x12'  x22' )   ( f    1 )   ( x12  x22 )   ( x12+f*x11   x22+f*x21 ) 
*/
T1_TMATRIX *T1_ShearVMatrix( T1_TMATRIX *matrix, double shear)
{
  
  if (matrix==NULL){
    if ((matrix=(T1_TMATRIX *)malloc( sizeof(T1_TMATRIX)))==NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      return( NULL);
    }
    matrix->cxx=1.0;
    matrix->cyx=0.0;
    matrix->cxy=0.0;
    matrix->cyy=1.0;
  }
  matrix->cxy +=shear*matrix->cxx;
  matrix->cyy +=shear*matrix->cyx;
  return( matrix);
  
}


/* Horizontal extension */
/* Horizontal-Extension:
            ( x11'  x21' )   ( f    0 )   ( x11  x21 )   ( f*x11   f*x21 ) 
	    (            ) = (        ) * (          ) = (               ) 
            ( x12'  x22' )   ( 0    1 )   ( x12  x22 )   ( x12     x22   ) 
*/
T1_TMATRIX *T1_ExtendHMatrix( T1_TMATRIX *matrix, double extent)
{
  
  if (matrix==NULL){
    if ((matrix=(T1_TMATRIX *)malloc( sizeof(T1_TMATRIX)))==NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      return( NULL);
    }
    matrix->cxx=1.0;
    matrix->cyx=0.0;
    matrix->cxy=0.0;
    matrix->cyy=1.0;
  }
  matrix->cxx *=extent;
  matrix->cyx *=extent;
  return( matrix);
  
}


/* Vertical extension */
/* Vertical-Extension:
            ( x11'  x21' )   ( 1    0 )   ( x11  x21 )   ( x11    x21   ) 
	    (            ) = (        ) * (          ) = (              ) 
            ( x12'  x22' )   ( 0    f )   ( x12  x22 )   ( f*x12  f*x22 ) 
*/
T1_TMATRIX *T1_ExtendVMatrix( T1_TMATRIX *matrix, double extent)
{
  
  if (matrix==NULL){
    if ((matrix=(T1_TMATRIX *)malloc( sizeof(T1_TMATRIX)))==NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      return( NULL);
    }
    matrix->cxx=1.0;
    matrix->cyx=0.0;
    matrix->cxy=0.0;
    matrix->cyy=1.0;
  }
  matrix->cxy *=extent;
  matrix->cyy *=extent;
  return( matrix);
  
}


/* General transformation */
/*  
    ( x11   x21 )   ( y11   y21 )   ( x11*y11+x21*y12   x11*y21+x21*y22 )
    (           ) * (           ) = (                                   )
    ( x12   x22 )   ( y12   y22 )   ( x12*y11+x22*y12   x12*y21+x22*y22 )
*/
T1_TMATRIX *T1_TransformMatrix( T1_TMATRIX *matrix,
				double cxx, double cyx,
				double cxy, double cyy)
{
  T1_TMATRIX tmat;
  
  if (matrix==NULL){
    if ((matrix=(T1_TMATRIX *)malloc( sizeof(T1_TMATRIX)))==NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      return( NULL);
    }
    matrix->cxx=1.0;
    matrix->cyx=0.0;
    matrix->cxy=0.0;
    matrix->cyy=1.0;
  }
  memcpy( &tmat, matrix, sizeof(T1_TMATRIX));
  matrix->cxx=cxx * tmat.cxx + cyx * tmat.cxy;
  matrix->cyx=cxx * tmat.cyx + cyx * tmat.cyy;
  matrix->cxy=cxy * tmat.cxx + cyy * tmat.cxy;
  matrix->cyy=cxy * tmat.cyx + cyy * tmat.cyy;
  
  return( matrix);
}



/* T1_StrokeFont(): Switch the  font referenced by FontID to stroking
   or filling. The stroked character will be cached and 
   filled characters are no longer cached and vice versa.
   This is only allowed if no size dependent data exists.
   Of course, the font must already have been loaded.
   Returns 0 for success and -1 otherwise.
   */
int T1_StrokeFont( int FontID, int dostroke)
{
  
  /* First, check for font residing in memory: */
  if ( T1_CheckForFontID( FontID) != 1 ) {
    T1_errno = T1ERR_INVALID_FONTID;
    return -1;
  }
  
  /* Second, check whether size-dependent data exists: */
  if ( pFontBase->pFontArray[FontID].pFontSizeDeps != NULL ) {
    T1_errno = T1ERR_OP_NOT_PERMITTED;
    return -1; 
  }

  if ( dostroke != 0 ) {
    pFontBase->pFontArray[FontID].info_flags |= RASTER_STROKED;
    pFontBase->pFontArray[FontID].info_flags |= CACHE_STROKED;
  }
  else {
    pFontBase->pFontArray[FontID].info_flags &= ~RASTER_STROKED;
    pFontBase->pFontArray[FontID].info_flags &= ~CACHE_STROKED;
  }
  

  return 0;
}



/* T1_SetStrokeFlag(): Return the stroke flag for font FontID.
   Return:  0                      flag has been set
           -1                      flag could not be set 
*/
int T1_SetStrokeFlag( int FontID)
{
  /* First, check for font residing in memory: */
  if ( T1_CheckForFontID(FontID) != 1 ) {
    T1_errno = T1ERR_INVALID_FONTID;
    return -1;
  }
  
  /* Set stroke flag to true */
  pFontBase->pFontArray[FontID].info_flags |= RASTER_STROKED;
  
  return 0;
  
}



/* T1_ClearStrokeFlag(): Reset the stroke flag for font FontID.
   Return:  0                      flag has been reset
           -1                      flag could not be reset 
*/
int T1_ClearStrokeFlag( int FontID)
{
  /* First, check for font residing in memory: */
  if ( T1_CheckForFontID(FontID) != 1 ) {
    T1_errno = T1ERR_INVALID_FONTID;
    return -1;
  }

  /* Reset stroke flag */
  pFontBase->pFontArray[FontID].info_flags &= ~RASTER_STROKED;
  
  return 0;
  
}



/* T1_GetStrokeMode(): Return the stroke flag for font FontID.
   Return: -1                      if font is not loaded.
	    0                      if flag is reset,
	    1                      if stroking is enabled for this font,
	    2                      if stroked characters are cached,
	    3                      if stroking is enabled and stroked
	                           characters are cached.
*/
int T1_GetStrokeMode( int FontID)
{
  int outval = 0;
  
  /* First, check for font residing in memory: */
  if ( T1_CheckForFontID( FontID) != 1 ) {
    T1_errno = T1ERR_INVALID_FONTID;
    return -1;
  }

  if ( (pFontBase->pFontArray[FontID].info_flags & CACHE_STROKED) != 0 ) 
    outval |= 0x02;
  
  if ( (pFontBase->pFontArray[FontID].info_flags & RASTER_STROKED) != 0 ) 
    outval |= 0x01;
  
  return outval;
    
}



/* T1_SetStrokeWidth(): Set the penwidth used when stroking font FontID.
   Return  -1           If width could not be set.
            0           if width has been set.
 */
int T1_SetStrokeWidth( int FontID, float strokewidth)
{
  /* First, check for font residing in memory: */
  if ( T1_CheckForFontID( FontID) != 1 ) {
    T1_errno = T1ERR_INVALID_FONTID;
    return -1;
  }

  /* Second, check whether caching stroked characters is enabled
     for this font and glyph data is already existing. In this case
     the operation is forbidden, unless the previous non-zero value
     is just restored! */
  if ( ((pFontBase->pFontArray[FontID].info_flags & CACHE_STROKED) != 0) &&
       (pFontBase->pFontArray[FontID].pFontSizeDeps != NULL) &&
       (pFontBase->pFontArray[FontID].SavedStrokeWidth != strokewidth)
       ) {
    T1_errno = T1ERR_OP_NOT_PERMITTED;
    return -1; 
  }

  /* OK, accept stroke width after ensuring a numerically meaningful
     value */
  if ( strokewidth < 0.0f ) {
    T1_errno = T1ERR_INVALID_PARAMETER;
    return -1;
  }

  pFontBase->pFontArray[FontID].StrokeWidth = strokewidth;
  
  if ( strokewidth != 0.0f )
    pFontBase->pFontArray[FontID].SavedStrokeWidth = strokewidth;
  
  return 0;
    
}



/* T1_GetStrokeWidth(): Get the penwidth used when stroking font FontID.
   If 0.0 is returned, it might also indicate that the font is not loaded.
*/
float T1_GetStrokeWidth( int FontID)
{
  /* First, check for font residing in memory: */
  if ( T1_CheckForFontID( FontID) != 1 ) {
    T1_errno = T1ERR_INVALID_FONTID;
    return 0.0f;
  }

  return pFontBase->pFontArray[FontID].StrokeWidth;  
}