📄 xglyph.c
字号:
/*-------------------------------------------------------------------------- ----- File: xglyph.c ----- Author: Rainer Menzner (Rainer.Menzner@web.de) ----- Date: 2001-10-03 ----- 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-2001. 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_NO_AFM 0x0200/* #define SHOW_MANIPULATE_PATHS */#include <X11/Intrinsic.h>#include <X11/StringDefs.h>#include <X11/Xaw/Label.h>#include <X11/Xaw/Command.h>#include <X11/Xaw/Form.h>#include <X11/Xaw/Dialog.h>#include <X11/Xaw/Box.h>#include <X11/Xaw/Toggle.h>#include <X11/Shell.h>#include <X11/Xaw/AsciiText.h>#include <X11/Xaw/SimpleMenu.h>#include <X11/Xaw/SmeBSB.h>#include <X11/Xaw/List.h>#include <stdio.h>#include <math.h>#include <stdlib.h>#include <sys/types.h>#include <sys/uio.h>#include <unistd.h>#include <sys/time.h>/* The following stuff is necessary for compiling and running xglyph on. 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 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 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", "--Help", "--noGrid", "--setPad", "--logError", "--logWarning", "--logStatistic", "--logDebug", "--ignoreForceBold", "--ignoreFamilyAlignment", "--ignoreHinting", "--ignoreAFM", "--debugLine", "--debugRegion", "--debugPath", "--debugFont", "--debugHint", "--checkPerformance", "--checkCopyFont", "--checkConcatGlyphs", "--checkConcatOutlines", "--checkBadCharHandling", "--checkDefaultEncoding", "--checkSmartAntialiasing", "--checkAACaching", NULL};int extraflags=0;/* #define SHOW_MANIPULATE_PATHS */#ifdef SHOW_MANIPULATE_PATHSvoid 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<argc; i++){ if (strncmp(&(argv[i][0]), "--", 2)==0){ j=0; optfound=0; while ( (j<numopts) && optfound==0){ if (strcmp(argv[i],xglyphoptions[j])==0){ switch (j){ case 0: printusage( 8); /* Show 8 options */ exit(0); case 1: printusage( 0); /* Show all options */ exit(0); case 2: extraflags |= NO_GRID; optfound=1; break; case 3: /* We have to examine one further argument */ i++; if (strcmp( argv[i], "8")==0) t1_pad=8; else if (strcmp( argv[i], "16")==0) t1_pad=16; else if (strcmp( argv[i], "32")==0) t1_pad=32; else{ fprintf( stderr, "xglyph: Invalid padding specification %s\n", argv[i]); exit(-1); } optfound=1; break; case 4: loglevel = T1LOG_ERROR; loglevel |= (0x01 << 8); optfound=1; break; case 5: loglevel = T1LOG_WARNING; loglevel |= (0x01 << 8); optfound=1; break; case 6: loglevel = T1LOG_STATISTIC; loglevel |= (0x01 << 8); optfound=1; break; case 7: loglevel = T1LOG_DEBUG; loglevel |= (0x01 << 8); optfound=1; break; case 8: rasterflags |= T1_IGNORE_FORCEBOLD; optfound=1; break; case 9: rasterflags |= T1_IGNORE_FAMILYALIGNMENT; optfound=1; break; case 10: rasterflags |= T1_IGNORE_HINTING; optfound=1; break; case 11: initflags |= T1_NO_AFM; optfound=1; break; case 12: rasterflags |= T1_DEBUG_LINE; optfound=1; break; case 13: rasterflags |= T1_DEBUG_REGION; optfound=1; break; case 14: rasterflags |= T1_DEBUG_PATH; optfound=1; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -