1 /*--------------------------------------------------------------------------
2 ----- File: xglyph.c
3 ----- Author: Rainer Menzner (Rainer.Menzner@web.de)
4 ----- Date: 2003-01-02
5 ----- Description: This file is part of the t1-library. The program xglyph
6 allows viewing of character- and string-glyphs. Diverse
7 parameters may be interactively configured.
8 ----- Copyright: t1lib is copyrighted (c) Rainer Menzner, 1996-2003.
9 As of version 0.5, t1lib is distributed under the
10 GNU General Public Library Lincense. The
11 conditions can be found in the files LICENSE and
12 LGPL, which should reside in the toplevel
13 directory of the distribution. Please note that
14 there are parts of t1lib that are subject to
15 other licenses:
16 The parseAFM-package is copyrighted by Adobe Systems
17 Inc.
18 The type1 rasterizer is copyrighted by IBM and the
19 X11-consortium.
20 ----- Warranties: Of course, there's NO WARRANTY OF ANY KIND :-)
21 ----- Credits: I want to thank IBM and the X11-consortium for making
22 their rasterizer freely available.
23 Also thanks to Piet Tutelaers for his ps2pk, from
24 which I took the rasterizer sources in a format
25 independent from X11.
26 Thanks to all people who make free software living!
27 --------------------------------------------------------------------------*/
28
29 /* definitions for activating special tests for features of t1lib
30 via commandline arguments: */
31 #define CHECK_PERFORMANCE 0x0001
32 #define CHECK_T1_COPYFONT_T1_ADDFONT 0x0002
33 #define CHECK_CONCATGLYPHS 0x0004
34 #define CHECK_CONCATOUTLINES 0x0008
35 #define CHECK_FOR_BAD_CHARS 0x0010
36 #define CHECK_DEFAULT_ENCODING 0x0020
37 #define CHECK_SMART_AA 0x0040
38 #define NO_GRID 0x0080
39 #define CHECK_AA_CACHING 0x0100
40 #define CHECK_CACHE_STROKED 0x0200
41 #define CHECK_SET_RECT 0x0400
42
43 /* #define SHOW_MANIPULATE_PATHS */
44
45 #include <X11/Intrinsic.h>
46 #include <X11/StringDefs.h>
47 #include <X11/Xaw/Label.h>
48 #include <X11/Xaw/Command.h>
49 #include <X11/Xaw/Form.h>
50 #include <X11/Xaw/Dialog.h>
51 #include <X11/Xaw/Box.h>
52 #include <X11/Xaw/Toggle.h>
53 #include <X11/Shell.h>
54 #include <X11/Xaw/AsciiText.h>
55 #include <X11/Xaw/SimpleMenu.h>
56 #include <X11/Xaw/SmeBSB.h>
57 #include <X11/Xaw/List.h>
58
59
60 #include <stdio.h>
61 #include <math.h>
62 #include <stdlib.h>
63 #include <sys/types.h>
64 #include <sys/uio.h>
65 #include <unistd.h>
66 #include <sys/time.h>
67
68
69 /* The following stuff is necessary for compiling and running
70 xglyph on VMS. Submitted by John Hasstedt (John.Hasstedt@sunysb.edu),
71 who did the VMS-port of t1lib. */
72 #if defined(__VMS) && __CRTL_VER < 70000000
73 # define putenv(p) \
74 printf("You must define T1LIB_CONFIG before running this program\n"); \
75 exit;
76 # define gettimeofday(p1,p2)
77 #endif
78
79
80 /* Note: We include t1lib.h and t1libx.h from lib/t1lib. That way the
81 objectfile does only need to be rebuild when the header itself
82 changes and not each time the library has been recompiled */
83 #include "../lib/t1lib/t1lib.h"
84 #include "../lib/t1lib/t1libx.h"
85
86 #ifndef PI
87 #define PI 3.1415927
88 #endif
89
90 /* utility functions */
91 BBox ComputeRotBBox( BBox, float);
92 long time_diff(struct timeval *, struct timeval *);
93
94 /* fallback-function */
95 void exitprog( Widget, XtPointer, XtPointer);
96 void togglekerning( Widget, XtPointer, XtPointer);
97 void toggleligatur( Widget, XtPointer, XtPointer);
98 void toggler2l( Widget, XtPointer, XtPointer);
99 void toggleunderline( Widget, XtPointer, XtPointer);
100 void toggleoverline( Widget, XtPointer, XtPointer);
101 void toggleoverstrike( Widget, XtPointer, XtPointer);
102 void showchar( Widget , XtPointer , XtPointer );
103 void showstring( Widget , XtPointer , XtPointer );
104 void aashowchar( Widget , XtPointer , XtPointer );
105 void aashowstring( Widget , XtPointer , XtPointer );
106 void showcharX( Widget , XtPointer , XtPointer );
107 void showstringX( Widget , XtPointer , XtPointer );
108 void aashowcharX( Widget , XtPointer , XtPointer );
109 void aashowstringX( Widget , XtPointer , XtPointer );
110 void showabout( Widget , XtPointer , XtPointer );
111 void toggleopacity( Widget, XtPointer, XtPointer);
112 void setcolor( Widget, XtPointer, XtPointer);
113 void fonttable( Widget, XtPointer, XtPointer);
114 void toggleaalevel( Widget, XtPointer, XtPointer);
115 int ComputeAAColorsX( unsigned long fg, unsigned long bg, int nolevels);
116 void printusage( int max);
117 int CheckTransform( void);
118
119
120
121
122 #define DOUBLEMARGIN 10
123 #define SIMPLEMARGIN 5
124 #define XOUTPUT_HALFVSIZE 200
125 #define XOUTPUT_HALFHSIZE 300
126 #define XGLYPH_PAD 16
127 #define T1LIBENCFILE "IsoLatin1.enc"
128 #define MAXENCODINGS 10
129 #define TESTFONTFILE "eufm10.pfb"
130 #define SHOWGRID
131 #define CROSS_SIZE 6
132
133 #define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
134 #define DIALOGWIDTH 170
135 #define DIALOGHEIGHT 20
136 #define ACTIONBUTTONHEIGHT 20
137 #define APPLICATIONHEIGHT 690
138 #define EDITABLE_COLOR "red"
139 #define MESSAGEBOXHEIGHT 180
140 #define AAMAXPLANES 17
141 #define GRAY0 WhitePixel(display, screen_number)
142 #define GRAY1 gray1.pixel
143 #define GRAY2 gray2.pixel
144 #define GRAY3 gray3.pixel
145 #define GRAY4 BlackPixel(display, screen_number)
146
147 #define min(a,b) (a < b ? a : b)
148 #define max(a,b) (a > b ? a : b)
149
150
151 #define DEFAULT_SIZE "100.0"
152 #define DEFAULT_CHAR "65"
153
154 /* Global variables for rasterizer parameters */
155 float Size=400.0, Slant=0.0, Extent=1.0, Angle=0.0;
156 int Modflag=0;
157 int FontID=0, Caching=1, DeviceResolution=72;
158 int StrokeWidth;
159 int nofonts;
160
161 long Space=0;
162 int Opacity=0;
163 int aalevel;
164 char TestString[1024]="Test";
165 int TestChar=70;
166 char EncodingFile[128]="";
167 char LastEncodingFile[128]="";
168 struct
169 {
170 char *encfilename;
171 char **encoding;
172 }
173 encstruct[MAXENCODINGS];
174
175 int *last_resolution;
176 float *lastExtent;
177 float *lastSlant;
178 int LigDetect=0;
179 unsigned long fg, bg, outbg;
180 Pixmap tmp_pixmap=0;
181 Pixmap white_pixmap=0;
182
183
184 Pixmap perf_pixmap;
185 Pixmap pixmap;
186 XImage *ximage;
187 XColor edit_color, gray0, gray1, gray2, gray3, gray4;
188 XColor white, black, gray, red, green, blue, pink4, yellow,
189 gridcolor1, gridcolor2,wozu;
190 XColor aacolors[AAMAXPLANES];
191 unsigned long aapixels[AAMAXPLANES];
192
193 XGCValues xgcvalues;
194
195
196 unsigned short dummy;
197 char input;
198 int overallwidth;
199 char commandline[256];
200 GLYPH *glyph;
201 GLYPH *glyph1, *glyph2;
202 char **Encoding=NULL;
203 unsigned int height, width;
204 char statusstring[1024];
205 T1_TMATRIX matrix;
206 T1_TMATRIX *matrixP;
207 static char msg_buf[256];
208
209
210 /* How t1lib pads lines: */
211 int t1_pad=0;
212
213 /* When to swap bytes in aa-pixels? */
214 int xglyph_byte_order;
215
216 /* The following is for time measurements: */
217 struct timeval time_start, time_stop;
218 struct timeval *time_ptr_start, *time_ptr_stop;
219 void *void_ptr;
220
221
222
223 /* Global X(t)-stuff */
224 Display *display;
225 Screen *screen;
226 int screennumber;
227 int depth;
228 Widget TopLevel;
229 Widget OutputWindow;
230 Widget Output;
231 Widget OutputWindow2;
232 Widget Output2;
233 Widget dialogfontid;
234 Widget dialogsize;
235 Widget dialogslant;
236 Widget dialogextent;
237 Widget dialogangle;
238 Widget dialogteststring;
239 Widget dialogtestcharacter;
240 Widget dialogdevres;
241 Widget dialogstroke;
242 Widget dialogencfile;
243 Widget dialogspace;
244 Widget dialogtmatrix;
245 Widget labelstatus;
246 Widget fgcolorbutton;
247 Widget bgcolorbutton;
248
249
250 /* color setting widgets */
251 Widget fgwhitebutton;
252 Widget fgblackbutton;
253 Widget fggraybutton;
254 Widget fgredbutton;
255 Widget fggreenbutton;
256 Widget fgbluebutton;
257 Widget bgwhitebutton;
258 Widget bgblackbutton;
259 Widget bggraybutton;
260 Widget bgredbutton;
261 Widget bggreenbutton;
262 Widget bgbluebutton;
263 Widget fglabel;
264 Widget bglabel;
265 Widget colorbox;
266 Widget fgstatus;
267 Widget bgstatus;
268
269
270 Widget optionsbox;
271
272
273 /* Commandline handling */
274 char *xglyphoptions[]={"--help", /* 0 */
275 "--Help", /* 1 */
276 "--noGrid", /* 2 */
277 "--setPad", /* 3 */
278 "--logError", /* 4 */
279 "--logWarning", /* 5 */
280 "--logStatistic", /* 6 */
281 "--logDebug", /* 7 */
282 "--ignoreForceBold", /* 8 */
283 "--ignoreFamilyAlignment", /* 9 */
284 "--ignoreHinting", /* 10 */
285 "--ignoreAFM", /* 11 */
286 "--debugLine", /* 12 */
287 "--debugRegion", /* 13 */
288 "--debugPath", /* 14 */
289 "--debugFont", /* 15 */
290 "--debugHint", /* 16 */
291 "--checkPerformance", /* 17 */
292 "--checkCopyFont", /* 18 */
293 "--checkConcatGlyphs", /* 19 */
294 "--checkConcatOutlines", /* 20 */
295 "--checkBadCharHandling", /* 21 */
296 "--checkDefaultEncoding", /* 22 */
297 "--checkSmartAntialiasing", /* 23 */
298 "--checkAACaching", /* 24 */
299 "--checkSetRect", /* 25 */
300 "--cacheStrokedGlyphs", /* 26 */
301 NULL};
302 int extraflags=0;
303
304 /* #define SHOW_MANIPULATE_PATHS */
305 #ifdef SHOW_MANIPULATE_PATHS
mymanipulate(long * x,long * y,int type)306 void mymanipulate( long *x, long *y, int type)
307 {
308 double corr;
309 double dx, dy;
310
311 dx=(double)*x;
312 dy=(double)*y;
313
314 /* we have to scale down because we deal with fractional pels */
315 /*
316 corr=0.000000000000004*dx*dx;
317 dy *=1.0+corr;
318 */
319 /*
320 #define PERIOD 500.0
321 corr=65536.0*0.5*sin(2*PI/PERIOD/65536.0*dx);
322 dy +=corr*30.0;
323 */
324 *y=(long)dy;
325
326 }
327 #endif
328
329
330
main(int argc,char ** argv)331 int main( int argc, char **argv)
332 {
333
334
335 XtAppContext TopLevelApp;
336 Arg args[10];
337
338
339 int i, j, numopts=0;
340
341 Widget kerningbutton;
342 Widget ligaturbutton;
343 Widget r2lbutton;
344 Widget showcharbutton;
345 Widget showstringbutton;
346 Widget aashowcharbutton;
347 Widget aashowstringbutton;
348 Widget showcharbuttonX;
349 Widget showstringbuttonX;
350 Widget aashowcharbuttonX;
351 Widget aashowstringbuttonX;
352 Widget stringlabel;
353 Widget aboutbutton;
354 Widget opacitybutton;
355 Widget underlinebutton;
356 Widget overstrikebutton;
357 Widget overlinebutton;
358 Widget transbox;
359 Widget fonttablebutton;
360 Widget aalevelbutton;
361
362
363 Widget exitbutton;
364
365 Widget box;
366
367
368 int rasterflags=0, initflags=0, optfound;
369 int loglevel=0;
370
371 i=0;
372 j=0;
373
374 while (xglyphoptions[i++]!=NULL)
375 numopts++;
376
377 for ( i=1; i<argc; i++){
378 if (strncmp(&(argv[i][0]), "--", 2)==0){
379 j=0;
380 optfound=0;
381 while ( (j<numopts) && optfound==0){
382 if (strcmp(argv[i],xglyphoptions[j])==0){
383 switch (j){
384 case 0:
385 printusage( 8); /* Show 8 options */
386 exit(0);
387 case 1:
388 printusage( 0); /* Show all options */
389 exit(0);
390 case 2:
391 extraflags |= NO_GRID;
392 optfound=1;
393 break;
394 case 3:
395 /* We have to examine one further argument */
396 i++;
397 if (strcmp( argv[i], "8")==0)
398 t1_pad=8;
399 else if (strcmp( argv[i], "16")==0)
400 t1_pad=16;
401 else if (strcmp( argv[i], "32")==0)
402 t1_pad=32;
403 else{
404 fprintf( stderr, "xglyph: Invalid padding specification %s\n",
405 argv[i]);
406 exit(-1);
407 }
408 optfound=1;
409 break;
410 case 4:
411 loglevel = T1LOG_ERROR;
412 loglevel |= (0x01 << 8);
413 optfound=1;
414 break;
415 case 5:
416 loglevel = T1LOG_WARNING;
417 loglevel |= (0x01 << 8);
418 optfound=1;
419 break;
420 case 6:
421 loglevel = T1LOG_STATISTIC;
422 loglevel |= (0x01 << 8);
423 optfound=1;
424 break;
425 case 7:
426 loglevel = T1LOG_DEBUG;
427 loglevel |= (0x01 << 8);
428 optfound=1;
429 break;
430 case 8:
431 rasterflags |= T1_IGNORE_FORCEBOLD;
432 optfound=1;
433 break;
434 case 9:
435 rasterflags |= T1_IGNORE_FAMILYALIGNMENT;
436 optfound=1;
437 break;
438 case 10:
439 rasterflags |= T1_IGNORE_HINTING;
440 optfound=1;
441 break;
442 case 11:
443 initflags |= T1_NO_AFM;
444 optfound=1;
445 break;
446 case 12:
447 rasterflags |= T1_DEBUG_LINE;
448 optfound=1;
449 break;
450 case 13:
451 rasterflags |= T1_DEBUG_REGION;
452 optfound=1;
453 break;
454 case 14:
455 rasterflags |= T1_DEBUG_PATH;
456 optfound=1;
457 break;
458 case 15:
459 rasterflags |= T1_DEBUG_FONT;
460 optfound=1;
461 break;
462 case 16:
463 rasterflags |= T1_DEBUG_HINT;
464 optfound=1;
465 break;
466 case 17:
467 extraflags |= CHECK_PERFORMANCE;
468 optfound=1;
469 break;
470 case 18:
471 extraflags |= CHECK_T1_COPYFONT_T1_ADDFONT;
472 optfound=1;
473 break;
474 case 19:
475 extraflags |= CHECK_CONCATGLYPHS;
476 optfound=1;
477 break;
478 case 20:
479 extraflags |= CHECK_CONCATOUTLINES;
480 optfound=1;
481 break;
482 case 21:
483 extraflags |= CHECK_FOR_BAD_CHARS;
484 optfound=1;
485 break;
486 case 22:
487 extraflags |= CHECK_DEFAULT_ENCODING;
488 optfound=1;
489 break;
490 case 23:
491 extraflags |= CHECK_SMART_AA;
492 optfound=1;
493 break;
494 case 24:
495 extraflags |= CHECK_AA_CACHING;
496 optfound=1;
497 break;
498 case 25:
499 extraflags |= CHECK_SET_RECT;
500 optfound = 1;
501 break;
502 case 26:
503 extraflags |= CHECK_CACHE_STROKED;
504 optfound = 1;
505 break;
506 default: /* should not be reached */
507 break;
508 }
509 } /* end of "if (strcmp.." */
510 j++;
511 }
512 if (optfound==0){
513 fprintf( stderr, "xglyph: Unknown option %s\n",
514 argv[i]);
515 exit(-1);
516 }
517 }
518 else /* string doesn't start with "--" -> no option */
519 break;
520 }
521
522
523 /* Assign address of time parameter */
524 time_ptr_start=&time_start;
525 time_ptr_stop=&time_stop;
526
527 /* Check for environment entry. If not set, set it to current
528 directory so that configuration file is found there */
529 if (getenv("T1LIB_CONFIG")==NULL){
530 putenv( "T1LIB_CONFIG=./t1lib.config");
531 }
532
533
534 /* Set log-level: */
535 T1_SetLogLevel( loglevel & (~(0x01<<8)));
536
537
538 /* Get padding value if not set from commandline. For 32 bit architectures
539 like Intel, 16 might be the best padding default value: */
540 if (t1_pad==0)
541 t1_pad=16;
542 if (T1_SetBitmapPad( t1_pad)!=0){
543 t1_pad=T1_GetBitmapPad();
544 }
545
546
547 /* Initialize t1-library. If xglyph is called with arguments
548 that are no options, we assume that the arguments are font
549 files and ignore the fontdata base file. At this point the value of
550 "i" is the number of commandline arg that is supposed to contain a
551 fontfile name (or it is argc, if no files where specified).
552
553 Note further that "loglevel" contains (1) info whether to create a log
554 file in the first bit of the higher byte of the lower word and
555 (2) info which loglevel to set. (3) It further may contain more
556 initialization flags.
557 */
558 if ((extraflags & CHECK_AA_CACHING)){
559 loglevel |= (T1_AA_CACHING<<8);
560 }
561
562 if (i==argc){
563 if (T1_InitLib( (loglevel>>8) | initflags )==NULL){
564 fprintf(stderr,"Initialization of t1lib failed (T1_errno=%d)!\n",
565 T1_errno);
566 return(-1);
567 }
568 }
569 else{ /* There are still arguments which we interprete as fontfile names */
570 if (T1_InitLib( (loglevel>>8) | initflags | IGNORE_FONTDATABASE )==NULL){
571 fprintf(stderr,"Initialization of t1lib failed (T1_errno=%d)!\n",
572 T1_errno);
573 return(-1);
574 }
575 /* We start adding fonts as the i-th commandline arguments */
576 for ( j=i; j<argc; j++){
577 T1_AddFont( argv[j]);
578 }
579 }
580
581 /* We return if no fonts could be installed */
582 if ((j=T1_GetNoFonts())<=0){
583 fprintf(stderr,"xglyph: No fonts in database (T1_errno=%d)!\n", T1_errno);
584 return(-1);
585 }
586
587 /* Set the raster parameters */
588 T1_SetRasterFlags( rasterflags);
589
590
591 /* Load alternate encoding and associate it with filename: */
592 encstruct[0].encoding=T1_LoadEncoding(T1LIBENCFILE);
593 encstruct[0].encfilename=(char *)malloc(strlen(T1LIBENCFILE)+1);
594 strcpy( encstruct[0].encfilename, T1LIBENCFILE);
595 for ( i=1; i<MAXENCODINGS; i++){
596 encstruct[i].encoding=NULL;
597 encstruct[i].encfilename=NULL;
598 }
599
600
601 /* If requested, set a default encoding vector */
602 if (extraflags & CHECK_DEFAULT_ENCODING){
603 T1_SetDefaultEncoding( encstruct[0].encoding);
604 }
605
606
607 if( extraflags & CHECK_T1_COPYFONT_T1_ADDFONT){
608 {
609 int k;
610
611 /* The following code is to test the T1_CopyFont()-function. It
612 generates logical fonts with IDs twice the ID of the original
613 font which are then slanted by 0.3. */
614 nofonts=T1_GetNoFonts();
615 printf("Initial number of fonts: %d\n", nofonts);
616
617 for (i=0; i< nofonts; i++){
618 T1_LoadFont(i);
619 if ((k=T1_CopyFont(i))<0){
620 fprintf(stderr,"T1_CopyFont() unsuccessful (k=%d), for FontID=%d\n", k, i);
621 }else{
622 T1_SlantFont(k,0.3);
623 fprintf(stderr,"Slanted Font under FontID %d generated\n", k);
624 }
625 }
626 fprintf( stderr, "T1_AddFont() returned newID %d for fontfile %s!\n",
627 T1_AddFont( TESTFONTFILE), TESTFONTFILE);
628
629 nofonts=T1_GetNoFonts();
630 printf("Final number of fonts: %d\n", nofonts);
631 }
632 }
633
634 /* Setup arrays for the last... values */
635 nofonts=T1_GetNoFonts();
636 if ( (last_resolution=(int *) malloc ( nofonts * sizeof(int)))==NULL){
637 fprintf( stderr, "xglyph: memory allocation error\n");
638 exit(1);
639 }
640 else
641 for (i=0; i<nofonts; i++)
642 last_resolution[i]=72;
643 if ( (lastSlant=(float *) malloc ( nofonts * sizeof(float)))==NULL){
644 fprintf( stderr, "xglyph: memory allocation error\n");
645 exit(1);
646 }
647 else
648 for (i=0; i<nofonts; i++)
649 lastSlant[i]=0.0;
650 if ( (lastExtent=(float *) malloc ( nofonts * sizeof(float)))==NULL){
651 fprintf( stderr, "xglyph: memory allocation error\n");
652 exit(1);
653 }
654 else
655 for (i=0; i<nofonts; i++)
656 lastExtent[i]=1.0;
657
658 if (extraflags & CHECK_SMART_AA)
659 T1_AASetSmartMode( T1_YES);
660
661 /* If checking caching of stroked characters is enabled via command line,
662 we call T1_StrokeFont() on each font in the database. This is valid
663 here since we do not already have glyph data. */
664 if ( extraflags & CHECK_CACHE_STROKED ) {
665 for ( i=0; i<nofonts; i++) {
666 T1_LoadFont(i);
667 T1_StrokeFont( i, 1);
668 }
669 }
670
671 /* Initialize application */
672 TopLevel = XtAppInitialize(&TopLevelApp, (String) "Xglyph", (XrmOptionDescList) NULL,
673 (Cardinal) 0,
674 &argc,
675 argv,
676 (String *) NULL,
677 (ArgList) NULL,
678 (Cardinal) 0);
679 i=0;
680 XtSetArg(args[i], XtNheight, APPLICATIONHEIGHT); i++;
681 XtSetValues(TopLevel,args,i);
682
683 /* Create window for graphics output */
684 Output = XtCreatePopupShell( "Xglyph-Output", topLevelShellWidgetClass,
685 TopLevel, NULL,0);
686
687 OutputWindow = XtCreateManagedWidget("xglyph-Output",labelWidgetClass, Output,
688 NULL, 0);
689
690
691 /* Get display/screen pointer and screennumber */
692 display = XtDisplay(OutputWindow);
693 screen = XtScreen(OutputWindow);
694 screennumber = DefaultScreen(display);
695 depth = DefaultDepth(display,screennumber);
696
697
698 /* In case client and server have different endian architecture,
699 we have to care for the 16 and 32 bit aa-pixels to have the
700 correct byte order */
701 if (T1_CheckEndian()==0)
702 xglyph_byte_order=0;
703 else
704 xglyph_byte_order=1;
705
706
707 if( extraflags & CHECK_PERFORMANCE){
708 perf_pixmap=0;
709 /* The following is for testing only */
710 Output2 = XtCreatePopupShell( "Xglyph-Output2", topLevelShellWidgetClass,
711 TopLevel, NULL,0);
712
713 OutputWindow2 = XtCreateManagedWidget("xglyph-Output2",labelWidgetClass, Output2,
714 NULL, 0);
715 i=0;
716 XtSetArg( args[i], XtNwidth, 800 ); i++;
717 XtSetArg( args[i], XtNheight, 600 ); i++;
718 XtSetValues(OutputWindow2,args,i);
719 }
720
721
722 /* Get colors and assign pixel values: */
723 XAllocNamedColor(display, DefaultColormap(display,screennumber), EDITABLE_COLOR,
724 &edit_color, &wozu);
725 XAllocNamedColor(display, DefaultColormap(display,screennumber), "green",
726 &green, &wozu);
727 XAllocNamedColor(display, DefaultColormap(display,screennumber), "blue",
728 &blue, &wozu);
729 XAllocNamedColor(display, DefaultColormap(display,screennumber), "black",
730 &gray4, &wozu);
731 XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray25",
732 &gray3, &wozu);
733 XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray50",
734 &gray2, &wozu);
735 XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray75",
736 &gray1, &wozu);
737 XAllocNamedColor(display, DefaultColormap(display,screennumber), "white",
738 &gray0, &wozu);
739 XAllocNamedColor(display, DefaultColormap(display,screennumber), "yellow",
740 &yellow, &wozu);
741 XAllocNamedColor(display, DefaultColormap(display,screennumber), "pink4",
742 &pink4, &wozu);
743 XAllocNamedColor(display, DefaultColormap(display,screennumber), "cyan",
744 &gridcolor1, &wozu);
745 XAllocNamedColor(display, DefaultColormap(display,screennumber), "magenta",
746 &gridcolor2, &wozu);
747 white=gray0;
748 black=gray4;
749 gray=gray1;
750 red=edit_color;
751 /* Fill the aacolors and aapixels-array */
752 ComputeAAColorsX( black.pixel, white.pixel, AAMAXPLANES);
753
754
755 /* Set default colors for X11 rastering functions */
756 fg=black.pixel;
757 bg=white.pixel;
758
759
760 T1_AASetBitsPerPixel(DefaultDepth(display,screennumber));
761 /* T1_LogicalPositionX( 0); */
762
763
764 /* The box-widget for all the buttons */
765 box=XtCreateManagedWidget("xglyph", boxWidgetClass, TopLevel, NULL, 0);
766
767 i=0;
768 XtSetArg(args[i], XtNheight,400); i++;
769 XtSetValues(box,args,i);
770
771
772 /* A dialogbox for the fontID-specification */
773 dialogfontid=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
774 NULL, 0);
775 i=0;
776 XtSetArg(args[i], XtNlabel, "FontID:"); i++;
777 XtSetArg(args[i], XtNvalue, "0"); i++;
778 XtSetValues(dialogfontid,args,i);
779 i=0;
780 XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
781 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
782 XtSetArg(args[i], XtNresize, FALSE); i++;
783 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
784 XtSetValues(XtNameToWidget(dialogfontid,"value"),args,i);
785
786
787
788 /* A dialogbox for the font-Size */
789 dialogsize=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
790 NULL, 0);
791 i=0;
792 XtSetArg(args[i], XtNlabel, "Font-Size [bp]:"); i++;
793 XtSetArg(args[i], XtNvalue, DEFAULT_SIZE); i++;
794 XtSetValues(dialogsize,args,i);
795 i=0;
796 XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
797 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
798 XtSetArg(args[i], XtNresize, FALSE); i++;
799 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
800 XtSetValues(XtNameToWidget(dialogsize,"value"),args,i);
801
802
803
804 /* A dialogbox for the font slant specification */
805 dialogslant=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
806 NULL, 0);
807 i=0;
808 XtSetArg(args[i], XtNlabel, "Slant:"); i++;
809 XtSetArg(args[i], XtNvalue, "0.0"); i++;
810 XtSetValues(dialogslant,args,i);
811 i=0;
812 XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++;
813 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
814 XtSetArg(args[i], XtNresize, FALSE); i++;
815 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
816 XtSetValues(XtNameToWidget(dialogslant,"value"),args,i);
817
818
819
820 /* A dialogbox for the font-extension */
821 dialogextent=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
822 NULL, 0);
823 i=0;
824 XtSetArg(args[i], XtNlabel, "Extension:"); i++;
825 XtSetArg(args[i], XtNvalue, "1.0"); i++;
826 XtSetValues(dialogextent,args,i);
827 i=0;
828 XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++;
829 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
830 XtSetArg(args[i], XtNresize, FALSE); i++;
831 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
832 XtSetValues(XtNameToWidget(dialogextent,"value"),args,i);
833
834
835
836 /* transformation matrix dialog widget */
837 dialogtmatrix = XtCreateManagedWidget( "dialog1", dialogWidgetClass, box,
838 NULL, 0);
839 i=0;
840 XtSetArg(args[i], XtNlabel, "Transformation-Matrix:"); i++;
841 XtSetArg(args[i], XtNvalue, "1.0, 0.0, 0.0, 1.0"); i++;
842 XtSetValues(dialogtmatrix,args,i);
843 i=0;
844 XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
845 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
846 XtSetArg(args[i], XtNresize, FALSE); i++;
847 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
848 XtSetValues(XtNameToWidget(dialogtmatrix,"value"),args,i);
849
850
851
852 /* A dialogbox for the device resolution */
853 dialogdevres=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
854 NULL, 0);
855 i=0;
856 XtSetArg(args[i], XtNlabel, "Res [DPI]"); i++;
857 XtSetArg(args[i], XtNvalue, "72"); i++;
858 XtSetValues(dialogdevres,args,i);
859 i=0;
860 XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++;
861 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
862 XtSetArg(args[i], XtNresize, FALSE); i++;
863 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
864 XtSetValues(XtNameToWidget(dialogdevres,"value"),args,i);
865
866
867
868 /* A dialogbox for the strokewidth */
869 dialogstroke=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
870 NULL, 0);
871 i=0;
872 XtSetArg(args[i], XtNlabel, "S-Width"); i++;
873 if ( extraflags & CHECK_CACHE_STROKED ) {
874 XtSetArg(args[i], XtNvalue, "10");
875 i++;
876 }
877 else {
878 XtSetArg(args[i], XtNvalue, "0");
879 i++;
880 }
881 XtSetValues(dialogstroke,args,i);
882 i=0;
883 XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++;
884 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
885 XtSetArg(args[i], XtNresize, FALSE); i++;
886 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
887 XtSetValues(XtNameToWidget(dialogstroke,"value"),args,i);
888
889
890
891 /* A dialogbox for the encoding filename */
892 dialogencfile=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
893 NULL, 0);
894 i=0;
895 XtSetArg(args[i], XtNlabel, "Encoding-File:"); i++;
896 XtSetArg(args[i], XtNvalue, ""); i++;
897 XtSetValues(dialogencfile,args,i);
898 i=0;
899 XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
900 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
901 XtSetArg(args[i], XtNresize, FALSE); i++;
902 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
903 XtSetValues(XtNameToWidget(dialogencfile,"value"),args,i);
904
905
906
907 /* A dialogbox for the angle */
908 dialogangle=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
909 NULL, 0);
910 i=0;
911 XtSetArg(args[i], XtNlabel, "Angle [deg]:"); i++;
912 XtSetArg(args[i], XtNvalue, "0.0"); i++;
913 XtSetValues(dialogangle,args,i);
914 i=0;
915 XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
916 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
917 XtSetArg(args[i], XtNresize, FALSE); i++;
918 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
919 XtSetValues(XtNameToWidget(dialogangle,"value"),args,i);
920
921
922
923 /* A dialogbox for the space-offset in strings */
924 dialogspace=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
925 NULL, 0);
926 i=0;
927 XtSetArg(args[i], XtNlabel, "Space-Off [1/1000 bp]:"); i++;
928 XtSetArg(args[i], XtNvalue, "0"); i++;
929 XtSetValues(dialogspace,args,i);
930 i=0;
931 XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
932 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
933 XtSetArg(args[i], XtNresize, FALSE); i++;
934 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
935 XtSetValues(XtNameToWidget(dialogspace,"value"),args,i);
936
937
938
939 /* A dialogbox for the character */
940 dialogtestcharacter=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
941 NULL, 0);
942 i=0;
943 XtSetArg(args[i], XtNlabel, "Character (decimal):"); i++;
944 XtSetArg(args[i], XtNvalue, DEFAULT_CHAR); i++;
945 XtSetValues(dialogtestcharacter,args,i);
946 i=0;
947 XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
948 XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
949 XtSetArg(args[i], XtNresize, FALSE); i++;
950 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
951 XtSetValues(XtNameToWidget(dialogtestcharacter,"value"),args,i);
952
953
954
955 /* The box for color selecting buttons for the
956 X11-rastering functions */
957 optionsbox=XtCreateManagedWidget("box", boxWidgetClass, box, NULL, 0);
958
959 i=0;
960 XtSetArg(args[i], XtNheight, DIALOGHEIGHT); i++;
961 XtSetArg(args[i], XtNwidth, DIALOGWIDTH + 30); i++;
962 XtSetValues(optionsbox,args,i);
963 /* The toggle widget for kerning (un-)setting */
964 kerningbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
965 NULL, 0);
966 i=0;
967 XtSetArg( args[i], XtNwidth, 55 ); i++;
968 XtSetArg( args[i], XtNheight, 20 ); i++;
969 XtSetArg( args[i], XtNlabel, "Kerning" ); i++;
970 XtSetValues(kerningbutton,args,i);
971 XtAddCallback( kerningbutton, XtNcallback,
972 (XtCallbackProc) togglekerning, (XtPointer) 0 );
973
974
975 /* The toggle widget for ligatur-detection (un-)setting */
976 ligaturbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
977 NULL, 0);
978 i=0;
979 XtSetArg( args[i], XtNwidth, 55 ); i++;
980 XtSetArg( args[i], XtNheight, 20 ); i++;
981 XtSetArg( args[i], XtNlabel, "Ligature" ); i++;
982 XtSetValues(ligaturbutton,args,i);
983 XtAddCallback( ligaturbutton, XtNcallback,
984 (XtCallbackProc) toggleligatur, (XtPointer) 0 );
985
986
987 /* The toggle widget for the typesetting direction switch message */
988 r2lbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
989 NULL, 0);
990 i=0;
991 XtSetArg( args[i], XtNwidth, 55 ); i++;
992 XtSetArg( args[i], XtNheight, 20 ); i++;
993 XtSetArg( args[i], XtNlabel, "|-->" ); i++;
994 XtSetValues(r2lbutton,args,i);
995 XtAddCallback( r2lbutton, XtNcallback,
996 (XtCallbackProc) toggler2l, (XtPointer) 0 );
997
998
999 /* The toggle widget for underlining (un-)setting */
1000 underlinebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
1001 NULL, 0);
1002 i=0;
1003 XtSetArg( args[i], XtNwidth, 55 ); i++;
1004 XtSetArg( args[i], XtNheight, 20 ); i++;
1005 XtSetArg( args[i], XtNlabel, "Underline" ); i++;
1006 XtSetValues(underlinebutton,args,i);
1007 XtAddCallback( underlinebutton, XtNcallback,
1008 (XtCallbackProc) toggleunderline, (XtPointer) 0 );
1009
1010
1011 /* The toggle widget for underlining (un-)setting */
1012 overlinebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
1013 NULL, 0);
1014 i=0;
1015 XtSetArg( args[i], XtNwidth, 55 ); i++;
1016 XtSetArg( args[i], XtNheight, 20 ); i++;
1017 XtSetArg( args[i], XtNlabel, "Overline" ); i++;
1018 XtSetValues(overlinebutton,args,i);
1019 XtAddCallback( overlinebutton, XtNcallback,
1020 (XtCallbackProc) toggleoverline, (XtPointer) 0 );
1021
1022
1023 /* The toggle widget for underlining (un-)setting */
1024 overstrikebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
1025 NULL, 0);
1026 i=0;
1027 XtSetArg( args[i], XtNwidth, 55 ); i++;
1028 XtSetArg( args[i], XtNheight, 20 ); i++;
1029 XtSetArg( args[i], XtNlabel, "Overstrike" ); i++;
1030 XtSetValues(overstrikebutton,args,i);
1031 XtAddCallback( overstrikebutton, XtNcallback,
1032 (XtCallbackProc) toggleoverstrike, (XtPointer) 0 );
1033
1034
1035 /* The button to raster and display the current character using
1036 the current settings */
1037 showcharbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
1038 NULL, 0);
1039 i=0;
1040 XtSetArg( args[i], XtNwidth, 60 ); i++;
1041 XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
1042 XtSetArg( args[i], XtNlabel, "Char"); i++;
1043 XtSetValues(showcharbutton,args,i);
1044 XtAddCallback( showcharbutton, XtNcallback,
1045 (XtCallbackProc) showchar, (XtPointer) 0 );
1046
1047
1048 /* The button to raster and display the current string using
1049 the current settings */
1050 showstringbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
1051 NULL, 0);
1052 i=0;
1053 XtSetArg( args[i], XtNwidth, 60 ); i++;
1054 XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
1055 XtSetArg( args[i], XtNlabel, "String"); i++;
1056 XtSetValues(showstringbutton,args,i);
1057 XtAddCallback( showstringbutton, XtNcallback,
1058 (XtCallbackProc) showstring, (XtPointer) 0 );
1059
1060
1061 /* The button to raster and display the current character using
1062 the current settings and antialiasing */
1063 aashowcharbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
1064 NULL, 0);
1065 i=0;
1066 XtSetArg( args[i], XtNwidth, 120 ); i++;
1067 XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
1068 XtSetArg( args[i], XtNlabel, "AAChar"); i++;
1069 XtSetValues(aashowcharbutton,args,i);
1070 XtAddCallback( aashowcharbutton, XtNcallback,
1071 (XtCallbackProc) aashowchar, (XtPointer) 0 );
1072
1073
1074 /* The button to raster and display the current string using
1075 the current settings and antialiasing */
1076 aashowstringbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
1077 NULL, 0);
1078 i=0;
1079 XtSetArg( args[i], XtNwidth, 120 ); i++;
1080 XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
1081 XtSetArg( args[i], XtNlabel, "AAString"); i++;
1082 XtSetValues(aashowstringbutton,args,i);
1083 XtAddCallback( aashowstringbutton, XtNcallback,
1084 (XtCallbackProc) aashowstring, (XtPointer) 0 );
1085
1086
1087 /* The button to raster and display the current character using
1088 the current settings */
1089 showcharbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box,
1090 NULL, 0);
1091 i=0;
1092 XtSetArg( args[i], XtNwidth, 60 ); i++;
1093 XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
1094 XtSetArg( args[i], XtNlabel, "CharX"); i++;
1095 XtSetValues(showcharbuttonX,args,i);
1096 XtAddCallback( showcharbuttonX, XtNcallback,
1097 (XtCallbackProc) showcharX, (XtPointer) 0 );
1098
1099
1100 /* The button to raster and display the current string using
1101 the current settings */
1102 showstringbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box,
1103 NULL, 0);
1104 i=0;
1105 XtSetArg( args[i], XtNwidth, 60 ); i++;
1106 XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
1107 XtSetArg( args[i], XtNlabel, "StringX"); i++;
1108 XtSetValues(showstringbuttonX,args,i);
1109 XtAddCallback( showstringbuttonX, XtNcallback,
1110 (XtCallbackProc) showstringX, (XtPointer) 0 );
1111
1112
1113 /* The button to raster and display the current character using
1114 the current settings and antialiasing */
1115 aashowcharbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box,
1116 NULL, 0);
1117 i=0;
1118 XtSetArg( args[i], XtNwidth, 120 ); i++;
1119 XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
1120 XtSetArg( args[i], XtNlabel, "AACharX"); i++;
1121 XtSetValues(aashowcharbuttonX,args,i);
1122 XtAddCallback( aashowcharbuttonX, XtNcallback,
1123 (XtCallbackProc) aashowcharX, (XtPointer) 0 );
1124
1125
1126 /* The button to raster and display the current string using
1127 the current settings and antialiasing */
1128 aashowstringbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box,
1129 NULL, 0);
1130 i=0;
1131 XtSetArg( args[i], XtNwidth, 120 ); i++;
1132 XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
1133 XtSetArg( args[i], XtNlabel, "AAStringX"); i++;
1134 XtSetValues(aashowstringbuttonX,args,i);
1135 XtAddCallback( aashowstringbuttonX, XtNcallback,
1136 (XtCallbackProc) aashowstringX, (XtPointer) 0 );
1137
1138
1139 /* The box for color trasp/op and fonttable button */
1140 transbox=XtCreateManagedWidget("box", boxWidgetClass, box, NULL, 0);
1141 i=0;
1142 XtSetArg(args[i], XtNheight,20); i++;
1143 XtSetArg(args[i], XtNwidth,90); i++;
1144 XtSetValues(transbox,args,i);
1145
1146
1147 /* The button to display an AA font table */
1148 fonttablebutton = XtCreateManagedWidget("Com", commandWidgetClass, transbox,
1149 NULL, 0);
1150 i=0;
1151 XtSetArg( args[i], XtNwidth, 80 ); i++;
1152 XtSetArg( args[i], XtNheight, 15 ); i++;
1153 XtSetArg( args[i], XtNlabel, "Font Table"); i++;
1154 XtSetValues(fonttablebutton,args,i);
1155 XtAddCallback( fonttablebutton, XtNcallback,
1156 (XtCallbackProc) fonttable, (XtPointer) 0 );
1157
1158
1159 /* The toggle widget for opacity/transparency */
1160 opacitybutton = XtCreateManagedWidget("toggle", toggleWidgetClass, transbox,
1161 NULL, 0);
1162 i=0;
1163 XtSetArg( args[i], XtNwidth, 80 ); i++;
1164 XtSetArg( args[i], XtNheight, 15 ); i++;
1165 XtSetArg( args[i], XtNlabel, "Transparent" ); i++;
1166 XtSetValues(opacitybutton,args,i);
1167 XtAddCallback( opacitybutton, XtNcallback,
1168 (XtCallbackProc) toggleopacity, (XtPointer) 0 );
1169 outbg=pink4.pixel; /* the initial bgcolor for transparent mode */
1170
1171
1172 /* The toggle widget for opacity/transparency */
1173 aalevelbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, transbox,
1174 NULL, 0);
1175 i=0;
1176 XtSetArg( args[i], XtNwidth, 80 ); i++;
1177 XtSetArg( args[i], XtNheight, 15 ); i++;
1178 XtSetArg( args[i], XtNlabel, "AA-Low" ); i++;
1179 XtSetValues(aalevelbutton,args,i);
1180 XtAddCallback( aalevelbutton, XtNcallback,
1181 (XtCallbackProc) toggleaalevel, (XtPointer) 0 );
1182 aalevel=T1_AA_LOW; /* the initial bgcolor for transparent mode */
1183
1184
1185 /* The box for color selecting buttons for the
1186 X11-rastering functions */
1187 colorbox=XtCreateManagedWidget("box", boxWidgetClass, box, NULL, 0);
1188 i=0;
1189 XtSetArg(args[i], XtNheight,20); i++;
1190 XtSetArg(args[i], XtNwidth,280); i++;
1191 XtSetValues(colorbox,args,i);
1192 /* FG-label */
1193 fgstatus = XtCreateManagedWidget("label", labelWidgetClass, colorbox,
1194 NULL, 0);
1195 i=0;
1196 XtSetArg( args[i], XtNwidth, 20 ); i++;
1197 XtSetArg( args[i], XtNheight, 20 ); i++;
1198 XtSetArg( args[i], XtNlabel, ""); i++;
1199 XtSetArg( args[i], XtNbackground, fg); i++;
1200 XtSetValues(fgstatus,args,i);
1201
1202 fglabel = XtCreateManagedWidget("label", labelWidgetClass, colorbox,
1203 NULL, 0);
1204 i=0;
1205 XtSetArg( args[i], XtNwidth, 80 ); i++;
1206 XtSetArg( args[i], XtNheight, 20 ); i++;
1207 XtSetArg( args[i], XtNlabel, "Foreground"); i++;
1208 XtSetValues(fglabel,args,i);
1209
1210 fgwhitebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1211 NULL, 0);
1212 i=0;
1213 XtSetArg( args[i], XtNwidth, 20 ); i++;
1214 XtSetArg( args[i], XtNheight, 20 ); i++;
1215 XtSetArg( args[i], XtNlabel, ""); i++;
1216 XtSetArg( args[i], XtNbackground, white.pixel); i++;
1217 XtSetValues(fgwhitebutton,args,i);
1218 XtAddCallback( fgwhitebutton, XtNcallback,
1219 (XtCallbackProc) setcolor, (XtPointer) 0 );
1220
1221 fgblackbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1222 NULL, 0);
1223 i=0;
1224 XtSetArg( args[i], XtNwidth, 20 ); i++;
1225 XtSetArg( args[i], XtNheight, 20 ); i++;
1226 XtSetArg( args[i], XtNlabel, ""); i++;
1227 XtSetArg( args[i], XtNbackground, black.pixel); i++;
1228 XtSetValues(fgblackbutton,args,i);
1229 XtAddCallback( fgblackbutton, XtNcallback,
1230 (XtCallbackProc) setcolor, (XtPointer) 0 );
1231
1232 fggraybutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1233 NULL, 0);
1234 i=0;
1235 XtSetArg( args[i], XtNwidth, 20 ); i++;
1236 XtSetArg( args[i], XtNheight, 20 ); i++;
1237 XtSetArg( args[i], XtNlabel, ""); i++;
1238 XtSetArg( args[i], XtNbackground, gray.pixel); i++;
1239 XtSetValues(fggraybutton,args,i);
1240 XtAddCallback( fggraybutton, XtNcallback,
1241 (XtCallbackProc) setcolor, (XtPointer) 0 );
1242
1243 fgredbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1244 NULL, 0);
1245 i=0;
1246 XtSetArg( args[i], XtNwidth, 20 ); i++;
1247 XtSetArg( args[i], XtNheight, 20 ); i++;
1248 XtSetArg( args[i], XtNlabel, ""); i++;
1249 XtSetArg( args[i], XtNbackground, red.pixel); i++;
1250 XtSetValues(fgredbutton,args,i);
1251 XtAddCallback( fgredbutton, XtNcallback,
1252 (XtCallbackProc) setcolor, (XtPointer) 0 );
1253
1254 fggreenbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1255 NULL, 0);
1256 i=0;
1257 XtSetArg( args[i], XtNwidth, 20 ); i++;
1258 XtSetArg( args[i], XtNheight, 20 ); i++;
1259 XtSetArg( args[i], XtNlabel, ""); i++;
1260 XtSetArg( args[i], XtNbackground, green.pixel); i++;
1261 XtSetValues(fggreenbutton,args,i);
1262 XtAddCallback( fggreenbutton, XtNcallback,
1263 (XtCallbackProc) setcolor, (XtPointer) 0 );
1264
1265 fgbluebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1266 NULL, 0);
1267 i=0;
1268 XtSetArg( args[i], XtNwidth, 20 ); i++;
1269 XtSetArg( args[i], XtNheight, 20 ); i++;
1270 XtSetArg( args[i], XtNlabel, ""); i++;
1271 XtSetArg( args[i], XtNbackground, blue.pixel); i++;
1272 XtSetValues(fgbluebutton,args,i);
1273 XtAddCallback( fgbluebutton, XtNcallback,
1274 (XtCallbackProc) setcolor, (XtPointer) 0 );
1275
1276 /* BG-label */
1277 bgstatus = XtCreateManagedWidget("label", labelWidgetClass, colorbox,
1278 NULL, 0);
1279 i=0;
1280 XtSetArg( args[i], XtNwidth, 20 ); i++;
1281 XtSetArg( args[i], XtNheight, 20 ); i++;
1282 XtSetArg( args[i], XtNlabel, ""); i++;
1283 XtSetArg( args[i], XtNbackground, bg); i++;
1284 XtSetValues(bgstatus,args,i);
1285
1286 bglabel = XtCreateManagedWidget("label", labelWidgetClass, colorbox,
1287 NULL, 0);
1288 i=0;
1289 XtSetArg( args[i], XtNwidth, 80 ); i++;
1290 XtSetArg( args[i], XtNheight, 20 ); i++;
1291 XtSetArg( args[i], XtNlabel, "Background"); i++;
1292 XtSetValues(bglabel,args,i);
1293
1294 bgwhitebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1295 NULL, 0);
1296 i=0;
1297 XtSetArg( args[i], XtNwidth, 20 ); i++;
1298 XtSetArg( args[i], XtNheight, 20 ); i++;
1299 XtSetArg( args[i], XtNlabel, ""); i++;
1300 XtSetArg( args[i], XtNbackground, white.pixel); i++;
1301 XtSetValues(bgwhitebutton,args,i);
1302 XtAddCallback( bgwhitebutton, XtNcallback,
1303 (XtCallbackProc) setcolor, (XtPointer) 0 );
1304
1305 bgblackbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1306 NULL, 0);
1307 i=0;
1308 XtSetArg( args[i], XtNwidth, 20 ); i++;
1309 XtSetArg( args[i], XtNheight, 20 ); i++;
1310 XtSetArg( args[i], XtNlabel, ""); i++;
1311 XtSetArg( args[i], XtNbackground, black.pixel); i++;
1312 XtSetValues(bgblackbutton,args,i);
1313 XtAddCallback( bgblackbutton, XtNcallback,
1314 (XtCallbackProc) setcolor, (XtPointer) 0 );
1315
1316 bggraybutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1317 NULL, 0);
1318 i=0;
1319 XtSetArg( args[i], XtNwidth, 20 ); i++;
1320 XtSetArg( args[i], XtNheight, 20 ); i++;
1321 XtSetArg( args[i], XtNlabel, ""); i++;
1322 XtSetArg( args[i], XtNbackground, gray.pixel); i++;
1323 XtSetValues(bggraybutton,args,i);
1324 XtAddCallback( bggraybutton, XtNcallback,
1325 (XtCallbackProc) setcolor, (XtPointer) 0 );
1326
1327 bgredbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1328 NULL, 0);
1329 i=0;
1330 XtSetArg( args[i], XtNwidth, 20 ); i++;
1331 XtSetArg( args[i], XtNheight, 20 ); i++;
1332 XtSetArg( args[i], XtNlabel, ""); i++;
1333 XtSetArg( args[i], XtNbackground, red.pixel); i++;
1334 XtSetValues(bgredbutton,args,i);
1335 XtAddCallback( bgredbutton, XtNcallback,
1336 (XtCallbackProc) setcolor, (XtPointer) 0 );
1337
1338 bggreenbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1339 NULL, 0);
1340 i=0;
1341 XtSetArg( args[i], XtNwidth, 20 ); i++;
1342 XtSetArg( args[i], XtNheight, 20 ); i++;
1343 XtSetArg( args[i], XtNlabel, ""); i++;
1344 XtSetArg( args[i], XtNbackground, green.pixel); i++;
1345 XtSetValues(bggreenbutton,args,i);
1346 XtAddCallback( bggreenbutton, XtNcallback,
1347 (XtCallbackProc) setcolor, (XtPointer) 0 );
1348
1349 bgbluebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
1350 NULL, 0);
1351 i=0;
1352 XtSetArg( args[i], XtNwidth, 20 ); i++;
1353 XtSetArg( args[i], XtNheight, 20 ); i++;
1354 XtSetArg( args[i], XtNlabel, ""); i++;
1355 XtSetArg( args[i], XtNbackground, blue.pixel); i++;
1356 XtSetValues(bgbluebutton,args,i);
1357 XtAddCallback( bgbluebutton, XtNcallback,
1358 (XtCallbackProc) setcolor, (XtPointer) 0 );
1359
1360
1361
1362 /* Label for the next box */
1363 stringlabel=XtCreateManagedWidget("Label", labelWidgetClass, box,
1364 NULL, 0);
1365 i=0;
1366 XtSetArg(args[i], XtNwidth,380); i++;
1367 XtSetArg(args[i], XtNlabel, "Test-String:"); i++;
1368 XtSetValues(stringlabel,args,i);
1369
1370
1371
1372
1373 /* An input-box for the test-string */
1374 dialogteststring=XtCreateManagedWidget("dialog1", asciiTextWidgetClass, box,
1375 NULL, 0);
1376 i=0;
1377 XtSetArg(args[i], XtNwidth,380); i++;
1378 XtSetArg(args[i], XtNheight,30); i++;
1379 XtSetArg(args[i], XtNwrap, XawtextWrapLine); i++;
1380 XtSetArg(args[i], XtNeditType, XawtextEdit ); i++;
1381 XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
1382 XtSetValues(dialogteststring,args,i);
1383
1384
1385
1386 /* Label for the next box */
1387 labelstatus=XtCreateManagedWidget("Label", labelWidgetClass, box,
1388 NULL, 0);
1389 i=0;
1390 XtSetArg(args[i], XtNwidth,380); i++;
1391 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
1392 XtSetArg(args[i], XtNlabel, "No Messages!"); i++;
1393 XtSetValues(labelstatus,args,i);
1394
1395
1396
1397 /* The button to exit the program */
1398 exitbutton = XtCreateManagedWidget("Com2", commandWidgetClass, box,
1399 NULL, 0);
1400 i=0;
1401 XtSetArg( args[i], XtNwidth, 100 ); i++;
1402 XtSetArg( args[i], XtNheight, 20 ); i++;
1403 XtSetArg( args[i], XtNx, 0 ); i++;
1404 XtSetArg( args[i], XtNy, 0 ); i++;
1405 XtSetArg( args[i], XtNlabel, " Exit Program"); i++;
1406 XtSetValues(exitbutton,args,i);
1407 XtAddCallback( exitbutton, XtNcallback,
1408 (XtCallbackProc) exitprog, (XtPointer) 0 );
1409
1410
1411 /* The About widget for the about message */
1412 aboutbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
1413 NULL, 0);
1414 i=0;
1415 XtSetArg( args[i], XtNwidth, 55 ); i++;
1416 XtSetArg( args[i], XtNheight, 20 ); i++;
1417 XtSetArg( args[i], XtNlabel, "About" ); i++;
1418 XtSetValues(aboutbutton,args,i);
1419 XtAddCallback( aboutbutton, XtNcallback,
1420 (XtCallbackProc) showabout, (XtPointer) 0 );
1421
1422
1423 XtRealizeWidget(TopLevel);
1424 XtPopup(Output,XtGrabNone);
1425
1426 if( extraflags & CHECK_PERFORMANCE){
1427 XtPopup(Output2,XtGrabNone);
1428 }
1429
1430
1431 /* Set parameters for X11-support */
1432 T1_SetX11Params( display, DefaultVisual(display, screennumber),
1433 DefaultDepth( display, screennumber),
1434 DefaultColormap(display, screennumber));
1435
1436
1437 /* Create a dummy-pixmap because we need one to destroy before
1438 the next is created! */
1439 pixmap = XCreatePixmap(display,
1440 XtWindow(OutputWindow),
1441 200,
1442 200,
1443 DefaultDepth(display,screennumber)
1444 );
1445
1446
1447
1448 XtAppMainLoop(TopLevelApp);
1449
1450 return(0);
1451
1452 }
1453
1454
1455 /* Compute the BBox of a rotated box: */
ComputeRotBBox(BBox inbox,float angle)1456 BBox ComputeRotBBox( BBox inbox, float angle)
1457 {
1458
1459 int i;
1460 BBox resultbox={ 0, 0, 0, 0};
1461 struct point
1462 {
1463 double x;
1464 double y;
1465 } p[4], P[4];
1466
1467 double sinalpha, cosalpha;
1468
1469 sinalpha=sin((double)angle*PI/180);
1470 cosalpha=cos((double)angle*PI/180);
1471
1472 /* initialize points */
1473 p[0].x=(double) inbox.llx;
1474 p[0].y=(double) inbox.lly;
1475 p[1].x=(double) inbox.urx;
1476 p[1].y=(double) inbox.lly;
1477 p[2].x=(double) inbox.urx;
1478 p[2].y=(double) inbox.ury;
1479 p[3].x=(double) inbox.llx;
1480 p[3].y=(double) inbox.ury;
1481
1482 /*
1483 fprintf( stderr, "InBox: (%f,%f), (%f,%f), (%f,%f), (%f,%f)\n",
1484 p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y,
1485 p[3].x, p[3].y);
1486 */
1487 /* Compute tranformed points */
1488 P[0].x=p[0].x*cosalpha-p[0].y*sinalpha;
1489 P[0].y=p[0].x*sinalpha+p[0].y*cosalpha;
1490 P[1].x=p[1].x*cosalpha-p[1].y*sinalpha;
1491 P[1].y=p[1].x*sinalpha+p[1].y*cosalpha;
1492 P[2].x=p[2].x*cosalpha-p[2].y*sinalpha;
1493 P[2].y=p[2].x*sinalpha+p[2].y*cosalpha;
1494 P[3].x=p[3].x*cosalpha-p[3].y*sinalpha;
1495 P[3].y=p[3].x*sinalpha+p[3].y*cosalpha;
1496 /*
1497 fprintf( stderr, "RotPoints: (%f,%f), (%f,%f), (%f,%f), (%f,%f)\n",
1498 P[0].x, P[0].y, P[1].x, P[1].y, P[2].x, P[2].y,
1499 P[3].x, P[3].y);
1500 */
1501
1502 /* Get BBox: */
1503 for (i=0; i<4; i++){
1504 if (P[i].x < (float) resultbox.llx)
1505 resultbox.llx=(int) floor(P[i].x +0.5);
1506 if (P[i].x > (float) resultbox.urx)
1507 resultbox.urx=(int) floor(P[i].x +0.5);
1508 if (P[i].y < (float) resultbox.lly)
1509 resultbox.lly=(int) floor(P[i].y +0.5);
1510 if (P[i].y > (float) resultbox.ury)
1511 resultbox.ury=(int) floor(P[i].y +0.5);
1512 }
1513
1514 return(resultbox);
1515
1516 }
1517
1518
1519
1520
exitprog(Widget exitbutton,XtPointer client_data,XtPointer call_data)1521 void exitprog(Widget exitbutton, XtPointer client_data , XtPointer call_data)
1522 {
1523
1524 int i;
1525
1526 for (i=0; i< T1_GetNoFonts(); i++){
1527 /* printf("Enc-Scheme=%s\n", T1_GetEncodingScheme( i));*/
1528 ;
1529 }
1530
1531 T1_CloseLib();
1532
1533 exit(0);
1534 }
1535
1536
togglekerning(Widget kerningbutton,XtPointer client_data,XtPointer call_data)1537 void togglekerning( Widget kerningbutton, XtPointer client_data, XtPointer call_data)
1538 {
1539 int i;
1540 char state=0;
1541 Arg args[10];
1542
1543
1544 /* Get state of toggle Button: */
1545 i=0;
1546 XtSetArg(args[i], XtNstate, &state); i++;
1547 XtGetValues(kerningbutton,args,1);
1548
1549 if ((state))
1550 Modflag |= T1_KERNING;
1551 else
1552 Modflag &= ~T1_KERNING;
1553
1554 }
1555
1556
1557
toggleligatur(Widget ligaturbutton,XtPointer client_data,XtPointer call_data)1558 void toggleligatur( Widget ligaturbutton, XtPointer client_data, XtPointer call_data)
1559 {
1560 int i;
1561 char state=0;
1562 Arg args[10];
1563
1564
1565 /* Get state of toggle Button: */
1566 i=0;
1567 XtSetArg(args[i], XtNstate, &state); i++;
1568 XtGetValues(ligaturbutton,args,1);
1569
1570 LigDetect=state;
1571
1572 }
1573
1574
1575
toggler2l(Widget r2lbutton,XtPointer client_data,XtPointer call_data)1576 void toggler2l( Widget r2lbutton, XtPointer client_data, XtPointer call_data)
1577 {
1578 int i;
1579 char state=0;
1580 Arg args[10];
1581
1582
1583 /* Get state of toggle Button: */
1584 i=0;
1585 XtSetArg(args[i], XtNstate, &state); i++;
1586 XtGetValues(r2lbutton,args,1);
1587
1588 if ((state))
1589 Modflag |= T1_RIGHT_TO_LEFT;
1590 else
1591 Modflag &= ~T1_RIGHT_TO_LEFT;
1592
1593 /* Invert state */
1594 i=0;
1595 if (state){
1596 XtSetArg( args[i], XtNwidth, 55 ); i++;
1597 XtSetArg( args[i], XtNheight, 20 ); i++;
1598 XtSetArg( args[i], XtNlabel, "<--|" ); i++;
1599 }
1600 else{
1601 XtSetArg( args[i], XtNwidth, 55 ); i++;
1602 XtSetArg( args[i], XtNheight, 20 ); i++;
1603 XtSetArg( args[i], XtNlabel, "|-->" ); i++;
1604 }
1605 XtSetValues(r2lbutton,args,i);
1606 }
1607
1608
1609
toggleunderline(Widget underlinebutton,XtPointer client_data,XtPointer call_data)1610 void toggleunderline( Widget underlinebutton, XtPointer client_data, XtPointer call_data)
1611 {
1612 int i;
1613 char state=0;
1614 Arg args[10];
1615
1616
1617 /* Get state of toggle Button: */
1618 i=0;
1619 XtSetArg(args[i], XtNstate, &state); i++;
1620 XtGetValues(underlinebutton,args,1);
1621
1622 if ((state))
1623 Modflag |= T1_UNDERLINE;
1624 else
1625 Modflag &= ~T1_UNDERLINE;
1626
1627 }
1628
1629
1630
toggleoverline(Widget overlinebutton,XtPointer client_data,XtPointer call_data)1631 void toggleoverline( Widget overlinebutton, XtPointer client_data, XtPointer call_data)
1632 {
1633 int i;
1634 char state=0;
1635 Arg args[10];
1636
1637
1638 /* Get state of toggle Button: */
1639 i=0;
1640 XtSetArg(args[i], XtNstate, &state); i++;
1641 XtGetValues( overlinebutton,args,1);
1642
1643 if ((state))
1644 Modflag |= T1_OVERLINE;
1645 else
1646 Modflag &= ~T1_OVERLINE;
1647
1648 }
1649
1650
1651
toggleoverstrike(Widget overstrikebutton,XtPointer client_data,XtPointer call_data)1652 void toggleoverstrike( Widget overstrikebutton, XtPointer client_data, XtPointer call_data)
1653 {
1654 int i;
1655 char state=0;
1656 Arg args[10];
1657
1658
1659 /* Get state of toggle Button: */
1660 i=0;
1661 XtSetArg(args[i], XtNstate, &state); i++;
1662 XtGetValues( overstrikebutton,args,1);
1663
1664 if ((state))
1665 Modflag |= T1_OVERSTRIKE;
1666 else
1667 Modflag &= ~T1_OVERSTRIKE;
1668
1669 }
1670
1671
1672
toggleopacity(Widget opacitybutton,XtPointer client_data,XtPointer call_data)1673 void toggleopacity( Widget opacitybutton, XtPointer client_data, XtPointer call_data)
1674 {
1675 int i;
1676 char state=0;
1677 Arg args[10];
1678
1679
1680 /* Get state of toggle Button: */
1681 i=0;
1682 XtSetArg(args[i], XtNstate, &state); i++;
1683 XtGetValues(opacitybutton,args,1);
1684
1685 i=0;
1686 XtSetArg( args[i], XtNstate, state); i++;
1687 XtSetArg( args[i], XtNwidth, 80 ); i++;
1688 XtSetArg( args[i], XtNheight, 20 ); i++;
1689
1690 Opacity=state;
1691
1692 /* Invert state */
1693 if (state){
1694 XtSetArg( args[i], XtNlabel, "Opaque" ); i++;
1695 XtSetValues(opacitybutton,args,i);
1696 outbg=bg;
1697 }
1698 else{
1699 XtSetArg( args[i], XtNlabel, "Transparent" ); i++;
1700 XtSetValues(opacitybutton,args,i);
1701 outbg=pink4.pixel;
1702 }
1703
1704 }
1705
1706
1707
1708 /* Toggle the antialiasing level */
toggleaalevel(Widget aalevelbutton,XtPointer client_data,XtPointer call_data)1709 void toggleaalevel( Widget aalevelbutton, XtPointer client_data, XtPointer call_data)
1710 {
1711 int i;
1712 char state=0;
1713 Arg args[10];
1714
1715
1716 /* Get state of toggle Button: */
1717 i=0;
1718 XtSetArg(args[i], XtNstate, &state); i++;
1719 XtGetValues( aalevelbutton,args,1);
1720
1721 i=0;
1722 XtSetArg( args[i], XtNstate, state); i++;
1723 XtSetArg( args[i], XtNwidth, 80 ); i++;
1724 XtSetArg( args[i], XtNheight, 15 ); i++;
1725
1726
1727 /* Invert state */
1728 if (state){
1729 XtSetArg( args[i], XtNlabel, "AA-High" ); i++;
1730 XtSetValues(aalevelbutton,args,i);
1731 aalevel=T1_AA_HIGH;
1732 }
1733 else{
1734 XtSetArg( args[i], XtNlabel, "AA-Low" ); i++;
1735 XtSetValues(aalevelbutton,args,i);
1736 aalevel=T1_AA_LOW;
1737 }
1738
1739 }
1740
1741
1742
1743 /* Set a new fore/background color */
setcolor(Widget widget,XtPointer client_data,XtPointer call_data)1744 void setcolor( Widget widget, XtPointer client_data, XtPointer call_data)
1745 {
1746 int i;
1747 Arg args[10];
1748
1749 /* foreground colors */
1750 if (widget==fgwhitebutton){
1751 fg=white.pixel;
1752 i=0;
1753 XtSetArg( args[i], XtNbackground, fg ); i++;
1754 XtSetValues(fgstatus,args,i);
1755 return;
1756 }
1757 if (widget==fgblackbutton){
1758 fg=black.pixel;
1759 i=0;
1760 XtSetArg( args[i], XtNbackground, fg ); i++;
1761 XtSetValues(fgstatus,args,i);
1762 return;
1763 }
1764 if (widget==fggraybutton){
1765 fg=gray.pixel;
1766 i=0;
1767 XtSetArg( args[i], XtNbackground, fg ); i++;
1768 XtSetValues(fgstatus,args,i);
1769 return;
1770 }
1771 if (widget==fgredbutton){
1772 fg=red.pixel;
1773 i=0;
1774 XtSetArg( args[i], XtNbackground, fg ); i++;
1775 XtSetValues(fgstatus,args,i);
1776 return;
1777 }
1778 if (widget==fggreenbutton){
1779 fg=green.pixel;
1780 i=0;
1781 XtSetArg( args[i], XtNbackground, fg ); i++;
1782 XtSetValues(fgstatus,args,i);
1783 return;
1784 }
1785 if (widget==fgbluebutton){
1786 fg=blue.pixel;
1787 i=0;
1788 XtSetArg( args[i], XtNbackground, fg ); i++;
1789 XtSetValues(fgstatus,args,i);
1790 return;
1791 }
1792 /* background colors */
1793 if (widget==bgwhitebutton){
1794 bg=white.pixel;
1795 if (Opacity)
1796 outbg=bg;
1797 i=0;
1798 XtSetArg( args[i], XtNbackground, bg ); i++;
1799 XtSetValues(bgstatus,args,i);
1800 return;
1801 }
1802 if (widget==bgblackbutton){
1803 bg=black.pixel;
1804 if (Opacity)
1805 outbg=bg;
1806 i=0;
1807 XtSetArg( args[i], XtNbackground, bg ); i++;
1808 XtSetValues(bgstatus,args,i);
1809 return;
1810 }
1811 if (widget==bggraybutton){
1812 bg=gray.pixel;
1813 if (Opacity)
1814 outbg=bg;
1815 i=0;
1816 XtSetArg( args[i], XtNbackground, bg ); i++;
1817 XtSetValues(bgstatus,args,i);
1818 return;
1819 }
1820 if (widget==bgredbutton){
1821 bg=red.pixel;
1822 if (Opacity)
1823 outbg=bg;
1824 i=0;
1825 XtSetArg( args[i], XtNbackground, bg ); i++;
1826 XtSetValues(bgstatus,args,i);
1827 return;
1828 }
1829 if (widget==bggreenbutton){
1830 bg=green.pixel;
1831 if (Opacity)
1832 outbg=bg;
1833 i=0;
1834 XtSetArg( args[i], XtNbackground, bg ); i++;
1835 XtSetValues(bgstatus,args,i);
1836 return;
1837 }
1838 if (widget==bgbluebutton){
1839 bg=blue.pixel;
1840 if (Opacity)
1841 outbg=bg;
1842 i=0;
1843 XtSetArg( args[i], XtNbackground, bg ); i++;
1844 XtSetValues(bgstatus,args,i);
1845 return;
1846 }
1847 /* we shouldn't get here */
1848 return;
1849
1850 }
1851
1852
1853
showchar(Widget showcharbutton,XtPointer client_data,XtPointer call_data)1854 void showchar( Widget showcharbutton, XtPointer client_data, XtPointer call_data)
1855 {
1856 int i, j;
1857 Arg args[10];
1858
1859
1860 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
1861 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
1862 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
1863 sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
1864 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
1865 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
1866
1867
1868 if (FontID<0 || FontID>=T1_GetNoFonts()) {
1869 sprintf(statusstring, "t1lib: FontID out of range!");
1870 i=0;
1871 XtSetArg(args[i], XtNbitmap,NULL); i++;
1872 XtSetArg(args[i], XtNwidth,380); i++;
1873 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
1874 XtSetArg(args[i], XtNlabel, statusstring); i++;
1875 XtSetValues(labelstatus,args,i);
1876 return;
1877 }
1878
1879 /* Ensure that font is loaded before any operation on the font */
1880 if ( T1_CheckForFontID( FontID) < 1 ) {
1881 T1_LoadFont( FontID);
1882 }
1883
1884 if ( StrokeWidth == 0.0f ) {
1885 T1_ClearStrokeFlag( FontID);
1886 }
1887 else {
1888 T1_SetStrokeFlag( FontID);
1889 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
1890 sprintf( statusstring, "t1lib: Unable to setup strokewidth!");
1891 i=0;
1892 XtSetArg(args[i], XtNbitmap,NULL); i++;
1893 XtSetArg(args[i], XtNwidth,380); i++;
1894 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
1895 XtSetArg(args[i], XtNlabel, statusstring); i++;
1896 XtSetValues(labelstatus,args,i);
1897 return;
1898 }
1899 }
1900
1901 if (CheckTransform()==0 && Angle==0.0){
1902 matrixP=NULL;
1903 }
1904 else{
1905 matrixP=T1_RotateMatrix( &matrix, Angle);
1906 }
1907
1908 if (DeviceResolution!=last_resolution[FontID]){
1909 /* Delete all size dependent data for that font */
1910 for ( i=0; i<T1_GetNoFonts(); i++)
1911 T1_DeleteAllSizes( i);
1912 /* Establish new device resolution */
1913 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
1914 /* Store current resolution */
1915 last_resolution[FontID]=DeviceResolution;
1916 }
1917 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
1918 if (i==EOF) EncodingFile[0]=0;
1919 if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
1920 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
1921 for (i=0; i<T1_GetNoFonts(); i++){
1922 T1_DeleteAllSizes(i);
1923 T1_ReencodeFont( i, NULL);
1924 }
1925 /* Take care that newly loaded fonts are encoded according to current
1926 encoding */
1927 T1_SetDefaultEncoding( NULL);
1928 }
1929 else{
1930 for (i=0; i<MAXENCODINGS; ){
1931 if ( encstruct[i].encfilename != NULL)
1932 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
1933 i++;
1934 break;
1935 }
1936 i++;
1937 }
1938 if (i==MAXENCODINGS){ /* Encoding from that file was not
1939 already loaded -> so load it */
1940 i=0;
1941 while (encstruct[i].encfilename != NULL)
1942 i++;
1943 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
1944 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
1945 if (encstruct[i].encoding==NULL){
1946 free( encstruct[i].encfilename);
1947 encstruct[i].encfilename=NULL;
1948 }
1949 i++;
1950 }
1951 for (j=0; j<T1_GetNoFonts(); j++){
1952 T1_DeleteAllSizes(j);
1953 T1_ReencodeFont( j, encstruct[i-1].encoding);
1954 }
1955 /* Take care that newly loaded fonts are encoded according to current
1956 encoding */
1957 T1_SetDefaultEncoding( encstruct[i-1].encoding);
1958 }
1959 strcpy( LastEncodingFile, EncodingFile);
1960 }
1961 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
1962 if (Slant!=lastSlant[FontID]){
1963 /* Delete all size dependent data */
1964 T1_DeleteAllSizes(FontID);
1965 T1_LoadFont(FontID);
1966 T1_SlantFont( FontID, Slant);
1967 lastSlant[FontID]=Slant;
1968 }
1969 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
1970 if (Extent!=lastExtent[FontID]){
1971 /* Delete all size dependent data */
1972 T1_DeleteAllSizes(FontID);
1973 T1_LoadFont(FontID);
1974 T1_ExtendFont( FontID, Extent);
1975 lastExtent[FontID]=Extent;
1976 }
1977
1978 if (Size<=0.0){
1979 sprintf(statusstring, "t1lib: Size must be positive!");
1980 i=0;
1981 XtSetArg(args[i], XtNbitmap,NULL); i++;
1982 XtSetArg(args[i], XtNwidth,380); i++;
1983 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
1984 XtSetArg(args[i], XtNlabel, statusstring); i++;
1985 XtSetValues(labelstatus,args,i);
1986 return;
1987 }
1988
1989 XSetForeground( display, DefaultGC( display, screennumber), black.pixel);
1990 XSetBackground( display, DefaultGC( display, screennumber), white.pixel);
1991 /* Reset T1_errno: */
1992 T1_errno=0;
1993 gettimeofday(time_ptr_start, void_ptr);
1994 if ( extraflags & CHECK_SET_RECT )
1995 glyph=T1_SetRect( FontID, Size, 1000.0, 1000.0, matrixP);
1996 else
1997 glyph=T1_SetChar( FontID, TestChar, Size, matrixP);
1998 gettimeofday(time_ptr_stop, void_ptr);
1999
2000 if (glyph==NULL){
2001 sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
2002 i=0;
2003 XtSetArg(args[i], XtNbitmap,NULL); i++;
2004 XtSetArg(args[i], XtNwidth,380); i++;
2005 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2006 XtSetArg(args[i], XtNlabel, statusstring); i++;
2007 XtSetValues(labelstatus,args,i);
2008 return;
2009 }
2010
2011
2012 height=glyph->metrics.ascent - glyph->metrics.descent;
2013 overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
2014 width=overallwidth;
2015
2016 /* Prepare status message: */
2017 sprintf(statusstring,"Elapsed time: %ld Microseconds\nLeftSideBearing: %d\nRightSideBearing: %d\nAscent: %d\nDescent: %d\nAdvanceX: %d\nAdvanceY: %d\nBits Per Pixel: %ld\nImage Size: %ld Bytes\nPostScript Fontname: %s\nCharactername: %s\nT1_errno: %d\n",
2018 time_diff(time_ptr_start,time_ptr_stop),
2019 glyph->metrics.leftSideBearing,
2020 glyph->metrics.rightSideBearing,
2021 glyph->metrics.ascent,
2022 glyph->metrics.descent,
2023 glyph->metrics.advanceX,
2024 glyph->metrics.advanceY,
2025 glyph->bpp,
2026 PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
2027 T1_GetFontName(FontID),
2028 T1_GetCharName(FontID,(char)TestChar),
2029 T1_errno);
2030
2031 if (glyph->bits !=NULL) {
2032 ximage=XCreateImage( display,
2033 DefaultVisual(display, screennumber),
2034 1, /* depths for bitmap is 1 */
2035 XYBitmap, /* XYBitmap or XYPixmap */
2036 0, /* No offset */
2037 glyph->bits,
2038 width,
2039 height,
2040 t1_pad, /* lines padded to bytes */
2041 0 /*PAD(width,8)/8*/ /* number of bytes per line */
2042 );
2043 /* Force bit and byte order */
2044 ximage->bitmap_bit_order=0;
2045 ximage->byte_order=0;
2046 XFreePixmap(display,pixmap);
2047 pixmap = XCreatePixmap(display,
2048 XtWindow(TopLevel),
2049 width,
2050 height,
2051 DefaultDepth(display,screennumber)
2052 );
2053 XPutImage(display,
2054 pixmap,
2055 DefaultGC( display, screennumber),
2056 ximage,
2057 0,
2058 0,
2059 0,
2060 0,
2061 width,
2062 height
2063 );
2064 XDestroyImage(ximage);
2065 }
2066
2067
2068 i=0;
2069 XtSetArg(args[i], XtNbitmap,NULL); i++;
2070 XtSetArg(args[i], XtNwidth,380); i++;
2071 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2072 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
2073 XtSetArg(args[i], XtNlabel, statusstring); i++;
2074 XtSetValues(labelstatus,args,i);
2075
2076
2077 i=0;
2078 XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
2079 XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
2080 if (glyph->bits != NULL) {
2081 XtSetArg( args[i], XtNbitmap, pixmap); i++;
2082 }
2083 else {
2084 XtSetArg( args[i], XtNbitmap, 0); i++;
2085 }
2086 XtSetArg( args[i], XtNresize, 1);i++;
2087 XtSetArg( args[i], XtNinternalWidth, 0); i++;
2088 XtSetArg( args[i], XtNinternalHeight, 0); i++;
2089 XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++;
2090 XtSetArg( args[i], XtNforeground, BlackPixel(display,screennumber)); i++;
2091 XtSetValues(OutputWindow ,args,i);
2092
2093
2094 i=0;
2095 XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
2096 XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
2097 if (glyph->bits != NULL) {
2098 XtSetArg( args[i], XtNbitmap, pixmap); i++;
2099 }
2100 else {
2101 XtSetArg( args[i], XtNbitmap, 0); i++;
2102 }
2103 XtSetArg( args[i], XtNresize, 1);i++;
2104 XtSetArg( args[i], XtNinternalWidth, 0); i++;
2105 XtSetArg( args[i], XtNinternalHeight, 0); i++;
2106 XtSetValues(Output ,args,i);
2107
2108 glyph->bits=NULL; /* Since XDestroyImage() free's this also! */
2109 }
2110
2111
2112
showstring(Widget showstringbutton,XtPointer client_data,XtPointer call_data)2113 void showstring( Widget showstringbutton, XtPointer client_data, XtPointer call_data)
2114 {
2115 int i,j,k,l,m,none_found;
2116 Arg args[10];
2117 char *theString='\0';
2118 char *ligtheString='\0';
2119 char *succs, *ligs;
2120 char buf_char;
2121
2122
2123 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
2124 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
2125 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
2126 sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
2127 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
2128 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
2129
2130 if (FontID<0 || FontID>=T1_GetNoFonts()) {
2131 sprintf(statusstring, "t1lib: FontID out of range!");
2132 i=0;
2133 XtSetArg(args[i], XtNbitmap,NULL); i++;
2134 XtSetArg(args[i], XtNwidth,380); i++;
2135 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2136 XtSetArg(args[i], XtNlabel, statusstring); i++;
2137 XtSetValues(labelstatus,args,i);
2138 return;
2139 }
2140
2141 /* Ensure that font is loaded before any operation on the font */
2142 if ( T1_CheckForFontID( FontID) < 1 ) {
2143 T1_LoadFont( FontID);
2144 }
2145
2146 if ( StrokeWidth == 0.0f ) {
2147 T1_ClearStrokeFlag( FontID);
2148 }
2149 else {
2150 T1_SetStrokeFlag( FontID);
2151 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
2152 sprintf( statusstring, "t1lib: Unable to setup strokewidth");
2153 i=0;
2154 XtSetArg(args[i], XtNbitmap,NULL); i++;
2155 XtSetArg(args[i], XtNwidth,380); i++;
2156 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2157 XtSetArg(args[i], XtNlabel, statusstring); i++;
2158 XtSetValues(labelstatus,args,i);
2159 return;
2160 }
2161 }
2162
2163 if (CheckTransform()==0 && Angle==0.0){
2164 matrixP=NULL;
2165 }
2166 else{
2167 matrixP=T1_RotateMatrix( &matrix, Angle);
2168 }
2169
2170 if (DeviceResolution!=last_resolution[FontID]){
2171 /* Delete all size dependent data for that font */
2172 for ( i=0; i<T1_GetNoFonts(); i++)
2173 T1_DeleteAllSizes( i);
2174 /* Establish new device resolution */
2175 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
2176 /* Store current resolution */
2177 last_resolution[FontID]=DeviceResolution;
2178 }
2179 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
2180 if (i==EOF) EncodingFile[0]=0;
2181 if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
2182 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
2183 for (i=0; i<T1_GetNoFonts(); i++){
2184 T1_DeleteAllSizes(i);
2185 T1_ReencodeFont( i, NULL);
2186 }
2187 /* Take care that newly loaded fonts are encoded according to current
2188 encoding */
2189 T1_SetDefaultEncoding( NULL);
2190 }
2191 else{
2192 for (i=0; i<MAXENCODINGS; ){
2193 if ( encstruct[i].encfilename != NULL)
2194 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
2195 i++;
2196 break;
2197 }
2198 i++;
2199 }
2200 if (i==MAXENCODINGS){ /* Encoding from that file was not
2201 already loaded -> so load it */
2202 i=0;
2203 while (encstruct[i].encfilename != NULL)
2204 i++;
2205 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
2206 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
2207 if (encstruct[i].encoding==NULL){
2208 free( encstruct[i].encfilename);
2209 encstruct[i].encfilename=NULL;
2210 }
2211 i++;
2212 }
2213 for (j=0; j<T1_GetNoFonts(); j++){
2214 T1_DeleteAllSizes(j);
2215 T1_ReencodeFont( j, encstruct[i-1].encoding);
2216 }
2217 /* Take care that newly loaded fonts are encoded according to current
2218 encoding */
2219 T1_SetDefaultEncoding( encstruct[i-1].encoding);
2220 }
2221 strcpy( LastEncodingFile, EncodingFile);
2222 }
2223 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
2224 if (Slant!=lastSlant[FontID]){
2225 /* Delete all size dependent data */
2226 T1_DeleteAllSizes(FontID);
2227 T1_LoadFont(FontID);
2228 T1_SlantFont( FontID, Slant);
2229 lastSlant[FontID]=Slant;
2230 }
2231 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
2232 if (Extent!=lastExtent[FontID]){
2233 /* Delete all size dependent data */
2234 T1_DeleteAllSizes(FontID);
2235 T1_LoadFont(FontID);
2236 T1_ExtendFont( FontID, Extent);
2237 lastExtent[FontID]=Extent;
2238 }
2239
2240 i=0;
2241 XtSetArg(args[i], XtNstring, &theString); i++;
2242 XtGetValues(dialogteststring,args,i);
2243
2244 if (Size<=0.0){
2245 sprintf(statusstring, "t1lib: Size must be positive!");
2246 i=0;
2247 XtSetArg(args[i], XtNbitmap,NULL); i++;
2248 XtSetArg(args[i], XtNwidth,380); i++;
2249 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2250 XtSetArg(args[i], XtNlabel, statusstring); i++;
2251 XtSetValues(labelstatus,args,i);
2252 return;
2253 }
2254
2255 /* Now comes the ligatur handling */
2256 if (strcmp(theString,"")==0)
2257 theString=(char *) TestString;
2258 i=strlen(theString);
2259 ligtheString=(char *)malloc((i+1)*sizeof(char));
2260 if (LigDetect){
2261 for (j=0,m=0;j<i;j++,m++){ /* Loop through the characters */
2262 if ((k=T1_QueryLigs( FontID, theString[j], &succs, &ligs))>0){
2263 buf_char=theString[j];
2264 while (k>0){
2265 none_found=1;
2266 for (l=0;l<k;l++){ /* Loop through the ligatures */
2267 if (succs[l]==theString[j+1]){
2268 buf_char=ligs[l];
2269 j++;
2270 none_found=0;
2271 break;
2272 }
2273 }
2274 if (none_found)
2275 break;
2276 k=T1_QueryLigs( FontID, buf_char, &succs, &ligs);
2277 }
2278 ligtheString[m]=buf_char;
2279 }
2280 else{ /* There are no ligatures */
2281 ligtheString[m]=theString[j];
2282 }
2283 }
2284 ligtheString[m]=0;
2285 }
2286 else {
2287 strcpy(ligtheString,theString);
2288 }
2289
2290 /*
2291 {
2292 METRICSINFO metrics;
2293
2294 metrics=T1_GetMetricsInfo(FontID,(char *)ligtheString,0,Space,(Modflag & T1_KERNING));
2295 printf("String's width: %d\n", metrics.width);
2296 printf("String's BBox: llx = %d\n", metrics.bbox.llx);
2297 printf(" lly = %d\n", metrics.bbox.lly);
2298 printf(" urx = %d\n", metrics.bbox.urx);
2299 printf(" ury = %d\n", metrics.bbox.ury);
2300 printf("Number of chars in string: %d\n", metrics.numchars);
2301 for (i=0;i<metrics.numchars;i++)
2302 printf("Position of %d. character in string: %d afm-units\n", i+1, metrics.charpos[i]);
2303 }
2304 */
2305
2306 /*
2307 {
2308 int i,j;
2309 T1_COMP_CHAR_INFO *ccd;
2310 T1_COMP_PIECE *cp;
2311
2312 printf("Number of composite characters in font: %d\n",
2313 j=T1_GetNoCompositeChars(FontID));
2314 for (i=0; i<j; i++) {
2315 ccd=T1_GetCompCharDataByIndex( FontID, i);
2316 if (ccd==NULL) {
2317 printf("AFM-ind=%d, ccd=%p, T1_errno=%d\n", i, ccd, T1_errno);
2318 T1_errno=0;
2319 }
2320 else {
2321 printf( "AFM-ind=%d: Compchar %s (%d), has %d pieces:\n",
2322 i,
2323 ccd->compchar > -1 ? T1_GetCharName( FontID, ccd->compchar) : "not_enc",
2324 ccd->compchar,
2325 ccd->numPieces);
2326
2327 printf( " basechar %s (%d)\n",
2328 ccd->pieces[0].piece > -1 ? T1_GetCharName( FontID, ccd->pieces[0].piece) : "not_enc",
2329 ccd->pieces[0].piece);
2330 printf( " accent %s (%d)\n",
2331 ccd->pieces[1].piece > -1 ? T1_GetCharName( FontID, ccd->pieces[1].piece) : "not_enc",
2332 ccd->pieces[1].piece);
2333 }
2334 T1_FreeCompCharData( ccd);
2335 }
2336
2337 }
2338 */
2339
2340
2341
2342 XSetForeground( display, DefaultGC( display, screennumber), black.pixel);
2343 XSetBackground( display, DefaultGC( display, screennumber), white.pixel);
2344 /* Reset T1_errno: */
2345 T1_errno=0;
2346 gettimeofday(time_ptr_start, void_ptr);
2347
2348 if( extraflags & CHECK_CONCATGLYPHS){
2349 glyph2=T1_SetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
2350 glyph1=T1_CopyGlyph( glyph2);
2351 glyph2=T1_SetString(FontID+1,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
2352 glyph=T1_ConcatGlyphs( glyph1, glyph2, 0, 0, Modflag);
2353 }
2354 else if( extraflags & CHECK_CONCATOUTLINES){
2355 {
2356 T1_OUTLINE *path=NULL;
2357 path=T1_GetStringOutline(FontID,(char *)ligtheString,
2358 0,Space,Modflag,Size,matrixP);
2359 if (path==NULL){
2360 return;
2361 }
2362 #ifdef SHOW_MANIPULATE_PATHS
2363 T1_AbsolutePath( path);
2364 T1_ManipulatePath( path, &mymanipulate);
2365 T1_RelativePath( path);
2366 #else
2367 T1_ConcatOutlines( path,
2368 T1_GetStringOutline(FontID+1,(char *)ligtheString,
2369 0,Space,Modflag,Size,matrixP));
2370 #endif
2371 glyph=T1_FillOutline( path, Modflag);
2372 }
2373 }
2374 else{
2375 if( extraflags & CHECK_FOR_BAD_CHARS){
2376 sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
2377 ligtheString[strlen(ligtheString)/2]=(unsigned char) TestChar;
2378 }
2379 glyph=T1_SetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
2380 }
2381
2382
2383 gettimeofday(time_ptr_stop, void_ptr);
2384
2385 free(ligtheString);
2386
2387 if ( glyph ==NULL ) {
2388 sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
2389 i=0;
2390 XtSetArg(args[i], XtNbitmap,NULL); i++;
2391 XtSetArg(args[i], XtNwidth,380); i++;
2392 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2393 XtSetArg(args[i], XtNlabel, statusstring); i++;
2394 XtSetValues(labelstatus,args,i);
2395 return;
2396 }
2397
2398
2399 height=glyph->metrics.ascent - glyph->metrics.descent;
2400 overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
2401 width=overallwidth;
2402
2403 /* Prepare status message: */
2404 sprintf(statusstring,"Elapsed time: %ld Microseconds\nLeftSideBearing: %d\nRightSideBearing: %d\nAscent: %d\nDescent: %d\nAdvanceX: %d\nAdvanceY: %d\nBits Per Pixel: %ld\nImage Size: %ld Bytes\nPostScript Fontname: %s\nT1_errno: %d\n",
2405 time_diff(time_ptr_start,time_ptr_stop),
2406 glyph->metrics.leftSideBearing,
2407 glyph->metrics.rightSideBearing,
2408 glyph->metrics.ascent,
2409 glyph->metrics.descent,
2410 glyph->metrics.advanceX,
2411 glyph->metrics.advanceY,
2412 glyph->bpp,
2413 PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
2414 T1_GetFontName(FontID),
2415 T1_errno);
2416
2417 if (glyph->bits != NULL) {
2418 ximage=XCreateImage( display,
2419 DefaultVisual(display, screennumber),
2420 1, /* depths for bitmap is 1 */
2421 XYBitmap, /* XYBitmap or XYPixmap */
2422 0, /* No offset */
2423 glyph->bits,
2424 width,
2425 height,
2426 t1_pad, /* lines padded to bytes */
2427 0 /*PAD(width,8)/8*/ /* number of bytes per line */
2428 );
2429 /* Force bit and byte order */
2430 ximage->bitmap_bit_order=LSBFirst;
2431 ximage->byte_order=LSBFirst;
2432 XFreePixmap(display,pixmap);
2433 pixmap = XCreatePixmap(display,
2434 XtWindow(TopLevel),
2435 width,
2436 height,
2437 DefaultDepth(display,screennumber)
2438 );
2439 XPutImage(display,
2440 pixmap,
2441 DefaultGC( display, screennumber),
2442 ximage,
2443 0,
2444 0,
2445 0,
2446 0,
2447 width,
2448 height
2449 );
2450 XDestroyImage(ximage);
2451 }
2452
2453
2454 i=0;
2455 XtSetArg(args[i], XtNbitmap,NULL); i++;
2456 XtSetArg(args[i], XtNwidth,380); i++;
2457 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2458 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
2459 XtSetArg(args[i], XtNlabel, statusstring); i++;
2460 XtSetValues(labelstatus,args,i);
2461
2462 i=0;
2463 XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
2464 XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
2465 if (glyph->bits != NULL) {
2466 XtSetArg( args[i], XtNbitmap, pixmap); i++;
2467 }
2468 else {
2469 XtSetArg( args[i], XtNbitmap, 0); i++;
2470 }
2471 XtSetArg( args[i], XtNresize, 1);i++;
2472 XtSetArg( args[i], XtNinternalWidth, 0); i++;
2473 XtSetArg( args[i], XtNinternalHeight, 0); i++;
2474 XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++;
2475 XtSetValues(OutputWindow ,args,i);
2476
2477 i=0;
2478 XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
2479 XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
2480 if (glyph->bits != NULL) {
2481 XtSetArg( args[i], XtNbitmap, pixmap); i++;
2482 }
2483 else {
2484 XtSetArg( args[i], XtNbitmap, 0); i++;
2485 }
2486 XtSetArg( args[i], XtNresize, 1);i++;
2487 XtSetArg( args[i], XtNinternalWidth, 0); i++;
2488 XtSetArg( args[i], XtNinternalHeight, 0); i++;
2489 XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++;
2490 XtSetValues(Output ,args,i);
2491
2492 glyph->bits=NULL; /* Since XDestroyImage() free's this also! */
2493 }
2494
2495
2496
aashowchar(Widget showcharbutton,XtPointer client_data,XtPointer call_data)2497 void aashowchar( Widget showcharbutton, XtPointer client_data, XtPointer call_data)
2498 {
2499 int i, j;
2500 Arg args[10];
2501
2502
2503 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
2504 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
2505 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
2506 sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
2507 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
2508 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
2509
2510 if (FontID<0 || FontID>=T1_GetNoFonts()) {
2511 sprintf(statusstring, "t1lib: FontID out of range!");
2512 i=0;
2513 XtSetArg(args[i], XtNbitmap,NULL); i++;
2514 XtSetArg(args[i], XtNwidth,380); i++;
2515 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2516 XtSetArg(args[i], XtNlabel, statusstring); i++;
2517 XtSetValues(labelstatus,args,i);
2518 return;
2519 }
2520
2521 /* Ensure that font is loaded before any operation on the font */
2522 if ( T1_CheckForFontID( FontID) < 1 ) {
2523 T1_LoadFont( FontID);
2524 }
2525
2526 if ( StrokeWidth == 0.0f ) {
2527 T1_ClearStrokeFlag( FontID);
2528 }
2529 else {
2530 T1_SetStrokeFlag( FontID);
2531 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
2532 sprintf( statusstring, "t1lib: Unable to setup strokewidth");
2533 i=0;
2534 XtSetArg(args[i], XtNbitmap,NULL); i++;
2535 XtSetArg(args[i], XtNwidth,380); i++;
2536 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2537 XtSetArg(args[i], XtNlabel, statusstring); i++;
2538 XtSetValues(labelstatus,args,i);
2539 return;
2540 }
2541 }
2542
2543 if (CheckTransform()==0 && Angle==0.0){
2544 matrixP=NULL;
2545 }
2546 else{
2547 matrixP=T1_RotateMatrix( &matrix, Angle);
2548 }
2549
2550 if (DeviceResolution!=last_resolution[FontID]){
2551 /* Delete all size dependent data for that font */
2552 for ( i=0; i<T1_GetNoFonts(); i++)
2553 T1_DeleteAllSizes( i);
2554 /* Establish new device resolution */
2555 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
2556 /* Store current resolution */
2557 last_resolution[FontID]=DeviceResolution;
2558 }
2559 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
2560 if (i==EOF) EncodingFile[0]=0;
2561 if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
2562 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
2563 for (i=0; i<T1_GetNoFonts(); i++){
2564 T1_DeleteAllSizes(i);
2565 T1_ReencodeFont( i, NULL);
2566 }
2567 /* Take care that newly loaded fonts are encoded according to current
2568 encoding */
2569 T1_SetDefaultEncoding( NULL);
2570 }
2571 else{
2572 for (i=0; i<MAXENCODINGS; ){
2573 if ( encstruct[i].encfilename != NULL)
2574 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
2575 i++;
2576 break;
2577 }
2578 i++;
2579 }
2580 if (i==MAXENCODINGS){ /* Encoding from that file was not
2581 already loaded -> so load it */
2582 i=0;
2583 while (encstruct[i].encfilename != NULL)
2584 i++;
2585 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
2586 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
2587 if (encstruct[i].encoding==NULL){
2588 free( encstruct[i].encfilename);
2589 encstruct[i].encfilename=NULL;
2590 }
2591 i++;
2592 }
2593 for (j=0; j<T1_GetNoFonts(); j++){
2594 T1_DeleteAllSizes(j);
2595 T1_ReencodeFont( j, encstruct[i-1].encoding);
2596 }
2597 /* Take care that newly loaded fonts are encoded according to current
2598 encoding */
2599 T1_SetDefaultEncoding( encstruct[i-1].encoding);
2600 }
2601 strcpy( LastEncodingFile, EncodingFile);
2602 }
2603 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
2604 if (Slant!=lastSlant[FontID]){
2605 /* Delete all size dependent data */
2606 T1_DeleteAllSizes(FontID);
2607 T1_LoadFont(FontID);
2608 T1_SlantFont( FontID, Slant);
2609 lastSlant[FontID]=Slant;
2610 }
2611 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
2612 if (Extent!=lastExtent[FontID]){
2613 /* Delete all size dependent data */
2614 T1_DeleteAllSizes(FontID);
2615 T1_LoadFont(FontID);
2616 T1_ExtendFont( FontID, Extent);
2617 lastExtent[FontID]=Extent;
2618 }
2619
2620 if (Size<=0.0){
2621 sprintf(statusstring, "t1lib: Size must be positive!");
2622 i=0;
2623 XtSetArg(args[i], XtNbitmap,NULL); i++;
2624 XtSetArg(args[i], XtNwidth,380); i++;
2625 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2626 XtSetArg(args[i], XtNlabel, statusstring); i++;
2627 XtSetValues(labelstatus,args,i);
2628 return;
2629 }
2630
2631 /* Reset T1_errno: */
2632 T1_errno=0;
2633 /* Set antialiasing level */
2634 T1_AASetLevel( aalevel);
2635 /* Set the colors for Anti-Aliasing */
2636 T1_AASetGrayValues( aapixels[0], /* white */
2637 aapixels[4],
2638 aapixels[8],
2639 aapixels[12],
2640 aapixels[16] ); /* black */
2641 T1_AAHSetGrayValues( aapixels);
2642 T1_AANSetGrayValues( aapixels[0], aapixels[16]);
2643 gettimeofday(time_ptr_start, void_ptr);
2644 if ( extraflags & CHECK_SET_RECT )
2645 glyph=T1_AASetRect( FontID, Size, 1000.0, 1000.0, matrixP);
2646 else
2647 glyph=T1_AASetChar( FontID, (char)TestChar, Size, matrixP);
2648 gettimeofday(time_ptr_stop, void_ptr);
2649
2650 if (glyph==NULL) {
2651 sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
2652 i=0;
2653 XtSetArg(args[i], XtNbitmap,NULL); i++;
2654 XtSetArg(args[i], XtNwidth,380); i++;
2655 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2656 XtSetArg(args[i], XtNlabel, statusstring); i++;
2657 XtSetValues(labelstatus,args,i);
2658 return;
2659 }
2660
2661
2662 height=glyph->metrics.ascent - glyph->metrics.descent;
2663 overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
2664 width=overallwidth;
2665
2666 /* Prepare status message: */
2667 sprintf(statusstring,"Elapsed time: %ld Microseconds\nLeftSideBearing: %d\nRightSideBearing: %d\nAscent: %d\nDescent: %d\nAdvanceX: %d\nAdvanceY: %d\nBits Per Pixel: %ld\nImage Size: %ld Bytes\nPostScript Fontname: %s\nCharactername: %s\nT1_errno: %d\n",
2668 time_diff(time_ptr_start,time_ptr_stop),
2669 glyph->metrics.leftSideBearing,
2670 glyph->metrics.rightSideBearing,
2671 glyph->metrics.ascent,
2672 glyph->metrics.descent,
2673 glyph->metrics.advanceX,
2674 glyph->metrics.advanceY,
2675 glyph->bpp,
2676 PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
2677 T1_GetFontName(FontID),
2678 T1_GetCharName(FontID,(char)TestChar),
2679 T1_errno);
2680
2681
2682 /*
2683 printf("glyph->bits=%u\n", glyph->bits);
2684 printf("glyph->metrics.leftSideBearing=%u\n", glyph->metrics.leftSideBearing);
2685 printf("glyph->metrics.rightSideBearing=%u\n", glyph->metrics.rightSideBearing);
2686 printf("glyph->metrics.advanceX=%u\n", glyph->metrics.advanceX);
2687 printf("glyph->metrics.ascent=%u\n", glyph->metrics.ascent);
2688 printf("glyph->metrics.descent=%u\n", glyph->metrics.descent);
2689 printf("glyph->pFontCacheInfo=%u\n", glyph->pFontCacheInfo);
2690 */
2691
2692 if (glyph->bits != NULL) {
2693 ximage=XCreateImage( display,
2694 DefaultVisual(display, screennumber),
2695 DefaultDepth(display,screennumber), /* depths for bitmap is 1 */
2696 ZPixmap, /* XYBitmap or XYPixmap */
2697 0, /* No offset */
2698 glyph->bits,
2699 width,
2700 height,
2701 t1_pad, /* lines padded to bytes */
2702 0 /*PAD(width,8)/8*/ /* number of bytes per line */
2703 );
2704 ximage->byte_order=xglyph_byte_order;
2705 XFreePixmap(display,pixmap);
2706 pixmap = XCreatePixmap(display,
2707 XtWindow(TopLevel),
2708 width,
2709 height,
2710 DefaultDepth(display,screennumber) /* 8 */ /* depth */
2711 );
2712 XPutImage(display,
2713 pixmap,
2714 DefaultGC( display, screennumber),
2715 ximage,
2716 0,
2717 0,
2718 0,
2719 0,
2720 width,
2721 height
2722 );
2723 XDestroyImage(ximage);
2724 }
2725
2726 i=0;
2727 XtSetArg(args[i], XtNbitmap,NULL); i++;
2728 XtSetArg(args[i], XtNwidth,380); i++;
2729 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2730 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
2731 XtSetArg(args[i], XtNlabel, statusstring); i++;
2732 XtSetValues(labelstatus,args,i);
2733
2734 i=0;
2735 XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
2736 XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
2737 if (glyph->bits != NULL) {
2738 XtSetArg( args[i], XtNbitmap, pixmap); i++;
2739 }
2740 else {
2741 XtSetArg( args[i], XtNbitmap, 0); i++;
2742 }
2743 XtSetArg( args[i], XtNresize, 1);i++;
2744 XtSetArg( args[i], XtNinternalWidth, 0); i++;
2745 XtSetArg( args[i], XtNinternalHeight, 0); i++;
2746 XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++;
2747 XtSetValues(OutputWindow ,args,i);
2748
2749 i=0;
2750 XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
2751 XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
2752 if (glyph->bits != NULL) {
2753 XtSetArg( args[i], XtNbitmap, pixmap); i++;
2754 }
2755 else {
2756 XtSetArg( args[i], XtNbitmap, 0); i++;
2757 }
2758 XtSetArg( args[i], XtNresize, 1);i++;
2759 XtSetArg( args[i], XtNinternalWidth, 0); i++;
2760 XtSetArg( args[i], XtNinternalHeight, 0); i++;
2761 XtSetValues(Output ,args,i);
2762
2763 glyph->bits=NULL; /* Since XDestroyImage() free's this also! */
2764 }
2765
2766
2767
aashowstring(Widget showstringbutton,XtPointer client_data,XtPointer call_data)2768 void aashowstring( Widget showstringbutton, XtPointer client_data, XtPointer call_data)
2769 {
2770 int i,j,k,l,m,none_found;
2771 Arg args[10];
2772 char *theString='\0';
2773 char *ligtheString='\0';
2774 char *succs, *ligs;
2775 char buf_char;
2776
2777
2778 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
2779 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
2780 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
2781 sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
2782 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
2783 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
2784
2785 if (FontID<0 || FontID>=T1_GetNoFonts()) {
2786 sprintf(statusstring, "t1lib: FontID out of range!");
2787 i=0;
2788 XtSetArg(args[i], XtNbitmap,NULL); i++;
2789 XtSetArg(args[i], XtNwidth,380); i++;
2790 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2791 XtSetArg(args[i], XtNlabel, statusstring); i++;
2792 XtSetValues(labelstatus,args,i);
2793 return;
2794 }
2795
2796 /* Ensure that font is loaded before any operation on the font */
2797 if ( T1_CheckForFontID( FontID) < 1 ) {
2798 T1_LoadFont( FontID);
2799 }
2800
2801 if ( StrokeWidth == 0.0f ) {
2802 T1_ClearStrokeFlag( FontID);
2803 }
2804 else {
2805 T1_SetStrokeFlag( FontID);
2806 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
2807 sprintf( statusstring, "t1lib: Unable to setup strokewidth");
2808 i=0;
2809 XtSetArg(args[i], XtNbitmap,NULL); i++;
2810 XtSetArg(args[i], XtNwidth,380); i++;
2811 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2812 XtSetArg(args[i], XtNlabel, statusstring); i++;
2813 XtSetValues(labelstatus,args,i);
2814 return;
2815 }
2816 }
2817
2818 if (CheckTransform()==0 && Angle==0.0){
2819 matrixP=NULL;
2820 }
2821 else{
2822 matrixP=T1_RotateMatrix( &matrix, Angle);
2823 }
2824
2825 if (DeviceResolution!=last_resolution[FontID]){
2826 /* Delete all size dependent data for that font */
2827 for ( i=0; i<T1_GetNoFonts(); i++)
2828 T1_DeleteAllSizes( i);
2829 /* Establish new device resolution */
2830 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
2831 /* Store current resolution */
2832 last_resolution[FontID]=DeviceResolution;
2833 }
2834 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
2835 if (i==EOF) EncodingFile[0]=0;
2836 if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
2837 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
2838 for (i=0; i<T1_GetNoFonts(); i++){
2839 T1_DeleteAllSizes(i);
2840 T1_ReencodeFont( i, NULL);
2841 }
2842 /* Take care that newly loaded fonts are encoded according to current
2843 encoding */
2844 T1_SetDefaultEncoding( NULL);
2845 }
2846 else{
2847 for (i=0; i<MAXENCODINGS; ){
2848 if ( encstruct[i].encfilename != NULL)
2849 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
2850 i++;
2851 break;
2852 }
2853 i++;
2854 }
2855 if (i==MAXENCODINGS){ /* Encoding from that file was not
2856 already loaded -> so load it */
2857 i=0;
2858 while (encstruct[i].encfilename != NULL)
2859 i++;
2860 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
2861 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
2862 if (encstruct[i].encoding==NULL){
2863 free( encstruct[i].encfilename);
2864 encstruct[i].encfilename=NULL;
2865 }
2866 i++;
2867 }
2868 for (j=0; j<T1_GetNoFonts(); j++){
2869 T1_DeleteAllSizes(j);
2870 T1_ReencodeFont( j, encstruct[i-1].encoding);
2871 }
2872 /* Take care that newly loaded fonts are encoded according to current
2873 encoding */
2874 T1_SetDefaultEncoding( encstruct[i-1].encoding);
2875 }
2876 strcpy( LastEncodingFile, EncodingFile);
2877 }
2878 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
2879 if (Slant!=lastSlant[FontID]){
2880 /* Delete all size dependent data */
2881 T1_DeleteAllSizes(FontID);
2882 T1_LoadFont(FontID);
2883 T1_SlantFont( FontID, Slant);
2884 lastSlant[FontID]=Slant;
2885 }
2886 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
2887 if (Extent!=lastExtent[FontID]){
2888 /* Delete all size dependent data */
2889 T1_DeleteAllSizes(FontID);
2890 T1_LoadFont(FontID);
2891 T1_ExtendFont( FontID, Extent);
2892 lastExtent[FontID]=Extent;
2893 }
2894
2895 i=0;
2896 XtSetArg(args[i], XtNstring, &theString); i++;
2897 XtGetValues(dialogteststring,args,i);
2898
2899 if (Size<=0.0){
2900 sprintf(statusstring, "t1lib: Size must be positive!");
2901 i=0;
2902 XtSetArg(args[i], XtNbitmap,NULL); i++;
2903 XtSetArg(args[i], XtNwidth,380); i++;
2904 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2905 XtSetArg(args[i], XtNlabel, statusstring); i++;
2906 XtSetValues(labelstatus,args,i);
2907 return;
2908 }
2909
2910 /* Now comes the ligatur handling */
2911 if (strcmp(theString,"")==0)
2912 theString=(char *) TestString;
2913 i=strlen(theString);
2914 ligtheString=(char *)malloc((i+1)*sizeof(char));
2915 if (LigDetect){
2916 for (j=0,m=0;j<i;j++,m++){ /* Loop through the characters */
2917 if ((k=T1_QueryLigs( FontID, theString[j], &succs, &ligs))>0){
2918 buf_char=theString[j];
2919 while (k>0){
2920 none_found=1;
2921 for (l=0;l<k;l++){ /* Loop through the ligatures */
2922 if (succs[l]==theString[j+1]){
2923 buf_char=ligs[l];
2924 j++;
2925 none_found=0;
2926 break;
2927 }
2928 }
2929 if (none_found)
2930 break;
2931 k=T1_QueryLigs( FontID, buf_char, &succs, &ligs);
2932 }
2933 ligtheString[m]=buf_char;
2934 }
2935 else{ /* There are no ligatures */
2936 ligtheString[m]=theString[j];
2937 }
2938 }
2939 ligtheString[m]=0;
2940 }
2941 else {
2942 strcpy(ligtheString,theString);
2943 }
2944
2945 /* Reset T1_errno: */
2946 T1_errno=0;
2947 /* Set antialiasing level */
2948 T1_AASetLevel( aalevel);
2949 /* Set the colors for Anti-Aliasing */
2950 T1_AASetGrayValues( aapixels[0], /* white */
2951 aapixels[4],
2952 aapixels[8],
2953 aapixels[12],
2954 aapixels[16] ); /* black */
2955 T1_AAHSetGrayValues( aapixels);
2956 T1_AANSetGrayValues( aapixels[0], aapixels[16]);
2957 gettimeofday(time_ptr_start, void_ptr);
2958
2959 if( extraflags & CHECK_CONCATGLYPHS){
2960 glyph2=T1_AASetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
2961 glyph1=T1_CopyGlyph( glyph2);
2962 glyph2=T1_AASetString(FontID+1,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
2963 glyph=T1_ConcatGlyphs( glyph1, glyph2, 0, 0, Modflag);
2964 }
2965 else if( extraflags & CHECK_CONCATOUTLINES){
2966 {
2967 T1_OUTLINE *path=NULL;
2968 path=T1_GetStringOutline(FontID,(char *)ligtheString,
2969 0,Space,Modflag,Size,matrixP);
2970 T1_ConcatOutlines( path,
2971 T1_GetMoveOutline( FontID, 1000, 0, Modflag, Size, matrixP));
2972 T1_ConcatOutlines( path,
2973 T1_GetStringOutline(FontID+1,(char *)ligtheString,
2974 0,Space,Modflag,Size,matrixP));
2975 glyph=T1_AAFillOutline( path, Modflag);
2976 }
2977 }
2978 else{
2979 glyph=T1_AASetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
2980 }
2981
2982 gettimeofday(time_ptr_stop, void_ptr);
2983
2984 free(ligtheString);
2985
2986
2987 if ( glyph == NULL){
2988 sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
2989 i=0;
2990 XtSetArg(args[i], XtNbitmap,NULL); i++;
2991 XtSetArg(args[i], XtNwidth,380); i++;
2992 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
2993 XtSetArg(args[i], XtNlabel, statusstring); i++;
2994 XtSetValues(labelstatus,args,i);
2995 return;
2996 }
2997
2998 height=glyph->metrics.ascent - glyph->metrics.descent;
2999 overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
3000 width=overallwidth;
3001
3002 /* Prepare status message: */
3003 sprintf(statusstring,"Elapsed time: %ld Microseconds\nLeftSideBearing: %d\nRightSideBearing: %d\nAscent: %d\nDescent: %d\nAdvanceX: %d\nAdvanceY: %d\nBits Per Pixel: %ld\nImage Size: %ld Bytes\nPostScript Fontname: %s\nT1_errno: %d\n",
3004 time_diff(time_ptr_start,time_ptr_stop),
3005 glyph->metrics.leftSideBearing,
3006 glyph->metrics.rightSideBearing,
3007 glyph->metrics.ascent,
3008 glyph->metrics.descent,
3009 glyph->metrics.advanceX,
3010 glyph->metrics.advanceY,
3011 glyph->bpp,
3012 PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
3013 T1_GetFontName(FontID),
3014 T1_errno);
3015
3016
3017 /*
3018 printf("glyph->bits=%u\n", glyph->bits);
3019 printf("glyph->metrics.leftSideBearing=%u\n", glyph->metrics.leftSideBearing);
3020 printf("glyph->metrics.rightSideBearing=%u\n", glyph->metrics.rightSideBearing);
3021 printf("glyph->metrics.advanceX=%u\n", glyph->metrics.advanceX);
3022 printf("glyph->metrics.ascent=%u\n", glyph->metrics.ascent);
3023 printf("glyph->metrics.descent=%u\n", glyph->metrics.descent);
3024 printf("glyph->pFontCacheInfo=%u\n", glyph->pFontCacheInfo);
3025 */
3026
3027 if (glyph->bits != NULL) {
3028 ximage=XCreateImage( display,
3029 DefaultVisual(display, screennumber),
3030 DefaultDepth(display,screennumber),
3031 ZPixmap, /* XYBitmap or XYPixmap */
3032 0, /* No offset */
3033 glyph->bits,
3034 width,
3035 height,
3036 t1_pad, /* lines padded to bytes */
3037 0 /* number of bytes per line */
3038 );
3039 ximage->byte_order=xglyph_byte_order;
3040 XFreePixmap(display,pixmap);
3041 pixmap = XCreatePixmap(display,
3042 XtWindow(TopLevel),
3043 width,
3044 height,
3045 DefaultDepth(display,screennumber)
3046 );
3047 XPutImage(display,
3048 pixmap,
3049 DefaultGC( display, screennumber),
3050 ximage,
3051 0,
3052 0,
3053 0,
3054 0,
3055 width,
3056 height
3057 );
3058 XDestroyImage(ximage);
3059 }
3060
3061 i=0;
3062 XtSetArg(args[i], XtNbitmap,NULL); i++;
3063 XtSetArg(args[i], XtNwidth,380); i++;
3064 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3065 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
3066 XtSetArg(args[i], XtNlabel, statusstring); i++;
3067 XtSetValues(labelstatus,args,i);
3068
3069 i=0;
3070 XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
3071 XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
3072 if (glyph->bits != NULL) {
3073 XtSetArg( args[i], XtNbitmap, pixmap); i++;
3074 }
3075 else {
3076 XtSetArg( args[i], XtNbitmap, 0); i++;
3077 }
3078 XtSetArg( args[i], XtNresize, 1);i++;
3079 XtSetArg( args[i], XtNinternalWidth, 0); i++;
3080 XtSetArg( args[i], XtNinternalHeight, 0); i++;
3081 XtSetArg( args[i], XtNbackground, WhitePixel( display, screennumber)); i++;
3082 XtSetValues(OutputWindow ,args,i);
3083
3084 i=0;
3085 XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
3086 XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
3087 if (glyph->bits != NULL) {
3088 XtSetArg( args[i], XtNbitmap, pixmap); i++;
3089 }
3090 else {
3091 XtSetArg( args[i], XtNbitmap, 0); i++;
3092 }
3093 XtSetArg( args[i], XtNresize, 1);i++;
3094 XtSetArg( args[i], XtNinternalWidth, 0); i++;
3095 XtSetArg( args[i], XtNinternalHeight, 0); i++;
3096 XtSetArg( args[i], XtNbackground, WhitePixel( display, screennumber)); i++;
3097 XtSetValues(Output ,args,i);
3098
3099 glyph->bits=NULL; /* Since XDestroyImage() free's this also! */
3100 }
3101
3102
3103
showcharX(Widget showcharbutton,XtPointer client_data,XtPointer call_data)3104 void showcharX( Widget showcharbutton, XtPointer client_data, XtPointer call_data)
3105 {
3106 int i, j;
3107 Arg args[10];
3108 int tmp_width, tmp_height;
3109
3110
3111 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
3112 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
3113 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
3114 sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
3115 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
3116 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
3117
3118 if (FontID<0 || FontID>=T1_GetNoFonts()) {
3119 sprintf(statusstring, "t1lib: FontID out of range!");
3120 i=0;
3121 XtSetArg(args[i], XtNbitmap,NULL); i++;
3122 XtSetArg(args[i], XtNwidth,380); i++;
3123 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3124 XtSetArg(args[i], XtNlabel, statusstring); i++;
3125 XtSetValues(labelstatus,args,i);
3126 return;
3127 }
3128
3129 /* Ensure that font is loaded before any operation on the font */
3130 if ( T1_CheckForFontID( FontID) < 1 ) {
3131 T1_LoadFont( FontID);
3132 }
3133
3134 if ( StrokeWidth == 0.0f ) {
3135 T1_ClearStrokeFlag( FontID);
3136 }
3137 else {
3138 T1_SetStrokeFlag( FontID);
3139 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
3140 sprintf( statusstring, "t1lib: Unable to setup strokewidth");
3141 i=0;
3142 XtSetArg(args[i], XtNbitmap,NULL); i++;
3143 XtSetArg(args[i], XtNwidth,380); i++;
3144 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3145 XtSetArg(args[i], XtNlabel, statusstring); i++;
3146 XtSetValues(labelstatus,args,i);
3147 return;
3148 }
3149 }
3150
3151 if (CheckTransform()==0 && Angle==0.0){
3152 matrixP=NULL;
3153 }
3154 else{
3155 matrixP=T1_RotateMatrix( &matrix, Angle);
3156 }
3157
3158 if (DeviceResolution!=last_resolution[FontID]){
3159 /* Delete all size dependent data for that font */
3160 for ( i=0; i<T1_GetNoFonts(); i++)
3161 T1_DeleteAllSizes( i);
3162 /* Establish new device resolution */
3163 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
3164 /* Store current resolution */
3165 last_resolution[FontID]=DeviceResolution;
3166 }
3167 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
3168 if (i==EOF) EncodingFile[0]=0;
3169 if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
3170 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
3171 for (i=0; i<T1_GetNoFonts(); i++){
3172 T1_DeleteAllSizes(i);
3173 T1_ReencodeFont( i, NULL);
3174 }
3175 /* Take care that newly loaded fonts are encoded according to current
3176 encoding */
3177 T1_SetDefaultEncoding( NULL);
3178 }
3179 else{
3180 for (i=0; i<MAXENCODINGS; ){
3181 if ( encstruct[i].encfilename != NULL)
3182 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
3183 i++;
3184 break;
3185 }
3186 i++;
3187 }
3188 if (i==MAXENCODINGS){ /* Encoding from that file was not
3189 already loaded -> so load it */
3190 i=0;
3191 while (encstruct[i].encfilename != NULL)
3192 i++;
3193 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
3194 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
3195 if (encstruct[i].encoding==NULL){
3196 free( encstruct[i].encfilename);
3197 encstruct[i].encfilename=NULL;
3198 }
3199 i++;
3200 }
3201 for (j=0; j<T1_GetNoFonts(); j++){
3202 T1_DeleteAllSizes(j);
3203 T1_ReencodeFont( j, encstruct[i-1].encoding);
3204 }
3205 /* Take care that newly loaded fonts are encoded according to current
3206 encoding */
3207 T1_SetDefaultEncoding( encstruct[i-1].encoding);
3208 }
3209 strcpy( LastEncodingFile, EncodingFile);
3210 }
3211 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
3212 if (Slant!=lastSlant[FontID]){
3213 /* Delete all size dependent data */
3214 T1_DeleteAllSizes(FontID);
3215 T1_LoadFont(FontID);
3216 T1_SlantFont( FontID, Slant);
3217 lastSlant[FontID]=Slant;
3218 }
3219 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
3220 if (Extent!=lastExtent[FontID]){
3221 /* Delete all size dependent data */
3222 T1_DeleteAllSizes(FontID);
3223 T1_LoadFont(FontID);
3224 T1_ExtendFont( FontID, Extent);
3225 lastExtent[FontID]=Extent;
3226 }
3227
3228 if (Size<=0.0){
3229 sprintf(statusstring, "t1lib: Size must be positive!");
3230 i=0;
3231 XtSetArg(args[i], XtNbitmap,NULL); i++;
3232 XtSetArg(args[i], XtNwidth,380); i++;
3233 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3234 XtSetArg(args[i], XtNlabel, statusstring); i++;
3235 XtSetValues(labelstatus,args,i);
3236 return;
3237 }
3238
3239 tmp_width=2 * XOUTPUT_HALFHSIZE;
3240 tmp_height=2 * XOUTPUT_HALFVSIZE;
3241
3242 if (tmp_pixmap==0)
3243 tmp_pixmap=XCreatePixmap( display,
3244 XtWindow(TopLevel),
3245 tmp_width,
3246 tmp_height,
3247 depth
3248 );
3249 /* Put some background in pixmap for demonstration of transparent-mode: */
3250 if (Opacity==0){
3251 XSetForeground( display, DefaultGC( display, screennumber), pink4.pixel);
3252 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3253 0, 0, tmp_width, tmp_height);
3254 XSetForeground( display, DefaultGC( display, screennumber), yellow.pixel);
3255 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3256 tmp_width/4, tmp_height/4, tmp_width/2, tmp_height/2);
3257 XSetForeground( display, DefaultGC( display, screennumber), fg);
3258 }
3259 else{
3260 XSetForeground( display, DefaultGC( display, screennumber), bg);
3261 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3262 0, 0, tmp_width, tmp_height);
3263 }
3264 XSetForeground( display, DefaultGC( display, screennumber), fg);
3265 XSetBackground( display, DefaultGC( display, screennumber), bg);
3266 /* Synchronize display in order to make the time measurement more acurate */
3267 XSync( display, True);
3268 /* Reset T1_errno: */
3269 T1_errno=0;
3270 gettimeofday(time_ptr_start, void_ptr);
3271 if ( extraflags & CHECK_SET_RECT )
3272 glyph=T1_SetRectX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
3273 XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
3274 FontID, Size, 1000.0, 1000.0, matrixP);
3275 else
3276 glyph=T1_SetCharX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
3277 XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
3278 FontID, TestChar, Size, matrixP);
3279 gettimeofday(time_ptr_stop, void_ptr);
3280
3281 if ((extraflags & NO_GRID)==0){
3282 XSetForeground( display, DefaultGC( display, screennumber), gridcolor1.pixel);
3283 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3284 XOUTPUT_HALFHSIZE, 0, /* X1, Y1 */
3285 XOUTPUT_HALFHSIZE, 2 * XOUTPUT_HALFVSIZE);
3286 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3287 0, XOUTPUT_HALFVSIZE, /* X1, Y1 */
3288 2 * XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE);
3289 XSetForeground( display, DefaultGC( display, screennumber), gridcolor2.pixel);
3290 if (glyph!=NULL){
3291 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3292 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX - CROSS_SIZE,
3293 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY,
3294 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE,
3295 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY);
3296 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3297 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
3298 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE,
3299 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
3300 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE);
3301 }
3302 }
3303 XSetForeground( display, DefaultGC( display, screennumber), fg);
3304
3305 /* Check for errors */
3306 if (glyph==NULL) {
3307 sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
3308 i=0;
3309 XtSetArg(args[i], XtNbitmap,NULL); i++;
3310 XtSetArg(args[i], XtNwidth,380); i++;
3311 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3312 XtSetArg(args[i], XtNlabel, statusstring); i++;
3313 XtSetValues(labelstatus,args,i);
3314 return;
3315 }
3316
3317 /* Prepare status message: */
3318 sprintf(statusstring,"Elapsed time: %ld Microseconds\nLeftSideBearing: %d\nRightSideBearing: %d\nAscent: %d\nDescent: %d\nAdvanceX: %d\nAdvanceY: %d\nBits Per Pixel: %ld\nImage Size: %ld Bytes\nPostScript Fontname: %s\nCharactername: %s\nT1_errno: %d\n",
3319 time_diff(time_ptr_start,time_ptr_stop),
3320 glyph->metrics.leftSideBearing,
3321 glyph->metrics.rightSideBearing,
3322 glyph->metrics.ascent,
3323 glyph->metrics.descent,
3324 glyph->metrics.advanceX,
3325 glyph->metrics.advanceY,
3326 glyph->bpp,
3327 PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
3328 T1_GetFontName(FontID),
3329 T1_GetCharName(FontID,(char)TestChar),
3330 T1_errno);
3331
3332 /* Finally, set the resources: */
3333 i=0;
3334 XtSetArg(args[i], XtNbitmap,NULL); i++;
3335 XtSetArg(args[i], XtNwidth,380); i++;
3336 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3337 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
3338 XtSetArg(args[i], XtNlabel, statusstring); i++;
3339 XtSetValues(labelstatus,args,i);
3340
3341 i=0;
3342 XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
3343 XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
3344 XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
3345 XtSetArg( args[i], XtNresize, 1);i++;
3346 XtSetArg( args[i], XtNinternalWidth, 0); i++;
3347 XtSetArg( args[i], XtNinternalHeight, 0); i++;
3348 XtSetArg( args[i], XtNbackground, outbg); i++;
3349 XtSetValues(OutputWindow ,args,i);
3350
3351 i=0;
3352 XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
3353 XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
3354 XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
3355 XtSetArg( args[i], XtNresize, 1);i++;
3356 XtSetArg( args[i], XtNinternalWidth, 0); i++;
3357 XtSetArg( args[i], XtNinternalHeight, 0); i++;
3358 XtSetValues(Output ,args,i);
3359
3360 }
3361
3362
3363
showstringX(Widget showstringbutton,XtPointer client_data,XtPointer call_data)3364 void showstringX( Widget showstringbutton, XtPointer client_data, XtPointer call_data)
3365 {
3366 int i,j,k,l,m,none_found;
3367 Arg args[10];
3368 int tmp_width, tmp_height;
3369
3370 char *theString='\0';
3371 char *ligtheString='\0';
3372 char *succs, *ligs;
3373 char buf_char;
3374
3375
3376 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
3377 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
3378 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
3379 sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
3380 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
3381 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
3382
3383 if (FontID<0 || FontID>=T1_GetNoFonts()) {
3384 sprintf(statusstring, "t1lib: FontID out of range!");
3385 i=0;
3386 XtSetArg(args[i], XtNbitmap,NULL); i++;
3387 XtSetArg(args[i], XtNwidth,380); i++;
3388 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3389 XtSetArg(args[i], XtNlabel, statusstring); i++;
3390 XtSetValues(labelstatus,args,i);
3391 return;
3392 }
3393
3394 /* Ensure that font is loaded before any operation on the font */
3395 if ( T1_CheckForFontID( FontID) < 1 ) {
3396 T1_LoadFont( FontID);
3397 }
3398
3399 if ( StrokeWidth == 0.0f ) {
3400 T1_ClearStrokeFlag( FontID);
3401 }
3402 else {
3403 T1_SetStrokeFlag( FontID);
3404 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
3405 sprintf( statusstring, "t1lib: Unable to setup strokewidth");
3406 i=0;
3407 XtSetArg(args[i], XtNbitmap,NULL); i++;
3408 XtSetArg(args[i], XtNwidth,380); i++;
3409 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3410 XtSetArg(args[i], XtNlabel, statusstring); i++;
3411 XtSetValues(labelstatus,args,i);
3412 return;
3413 }
3414 }
3415
3416 if (CheckTransform()==0 && Angle==0.0){
3417 matrixP=NULL;
3418 }
3419 else{
3420 matrixP=T1_RotateMatrix( &matrix, Angle);
3421 }
3422
3423 if (DeviceResolution!=last_resolution[FontID]){
3424 /* Delete all size dependent data for that font */
3425 for ( i=0; i<T1_GetNoFonts(); i++)
3426 T1_DeleteAllSizes( i);
3427 /* Establish new device resolution */
3428 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
3429 /* Store current resolution */
3430 last_resolution[FontID]=DeviceResolution;
3431 }
3432 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
3433 if (i==EOF) EncodingFile[0]=0;
3434 if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
3435 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
3436 for (i=0; i<T1_GetNoFonts(); i++){
3437 T1_DeleteAllSizes(i);
3438 T1_ReencodeFont( i, NULL);
3439 }
3440 /* Take care that newly loaded fonts are encoded according to current
3441 encoding */
3442 T1_SetDefaultEncoding( NULL);
3443 }
3444 else{
3445 for (i=0; i<MAXENCODINGS; ){
3446 if ( encstruct[i].encfilename != NULL)
3447 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
3448 i++;
3449 break;
3450 }
3451 i++;
3452 }
3453 if (i==MAXENCODINGS){ /* Encoding from that file was not
3454 already loaded -> so load it */
3455 i=0;
3456 while (encstruct[i].encfilename != NULL)
3457 i++;
3458 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
3459 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
3460 if (encstruct[i].encoding==NULL){
3461 free( encstruct[i].encfilename);
3462 encstruct[i].encfilename=NULL;
3463 }
3464 i++;
3465 }
3466 for (j=0; j<T1_GetNoFonts(); j++){
3467 T1_DeleteAllSizes(j);
3468 T1_ReencodeFont( j, encstruct[i-1].encoding);
3469 }
3470 /* Take care that newly loaded fonts are encoded according to current
3471 encoding */
3472 T1_SetDefaultEncoding( encstruct[i-1].encoding);
3473 }
3474 strcpy( LastEncodingFile, EncodingFile);
3475 }
3476 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
3477 if (Slant!=lastSlant[FontID]){
3478 /* Delete all size dependent data */
3479 T1_DeleteAllSizes(FontID);
3480 T1_LoadFont(FontID);
3481 T1_SlantFont( FontID, Slant);
3482 lastSlant[FontID]=Slant;
3483 }
3484 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
3485 if (Extent!=lastExtent[FontID]){
3486 /* Delete all size dependent data */
3487 T1_DeleteAllSizes(FontID);
3488 T1_LoadFont(FontID);
3489 T1_ExtendFont( FontID, Extent);
3490 lastExtent[FontID]=Extent;
3491 }
3492
3493 i=0;
3494 XtSetArg(args[i], XtNstring, &theString); i++;
3495 XtGetValues(dialogteststring,args,i);
3496
3497 if (Size<=0.0){
3498 sprintf(statusstring, "t1lib: Size must be positive!");
3499 i=0;
3500 XtSetArg(args[i], XtNbitmap,NULL); i++;
3501 XtSetArg(args[i], XtNwidth,380); i++;
3502 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3503 XtSetArg(args[i], XtNlabel, statusstring); i++;
3504 XtSetValues(labelstatus,args,i);
3505 return;
3506 }
3507
3508 /* Now comes the ligatur handling */
3509 if (strcmp(theString,"")==0)
3510 theString=(char *) TestString;
3511 i=strlen(theString);
3512 ligtheString=(char *)malloc((i+1)*sizeof(char));
3513 if (LigDetect){
3514 for (j=0,m=0;j<i;j++,m++){ /* Loop through the characters */
3515 if ((k=T1_QueryLigs( FontID, theString[j], &succs, &ligs))>0){
3516 buf_char=theString[j];
3517 while (k>0){
3518 none_found=1;
3519 for (l=0;l<k;l++){ /* Loop through the ligatures */
3520 if (succs[l]==theString[j+1]){
3521 buf_char=ligs[l];
3522 j++;
3523 none_found=0;
3524 break;
3525 }
3526 }
3527 if (none_found)
3528 break;
3529 k=T1_QueryLigs( FontID, buf_char, &succs, &ligs);
3530 }
3531 ligtheString[m]=buf_char;
3532 }
3533 else{ /* There are no ligatures */
3534 ligtheString[m]=theString[j];
3535 }
3536 }
3537 ligtheString[m]=0;
3538 }
3539 else {
3540 strcpy(ligtheString,theString);
3541 }
3542
3543 tmp_width=2 * XOUTPUT_HALFHSIZE;
3544 tmp_height=2 * XOUTPUT_HALFVSIZE;
3545
3546 if (tmp_pixmap==0)
3547 tmp_pixmap=XCreatePixmap( display,
3548 XtWindow(TopLevel),
3549 tmp_width,
3550 tmp_height,
3551 depth
3552 );
3553 /* Put some background in pixmap for demonstration of transparent-mode: */
3554 if (Opacity==0){
3555 XSetForeground( display, DefaultGC( display, screennumber), pink4.pixel);
3556 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3557 0, 0, tmp_width, tmp_height);
3558 XSetForeground( display, DefaultGC( display, screennumber), yellow.pixel);
3559 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3560 tmp_width/4, tmp_height/4, tmp_width/2, tmp_height/2);
3561 XSetForeground( display, DefaultGC( display, screennumber), fg);
3562 }
3563 else{
3564 XSetForeground( display, DefaultGC( display, screennumber), bg);
3565 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3566 0, 0, tmp_width, tmp_height);
3567 }
3568 XSetForeground( display, DefaultGC( display, screennumber), fg);
3569 XSetBackground( display, DefaultGC( display, screennumber), bg);
3570 /* Synchronize display in order to make the time measurement more acurate */
3571 XSync( display, True);
3572 /* Reset T1_errno: */
3573 T1_errno=0;
3574 /* Draw the string into temporary pixmap */
3575 gettimeofday(time_ptr_start, void_ptr);
3576
3577 if( extraflags & CHECK_PERFORMANCE){
3578 j=0;
3579 for (i=0; j<600; i++){
3580 j=(int)(Size*1.2*i);
3581 glyph=T1_SetStringX( XtWindow(OutputWindow2), DefaultGC( display, screennumber), Opacity,
3582 0, j, /* x_dest, y_dest */
3583 FontID, (char *)ligtheString,
3584 0, Space, Modflag, Size, matrixP);
3585 }
3586 }
3587 else{
3588 glyph=T1_SetStringX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
3589 XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE,
3590 FontID, (char *)ligtheString,
3591 0, Space, Modflag, Size, matrixP);
3592 }
3593
3594 gettimeofday(time_ptr_stop, void_ptr);
3595
3596 if ((extraflags & NO_GRID)==0){
3597 XSetForeground( display, DefaultGC( display, screennumber), gridcolor1.pixel);
3598 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3599 XOUTPUT_HALFHSIZE, 0, /* X1, Y1 */
3600 XOUTPUT_HALFHSIZE, 2 * XOUTPUT_HALFVSIZE);
3601 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3602 0, XOUTPUT_HALFVSIZE, /* X1, Y1 */
3603 2 * XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE);
3604 XSetForeground( display, DefaultGC( display, screennumber), gridcolor2.pixel);
3605 if (glyph!=NULL){
3606 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3607 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX - CROSS_SIZE,
3608 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY,
3609 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE,
3610 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY);
3611 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3612 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
3613 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE,
3614 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
3615 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE);
3616 }
3617 }
3618
3619 XSetForeground( display, DefaultGC( display, screennumber), fg);
3620
3621 /* Free the ligature-converted string */
3622 free(ligtheString);
3623
3624 /* Check for errors */
3625 if (glyph==NULL) {
3626 sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
3627 i=0;
3628 XtSetArg(args[i], XtNbitmap,NULL); i++;
3629 XtSetArg(args[i], XtNwidth,380); i++;
3630 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3631 XtSetArg(args[i], XtNlabel, statusstring); i++;
3632 XtSetValues(labelstatus,args,i);
3633 return;
3634 }
3635
3636 /* Prepare status message: */
3637 sprintf(statusstring,"Elapsed time: %ld Microseconds\nLeftSideBearing: %d\nRightSideBearing: %d\nAscent: %d\nDescent: %d\nAdvanceX: %d\nAdvanceY: %d\nBits Per Pixel: %ld\nImage Size: %ld Bytes\nPostScript Fontname: %s\nT1_errno: %d\n",
3638 time_diff(time_ptr_start,time_ptr_stop),
3639 glyph->metrics.leftSideBearing,
3640 glyph->metrics.rightSideBearing,
3641 glyph->metrics.ascent,
3642 glyph->metrics.descent,
3643 glyph->metrics.advanceX,
3644 glyph->metrics.advanceY,
3645 glyph->bpp,
3646 PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
3647 T1_GetFontName(FontID),
3648 T1_errno);
3649
3650
3651 /* Finally, set resources */
3652 i=0;
3653 XtSetArg(args[i], XtNbitmap,NULL); i++;
3654 XtSetArg(args[i], XtNwidth,380); i++;
3655 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3656 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
3657 XtSetArg(args[i], XtNlabel, statusstring); i++;
3658 XtSetValues(labelstatus,args,i);
3659
3660 i=0;
3661 XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
3662 XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
3663 XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
3664 XtSetArg( args[i], XtNresize, 1);i++;
3665 XtSetArg( args[i], XtNinternalWidth, 0); i++;
3666 XtSetArg( args[i], XtNinternalHeight, 0); i++;
3667 XtSetArg( args[i], XtNbackground, outbg); i++;
3668 XtSetValues(OutputWindow ,args,i);
3669
3670 i=0;
3671 XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
3672 XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
3673 XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
3674 XtSetArg( args[i], XtNresize, 1);i++;
3675 XtSetArg( args[i], XtNinternalWidth, 0); i++;
3676 XtSetArg( args[i], XtNinternalHeight, 0); i++;
3677 XtSetArg( args[i], XtNbackground, outbg); i++;
3678 XtSetValues(Output ,args,i);
3679
3680 }
3681
3682
3683
aashowcharX(Widget showcharbutton,XtPointer client_data,XtPointer call_data)3684 void aashowcharX( Widget showcharbutton, XtPointer client_data, XtPointer call_data)
3685 {
3686 int i, j;
3687 Arg args[10];
3688 int tmp_width, tmp_height;
3689
3690
3691 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
3692 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
3693 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
3694 sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
3695 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
3696 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
3697
3698 if (FontID<0 || FontID>=T1_GetNoFonts()) {
3699 sprintf(statusstring, "t1lib: FontID out of range!");
3700 i=0;
3701 XtSetArg(args[i], XtNbitmap,NULL); i++;
3702 XtSetArg(args[i], XtNwidth,380); i++;
3703 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3704 XtSetArg(args[i], XtNlabel, statusstring); i++;
3705 XtSetValues(labelstatus,args,i);
3706 return;
3707 }
3708
3709 /* Ensure that font is loaded before any operation on the font */
3710 if ( T1_CheckForFontID( FontID) < 1 ) {
3711 T1_LoadFont( FontID);
3712 }
3713
3714 if ( StrokeWidth == 0.0f ) {
3715 T1_ClearStrokeFlag( FontID);
3716 }
3717 else {
3718 T1_SetStrokeFlag( FontID);
3719 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
3720 sprintf( statusstring, "t1lib: Unable to setup strokewidth");
3721 i=0;
3722 XtSetArg(args[i], XtNbitmap,NULL); i++;
3723 XtSetArg(args[i], XtNwidth,380); i++;
3724 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3725 XtSetArg(args[i], XtNlabel, statusstring); i++;
3726 XtSetValues(labelstatus,args,i);
3727 return;
3728 }
3729 }
3730
3731 if (CheckTransform()==0 && Angle==0.0){
3732 matrixP=NULL;
3733 }
3734 else{
3735 matrixP=T1_RotateMatrix( &matrix, Angle);
3736 }
3737
3738 if (DeviceResolution!=last_resolution[FontID]){
3739 /* Delete all size dependent data for that font */
3740 for ( i=0; i<T1_GetNoFonts(); i++)
3741 T1_DeleteAllSizes( i);
3742 /* Establish new device resolution */
3743 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
3744 /* Store current resolution */
3745 last_resolution[FontID]=DeviceResolution;
3746 }
3747 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
3748 if (i==EOF) EncodingFile[0]=0;
3749 if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
3750 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
3751 for (i=0; i<T1_GetNoFonts(); i++){
3752 T1_DeleteAllSizes(i);
3753 T1_ReencodeFont( i, NULL);
3754 }
3755 /* Take care that newly loaded fonts are encoded according to current
3756 encoding */
3757 T1_SetDefaultEncoding( NULL);
3758 }
3759 else{
3760 for (i=0; i<MAXENCODINGS; ){
3761 if ( encstruct[i].encfilename != NULL)
3762 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
3763 i++;
3764 break;
3765 }
3766 i++;
3767 }
3768 if (i==MAXENCODINGS){ /* Encoding from that file was not
3769 already loaded -> so load it */
3770 i=0;
3771 while (encstruct[i].encfilename != NULL)
3772 i++;
3773 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
3774 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
3775 if (encstruct[i].encoding==NULL){
3776 free( encstruct[i].encfilename);
3777 encstruct[i].encfilename=NULL;
3778 }
3779 i++;
3780 }
3781 for (j=0; j<T1_GetNoFonts(); j++){
3782 T1_DeleteAllSizes(j);
3783 T1_ReencodeFont( j, encstruct[i-1].encoding);
3784 }
3785 /* Take care that newly loaded fonts are encoded according to current
3786 encoding */
3787 T1_SetDefaultEncoding( encstruct[i-1].encoding);
3788 }
3789 strcpy( LastEncodingFile, EncodingFile);
3790 }
3791 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
3792 if (Slant!=lastSlant[FontID]){
3793 /* Delete all size dependent data */
3794 T1_DeleteAllSizes(FontID);
3795 T1_LoadFont(FontID);
3796 T1_SlantFont( FontID, Slant);
3797 lastSlant[FontID]=Slant;
3798 }
3799 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
3800 if (Extent!=lastExtent[FontID]){
3801 /* Delete all size dependent data */
3802 T1_DeleteAllSizes(FontID);
3803 T1_LoadFont(FontID);
3804 T1_ExtendFont( FontID, Extent);
3805 lastExtent[FontID]=Extent;
3806 }
3807
3808 if (Size<=0.0){
3809 sprintf(statusstring, "t1lib: Size must be positive!");
3810 i=0;
3811 XtSetArg(args[i], XtNbitmap,NULL); i++;
3812 XtSetArg(args[i], XtNwidth,380); i++;
3813 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3814 XtSetArg(args[i], XtNlabel, statusstring); i++;
3815 XtSetValues(labelstatus,args,i);
3816 return;
3817 }
3818
3819 tmp_width=2 * XOUTPUT_HALFHSIZE;
3820 tmp_height=2 * XOUTPUT_HALFVSIZE;
3821
3822 if (tmp_pixmap==0)
3823 tmp_pixmap=XCreatePixmap( display,
3824 XtWindow(TopLevel),
3825 tmp_width,
3826 tmp_height,
3827 depth
3828 );
3829 /* Put some background in pixmap for demonstration of transparent-mode: */
3830 if (Opacity==0){
3831 XSetForeground( display, DefaultGC( display, screennumber), pink4.pixel);
3832 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3833 0, 0, tmp_width, tmp_height);
3834 XSetForeground( display, DefaultGC( display, screennumber), yellow.pixel);
3835 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3836 tmp_width/4, tmp_height/4, tmp_width/2, tmp_height/2);
3837 XSetForeground( display, DefaultGC( display, screennumber), fg);
3838 }
3839 else{
3840 XSetForeground( display, DefaultGC( display, screennumber), bg);
3841 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
3842 0, 0, tmp_width, tmp_height);
3843 }
3844 XSetForeground( display, DefaultGC( display, screennumber), fg);
3845 XSetBackground( display, DefaultGC( display, screennumber), bg);
3846 /* Synchronize display in order to make the time measurement more acurate */
3847 XSync( display, True);
3848 /* Reset T1_errno: */
3849 T1_errno=0;
3850 /* Set antialiasing level */
3851 T1_AASetLevel( aalevel);
3852 gettimeofday(time_ptr_start, void_ptr);
3853 if ( extraflags & CHECK_SET_RECT )
3854 glyph=T1_AASetRectX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
3855 XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
3856 FontID, Size, 1000.0, 1000.0, matrixP);
3857 else
3858 glyph=T1_AASetCharX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
3859 XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
3860 FontID, TestChar, Size, matrixP);
3861 gettimeofday(time_ptr_stop, void_ptr);
3862
3863 if ((extraflags & NO_GRID)==0){
3864 XSetForeground( display, DefaultGC( display, screennumber), gridcolor1.pixel);
3865 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3866 XOUTPUT_HALFHSIZE, 0, /* X1, Y1 */
3867 XOUTPUT_HALFHSIZE, 2 * XOUTPUT_HALFVSIZE);
3868 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3869 0, XOUTPUT_HALFVSIZE, /* X1, Y1 */
3870 2 * XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE);
3871 XSetForeground( display, DefaultGC( display, screennumber), gridcolor2.pixel);
3872 if (glyph!=NULL){
3873 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3874 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX - CROSS_SIZE,
3875 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY,
3876 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE,
3877 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY);
3878 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
3879 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
3880 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE,
3881 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
3882 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE);
3883 }
3884 }
3885
3886 XSetForeground( display, DefaultGC( display, screennumber), fg);
3887
3888 /* Check for errors */
3889 if (glyph==NULL) {
3890 sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
3891 i=0;
3892 XtSetArg(args[i], XtNbitmap,NULL); i++;
3893 XtSetArg(args[i], XtNwidth,380); i++;
3894 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3895 XtSetArg(args[i], XtNlabel, statusstring); i++;
3896 XtSetValues(labelstatus,args,i);
3897 return;
3898 }
3899
3900 /* Prepare status message: */
3901 sprintf(statusstring,"Elapsed time: %ld Microseconds\nLeftSideBearing: %d\nRightSideBearing: %d\nAscent: %d\nDescent: %d\nAdvanceX: %d\nAdvanceY: %d\nBits Per Pixel: %ld\nImage Size: %ld Bytes\nPostScript Fontname: %s\nCharactername: %s\nT1_errno: %d\n",
3902 time_diff(time_ptr_start,time_ptr_stop),
3903 glyph->metrics.leftSideBearing,
3904 glyph->metrics.rightSideBearing,
3905 glyph->metrics.ascent,
3906 glyph->metrics.descent,
3907 glyph->metrics.advanceX,
3908 glyph->metrics.advanceY,
3909 glyph->bpp,
3910 PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
3911 T1_GetFontName(FontID),
3912 T1_GetCharName(FontID,(char)TestChar),
3913 T1_errno);
3914
3915 /* Finally, set the resources: */
3916 i=0;
3917 XtSetArg(args[i], XtNbitmap,NULL); i++;
3918 XtSetArg(args[i], XtNwidth,380); i++;
3919 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3920 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
3921 XtSetArg(args[i], XtNlabel, statusstring); i++;
3922 XtSetValues(labelstatus,args,i);
3923
3924 i=0;
3925 XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
3926 XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
3927 XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
3928 XtSetArg( args[i], XtNresize, 1);i++;
3929 XtSetArg( args[i], XtNinternalWidth, 0); i++;
3930 XtSetArg( args[i], XtNinternalHeight, 0); i++;
3931 XtSetArg( args[i], XtNbackground, outbg); i++;
3932 XtSetValues(OutputWindow ,args,i);
3933
3934 i=0;
3935 XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
3936 XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
3937 XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
3938 XtSetArg( args[i], XtNresize, 1);i++;
3939 XtSetArg( args[i], XtNinternalWidth, 0); i++;
3940 XtSetArg( args[i], XtNinternalHeight, 0); i++;
3941 XtSetValues(Output ,args,i);
3942
3943 }
3944
3945
3946
aashowstringX(Widget showstringbutton,XtPointer client_data,XtPointer call_data)3947 void aashowstringX( Widget showstringbutton, XtPointer client_data, XtPointer call_data)
3948 {
3949 int i,j,k,l,m,none_found;
3950 Arg args[10];
3951 int tmp_width, tmp_height;
3952
3953 char *theString='\0';
3954 char *ligtheString='\0';
3955 char *succs, *ligs;
3956 char buf_char;
3957
3958
3959 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
3960 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
3961 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
3962 sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
3963 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
3964 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
3965
3966 if (FontID<0 || FontID>=T1_GetNoFonts()) {
3967 sprintf(statusstring, "t1lib: FontID out of range!");
3968 i=0;
3969 XtSetArg(args[i], XtNbitmap,NULL); i++;
3970 XtSetArg(args[i], XtNwidth,380); i++;
3971 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3972 XtSetArg(args[i], XtNlabel, statusstring); i++;
3973 XtSetValues(labelstatus,args,i);
3974 return;
3975 }
3976
3977 /* Ensure that font is loaded before any operation on the font */
3978 if ( T1_CheckForFontID( FontID) < 1 ) {
3979 T1_LoadFont( FontID);
3980 }
3981
3982 if ( StrokeWidth == 0.0f ) {
3983 T1_ClearStrokeFlag( FontID);
3984 }
3985 else {
3986 T1_SetStrokeFlag( FontID);
3987 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
3988 sprintf( statusstring, "t1lib: Unable to setup strokewidth");
3989 i=0;
3990 XtSetArg(args[i], XtNbitmap,NULL); i++;
3991 XtSetArg(args[i], XtNwidth,380); i++;
3992 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
3993 XtSetArg(args[i], XtNlabel, statusstring); i++;
3994 XtSetValues(labelstatus,args,i);
3995 return;
3996 }
3997 }
3998
3999 if (CheckTransform()==0 && Angle==0.0){
4000 matrixP=NULL;
4001 }
4002 else{
4003 matrixP=T1_RotateMatrix( &matrix, Angle);
4004 }
4005
4006 if (DeviceResolution!=last_resolution[FontID]){
4007 /* Delete all size dependent data for that font */
4008 for ( i=0; i<T1_GetNoFonts(); i++)
4009 T1_DeleteAllSizes( i);
4010 /* Establish new device resolution */
4011 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
4012 /* Store current resolution */
4013 last_resolution[FontID]=DeviceResolution;
4014 }
4015 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
4016 if (i==EOF) EncodingFile[0]=0;
4017 if (strcmp(EncodingFile,LastEncodingFile)!=0){ /* encoding has changed */
4018 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
4019 for (i=0; i<T1_GetNoFonts(); i++){
4020 T1_DeleteAllSizes(i);
4021 T1_ReencodeFont( i, NULL);
4022 }
4023 /* Take care that newly loaded fonts are encoded according to current
4024 encoding */
4025 T1_SetDefaultEncoding( NULL);
4026 }
4027 else{
4028 for (i=0; i<MAXENCODINGS; ){
4029 if ( encstruct[i].encfilename != NULL)
4030 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
4031 i++;
4032 break;
4033 }
4034 i++;
4035 }
4036 if (i==MAXENCODINGS){ /* Encoding from that file was not
4037 already loaded -> so load it */
4038 i=0;
4039 while (encstruct[i].encfilename != NULL)
4040 i++;
4041 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
4042 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
4043 if (encstruct[i].encoding==NULL){
4044 free( encstruct[i].encfilename);
4045 encstruct[i].encfilename=NULL;
4046 }
4047 i++;
4048 }
4049 else
4050 for (j=0; j<T1_GetNoFonts(); j++){
4051 T1_DeleteAllSizes(j);
4052 T1_ReencodeFont( j, encstruct[i-1].encoding);
4053 }
4054 /* Take care that newly loaded fonts are encoded according to current
4055 encoding */
4056 T1_SetDefaultEncoding( encstruct[i-1].encoding);
4057 }
4058 strcpy( LastEncodingFile, EncodingFile);
4059 }
4060 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
4061 if (Slant!=lastSlant[FontID]){
4062 /* Delete all size dependent data */
4063 T1_DeleteAllSizes(FontID);
4064 T1_LoadFont(FontID);
4065 T1_SlantFont( FontID, Slant);
4066 lastSlant[FontID]=Slant;
4067 }
4068 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
4069 if (Extent!=lastExtent[FontID]){
4070 /* Delete all size dependent data */
4071 T1_DeleteAllSizes(FontID);
4072 T1_LoadFont(FontID);
4073 T1_ExtendFont( FontID, Extent);
4074 lastExtent[FontID]=Extent;
4075 }
4076
4077 i=0;
4078 XtSetArg(args[i], XtNstring, &theString); i++;
4079 XtGetValues(dialogteststring,args,i);
4080
4081 if (Size<=0.0){
4082 sprintf(statusstring, "t1lib: Size must be positive!");
4083 i=0;
4084 XtSetArg(args[i], XtNbitmap,NULL); i++;
4085 XtSetArg(args[i], XtNwidth,380); i++;
4086 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
4087 XtSetArg(args[i], XtNlabel, statusstring); i++;
4088 XtSetValues(labelstatus,args,i);
4089 return;
4090 }
4091
4092 /* Now comes the ligatur handling */
4093 if (strcmp(theString,"")==0)
4094 theString=(char *) TestString;
4095 i=strlen(theString);
4096 ligtheString=(char *)malloc((i+1)*sizeof(char));
4097 if (LigDetect){
4098 for (j=0,m=0;j<i;j++,m++){ /* Loop through the characters */
4099 if ((k=T1_QueryLigs( FontID, theString[j], &succs, &ligs))>0){
4100 buf_char=theString[j];
4101 while (k>0){
4102 none_found=1;
4103 for (l=0;l<k;l++){ /* Loop through the ligatures */
4104 if (succs[l]==theString[j+1]){
4105 buf_char=ligs[l];
4106 j++;
4107 none_found=0;
4108 break;
4109 }
4110 }
4111 if (none_found)
4112 break;
4113 k=T1_QueryLigs( FontID, buf_char, &succs, &ligs);
4114 }
4115 ligtheString[m]=buf_char;
4116 }
4117 else{ /* There are no ligatures */
4118 ligtheString[m]=theString[j];
4119 }
4120 }
4121 ligtheString[m]=0;
4122 }
4123 else {
4124 strcpy(ligtheString,theString);
4125 }
4126
4127 tmp_width=2 * XOUTPUT_HALFHSIZE;
4128 tmp_height=2 * XOUTPUT_HALFVSIZE;
4129
4130 if (tmp_pixmap==0)
4131 tmp_pixmap=XCreatePixmap( display,
4132 XtWindow(TopLevel),
4133 tmp_width,
4134 tmp_height,
4135 depth
4136 );
4137
4138 /* Put some background in pixmap for demonstration of transparent-mode: */
4139 if (Opacity==0){
4140 XSetForeground( display, DefaultGC( display, screennumber), pink4.pixel);
4141 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
4142 0, 0, tmp_width, tmp_height);
4143 XSetForeground( display, DefaultGC( display, screennumber), yellow.pixel);
4144 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
4145 tmp_width/4, tmp_height/4, tmp_width/2, tmp_height/2);
4146 XSetForeground( display, DefaultGC( display, screennumber), fg);
4147 }
4148 else{
4149 XSetForeground( display, DefaultGC( display, screennumber), bg);
4150 XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
4151 0, 0, tmp_width, tmp_height);
4152 }
4153 XSetForeground( display, DefaultGC( display, screennumber), fg);
4154 XSetBackground( display, DefaultGC( display, screennumber), bg);
4155 /* Synchronize display in order to make the time measurement more acurate */
4156 XSync( display, True);
4157 /* Reset T1_errno: */
4158 T1_errno=0;
4159 /* Set antialiasing level */
4160 T1_AASetLevel( aalevel);
4161 /* Draw the string into temporary pixmap */
4162 gettimeofday(time_ptr_start, void_ptr);
4163
4164 if( extraflags & CHECK_PERFORMANCE){
4165 j=0;
4166 for (i=0; j<600; i++){
4167 j=(int)(Size*1.2*i);
4168 glyph=T1_AASetStringX( XtWindow(OutputWindow2), DefaultGC( display, screennumber), Opacity,
4169 0, j, /* x_dest, y_dest */
4170 FontID, (char *)ligtheString,
4171 0, Space, Modflag, Size, matrixP);
4172 }
4173 }
4174 else{
4175 glyph=T1_AASetStringX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
4176 XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
4177 FontID, (char *)ligtheString,
4178 0, Space, Modflag, Size, matrixP);
4179 }
4180
4181 gettimeofday(time_ptr_stop, void_ptr);
4182
4183 if ((extraflags & NO_GRID)==0){
4184 XSetForeground( display, DefaultGC( display, screennumber), gridcolor1.pixel);
4185 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
4186 XOUTPUT_HALFHSIZE, 0, /* X1, Y1 */
4187 XOUTPUT_HALFHSIZE, 2 * XOUTPUT_HALFVSIZE);
4188 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
4189 0, XOUTPUT_HALFVSIZE, /* X1, Y1 */
4190 2 * XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE);
4191 XSetForeground( display, DefaultGC( display, screennumber), gridcolor2.pixel);
4192 if (glyph!=NULL){
4193 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
4194 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX - CROSS_SIZE,
4195 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY,
4196 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE,
4197 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY);
4198 XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
4199 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
4200 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE,
4201 XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
4202 XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE);
4203 }
4204 }
4205
4206 XSetForeground( display, DefaultGC( display, screennumber), fg);
4207
4208 /* Free the ligature-converted string */
4209 free(ligtheString);
4210
4211 /* Check for errors */
4212 if (glyph==NULL) {
4213 sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
4214 i=0;
4215 XtSetArg(args[i], XtNbitmap,NULL); i++;
4216 XtSetArg(args[i], XtNwidth,380); i++;
4217 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
4218 XtSetArg(args[i], XtNlabel, statusstring); i++;
4219 XtSetValues(labelstatus,args,i);
4220 return;
4221 }
4222
4223 /* Prepare status message: */
4224 sprintf(statusstring,"Elapsed time: %ld Microseconds\nLeftSideBearing: %d\nRightSideBearing: %d\nAscent: %d\nDescent: %d\nAdvanceX: %d\nAdvanceY: %d\nBits Per Pixel: %ld\nImage Size: %ld Bytes\nPostScript Fontname: %s\nT1_errno: %d\n",
4225 time_diff(time_ptr_start,time_ptr_stop),
4226 glyph->metrics.leftSideBearing,
4227 glyph->metrics.rightSideBearing,
4228 glyph->metrics.ascent,
4229 glyph->metrics.descent,
4230 glyph->metrics.advanceX,
4231 glyph->metrics.advanceY,
4232 glyph->bpp,
4233 PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
4234 T1_GetFontName(FontID),
4235 T1_errno);
4236
4237
4238
4239 /* Finally, set resources */
4240 i=0;
4241 XtSetArg(args[i], XtNbitmap,NULL); i++;
4242 XtSetArg(args[i], XtNwidth,380); i++;
4243 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
4244 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
4245 XtSetArg(args[i], XtNlabel, statusstring); i++;
4246 XtSetValues(labelstatus,args,i);
4247
4248 i=0;
4249 XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
4250 XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
4251 XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
4252 XtSetArg( args[i], XtNresize, 1);i++;
4253 XtSetArg( args[i], XtNinternalWidth, 0); i++;
4254 XtSetArg( args[i], XtNinternalHeight, 0); i++;
4255 XtSetArg( args[i], XtNbackground, outbg); i++;
4256 XtSetValues(OutputWindow ,args,i);
4257
4258 i=0;
4259 XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
4260 XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
4261 XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
4262 XtSetArg( args[i], XtNresize, 1);i++;
4263 XtSetArg( args[i], XtNinternalWidth, 0); i++;
4264 XtSetArg( args[i], XtNinternalHeight, 0); i++;
4265 XtSetArg( args[i], XtNbackground, outbg); i++;
4266 XtSetValues(Output ,args,i);
4267
4268 }
4269
4270
fonttable(Widget fonttablebutton,XtPointer client_data,XtPointer call_data)4271 void fonttable( Widget fonttablebutton, XtPointer client_data, XtPointer call_data)
4272 {
4273
4274 int i, j;
4275
4276 Arg args[10];
4277 static Pixmap pixmap=0;
4278 int x, y;
4279 int CellLeftMargin, CellTopMargin;
4280 int ColAdvance, RowAdvance;
4281 int width, height;
4282 int FontID, DeviceResolution;
4283 float Size, Extent, Slant;
4284 float scale;
4285
4286 BBox fontbbox, tmpbbox;
4287
4288 sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
4289 sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
4290 sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
4291 sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
4292 sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
4293 sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
4294
4295 if (FontID<0 || FontID>=T1_GetNoFonts()) {
4296 sprintf(statusstring, "t1lib: FontID out of range!");
4297 i=0;
4298 XtSetArg(args[i], XtNbitmap,NULL); i++;
4299 XtSetArg(args[i], XtNwidth,380); i++;
4300 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
4301 XtSetArg(args[i], XtNlabel, statusstring); i++;
4302 XtSetValues(labelstatus,args,i);
4303 return;
4304 }
4305
4306 /* Ensure that font is loaded before any operation on the font */
4307 if ( T1_CheckForFontID( FontID) < 1 ) {
4308 T1_LoadFont( FontID);
4309 }
4310
4311 if ( StrokeWidth == 0.0f ) {
4312 T1_ClearStrokeFlag( FontID);
4313 }
4314 else {
4315 T1_SetStrokeFlag( FontID);
4316 if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
4317 sprintf( statusstring, "t1lib: Unable to setup strokewidth");
4318 i=0;
4319 XtSetArg(args[i], XtNbitmap,NULL); i++;
4320 XtSetArg(args[i], XtNwidth,380); i++;
4321 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
4322 XtSetArg(args[i], XtNlabel, statusstring); i++;
4323 XtSetValues(labelstatus,args,i);
4324 return;
4325 }
4326 }
4327
4328 /* We don't obey rotation when displaying a fonttable */
4329 matrixP=NULL;
4330
4331 if (DeviceResolution!=last_resolution[FontID]){
4332 /* Delete all size dependent data for that font */
4333 for ( i=0; i<T1_GetNoFonts(); i++)
4334 T1_DeleteAllSizes( i);
4335 /* Establish new device resolution */
4336 T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
4337 /* Store current resolution */
4338 last_resolution[FontID]=DeviceResolution;
4339 }
4340 i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
4341 if (i==EOF) EncodingFile[0]=0;
4342 if (strcmp(EncodingFile,LastEncodingFile)!=0){ /* encoding has changed */
4343 if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
4344 for (i=0; i<T1_GetNoFonts(); i++){
4345 T1_DeleteAllSizes(i);
4346 T1_ReencodeFont( i, NULL);
4347 }
4348 /* Take care that newly loaded fonts are encoded according to current
4349 encoding */
4350 T1_SetDefaultEncoding( NULL);
4351 }
4352 else{
4353 for (i=0; i<MAXENCODINGS; ){
4354 if ( encstruct[i].encfilename != NULL)
4355 if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
4356 i++;
4357 break;
4358 }
4359 i++;
4360 }
4361 if (i==MAXENCODINGS){ /* Encoding from that file was not
4362 already loaded -> so load it */
4363 i=0;
4364 while (encstruct[i].encfilename != NULL)
4365 i++;
4366 encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
4367 encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
4368 if (encstruct[i].encoding==NULL){
4369 free( encstruct[i].encfilename);
4370 encstruct[i].encfilename=NULL;
4371 }
4372 i++;
4373 }
4374 else
4375 for (j=0; j<T1_GetNoFonts(); j++){
4376 T1_DeleteAllSizes(j);
4377 T1_ReencodeFont( j, encstruct[i-1].encoding);
4378 }
4379 /* Take care that newly loaded fonts are encoded according to current
4380 encoding */
4381 T1_SetDefaultEncoding( encstruct[i-1].encoding);
4382 }
4383 strcpy( LastEncodingFile, EncodingFile);
4384 }
4385 sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
4386 if (Slant!=lastSlant[FontID]){
4387 /* Delete all size dependent data */
4388 T1_DeleteAllSizes(FontID);
4389 T1_LoadFont(FontID);
4390 T1_SlantFont( FontID, Slant);
4391 lastSlant[FontID]=Slant;
4392 }
4393 sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
4394 if (Extent!=lastExtent[FontID]){
4395 /* Delete all size dependent data */
4396 T1_DeleteAllSizes(FontID);
4397 T1_LoadFont(FontID);
4398 T1_ExtendFont( FontID, Extent);
4399 lastExtent[FontID]=Extent;
4400 }
4401
4402 if (Size<=0.0){
4403 sprintf(statusstring, "t1lib: Size must be positive!");
4404 i=0;
4405 XtSetArg(args[i], XtNbitmap,NULL); i++;
4406 XtSetArg(args[i], XtNwidth,380); i++;
4407 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
4408 XtSetArg(args[i], XtNlabel, statusstring); i++;
4409 XtSetValues(labelstatus,args,i);
4410 return;
4411 }
4412
4413 /* We have read all parameters, now lets get font bbox in order to be
4414 able to compute the cell-metrics */
4415 T1_LoadFont( FontID);
4416 fontbbox=T1_GetFontBBox( FontID);
4417
4418 /* we check for a valid fontbbox, otherwise we compute it ourselves */
4419 if ( fontbbox.llx==0 &&
4420 fontbbox.lly==0 &&
4421 fontbbox.urx==0 &&
4422 fontbbox.ury==0 ){
4423 T1_PrintLog( "fonttable()", "Re-Computing FontBBox", T1LOG_DEBUG);
4424 for (i=0; i<256; i++){
4425 tmpbbox=T1_GetCharBBox( FontID, i);
4426 if (tmpbbox.llx<fontbbox.llx)
4427 fontbbox.llx=tmpbbox.llx;
4428 if (tmpbbox.lly<fontbbox.lly)
4429 fontbbox.lly=tmpbbox.lly;
4430 if (tmpbbox.urx>fontbbox.urx)
4431 fontbbox.urx=tmpbbox.urx;
4432 if (tmpbbox.ury>fontbbox.ury)
4433 fontbbox.ury=tmpbbox.ury;
4434 }
4435 }
4436
4437 /* We scale the font bounding box according to extent, slant and
4438 device resolution. For the slant, we assume that the font contains
4439 at least one character which reaches to the upper right corner and
4440 the same for lower left corner. */
4441 scale=DeviceResolution/72.0;
4442 fontbbox.urx=fontbbox.urx+(int)((float)fontbbox.ury*Slant);
4443 fontbbox.llx=fontbbox.llx+(int)((float)fontbbox.lly*Slant);
4444 fontbbox.urx=(int)((float)fontbbox.urx*Extent);
4445 fontbbox.llx=(int)((float)fontbbox.llx*Extent);
4446 fontbbox.llx=(int)((float)fontbbox.llx*scale);
4447 fontbbox.urx=(int)((float)fontbbox.urx*scale);
4448 fontbbox.lly=(int)((float)fontbbox.lly*scale);
4449 fontbbox.ury=(int)((float)fontbbox.ury*scale);
4450
4451 /* Left and top margin of the char-origins with respect upper left corner
4452 of cell */
4453 CellTopMargin=SIMPLEMARGIN + fontbbox.ury;
4454 if (fontbbox.llx < 0){
4455 CellLeftMargin= - fontbbox.llx;
4456 }
4457 else{
4458 CellLeftMargin=0;
4459 }
4460 /* How much to advance in which direction when incrementing */
4461 ColAdvance=CellLeftMargin + fontbbox.urx ;
4462 RowAdvance=CellTopMargin - fontbbox.lly ;
4463 /* Scale the charspace values */
4464 CellTopMargin = (int) floor((double)CellTopMargin*Size/1000.0+0.5)+SIMPLEMARGIN;
4465 CellLeftMargin = (int) floor((double)CellLeftMargin*Size/1000.0+0.5)+SIMPLEMARGIN;
4466 ColAdvance = (int) floor((double)ColAdvance*Size/1000.0+0.5)+DOUBLEMARGIN;
4467 RowAdvance = (int) floor((double)RowAdvance*Size/1000.0+0.5)+DOUBLEMARGIN;
4468 /* Overall width and height of map */
4469 width=1+(16*ColAdvance);
4470 height=1+(16*RowAdvance);
4471
4472 /* We clip to a window as large as the screen in this function */
4473 if (width > 1024)
4474 width=WidthOfScreen(screen);
4475 if (height > 768)
4476 height=HeightOfScreen(screen);
4477
4478 /* Create pixmap of appropriate size, */
4479 if (pixmap!=0)
4480 XFreePixmap( display, pixmap);
4481 pixmap=XCreatePixmap( display,
4482 XtWindow(TopLevel),
4483 width,
4484 height,
4485 depth
4486 );
4487 /* We always use opaque mode */
4488 XSetForeground( display, DefaultGC( display, screennumber), bg);
4489 XFillRectangle( display, pixmap, DefaultGC( display, screennumber),
4490 0, 0, width, height);
4491 XSetForeground( display, DefaultGC( display, screennumber), fg);
4492 XSetBackground( display, DefaultGC( display, screennumber), bg);
4493
4494 /* Draw cell grid: */
4495 for (j=0; j<17; j++){
4496 XDrawLine( display, pixmap, DefaultGC( display, screennumber),
4497 j*ColAdvance, 0,
4498 j*ColAdvance, height);
4499 }
4500 for (j=0; j<17; j++){
4501 XDrawLine( display, pixmap, DefaultGC( display, screennumber),
4502 0, j*RowAdvance,
4503 width, j*RowAdvance);
4504 }
4505
4506 /* Reset T1_errno: */
4507 T1_errno=0;
4508 /* Set antialiasing level */
4509 T1_AASetLevel( aalevel);
4510 /* Draw characters into pixmap */
4511 for ( i=0; i<16; ) { /* row-loop */
4512 for ( j=0; j<16; j++) {
4513 x=1+(j*ColAdvance)+CellLeftMargin;
4514 y=1+CellTopMargin+(i*RowAdvance);
4515 glyph=T1_AASetCharX( pixmap, DefaultGC( display, screennumber), 1,
4516 x, y, FontID, (char) (i*16+j), Size, matrixP);
4517 if (x>width) {
4518 sprintf( msg_buf, "Clipping row %d horizontally at column %d", i, j);
4519 T1_PrintLog( "fonttable()", msg_buf, T1LOG_STATISTIC);
4520 break;
4521 }
4522
4523 }
4524 if (y>height) {
4525 sprintf( msg_buf, "Clipping vertically at row %d", i);
4526 T1_PrintLog( "fonttable()", msg_buf, T1LOG_STATISTIC);
4527 break;
4528 }
4529 i++;
4530 }
4531
4532 /* If font was not loadable */
4533 if (T1_GetFontName( FontID)==NULL)
4534 sprintf(statusstring, "t1lib: Can't get font name, T1_errno=%d!", T1_errno);
4535 else
4536 sprintf(statusstring,"Font %s, final T1_errno = %d\n %s",
4537 T1_GetFontName( FontID), T1_errno, T1_StrError(T1_errno));
4538
4539 /* Finally, set resources */
4540 i=0;
4541 XtSetArg(args[i], XtNbitmap,NULL); i++;
4542 XtSetArg(args[i], XtNwidth,380); i++;
4543 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
4544 XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
4545 XtSetArg(args[i], XtNlabel, statusstring); i++;
4546 XtSetValues(labelstatus,args,i);
4547
4548 i=0;
4549 XtSetArg( args[i], XtNwidth, width); i++;
4550 XtSetArg( args[i], XtNheight, height); i++;
4551 XtSetArg( args[i], XtNbitmap, pixmap); i++;
4552 XtSetArg( args[i], XtNresize, 1);i++;
4553 XtSetArg( args[i], XtNinternalWidth, 0); i++;
4554 XtSetArg( args[i], XtNinternalHeight, 0); i++;
4555 XtSetArg( args[i], XtNbackground, outbg); i++;
4556 XtSetValues(OutputWindow ,args,i);
4557
4558 i=0;
4559 XtSetArg( args[i], XtNwidth, width); i++;
4560 XtSetArg( args[i], XtNheight, height); i++;
4561 XtSetArg( args[i], XtNbitmap, pixmap); i++;
4562 XtSetArg( args[i], XtNresize, 1);i++;
4563 XtSetArg( args[i], XtNinternalWidth, 0); i++;
4564 XtSetArg( args[i], XtNinternalHeight, 0); i++;
4565 XtSetArg( args[i], XtNbackground, outbg); i++;
4566 XtSetValues(Output ,args,i);
4567
4568
4569 }
4570
4571
4572
4573 /* This function shows the About-message */
showabout(Widget aboutbutton,XtPointer client_data,XtPointer call_data)4574 void showabout( Widget aboutbutton, XtPointer client_data, XtPointer call_data)
4575 {
4576 int i;
4577 Arg args[10];
4578 Pixmap about=0;
4579 XGCValues xgcvalues;
4580 GC gc;
4581 static char ident[80]="";
4582
4583 #define T1GCMASK GCForeground | GCBackground
4584
4585 if (about==0) {
4586 about=XCreatePixmap( display, XtWindow(TopLevel),
4587 380, MESSAGEBOXHEIGHT, depth);
4588 }
4589 gc=DefaultGC( display, screennumber);
4590
4591 XGetGCValues( display, gc, T1GCMASK, &xgcvalues);
4592 fg=xgcvalues.foreground;
4593 bg=xgcvalues.background;
4594
4595 XSetForeground( display, gc, white.pixel);
4596 XFillRectangle( display, about, gc, 0, 0, 380, MESSAGEBOXHEIGHT);
4597 XSetForeground( display, gc, black.pixel);
4598 XSetBackground( display, gc, white.pixel);
4599
4600 /* Set antialiasing level */
4601 T1_AASetLevel( aalevel);
4602 sprintf( ident, "This is xglyph, T1Lib Version %s", T1_GetLibIdent());
4603 glyph=T1_AASetStringX( about, gc, 1, 10, 30, /* x_dest, y_dest */
4604 0, ident,
4605 0, 0.0, T1_UNDERLINE | T1_KERNING, 20.0, NULL);
4606 glyph=T1_AASetStringX( about, gc, 1, 10, 60, /* x_dest, y_dest */
4607 0, "xglyph is an interactive tool for illustrating some",
4608 0, 0.0, T1_KERNING, 15.0, NULL);
4609 glyph=T1_AASetStringX( about, gc, 1, 10, 80, /* x_dest, y_dest */
4610 0, "of the T1Lib features. T1Lib is distributed under",
4611 0, 0.0, T1_KERNING, 15.0, NULL);
4612 glyph=T1_AASetStringX( about, gc, 1, 10, 100, /* x_dest, y_dest */
4613 0, "the GNU General Public Library License (LGPL).",
4614 0, 0.0, T1_KERNING, 15.0, NULL);
4615 glyph=T1_AASetStringX( about, gc, 1, 10, 133, /* x_dest, y_dest */
4616 0, "Enjoy it!",
4617 0, 0.0, T1_KERNING, 15.0, NULL);
4618 XSetForeground( display, gc, fg);
4619 XSetBackground( display, gc, bg);
4620
4621 i=0;
4622 XtSetArg(args[i], XtNwidth,380); i++;
4623 XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
4624 XtSetArg(args[i], XtNbackgroundPixmap, about); i++;
4625 XtSetArg(args[i], XtNlabel, ""); i++;
4626 XtSetValues(labelstatus,args,i);
4627 }
4628
4629
4630
4631 /* This function returns a time difference in Microseconds, provided that
4632 the time difference is not greater than approximately 35 minutes. */
time_diff(struct timeval * time_ptr_start,struct timeval * time_ptr_stop)4633 long time_diff(struct timeval *time_ptr_start, struct timeval *time_ptr_stop)
4634 {
4635 return((time_ptr_stop->tv_sec -
4636 time_ptr_start->tv_sec)*1000000
4637 +(time_ptr_stop->tv_usec -
4638 time_ptr_start->tv_usec));
4639 }
4640
4641
4642 /* T1_ComputeAAColorsX(): Compute the antialiasing colors in dependency
4643 of foreground and background */
ComputeAAColorsX(unsigned long fg,unsigned long bg,int nolevels)4644 int ComputeAAColorsX( unsigned long fg, unsigned long bg, int nolevels)
4645 {
4646
4647 static unsigned long last_fg;
4648 static unsigned long last_bg;
4649 unsigned long delta_red, delta_green, delta_blue;
4650 int i;
4651 int nocolors=0;
4652
4653
4654 aacolors[0].pixel=bg;
4655 aacolors[nolevels-1].pixel=fg;
4656
4657 if ((fg==last_fg)&&(bg==last_bg))
4658 return(nocolors);
4659
4660 /* Get RGB values for fore- and background */
4661 XQueryColor( display, DefaultColormap(display,screennumber), &aacolors[0]);
4662 XQueryColor( display, DefaultColormap(display,screennumber), &aacolors[nolevels-1]);
4663 delta_red = (aacolors[nolevels-1].red - aacolors[0].red)/(nolevels-1);
4664 delta_green = (aacolors[nolevels-1].green - aacolors[0].green)/(nolevels-1);
4665 delta_blue = (aacolors[nolevels-1].blue - aacolors[0].blue)/(nolevels-1);
4666 aapixels[0]=aacolors[0].pixel;
4667 aapixels[nolevels-1]=aacolors[nolevels-1].pixel;
4668
4669 for (i=1; i<nolevels-1; i++){
4670 aacolors[i].red = aacolors[i-1].red + delta_red;
4671 aacolors[i].green = aacolors[i-1].green + delta_green;
4672 aacolors[i].blue = aacolors[i-1].blue + delta_blue;
4673 /* Allocate color in current palette */
4674 if (XAllocColor( display, DefaultColormap(display,screennumber),
4675 &aacolors[i])!=0){
4676 aapixels[i]=aacolors[i].pixel;
4677 nocolors++;
4678 }
4679
4680 }
4681
4682 return(nocolors);
4683
4684 }
4685
4686
4687
printusage(int max)4688 void printusage( int max)
4689 {
4690 int i=0;
4691
4692 if (max==0)
4693 max=100000; /* should be large enough :) */
4694
4695 fprintf(stdout, "xglyph -- t1lib Version %s\n\n", T1_GetLibIdent());
4696 fprintf(stdout, "Usage: xglyph [options] [fontfile1 [fontfile2 [...]]]\n\n");
4697 fprintf(stdout, "where options is one of:\n");
4698 while ( xglyphoptions[i]!=NULL && i<max){
4699 if (i==3) /* We print the possible values here. */
4700 fprintf( stdout, "\t\t%s {8,16,32}\n", xglyphoptions[i++]);
4701 else
4702 fprintf( stdout, "\t\t%s\n", xglyphoptions[i++]);
4703 }
4704
4705 fprintf(stdout, "For additional information see the t1lib manual!\n");
4706 return;
4707 }
4708
4709
CheckTransform(void)4710 int CheckTransform( void)
4711 {
4712
4713 int err;
4714 float x1, x2, x3, x4;
4715
4716 err=sscanf( XawDialogGetValueString(dialogtmatrix), "%f,%f,%f,%f",
4717 &x1, &x2, &x3, &x4 );
4718 if ( (x1 == (float) 1.0) &&
4719 (x2 == (float) 0.0) &&
4720 (x3 == (float) 0.0) &&
4721 (x4 == (float) 1.0) ){
4722 matrix.cxx=x1;
4723 matrix.cyx=x2;
4724 matrix.cxy=x3;
4725 matrix.cyy=x4;
4726 return( 0);
4727 }
4728 else{
4729 matrix.cxx=x1;
4730 matrix.cyx=x2;
4731 matrix.cxy=x3;
4732 matrix.cyy=x4;
4733 return( 1);
4734 }
4735 }
4736
4737