PageRenderTime 75ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  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( args[i], XtNlabel, "Transparent" ); i++;
  1417. XtSetValues(opacitybutton,args,i);
  1418. outbg=pink4.pixel;
  1419. }
  1420. }
  1421. /* Toggle the antialiasing level */
  1422. void toggleaalevel( Widget aalevelbutton, XtPointer client_data, XtPointer call_data)
  1423. {
  1424. int i;
  1425. char state=0;
  1426. Arg args[10];
  1427. /* Get state of toggle Button: */
  1428. i=0;
  1429. XtSetArg(args[i], XtNstate, &state); i++;
  1430. XtGetValues( aalevelbutton,args,1);
  1431. i=0;
  1432. XtSetArg( args[i], XtNstate, state); i++;
  1433. XtSetArg( args[i], XtNwidth, 80 ); i++;
  1434. XtSetArg( args[i], XtNheight, 15 ); i++;
  1435. /* Invert state */
  1436. if (state){
  1437. XtSetArg( args[i], XtNlabel, "AA-High" ); i++;
  1438. XtSetValues(aalevelbutton,args,i);
  1439. aalevel=T1_AA_HIGH;
  1440. }
  1441. else{
  1442. XtSetArg( args[i], XtNlabel, "AA-Low" ); i++;
  1443. XtSetValues(aalevelbutton,args,i);
  1444. aalevel=T1_AA_LOW;
  1445. }
  1446. }
  1447. /* Set a new fore/background color */
  1448. void setcolor( Widget widget, XtPointer client_data, XtPointer call_data)
  1449. {
  1450. int i;
  1451. Arg args[10];
  1452. /* foreground colors */
  1453. if (widget==fgwhitebutton){
  1454. fg=white.pixel;
  1455. i=0;
  1456. XtSetArg( args[i], XtNbackground, fg ); i++;
  1457. XtSetValues(fgstatus,args,i);
  1458. return;
  1459. }
  1460. if (widget==fgblackbutton){
  1461. fg=black.pixel;
  1462. i=0;
  1463. XtSetArg( args[i], XtNbackground, fg ); i++;
  1464. XtSetValues(fgstatus,args,i);
  1465. return;
  1466. }
  1467. if (widget==fggraybutton){
  1468. fg=gray.pixel;
  1469. i=0;
  1470. XtSetArg( args[i], XtNbackground, fg ); i++;
  1471. XtSetValues(fgstatus,args,i);
  1472. return;
  1473. }
  1474. if (widget==fgredbutton){
  1475. fg=red.pixel;
  1476. i=0;
  1477. XtSetArg( args[i], XtNbackground, fg ); i++;
  1478. XtSetValues(fgstatus,args,i);
  1479. return;
  1480. }
  1481. if (widget==fggreenbutton){
  1482. fg=green.pixel;
  1483. i=0;
  1484. XtSetArg( args[i], XtNbackground, fg ); i++;
  1485. XtSetValues(fgstatus,args,i);
  1486. return;
  1487. }
  1488. if (widget==fgbluebutton){
  1489. fg=blue.pixel;
  1490. i=0;
  1491. XtSetArg( args[i], XtNbackground, fg ); i++;
  1492. XtSetValues(fgstatus,args,i);
  1493. return;
  1494. }
  1495. /* background colors */
  1496. if (widget==bgwhitebutton){
  1497. bg=white.pixel;
  1498. if (Opacity)
  1499. outbg=bg;
  1500. i=0;
  1501. XtSetArg( args[i], XtNbackground, bg ); i++;
  1502. XtSetValues(bgstatus,args,i);
  1503. return;
  1504. }
  1505. if (widget==bgblackbutton){
  1506. bg=black.pixel;
  1507. if (Opacity)
  1508. outbg=bg;
  1509. i=0;
  1510. XtSetArg( args[i], XtNbackground, bg ); i++;
  1511. XtSetValues(bgstatus,args,i);
  1512. return;
  1513. }
  1514. if (widget==bggraybutton){
  1515. bg=gray.pixel;
  1516. if (Opacity)
  1517. outbg=bg;
  1518. i=0;
  1519. XtSetArg( args[i], XtNbackground, bg ); i++;
  1520. XtSetValues(bgstatus,args,i);
  1521. return;
  1522. }
  1523. if (widget==bgredbutton){
  1524. bg=red.pixel;
  1525. if (Opacity)
  1526. outbg=bg;
  1527. i=0;
  1528. XtSetArg( args[i], XtNbackground, bg ); i++;
  1529. XtSetValues(bgstatus,args,i);
  1530. return;
  1531. }
  1532. if (widget==bggreenbutton){
  1533. bg=green.pixel;
  1534. if (Opacity)
  1535. outbg=bg;
  1536. i=0;
  1537. XtSetArg( args[i], XtNbackground, bg ); i++;
  1538. XtSetValues(bgstatus,args,i);
  1539. return;
  1540. }
  1541. if (widget==bgbluebutton){
  1542. bg=blue.pixel;
  1543. if (Opacity)
  1544. outbg=bg;
  1545. i=0;
  1546. XtSetArg( args[i], XtNbackground, bg ); i++;
  1547. XtSetValues(bgstatus,args,i);
  1548. return;
  1549. }
  1550. /* we shouldn't get here */
  1551. return;
  1552. }
  1553. void showchar( Widget showcharbutton, XtPointer client_data, XtPointer call_data)
  1554. {
  1555. int i, j;
  1556. Arg args[10];
  1557. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  1558. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  1559. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  1560. sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
  1561. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  1562. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  1563. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  1564. sprintf(statusstring, "t1lib: FontID out of range!");
  1565. i=0;
  1566. XtSetArg(args[i], XtNbitmap,NULL); i++;
  1567. XtSetArg(args[i], XtNwidth,380); i++;
  1568. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1569. XtSetArg(args[i], XtNlabel, statusstring); i++;
  1570. XtSetValues(labelstatus,args,i);
  1571. return;
  1572. }
  1573. /* Ensure that font is loaded before any operation on the font */
  1574. if ( T1_CheckForFontID( FontID) < 1 ) {
  1575. T1_LoadFont( FontID);
  1576. }
  1577. if ( StrokeWidth == 0.0f ) {
  1578. T1_ClearStrokeFlag( FontID);
  1579. }
  1580. else {
  1581. T1_SetStrokeFlag( FontID);
  1582. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  1583. sprintf( statusstring, "t1lib: Unable to setup strokewidth!");
  1584. i=0;
  1585. XtSetArg(args[i], XtNbitmap,NULL); i++;
  1586. XtSetArg(args[i], XtNwidth,380); i++;
  1587. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1588. XtSetArg(args[i], XtNlabel, statusstring); i++;
  1589. XtSetValues(labelstatus,args,i);
  1590. return;
  1591. }
  1592. }
  1593. if (CheckTransform()==0 && Angle==0.0){
  1594. matrixP=NULL;
  1595. }
  1596. else{
  1597. matrixP=T1_RotateMatrix( &matrix, Angle);
  1598. }
  1599. if (DeviceResolution!=last_resolution[FontID]){
  1600. /* Delete all size dependent data for that font */
  1601. for ( i=0; i<T1_GetNoFonts(); i++)
  1602. T1_DeleteAllSizes( i);
  1603. /* Establish new device resolution */
  1604. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  1605. /* Store current resolution */
  1606. last_resolution[FontID]=DeviceResolution;
  1607. }
  1608. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  1609. if (i==EOF) EncodingFile[0]=0;
  1610. if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
  1611. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  1612. for (i=0; i<T1_GetNoFonts(); i++){
  1613. T1_DeleteAllSizes(i);
  1614. T1_ReencodeFont( i, NULL);
  1615. }
  1616. /* Take care that newly loaded fonts are encoded according to current
  1617. encoding */
  1618. T1_SetDefaultEncoding( NULL);
  1619. }
  1620. else{
  1621. for (i=0; i<MAXENCODINGS; ){
  1622. if ( encstruct[i].encfilename != NULL)
  1623. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  1624. i++;
  1625. break;
  1626. }
  1627. i++;
  1628. }
  1629. if (i==MAXENCODINGS){ /* Encoding from that file was not
  1630. already loaded -> so load it */
  1631. i=0;
  1632. while (encstruct[i].encfilename != NULL)
  1633. i++;
  1634. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  1635. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  1636. if (encstruct[i].encoding==NULL){
  1637. free( encstruct[i].encfilename);
  1638. encstruct[i].encfilename=NULL;
  1639. }
  1640. i++;
  1641. }
  1642. for (j=0; j<T1_GetNoFonts(); j++){
  1643. T1_DeleteAllSizes(j);
  1644. T1_ReencodeFont( j, encstruct[i-1].encoding);
  1645. }
  1646. /* Take care that newly loaded fonts are encoded according to current
  1647. encoding */
  1648. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  1649. }
  1650. strcpy( LastEncodingFile, EncodingFile);
  1651. }
  1652. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  1653. if (Slant!=lastSlant[FontID]){
  1654. /* Delete all size dependent data */
  1655. T1_DeleteAllSizes(FontID);
  1656. T1_LoadFont(FontID);
  1657. T1_SlantFont( FontID, Slant);
  1658. lastSlant[FontID]=Slant;
  1659. }
  1660. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  1661. if (Extent!=lastExtent[FontID]){
  1662. /* Delete all size dependent data */
  1663. T1_DeleteAllSizes(FontID);
  1664. T1_LoadFont(FontID);
  1665. T1_ExtendFont( FontID, Extent);
  1666. lastExtent[FontID]=Extent;
  1667. }
  1668. if (Size<=0.0){
  1669. sprintf(statusstring, "t1lib: Size must be positive!");
  1670. i=0;
  1671. XtSetArg(args[i], XtNbitmap,NULL); i++;
  1672. XtSetArg(args[i], XtNwidth,380); i++;
  1673. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1674. XtSetArg(args[i], XtNlabel, statusstring); i++;
  1675. XtSetValues(labelstatus,args,i);
  1676. return;
  1677. }
  1678. XSetForeground( display, DefaultGC( display, screennumber), black.pixel);
  1679. XSetBackground( display, DefaultGC( display, screennumber), white.pixel);
  1680. /* Reset T1_errno: */
  1681. T1_errno=0;
  1682. gettimeofday(time_ptr_start, void_ptr);
  1683. if ( extraflags & CHECK_SET_RECT )
  1684. glyph=T1_SetRect( FontID, Size, 1000.0, 1000.0, matrixP);
  1685. else
  1686. glyph=T1_SetChar( FontID, TestChar, Size, matrixP);
  1687. gettimeofday(time_ptr_stop, void_ptr);
  1688. if (glyph==NULL){
  1689. sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
  1690. i=0;
  1691. XtSetArg(args[i], XtNbitmap,NULL); i++;
  1692. XtSetArg(args[i], XtNwidth,380); i++;
  1693. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1694. XtSetArg(args[i], XtNlabel, statusstring); i++;
  1695. XtSetValues(labelstatus,args,i);
  1696. return;
  1697. }
  1698. height=glyph->metrics.ascent - glyph->metrics.descent;
  1699. overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
  1700. width=overallwidth;
  1701. /* Prepare status message: */
  1702. 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",
  1703. time_diff(time_ptr_start,time_ptr_stop),
  1704. glyph->metrics.leftSideBearing,
  1705. glyph->metrics.rightSideBearing,
  1706. glyph->metrics.ascent,
  1707. glyph->metrics.descent,
  1708. glyph->metrics.advanceX,
  1709. glyph->metrics.advanceY,
  1710. glyph->bpp,
  1711. PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
  1712. T1_GetFontName(FontID),
  1713. T1_GetCharName(FontID,(char)TestChar),
  1714. T1_errno);
  1715. if (glyph->bits !=NULL) {
  1716. ximage=XCreateImage( display,
  1717. DefaultVisual(display, screennumber),
  1718. 1, /* depths for bitmap is 1 */
  1719. XYBitmap, /* XYBitmap or XYPixmap */
  1720. 0, /* No offset */
  1721. glyph->bits,
  1722. width,
  1723. height,
  1724. t1_pad, /* lines padded to bytes */
  1725. 0 /*PAD(width,8)/8*/ /* number of bytes per line */
  1726. );
  1727. /* Force bit and byte order */
  1728. ximage->bitmap_bit_order=0;
  1729. ximage->byte_order=0;
  1730. XFreePixmap(display,pixmap);
  1731. pixmap = XCreatePixmap(display,
  1732. XtWindow(TopLevel),
  1733. width,
  1734. height,
  1735. DefaultDepth(display,screennumber)
  1736. );
  1737. XPutImage(display,
  1738. pixmap,
  1739. DefaultGC( display, screennumber),
  1740. ximage,
  1741. 0,
  1742. 0,
  1743. 0,
  1744. 0,
  1745. width,
  1746. height
  1747. );
  1748. XDestroyImage(ximage);
  1749. }
  1750. i=0;
  1751. XtSetArg(args[i], XtNbitmap,NULL); i++;
  1752. XtSetArg(args[i], XtNwidth,380); i++;
  1753. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1754. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  1755. XtSetArg(args[i], XtNlabel, statusstring); i++;
  1756. XtSetValues(labelstatus,args,i);
  1757. i=0;
  1758. XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
  1759. XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
  1760. if (glyph->bits != NULL) {
  1761. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  1762. }
  1763. else {
  1764. XtSetArg( args[i], XtNbitmap, 0); i++;
  1765. }
  1766. XtSetArg( args[i], XtNresize, 1);i++;
  1767. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  1768. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  1769. XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++;
  1770. XtSetArg( args[i], XtNforeground, BlackPixel(display,screennumber)); i++;
  1771. XtSetValues(OutputWindow ,args,i);
  1772. i=0;
  1773. XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
  1774. XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
  1775. if (glyph->bits != NULL) {
  1776. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  1777. }
  1778. else {
  1779. XtSetArg( args[i], XtNbitmap, 0); i++;
  1780. }
  1781. XtSetArg( args[i], XtNresize, 1);i++;
  1782. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  1783. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  1784. XtSetValues(Output ,args,i);
  1785. glyph->bits=NULL; /* Since XDestroyImage() free's this also! */
  1786. }
  1787. void showstring( Widget showstringbutton, XtPointer client_data, XtPointer call_data)
  1788. {
  1789. int i,j,k,l,m,none_found;
  1790. Arg args[10];
  1791. char *theString='\0';
  1792. char *ligtheString='\0';
  1793. char *succs, *ligs;
  1794. char buf_char;
  1795. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  1796. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  1797. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  1798. sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
  1799. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  1800. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  1801. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  1802. sprintf(statusstring, "t1lib: FontID out of range!");
  1803. i=0;
  1804. XtSetArg(args[i], XtNbitmap,NULL); i++;
  1805. XtSetArg(args[i], XtNwidth,380); i++;
  1806. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1807. XtSetArg(args[i], XtNlabel, statusstring); i++;
  1808. XtSetValues(labelstatus,args,i);
  1809. return;
  1810. }
  1811. /* Ensure that font is loaded before any operation on the font */
  1812. if ( T1_CheckForFontID( FontID) < 1 ) {
  1813. T1_LoadFont( FontID);
  1814. }
  1815. if ( StrokeWidth == 0.0f ) {
  1816. T1_ClearStrokeFlag( FontID);
  1817. }
  1818. else {
  1819. T1_SetStrokeFlag( FontID);
  1820. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  1821. sprintf( statusstring, "t1lib: Unable to setup strokewidth");
  1822. i=0;
  1823. XtSetArg(args[i], XtNbitmap,NULL); i++;
  1824. XtSetArg(args[i], XtNwidth,380); i++;
  1825. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1826. XtSetArg(args[i], XtNlabel, statusstring); i++;
  1827. XtSetValues(labelstatus,args,i);
  1828. return;
  1829. }
  1830. }
  1831. if (CheckTransform()==0 && Angle==0.0){
  1832. matrixP=NULL;
  1833. }
  1834. else{
  1835. matrixP=T1_RotateMatrix( &matrix, Angle);
  1836. }
  1837. if (DeviceResolution!=last_resolution[FontID]){
  1838. /* Delete all size dependent data for that font */
  1839. for ( i=0; i<T1_GetNoFonts(); i++)
  1840. T1_DeleteAllSizes( i);
  1841. /* Establish new device resolution */
  1842. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  1843. /* Store current resolution */
  1844. last_resolution[FontID]=DeviceResolution;
  1845. }
  1846. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  1847. if (i==EOF) EncodingFile[0]=0;
  1848. if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
  1849. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  1850. for (i=0; i<T1_GetNoFonts(); i++){
  1851. T1_DeleteAllSizes(i);
  1852. T1_ReencodeFont( i, NULL);
  1853. }
  1854. /* Take care that newly loaded fonts are encoded according to current
  1855. encoding */
  1856. T1_SetDefaultEncoding( NULL);
  1857. }
  1858. else{
  1859. for (i=0; i<MAXENCODINGS; ){
  1860. if ( encstruct[i].encfilename != NULL)
  1861. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  1862. i++;
  1863. break;
  1864. }
  1865. i++;
  1866. }
  1867. if (i==MAXENCODINGS){ /* Encoding from that file was not
  1868. already loaded -> so load it */
  1869. i=0;
  1870. while (encstruct[i].encfilename != NULL)
  1871. i++;
  1872. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  1873. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  1874. if (encstruct[i].encoding==NULL){
  1875. free( encstruct[i].encfilename);
  1876. encstruct[i].encfilename=NULL;
  1877. }
  1878. i++;
  1879. }
  1880. for (j=0; j<T1_GetNoFonts(); j++){
  1881. T1_DeleteAllSizes(j);
  1882. T1_ReencodeFont( j, encstruct[i-1].encoding);
  1883. }
  1884. /* Take care that newly loaded fonts are encoded according to current
  1885. encoding */
  1886. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  1887. }
  1888. strcpy( LastEncodingFile, EncodingFile);
  1889. }
  1890. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  1891. if (Slant!=lastSlant[FontID]){
  1892. /* Delete all size dependent data */
  1893. T1_DeleteAllSizes(FontID);
  1894. T1_LoadFont(FontID);
  1895. T1_SlantFont( FontID, Slant);
  1896. lastSlant[FontID]=Slant;
  1897. }
  1898. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  1899. if (Extent!=lastExtent[FontID]){
  1900. /* Delete all size dependent data */
  1901. T1_DeleteAllSizes(FontID);
  1902. T1_LoadFont(FontID);
  1903. T1_ExtendFont( FontID, Extent);
  1904. lastExtent[FontID]=Extent;
  1905. }
  1906. i=0;
  1907. XtSetArg(args[i], XtNstring, &theString); i++;
  1908. XtGetValues(dialogteststring,args,i);
  1909. if (Size<=0.0){
  1910. sprintf(statusstring, "t1lib: Size must be positive!");
  1911. i=0;
  1912. XtSetArg(args[i], XtNbitmap,NULL); i++;
  1913. XtSetArg(args[i], XtNwidth,380); i++;
  1914. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  1915. XtSetArg(args[i], XtNlabel, statusstring); i++;
  1916. XtSetValues(labelstatus,args,i);
  1917. return;
  1918. }
  1919. /* Now comes the ligatur handling */
  1920. if (strcmp(theString,"")==0)
  1921. theString=(char *) TestString;
  1922. i=strlen(theString);
  1923. ligtheString=(char *)malloc((i+1)*sizeof(char));
  1924. if (LigDetect){
  1925. for (j=0,m=0;j<i;j++,m++){ /* Loop through the characters */
  1926. if ((k=T1_QueryLigs( FontID, theString[j], &succs, &ligs))>0){
  1927. buf_char=theString[j];
  1928. while (k>0){
  1929. none_found=1;
  1930. for (l=0;l<k;l++){ /* Loop through the ligatures */
  1931. if (succs[l]==theString[j+1]){
  1932. buf_char=ligs[l];
  1933. j++;
  1934. none_found=0;
  1935. break;
  1936. }
  1937. }
  1938. if (none_found)
  1939. break;
  1940. k=T1_QueryLigs( FontID, buf_char, &succs, &ligs);
  1941. }
  1942. ligtheString[m]=buf_char;
  1943. }
  1944. else{ /* There are no ligatures */
  1945. ligtheString[m]=theString[j];
  1946. }
  1947. }
  1948. ligtheString[m]=0;
  1949. }
  1950. else {
  1951. strcpy(ligtheString,theString);
  1952. }
  1953. /*
  1954. {
  1955. METRICSINFO metrics;
  1956. metrics=T1_GetMetricsInfo(FontID,(char *)ligtheString,0,Space,(Modflag & T1_KERNING));
  1957. printf("String's width: %d\n", metrics.width);
  1958. printf("String's BBox: llx = %d\n", metrics.bbox.llx);
  1959. printf(" lly = %d\n", metrics.bbox.lly);
  1960. printf(" urx = %d\n", metrics.bbox.urx);
  1961. printf(" ury = %d\n", metrics.bbox.ury);
  1962. printf("Number of chars in string: %d\n", metrics.numchars);
  1963. for (i=0;i<metrics.numchars;i++)
  1964. printf("Position of %d. character in string: %d afm-units\n", i+1, metrics.charpos[i]);
  1965. }
  1966. */
  1967. /*
  1968. {
  1969. int i,j;
  1970. T1_COMP_CHAR_INFO *ccd;
  1971. T1_COMP_PIECE *cp;
  1972. printf("Number of composite characters in font: %d\n",
  1973. j=T1_GetNoCompositeChars(FontID));
  1974. for (i=0; i<j; i++) {
  1975. ccd=T1_GetCompCharDataByIndex( FontID, i);
  1976. if (ccd==NULL) {
  1977. printf("AFM-ind=%d, ccd=%p, T1_errno=%d\n", i, ccd, T1_errno);
  1978. T1_errno=0;
  1979. }
  1980. else {
  1981. printf( "AFM-ind=%d: Compchar %s (%d), has %d pieces:\n",
  1982. i,
  1983. ccd->compchar > -1 ? T1_GetCharName( FontID, ccd->compchar) : "not_enc",
  1984. ccd->compchar,
  1985. ccd->numPieces);
  1986. printf( " basechar %s (%d)\n",
  1987. ccd->pieces[0].piece > -1 ? T1_GetCharName( FontID, ccd->pieces[0].piece) : "not_enc",
  1988. ccd->pieces[0].piece);
  1989. printf( " accent %s (%d)\n",
  1990. ccd->pieces[1].piece > -1 ? T1_GetCharName( FontID, ccd->pieces[1].piece) : "not_enc",
  1991. ccd->pieces[1].piece);
  1992. }
  1993. T1_FreeCompCharData( ccd);
  1994. }
  1995. }
  1996. */
  1997. XSetForeground( display, DefaultGC( display, screennumber), black.pixel);
  1998. XSetBackground( display, DefaultGC( display, screennumber), white.pixel);
  1999. /* Reset T1_errno: */
  2000. T1_errno=0;
  2001. gettimeofday(time_ptr_start, void_ptr);
  2002. if( extraflags & CHECK_CONCATGLYPHS){
  2003. glyph2=T1_SetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
  2004. glyph1=T1_CopyGlyph( glyph2);
  2005. glyph2=T1_SetString(FontID+1,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
  2006. glyph=T1_ConcatGlyphs( glyph1, glyph2, 0, 0, Modflag);
  2007. }
  2008. else if( extraflags & CHECK_CONCATOUTLINES){
  2009. {
  2010. T1_OUTLINE *path=NULL;
  2011. path=T1_GetStringOutline(FontID,(char *)ligtheString,
  2012. 0,Space,Modflag,Size,matrixP);
  2013. if (path==NULL){
  2014. return;
  2015. }
  2016. #ifdef SHOW_MANIPULATE_PATHS
  2017. T1_AbsolutePath( path);
  2018. T1_ManipulatePath( path, &mymanipulate);
  2019. T1_RelativePath( path);
  2020. #else
  2021. T1_ConcatOutlines( path,
  2022. T1_GetStringOutline(FontID+1,(char *)ligtheString,
  2023. 0,Space,Modflag,Size,matrixP));
  2024. #endif
  2025. glyph=T1_FillOutline( path, Modflag);
  2026. }
  2027. }
  2028. else{
  2029. if( extraflags & CHECK_FOR_BAD_CHARS){
  2030. sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
  2031. ligtheString[strlen(ligtheString)/2]=(unsigned char) TestChar;
  2032. }
  2033. glyph=T1_SetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
  2034. }
  2035. gettimeofday(time_ptr_stop, void_ptr);
  2036. free(ligtheString);
  2037. if ( glyph ==NULL ) {
  2038. sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
  2039. i=0;
  2040. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2041. XtSetArg(args[i], XtNwidth,380); i++;
  2042. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2043. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2044. XtSetValues(labelstatus,args,i);
  2045. return;
  2046. }
  2047. height=glyph->metrics.ascent - glyph->metrics.descent;
  2048. overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
  2049. width=overallwidth;
  2050. /* Prepare status message: */
  2051. 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",
  2052. time_diff(time_ptr_start,time_ptr_stop),
  2053. glyph->metrics.leftSideBearing,
  2054. glyph->metrics.rightSideBearing,
  2055. glyph->metrics.ascent,
  2056. glyph->metrics.descent,
  2057. glyph->metrics.advanceX,
  2058. glyph->metrics.advanceY,
  2059. glyph->bpp,
  2060. PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
  2061. T1_GetFontName(FontID),
  2062. T1_errno);
  2063. if (glyph->bits != NULL) {
  2064. ximage=XCreateImage( display,
  2065. DefaultVisual(display, screennumber),
  2066. 1, /* depths for bitmap is 1 */
  2067. XYBitmap, /* XYBitmap or XYPixmap */
  2068. 0, /* No offset */
  2069. glyph->bits,
  2070. width,
  2071. height,
  2072. t1_pad, /* lines padded to bytes */
  2073. 0 /*PAD(width,8)/8*/ /* number of bytes per line */
  2074. );
  2075. /* Force bit and byte order */
  2076. ximage->bitmap_bit_order=LSBFirst;
  2077. ximage->byte_order=LSBFirst;
  2078. XFreePixmap(display,pixmap);
  2079. pixmap = XCreatePixmap(display,
  2080. XtWindow(TopLevel),
  2081. width,
  2082. height,
  2083. DefaultDepth(display,screennumber)
  2084. );
  2085. XPutImage(display,
  2086. pixmap,
  2087. DefaultGC( display, screennumber),
  2088. ximage,
  2089. 0,
  2090. 0,
  2091. 0,
  2092. 0,
  2093. width,
  2094. height
  2095. );
  2096. XDestroyImage(ximage);
  2097. }
  2098. i=0;
  2099. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2100. XtSetArg(args[i], XtNwidth,380); i++;
  2101. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2102. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  2103. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2104. XtSetValues(labelstatus,args,i);
  2105. i=0;
  2106. XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
  2107. XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
  2108. if (glyph->bits != NULL) {
  2109. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  2110. }
  2111. else {
  2112. XtSetArg( args[i], XtNbitmap, 0); i++;
  2113. }
  2114. XtSetArg( args[i], XtNresize, 1);i++;
  2115. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  2116. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  2117. XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++;
  2118. XtSetValues(OutputWindow ,args,i);
  2119. i=0;
  2120. XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
  2121. XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
  2122. if (glyph->bits != NULL) {
  2123. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  2124. }
  2125. else {
  2126. XtSetArg( args[i], XtNbitmap, 0); i++;
  2127. }
  2128. XtSetArg( args[i], XtNresize, 1);i++;
  2129. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  2130. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  2131. XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++;
  2132. XtSetValues(Output ,args,i);
  2133. glyph->bits=NULL; /* Since XDestroyImage() free's this also! */
  2134. }
  2135. void aashowchar( Widget showcharbutton, XtPointer client_data, XtPointer call_data)
  2136. {
  2137. int i, j;
  2138. Arg args[10];
  2139. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  2140. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  2141. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  2142. sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
  2143. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  2144. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  2145. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  2146. sprintf(statusstring, "t1lib: FontID out of range!");
  2147. i=0;
  2148. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2149. XtSetArg(args[i], XtNwidth,380); i++;
  2150. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2151. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2152. XtSetValues(labelstatus,args,i);
  2153. return;
  2154. }
  2155. /* Ensure that font is loaded before any operation on the font */
  2156. if ( T1_CheckForFontID( FontID) < 1 ) {
  2157. T1_LoadFont( FontID);
  2158. }
  2159. if ( StrokeWidth == 0.0f ) {
  2160. T1_ClearStrokeFlag( FontID);
  2161. }
  2162. else {
  2163. T1_SetStrokeFlag( FontID);
  2164. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  2165. sprintf( statusstring, "t1lib: Unable to setup strokewidth");
  2166. i=0;
  2167. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2168. XtSetArg(args[i], XtNwidth,380); i++;
  2169. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2170. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2171. XtSetValues(labelstatus,args,i);
  2172. return;
  2173. }
  2174. }
  2175. if (CheckTransform()==0 && Angle==0.0){
  2176. matrixP=NULL;
  2177. }
  2178. else{
  2179. matrixP=T1_RotateMatrix( &matrix, Angle);
  2180. }
  2181. if (DeviceResolution!=last_resolution[FontID]){
  2182. /* Delete all size dependent data for that font */
  2183. for ( i=0; i<T1_GetNoFonts(); i++)
  2184. T1_DeleteAllSizes( i);
  2185. /* Establish new device resolution */
  2186. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  2187. /* Store current resolution */
  2188. last_resolution[FontID]=DeviceResolution;
  2189. }
  2190. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  2191. if (i==EOF) EncodingFile[0]=0;
  2192. if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
  2193. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  2194. for (i=0; i<T1_GetNoFonts(); i++){
  2195. T1_DeleteAllSizes(i);
  2196. T1_ReencodeFont( i, NULL);
  2197. }
  2198. /* Take care that newly loaded fonts are encoded according to current
  2199. encoding */
  2200. T1_SetDefaultEncoding( NULL);
  2201. }
  2202. else{
  2203. for (i=0; i<MAXENCODINGS; ){
  2204. if ( encstruct[i].encfilename != NULL)
  2205. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  2206. i++;
  2207. break;
  2208. }
  2209. i++;
  2210. }
  2211. if (i==MAXENCODINGS){ /* Encoding from that file was not
  2212. already loaded -> so load it */
  2213. i=0;
  2214. while (encstruct[i].encfilename != NULL)
  2215. i++;
  2216. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  2217. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  2218. if (encstruct[i].encoding==NULL){
  2219. free( encstruct[i].encfilename);
  2220. encstruct[i].encfilename=NULL;
  2221. }
  2222. i++;
  2223. }
  2224. for (j=0; j<T1_GetNoFonts(); j++){
  2225. T1_DeleteAllSizes(j);
  2226. T1_ReencodeFont( j, encstruct[i-1].encoding);
  2227. }
  2228. /* Take care that newly loaded fonts are encoded according to current
  2229. encoding */
  2230. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  2231. }
  2232. strcpy( LastEncodingFile, EncodingFile);
  2233. }
  2234. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  2235. if (Slant!=lastSlant[FontID]){
  2236. /* Delete all size dependent data */
  2237. T1_DeleteAllSizes(FontID);
  2238. T1_LoadFont(FontID);
  2239. T1_SlantFont( FontID, Slant);
  2240. lastSlant[FontID]=Slant;
  2241. }
  2242. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  2243. if (Extent!=lastExtent[FontID]){
  2244. /* Delete all size dependent data */
  2245. T1_DeleteAllSizes(FontID);
  2246. T1_LoadFont(FontID);
  2247. T1_ExtendFont( FontID, Extent);
  2248. lastExtent[FontID]=Extent;
  2249. }
  2250. if (Size<=0.0){
  2251. sprintf(statusstring, "t1lib: Size must be positive!");
  2252. i=0;
  2253. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2254. XtSetArg(args[i], XtNwidth,380); i++;
  2255. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2256. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2257. XtSetValues(labelstatus,args,i);
  2258. return;
  2259. }
  2260. /* Reset T1_errno: */
  2261. T1_errno=0;
  2262. /* Set antialiasing level */
  2263. T1_AASetLevel( aalevel);
  2264. /* Set the colors for Anti-Aliasing */
  2265. T1_AASetGrayValues( aapixels[0], /* white */
  2266. aapixels[4],
  2267. aapixels[8],
  2268. aapixels[12],
  2269. aapixels[16] ); /* black */
  2270. T1_AAHSetGrayValues( aapixels);
  2271. T1_AANSetGrayValues( aapixels[0], aapixels[16]);
  2272. gettimeofday(time_ptr_start, void_ptr);
  2273. if ( extraflags & CHECK_SET_RECT )
  2274. glyph=T1_AASetRect( FontID, Size, 1000.0, 1000.0, matrixP);
  2275. else
  2276. glyph=T1_AASetChar( FontID, (char)TestChar, Size, matrixP);
  2277. gettimeofday(time_ptr_stop, void_ptr);
  2278. if (glyph==NULL) {
  2279. sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
  2280. i=0;
  2281. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2282. XtSetArg(args[i], XtNwidth,380); i++;
  2283. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2284. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2285. XtSetValues(labelstatus,args,i);
  2286. return;
  2287. }
  2288. height=glyph->metrics.ascent - glyph->metrics.descent;
  2289. overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
  2290. width=overallwidth;
  2291. /* Prepare status message: */
  2292. 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",
  2293. time_diff(time_ptr_start,time_ptr_stop),
  2294. glyph->metrics.leftSideBearing,
  2295. glyph->metrics.rightSideBearing,
  2296. glyph->metrics.ascent,
  2297. glyph->metrics.descent,
  2298. glyph->metrics.advanceX,
  2299. glyph->metrics.advanceY,
  2300. glyph->bpp,
  2301. PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
  2302. T1_GetFontName(FontID),
  2303. T1_GetCharName(FontID,(char)TestChar),
  2304. T1_errno);
  2305. /*
  2306. printf("glyph->bits=%u\n", glyph->bits);
  2307. printf("glyph->metrics.leftSideBearing=%u\n", glyph->metrics.leftSideBearing);
  2308. printf("glyph->metrics.rightSideBearing=%u\n", glyph->metrics.rightSideBearing);
  2309. printf("glyph->metrics.advanceX=%u\n", glyph->metrics.advanceX);
  2310. printf("glyph->metrics.ascent=%u\n", glyph->metrics.ascent);
  2311. printf("glyph->metrics.descent=%u\n", glyph->metrics.descent);
  2312. printf("glyph->pFontCacheInfo=%u\n", glyph->pFontCacheInfo);
  2313. */
  2314. if (glyph->bits != NULL) {
  2315. ximage=XCreateImage( display,
  2316. DefaultVisual(display, screennumber),
  2317. DefaultDepth(display,screennumber), /* depths for bitmap is 1 */
  2318. ZPixmap, /* XYBitmap or XYPixmap */
  2319. 0, /* No offset */
  2320. glyph->bits,
  2321. width,
  2322. height,
  2323. t1_pad, /* lines padded to bytes */
  2324. 0 /*PAD(width,8)/8*/ /* number of bytes per line */
  2325. );
  2326. ximage->byte_order=xglyph_byte_order;
  2327. XFreePixmap(display,pixmap);
  2328. pixmap = XCreatePixmap(display,
  2329. XtWindow(TopLevel),
  2330. width,
  2331. height,
  2332. DefaultDepth(display,screennumber) /* 8 */ /* depth */
  2333. );
  2334. XPutImage(display,
  2335. pixmap,
  2336. DefaultGC( display, screennumber),
  2337. ximage,
  2338. 0,
  2339. 0,
  2340. 0,
  2341. 0,
  2342. width,
  2343. height
  2344. );
  2345. XDestroyImage(ximage);
  2346. }
  2347. i=0;
  2348. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2349. XtSetArg(args[i], XtNwidth,380); i++;
  2350. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2351. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  2352. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2353. XtSetValues(labelstatus,args,i);
  2354. i=0;
  2355. XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
  2356. XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
  2357. if (glyph->bits != NULL) {
  2358. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  2359. }
  2360. else {
  2361. XtSetArg( args[i], XtNbitmap, 0); i++;
  2362. }
  2363. XtSetArg( args[i], XtNresize, 1);i++;
  2364. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  2365. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  2366. XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++;
  2367. XtSetValues(OutputWindow ,args,i);
  2368. i=0;
  2369. XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
  2370. XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
  2371. if (glyph->bits != NULL) {
  2372. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  2373. }
  2374. else {
  2375. XtSetArg( args[i], XtNbitmap, 0); i++;
  2376. }
  2377. XtSetArg( args[i], XtNresize, 1);i++;
  2378. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  2379. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  2380. XtSetValues(Output ,args,i);
  2381. glyph->bits=NULL; /* Since XDestroyImage() free's this also! */
  2382. }
  2383. void aashowstring( Widget showstringbutton, XtPointer client_data, XtPointer call_data)
  2384. {
  2385. int i,j,k,l,m,none_found;
  2386. Arg args[10];
  2387. char *theString='\0';
  2388. char *ligtheString='\0';
  2389. char *succs, *ligs;
  2390. char buf_char;
  2391. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  2392. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  2393. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  2394. sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
  2395. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  2396. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  2397. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  2398. sprintf(statusstring, "t1lib: FontID out of range!");
  2399. i=0;
  2400. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2401. XtSetArg(args[i], XtNwidth,380); i++;
  2402. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2403. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2404. XtSetValues(labelstatus,args,i);
  2405. return;
  2406. }
  2407. /* Ensure that font is loaded before any operation on the font */
  2408. if ( T1_CheckForFontID( FontID) < 1 ) {
  2409. T1_LoadFont( FontID);
  2410. }
  2411. if ( StrokeWidth == 0.0f ) {
  2412. T1_ClearStrokeFlag( FontID);
  2413. }
  2414. else {
  2415. T1_SetStrokeFlag( FontID);
  2416. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  2417. sprintf( statusstring, "t1lib: Unable to setup strokewidth");
  2418. i=0;
  2419. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2420. XtSetArg(args[i], XtNwidth,380); i++;
  2421. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2422. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2423. XtSetValues(labelstatus,args,i);
  2424. return;
  2425. }
  2426. }
  2427. if (CheckTransform()==0 && Angle==0.0){
  2428. matrixP=NULL;
  2429. }
  2430. else{
  2431. matrixP=T1_RotateMatrix( &matrix, Angle);
  2432. }
  2433. if (DeviceResolution!=last_resolution[FontID]){
  2434. /* Delete all size dependent data for that font */
  2435. for ( i=0; i<T1_GetNoFonts(); i++)
  2436. T1_DeleteAllSizes( i);
  2437. /* Establish new device resolution */
  2438. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  2439. /* Store current resolution */
  2440. last_resolution[FontID]=DeviceResolution;
  2441. }
  2442. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  2443. if (i==EOF) EncodingFile[0]=0;
  2444. if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
  2445. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  2446. for (i=0; i<T1_GetNoFonts(); i++){
  2447. T1_DeleteAllSizes(i);
  2448. T1_ReencodeFont( i, NULL);
  2449. }
  2450. /* Take care that newly loaded fonts are encoded according to current
  2451. encoding */
  2452. T1_SetDefaultEncoding( NULL);
  2453. }
  2454. else{
  2455. for (i=0; i<MAXENCODINGS; ){
  2456. if ( encstruct[i].encfilename != NULL)
  2457. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  2458. i++;
  2459. break;
  2460. }
  2461. i++;
  2462. }
  2463. if (i==MAXENCODINGS){ /* Encoding from that file was not
  2464. already loaded -> so load it */
  2465. i=0;
  2466. while (encstruct[i].encfilename != NULL)
  2467. i++;
  2468. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  2469. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  2470. if (encstruct[i].encoding==NULL){
  2471. free( encstruct[i].encfilename);
  2472. encstruct[i].encfilename=NULL;
  2473. }
  2474. i++;
  2475. }
  2476. for (j=0; j<T1_GetNoFonts(); j++){
  2477. T1_DeleteAllSizes(j);
  2478. T1_ReencodeFont( j, encstruct[i-1].encoding);
  2479. }
  2480. /* Take care that newly loaded fonts are encoded according to current
  2481. encoding */
  2482. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  2483. }
  2484. strcpy( LastEncodingFile, EncodingFile);
  2485. }
  2486. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  2487. if (Slant!=lastSlant[FontID]){
  2488. /* Delete all size dependent data */
  2489. T1_DeleteAllSizes(FontID);
  2490. T1_LoadFont(FontID);
  2491. T1_SlantFont( FontID, Slant);
  2492. lastSlant[FontID]=Slant;
  2493. }
  2494. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  2495. if (Extent!=lastExtent[FontID]){
  2496. /* Delete all size dependent data */
  2497. T1_DeleteAllSizes(FontID);
  2498. T1_LoadFont(FontID);
  2499. T1_ExtendFont( FontID, Extent);
  2500. lastExtent[FontID]=Extent;
  2501. }
  2502. i=0;
  2503. XtSetArg(args[i], XtNstring, &theString); i++;
  2504. XtGetValues(dialogteststring,args,i);
  2505. if (Size<=0.0){
  2506. sprintf(statusstring, "t1lib: Size must be positive!");
  2507. i=0;
  2508. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2509. XtSetArg(args[i], XtNwidth,380); i++;
  2510. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2511. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2512. XtSetValues(labelstatus,args,i);
  2513. return;
  2514. }
  2515. /* Now comes the ligatur handling */
  2516. if (strcmp(theString,"")==0)
  2517. theString=(char *) TestString;
  2518. i=strlen(theString);
  2519. ligtheString=(char *)malloc((i+1)*sizeof(char));
  2520. if (LigDetect){
  2521. for (j=0,m=0;j<i;j++,m++){ /* Loop through the characters */
  2522. if ((k=T1_QueryLigs( FontID, theString[j], &succs, &ligs))>0){
  2523. buf_char=theString[j];
  2524. while (k>0){
  2525. none_found=1;
  2526. for (l=0;l<k;l++){ /* Loop through the ligatures */
  2527. if (succs[l]==theString[j+1]){
  2528. buf_char=ligs[l];
  2529. j++;
  2530. none_found=0;
  2531. break;
  2532. }
  2533. }
  2534. if (none_found)
  2535. break;
  2536. k=T1_QueryLigs( FontID, buf_char, &succs, &ligs);
  2537. }
  2538. ligtheString[m]=buf_char;
  2539. }
  2540. else{ /* There are no ligatures */
  2541. ligtheString[m]=theString[j];
  2542. }
  2543. }
  2544. ligtheString[m]=0;
  2545. }
  2546. else {
  2547. strcpy(ligtheString,theString);
  2548. }
  2549. /* Reset T1_errno: */
  2550. T1_errno=0;
  2551. /* Set antialiasing level */
  2552. T1_AASetLevel( aalevel);
  2553. /* Set the colors for Anti-Aliasing */
  2554. T1_AASetGrayValues( aapixels[0], /* white */
  2555. aapixels[4],
  2556. aapixels[8],
  2557. aapixels[12],
  2558. aapixels[16] ); /* black */
  2559. T1_AAHSetGrayValues( aapixels);
  2560. T1_AANSetGrayValues( aapixels[0], aapixels[16]);
  2561. gettimeofday(time_ptr_start, void_ptr);
  2562. if( extraflags & CHECK_CONCATGLYPHS){
  2563. glyph2=T1_AASetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
  2564. glyph1=T1_CopyGlyph( glyph2);
  2565. glyph2=T1_AASetString(FontID+1,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
  2566. glyph=T1_ConcatGlyphs( glyph1, glyph2, 0, 0, Modflag);
  2567. }
  2568. else if( extraflags & CHECK_CONCATOUTLINES){
  2569. {
  2570. T1_OUTLINE *path=NULL;
  2571. path=T1_GetStringOutline(FontID,(char *)ligtheString,
  2572. 0,Space,Modflag,Size,matrixP);
  2573. T1_ConcatOutlines( path,
  2574. T1_GetMoveOutline( FontID, 1000, 0, Modflag, Size, matrixP));
  2575. T1_ConcatOutlines( path,
  2576. T1_GetStringOutline(FontID+1,(char *)ligtheString,
  2577. 0,Space,Modflag,Size,matrixP));
  2578. glyph=T1_AAFillOutline( path, Modflag);
  2579. }
  2580. }
  2581. else{
  2582. glyph=T1_AASetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP);
  2583. }
  2584. gettimeofday(time_ptr_stop, void_ptr);
  2585. free(ligtheString);
  2586. if ( glyph == NULL){
  2587. sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
  2588. i=0;
  2589. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2590. XtSetArg(args[i], XtNwidth,380); i++;
  2591. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2592. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2593. XtSetValues(labelstatus,args,i);
  2594. return;
  2595. }
  2596. height=glyph->metrics.ascent - glyph->metrics.descent;
  2597. overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
  2598. width=overallwidth;
  2599. /* Prepare status message: */
  2600. 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",
  2601. time_diff(time_ptr_start,time_ptr_stop),
  2602. glyph->metrics.leftSideBearing,
  2603. glyph->metrics.rightSideBearing,
  2604. glyph->metrics.ascent,
  2605. glyph->metrics.descent,
  2606. glyph->metrics.advanceX,
  2607. glyph->metrics.advanceY,
  2608. glyph->bpp,
  2609. PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
  2610. T1_GetFontName(FontID),
  2611. T1_errno);
  2612. /*
  2613. printf("glyph->bits=%u\n", glyph->bits);
  2614. printf("glyph->metrics.leftSideBearing=%u\n", glyph->metrics.leftSideBearing);
  2615. printf("glyph->metrics.rightSideBearing=%u\n", glyph->metrics.rightSideBearing);
  2616. printf("glyph->metrics.advanceX=%u\n", glyph->metrics.advanceX);
  2617. printf("glyph->metrics.ascent=%u\n", glyph->metrics.ascent);
  2618. printf("glyph->metrics.descent=%u\n", glyph->metrics.descent);
  2619. printf("glyph->pFontCacheInfo=%u\n", glyph->pFontCacheInfo);
  2620. */
  2621. if (glyph->bits != NULL) {
  2622. ximage=XCreateImage( display,
  2623. DefaultVisual(display, screennumber),
  2624. DefaultDepth(display,screennumber),
  2625. ZPixmap, /* XYBitmap or XYPixmap */
  2626. 0, /* No offset */
  2627. glyph->bits,
  2628. width,
  2629. height,
  2630. t1_pad, /* lines padded to bytes */
  2631. 0 /* number of bytes per line */
  2632. );
  2633. ximage->byte_order=xglyph_byte_order;
  2634. XFreePixmap(display,pixmap);
  2635. pixmap = XCreatePixmap(display,
  2636. XtWindow(TopLevel),
  2637. width,
  2638. height,
  2639. DefaultDepth(display,screennumber)
  2640. );
  2641. XPutImage(display,
  2642. pixmap,
  2643. DefaultGC( display, screennumber),
  2644. ximage,
  2645. 0,
  2646. 0,
  2647. 0,
  2648. 0,
  2649. width,
  2650. height
  2651. );
  2652. XDestroyImage(ximage);
  2653. }
  2654. i=0;
  2655. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2656. XtSetArg(args[i], XtNwidth,380); i++;
  2657. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2658. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  2659. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2660. XtSetValues(labelstatus,args,i);
  2661. i=0;
  2662. XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
  2663. XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
  2664. if (glyph->bits != NULL) {
  2665. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  2666. }
  2667. else {
  2668. XtSetArg( args[i], XtNbitmap, 0); i++;
  2669. }
  2670. XtSetArg( args[i], XtNresize, 1);i++;
  2671. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  2672. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  2673. XtSetArg( args[i], XtNbackground, WhitePixel( display, screennumber)); i++;
  2674. XtSetValues(OutputWindow ,args,i);
  2675. i=0;
  2676. XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++;
  2677. XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++;
  2678. if (glyph->bits != NULL) {
  2679. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  2680. }
  2681. else {
  2682. XtSetArg( args[i], XtNbitmap, 0); i++;
  2683. }
  2684. XtSetArg( args[i], XtNresize, 1);i++;
  2685. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  2686. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  2687. XtSetArg( args[i], XtNbackground, WhitePixel( display, screennumber)); i++;
  2688. XtSetValues(Output ,args,i);
  2689. glyph->bits=NULL; /* Since XDestroyImage() free's this also! */
  2690. }
  2691. void showcharX( Widget showcharbutton, XtPointer client_data, XtPointer call_data)
  2692. {
  2693. int i, j;
  2694. Arg args[10];
  2695. int tmp_width, tmp_height;
  2696. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  2697. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  2698. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  2699. sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
  2700. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  2701. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  2702. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  2703. sprintf(statusstring, "t1lib: FontID out of range!");
  2704. i=0;
  2705. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2706. XtSetArg(args[i], XtNwidth,380); i++;
  2707. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2708. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2709. XtSetValues(labelstatus,args,i);
  2710. return;
  2711. }
  2712. /* Ensure that font is loaded before any operation on the font */
  2713. if ( T1_CheckForFontID( FontID) < 1 ) {
  2714. T1_LoadFont( FontID);
  2715. }
  2716. if ( StrokeWidth == 0.0f ) {
  2717. T1_ClearStrokeFlag( FontID);
  2718. }
  2719. else {
  2720. T1_SetStrokeFlag( FontID);
  2721. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  2722. sprintf( statusstring, "t1lib: Unable to setup strokewidth");
  2723. i=0;
  2724. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2725. XtSetArg(args[i], XtNwidth,380); i++;
  2726. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2727. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2728. XtSetValues(labelstatus,args,i);
  2729. return;
  2730. }
  2731. }
  2732. if (CheckTransform()==0 && Angle==0.0){
  2733. matrixP=NULL;
  2734. }
  2735. else{
  2736. matrixP=T1_RotateMatrix( &matrix, Angle);
  2737. }
  2738. if (DeviceResolution!=last_resolution[FontID]){
  2739. /* Delete all size dependent data for that font */
  2740. for ( i=0; i<T1_GetNoFonts(); i++)
  2741. T1_DeleteAllSizes( i);
  2742. /* Establish new device resolution */
  2743. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  2744. /* Store current resolution */
  2745. last_resolution[FontID]=DeviceResolution;
  2746. }
  2747. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  2748. if (i==EOF) EncodingFile[0]=0;
  2749. if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
  2750. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  2751. for (i=0; i<T1_GetNoFonts(); i++){
  2752. T1_DeleteAllSizes(i);
  2753. T1_ReencodeFont( i, NULL);
  2754. }
  2755. /* Take care that newly loaded fonts are encoded according to current
  2756. encoding */
  2757. T1_SetDefaultEncoding( NULL);
  2758. }
  2759. else{
  2760. for (i=0; i<MAXENCODINGS; ){
  2761. if ( encstruct[i].encfilename != NULL)
  2762. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  2763. i++;
  2764. break;
  2765. }
  2766. i++;
  2767. }
  2768. if (i==MAXENCODINGS){ /* Encoding from that file was not
  2769. already loaded -> so load it */
  2770. i=0;
  2771. while (encstruct[i].encfilename != NULL)
  2772. i++;
  2773. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  2774. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  2775. if (encstruct[i].encoding==NULL){
  2776. free( encstruct[i].encfilename);
  2777. encstruct[i].encfilename=NULL;
  2778. }
  2779. i++;
  2780. }
  2781. for (j=0; j<T1_GetNoFonts(); j++){
  2782. T1_DeleteAllSizes(j);
  2783. T1_ReencodeFont( j, encstruct[i-1].encoding);
  2784. }
  2785. /* Take care that newly loaded fonts are encoded according to current
  2786. encoding */
  2787. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  2788. }
  2789. strcpy( LastEncodingFile, EncodingFile);
  2790. }
  2791. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  2792. if (Slant!=lastSlant[FontID]){
  2793. /* Delete all size dependent data */
  2794. T1_DeleteAllSizes(FontID);
  2795. T1_LoadFont(FontID);
  2796. T1_SlantFont( FontID, Slant);
  2797. lastSlant[FontID]=Slant;
  2798. }
  2799. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  2800. if (Extent!=lastExtent[FontID]){
  2801. /* Delete all size dependent data */
  2802. T1_DeleteAllSizes(FontID);
  2803. T1_LoadFont(FontID);
  2804. T1_ExtendFont( FontID, Extent);
  2805. lastExtent[FontID]=Extent;
  2806. }
  2807. if (Size<=0.0){
  2808. sprintf(statusstring, "t1lib: Size must be positive!");
  2809. i=0;
  2810. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2811. XtSetArg(args[i], XtNwidth,380); i++;
  2812. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2813. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2814. XtSetValues(labelstatus,args,i);
  2815. return;
  2816. }
  2817. tmp_width=2 * XOUTPUT_HALFHSIZE;
  2818. tmp_height=2 * XOUTPUT_HALFVSIZE;
  2819. if (tmp_pixmap==0)
  2820. tmp_pixmap=XCreatePixmap( display,
  2821. XtWindow(TopLevel),
  2822. tmp_width,
  2823. tmp_height,
  2824. depth
  2825. );
  2826. /* Put some background in pixmap for demonstration of transparent-mode: */
  2827. if (Opacity==0){
  2828. XSetForeground( display, DefaultGC( display, screennumber), pink4.pixel);
  2829. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  2830. 0, 0, tmp_width, tmp_height);
  2831. XSetForeground( display, DefaultGC( display, screennumber), yellow.pixel);
  2832. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  2833. tmp_width/4, tmp_height/4, tmp_width/2, tmp_height/2);
  2834. XSetForeground( display, DefaultGC( display, screennumber), fg);
  2835. }
  2836. else{
  2837. XSetForeground( display, DefaultGC( display, screennumber), bg);
  2838. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  2839. 0, 0, tmp_width, tmp_height);
  2840. }
  2841. XSetForeground( display, DefaultGC( display, screennumber), fg);
  2842. XSetBackground( display, DefaultGC( display, screennumber), bg);
  2843. /* Synchronize display in order to make the time measurement more acurate */
  2844. XSync( display, True);
  2845. /* Reset T1_errno: */
  2846. T1_errno=0;
  2847. gettimeofday(time_ptr_start, void_ptr);
  2848. if ( extraflags & CHECK_SET_RECT )
  2849. glyph=T1_SetRectX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
  2850. XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
  2851. FontID, Size, 1000.0, 1000.0, matrixP);
  2852. else
  2853. glyph=T1_SetCharX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
  2854. XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
  2855. FontID, TestChar, Size, matrixP);
  2856. gettimeofday(time_ptr_stop, void_ptr);
  2857. if ((extraflags & NO_GRID)==0){
  2858. XSetForeground( display, DefaultGC( display, screennumber), gridcolor1.pixel);
  2859. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  2860. XOUTPUT_HALFHSIZE, 0, /* X1, Y1 */
  2861. XOUTPUT_HALFHSIZE, 2 * XOUTPUT_HALFVSIZE);
  2862. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  2863. 0, XOUTPUT_HALFVSIZE, /* X1, Y1 */
  2864. 2 * XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE);
  2865. XSetForeground( display, DefaultGC( display, screennumber), gridcolor2.pixel);
  2866. if (glyph!=NULL){
  2867. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  2868. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX - CROSS_SIZE,
  2869. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY,
  2870. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE,
  2871. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY);
  2872. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  2873. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
  2874. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE,
  2875. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
  2876. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE);
  2877. }
  2878. }
  2879. XSetForeground( display, DefaultGC( display, screennumber), fg);
  2880. /* Check for errors */
  2881. if (glyph==NULL) {
  2882. sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
  2883. i=0;
  2884. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2885. XtSetArg(args[i], XtNwidth,380); i++;
  2886. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2887. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2888. XtSetValues(labelstatus,args,i);
  2889. return;
  2890. }
  2891. /* Prepare status message: */
  2892. 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",
  2893. time_diff(time_ptr_start,time_ptr_stop),
  2894. glyph->metrics.leftSideBearing,
  2895. glyph->metrics.rightSideBearing,
  2896. glyph->metrics.ascent,
  2897. glyph->metrics.descent,
  2898. glyph->metrics.advanceX,
  2899. glyph->metrics.advanceY,
  2900. glyph->bpp,
  2901. PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
  2902. T1_GetFontName(FontID),
  2903. T1_GetCharName(FontID,(char)TestChar),
  2904. T1_errno);
  2905. /* Finally, set the resources: */
  2906. i=0;
  2907. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2908. XtSetArg(args[i], XtNwidth,380); i++;
  2909. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2910. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  2911. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2912. XtSetValues(labelstatus,args,i);
  2913. i=0;
  2914. XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
  2915. XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
  2916. XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
  2917. XtSetArg( args[i], XtNresize, 1);i++;
  2918. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  2919. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  2920. XtSetArg( args[i], XtNbackground, outbg); i++;
  2921. XtSetValues(OutputWindow ,args,i);
  2922. i=0;
  2923. XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
  2924. XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
  2925. XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
  2926. XtSetArg( args[i], XtNresize, 1);i++;
  2927. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  2928. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  2929. XtSetValues(Output ,args,i);
  2930. }
  2931. void showstringX( Widget showstringbutton, XtPointer client_data, XtPointer call_data)
  2932. {
  2933. int i,j,k,l,m,none_found;
  2934. Arg args[10];
  2935. int tmp_width, tmp_height;
  2936. char *theString='\0';
  2937. char *ligtheString='\0';
  2938. char *succs, *ligs;
  2939. char buf_char;
  2940. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  2941. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  2942. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  2943. sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
  2944. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  2945. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  2946. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  2947. sprintf(statusstring, "t1lib: FontID out of range!");
  2948. i=0;
  2949. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2950. XtSetArg(args[i], XtNwidth,380); i++;
  2951. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2952. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2953. XtSetValues(labelstatus,args,i);
  2954. return;
  2955. }
  2956. /* Ensure that font is loaded before any operation on the font */
  2957. if ( T1_CheckForFontID( FontID) < 1 ) {
  2958. T1_LoadFont( FontID);
  2959. }
  2960. if ( StrokeWidth == 0.0f ) {
  2961. T1_ClearStrokeFlag( FontID);
  2962. }
  2963. else {
  2964. T1_SetStrokeFlag( FontID);
  2965. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  2966. sprintf( statusstring, "t1lib: Unable to setup strokewidth");
  2967. i=0;
  2968. XtSetArg(args[i], XtNbitmap,NULL); i++;
  2969. XtSetArg(args[i], XtNwidth,380); i++;
  2970. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  2971. XtSetArg(args[i], XtNlabel, statusstring); i++;
  2972. XtSetValues(labelstatus,args,i);
  2973. return;
  2974. }
  2975. }
  2976. if (CheckTransform()==0 && Angle==0.0){
  2977. matrixP=NULL;
  2978. }
  2979. else{
  2980. matrixP=T1_RotateMatrix( &matrix, Angle);
  2981. }
  2982. if (DeviceResolution!=last_resolution[FontID]){
  2983. /* Delete all size dependent data for that font */
  2984. for ( i=0; i<T1_GetNoFonts(); i++)
  2985. T1_DeleteAllSizes( i);
  2986. /* Establish new device resolution */
  2987. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  2988. /* Store current resolution */
  2989. last_resolution[FontID]=DeviceResolution;
  2990. }
  2991. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  2992. if (i==EOF) EncodingFile[0]=0;
  2993. if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
  2994. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  2995. for (i=0; i<T1_GetNoFonts(); i++){
  2996. T1_DeleteAllSizes(i);
  2997. T1_ReencodeFont( i, NULL);
  2998. }
  2999. /* Take care that newly loaded fonts are encoded according to current
  3000. encoding */
  3001. T1_SetDefaultEncoding( NULL);
  3002. }
  3003. else{
  3004. for (i=0; i<MAXENCODINGS; ){
  3005. if ( encstruct[i].encfilename != NULL)
  3006. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  3007. i++;
  3008. break;
  3009. }
  3010. i++;
  3011. }
  3012. if (i==MAXENCODINGS){ /* Encoding from that file was not
  3013. already loaded -> so load it */
  3014. i=0;
  3015. while (encstruct[i].encfilename != NULL)
  3016. i++;
  3017. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  3018. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  3019. if (encstruct[i].encoding==NULL){
  3020. free( encstruct[i].encfilename);
  3021. encstruct[i].encfilename=NULL;
  3022. }
  3023. i++;
  3024. }
  3025. for (j=0; j<T1_GetNoFonts(); j++){
  3026. T1_DeleteAllSizes(j);
  3027. T1_ReencodeFont( j, encstruct[i-1].encoding);
  3028. }
  3029. /* Take care that newly loaded fonts are encoded according to current
  3030. encoding */
  3031. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  3032. }
  3033. strcpy( LastEncodingFile, EncodingFile);
  3034. }
  3035. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  3036. if (Slant!=lastSlant[FontID]){
  3037. /* Delete all size dependent data */
  3038. T1_DeleteAllSizes(FontID);
  3039. T1_LoadFont(FontID);
  3040. T1_SlantFont( FontID, Slant);
  3041. lastSlant[FontID]=Slant;
  3042. }
  3043. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  3044. if (Extent!=lastExtent[FontID]){
  3045. /* Delete all size dependent data */
  3046. T1_DeleteAllSizes(FontID);
  3047. T1_LoadFont(FontID);
  3048. T1_ExtendFont( FontID, Extent);
  3049. lastExtent[FontID]=Extent;
  3050. }
  3051. i=0;
  3052. XtSetArg(args[i], XtNstring, &theString); i++;
  3053. XtGetValues(dialogteststring,args,i);
  3054. if (Size<=0.0){
  3055. sprintf(statusstring, "t1lib: Size must be positive!");
  3056. i=0;
  3057. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3058. XtSetArg(args[i], XtNwidth,380); i++;
  3059. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3060. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3061. XtSetValues(labelstatus,args,i);
  3062. return;
  3063. }
  3064. /* Now comes the ligatur handling */
  3065. if (strcmp(theString,"")==0)
  3066. theString=(char *) TestString;
  3067. i=strlen(theString);
  3068. ligtheString=(char *)malloc((i+1)*sizeof(char));
  3069. if (LigDetect){
  3070. for (j=0,m=0;j<i;j++,m++){ /* Loop through the characters */
  3071. if ((k=T1_QueryLigs( FontID, theString[j], &succs, &ligs))>0){
  3072. buf_char=theString[j];
  3073. while (k>0){
  3074. none_found=1;
  3075. for (l=0;l<k;l++){ /* Loop through the ligatures */
  3076. if (succs[l]==theString[j+1]){
  3077. buf_char=ligs[l];
  3078. j++;
  3079. none_found=0;
  3080. break;
  3081. }
  3082. }
  3083. if (none_found)
  3084. break;
  3085. k=T1_QueryLigs( FontID, buf_char, &succs, &ligs);
  3086. }
  3087. ligtheString[m]=buf_char;
  3088. }
  3089. else{ /* There are no ligatures */
  3090. ligtheString[m]=theString[j];
  3091. }
  3092. }
  3093. ligtheString[m]=0;
  3094. }
  3095. else {
  3096. strcpy(ligtheString,theString);
  3097. }
  3098. tmp_width=2 * XOUTPUT_HALFHSIZE;
  3099. tmp_height=2 * XOUTPUT_HALFVSIZE;
  3100. if (tmp_pixmap==0)
  3101. tmp_pixmap=XCreatePixmap( display,
  3102. XtWindow(TopLevel),
  3103. tmp_width,
  3104. tmp_height,
  3105. depth
  3106. );
  3107. /* Put some background in pixmap for demonstration of transparent-mode: */
  3108. if (Opacity==0){
  3109. XSetForeground( display, DefaultGC( display, screennumber), pink4.pixel);
  3110. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3111. 0, 0, tmp_width, tmp_height);
  3112. XSetForeground( display, DefaultGC( display, screennumber), yellow.pixel);
  3113. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3114. tmp_width/4, tmp_height/4, tmp_width/2, tmp_height/2);
  3115. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3116. }
  3117. else{
  3118. XSetForeground( display, DefaultGC( display, screennumber), bg);
  3119. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3120. 0, 0, tmp_width, tmp_height);
  3121. }
  3122. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3123. XSetBackground( display, DefaultGC( display, screennumber), bg);
  3124. /* Synchronize display in order to make the time measurement more acurate */
  3125. XSync( display, True);
  3126. /* Reset T1_errno: */
  3127. T1_errno=0;
  3128. /* Draw the string into temporary pixmap */
  3129. gettimeofday(time_ptr_start, void_ptr);
  3130. if( extraflags & CHECK_PERFORMANCE){
  3131. j=0;
  3132. for (i=0; j<600; i++){
  3133. j=(int)(Size*1.2*i);
  3134. glyph=T1_SetStringX( XtWindow(OutputWindow2), DefaultGC( display, screennumber), Opacity,
  3135. 0, j, /* x_dest, y_dest */
  3136. FontID, (char *)ligtheString,
  3137. 0, Space, Modflag, Size, matrixP);
  3138. }
  3139. }
  3140. else{
  3141. glyph=T1_SetStringX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
  3142. XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE,
  3143. FontID, (char *)ligtheString,
  3144. 0, Space, Modflag, Size, matrixP);
  3145. }
  3146. gettimeofday(time_ptr_stop, void_ptr);
  3147. if ((extraflags & NO_GRID)==0){
  3148. XSetForeground( display, DefaultGC( display, screennumber), gridcolor1.pixel);
  3149. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3150. XOUTPUT_HALFHSIZE, 0, /* X1, Y1 */
  3151. XOUTPUT_HALFHSIZE, 2 * XOUTPUT_HALFVSIZE);
  3152. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3153. 0, XOUTPUT_HALFVSIZE, /* X1, Y1 */
  3154. 2 * XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE);
  3155. XSetForeground( display, DefaultGC( display, screennumber), gridcolor2.pixel);
  3156. if (glyph!=NULL){
  3157. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3158. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX - CROSS_SIZE,
  3159. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY,
  3160. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE,
  3161. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY);
  3162. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3163. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
  3164. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE,
  3165. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
  3166. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE);
  3167. }
  3168. }
  3169. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3170. /* Free the ligature-converted string */
  3171. free(ligtheString);
  3172. /* Check for errors */
  3173. if (glyph==NULL) {
  3174. sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
  3175. i=0;
  3176. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3177. XtSetArg(args[i], XtNwidth,380); i++;
  3178. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3179. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3180. XtSetValues(labelstatus,args,i);
  3181. return;
  3182. }
  3183. /* Prepare status message: */
  3184. 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",
  3185. time_diff(time_ptr_start,time_ptr_stop),
  3186. glyph->metrics.leftSideBearing,
  3187. glyph->metrics.rightSideBearing,
  3188. glyph->metrics.ascent,
  3189. glyph->metrics.descent,
  3190. glyph->metrics.advanceX,
  3191. glyph->metrics.advanceY,
  3192. glyph->bpp,
  3193. PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
  3194. T1_GetFontName(FontID),
  3195. T1_errno);
  3196. /* Finally, set resources */
  3197. i=0;
  3198. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3199. XtSetArg(args[i], XtNwidth,380); i++;
  3200. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3201. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  3202. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3203. XtSetValues(labelstatus,args,i);
  3204. i=0;
  3205. XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
  3206. XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
  3207. XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
  3208. XtSetArg( args[i], XtNresize, 1);i++;
  3209. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  3210. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  3211. XtSetArg( args[i], XtNbackground, outbg); i++;
  3212. XtSetValues(OutputWindow ,args,i);
  3213. i=0;
  3214. XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
  3215. XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
  3216. XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
  3217. XtSetArg( args[i], XtNresize, 1);i++;
  3218. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  3219. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  3220. XtSetArg( args[i], XtNbackground, outbg); i++;
  3221. XtSetValues(Output ,args,i);
  3222. }
  3223. void aashowcharX( Widget showcharbutton, XtPointer client_data, XtPointer call_data)
  3224. {
  3225. int i, j;
  3226. Arg args[10];
  3227. int tmp_width, tmp_height;
  3228. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  3229. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  3230. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  3231. sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar);
  3232. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  3233. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  3234. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  3235. sprintf(statusstring, "t1lib: FontID out of range!");
  3236. i=0;
  3237. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3238. XtSetArg(args[i], XtNwidth,380); i++;
  3239. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3240. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3241. XtSetValues(labelstatus,args,i);
  3242. return;
  3243. }
  3244. /* Ensure that font is loaded before any operation on the font */
  3245. if ( T1_CheckForFontID( FontID) < 1 ) {
  3246. T1_LoadFont( FontID);
  3247. }
  3248. if ( StrokeWidth == 0.0f ) {
  3249. T1_ClearStrokeFlag( FontID);
  3250. }
  3251. else {
  3252. T1_SetStrokeFlag( FontID);
  3253. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  3254. sprintf( statusstring, "t1lib: Unable to setup strokewidth");
  3255. i=0;
  3256. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3257. XtSetArg(args[i], XtNwidth,380); i++;
  3258. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3259. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3260. XtSetValues(labelstatus,args,i);
  3261. return;
  3262. }
  3263. }
  3264. if (CheckTransform()==0 && Angle==0.0){
  3265. matrixP=NULL;
  3266. }
  3267. else{
  3268. matrixP=T1_RotateMatrix( &matrix, Angle);
  3269. }
  3270. if (DeviceResolution!=last_resolution[FontID]){
  3271. /* Delete all size dependent data for that font */
  3272. for ( i=0; i<T1_GetNoFonts(); i++)
  3273. T1_DeleteAllSizes( i);
  3274. /* Establish new device resolution */
  3275. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  3276. /* Store current resolution */
  3277. last_resolution[FontID]=DeviceResolution;
  3278. }
  3279. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  3280. if (i==EOF) EncodingFile[0]=0;
  3281. if (strcmp(EncodingFile,LastEncodingFile)){ /* encoding has changed */
  3282. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  3283. for (i=0; i<T1_GetNoFonts(); i++){
  3284. T1_DeleteAllSizes(i);
  3285. T1_ReencodeFont( i, NULL);
  3286. }
  3287. /* Take care that newly loaded fonts are encoded according to current
  3288. encoding */
  3289. T1_SetDefaultEncoding( NULL);
  3290. }
  3291. else{
  3292. for (i=0; i<MAXENCODINGS; ){
  3293. if ( encstruct[i].encfilename != NULL)
  3294. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  3295. i++;
  3296. break;
  3297. }
  3298. i++;
  3299. }
  3300. if (i==MAXENCODINGS){ /* Encoding from that file was not
  3301. already loaded -> so load it */
  3302. i=0;
  3303. while (encstruct[i].encfilename != NULL)
  3304. i++;
  3305. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  3306. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  3307. if (encstruct[i].encoding==NULL){
  3308. free( encstruct[i].encfilename);
  3309. encstruct[i].encfilename=NULL;
  3310. }
  3311. i++;
  3312. }
  3313. for (j=0; j<T1_GetNoFonts(); j++){
  3314. T1_DeleteAllSizes(j);
  3315. T1_ReencodeFont( j, encstruct[i-1].encoding);
  3316. }
  3317. /* Take care that newly loaded fonts are encoded according to current
  3318. encoding */
  3319. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  3320. }
  3321. strcpy( LastEncodingFile, EncodingFile);
  3322. }
  3323. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  3324. if (Slant!=lastSlant[FontID]){
  3325. /* Delete all size dependent data */
  3326. T1_DeleteAllSizes(FontID);
  3327. T1_LoadFont(FontID);
  3328. T1_SlantFont( FontID, Slant);
  3329. lastSlant[FontID]=Slant;
  3330. }
  3331. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  3332. if (Extent!=lastExtent[FontID]){
  3333. /* Delete all size dependent data */
  3334. T1_DeleteAllSizes(FontID);
  3335. T1_LoadFont(FontID);
  3336. T1_ExtendFont( FontID, Extent);
  3337. lastExtent[FontID]=Extent;
  3338. }
  3339. if (Size<=0.0){
  3340. sprintf(statusstring, "t1lib: Size must be positive!");
  3341. i=0;
  3342. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3343. XtSetArg(args[i], XtNwidth,380); i++;
  3344. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3345. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3346. XtSetValues(labelstatus,args,i);
  3347. return;
  3348. }
  3349. tmp_width=2 * XOUTPUT_HALFHSIZE;
  3350. tmp_height=2 * XOUTPUT_HALFVSIZE;
  3351. if (tmp_pixmap==0)
  3352. tmp_pixmap=XCreatePixmap( display,
  3353. XtWindow(TopLevel),
  3354. tmp_width,
  3355. tmp_height,
  3356. depth
  3357. );
  3358. /* Put some background in pixmap for demonstration of transparent-mode: */
  3359. if (Opacity==0){
  3360. XSetForeground( display, DefaultGC( display, screennumber), pink4.pixel);
  3361. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3362. 0, 0, tmp_width, tmp_height);
  3363. XSetForeground( display, DefaultGC( display, screennumber), yellow.pixel);
  3364. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3365. tmp_width/4, tmp_height/4, tmp_width/2, tmp_height/2);
  3366. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3367. }
  3368. else{
  3369. XSetForeground( display, DefaultGC( display, screennumber), bg);
  3370. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3371. 0, 0, tmp_width, tmp_height);
  3372. }
  3373. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3374. XSetBackground( display, DefaultGC( display, screennumber), bg);
  3375. /* Synchronize display in order to make the time measurement more acurate */
  3376. XSync( display, True);
  3377. /* Reset T1_errno: */
  3378. T1_errno=0;
  3379. /* Set antialiasing level */
  3380. T1_AASetLevel( aalevel);
  3381. gettimeofday(time_ptr_start, void_ptr);
  3382. if ( extraflags & CHECK_SET_RECT )
  3383. glyph=T1_AASetRectX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
  3384. XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
  3385. FontID, Size, 1000.0, 1000.0, matrixP);
  3386. else
  3387. glyph=T1_AASetCharX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
  3388. XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
  3389. FontID, TestChar, Size, matrixP);
  3390. gettimeofday(time_ptr_stop, void_ptr);
  3391. if ((extraflags & NO_GRID)==0){
  3392. XSetForeground( display, DefaultGC( display, screennumber), gridcolor1.pixel);
  3393. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3394. XOUTPUT_HALFHSIZE, 0, /* X1, Y1 */
  3395. XOUTPUT_HALFHSIZE, 2 * XOUTPUT_HALFVSIZE);
  3396. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3397. 0, XOUTPUT_HALFVSIZE, /* X1, Y1 */
  3398. 2 * XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE);
  3399. XSetForeground( display, DefaultGC( display, screennumber), gridcolor2.pixel);
  3400. if (glyph!=NULL){
  3401. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3402. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX - CROSS_SIZE,
  3403. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY,
  3404. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE,
  3405. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY);
  3406. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3407. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
  3408. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE,
  3409. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
  3410. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE);
  3411. }
  3412. }
  3413. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3414. /* Check for errors */
  3415. if (glyph==NULL) {
  3416. sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
  3417. i=0;
  3418. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3419. XtSetArg(args[i], XtNwidth,380); i++;
  3420. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3421. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3422. XtSetValues(labelstatus,args,i);
  3423. return;
  3424. }
  3425. /* Prepare status message: */
  3426. 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",
  3427. time_diff(time_ptr_start,time_ptr_stop),
  3428. glyph->metrics.leftSideBearing,
  3429. glyph->metrics.rightSideBearing,
  3430. glyph->metrics.ascent,
  3431. glyph->metrics.descent,
  3432. glyph->metrics.advanceX,
  3433. glyph->metrics.advanceY,
  3434. glyph->bpp,
  3435. PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
  3436. T1_GetFontName(FontID),
  3437. T1_GetCharName(FontID,(char)TestChar),
  3438. T1_errno);
  3439. /* Finally, set the resources: */
  3440. i=0;
  3441. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3442. XtSetArg(args[i], XtNwidth,380); i++;
  3443. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3444. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  3445. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3446. XtSetValues(labelstatus,args,i);
  3447. i=0;
  3448. XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
  3449. XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
  3450. XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
  3451. XtSetArg( args[i], XtNresize, 1);i++;
  3452. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  3453. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  3454. XtSetArg( args[i], XtNbackground, outbg); i++;
  3455. XtSetValues(OutputWindow ,args,i);
  3456. i=0;
  3457. XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
  3458. XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
  3459. XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
  3460. XtSetArg( args[i], XtNresize, 1);i++;
  3461. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  3462. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  3463. XtSetValues(Output ,args,i);
  3464. }
  3465. void aashowstringX( Widget showstringbutton, XtPointer client_data, XtPointer call_data)
  3466. {
  3467. int i,j,k,l,m,none_found;
  3468. Arg args[10];
  3469. int tmp_width, tmp_height;
  3470. char *theString='\0';
  3471. char *ligtheString='\0';
  3472. char *succs, *ligs;
  3473. char buf_char;
  3474. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  3475. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  3476. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  3477. sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
  3478. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  3479. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  3480. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  3481. sprintf(statusstring, "t1lib: FontID out of range!");
  3482. i=0;
  3483. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3484. XtSetArg(args[i], XtNwidth,380); i++;
  3485. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3486. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3487. XtSetValues(labelstatus,args,i);
  3488. return;
  3489. }
  3490. /* Ensure that font is loaded before any operation on the font */
  3491. if ( T1_CheckForFontID( FontID) < 1 ) {
  3492. T1_LoadFont( FontID);
  3493. }
  3494. if ( StrokeWidth == 0.0f ) {
  3495. T1_ClearStrokeFlag( FontID);
  3496. }
  3497. else {
  3498. T1_SetStrokeFlag( FontID);
  3499. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  3500. sprintf( statusstring, "t1lib: Unable to setup strokewidth");
  3501. i=0;
  3502. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3503. XtSetArg(args[i], XtNwidth,380); i++;
  3504. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3505. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3506. XtSetValues(labelstatus,args,i);
  3507. return;
  3508. }
  3509. }
  3510. if (CheckTransform()==0 && Angle==0.0){
  3511. matrixP=NULL;
  3512. }
  3513. else{
  3514. matrixP=T1_RotateMatrix( &matrix, Angle);
  3515. }
  3516. if (DeviceResolution!=last_resolution[FontID]){
  3517. /* Delete all size dependent data for that font */
  3518. for ( i=0; i<T1_GetNoFonts(); i++)
  3519. T1_DeleteAllSizes( i);
  3520. /* Establish new device resolution */
  3521. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  3522. /* Store current resolution */
  3523. last_resolution[FontID]=DeviceResolution;
  3524. }
  3525. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  3526. if (i==EOF) EncodingFile[0]=0;
  3527. if (strcmp(EncodingFile,LastEncodingFile)!=0){ /* encoding has changed */
  3528. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  3529. for (i=0; i<T1_GetNoFonts(); i++){
  3530. T1_DeleteAllSizes(i);
  3531. T1_ReencodeFont( i, NULL);
  3532. }
  3533. /* Take care that newly loaded fonts are encoded according to current
  3534. encoding */
  3535. T1_SetDefaultEncoding( NULL);
  3536. }
  3537. else{
  3538. for (i=0; i<MAXENCODINGS; ){
  3539. if ( encstruct[i].encfilename != NULL)
  3540. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  3541. i++;
  3542. break;
  3543. }
  3544. i++;
  3545. }
  3546. if (i==MAXENCODINGS){ /* Encoding from that file was not
  3547. already loaded -> so load it */
  3548. i=0;
  3549. while (encstruct[i].encfilename != NULL)
  3550. i++;
  3551. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  3552. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  3553. if (encstruct[i].encoding==NULL){
  3554. free( encstruct[i].encfilename);
  3555. encstruct[i].encfilename=NULL;
  3556. }
  3557. i++;
  3558. }
  3559. else
  3560. for (j=0; j<T1_GetNoFonts(); j++){
  3561. T1_DeleteAllSizes(j);
  3562. T1_ReencodeFont( j, encstruct[i-1].encoding);
  3563. }
  3564. /* Take care that newly loaded fonts are encoded according to current
  3565. encoding */
  3566. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  3567. }
  3568. strcpy( LastEncodingFile, EncodingFile);
  3569. }
  3570. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  3571. if (Slant!=lastSlant[FontID]){
  3572. /* Delete all size dependent data */
  3573. T1_DeleteAllSizes(FontID);
  3574. T1_LoadFont(FontID);
  3575. T1_SlantFont( FontID, Slant);
  3576. lastSlant[FontID]=Slant;
  3577. }
  3578. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  3579. if (Extent!=lastExtent[FontID]){
  3580. /* Delete all size dependent data */
  3581. T1_DeleteAllSizes(FontID);
  3582. T1_LoadFont(FontID);
  3583. T1_ExtendFont( FontID, Extent);
  3584. lastExtent[FontID]=Extent;
  3585. }
  3586. i=0;
  3587. XtSetArg(args[i], XtNstring, &theString); i++;
  3588. XtGetValues(dialogteststring,args,i);
  3589. if (Size<=0.0){
  3590. sprintf(statusstring, "t1lib: Size must be positive!");
  3591. i=0;
  3592. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3593. XtSetArg(args[i], XtNwidth,380); i++;
  3594. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3595. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3596. XtSetValues(labelstatus,args,i);
  3597. return;
  3598. }
  3599. /* Now comes the ligatur handling */
  3600. if (strcmp(theString,"")==0)
  3601. theString=(char *) TestString;
  3602. i=strlen(theString);
  3603. ligtheString=(char *)malloc((i+1)*sizeof(char));
  3604. if (LigDetect){
  3605. for (j=0,m=0;j<i;j++,m++){ /* Loop through the characters */
  3606. if ((k=T1_QueryLigs( FontID, theString[j], &succs, &ligs))>0){
  3607. buf_char=theString[j];
  3608. while (k>0){
  3609. none_found=1;
  3610. for (l=0;l<k;l++){ /* Loop through the ligatures */
  3611. if (succs[l]==theString[j+1]){
  3612. buf_char=ligs[l];
  3613. j++;
  3614. none_found=0;
  3615. break;
  3616. }
  3617. }
  3618. if (none_found)
  3619. break;
  3620. k=T1_QueryLigs( FontID, buf_char, &succs, &ligs);
  3621. }
  3622. ligtheString[m]=buf_char;
  3623. }
  3624. else{ /* There are no ligatures */
  3625. ligtheString[m]=theString[j];
  3626. }
  3627. }
  3628. ligtheString[m]=0;
  3629. }
  3630. else {
  3631. strcpy(ligtheString,theString);
  3632. }
  3633. tmp_width=2 * XOUTPUT_HALFHSIZE;
  3634. tmp_height=2 * XOUTPUT_HALFVSIZE;
  3635. if (tmp_pixmap==0)
  3636. tmp_pixmap=XCreatePixmap( display,
  3637. XtWindow(TopLevel),
  3638. tmp_width,
  3639. tmp_height,
  3640. depth
  3641. );
  3642. /* Put some background in pixmap for demonstration of transparent-mode: */
  3643. if (Opacity==0){
  3644. XSetForeground( display, DefaultGC( display, screennumber), pink4.pixel);
  3645. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3646. 0, 0, tmp_width, tmp_height);
  3647. XSetForeground( display, DefaultGC( display, screennumber), yellow.pixel);
  3648. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3649. tmp_width/4, tmp_height/4, tmp_width/2, tmp_height/2);
  3650. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3651. }
  3652. else{
  3653. XSetForeground( display, DefaultGC( display, screennumber), bg);
  3654. XFillRectangle( display, tmp_pixmap, DefaultGC( display, screennumber),
  3655. 0, 0, tmp_width, tmp_height);
  3656. }
  3657. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3658. XSetBackground( display, DefaultGC( display, screennumber), bg);
  3659. /* Synchronize display in order to make the time measurement more acurate */
  3660. XSync( display, True);
  3661. /* Reset T1_errno: */
  3662. T1_errno=0;
  3663. /* Set antialiasing level */
  3664. T1_AASetLevel( aalevel);
  3665. /* Draw the string into temporary pixmap */
  3666. gettimeofday(time_ptr_start, void_ptr);
  3667. if( extraflags & CHECK_PERFORMANCE){
  3668. j=0;
  3669. for (i=0; j<600; i++){
  3670. j=(int)(Size*1.2*i);
  3671. glyph=T1_AASetStringX( XtWindow(OutputWindow2), DefaultGC( display, screennumber), Opacity,
  3672. 0, j, /* x_dest, y_dest */
  3673. FontID, (char *)ligtheString,
  3674. 0, Space, Modflag, Size, matrixP);
  3675. }
  3676. }
  3677. else{
  3678. glyph=T1_AASetStringX( tmp_pixmap, DefaultGC( display, screennumber), Opacity,
  3679. XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE, /* x_dest, y_dest */
  3680. FontID, (char *)ligtheString,
  3681. 0, Space, Modflag, Size, matrixP);
  3682. }
  3683. gettimeofday(time_ptr_stop, void_ptr);
  3684. if ((extraflags & NO_GRID)==0){
  3685. XSetForeground( display, DefaultGC( display, screennumber), gridcolor1.pixel);
  3686. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3687. XOUTPUT_HALFHSIZE, 0, /* X1, Y1 */
  3688. XOUTPUT_HALFHSIZE, 2 * XOUTPUT_HALFVSIZE);
  3689. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3690. 0, XOUTPUT_HALFVSIZE, /* X1, Y1 */
  3691. 2 * XOUTPUT_HALFHSIZE, XOUTPUT_HALFVSIZE);
  3692. XSetForeground( display, DefaultGC( display, screennumber), gridcolor2.pixel);
  3693. if (glyph!=NULL){
  3694. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3695. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX - CROSS_SIZE,
  3696. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY,
  3697. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE,
  3698. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY);
  3699. XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber),
  3700. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
  3701. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE,
  3702. XOUTPUT_HALFHSIZE + glyph->metrics.advanceX,
  3703. XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE);
  3704. }
  3705. }
  3706. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3707. /* Free the ligature-converted string */
  3708. free(ligtheString);
  3709. /* Check for errors */
  3710. if (glyph==NULL) {
  3711. sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno));
  3712. i=0;
  3713. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3714. XtSetArg(args[i], XtNwidth,380); i++;
  3715. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3716. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3717. XtSetValues(labelstatus,args,i);
  3718. return;
  3719. }
  3720. /* Prepare status message: */
  3721. 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",
  3722. time_diff(time_ptr_start,time_ptr_stop),
  3723. glyph->metrics.leftSideBearing,
  3724. glyph->metrics.rightSideBearing,
  3725. glyph->metrics.ascent,
  3726. glyph->metrics.descent,
  3727. glyph->metrics.advanceX,
  3728. glyph->metrics.advanceY,
  3729. glyph->bpp,
  3730. PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent),
  3731. T1_GetFontName(FontID),
  3732. T1_errno);
  3733. /* Finally, set resources */
  3734. i=0;
  3735. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3736. XtSetArg(args[i], XtNwidth,380); i++;
  3737. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3738. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  3739. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3740. XtSetValues(labelstatus,args,i);
  3741. i=0;
  3742. XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
  3743. XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
  3744. XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
  3745. XtSetArg( args[i], XtNresize, 1);i++;
  3746. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  3747. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  3748. XtSetArg( args[i], XtNbackground, outbg); i++;
  3749. XtSetValues(OutputWindow ,args,i);
  3750. i=0;
  3751. XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++;
  3752. XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++;
  3753. XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++;
  3754. XtSetArg( args[i], XtNresize, 1);i++;
  3755. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  3756. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  3757. XtSetArg( args[i], XtNbackground, outbg); i++;
  3758. XtSetValues(Output ,args,i);
  3759. }
  3760. void fonttable( Widget fonttablebutton, XtPointer client_data, XtPointer call_data)
  3761. {
  3762. int i, j;
  3763. Arg args[10];
  3764. static Pixmap pixmap=0;
  3765. int x, y;
  3766. int CellLeftMargin, CellTopMargin;
  3767. int ColAdvance, RowAdvance;
  3768. int width, height;
  3769. int FontID, DeviceResolution;
  3770. float Size, Extent, Slant;
  3771. float scale;
  3772. BBox fontbbox, tmpbbox;
  3773. sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID);
  3774. sscanf( XawDialogGetValueString(dialogsize),"%f", &Size);
  3775. sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle);
  3776. sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space);
  3777. sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution);
  3778. sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth);
  3779. if (FontID<0 || FontID>=T1_GetNoFonts()) {
  3780. sprintf(statusstring, "t1lib: FontID out of range!");
  3781. i=0;
  3782. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3783. XtSetArg(args[i], XtNwidth,380); i++;
  3784. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3785. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3786. XtSetValues(labelstatus,args,i);
  3787. return;
  3788. }
  3789. /* Ensure that font is loaded before any operation on the font */
  3790. if ( T1_CheckForFontID( FontID) < 1 ) {
  3791. T1_LoadFont( FontID);
  3792. }
  3793. if ( StrokeWidth == 0.0f ) {
  3794. T1_ClearStrokeFlag( FontID);
  3795. }
  3796. else {
  3797. T1_SetStrokeFlag( FontID);
  3798. if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) {
  3799. sprintf( statusstring, "t1lib: Unable to setup strokewidth");
  3800. i=0;
  3801. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3802. XtSetArg(args[i], XtNwidth,380); i++;
  3803. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3804. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3805. XtSetValues(labelstatus,args,i);
  3806. return;
  3807. }
  3808. }
  3809. /* We don't obey rotation when displaying a fonttable */
  3810. matrixP=NULL;
  3811. if (DeviceResolution!=last_resolution[FontID]){
  3812. /* Delete all size dependent data for that font */
  3813. for ( i=0; i<T1_GetNoFonts(); i++)
  3814. T1_DeleteAllSizes( i);
  3815. /* Establish new device resolution */
  3816. T1_SetDeviceResolutions(DeviceResolution,DeviceResolution);
  3817. /* Store current resolution */
  3818. last_resolution[FontID]=DeviceResolution;
  3819. }
  3820. i=sscanf( XawDialogGetValueString(dialogencfile),"%s", (char *)EncodingFile);
  3821. if (i==EOF) EncodingFile[0]=0;
  3822. if (strcmp(EncodingFile,LastEncodingFile)!=0){ /* encoding has changed */
  3823. if (strcmp( EncodingFile, "")==0){ /* -> reset to internal encoding */
  3824. for (i=0; i<T1_GetNoFonts(); i++){
  3825. T1_DeleteAllSizes(i);
  3826. T1_ReencodeFont( i, NULL);
  3827. }
  3828. /* Take care that newly loaded fonts are encoded according to current
  3829. encoding */
  3830. T1_SetDefaultEncoding( NULL);
  3831. }
  3832. else{
  3833. for (i=0; i<MAXENCODINGS; ){
  3834. if ( encstruct[i].encfilename != NULL)
  3835. if (strcmp( encstruct[i].encfilename, EncodingFile)==0){
  3836. i++;
  3837. break;
  3838. }
  3839. i++;
  3840. }
  3841. if (i==MAXENCODINGS){ /* Encoding from that file was not
  3842. already loaded -> so load it */
  3843. i=0;
  3844. while (encstruct[i].encfilename != NULL)
  3845. i++;
  3846. encstruct[i].encoding=T1_LoadEncoding(EncodingFile);
  3847. encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1);
  3848. if (encstruct[i].encoding==NULL){
  3849. free( encstruct[i].encfilename);
  3850. encstruct[i].encfilename=NULL;
  3851. }
  3852. i++;
  3853. }
  3854. else
  3855. for (j=0; j<T1_GetNoFonts(); j++){
  3856. T1_DeleteAllSizes(j);
  3857. T1_ReencodeFont( j, encstruct[i-1].encoding);
  3858. }
  3859. /* Take care that newly loaded fonts are encoded according to current
  3860. encoding */
  3861. T1_SetDefaultEncoding( encstruct[i-1].encoding);
  3862. }
  3863. strcpy( LastEncodingFile, EncodingFile);
  3864. }
  3865. sscanf( XawDialogGetValueString(dialogslant),"%f", &Slant);
  3866. if (Slant!=lastSlant[FontID]){
  3867. /* Delete all size dependent data */
  3868. T1_DeleteAllSizes(FontID);
  3869. T1_LoadFont(FontID);
  3870. T1_SlantFont( FontID, Slant);
  3871. lastSlant[FontID]=Slant;
  3872. }
  3873. sscanf( XawDialogGetValueString(dialogextent),"%f", &Extent);
  3874. if (Extent!=lastExtent[FontID]){
  3875. /* Delete all size dependent data */
  3876. T1_DeleteAllSizes(FontID);
  3877. T1_LoadFont(FontID);
  3878. T1_ExtendFont( FontID, Extent);
  3879. lastExtent[FontID]=Extent;
  3880. }
  3881. if (Size<=0.0){
  3882. sprintf(statusstring, "t1lib: Size must be positive!");
  3883. i=0;
  3884. XtSetArg(args[i], XtNbitmap,NULL); i++;
  3885. XtSetArg(args[i], XtNwidth,380); i++;
  3886. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  3887. XtSetArg(args[i], XtNlabel, statusstring); i++;
  3888. XtSetValues(labelstatus,args,i);
  3889. return;
  3890. }
  3891. /* We have read all parameters, now lets get font bbox in order to be
  3892. able to compute the cell-metrics */
  3893. T1_LoadFont( FontID);
  3894. fontbbox=T1_GetFontBBox( FontID);
  3895. /* we check for a valid fontbbox, otherwise we compute it ourselves */
  3896. if ( fontbbox.llx==0 &&
  3897. fontbbox.lly==0 &&
  3898. fontbbox.urx==0 &&
  3899. fontbbox.ury==0 ){
  3900. T1_PrintLog( "fonttable()", "Re-Computing FontBBox", T1LOG_DEBUG);
  3901. for (i=0; i<256; i++){
  3902. tmpbbox=T1_GetCharBBox( FontID, i);
  3903. if (tmpbbox.llx<fontbbox.llx)
  3904. fontbbox.llx=tmpbbox.llx;
  3905. if (tmpbbox.lly<fontbbox.lly)
  3906. fontbbox.lly=tmpbbox.lly;
  3907. if (tmpbbox.urx>fontbbox.urx)
  3908. fontbbox.urx=tmpbbox.urx;
  3909. if (tmpbbox.ury>fontbbox.ury)
  3910. fontbbox.ury=tmpbbox.ury;
  3911. }
  3912. }
  3913. /* We scale the font bounding box according to extent, slant and
  3914. device resolution. For the slant, we assume that the font contains
  3915. at least one character which reaches to the upper right corner and
  3916. the same for lower left corner. */
  3917. scale=DeviceResolution/72.0;
  3918. fontbbox.urx=fontbbox.urx+(int)((float)fontbbox.ury*Slant);
  3919. fontbbox.llx=fontbbox.llx+(int)((float)fontbbox.lly*Slant);
  3920. fontbbox.urx=(int)((float)fontbbox.urx*Extent);
  3921. fontbbox.llx=(int)((float)fontbbox.llx*Extent);
  3922. fontbbox.llx=(int)((float)fontbbox.llx*scale);
  3923. fontbbox.urx=(int)((float)fontbbox.urx*scale);
  3924. fontbbox.lly=(int)((float)fontbbox.lly*scale);
  3925. fontbbox.ury=(int)((float)fontbbox.ury*scale);
  3926. /* Left and top margin of the char-origins with respect upper left corner
  3927. of cell */
  3928. CellTopMargin=SIMPLEMARGIN + fontbbox.ury;
  3929. if (fontbbox.llx < 0){
  3930. CellLeftMargin= - fontbbox.llx;
  3931. }
  3932. else{
  3933. CellLeftMargin=0;
  3934. }
  3935. /* How much to advance in which direction when incrementing */
  3936. ColAdvance=CellLeftMargin + fontbbox.urx ;
  3937. RowAdvance=CellTopMargin - fontbbox.lly ;
  3938. /* Scale the charspace values */
  3939. CellTopMargin = (int) floor((double)CellTopMargin*Size/1000.0+0.5)+SIMPLEMARGIN;
  3940. CellLeftMargin = (int) floor((double)CellLeftMargin*Size/1000.0+0.5)+SIMPLEMARGIN;
  3941. ColAdvance = (int) floor((double)ColAdvance*Size/1000.0+0.5)+DOUBLEMARGIN;
  3942. RowAdvance = (int) floor((double)RowAdvance*Size/1000.0+0.5)+DOUBLEMARGIN;
  3943. /* Overall width and height of map */
  3944. width=1+(16*ColAdvance);
  3945. height=1+(16*RowAdvance);
  3946. /* We clip to a window as large as the screen in this function */
  3947. if (width > 1024)
  3948. width=WidthOfScreen(screen);
  3949. if (height > 768)
  3950. height=HeightOfScreen(screen);
  3951. /* Create pixmap of appropriate size, */
  3952. if (pixmap!=0)
  3953. XFreePixmap( display, pixmap);
  3954. pixmap=XCreatePixmap( display,
  3955. XtWindow(TopLevel),
  3956. width,
  3957. height,
  3958. depth
  3959. );
  3960. /* We always use opaque mode */
  3961. XSetForeground( display, DefaultGC( display, screennumber), bg);
  3962. XFillRectangle( display, pixmap, DefaultGC( display, screennumber),
  3963. 0, 0, width, height);
  3964. XSetForeground( display, DefaultGC( display, screennumber), fg);
  3965. XSetBackground( display, DefaultGC( display, screennumber), bg);
  3966. /* Draw cell grid: */
  3967. for (j=0; j<17; j++){
  3968. XDrawLine( display, pixmap, DefaultGC( display, screennumber),
  3969. j*ColAdvance, 0,
  3970. j*ColAdvance, height);
  3971. }
  3972. for (j=0; j<17; j++){
  3973. XDrawLine( display, pixmap, DefaultGC( display, screennumber),
  3974. 0, j*RowAdvance,
  3975. width, j*RowAdvance);
  3976. }
  3977. /* Reset T1_errno: */
  3978. T1_errno=0;
  3979. /* Set antialiasing level */
  3980. T1_AASetLevel( aalevel);
  3981. /* Draw characters into pixmap */
  3982. for ( i=0; i<16; ) { /* row-loop */
  3983. for ( j=0; j<16; j++) {
  3984. x=1+(j*ColAdvance)+CellLeftMargin;
  3985. y=1+CellTopMargin+(i*RowAdvance);
  3986. glyph=T1_AASetCharX( pixmap, DefaultGC( display, screennumber), 1,
  3987. x, y, FontID, (char) (i*16+j), Size, matrixP);
  3988. if (x>width) {
  3989. sprintf( msg_buf, "Clipping row %d horizontally at column %d", i, j);
  3990. T1_PrintLog( "fonttable()", msg_buf, T1LOG_STATISTIC);
  3991. break;
  3992. }
  3993. }
  3994. if (y>height) {
  3995. sprintf( msg_buf, "Clipping vertically at row %d", i);
  3996. T1_PrintLog( "fonttable()", msg_buf, T1LOG_STATISTIC);
  3997. break;
  3998. }
  3999. i++;
  4000. }
  4001. /* If font was not loadable */
  4002. if (T1_GetFontName( FontID)==NULL)
  4003. sprintf(statusstring, "t1lib: Can't get font name, T1_errno=%d!", T1_errno);
  4004. else
  4005. sprintf(statusstring,"Font %s, final T1_errno = %d\n %s",
  4006. T1_GetFontName( FontID), T1_errno, T1_StrError(T1_errno));
  4007. /* Finally, set resources */
  4008. i=0;
  4009. XtSetArg(args[i], XtNbitmap,NULL); i++;
  4010. XtSetArg(args[i], XtNwidth,380); i++;
  4011. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  4012. XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++;
  4013. XtSetArg(args[i], XtNlabel, statusstring); i++;
  4014. XtSetValues(labelstatus,args,i);
  4015. i=0;
  4016. XtSetArg( args[i], XtNwidth, width); i++;
  4017. XtSetArg( args[i], XtNheight, height); i++;
  4018. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  4019. XtSetArg( args[i], XtNresize, 1);i++;
  4020. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  4021. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  4022. XtSetArg( args[i], XtNbackground, outbg); i++;
  4023. XtSetValues(OutputWindow ,args,i);
  4024. i=0;
  4025. XtSetArg( args[i], XtNwidth, width); i++;
  4026. XtSetArg( args[i], XtNheight, height); i++;
  4027. XtSetArg( args[i], XtNbitmap, pixmap); i++;
  4028. XtSetArg( args[i], XtNresize, 1);i++;
  4029. XtSetArg( args[i], XtNinternalWidth, 0); i++;
  4030. XtSetArg( args[i], XtNinternalHeight, 0); i++;
  4031. XtSetArg( args[i], XtNbackground, outbg); i++;
  4032. XtSetValues(Output ,args,i);
  4033. }
  4034. /* This function shows the About-message */
  4035. void showabout( Widget aboutbutton, XtPointer client_data, XtPointer call_data)
  4036. {
  4037. int i;
  4038. Arg args[10];
  4039. Pixmap about=0;
  4040. XGCValues xgcvalues;
  4041. GC gc;
  4042. static char ident[80]="";
  4043. #define T1GCMASK GCForeground | GCBackground
  4044. if (about==0) {
  4045. about=XCreatePixmap( display, XtWindow(TopLevel),
  4046. 380, MESSAGEBOXHEIGHT, depth);
  4047. }
  4048. gc=DefaultGC( display, screennumber);
  4049. XGetGCValues( display, gc, T1GCMASK, &xgcvalues);
  4050. fg=xgcvalues.foreground;
  4051. bg=xgcvalues.background;
  4052. XSetForeground( display, gc, white.pixel);
  4053. XFillRectangle( display, about, gc, 0, 0, 380, MESSAGEBOXHEIGHT);
  4054. XSetForeground( display, gc, black.pixel);
  4055. XSetBackground( display, gc, white.pixel);
  4056. /* Set antialiasing level */
  4057. T1_AASetLevel( aalevel);
  4058. sprintf( ident, "This is xglyph, T1Lib Version %s", T1_GetLibIdent());
  4059. glyph=T1_AASetStringX( about, gc, 1, 10, 30, /* x_dest, y_dest */
  4060. 0, ident,
  4061. 0, 0.0, T1_UNDERLINE | T1_KERNING, 20.0, NULL);
  4062. glyph=T1_AASetStringX( about, gc, 1, 10, 60, /* x_dest, y_dest */
  4063. 0, "xglyph is an interactive tool for illustrating some",
  4064. 0, 0.0, T1_KERNING, 15.0, NULL);
  4065. glyph=T1_AASetStringX( about, gc, 1, 10, 80, /* x_dest, y_dest */
  4066. 0, "of the T1Lib features. T1Lib is distributed under",
  4067. 0, 0.0, T1_KERNING, 15.0, NULL);
  4068. glyph=T1_AASetStringX( about, gc, 1, 10, 100, /* x_dest, y_dest */
  4069. 0, "the GNU General Public Library License (LGPL).",
  4070. 0, 0.0, T1_KERNING, 15.0, NULL);
  4071. glyph=T1_AASetStringX( about, gc, 1, 10, 133, /* x_dest, y_dest */
  4072. 0, "Enjoy it!",
  4073. 0, 0.0, T1_KERNING, 15.0, NULL);
  4074. XSetForeground( display, gc, fg);
  4075. XSetBackground( display, gc, bg);
  4076. i=0;
  4077. XtSetArg(args[i], XtNwidth,380); i++;
  4078. XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++;
  4079. XtSetArg(args[i], XtNbackgroundPixmap, about); i++;
  4080. XtSetArg(args[i], XtNlabel, ""); i++;
  4081. XtSetValues(labelstatus,args,i);
  4082. }
  4083. /* This function returns a time difference in Microseconds, provided that
  4084. the time difference is not greater than approximately 35 minutes. */
  4085. long time_diff(struct timeval *time_ptr_start, struct timeval *time_ptr_stop)
  4086. {
  4087. return((time_ptr_stop->tv_sec -
  4088. time_ptr_start->tv_sec)*1000000
  4089. +(time_ptr_stop->tv_usec -
  4090. time_ptr_start->tv_usec));
  4091. }
  4092. /* T1_ComputeAAColorsX(): Compute the antialiasing colors in dependency
  4093. of foreground and background */
  4094. int ComputeAAColorsX( unsigned long fg, unsigned long bg, int nolevels)
  4095. {
  4096. static unsigned long last_fg;
  4097. static unsigned long last_bg;
  4098. unsigned long delta_red, delta_green, delta_blue;
  4099. int i;
  4100. int nocolors=0;
  4101. aacolors[0].pixel=bg;
  4102. aacolors[nolevels-1].pixel=fg;
  4103. if ((fg==last_fg)&&(bg==last_bg))
  4104. return(nocolors);
  4105. /* Get RGB values for fore- and background */
  4106. XQueryColor( display, DefaultColormap(display,screennumber), &aacolors[0]);
  4107. XQueryColor( display, DefaultColormap(display,screennumber), &aacolors[nolevels-1]);
  4108. delta_red = (aacolors[nolevels-1].red - aacolors[0].red)/(nolevels-1);
  4109. delta_green = (aacolors[nolevels-1].green - aacolors[0].green)/(nolevels-1);
  4110. delta_blue = (aacolors[nolevels-1].blue - aacolors[0].blue)/(nolevels-1);
  4111. aapixels[0]=aacolors[0].pixel;
  4112. aapixels[nolevels-1]=aacolors[nolevels-1].pixel;
  4113. for (i=1; i<nolevels-1; i++){
  4114. aacolors[i].red = aacolors[i-1].red + delta_red;
  4115. aacolors[i].green = aacolors[i-1].green + delta_green;
  4116. aacolors[i].blue = aacolors[i-1].blue + delta_blue;
  4117. /* Allocate color in current palette */
  4118. if (XAllocColor( display, DefaultColormap(display,screennumber),
  4119. &aacolors[i])!=0){
  4120. aapixels[i]=aacolors[i].pixel;
  4121. nocolors++;
  4122. }
  4123. }
  4124. return(nocolors);
  4125. }
  4126. void printusage( int max)
  4127. {
  4128. int i=0;
  4129. if (max==0)
  4130. max=100000; /* should be large enough :) */
  4131. fprintf(stdout, "xglyph -- t1lib Version %s\n\n", T1_GetLibIdent());
  4132. fprintf(stdout, "Usage: xglyph [options] [fontfile1 [fontfile2 [...]]]\n\n");
  4133. fprintf(stdout, "where options is one of:\n");
  4134. while ( xglyphoptions[i]!=NULL && i<max){
  4135. if (i==3) /* We print the possible values here. */
  4136. fprintf( stdout, "\t\t%s {8,16,32}\n", xglyphoptions[i++]);
  4137. else
  4138. fprintf( stdout, "\t\t%s\n", xglyphoptions[i++]);
  4139. }
  4140. fprintf(stdout, "For additional information see the t1lib manual!\n");
  4141. return;
  4142. }
  4143. int CheckTransform( void)
  4144. {
  4145. int err;
  4146. float x1, x2, x3, x4;
  4147. err=sscanf( XawDialogGetValueString(dialogtmatrix), "%f,%f,%f,%f",
  4148. &x1, &x2, &x3, &x4 );
  4149. if ( (x1 == (float) 1.0) &&
  4150. (x2 == (float) 0.0) &&
  4151. (x3 == (float) 0.0) &&
  4152. (x4 == (float) 1.0) ){
  4153. matrix.cxx=x1;
  4154. matrix.cyx=x2;
  4155. matrix.cxy=x3;
  4156. matrix.cyy=x4;
  4157. return( 0);
  4158. }
  4159. else{
  4160. matrix.cxx=x1;
  4161. matrix.cyx=x2;
  4162. matrix.cxy=x3;
  4163. matrix.cyy=x4;
  4164. return( 1);
  4165. }
  4166. }