PageRenderTime 100ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 2ms

/t1lib-5.1.2/xglyph/xglyph.c

#
C | 4739 lines | 3747 code | 568 blank | 424 comment | 463 complexity | 5a060dab692f5ed2fd7058f32eef3ba4 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.0, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  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. /* definitions for activating special tests for features of t1lib
  29. via commandline arguments: */
  30. #define CHECK_PERFORMANCE 0x0001
  31. #define CHECK_T1_COPYFONT_T1_ADDFONT 0x0002
  32. #define CHECK_CONCATGLYPHS 0x0004
  33. #define CHECK_CONCATOUTLINES 0x0008
  34. #define CHECK_FOR_BAD_CHARS 0x0010
  35. #define CHECK_DEFAULT_ENCODING 0x0020
  36. #define CHECK_SMART_AA 0x0040
  37. #define NO_GRID 0x0080
  38. #define CHECK_AA_CACHING 0x0100
  39. #define CHECK_CACHE_STROKED 0x0200
  40. #define CHECK_SET_RECT 0x0400
  41. /* #define SHOW_MANIPULATE_PATHS */
  42. #include <X11/Intrinsic.h>
  43. #include <X11/StringDefs.h>
  44. #include <X11/Xaw/Label.h>
  45. #include <X11/Xaw/Command.h>
  46. #include <X11/Xaw/Form.h>
  47. #include <X11/Xaw/Dialog.h>
  48. #include <X11/Xaw/Box.h>
  49. #include <X11/Xaw/Toggle.h>
  50. #include <X11/Shell.h>
  51. #include <X11/Xaw/AsciiText.h>
  52. #include <X11/Xaw/SimpleMenu.h>
  53. #include <X11/Xaw/SmeBSB.h>
  54. #include <X11/Xaw/List.h>
  55. #include <stdio.h>
  56. #include <math.h>
  57. #include <stdlib.h>
  58. #include <sys/types.h>
  59. #include <sys/uio.h>
  60. #include <unistd.h>
  61. #include <sys/time.h>
  62. /* The following stuff is necessary for compiling and running
  63. xglyph on VMS. Submitted by John Hasstedt (John.Hasstedt@sunysb.edu),
  64. who did the VMS-port of t1lib. */
  65. #if defined(__VMS) && __CRTL_VER < 70000000
  66. # define putenv(p) \
  67. printf("You must define T1LIB_CONFIG before running this program\n"); \
  68. exit;
  69. # define gettimeofday(p1,p2)
  70. #endif
  71. /* Note: We include t1lib.h and t1libx.h from lib/t1lib. That way the
  72. objectfile does only need to be rebuild when the header itself
  73. changes and not each time the library has been recompiled */
  74. #include "../lib/t1lib/t1lib.h"
  75. #include "../lib/t1lib/t1libx.h"
  76. #ifndef PI
  77. #define PI 3.1415927
  78. #endif
  79. /* utility functions */
  80. BBox ComputeRotBBox( BBox, float);
  81. long time_diff(struct timeval *, struct timeval *);
  82. /* fallback-function */
  83. void exitprog( Widget, XtPointer, XtPointer);
  84. void togglekerning( Widget, XtPointer, XtPointer);
  85. void toggleligatur( Widget, XtPointer, XtPointer);
  86. void toggler2l( Widget, XtPointer, XtPointer);
  87. void toggleunderline( Widget, XtPointer, XtPointer);
  88. void toggleoverline( Widget, XtPointer, XtPointer);
  89. void toggleoverstrike( Widget, XtPointer, XtPointer);
  90. void showchar( Widget , XtPointer , XtPointer );
  91. void showstring( Widget , XtPointer , XtPointer );
  92. void aashowchar( Widget , XtPointer , XtPointer );
  93. void aashowstring( Widget , XtPointer , XtPointer );
  94. void showcharX( Widget , XtPointer , XtPointer );
  95. void showstringX( Widget , XtPointer , XtPointer );
  96. void aashowcharX( Widget , XtPointer , XtPointer );
  97. void aashowstringX( Widget , XtPointer , XtPointer );
  98. void showabout( Widget , XtPointer , XtPointer );
  99. void toggleopacity( Widget, XtPointer, XtPointer);
  100. void setcolor( Widget, XtPointer, XtPointer);
  101. void fonttable( Widget, XtPointer, XtPointer);
  102. void toggleaalevel( Widget, XtPointer, XtPointer);
  103. int ComputeAAColorsX( unsigned long fg, unsigned long bg, int nolevels);
  104. void printusage( int max);
  105. int CheckTransform( void);
  106. #define DOUBLEMARGIN 10
  107. #define SIMPLEMARGIN 5
  108. #define XOUTPUT_HALFVSIZE 200
  109. #define XOUTPUT_HALFHSIZE 300
  110. #define XGLYPH_PAD 16
  111. #define T1LIBENCFILE "IsoLatin1.enc"
  112. #define MAXENCODINGS 10
  113. #define TESTFONTFILE "eufm10.pfb"
  114. #define SHOWGRID
  115. #define CROSS_SIZE 6
  116. #define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
  117. #define DIALOGWIDTH 170
  118. #define DIALOGHEIGHT 20
  119. #define ACTIONBUTTONHEIGHT 20
  120. #define APPLICATIONHEIGHT 690
  121. #define EDITABLE_COLOR "red"
  122. #define MESSAGEBOXHEIGHT 180
  123. #define AAMAXPLANES 17
  124. #define GRAY0 WhitePixel(display, screen_number)
  125. #define GRAY1 gray1.pixel
  126. #define GRAY2 gray2.pixel
  127. #define GRAY3 gray3.pixel
  128. #define GRAY4 BlackPixel(display, screen_number)
  129. #define min(a,b) (a < b ? a : b)
  130. #define max(a,b) (a > b ? a : b)
  131. #define DEFAULT_SIZE "100.0"
  132. #define DEFAULT_CHAR "65"
  133. /* Global variables for rasterizer parameters */
  134. float Size=400.0, Slant=0.0, Extent=1.0, Angle=0.0;
  135. int Modflag=0;
  136. int FontID=0, Caching=1, DeviceResolution=72;
  137. int StrokeWidth;
  138. int nofonts;
  139. long Space=0;
  140. int Opacity=0;
  141. int aalevel;
  142. char TestString[1024]="Test";
  143. int TestChar=70;
  144. char EncodingFile[128]="";
  145. char LastEncodingFile[128]="";
  146. struct
  147. {
  148. char *encfilename;
  149. char **encoding;
  150. }
  151. encstruct[MAXENCODINGS];
  152. int *last_resolution;
  153. float *lastExtent;
  154. float *lastSlant;
  155. int LigDetect=0;
  156. unsigned long fg, bg, outbg;
  157. Pixmap tmp_pixmap=0;
  158. Pixmap white_pixmap=0;
  159. Pixmap perf_pixmap;
  160. Pixmap pixmap;
  161. XImage *ximage;
  162. XColor edit_color, gray0, gray1, gray2, gray3, gray4;
  163. XColor white, black, gray, red, green, blue, pink4, yellow,
  164. gridcolor1, gridcolor2,wozu;
  165. XColor aacolors[AAMAXPLANES];
  166. unsigned long aapixels[AAMAXPLANES];
  167. XGCValues xgcvalues;
  168. unsigned short dummy;
  169. char input;
  170. int overallwidth;
  171. char commandline[256];
  172. GLYPH *glyph;
  173. GLYPH *glyph1, *glyph2;
  174. char **Encoding=NULL;
  175. unsigned int height, width;
  176. char statusstring[1024];
  177. T1_TMATRIX matrix;
  178. T1_TMATRIX *matrixP;
  179. static char msg_buf[256];
  180. /* How t1lib pads lines: */
  181. int t1_pad=0;
  182. /* When to swap bytes in aa-pixels? */
  183. int xglyph_byte_order;
  184. /* The following is for time measurements: */
  185. struct timeval time_start, time_stop;
  186. struct timeval *time_ptr_start, *time_ptr_stop;
  187. void *void_ptr;
  188. /* Global X(t)-stuff */
  189. Display *display;
  190. Screen *screen;
  191. int screennumber;
  192. int depth;
  193. Widget TopLevel;
  194. Widget OutputWindow;
  195. Widget Output;
  196. Widget OutputWindow2;
  197. Widget Output2;
  198. Widget dialogfontid;
  199. Widget dialogsize;
  200. Widget dialogslant;
  201. Widget dialogextent;
  202. Widget dialogangle;
  203. Widget dialogteststring;
  204. Widget dialogtestcharacter;
  205. Widget dialogdevres;
  206. Widget dialogstroke;
  207. Widget dialogencfile;
  208. Widget dialogspace;
  209. Widget dialogtmatrix;
  210. Widget labelstatus;
  211. Widget fgcolorbutton;
  212. Widget bgcolorbutton;
  213. /* color setting widgets */
  214. Widget fgwhitebutton;
  215. Widget fgblackbutton;
  216. Widget fggraybutton;
  217. Widget fgredbutton;
  218. Widget fggreenbutton;
  219. Widget fgbluebutton;
  220. Widget bgwhitebutton;
  221. Widget bgblackbutton;
  222. Widget bggraybutton;
  223. Widget bgredbutton;
  224. Widget bggreenbutton;
  225. Widget bgbluebutton;
  226. Widget fglabel;
  227. Widget bglabel;
  228. Widget colorbox;
  229. Widget fgstatus;
  230. Widget bgstatus;
  231. Widget optionsbox;
  232. /* Commandline handling */
  233. char *xglyphoptions[]={"--help", /* 0 */
  234. "--Help", /* 1 */
  235. "--noGrid", /* 2 */
  236. "--setPad", /* 3 */
  237. "--logError", /* 4 */
  238. "--logWarning", /* 5 */
  239. "--logStatistic", /* 6 */
  240. "--logDebug", /* 7 */
  241. "--ignoreForceBold", /* 8 */
  242. "--ignoreFamilyAlignment", /* 9 */
  243. "--ignoreHinting", /* 10 */
  244. "--ignoreAFM", /* 11 */
  245. "--debugLine", /* 12 */
  246. "--debugRegion", /* 13 */
  247. "--debugPath", /* 14 */
  248. "--debugFont", /* 15 */
  249. "--debugHint", /* 16 */
  250. "--checkPerformance", /* 17 */
  251. "--checkCopyFont", /* 18 */
  252. "--checkConcatGlyphs", /* 19 */
  253. "--checkConcatOutlines", /* 20 */
  254. "--checkBadCharHandling", /* 21 */
  255. "--checkDefaultEncoding", /* 22 */
  256. "--checkSmartAntialiasing", /* 23 */
  257. "--checkAACaching", /* 24 */
  258. "--checkSetRect", /* 25 */
  259. "--cacheStrokedGlyphs", /* 26 */
  260. NULL};
  261. int extraflags=0;
  262. /* #define SHOW_MANIPULATE_PATHS */
  263. #ifdef SHOW_MANIPULATE_PATHS
  264. void mymanipulate( long *x, long *y, int type)
  265. {
  266. double corr;
  267. double dx, dy;
  268. dx=(double)*x;
  269. dy=(double)*y;
  270. /* we have to scale down because we deal with fractional pels */
  271. /*
  272. corr=0.000000000000004*dx*dx;
  273. dy *=1.0+corr;
  274. */
  275. /*
  276. #define PERIOD 500.0
  277. corr=65536.0*0.5*sin(2*PI/PERIOD/65536.0*dx);
  278. dy +=corr*30.0;
  279. */
  280. *y=(long)dy;
  281. }
  282. #endif
  283. int main( int argc, char **argv)
  284. {
  285. XtAppContext TopLevelApp;
  286. Arg args[10];
  287. int i, j, numopts=0;
  288. Widget kerningbutton;
  289. Widget ligaturbutton;
  290. Widget r2lbutton;
  291. Widget showcharbutton;
  292. Widget showstringbutton;
  293. Widget aashowcharbutton;
  294. Widget aashowstringbutton;
  295. Widget showcharbuttonX;
  296. Widget showstringbuttonX;
  297. Widget aashowcharbuttonX;
  298. Widget aashowstringbuttonX;
  299. Widget stringlabel;
  300. Widget aboutbutton;
  301. Widget opacitybutton;
  302. Widget underlinebutton;
  303. Widget overstrikebutton;
  304. Widget overlinebutton;
  305. Widget transbox;
  306. Widget fonttablebutton;
  307. Widget aalevelbutton;
  308. Widget exitbutton;
  309. Widget box;
  310. int rasterflags=0, initflags=0, optfound;
  311. int loglevel=0;
  312. i=0;
  313. j=0;
  314. while (xglyphoptions[i++]!=NULL)
  315. numopts++;
  316. for ( i=1; i<argc; i++){
  317. if (strncmp(&(argv[i][0]), "--", 2)==0){
  318. j=0;
  319. optfound=0;
  320. while ( (j<numopts) && optfound==0){
  321. if (strcmp(argv[i],xglyphoptions[j])==0){
  322. switch (j){
  323. case 0:
  324. printusage( 8); /* Show 8 options */
  325. exit(0);
  326. case 1:
  327. printusage( 0); /* Show all options */
  328. exit(0);
  329. case 2:
  330. extraflags |= NO_GRID;
  331. optfound=1;
  332. break;
  333. case 3:
  334. /* We have to examine one further argument */
  335. i++;
  336. if (strcmp( argv[i], "8")==0)
  337. t1_pad=8;
  338. else if (strcmp( argv[i], "16")==0)
  339. t1_pad=16;
  340. else if (strcmp( argv[i], "32")==0)
  341. t1_pad=32;
  342. else{
  343. fprintf( stderr, "xglyph: Invalid padding specification %s\n",
  344. argv[i]);
  345. exit(-1);
  346. }
  347. optfound=1;
  348. break;
  349. case 4:
  350. loglevel = T1LOG_ERROR;
  351. loglevel |= (0x01 << 8);
  352. optfound=1;
  353. break;
  354. case 5:
  355. loglevel = T1LOG_WARNING;
  356. loglevel |= (0x01 << 8);
  357. optfound=1;
  358. break;
  359. case 6:
  360. loglevel = T1LOG_STATISTIC;
  361. loglevel |= (0x01 << 8);
  362. optfound=1;
  363. break;
  364. case 7:
  365. loglevel = T1LOG_DEBUG;
  366. loglevel |= (0x01 << 8);
  367. optfound=1;
  368. break;
  369. case 8:
  370. rasterflags |= T1_IGNORE_FORCEBOLD;
  371. optfound=1;
  372. break;
  373. case 9:
  374. rasterflags |= T1_IGNORE_FAMILYALIGNMENT;
  375. optfound=1;
  376. break;
  377. case 10:
  378. rasterflags |= T1_IGNORE_HINTING;
  379. optfound=1;
  380. break;
  381. case 11:
  382. initflags |= T1_NO_AFM;
  383. optfound=1;
  384. break;
  385. case 12:
  386. rasterflags |= T1_DEBUG_LINE;
  387. optfound=1;
  388. break;
  389. case 13:
  390. rasterflags |= T1_DEBUG_REGION;
  391. optfound=1;
  392. break;
  393. case 14:
  394. rasterflags |= T1_DEBUG_PATH;
  395. optfound=1;
  396. break;
  397. case 15:
  398. rasterflags |= T1_DEBUG_FONT;
  399. optfound=1;
  400. break;
  401. case 16:
  402. rasterflags |= T1_DEBUG_HINT;
  403. optfound=1;
  404. break;
  405. case 17:
  406. extraflags |= CHECK_PERFORMANCE;
  407. optfound=1;
  408. break;
  409. case 18:
  410. extraflags |= CHECK_T1_COPYFONT_T1_ADDFONT;
  411. optfound=1;
  412. break;
  413. case 19:
  414. extraflags |= CHECK_CONCATGLYPHS;
  415. optfound=1;
  416. break;
  417. case 20:
  418. extraflags |= CHECK_CONCATOUTLINES;
  419. optfound=1;
  420. break;
  421. case 21:
  422. extraflags |= CHECK_FOR_BAD_CHARS;
  423. optfound=1;
  424. break;
  425. case 22:
  426. extraflags |= CHECK_DEFAULT_ENCODING;
  427. optfound=1;
  428. break;
  429. case 23:
  430. extraflags |= CHECK_SMART_AA;
  431. optfound=1;
  432. break;
  433. case 24:
  434. extraflags |= CHECK_AA_CACHING;
  435. optfound=1;
  436. break;
  437. case 25:
  438. extraflags |= CHECK_SET_RECT;
  439. optfound = 1;
  440. break;
  441. case 26:
  442. extraflags |= CHECK_CACHE_STROKED;
  443. optfound = 1;
  444. break;
  445. default: /* should not be reached */
  446. break;
  447. }
  448. } /* end of "if (strcmp.." */
  449. j++;
  450. }
  451. if (optfound==0){
  452. fprintf( stderr, "xglyph: Unknown option %s\n",
  453. argv[i]);
  454. exit(-1);
  455. }
  456. }
  457. else /* string doesn't start with "--" -> no option */
  458. break;
  459. }
  460. /* Assign address of time parameter */
  461. time_ptr_start=&time_start;
  462. time_ptr_stop=&time_stop;
  463. /* Check for environment entry. If not set, set it to current
  464. directory so that configuration file is found there */
  465. /* It violates the Debian Policy */
  466. #if 0
  467. if (getenv("T1LIB_CONFIG")==NULL){
  468. putenv( "T1LIB_CONFIG=./t1lib.config");
  469. }
  470. #endif
  471. /* Set log-level: */
  472. T1_SetLogLevel( loglevel & (~(0x01<<8)));
  473. /* Get padding value if not set from commandline. For 32 bit architectures
  474. like Intel, 16 might be the best padding default value: */
  475. if (t1_pad==0)
  476. t1_pad=16;
  477. if (T1_SetBitmapPad( t1_pad)!=0){
  478. t1_pad=T1_GetBitmapPad();
  479. }
  480. /* Initialize t1-library. If xglyph is called with arguments
  481. that are no options, we assume that the arguments are font
  482. files and ignore the fontdata base file. At this point the value of
  483. "i" is the number of commandline arg that is supposed to contain a
  484. fontfile name (or it is argc, if no files where specified).
  485. Note further that "loglevel" contains (1) info whether to create a log
  486. file in the first bit of the higher byte of the lower word and
  487. (2) info which loglevel to set. (3) It further may contain more
  488. initialization flags.
  489. */
  490. if ((extraflags & CHECK_AA_CACHING)){
  491. loglevel |= (T1_AA_CACHING<<8);
  492. }
  493. if (i==argc){
  494. if (T1_InitLib( (loglevel>>8) | initflags )==NULL){
  495. fprintf(stderr,"Initialization of t1lib failed (T1_errno=%d)!\n",
  496. T1_errno);
  497. return(-1);
  498. }
  499. }
  500. else{ /* There are still arguments which we interprete as fontfile names */
  501. if (T1_InitLib( (loglevel>>8) | initflags | IGNORE_FONTDATABASE )==NULL){
  502. fprintf(stderr,"Initialization of t1lib failed (T1_errno=%d)!\n",
  503. T1_errno);
  504. return(-1);
  505. }
  506. /* We start adding fonts as the i-th commandline arguments */
  507. for ( j=i; j<argc; j++){
  508. T1_AddFont( argv[j]);
  509. }
  510. }
  511. /* We return if no fonts could be installed */
  512. if ((j=T1_GetNoFonts())<=0){
  513. fprintf(stderr,"xglyph: No fonts in database (T1_errno=%d)!\n", T1_errno);
  514. return(-1);
  515. }
  516. /* Set the raster parameters */
  517. T1_SetRasterFlags( rasterflags);
  518. /* Load alternate encoding and associate it with filename: */
  519. encstruct[0].encoding=T1_LoadEncoding(T1LIBENCFILE);
  520. encstruct[0].encfilename=(char *)malloc(strlen(T1LIBENCFILE)+1);
  521. strcpy( encstruct[0].encfilename, T1LIBENCFILE);
  522. for ( i=1; i<MAXENCODINGS; i++){
  523. encstruct[i].encoding=NULL;
  524. encstruct[i].encfilename=NULL;
  525. }
  526. /* If requested, set a default encoding vector */
  527. if (extraflags & CHECK_DEFAULT_ENCODING){
  528. T1_SetDefaultEncoding( encstruct[0].encoding);
  529. }
  530. if( extraflags & CHECK_T1_COPYFONT_T1_ADDFONT){
  531. {
  532. int k;
  533. /* The following code is to test the T1_CopyFont()-function. It
  534. generates logical fonts with IDs twice the ID of the original
  535. font which are then slanted by 0.3. */
  536. nofonts=T1_GetNoFonts();
  537. printf("Initial number of fonts: %d\n", nofonts);
  538. for (i=0; i< nofonts; i++){
  539. T1_LoadFont(i);
  540. if ((k=T1_CopyFont(i))<0){
  541. fprintf(stderr,"T1_CopyFont() unsuccessful (k=%d), for FontID=%d\n", k, i);
  542. }else{
  543. T1_SlantFont(k,0.3);
  544. fprintf(stderr,"Slanted Font under FontID %d generated\n", k);
  545. }
  546. }
  547. fprintf( stderr, "T1_AddFont() returned newID %d for fontfile %s!\n",
  548. T1_AddFont( TESTFONTFILE), TESTFONTFILE);
  549. nofonts=T1_GetNoFonts();
  550. printf("Final number of fonts: %d\n", nofonts);
  551. }
  552. }
  553. /* Setup arrays for the last... values */
  554. nofonts=T1_GetNoFonts();
  555. if ( (last_resolution=(int *) malloc ( nofonts * sizeof(int)))==NULL){
  556. fprintf( stderr, "xglyph: memory allocation error\n");
  557. exit(1);
  558. }
  559. else
  560. for (i=0; i<nofonts; i++)
  561. last_resolution[i]=72;
  562. if ( (lastSlant=(float *) malloc ( nofonts * sizeof(float)))==NULL){
  563. fprintf( stderr, "xglyph: memory allocation error\n");
  564. exit(1);
  565. }
  566. else
  567. for (i=0; i<nofonts; i++)
  568. lastSlant[i]=0.0;
  569. if ( (lastExtent=(float *) malloc ( nofonts * sizeof(float)))==NULL){
  570. fprintf( stderr, "xglyph: memory allocation error\n");
  571. exit(1);
  572. }
  573. else
  574. for (i=0; i<nofonts; i++)
  575. lastExtent[i]=1.0;
  576. if (extraflags & CHECK_SMART_AA)
  577. T1_AASetSmartMode( T1_YES);
  578. /* If checking caching of stroked characters is enabled via command line,
  579. we call T1_StrokeFont() on each font in the database. This is valid
  580. here since we do not already have glyph data. */
  581. if ( extraflags & CHECK_CACHE_STROKED ) {
  582. for ( i=0; i<nofonts; i++) {
  583. T1_LoadFont(i);
  584. T1_StrokeFont( i, 1);
  585. }
  586. }
  587. /* Initialize application */
  588. TopLevel = XtAppInitialize(&TopLevelApp, (String) "Xglyph", (XrmOptionDescList) NULL,
  589. (Cardinal) 0,
  590. &argc,
  591. argv,
  592. (String *) NULL,
  593. (ArgList) NULL,
  594. (Cardinal) 0);
  595. i=0;
  596. XtSetArg(args[i], XtNheight, APPLICATIONHEIGHT); i++;
  597. XtSetValues(TopLevel,args,i);
  598. /* Create window for graphics output */
  599. Output = XtCreatePopupShell( "Xglyph-Output", topLevelShellWidgetClass,
  600. TopLevel, NULL,0);
  601. OutputWindow = XtCreateManagedWidget("xglyph-Output",labelWidgetClass, Output,
  602. NULL, 0);
  603. /* Get display/screen pointer and screennumber */
  604. display = XtDisplay(OutputWindow);
  605. screen = XtScreen(OutputWindow);
  606. screennumber = DefaultScreen(display);
  607. depth = DefaultDepth(display,screennumber);
  608. /* In case client and server have different endian architecture,
  609. we have to care for the 16 and 32 bit aa-pixels to have the
  610. correct byte order */
  611. if (T1_CheckEndian()==0)
  612. xglyph_byte_order=0;
  613. else
  614. xglyph_byte_order=1;
  615. if( extraflags & CHECK_PERFORMANCE){
  616. perf_pixmap=0;
  617. /* The following is for testing only */
  618. Output2 = XtCreatePopupShell( "Xglyph-Output2", topLevelShellWidgetClass,
  619. TopLevel, NULL,0);
  620. OutputWindow2 = XtCreateManagedWidget("xglyph-Output2",labelWidgetClass, Output2,
  621. NULL, 0);
  622. i=0;
  623. XtSetArg( args[i], XtNwidth, 800 ); i++;
  624. XtSetArg( args[i], XtNheight, 600 ); i++;
  625. XtSetValues(OutputWindow2,args,i);
  626. }
  627. /* Get colors and assign pixel values: */
  628. XAllocNamedColor(display, DefaultColormap(display,screennumber), EDITABLE_COLOR,
  629. &edit_color, &wozu);
  630. XAllocNamedColor(display, DefaultColormap(display,screennumber), "green",
  631. &green, &wozu);
  632. XAllocNamedColor(display, DefaultColormap(display,screennumber), "blue",
  633. &blue, &wozu);
  634. XAllocNamedColor(display, DefaultColormap(display,screennumber), "black",
  635. &gray4, &wozu);
  636. XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray25",
  637. &gray3, &wozu);
  638. XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray50",
  639. &gray2, &wozu);
  640. XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray75",
  641. &gray1, &wozu);
  642. XAllocNamedColor(display, DefaultColormap(display,screennumber), "white",
  643. &gray0, &wozu);
  644. XAllocNamedColor(display, DefaultColormap(display,screennumber), "yellow",
  645. &yellow, &wozu);
  646. XAllocNamedColor(display, DefaultColormap(display,screennumber), "pink4",
  647. &pink4, &wozu);
  648. XAllocNamedColor(display, DefaultColormap(display,screennumber), "cyan",
  649. &gridcolor1, &wozu);
  650. XAllocNamedColor(display, DefaultColormap(display,screennumber), "magenta",
  651. &gridcolor2, &wozu);
  652. white=gray0;
  653. black=gray4;
  654. gray=gray1;
  655. red=edit_color;
  656. /* Fill the aacolors and aapixels-array */
  657. ComputeAAColorsX( black.pixel, white.pixel, AAMAXPLANES);
  658. /* Set default colors for X11 rastering functions */
  659. fg=black.pixel;
  660. bg=white.pixel;
  661. T1_AASetBitsPerPixel(DefaultDepth(display,screennumber));
  662. /* T1_LogicalPositionX( 0); */
  663. /* The box-widget for all the buttons */
  664. box=XtCreateManagedWidget("xglyph", boxWidgetClass, TopLevel, NULL, 0);
  665. i=0;
  666. XtSetArg(args[i], XtNheight,400); i++;
  667. XtSetValues(box,args,i);
  668. /* A dialogbox for the fontID-specification */
  669. dialogfontid=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  670. NULL, 0);
  671. i=0;
  672. XtSetArg(args[i], XtNlabel, "FontID:"); i++;
  673. XtSetArg(args[i], XtNvalue, "0"); i++;
  674. XtSetValues(dialogfontid,args,i);
  675. i=0;
  676. XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
  677. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  678. XtSetArg(args[i], XtNresize, FALSE); i++;
  679. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  680. XtSetValues(XtNameToWidget(dialogfontid,"value"),args,i);
  681. /* A dialogbox for the font-Size */
  682. dialogsize=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  683. NULL, 0);
  684. i=0;
  685. XtSetArg(args[i], XtNlabel, "Font-Size [bp]:"); i++;
  686. XtSetArg(args[i], XtNvalue, DEFAULT_SIZE); i++;
  687. XtSetValues(dialogsize,args,i);
  688. i=0;
  689. XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
  690. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  691. XtSetArg(args[i], XtNresize, FALSE); i++;
  692. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  693. XtSetValues(XtNameToWidget(dialogsize,"value"),args,i);
  694. /* A dialogbox for the font slant specification */
  695. dialogslant=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  696. NULL, 0);
  697. i=0;
  698. XtSetArg(args[i], XtNlabel, "Slant:"); i++;
  699. XtSetArg(args[i], XtNvalue, "0.0"); i++;
  700. XtSetValues(dialogslant,args,i);
  701. i=0;
  702. XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++;
  703. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  704. XtSetArg(args[i], XtNresize, FALSE); i++;
  705. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  706. XtSetValues(XtNameToWidget(dialogslant,"value"),args,i);
  707. /* A dialogbox for the font-extension */
  708. dialogextent=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  709. NULL, 0);
  710. i=0;
  711. XtSetArg(args[i], XtNlabel, "Extension:"); i++;
  712. XtSetArg(args[i], XtNvalue, "1.0"); i++;
  713. XtSetValues(dialogextent,args,i);
  714. i=0;
  715. XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++;
  716. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  717. XtSetArg(args[i], XtNresize, FALSE); i++;
  718. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  719. XtSetValues(XtNameToWidget(dialogextent,"value"),args,i);
  720. /* transformation matrix dialog widget */
  721. dialogtmatrix = XtCreateManagedWidget( "dialog1", dialogWidgetClass, box,
  722. NULL, 0);
  723. i=0;
  724. XtSetArg(args[i], XtNlabel, "Transformation-Matrix:"); i++;
  725. XtSetArg(args[i], XtNvalue, "1.0, 0.0, 0.0, 1.0"); i++;
  726. XtSetValues(dialogtmatrix,args,i);
  727. i=0;
  728. XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
  729. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  730. XtSetArg(args[i], XtNresize, FALSE); i++;
  731. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  732. XtSetValues(XtNameToWidget(dialogtmatrix,"value"),args,i);
  733. /* A dialogbox for the device resolution */
  734. dialogdevres=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  735. NULL, 0);
  736. i=0;
  737. XtSetArg(args[i], XtNlabel, "Res [DPI]"); i++;
  738. XtSetArg(args[i], XtNvalue, "72"); i++;
  739. XtSetValues(dialogdevres,args,i);
  740. i=0;
  741. XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++;
  742. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  743. XtSetArg(args[i], XtNresize, FALSE); i++;
  744. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  745. XtSetValues(XtNameToWidget(dialogdevres,"value"),args,i);
  746. /* A dialogbox for the strokewidth */
  747. dialogstroke=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  748. NULL, 0);
  749. i=0;
  750. XtSetArg(args[i], XtNlabel, "S-Width"); i++;
  751. if ( extraflags & CHECK_CACHE_STROKED ) {
  752. XtSetArg(args[i], XtNvalue, "10");
  753. i++;
  754. }
  755. else {
  756. XtSetArg(args[i], XtNvalue, "0");
  757. i++;
  758. }
  759. XtSetValues(dialogstroke,args,i);
  760. i=0;
  761. XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++;
  762. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  763. XtSetArg(args[i], XtNresize, FALSE); i++;
  764. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  765. XtSetValues(XtNameToWidget(dialogstroke,"value"),args,i);
  766. /* A dialogbox for the encoding filename */
  767. dialogencfile=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  768. NULL, 0);
  769. i=0;
  770. XtSetArg(args[i], XtNlabel, "Encoding-File:"); i++;
  771. XtSetArg(args[i], XtNvalue, ""); i++;
  772. XtSetValues(dialogencfile,args,i);
  773. i=0;
  774. XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
  775. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  776. XtSetArg(args[i], XtNresize, FALSE); i++;
  777. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  778. XtSetValues(XtNameToWidget(dialogencfile,"value"),args,i);
  779. /* A dialogbox for the angle */
  780. dialogangle=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  781. NULL, 0);
  782. i=0;
  783. XtSetArg(args[i], XtNlabel, "Angle [deg]:"); i++;
  784. XtSetArg(args[i], XtNvalue, "0.0"); i++;
  785. XtSetValues(dialogangle,args,i);
  786. i=0;
  787. XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
  788. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  789. XtSetArg(args[i], XtNresize, FALSE); i++;
  790. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  791. XtSetValues(XtNameToWidget(dialogangle,"value"),args,i);
  792. /* A dialogbox for the space-offset in strings */
  793. dialogspace=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  794. NULL, 0);
  795. i=0;
  796. XtSetArg(args[i], XtNlabel, "Space-Off [1/1000 bp]:"); i++;
  797. XtSetArg(args[i], XtNvalue, "0"); i++;
  798. XtSetValues(dialogspace,args,i);
  799. i=0;
  800. XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
  801. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  802. XtSetArg(args[i], XtNresize, FALSE); i++;
  803. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  804. XtSetValues(XtNameToWidget(dialogspace,"value"),args,i);
  805. /* A dialogbox for the character */
  806. dialogtestcharacter=XtCreateManagedWidget("dialog1", dialogWidgetClass, box,
  807. NULL, 0);
  808. i=0;
  809. XtSetArg(args[i], XtNlabel, "Character (decimal):"); i++;
  810. XtSetArg(args[i], XtNvalue, DEFAULT_CHAR); i++;
  811. XtSetValues(dialogtestcharacter,args,i);
  812. i=0;
  813. XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++;
  814. XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++;
  815. XtSetArg(args[i], XtNresize, FALSE); i++;
  816. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  817. XtSetValues(XtNameToWidget(dialogtestcharacter,"value"),args,i);
  818. /* The box for color selecting buttons for the
  819. X11-rastering functions */
  820. optionsbox=XtCreateManagedWidget("box", boxWidgetClass, box, NULL, 0);
  821. i=0;
  822. XtSetArg(args[i], XtNheight, DIALOGHEIGHT); i++;
  823. XtSetArg(args[i], XtNwidth, DIALOGWIDTH + 30); i++;
  824. XtSetValues(optionsbox,args,i);
  825. /* The toggle widget for kerning (un-)setting */
  826. kerningbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
  827. NULL, 0);
  828. i=0;
  829. XtSetArg( args[i], XtNwidth, 55 ); i++;
  830. XtSetArg( args[i], XtNheight, 20 ); i++;
  831. XtSetArg( args[i], XtNlabel, "Kerning" ); i++;
  832. XtSetValues(kerningbutton,args,i);
  833. XtAddCallback( kerningbutton, XtNcallback,
  834. (XtCallbackProc) togglekerning, (XtPointer) 0 );
  835. /* The toggle widget for ligatur-detection (un-)setting */
  836. ligaturbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
  837. NULL, 0);
  838. i=0;
  839. XtSetArg( args[i], XtNwidth, 55 ); i++;
  840. XtSetArg( args[i], XtNheight, 20 ); i++;
  841. XtSetArg( args[i], XtNlabel, "Ligature" ); i++;
  842. XtSetValues(ligaturbutton,args,i);
  843. XtAddCallback( ligaturbutton, XtNcallback,
  844. (XtCallbackProc) toggleligatur, (XtPointer) 0 );
  845. /* The toggle widget for the typesetting direction switch message */
  846. r2lbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
  847. NULL, 0);
  848. i=0;
  849. XtSetArg( args[i], XtNwidth, 55 ); i++;
  850. XtSetArg( args[i], XtNheight, 20 ); i++;
  851. XtSetArg( args[i], XtNlabel, "|-->" ); i++;
  852. XtSetValues(r2lbutton,args,i);
  853. XtAddCallback( r2lbutton, XtNcallback,
  854. (XtCallbackProc) toggler2l, (XtPointer) 0 );
  855. /* The toggle widget for underlining (un-)setting */
  856. underlinebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
  857. NULL, 0);
  858. i=0;
  859. XtSetArg( args[i], XtNwidth, 55 ); i++;
  860. XtSetArg( args[i], XtNheight, 20 ); i++;
  861. XtSetArg( args[i], XtNlabel, "Underline" ); i++;
  862. XtSetValues(underlinebutton,args,i);
  863. XtAddCallback( underlinebutton, XtNcallback,
  864. (XtCallbackProc) toggleunderline, (XtPointer) 0 );
  865. /* The toggle widget for underlining (un-)setting */
  866. overlinebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
  867. NULL, 0);
  868. i=0;
  869. XtSetArg( args[i], XtNwidth, 55 ); i++;
  870. XtSetArg( args[i], XtNheight, 20 ); i++;
  871. XtSetArg( args[i], XtNlabel, "Overline" ); i++;
  872. XtSetValues(overlinebutton,args,i);
  873. XtAddCallback( overlinebutton, XtNcallback,
  874. (XtCallbackProc) toggleoverline, (XtPointer) 0 );
  875. /* The toggle widget for underlining (un-)setting */
  876. overstrikebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox,
  877. NULL, 0);
  878. i=0;
  879. XtSetArg( args[i], XtNwidth, 55 ); i++;
  880. XtSetArg( args[i], XtNheight, 20 ); i++;
  881. XtSetArg( args[i], XtNlabel, "Overstrike" ); i++;
  882. XtSetValues(overstrikebutton,args,i);
  883. XtAddCallback( overstrikebutton, XtNcallback,
  884. (XtCallbackProc) toggleoverstrike, (XtPointer) 0 );
  885. /* The button to raster and display the current character using
  886. the current settings */
  887. showcharbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
  888. NULL, 0);
  889. i=0;
  890. XtSetArg( args[i], XtNwidth, 60 ); i++;
  891. XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
  892. XtSetArg( args[i], XtNlabel, "Char"); i++;
  893. XtSetValues(showcharbutton,args,i);
  894. XtAddCallback( showcharbutton, XtNcallback,
  895. (XtCallbackProc) showchar, (XtPointer) 0 );
  896. /* The button to raster and display the current string using
  897. the current settings */
  898. showstringbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
  899. NULL, 0);
  900. i=0;
  901. XtSetArg( args[i], XtNwidth, 60 ); i++;
  902. XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
  903. XtSetArg( args[i], XtNlabel, "String"); i++;
  904. XtSetValues(showstringbutton,args,i);
  905. XtAddCallback( showstringbutton, XtNcallback,
  906. (XtCallbackProc) showstring, (XtPointer) 0 );
  907. /* The button to raster and display the current character using
  908. the current settings and antialiasing */
  909. aashowcharbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
  910. NULL, 0);
  911. i=0;
  912. XtSetArg( args[i], XtNwidth, 120 ); i++;
  913. XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
  914. XtSetArg( args[i], XtNlabel, "AAChar"); i++;
  915. XtSetValues(aashowcharbutton,args,i);
  916. XtAddCallback( aashowcharbutton, XtNcallback,
  917. (XtCallbackProc) aashowchar, (XtPointer) 0 );
  918. /* The button to raster and display the current string using
  919. the current settings and antialiasing */
  920. aashowstringbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
  921. NULL, 0);
  922. i=0;
  923. XtSetArg( args[i], XtNwidth, 120 ); i++;
  924. XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
  925. XtSetArg( args[i], XtNlabel, "AAString"); i++;
  926. XtSetValues(aashowstringbutton,args,i);
  927. XtAddCallback( aashowstringbutton, XtNcallback,
  928. (XtCallbackProc) aashowstring, (XtPointer) 0 );
  929. /* The button to raster and display the current character using
  930. the current settings */
  931. showcharbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box,
  932. NULL, 0);
  933. i=0;
  934. XtSetArg( args[i], XtNwidth, 60 ); i++;
  935. XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
  936. XtSetArg( args[i], XtNlabel, "CharX"); i++;
  937. XtSetValues(showcharbuttonX,args,i);
  938. XtAddCallback( showcharbuttonX, XtNcallback,
  939. (XtCallbackProc) showcharX, (XtPointer) 0 );
  940. /* The button to raster and display the current string using
  941. the current settings */
  942. showstringbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box,
  943. NULL, 0);
  944. i=0;
  945. XtSetArg( args[i], XtNwidth, 60 ); i++;
  946. XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
  947. XtSetArg( args[i], XtNlabel, "StringX"); i++;
  948. XtSetValues(showstringbuttonX,args,i);
  949. XtAddCallback( showstringbuttonX, XtNcallback,
  950. (XtCallbackProc) showstringX, (XtPointer) 0 );
  951. /* The button to raster and display the current character using
  952. the current settings and antialiasing */
  953. aashowcharbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box,
  954. NULL, 0);
  955. i=0;
  956. XtSetArg( args[i], XtNwidth, 120 ); i++;
  957. XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
  958. XtSetArg( args[i], XtNlabel, "AACharX"); i++;
  959. XtSetValues(aashowcharbuttonX,args,i);
  960. XtAddCallback( aashowcharbuttonX, XtNcallback,
  961. (XtCallbackProc) aashowcharX, (XtPointer) 0 );
  962. /* The button to raster and display the current string using
  963. the current settings and antialiasing */
  964. aashowstringbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box,
  965. NULL, 0);
  966. i=0;
  967. XtSetArg( args[i], XtNwidth, 120 ); i++;
  968. XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++;
  969. XtSetArg( args[i], XtNlabel, "AAStringX"); i++;
  970. XtSetValues(aashowstringbuttonX,args,i);
  971. XtAddCallback( aashowstringbuttonX, XtNcallback,
  972. (XtCallbackProc) aashowstringX, (XtPointer) 0 );
  973. /* The box for color trasp/op and fonttable button */
  974. transbox=XtCreateManagedWidget("box", boxWidgetClass, box, NULL, 0);
  975. i=0;
  976. XtSetArg(args[i], XtNheight,20); i++;
  977. XtSetArg(args[i], XtNwidth,90); i++;
  978. XtSetValues(transbox,args,i);
  979. /* The button to display an AA font table */
  980. fonttablebutton = XtCreateManagedWidget("Com", commandWidgetClass, transbox,
  981. NULL, 0);
  982. i=0;
  983. XtSetArg( args[i], XtNwidth, 80 ); i++;
  984. XtSetArg( args[i], XtNheight, 15 ); i++;
  985. XtSetArg( args[i], XtNlabel, "Font Table"); i++;
  986. XtSetValues(fonttablebutton,args,i);
  987. XtAddCallback( fonttablebutton, XtNcallback,
  988. (XtCallbackProc) fonttable, (XtPointer) 0 );
  989. /* The toggle widget for opacity/transparency */
  990. opacitybutton = XtCreateManagedWidget("toggle", toggleWidgetClass, transbox,
  991. NULL, 0);
  992. i=0;
  993. XtSetArg( args[i], XtNwidth, 80 ); i++;
  994. XtSetArg( args[i], XtNheight, 15 ); i++;
  995. XtSetArg( args[i], XtNlabel, "Transparent" ); i++;
  996. XtSetValues(opacitybutton,args,i);
  997. XtAddCallback( opacitybutton, XtNcallback,
  998. (XtCallbackProc) toggleopacity, (XtPointer) 0 );
  999. outbg=pink4.pixel; /* the initial bgcolor for transparent mode */
  1000. /* The toggle widget for opacity/transparency */
  1001. aalevelbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, transbox,
  1002. NULL, 0);
  1003. i=0;
  1004. XtSetArg( args[i], XtNwidth, 80 ); i++;
  1005. XtSetArg( args[i], XtNheight, 15 ); i++;
  1006. XtSetArg( args[i], XtNlabel, "AA-Low" ); i++;
  1007. XtSetValues(aalevelbutton,args,i);
  1008. XtAddCallback( aalevelbutton, XtNcallback,
  1009. (XtCallbackProc) toggleaalevel, (XtPointer) 0 );
  1010. aalevel=T1_AA_LOW; /* the initial bgcolor for transparent mode */
  1011. /* The box for color selecting buttons for the
  1012. X11-rastering functions */
  1013. colorbox=XtCreateManagedWidget("box", boxWidgetClass, box, NULL, 0);
  1014. i=0;
  1015. XtSetArg(args[i], XtNheight,20); i++;
  1016. XtSetArg(args[i], XtNwidth,280); i++;
  1017. XtSetValues(colorbox,args,i);
  1018. /* FG-label */
  1019. fgstatus = XtCreateManagedWidget("label", labelWidgetClass, colorbox,
  1020. NULL, 0);
  1021. i=0;
  1022. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1023. XtSetArg( args[i], XtNheight, 20 ); i++;
  1024. XtSetArg( args[i], XtNlabel, ""); i++;
  1025. XtSetArg( args[i], XtNbackground, fg); i++;
  1026. XtSetValues(fgstatus,args,i);
  1027. fglabel = XtCreateManagedWidget("label", labelWidgetClass, colorbox,
  1028. NULL, 0);
  1029. i=0;
  1030. XtSetArg( args[i], XtNwidth, 80 ); i++;
  1031. XtSetArg( args[i], XtNheight, 20 ); i++;
  1032. XtSetArg( args[i], XtNlabel, "Foreground"); i++;
  1033. XtSetValues(fglabel,args,i);
  1034. fgwhitebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1035. NULL, 0);
  1036. i=0;
  1037. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1038. XtSetArg( args[i], XtNheight, 20 ); i++;
  1039. XtSetArg( args[i], XtNlabel, ""); i++;
  1040. XtSetArg( args[i], XtNbackground, white.pixel); i++;
  1041. XtSetValues(fgwhitebutton,args,i);
  1042. XtAddCallback( fgwhitebutton, XtNcallback,
  1043. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1044. fgblackbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1045. NULL, 0);
  1046. i=0;
  1047. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1048. XtSetArg( args[i], XtNheight, 20 ); i++;
  1049. XtSetArg( args[i], XtNlabel, ""); i++;
  1050. XtSetArg( args[i], XtNbackground, black.pixel); i++;
  1051. XtSetValues(fgblackbutton,args,i);
  1052. XtAddCallback( fgblackbutton, XtNcallback,
  1053. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1054. fggraybutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1055. NULL, 0);
  1056. i=0;
  1057. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1058. XtSetArg( args[i], XtNheight, 20 ); i++;
  1059. XtSetArg( args[i], XtNlabel, ""); i++;
  1060. XtSetArg( args[i], XtNbackground, gray.pixel); i++;
  1061. XtSetValues(fggraybutton,args,i);
  1062. XtAddCallback( fggraybutton, XtNcallback,
  1063. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1064. fgredbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1065. NULL, 0);
  1066. i=0;
  1067. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1068. XtSetArg( args[i], XtNheight, 20 ); i++;
  1069. XtSetArg( args[i], XtNlabel, ""); i++;
  1070. XtSetArg( args[i], XtNbackground, red.pixel); i++;
  1071. XtSetValues(fgredbutton,args,i);
  1072. XtAddCallback( fgredbutton, XtNcallback,
  1073. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1074. fggreenbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1075. NULL, 0);
  1076. i=0;
  1077. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1078. XtSetArg( args[i], XtNheight, 20 ); i++;
  1079. XtSetArg( args[i], XtNlabel, ""); i++;
  1080. XtSetArg( args[i], XtNbackground, green.pixel); i++;
  1081. XtSetValues(fggreenbutton,args,i);
  1082. XtAddCallback( fggreenbutton, XtNcallback,
  1083. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1084. fgbluebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1085. NULL, 0);
  1086. i=0;
  1087. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1088. XtSetArg( args[i], XtNheight, 20 ); i++;
  1089. XtSetArg( args[i], XtNlabel, ""); i++;
  1090. XtSetArg( args[i], XtNbackground, blue.pixel); i++;
  1091. XtSetValues(fgbluebutton,args,i);
  1092. XtAddCallback( fgbluebutton, XtNcallback,
  1093. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1094. /* BG-label */
  1095. bgstatus = XtCreateManagedWidget("label", labelWidgetClass, colorbox,
  1096. NULL, 0);
  1097. i=0;
  1098. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1099. XtSetArg( args[i], XtNheight, 20 ); i++;
  1100. XtSetArg( args[i], XtNlabel, ""); i++;
  1101. XtSetArg( args[i], XtNbackground, bg); i++;
  1102. XtSetValues(bgstatus,args,i);
  1103. bglabel = XtCreateManagedWidget("label", labelWidgetClass, colorbox,
  1104. NULL, 0);
  1105. i=0;
  1106. XtSetArg( args[i], XtNwidth, 80 ); i++;
  1107. XtSetArg( args[i], XtNheight, 20 ); i++;
  1108. XtSetArg( args[i], XtNlabel, "Background"); i++;
  1109. XtSetValues(bglabel,args,i);
  1110. bgwhitebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1111. NULL, 0);
  1112. i=0;
  1113. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1114. XtSetArg( args[i], XtNheight, 20 ); i++;
  1115. XtSetArg( args[i], XtNlabel, ""); i++;
  1116. XtSetArg( args[i], XtNbackground, white.pixel); i++;
  1117. XtSetValues(bgwhitebutton,args,i);
  1118. XtAddCallback( bgwhitebutton, XtNcallback,
  1119. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1120. bgblackbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1121. NULL, 0);
  1122. i=0;
  1123. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1124. XtSetArg( args[i], XtNheight, 20 ); i++;
  1125. XtSetArg( args[i], XtNlabel, ""); i++;
  1126. XtSetArg( args[i], XtNbackground, black.pixel); i++;
  1127. XtSetValues(bgblackbutton,args,i);
  1128. XtAddCallback( bgblackbutton, XtNcallback,
  1129. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1130. bggraybutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1131. NULL, 0);
  1132. i=0;
  1133. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1134. XtSetArg( args[i], XtNheight, 20 ); i++;
  1135. XtSetArg( args[i], XtNlabel, ""); i++;
  1136. XtSetArg( args[i], XtNbackground, gray.pixel); i++;
  1137. XtSetValues(bggraybutton,args,i);
  1138. XtAddCallback( bggraybutton, XtNcallback,
  1139. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1140. bgredbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1141. NULL, 0);
  1142. i=0;
  1143. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1144. XtSetArg( args[i], XtNheight, 20 ); i++;
  1145. XtSetArg( args[i], XtNlabel, ""); i++;
  1146. XtSetArg( args[i], XtNbackground, red.pixel); i++;
  1147. XtSetValues(bgredbutton,args,i);
  1148. XtAddCallback( bgredbutton, XtNcallback,
  1149. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1150. bggreenbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1151. NULL, 0);
  1152. i=0;
  1153. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1154. XtSetArg( args[i], XtNheight, 20 ); i++;
  1155. XtSetArg( args[i], XtNlabel, ""); i++;
  1156. XtSetArg( args[i], XtNbackground, green.pixel); i++;
  1157. XtSetValues(bggreenbutton,args,i);
  1158. XtAddCallback( bggreenbutton, XtNcallback,
  1159. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1160. bgbluebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox,
  1161. NULL, 0);
  1162. i=0;
  1163. XtSetArg( args[i], XtNwidth, 20 ); i++;
  1164. XtSetArg( args[i], XtNheight, 20 ); i++;
  1165. XtSetArg( args[i], XtNlabel, ""); i++;
  1166. XtSetArg( args[i], XtNbackground, blue.pixel); i++;
  1167. XtSetValues(bgbluebutton,args,i);
  1168. XtAddCallback( bgbluebutton, XtNcallback,
  1169. (XtCallbackProc) setcolor, (XtPointer) 0 );
  1170. /* Label for the next box */
  1171. stringlabel=XtCreateManagedWidget("Label", labelWidgetClass, box,
  1172. NULL, 0);
  1173. i=0;
  1174. XtSetArg(args[i], XtNwidth,380); i++;
  1175. XtSetArg(args[i], XtNlabel, "Test-String:"); i++;
  1176. XtSetValues(stringlabel,args,i);
  1177. /* An input-box for the test-string */
  1178. dialogteststring=XtCreateManagedWidget("dialog1", asciiTextWidgetClass, box,
  1179. NULL, 0);
  1180. i=0;
  1181. XtSetArg(args[i], XtNwidth,380); i++;
  1182. XtSetArg(args[i], XtNheight,30); i++;
  1183. XtSetArg(args[i], XtNwrap, XawtextWrapLine); i++;
  1184. XtSetArg(args[i], XtNeditType, XawtextEdit ); i++;
  1185. XtSetArg(args[i], XtNforeground, edit_color.pixel); i++;
  1186. XtSetValues(dialogteststring,args,i);
  1187. /* Label for the next box */
  1188. labelstatus=XtCreateManagedWidget("Label", labelWidgetClass, box,
  1189. NULL, 0);
  1190. i=0;
  1191. XtSetArg(args[i], XtNwidth,380); i++;
  1192. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1193. XtSetArg(args[i], XtNlabel, "No Messages!"); i++;
  1194. XtSetValues(labelstatus,args,i);
  1195. /* The button to exit the program */
  1196. exitbutton = XtCreateManagedWidget("Com2", commandWidgetClass, box,
  1197. NULL, 0);
  1198. i=0;
  1199. XtSetArg( args[i], XtNwidth, 100 ); i++;
  1200. XtSetArg( args[i], XtNheight, 20 ); i++;
  1201. XtSetArg( args[i], XtNx, 0 ); i++;
  1202. XtSetArg( args[i], XtNy, 0 ); i++;
  1203. XtSetArg( args[i], XtNlabel, " Exit Program"); i++;
  1204. XtSetValues(exitbutton,args,i);
  1205. XtAddCallback( exitbutton, XtNcallback,
  1206. (XtCallbackProc) exitprog, (XtPointer) 0 );
  1207. /* The About widget for the about message */
  1208. aboutbutton = XtCreateManagedWidget("Com", commandWidgetClass, box,
  1209. NULL, 0);
  1210. i=0;
  1211. XtSetArg( args[i], XtNwidth, 55 ); i++;
  1212. XtSetArg( args[i], XtNheight, 20 ); i++;
  1213. XtSetArg( args[i], XtNlabel, "About" ); i++;
  1214. XtSetValues(aboutbutton,args,i);
  1215. XtAddCallback( aboutbutton, XtNcallback,
  1216. (XtCallbackProc) showabout, (XtPointer) 0 );
  1217. XtRealizeWidget(TopLevel);
  1218. XtPopup(Output,XtGrabNone);
  1219. if( extraflags & CHECK_PERFORMANCE){
  1220. XtPopup(Output2,XtGrabNone);
  1221. }
  1222. /* Set parameters for X11-support */
  1223. T1_SetX11Params( display, DefaultVisual(display, screennumber),
  1224. DefaultDepth( display, screennumber),
  1225. DefaultColormap(display, screennumber));
  1226. /* Create a dummy-pixmap because we need one to destroy before
  1227. the next is created! */
  1228. pixmap = XCreatePixmap(display,
  1229. XtWindow(OutputWindow),
  1230. 200,
  1231. 200,
  1232. DefaultDepth(display,screennumber)
  1233. );
  1234. XtAppMainLoop(TopLevelApp);
  1235. return(0);
  1236. }
  1237. /* Compute the BBox of a rotated box: */
  1238. BBox ComputeRotBBox( BBox inbox, float angle)
  1239. {
  1240. int i;
  1241. BBox resultbox={ 0, 0, 0, 0};
  1242. struct point
  1243. {
  1244. double x;
  1245. double y;
  1246. } p[4], P[4];
  1247. double sinalpha, cosalpha;
  1248. sinalpha=sin((double)angle*PI/180);
  1249. cosalpha=cos((double)angle*PI/180);
  1250. /* initialize points */
  1251. p[0].x=(double) inbox.llx;
  1252. p[0].y=(double) inbox.lly;
  1253. p[1].x=(double) inbox.urx;
  1254. p[1].y=(double) inbox.lly;
  1255. p[2].x=(double) inbox.urx;
  1256. p[2].y=(double) inbox.ury;
  1257. p[3].x=(double) inbox.llx;
  1258. p[3].y=(double) inbox.ury;
  1259. /*
  1260. fprintf( stderr, "InBox: (%f,%f), (%f,%f), (%f,%f), (%f,%f)\n",
  1261. p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y,
  1262. p[3].x, p[3].y);
  1263. */
  1264. /* Compute tranformed points */
  1265. P[0].x=p[0].x*cosalpha-p[0].y*sinalpha;
  1266. P[0].y=p[0].x*sinalpha+p[0].y*cosalpha;
  1267. P[1].x=p[1].x*cosalpha-p[1].y*sinalpha;
  1268. P[1].y=p[1].x*sinalpha+p[1].y*cosalpha;
  1269. P[2].x=p[2].x*cosalpha-p[2].y*sinalpha;
  1270. P[2].y=p[2].x*sinalpha+p[2].y*cosalpha;
  1271. P[3].x=p[3].x*cosalpha-p[3].y*sinalpha;
  1272. P[3].y=p[3].x*sinalpha+p[3].y*cosalpha;
  1273. /*
  1274. fprintf( stderr, "RotPoints: (%f,%f), (%f,%f), (%f,%f), (%f,%f)\n",
  1275. P[0].x, P[0].y, P[1].x, P[1].y, P[2].x, P[2].y,
  1276. P[3].x, P[3].y);
  1277. */
  1278. /* Get BBox: */
  1279. for (i=0; i<4; i++){
  1280. if (P[i].x < (float) resultbox.llx)
  1281. resultbox.llx=(int) floor(P[i].x +0.5);
  1282. if (P[i].x > (float) resultbox.urx)
  1283. resultbox.urx=(int) floor(P[i].x +0.5);
  1284. if (P[i].y < (float) resultbox.lly)
  1285. resultbox.lly=(int) floor(P[i].y +0.5);
  1286. if (P[i].y > (float) resultbox.ury)
  1287. resultbox.ury=(int) floor(P[i].y +0.5);
  1288. }
  1289. return(resultbox);
  1290. }
  1291. void exitprog(Widget exitbutton, XtPointer client_data , XtPointer call_data)
  1292. {
  1293. int i;
  1294. for (i=0; i< T1_GetNoFonts(); i++){
  1295. /* printf("Enc-Scheme=%s\n", T1_GetEncodingScheme( i));*/
  1296. ;
  1297. }
  1298. T1_CloseLib();
  1299. exit(0);
  1300. }
  1301. void togglekerning( Widget kerningbutton, XtPointer client_data, XtPointer call_data)
  1302. {
  1303. int i;
  1304. char state=0;
  1305. Arg args[10];
  1306. /* Get state of toggle Button: */
  1307. i=0;
  1308. XtSetArg(args[i], XtNstate, &state); i++;
  1309. XtGetValues(kerningbutton,args,1);
  1310. if ((state))
  1311. Modflag |= T1_KERNING;
  1312. else
  1313. Modflag &= ~T1_KERNING;
  1314. }
  1315. void toggleligatur( Widget ligaturbutton, XtPointer client_data, XtPointer call_data)
  1316. {
  1317. int i;
  1318. char state=0;
  1319. Arg args[10];
  1320. /* Get state of toggle Button: */
  1321. i=0;
  1322. XtSetArg(args[i], XtNstate, &state); i++;
  1323. XtGetValues(ligaturbutton,args,1);
  1324. LigDetect=state;
  1325. }
  1326. void toggler2l( Widget r2lbutton, XtPointer client_data, XtPointer call_data)
  1327. {
  1328. int i;
  1329. char state=0;
  1330. Arg args[10];
  1331. /* Get state of toggle Button: */
  1332. i=0;
  1333. XtSetArg(args[i], XtNstate, &state); i++;
  1334. XtGetValues(r2lbutton,args,1);
  1335. if ((state))
  1336. Modflag |= T1_RIGHT_TO_LEFT;
  1337. else
  1338. Modflag &= ~T1_RIGHT_TO_LEFT;
  1339. /* Invert state */
  1340. i=0;
  1341. if (state){
  1342. XtSetArg( args[i], XtNwidth, 55 ); i++;
  1343. XtSetArg( args[i], XtNheight, 20 ); i++;
  1344. XtSetArg( args[i], XtNlabel, "<--|" ); i++;
  1345. }
  1346. else{
  1347. XtSetArg( args[i], XtNwidth, 55 ); i++;
  1348. XtSetArg( args[i], XtNheight, 20 ); i++;
  1349. XtSetArg( args[i], XtNlabel, "|-->" ); i++;
  1350. }
  1351. XtSetValues(r2lbutton,args,i);
  1352. }
  1353. void toggleunderline( Widget underlinebutton, XtPointer client_data, XtPointer call_data)
  1354. {
  1355. int i;
  1356. char state=0;
  1357. Arg args[10];
  1358. /* Get state of toggle Button: */
  1359. i=0;
  1360. XtSetArg(args[i], XtNstate, &state); i++;
  1361. XtGetValues(underlinebutton,args,1);
  1362. if ((state))
  1363. Modflag |= T1_UNDERLINE;
  1364. else
  1365. Modflag &= ~T1_UNDERLINE;
  1366. }
  1367. void toggleoverline( Widget overlinebutton, XtPointer client_data, XtPointer call_data)
  1368. {
  1369. int i;
  1370. char state=0;
  1371. Arg args[10];
  1372. /* Get state of toggle Button: */
  1373. i=0;
  1374. XtSetArg(args[i], XtNstate, &state); i++;
  1375. XtGetValues( overlinebutton,args,1);
  1376. if ((state))
  1377. Modflag |= T1_OVERLINE;
  1378. else
  1379. Modflag &= ~T1_OVERLINE;
  1380. }
  1381. void toggleoverstrike( Widget overstrikebutton, XtPointer client_data, XtPointer call_data)
  1382. {
  1383. int i;
  1384. char state=0;
  1385. Arg args[10];
  1386. /* Get state of toggle Button: */
  1387. i=0;
  1388. XtSetArg(args[i], XtNstate, &state); i++;
  1389. XtGetValues( overstrikebutton,args,1);
  1390. if ((state))
  1391. Modflag |= T1_OVERSTRIKE;
  1392. else
  1393. Modflag &= ~T1_OVERSTRIKE;
  1394. }
  1395. void toggleopacity( Widget opacitybutton, XtPointer client_data, XtPointer call_data)
  1396. {
  1397. int i;
  1398. char state=0;
  1399. Arg args[10];
  1400. /* Get state of toggle Button: */
  1401. i=0;
  1402. XtSetArg(args[i], XtNstate, &state); i++;
  1403. XtGetValues(opacitybutton,args,1);
  1404. i=0;
  1405. XtSetArg( args[i], XtNstate, state); i++;
  1406. XtSetArg( args[i], XtNwidth, 80 ); i++;
  1407. XtSetArg( args[i], XtNheight, 20 ); i++;
  1408. Opacity=state;
  1409. /* Invert state */
  1410. if (state){
  1411. XtSetArg( args[i], XtNlabel, "Opaque" ); i++;
  1412. XtSetValues(opacitybutton,args,i);
  1413. outbg=bg;
  1414. }
  1415. else{
  1416. XtSetArg

Large files files are truncated, but you can click here to view the full file