/*-------------------------------------------------------------------------- ----- File: xglyph.c ----- Author: Rainer Menzner (Rainer.Menzner@web.de) ----- Date: 2003-01-02 ----- Description: This file is part of the t1-library. The program xglyph allows viewing of character- and string-glyphs. Diverse parameters may be interactively configured. ----- Copyright: t1lib is copyrighted (c) Rainer Menzner, 1996-2003. As of version 0.5, t1lib is distributed under the GNU General Public Library Lincense. The conditions can be found in the files LICENSE and LGPL, which should reside in the toplevel directory of the distribution. Please note that there are parts of t1lib that are subject to other licenses: The parseAFM-package is copyrighted by Adobe Systems Inc. The type1 rasterizer is copyrighted by IBM and the X11-consortium. ----- Warranties: Of course, there's NO WARRANTY OF ANY KIND :-) ----- Credits: I want to thank IBM and the X11-consortium for making their rasterizer freely available. Also thanks to Piet Tutelaers for his ps2pk, from which I took the rasterizer sources in a format independent from X11. Thanks to all people who make free software living! --------------------------------------------------------------------------*/ /* definitions for activating special tests for features of t1lib via commandline arguments: */ #define CHECK_PERFORMANCE 0x0001 #define CHECK_T1_COPYFONT_T1_ADDFONT 0x0002 #define CHECK_CONCATGLYPHS 0x0004 #define CHECK_CONCATOUTLINES 0x0008 #define CHECK_FOR_BAD_CHARS 0x0010 #define CHECK_DEFAULT_ENCODING 0x0020 #define CHECK_SMART_AA 0x0040 #define NO_GRID 0x0080 #define CHECK_AA_CACHING 0x0100 #define CHECK_CACHE_STROKED 0x0200 #define CHECK_SET_RECT 0x0400 /* #define SHOW_MANIPULATE_PATHS */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* The following stuff is necessary for compiling and running xglyph on VMS. Submitted by John Hasstedt (John.Hasstedt@sunysb.edu), who did the VMS-port of t1lib. */ #if defined(__VMS) && __CRTL_VER < 70000000 # define putenv(p) \ printf("You must define T1LIB_CONFIG before running this program\n"); \ exit; # define gettimeofday(p1,p2) #endif /* Note: We include t1lib.h and t1libx.h from lib/t1lib. That way the objectfile does only need to be rebuild when the header itself changes and not each time the library has been recompiled */ #include "../lib/t1lib/t1lib.h" #include "../lib/t1lib/t1libx.h" #ifndef PI #define PI 3.1415927 #endif /* utility functions */ BBox ComputeRotBBox( BBox, float); long time_diff(struct timeval *, struct timeval *); /* fallback-function */ void exitprog( Widget, XtPointer, XtPointer); void togglekerning( Widget, XtPointer, XtPointer); void toggleligatur( Widget, XtPointer, XtPointer); void toggler2l( Widget, XtPointer, XtPointer); void toggleunderline( Widget, XtPointer, XtPointer); void toggleoverline( Widget, XtPointer, XtPointer); void toggleoverstrike( Widget, XtPointer, XtPointer); void showchar( Widget , XtPointer , XtPointer ); void showstring( Widget , XtPointer , XtPointer ); void aashowchar( Widget , XtPointer , XtPointer ); void aashowstring( Widget , XtPointer , XtPointer ); void showcharX( Widget , XtPointer , XtPointer ); void showstringX( Widget , XtPointer , XtPointer ); void aashowcharX( Widget , XtPointer , XtPointer ); void aashowstringX( Widget , XtPointer , XtPointer ); void showabout( Widget , XtPointer , XtPointer ); void toggleopacity( Widget, XtPointer, XtPointer); void setcolor( Widget, XtPointer, XtPointer); void fonttable( Widget, XtPointer, XtPointer); void toggleaalevel( Widget, XtPointer, XtPointer); int ComputeAAColorsX( unsigned long fg, unsigned long bg, int nolevels); void printusage( int max); int CheckTransform( void); #define DOUBLEMARGIN 10 #define SIMPLEMARGIN 5 #define XOUTPUT_HALFVSIZE 200 #define XOUTPUT_HALFHSIZE 300 #define XGLYPH_PAD 16 #define T1LIBENCFILE "IsoLatin1.enc" #define MAXENCODINGS 10 #define TESTFONTFILE "eufm10.pfb" #define SHOWGRID #define CROSS_SIZE 6 #define PAD(bits, pad) (((bits)+(pad)-1)&-(pad)) #define DIALOGWIDTH 170 #define DIALOGHEIGHT 20 #define ACTIONBUTTONHEIGHT 20 #define APPLICATIONHEIGHT 690 #define EDITABLE_COLOR "red" #define MESSAGEBOXHEIGHT 180 #define AAMAXPLANES 17 #define GRAY0 WhitePixel(display, screen_number) #define GRAY1 gray1.pixel #define GRAY2 gray2.pixel #define GRAY3 gray3.pixel #define GRAY4 BlackPixel(display, screen_number) #define min(a,b) (a < b ? a : b) #define max(a,b) (a > b ? a : b) #define DEFAULT_SIZE "100.0" #define DEFAULT_CHAR "65" /* Global variables for rasterizer parameters */ float Size=400.0, Slant=0.0, Extent=1.0, Angle=0.0; int Modflag=0; int FontID=0, Caching=1, DeviceResolution=72; int StrokeWidth; int nofonts; long Space=0; int Opacity=0; int aalevel; char TestString[1024]="Test"; int TestChar=70; char EncodingFile[128]=""; char LastEncodingFile[128]=""; struct { char *encfilename; char **encoding; } encstruct[MAXENCODINGS]; int *last_resolution; float *lastExtent; float *lastSlant; int LigDetect=0; unsigned long fg, bg, outbg; Pixmap tmp_pixmap=0; Pixmap white_pixmap=0; Pixmap perf_pixmap; Pixmap pixmap; XImage *ximage; XColor edit_color, gray0, gray1, gray2, gray3, gray4; XColor white, black, gray, red, green, blue, pink4, yellow, gridcolor1, gridcolor2,wozu; XColor aacolors[AAMAXPLANES]; unsigned long aapixels[AAMAXPLANES]; XGCValues xgcvalues; unsigned short dummy; char input; int overallwidth; char commandline[256]; GLYPH *glyph; GLYPH *glyph1, *glyph2; char **Encoding=NULL; unsigned int height, width; char statusstring[1024]; T1_TMATRIX matrix; T1_TMATRIX *matrixP; static char msg_buf[256]; /* How t1lib pads lines: */ int t1_pad=0; /* When to swap bytes in aa-pixels? */ int xglyph_byte_order; /* The following is for time measurements: */ struct timeval time_start, time_stop; struct timeval *time_ptr_start, *time_ptr_stop; void *void_ptr; /* Global X(t)-stuff */ Display *display; Screen *screen; int screennumber; int depth; Widget TopLevel; Widget OutputWindow; Widget Output; Widget OutputWindow2; Widget Output2; Widget dialogfontid; Widget dialogsize; Widget dialogslant; Widget dialogextent; Widget dialogangle; Widget dialogteststring; Widget dialogtestcharacter; Widget dialogdevres; Widget dialogstroke; Widget dialogencfile; Widget dialogspace; Widget dialogtmatrix; Widget labelstatus; Widget fgcolorbutton; Widget bgcolorbutton; /* color setting widgets */ Widget fgwhitebutton; Widget fgblackbutton; Widget fggraybutton; Widget fgredbutton; Widget fggreenbutton; Widget fgbluebutton; Widget bgwhitebutton; Widget bgblackbutton; Widget bggraybutton; Widget bgredbutton; Widget bggreenbutton; Widget bgbluebutton; Widget fglabel; Widget bglabel; Widget colorbox; Widget fgstatus; Widget bgstatus; Widget optionsbox; /* Commandline handling */ char *xglyphoptions[]={"--help", /* 0 */ "--Help", /* 1 */ "--noGrid", /* 2 */ "--setPad", /* 3 */ "--logError", /* 4 */ "--logWarning", /* 5 */ "--logStatistic", /* 6 */ "--logDebug", /* 7 */ "--ignoreForceBold", /* 8 */ "--ignoreFamilyAlignment", /* 9 */ "--ignoreHinting", /* 10 */ "--ignoreAFM", /* 11 */ "--debugLine", /* 12 */ "--debugRegion", /* 13 */ "--debugPath", /* 14 */ "--debugFont", /* 15 */ "--debugHint", /* 16 */ "--checkPerformance", /* 17 */ "--checkCopyFont", /* 18 */ "--checkConcatGlyphs", /* 19 */ "--checkConcatOutlines", /* 20 */ "--checkBadCharHandling", /* 21 */ "--checkDefaultEncoding", /* 22 */ "--checkSmartAntialiasing", /* 23 */ "--checkAACaching", /* 24 */ "--checkSetRect", /* 25 */ "--cacheStrokedGlyphs", /* 26 */ NULL}; int extraflags=0; /* #define SHOW_MANIPULATE_PATHS */ #ifdef SHOW_MANIPULATE_PATHS void mymanipulate( long *x, long *y, int type) { double corr; double dx, dy; dx=(double)*x; dy=(double)*y; /* we have to scale down because we deal with fractional pels */ /* corr=0.000000000000004*dx*dx; dy *=1.0+corr; */ /* #define PERIOD 500.0 corr=65536.0*0.5*sin(2*PI/PERIOD/65536.0*dx); dy +=corr*30.0; */ *y=(long)dy; } #endif int main( int argc, char **argv) { XtAppContext TopLevelApp; Arg args[10]; int i, j, numopts=0; Widget kerningbutton; Widget ligaturbutton; Widget r2lbutton; Widget showcharbutton; Widget showstringbutton; Widget aashowcharbutton; Widget aashowstringbutton; Widget showcharbuttonX; Widget showstringbuttonX; Widget aashowcharbuttonX; Widget aashowstringbuttonX; Widget stringlabel; Widget aboutbutton; Widget opacitybutton; Widget underlinebutton; Widget overstrikebutton; Widget overlinebutton; Widget transbox; Widget fonttablebutton; Widget aalevelbutton; Widget exitbutton; Widget box; int rasterflags=0, initflags=0, optfound; int loglevel=0; i=0; j=0; while (xglyphoptions[i++]!=NULL) numopts++; for ( i=1; i no option */ break; } /* Assign address of time parameter */ time_ptr_start=&time_start; time_ptr_stop=&time_stop; /* Check for environment entry. If not set, set it to current directory so that configuration file is found there */ if (getenv("T1LIB_CONFIG")==NULL){ putenv( "T1LIB_CONFIG=./t1lib.config"); } /* Set log-level: */ T1_SetLogLevel( loglevel & (~(0x01<<8))); /* Get padding value if not set from commandline. For 32 bit architectures like Intel, 16 might be the best padding default value: */ if (t1_pad==0) t1_pad=16; if (T1_SetBitmapPad( t1_pad)!=0){ t1_pad=T1_GetBitmapPad(); } /* Initialize t1-library. If xglyph is called with arguments that are no options, we assume that the arguments are font files and ignore the fontdata base file. At this point the value of "i" is the number of commandline arg that is supposed to contain a fontfile name (or it is argc, if no files where specified). Note further that "loglevel" contains (1) info whether to create a log file in the first bit of the higher byte of the lower word and (2) info which loglevel to set. (3) It further may contain more initialization flags. */ if ((extraflags & CHECK_AA_CACHING)){ loglevel |= (T1_AA_CACHING<<8); } if (i==argc){ if (T1_InitLib( (loglevel>>8) | initflags )==NULL){ fprintf(stderr,"Initialization of t1lib failed (T1_errno=%d)!\n", T1_errno); return(-1); } } else{ /* There are still arguments which we interprete as fontfile names */ if (T1_InitLib( (loglevel>>8) | initflags | IGNORE_FONTDATABASE )==NULL){ fprintf(stderr,"Initialization of t1lib failed (T1_errno=%d)!\n", T1_errno); return(-1); } /* We start adding fonts as the i-th commandline arguments */ for ( j=i; j" ); i++; XtSetValues(r2lbutton,args,i); XtAddCallback( r2lbutton, XtNcallback, (XtCallbackProc) toggler2l, (XtPointer) 0 ); /* The toggle widget for underlining (un-)setting */ underlinebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 55 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, "Underline" ); i++; XtSetValues(underlinebutton,args,i); XtAddCallback( underlinebutton, XtNcallback, (XtCallbackProc) toggleunderline, (XtPointer) 0 ); /* The toggle widget for underlining (un-)setting */ overlinebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 55 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, "Overline" ); i++; XtSetValues(overlinebutton,args,i); XtAddCallback( overlinebutton, XtNcallback, (XtCallbackProc) toggleoverline, (XtPointer) 0 ); /* The toggle widget for underlining (un-)setting */ overstrikebutton = XtCreateManagedWidget("toggle", toggleWidgetClass, optionsbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 55 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, "Overstrike" ); i++; XtSetValues(overstrikebutton,args,i); XtAddCallback( overstrikebutton, XtNcallback, (XtCallbackProc) toggleoverstrike, (XtPointer) 0 ); /* The button to raster and display the current character using the current settings */ showcharbutton = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 60 ); i++; XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++; XtSetArg( args[i], XtNlabel, "Char"); i++; XtSetValues(showcharbutton,args,i); XtAddCallback( showcharbutton, XtNcallback, (XtCallbackProc) showchar, (XtPointer) 0 ); /* The button to raster and display the current string using the current settings */ showstringbutton = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 60 ); i++; XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++; XtSetArg( args[i], XtNlabel, "String"); i++; XtSetValues(showstringbutton,args,i); XtAddCallback( showstringbutton, XtNcallback, (XtCallbackProc) showstring, (XtPointer) 0 ); /* The button to raster and display the current character using the current settings and antialiasing */ aashowcharbutton = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 120 ); i++; XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++; XtSetArg( args[i], XtNlabel, "AAChar"); i++; XtSetValues(aashowcharbutton,args,i); XtAddCallback( aashowcharbutton, XtNcallback, (XtCallbackProc) aashowchar, (XtPointer) 0 ); /* The button to raster and display the current string using the current settings and antialiasing */ aashowstringbutton = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 120 ); i++; XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++; XtSetArg( args[i], XtNlabel, "AAString"); i++; XtSetValues(aashowstringbutton,args,i); XtAddCallback( aashowstringbutton, XtNcallback, (XtCallbackProc) aashowstring, (XtPointer) 0 ); /* The button to raster and display the current character using the current settings */ showcharbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 60 ); i++; XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++; XtSetArg( args[i], XtNlabel, "CharX"); i++; XtSetValues(showcharbuttonX,args,i); XtAddCallback( showcharbuttonX, XtNcallback, (XtCallbackProc) showcharX, (XtPointer) 0 ); /* The button to raster and display the current string using the current settings */ showstringbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 60 ); i++; XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++; XtSetArg( args[i], XtNlabel, "StringX"); i++; XtSetValues(showstringbuttonX,args,i); XtAddCallback( showstringbuttonX, XtNcallback, (XtCallbackProc) showstringX, (XtPointer) 0 ); /* The button to raster and display the current character using the current settings and antialiasing */ aashowcharbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 120 ); i++; XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++; XtSetArg( args[i], XtNlabel, "AACharX"); i++; XtSetValues(aashowcharbuttonX,args,i); XtAddCallback( aashowcharbuttonX, XtNcallback, (XtCallbackProc) aashowcharX, (XtPointer) 0 ); /* The button to raster and display the current string using the current settings and antialiasing */ aashowstringbuttonX = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 120 ); i++; XtSetArg( args[i], XtNheight, ACTIONBUTTONHEIGHT ); i++; XtSetArg( args[i], XtNlabel, "AAStringX"); i++; XtSetValues(aashowstringbuttonX,args,i); XtAddCallback( aashowstringbuttonX, XtNcallback, (XtCallbackProc) aashowstringX, (XtPointer) 0 ); /* The box for color trasp/op and fonttable button */ transbox=XtCreateManagedWidget("box", boxWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNheight,20); i++; XtSetArg(args[i], XtNwidth,90); i++; XtSetValues(transbox,args,i); /* The button to display an AA font table */ fonttablebutton = XtCreateManagedWidget("Com", commandWidgetClass, transbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 80 ); i++; XtSetArg( args[i], XtNheight, 15 ); i++; XtSetArg( args[i], XtNlabel, "Font Table"); i++; XtSetValues(fonttablebutton,args,i); XtAddCallback( fonttablebutton, XtNcallback, (XtCallbackProc) fonttable, (XtPointer) 0 ); /* The toggle widget for opacity/transparency */ opacitybutton = XtCreateManagedWidget("toggle", toggleWidgetClass, transbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 80 ); i++; XtSetArg( args[i], XtNheight, 15 ); i++; XtSetArg( args[i], XtNlabel, "Transparent" ); i++; XtSetValues(opacitybutton,args,i); XtAddCallback( opacitybutton, XtNcallback, (XtCallbackProc) toggleopacity, (XtPointer) 0 ); outbg=pink4.pixel; /* the initial bgcolor for transparent mode */ /* The toggle widget for opacity/transparency */ aalevelbutton = XtCreateManagedWidget("toggle", toggleWidgetClass, transbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 80 ); i++; XtSetArg( args[i], XtNheight, 15 ); i++; XtSetArg( args[i], XtNlabel, "AA-Low" ); i++; XtSetValues(aalevelbutton,args,i); XtAddCallback( aalevelbutton, XtNcallback, (XtCallbackProc) toggleaalevel, (XtPointer) 0 ); aalevel=T1_AA_LOW; /* the initial bgcolor for transparent mode */ /* The box for color selecting buttons for the X11-rastering functions */ colorbox=XtCreateManagedWidget("box", boxWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNheight,20); i++; XtSetArg(args[i], XtNwidth,280); i++; XtSetValues(colorbox,args,i); /* FG-label */ fgstatus = XtCreateManagedWidget("label", labelWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, fg); i++; XtSetValues(fgstatus,args,i); fglabel = XtCreateManagedWidget("label", labelWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 80 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, "Foreground"); i++; XtSetValues(fglabel,args,i); fgwhitebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, white.pixel); i++; XtSetValues(fgwhitebutton,args,i); XtAddCallback( fgwhitebutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); fgblackbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, black.pixel); i++; XtSetValues(fgblackbutton,args,i); XtAddCallback( fgblackbutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); fggraybutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, gray.pixel); i++; XtSetValues(fggraybutton,args,i); XtAddCallback( fggraybutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); fgredbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, red.pixel); i++; XtSetValues(fgredbutton,args,i); XtAddCallback( fgredbutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); fggreenbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, green.pixel); i++; XtSetValues(fggreenbutton,args,i); XtAddCallback( fggreenbutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); fgbluebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, blue.pixel); i++; XtSetValues(fgbluebutton,args,i); XtAddCallback( fgbluebutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); /* BG-label */ bgstatus = XtCreateManagedWidget("label", labelWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, bg); i++; XtSetValues(bgstatus,args,i); bglabel = XtCreateManagedWidget("label", labelWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 80 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, "Background"); i++; XtSetValues(bglabel,args,i); bgwhitebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, white.pixel); i++; XtSetValues(bgwhitebutton,args,i); XtAddCallback( bgwhitebutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); bgblackbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, black.pixel); i++; XtSetValues(bgblackbutton,args,i); XtAddCallback( bgblackbutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); bggraybutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, gray.pixel); i++; XtSetValues(bggraybutton,args,i); XtAddCallback( bggraybutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); bgredbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, red.pixel); i++; XtSetValues(bgredbutton,args,i); XtAddCallback( bgredbutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); bggreenbutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, green.pixel); i++; XtSetValues(bggreenbutton,args,i); XtAddCallback( bggreenbutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); bgbluebutton = XtCreateManagedWidget("Com", commandWidgetClass, colorbox, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 20 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, ""); i++; XtSetArg( args[i], XtNbackground, blue.pixel); i++; XtSetValues(bgbluebutton,args,i); XtAddCallback( bgbluebutton, XtNcallback, (XtCallbackProc) setcolor, (XtPointer) 0 ); /* Label for the next box */ stringlabel=XtCreateManagedWidget("Label", labelWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNlabel, "Test-String:"); i++; XtSetValues(stringlabel,args,i); /* An input-box for the test-string */ dialogteststring=XtCreateManagedWidget("dialog1", asciiTextWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight,30); i++; XtSetArg(args[i], XtNwrap, XawtextWrapLine); i++; XtSetArg(args[i], XtNeditType, XawtextEdit ); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(dialogteststring,args,i); /* Label for the next box */ labelstatus=XtCreateManagedWidget("Label", labelWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, "No Messages!"); i++; XtSetValues(labelstatus,args,i); /* The button to exit the program */ exitbutton = XtCreateManagedWidget("Com2", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 100 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNx, 0 ); i++; XtSetArg( args[i], XtNy, 0 ); i++; XtSetArg( args[i], XtNlabel, " Exit Program"); i++; XtSetValues(exitbutton,args,i); XtAddCallback( exitbutton, XtNcallback, (XtCallbackProc) exitprog, (XtPointer) 0 ); /* The About widget for the about message */ aboutbutton = XtCreateManagedWidget("Com", commandWidgetClass, box, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 55 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, "About" ); i++; XtSetValues(aboutbutton,args,i); XtAddCallback( aboutbutton, XtNcallback, (XtCallbackProc) showabout, (XtPointer) 0 ); XtRealizeWidget(TopLevel); XtPopup(Output,XtGrabNone); if( extraflags & CHECK_PERFORMANCE){ XtPopup(Output2,XtGrabNone); } /* Set parameters for X11-support */ T1_SetX11Params( display, DefaultVisual(display, screennumber), DefaultDepth( display, screennumber), DefaultColormap(display, screennumber)); /* Create a dummy-pixmap because we need one to destroy before the next is created! */ pixmap = XCreatePixmap(display, XtWindow(OutputWindow), 200, 200, DefaultDepth(display,screennumber) ); XtAppMainLoop(TopLevelApp); return(0); } /* Compute the BBox of a rotated box: */ BBox ComputeRotBBox( BBox inbox, float angle) { int i; BBox resultbox={ 0, 0, 0, 0}; struct point { double x; double y; } p[4], P[4]; double sinalpha, cosalpha; sinalpha=sin((double)angle*PI/180); cosalpha=cos((double)angle*PI/180); /* initialize points */ p[0].x=(double) inbox.llx; p[0].y=(double) inbox.lly; p[1].x=(double) inbox.urx; p[1].y=(double) inbox.lly; p[2].x=(double) inbox.urx; p[2].y=(double) inbox.ury; p[3].x=(double) inbox.llx; p[3].y=(double) inbox.ury; /* fprintf( stderr, "InBox: (%f,%f), (%f,%f), (%f,%f), (%f,%f)\n", p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y); */ /* Compute tranformed points */ P[0].x=p[0].x*cosalpha-p[0].y*sinalpha; P[0].y=p[0].x*sinalpha+p[0].y*cosalpha; P[1].x=p[1].x*cosalpha-p[1].y*sinalpha; P[1].y=p[1].x*sinalpha+p[1].y*cosalpha; P[2].x=p[2].x*cosalpha-p[2].y*sinalpha; P[2].y=p[2].x*sinalpha+p[2].y*cosalpha; P[3].x=p[3].x*cosalpha-p[3].y*sinalpha; P[3].y=p[3].x*sinalpha+p[3].y*cosalpha; /* fprintf( stderr, "RotPoints: (%f,%f), (%f,%f), (%f,%f), (%f,%f)\n", P[0].x, P[0].y, P[1].x, P[1].y, P[2].x, P[2].y, P[3].x, P[3].y); */ /* Get BBox: */ for (i=0; i<4; i++){ if (P[i].x < (float) resultbox.llx) resultbox.llx=(int) floor(P[i].x +0.5); if (P[i].x > (float) resultbox.urx) resultbox.urx=(int) floor(P[i].x +0.5); if (P[i].y < (float) resultbox.lly) resultbox.lly=(int) floor(P[i].y +0.5); if (P[i].y > (float) resultbox.ury) resultbox.ury=(int) floor(P[i].y +0.5); } return(resultbox); } void exitprog(Widget exitbutton, XtPointer client_data , XtPointer call_data) { int i; for (i=0; i< T1_GetNoFonts(); i++){ /* printf("Enc-Scheme=%s\n", T1_GetEncodingScheme( i));*/ ; } T1_CloseLib(); exit(0); } void togglekerning( Widget kerningbutton, XtPointer client_data, XtPointer call_data) { int i; char state=0; Arg args[10]; /* Get state of toggle Button: */ i=0; XtSetArg(args[i], XtNstate, &state); i++; XtGetValues(kerningbutton,args,1); if ((state)) Modflag |= T1_KERNING; else Modflag &= ~T1_KERNING; } void toggleligatur( Widget ligaturbutton, XtPointer client_data, XtPointer call_data) { int i; char state=0; Arg args[10]; /* Get state of toggle Button: */ i=0; XtSetArg(args[i], XtNstate, &state); i++; XtGetValues(ligaturbutton,args,1); LigDetect=state; } void toggler2l( Widget r2lbutton, XtPointer client_data, XtPointer call_data) { int i; char state=0; Arg args[10]; /* Get state of toggle Button: */ i=0; XtSetArg(args[i], XtNstate, &state); i++; XtGetValues(r2lbutton,args,1); if ((state)) Modflag |= T1_RIGHT_TO_LEFT; else Modflag &= ~T1_RIGHT_TO_LEFT; /* Invert state */ i=0; if (state){ XtSetArg( args[i], XtNwidth, 55 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, "<--|" ); i++; } else{ XtSetArg( args[i], XtNwidth, 55 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; XtSetArg( args[i], XtNlabel, "|-->" ); i++; } XtSetValues(r2lbutton,args,i); } void toggleunderline( Widget underlinebutton, XtPointer client_data, XtPointer call_data) { int i; char state=0; Arg args[10]; /* Get state of toggle Button: */ i=0; XtSetArg(args[i], XtNstate, &state); i++; XtGetValues(underlinebutton,args,1); if ((state)) Modflag |= T1_UNDERLINE; else Modflag &= ~T1_UNDERLINE; } void toggleoverline( Widget overlinebutton, XtPointer client_data, XtPointer call_data) { int i; char state=0; Arg args[10]; /* Get state of toggle Button: */ i=0; XtSetArg(args[i], XtNstate, &state); i++; XtGetValues( overlinebutton,args,1); if ((state)) Modflag |= T1_OVERLINE; else Modflag &= ~T1_OVERLINE; } void toggleoverstrike( Widget overstrikebutton, XtPointer client_data, XtPointer call_data) { int i; char state=0; Arg args[10]; /* Get state of toggle Button: */ i=0; XtSetArg(args[i], XtNstate, &state); i++; XtGetValues( overstrikebutton,args,1); if ((state)) Modflag |= T1_OVERSTRIKE; else Modflag &= ~T1_OVERSTRIKE; } void toggleopacity( Widget opacitybutton, XtPointer client_data, XtPointer call_data) { int i; char state=0; Arg args[10]; /* Get state of toggle Button: */ i=0; XtSetArg(args[i], XtNstate, &state); i++; XtGetValues(opacitybutton,args,1); i=0; XtSetArg( args[i], XtNstate, state); i++; XtSetArg( args[i], XtNwidth, 80 ); i++; XtSetArg( args[i], XtNheight, 20 ); i++; Opacity=state; /* Invert state */ if (state){ XtSetArg( args[i], XtNlabel, "Opaque" ); i++; XtSetValues(opacitybutton,args,i); outbg=bg; } else{ XtSetArg( args[i], XtNlabel, "Transparent" ); i++; XtSetValues(opacitybutton,args,i); outbg=pink4.pixel; } } /* Toggle the antialiasing level */ void toggleaalevel( Widget aalevelbutton, XtPointer client_data, XtPointer call_data) { int i; char state=0; Arg args[10]; /* Get state of toggle Button: */ i=0; XtSetArg(args[i], XtNstate, &state); i++; XtGetValues( aalevelbutton,args,1); i=0; XtSetArg( args[i], XtNstate, state); i++; XtSetArg( args[i], XtNwidth, 80 ); i++; XtSetArg( args[i], XtNheight, 15 ); i++; /* Invert state */ if (state){ XtSetArg( args[i], XtNlabel, "AA-High" ); i++; XtSetValues(aalevelbutton,args,i); aalevel=T1_AA_HIGH; } else{ XtSetArg( args[i], XtNlabel, "AA-Low" ); i++; XtSetValues(aalevelbutton,args,i); aalevel=T1_AA_LOW; } } /* Set a new fore/background color */ void setcolor( Widget widget, XtPointer client_data, XtPointer call_data) { int i; Arg args[10]; /* foreground colors */ if (widget==fgwhitebutton){ fg=white.pixel; i=0; XtSetArg( args[i], XtNbackground, fg ); i++; XtSetValues(fgstatus,args,i); return; } if (widget==fgblackbutton){ fg=black.pixel; i=0; XtSetArg( args[i], XtNbackground, fg ); i++; XtSetValues(fgstatus,args,i); return; } if (widget==fggraybutton){ fg=gray.pixel; i=0; XtSetArg( args[i], XtNbackground, fg ); i++; XtSetValues(fgstatus,args,i); return; } if (widget==fgredbutton){ fg=red.pixel; i=0; XtSetArg( args[i], XtNbackground, fg ); i++; XtSetValues(fgstatus,args,i); return; } if (widget==fggreenbutton){ fg=green.pixel; i=0; XtSetArg( args[i], XtNbackground, fg ); i++; XtSetValues(fgstatus,args,i); return; } if (widget==fgbluebutton){ fg=blue.pixel; i=0; XtSetArg( args[i], XtNbackground, fg ); i++; XtSetValues(fgstatus,args,i); return; } /* background colors */ if (widget==bgwhitebutton){ bg=white.pixel; if (Opacity) outbg=bg; i=0; XtSetArg( args[i], XtNbackground, bg ); i++; XtSetValues(bgstatus,args,i); return; } if (widget==bgblackbutton){ bg=black.pixel; if (Opacity) outbg=bg; i=0; XtSetArg( args[i], XtNbackground, bg ); i++; XtSetValues(bgstatus,args,i); return; } if (widget==bggraybutton){ bg=gray.pixel; if (Opacity) outbg=bg; i=0; XtSetArg( args[i], XtNbackground, bg ); i++; XtSetValues(bgstatus,args,i); return; } if (widget==bgredbutton){ bg=red.pixel; if (Opacity) outbg=bg; i=0; XtSetArg( args[i], XtNbackground, bg ); i++; XtSetValues(bgstatus,args,i); return; } if (widget==bggreenbutton){ bg=green.pixel; if (Opacity) outbg=bg; i=0; XtSetArg( args[i], XtNbackground, bg ); i++; XtSetValues(bgstatus,args,i); return; } if (widget==bgbluebutton){ bg=blue.pixel; if (Opacity) outbg=bg; i=0; XtSetArg( args[i], XtNbackground, bg ); i++; XtSetValues(bgstatus,args,i); return; } /* we shouldn't get here */ return; } void showchar( Widget showcharbutton, XtPointer client_data, XtPointer call_data) { int i, j; Arg args[10]; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } if (CheckTransform()==0 && Angle==0.0){ matrixP=NULL; } else{ matrixP=T1_RotateMatrix( &matrix, Angle); } if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } for (j=0; jmetrics.ascent - glyph->metrics.descent; overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing; width=overallwidth; /* Prepare status message: */ 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", time_diff(time_ptr_start,time_ptr_stop), glyph->metrics.leftSideBearing, glyph->metrics.rightSideBearing, glyph->metrics.ascent, glyph->metrics.descent, glyph->metrics.advanceX, glyph->metrics.advanceY, glyph->bpp, PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent), T1_GetFontName(FontID), T1_GetCharName(FontID,(char)TestChar), T1_errno); if (glyph->bits !=NULL) { ximage=XCreateImage( display, DefaultVisual(display, screennumber), 1, /* depths for bitmap is 1 */ XYBitmap, /* XYBitmap or XYPixmap */ 0, /* No offset */ glyph->bits, width, height, t1_pad, /* lines padded to bytes */ 0 /*PAD(width,8)/8*/ /* number of bytes per line */ ); /* Force bit and byte order */ ximage->bitmap_bit_order=0; ximage->byte_order=0; XFreePixmap(display,pixmap); pixmap = XCreatePixmap(display, XtWindow(TopLevel), width, height, DefaultDepth(display,screennumber) ); XPutImage(display, pixmap, DefaultGC( display, screennumber), ximage, 0, 0, 0, 0, width, height ); XDestroyImage(ximage); } i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++; if (glyph->bits != NULL) { XtSetArg( args[i], XtNbitmap, pixmap); i++; } else { XtSetArg( args[i], XtNbitmap, 0); i++; } XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++; XtSetArg( args[i], XtNforeground, BlackPixel(display,screennumber)); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++; if (glyph->bits != NULL) { XtSetArg( args[i], XtNbitmap, pixmap); i++; } else { XtSetArg( args[i], XtNbitmap, 0); i++; } XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetValues(Output ,args,i); glyph->bits=NULL; /* Since XDestroyImage() free's this also! */ } void showstring( Widget showstringbutton, XtPointer client_data, XtPointer call_data) { int i,j,k,l,m,none_found; Arg args[10]; char *theString='\0'; char *ligtheString='\0'; char *succs, *ligs; char buf_char; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } if (CheckTransform()==0 && Angle==0.0){ matrixP=NULL; } else{ matrixP=T1_RotateMatrix( &matrix, Angle); } if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } for (j=0; j0){ buf_char=theString[j]; while (k>0){ none_found=1; for (l=0;lcompchar > -1 ? T1_GetCharName( FontID, ccd->compchar) : "not_enc", ccd->compchar, ccd->numPieces); printf( " basechar %s (%d)\n", ccd->pieces[0].piece > -1 ? T1_GetCharName( FontID, ccd->pieces[0].piece) : "not_enc", ccd->pieces[0].piece); printf( " accent %s (%d)\n", ccd->pieces[1].piece > -1 ? T1_GetCharName( FontID, ccd->pieces[1].piece) : "not_enc", ccd->pieces[1].piece); } T1_FreeCompCharData( ccd); } } */ XSetForeground( display, DefaultGC( display, screennumber), black.pixel); XSetBackground( display, DefaultGC( display, screennumber), white.pixel); /* Reset T1_errno: */ T1_errno=0; gettimeofday(time_ptr_start, void_ptr); if( extraflags & CHECK_CONCATGLYPHS){ glyph2=T1_SetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP); glyph1=T1_CopyGlyph( glyph2); glyph2=T1_SetString(FontID+1,(char *)ligtheString,0,Space,Modflag,Size,matrixP); glyph=T1_ConcatGlyphs( glyph1, glyph2, 0, 0, Modflag); } else if( extraflags & CHECK_CONCATOUTLINES){ { T1_OUTLINE *path=NULL; path=T1_GetStringOutline(FontID,(char *)ligtheString, 0,Space,Modflag,Size,matrixP); if (path==NULL){ return; } #ifdef SHOW_MANIPULATE_PATHS T1_AbsolutePath( path); T1_ManipulatePath( path, &mymanipulate); T1_RelativePath( path); #else T1_ConcatOutlines( path, T1_GetStringOutline(FontID+1,(char *)ligtheString, 0,Space,Modflag,Size,matrixP)); #endif glyph=T1_FillOutline( path, Modflag); } } else{ if( extraflags & CHECK_FOR_BAD_CHARS){ sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar); ligtheString[strlen(ligtheString)/2]=(unsigned char) TestChar; } glyph=T1_SetString(FontID,(char *)ligtheString,0,Space,Modflag,Size,matrixP); } gettimeofday(time_ptr_stop, void_ptr); free(ligtheString); if ( glyph ==NULL ) { sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno)); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } height=glyph->metrics.ascent - glyph->metrics.descent; overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing; width=overallwidth; /* Prepare status message: */ 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", time_diff(time_ptr_start,time_ptr_stop), glyph->metrics.leftSideBearing, glyph->metrics.rightSideBearing, glyph->metrics.ascent, glyph->metrics.descent, glyph->metrics.advanceX, glyph->metrics.advanceY, glyph->bpp, PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent), T1_GetFontName(FontID), T1_errno); if (glyph->bits != NULL) { ximage=XCreateImage( display, DefaultVisual(display, screennumber), 1, /* depths for bitmap is 1 */ XYBitmap, /* XYBitmap or XYPixmap */ 0, /* No offset */ glyph->bits, width, height, t1_pad, /* lines padded to bytes */ 0 /*PAD(width,8)/8*/ /* number of bytes per line */ ); /* Force bit and byte order */ ximage->bitmap_bit_order=LSBFirst; ximage->byte_order=LSBFirst; XFreePixmap(display,pixmap); pixmap = XCreatePixmap(display, XtWindow(TopLevel), width, height, DefaultDepth(display,screennumber) ); XPutImage(display, pixmap, DefaultGC( display, screennumber), ximage, 0, 0, 0, 0, width, height ); XDestroyImage(ximage); } i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++; if (glyph->bits != NULL) { XtSetArg( args[i], XtNbitmap, pixmap); i++; } else { XtSetArg( args[i], XtNbitmap, 0); i++; } XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++; if (glyph->bits != NULL) { XtSetArg( args[i], XtNbitmap, pixmap); i++; } else { XtSetArg( args[i], XtNbitmap, 0); i++; } XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++; XtSetValues(Output ,args,i); glyph->bits=NULL; /* Since XDestroyImage() free's this also! */ } void aashowchar( Widget showcharbutton, XtPointer client_data, XtPointer call_data) { int i, j; Arg args[10]; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } if (CheckTransform()==0 && Angle==0.0){ matrixP=NULL; } else{ matrixP=T1_RotateMatrix( &matrix, Angle); } if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } for (j=0; jmetrics.ascent - glyph->metrics.descent; overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing; width=overallwidth; /* Prepare status message: */ 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", time_diff(time_ptr_start,time_ptr_stop), glyph->metrics.leftSideBearing, glyph->metrics.rightSideBearing, glyph->metrics.ascent, glyph->metrics.descent, glyph->metrics.advanceX, glyph->metrics.advanceY, glyph->bpp, PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent), T1_GetFontName(FontID), T1_GetCharName(FontID,(char)TestChar), T1_errno); /* printf("glyph->bits=%u\n", glyph->bits); printf("glyph->metrics.leftSideBearing=%u\n", glyph->metrics.leftSideBearing); printf("glyph->metrics.rightSideBearing=%u\n", glyph->metrics.rightSideBearing); printf("glyph->metrics.advanceX=%u\n", glyph->metrics.advanceX); printf("glyph->metrics.ascent=%u\n", glyph->metrics.ascent); printf("glyph->metrics.descent=%u\n", glyph->metrics.descent); printf("glyph->pFontCacheInfo=%u\n", glyph->pFontCacheInfo); */ if (glyph->bits != NULL) { ximage=XCreateImage( display, DefaultVisual(display, screennumber), DefaultDepth(display,screennumber), /* depths for bitmap is 1 */ ZPixmap, /* XYBitmap or XYPixmap */ 0, /* No offset */ glyph->bits, width, height, t1_pad, /* lines padded to bytes */ 0 /*PAD(width,8)/8*/ /* number of bytes per line */ ); ximage->byte_order=xglyph_byte_order; XFreePixmap(display,pixmap); pixmap = XCreatePixmap(display, XtWindow(TopLevel), width, height, DefaultDepth(display,screennumber) /* 8 */ /* depth */ ); XPutImage(display, pixmap, DefaultGC( display, screennumber), ximage, 0, 0, 0, 0, width, height ); XDestroyImage(ximage); } i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++; if (glyph->bits != NULL) { XtSetArg( args[i], XtNbitmap, pixmap); i++; } else { XtSetArg( args[i], XtNbitmap, 0); i++; } XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, WhitePixel(display,screennumber)); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++; if (glyph->bits != NULL) { XtSetArg( args[i], XtNbitmap, pixmap); i++; } else { XtSetArg( args[i], XtNbitmap, 0); i++; } XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetValues(Output ,args,i); glyph->bits=NULL; /* Since XDestroyImage() free's this also! */ } void aashowstring( Widget showstringbutton, XtPointer client_data, XtPointer call_data) { int i,j,k,l,m,none_found; Arg args[10]; char *theString='\0'; char *ligtheString='\0'; char *succs, *ligs; char buf_char; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } if (CheckTransform()==0 && Angle==0.0){ matrixP=NULL; } else{ matrixP=T1_RotateMatrix( &matrix, Angle); } if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } for (j=0; j0){ buf_char=theString[j]; while (k>0){ none_found=1; for (l=0;lmetrics.ascent - glyph->metrics.descent; overallwidth=glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing; width=overallwidth; /* Prepare status message: */ 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", time_diff(time_ptr_start,time_ptr_stop), glyph->metrics.leftSideBearing, glyph->metrics.rightSideBearing, glyph->metrics.ascent, glyph->metrics.descent, glyph->metrics.advanceX, glyph->metrics.advanceY, glyph->bpp, PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent), T1_GetFontName(FontID), T1_errno); /* printf("glyph->bits=%u\n", glyph->bits); printf("glyph->metrics.leftSideBearing=%u\n", glyph->metrics.leftSideBearing); printf("glyph->metrics.rightSideBearing=%u\n", glyph->metrics.rightSideBearing); printf("glyph->metrics.advanceX=%u\n", glyph->metrics.advanceX); printf("glyph->metrics.ascent=%u\n", glyph->metrics.ascent); printf("glyph->metrics.descent=%u\n", glyph->metrics.descent); printf("glyph->pFontCacheInfo=%u\n", glyph->pFontCacheInfo); */ if (glyph->bits != NULL) { ximage=XCreateImage( display, DefaultVisual(display, screennumber), DefaultDepth(display,screennumber), ZPixmap, /* XYBitmap or XYPixmap */ 0, /* No offset */ glyph->bits, width, height, t1_pad, /* lines padded to bytes */ 0 /* number of bytes per line */ ); ximage->byte_order=xglyph_byte_order; XFreePixmap(display,pixmap); pixmap = XCreatePixmap(display, XtWindow(TopLevel), width, height, DefaultDepth(display,screennumber) ); XPutImage(display, pixmap, DefaultGC( display, screennumber), ximage, 0, 0, 0, 0, width, height ); XDestroyImage(ximage); } i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++; if (glyph->bits != NULL) { XtSetArg( args[i], XtNbitmap, pixmap); i++; } else { XtSetArg( args[i], XtNbitmap, 0); i++; } XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, WhitePixel( display, screennumber)); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, height + DOUBLEMARGIN); i++; if (glyph->bits != NULL) { XtSetArg( args[i], XtNbitmap, pixmap); i++; } else { XtSetArg( args[i], XtNbitmap, 0); i++; } XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, WhitePixel( display, screennumber)); i++; XtSetValues(Output ,args,i); glyph->bits=NULL; /* Since XDestroyImage() free's this also! */ } void showcharX( Widget showcharbutton, XtPointer client_data, XtPointer call_data) { int i, j; Arg args[10]; int tmp_width, tmp_height; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } if (CheckTransform()==0 && Angle==0.0){ matrixP=NULL; } else{ matrixP=T1_RotateMatrix( &matrix, Angle); } if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } for (j=0; jmetrics.advanceX - CROSS_SIZE, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY, XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY); XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber), XOUTPUT_HALFHSIZE + glyph->metrics.advanceX, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE, XOUTPUT_HALFHSIZE + glyph->metrics.advanceX, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE); } } XSetForeground( display, DefaultGC( display, screennumber), fg); /* Check for errors */ if (glyph==NULL) { sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno)); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Prepare status message: */ 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", time_diff(time_ptr_start,time_ptr_stop), glyph->metrics.leftSideBearing, glyph->metrics.rightSideBearing, glyph->metrics.ascent, glyph->metrics.descent, glyph->metrics.advanceX, glyph->metrics.advanceY, glyph->bpp, PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent), T1_GetFontName(FontID), T1_GetCharName(FontID,(char)TestChar), T1_errno); /* Finally, set the resources: */ i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, outbg); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetValues(Output ,args,i); } void showstringX( Widget showstringbutton, XtPointer client_data, XtPointer call_data) { int i,j,k,l,m,none_found; Arg args[10]; int tmp_width, tmp_height; char *theString='\0'; char *ligtheString='\0'; char *succs, *ligs; char buf_char; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } if (CheckTransform()==0 && Angle==0.0){ matrixP=NULL; } else{ matrixP=T1_RotateMatrix( &matrix, Angle); } if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } for (j=0; j0){ buf_char=theString[j]; while (k>0){ none_found=1; for (l=0;lmetrics.advanceX - CROSS_SIZE, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY, XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY); XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber), XOUTPUT_HALFHSIZE + glyph->metrics.advanceX, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE, XOUTPUT_HALFHSIZE + glyph->metrics.advanceX, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE); } } XSetForeground( display, DefaultGC( display, screennumber), fg); /* Free the ligature-converted string */ free(ligtheString); /* Check for errors */ if (glyph==NULL) { sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno)); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Prepare status message: */ 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", time_diff(time_ptr_start,time_ptr_stop), glyph->metrics.leftSideBearing, glyph->metrics.rightSideBearing, glyph->metrics.ascent, glyph->metrics.descent, glyph->metrics.advanceX, glyph->metrics.advanceY, glyph->bpp, PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent), T1_GetFontName(FontID), T1_errno); /* Finally, set resources */ i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, outbg); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, outbg); i++; XtSetValues(Output ,args,i); } void aashowcharX( Widget showcharbutton, XtPointer client_data, XtPointer call_data) { int i, j; Arg args[10]; int tmp_width, tmp_height; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogtestcharacter), "%d", &TestChar); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } if (CheckTransform()==0 && Angle==0.0){ matrixP=NULL; } else{ matrixP=T1_RotateMatrix( &matrix, Angle); } if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } for (j=0; jmetrics.advanceX - CROSS_SIZE, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY, XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY); XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber), XOUTPUT_HALFHSIZE + glyph->metrics.advanceX, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE, XOUTPUT_HALFHSIZE + glyph->metrics.advanceX, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE); } } XSetForeground( display, DefaultGC( display, screennumber), fg); /* Check for errors */ if (glyph==NULL) { sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno)); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Prepare status message: */ 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", time_diff(time_ptr_start,time_ptr_stop), glyph->metrics.leftSideBearing, glyph->metrics.rightSideBearing, glyph->metrics.ascent, glyph->metrics.descent, glyph->metrics.advanceX, glyph->metrics.advanceY, glyph->bpp, PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent), T1_GetFontName(FontID), T1_GetCharName(FontID,(char)TestChar), T1_errno); /* Finally, set the resources: */ i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, outbg); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetValues(Output ,args,i); } void aashowstringX( Widget showstringbutton, XtPointer client_data, XtPointer call_data) { int i,j,k,l,m,none_found; Arg args[10]; int tmp_width, tmp_height; char *theString='\0'; char *ligtheString='\0'; char *succs, *ligs; char buf_char; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } if (CheckTransform()==0 && Angle==0.0){ matrixP=NULL; } else{ matrixP=T1_RotateMatrix( &matrix, Angle); } if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } else for (j=0; j0){ buf_char=theString[j]; while (k>0){ none_found=1; for (l=0;lmetrics.advanceX - CROSS_SIZE, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY, XOUTPUT_HALFHSIZE + glyph->metrics.advanceX + CROSS_SIZE, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY); XDrawLine( display, tmp_pixmap, DefaultGC( display, screennumber), XOUTPUT_HALFHSIZE + glyph->metrics.advanceX, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY - CROSS_SIZE, XOUTPUT_HALFHSIZE + glyph->metrics.advanceX, XOUTPUT_HALFVSIZE - glyph->metrics.advanceY + CROSS_SIZE); } } XSetForeground( display, DefaultGC( display, screennumber), fg); /* Free the ligature-converted string */ free(ligtheString); /* Check for errors */ if (glyph==NULL) { sprintf(statusstring, "t1lib: Couldn't generate Bitmap,\n(%s)", T1_StrError(T1_errno)); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Prepare status message: */ 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", time_diff(time_ptr_start,time_ptr_stop), glyph->metrics.leftSideBearing, glyph->metrics.rightSideBearing, glyph->metrics.ascent, glyph->metrics.descent, glyph->metrics.advanceX, glyph->metrics.advanceY, glyph->bpp, PAD(glyph->bpp*(glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing),XGLYPH_PAD)/8*(glyph->metrics.ascent-glyph->metrics.descent), T1_GetFontName(FontID), T1_errno); /* Finally, set resources */ i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, outbg); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, tmp_width + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNheight, tmp_height + DOUBLEMARGIN); i++; XtSetArg( args[i], XtNbitmap, tmp_pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, outbg); i++; XtSetValues(Output ,args,i); } void fonttable( Widget fonttablebutton, XtPointer client_data, XtPointer call_data) { int i, j; Arg args[10]; static Pixmap pixmap=0; int x, y; int CellLeftMargin, CellTopMargin; int ColAdvance, RowAdvance; int width, height; int FontID, DeviceResolution; float Size, Extent, Slant; float scale; BBox fontbbox, tmpbbox; sscanf( XawDialogGetValueString(dialogfontid),"%d", &FontID); sscanf( XawDialogGetValueString(dialogsize),"%f", &Size); sscanf( XawDialogGetValueString(dialogangle),"%f", &Angle); sscanf( XawDialogGetValueString(dialogspace),"%ld", &Space); sscanf( XawDialogGetValueString(dialogdevres),"%d", &DeviceResolution); sscanf( XawDialogGetValueString(dialogstroke),"%d", &StrokeWidth); if (FontID<0 || FontID>=T1_GetNoFonts()) { sprintf(statusstring, "t1lib: FontID out of range!"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } /* Ensure that font is loaded before any operation on the font */ if ( T1_CheckForFontID( FontID) < 1 ) { T1_LoadFont( FontID); } if ( StrokeWidth == 0.0f ) { T1_ClearStrokeFlag( FontID); } else { T1_SetStrokeFlag( FontID); if ( T1_SetStrokeWidth( FontID, StrokeWidth) != 0 ) { sprintf( statusstring, "t1lib: Unable to setup strokewidth"); i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); return; } } /* We don't obey rotation when displaying a fonttable */ matrixP=NULL; if (DeviceResolution!=last_resolution[FontID]){ /* Delete all size dependent data for that font */ for ( i=0; i reset to internal encoding */ for (i=0; i so load it */ i=0; while (encstruct[i].encfilename != NULL) i++; encstruct[i].encoding=T1_LoadEncoding(EncodingFile); encstruct[i].encfilename=(char *)malloc(strlen(EncodingFile)+1); if (encstruct[i].encoding==NULL){ free( encstruct[i].encfilename); encstruct[i].encfilename=NULL; } i++; } else for (j=0; jfontbbox.urx) fontbbox.urx=tmpbbox.urx; if (tmpbbox.ury>fontbbox.ury) fontbbox.ury=tmpbbox.ury; } } /* We scale the font bounding box according to extent, slant and device resolution. For the slant, we assume that the font contains at least one character which reaches to the upper right corner and the same for lower left corner. */ scale=DeviceResolution/72.0; fontbbox.urx=fontbbox.urx+(int)((float)fontbbox.ury*Slant); fontbbox.llx=fontbbox.llx+(int)((float)fontbbox.lly*Slant); fontbbox.urx=(int)((float)fontbbox.urx*Extent); fontbbox.llx=(int)((float)fontbbox.llx*Extent); fontbbox.llx=(int)((float)fontbbox.llx*scale); fontbbox.urx=(int)((float)fontbbox.urx*scale); fontbbox.lly=(int)((float)fontbbox.lly*scale); fontbbox.ury=(int)((float)fontbbox.ury*scale); /* Left and top margin of the char-origins with respect upper left corner of cell */ CellTopMargin=SIMPLEMARGIN + fontbbox.ury; if (fontbbox.llx < 0){ CellLeftMargin= - fontbbox.llx; } else{ CellLeftMargin=0; } /* How much to advance in which direction when incrementing */ ColAdvance=CellLeftMargin + fontbbox.urx ; RowAdvance=CellTopMargin - fontbbox.lly ; /* Scale the charspace values */ CellTopMargin = (int) floor((double)CellTopMargin*Size/1000.0+0.5)+SIMPLEMARGIN; CellLeftMargin = (int) floor((double)CellLeftMargin*Size/1000.0+0.5)+SIMPLEMARGIN; ColAdvance = (int) floor((double)ColAdvance*Size/1000.0+0.5)+DOUBLEMARGIN; RowAdvance = (int) floor((double)RowAdvance*Size/1000.0+0.5)+DOUBLEMARGIN; /* Overall width and height of map */ width=1+(16*ColAdvance); height=1+(16*RowAdvance); /* We clip to a window as large as the screen in this function */ if (width > 1024) width=WidthOfScreen(screen); if (height > 768) height=HeightOfScreen(screen); /* Create pixmap of appropriate size, */ if (pixmap!=0) XFreePixmap( display, pixmap); pixmap=XCreatePixmap( display, XtWindow(TopLevel), width, height, depth ); /* We always use opaque mode */ XSetForeground( display, DefaultGC( display, screennumber), bg); XFillRectangle( display, pixmap, DefaultGC( display, screennumber), 0, 0, width, height); XSetForeground( display, DefaultGC( display, screennumber), fg); XSetBackground( display, DefaultGC( display, screennumber), bg); /* Draw cell grid: */ for (j=0; j<17; j++){ XDrawLine( display, pixmap, DefaultGC( display, screennumber), j*ColAdvance, 0, j*ColAdvance, height); } for (j=0; j<17; j++){ XDrawLine( display, pixmap, DefaultGC( display, screennumber), 0, j*RowAdvance, width, j*RowAdvance); } /* Reset T1_errno: */ T1_errno=0; /* Set antialiasing level */ T1_AASetLevel( aalevel); /* Draw characters into pixmap */ for ( i=0; i<16; ) { /* row-loop */ for ( j=0; j<16; j++) { x=1+(j*ColAdvance)+CellLeftMargin; y=1+CellTopMargin+(i*RowAdvance); glyph=T1_AASetCharX( pixmap, DefaultGC( display, screennumber), 1, x, y, FontID, (char) (i*16+j), Size, matrixP); if (x>width) { sprintf( msg_buf, "Clipping row %d horizontally at column %d", i, j); T1_PrintLog( "fonttable()", msg_buf, T1LOG_STATISTIC); break; } } if (y>height) { sprintf( msg_buf, "Clipping vertically at row %d", i); T1_PrintLog( "fonttable()", msg_buf, T1LOG_STATISTIC); break; } i++; } /* If font was not loadable */ if (T1_GetFontName( FontID)==NULL) sprintf(statusstring, "t1lib: Can't get font name, T1_errno=%d!", T1_errno); else sprintf(statusstring,"Font %s, final T1_errno = %d\n %s", T1_GetFontName( FontID), T1_errno, T1_StrError(T1_errno)); /* Finally, set resources */ i=0; XtSetArg(args[i], XtNbitmap,NULL); i++; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, XtUnspecifiedPixmap); i++; XtSetArg(args[i], XtNlabel, statusstring); i++; XtSetValues(labelstatus,args,i); i=0; XtSetArg( args[i], XtNwidth, width); i++; XtSetArg( args[i], XtNheight, height); i++; XtSetArg( args[i], XtNbitmap, pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, outbg); i++; XtSetValues(OutputWindow ,args,i); i=0; XtSetArg( args[i], XtNwidth, width); i++; XtSetArg( args[i], XtNheight, height); i++; XtSetArg( args[i], XtNbitmap, pixmap); i++; XtSetArg( args[i], XtNresize, 1);i++; XtSetArg( args[i], XtNinternalWidth, 0); i++; XtSetArg( args[i], XtNinternalHeight, 0); i++; XtSetArg( args[i], XtNbackground, outbg); i++; XtSetValues(Output ,args,i); } /* This function shows the About-message */ void showabout( Widget aboutbutton, XtPointer client_data, XtPointer call_data) { int i; Arg args[10]; Pixmap about=0; XGCValues xgcvalues; GC gc; static char ident[80]=""; #define T1GCMASK GCForeground | GCBackground if (about==0) { about=XCreatePixmap( display, XtWindow(TopLevel), 380, MESSAGEBOXHEIGHT, depth); } gc=DefaultGC( display, screennumber); XGetGCValues( display, gc, T1GCMASK, &xgcvalues); fg=xgcvalues.foreground; bg=xgcvalues.background; XSetForeground( display, gc, white.pixel); XFillRectangle( display, about, gc, 0, 0, 380, MESSAGEBOXHEIGHT); XSetForeground( display, gc, black.pixel); XSetBackground( display, gc, white.pixel); /* Set antialiasing level */ T1_AASetLevel( aalevel); sprintf( ident, "This is xglyph, T1Lib Version %s", T1_GetLibIdent()); glyph=T1_AASetStringX( about, gc, 1, 10, 30, /* x_dest, y_dest */ 0, ident, 0, 0.0, T1_UNDERLINE | T1_KERNING, 20.0, NULL); glyph=T1_AASetStringX( about, gc, 1, 10, 60, /* x_dest, y_dest */ 0, "xglyph is an interactive tool for illustrating some", 0, 0.0, T1_KERNING, 15.0, NULL); glyph=T1_AASetStringX( about, gc, 1, 10, 80, /* x_dest, y_dest */ 0, "of the T1Lib features. T1Lib is distributed under", 0, 0.0, T1_KERNING, 15.0, NULL); glyph=T1_AASetStringX( about, gc, 1, 10, 100, /* x_dest, y_dest */ 0, "the GNU General Public Library License (LGPL).", 0, 0.0, T1_KERNING, 15.0, NULL); glyph=T1_AASetStringX( about, gc, 1, 10, 133, /* x_dest, y_dest */ 0, "Enjoy it!", 0, 0.0, T1_KERNING, 15.0, NULL); XSetForeground( display, gc, fg); XSetBackground( display, gc, bg); i=0; XtSetArg(args[i], XtNwidth,380); i++; XtSetArg(args[i], XtNheight, MESSAGEBOXHEIGHT); i++; XtSetArg(args[i], XtNbackgroundPixmap, about); i++; XtSetArg(args[i], XtNlabel, ""); i++; XtSetValues(labelstatus,args,i); } /* This function returns a time difference in Microseconds, provided that the time difference is not greater than approximately 35 minutes. */ long time_diff(struct timeval *time_ptr_start, struct timeval *time_ptr_stop) { return((time_ptr_stop->tv_sec - time_ptr_start->tv_sec)*1000000 +(time_ptr_stop->tv_usec - time_ptr_start->tv_usec)); } /* T1_ComputeAAColorsX(): Compute the antialiasing colors in dependency of foreground and background */ int ComputeAAColorsX( unsigned long fg, unsigned long bg, int nolevels) { static unsigned long last_fg; static unsigned long last_bg; unsigned long delta_red, delta_green, delta_blue; int i; int nocolors=0; aacolors[0].pixel=bg; aacolors[nolevels-1].pixel=fg; if ((fg==last_fg)&&(bg==last_bg)) return(nocolors); /* Get RGB values for fore- and background */ XQueryColor( display, DefaultColormap(display,screennumber), &aacolors[0]); XQueryColor( display, DefaultColormap(display,screennumber), &aacolors[nolevels-1]); delta_red = (aacolors[nolevels-1].red - aacolors[0].red)/(nolevels-1); delta_green = (aacolors[nolevels-1].green - aacolors[0].green)/(nolevels-1); delta_blue = (aacolors[nolevels-1].blue - aacolors[0].blue)/(nolevels-1); aapixels[0]=aacolors[0].pixel; aapixels[nolevels-1]=aacolors[nolevels-1].pixel; for (i=1; i