📄 xglyph.c
字号:
case 15: rasterflags |= T1_DEBUG_FONT; optfound=1; break; case 16: rasterflags |= T1_DEBUG_HINT; optfound=1; break; case 17: extraflags |= CHECK_PERFORMANCE; optfound=1; break; case 18: extraflags |= CHECK_T1_COPYFONT_T1_ADDFONT; optfound=1; break; case 19: extraflags |= CHECK_CONCATGLYPHS; optfound=1; break; case 20: extraflags |= CHECK_CONCATOUTLINES; optfound=1; break; case 21: extraflags |= CHECK_FOR_BAD_CHARS; optfound=1; break; case 22: extraflags |= CHECK_DEFAULT_ENCODING; optfound=1; break; case 23: extraflags |= CHECK_SMART_AA; optfound=1; break; case 24: extraflags |= CHECK_AA_CACHING; optfound=1; break; default: /* should not be reached */ break; } } /* end of "if (strcmp.." */ j++; } if (optfound==0){ fprintf( stderr, "xglyph: Unknown option %s\n", argv[i]); exit(-1); } } else /* string doesn't start with "--" -> 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<argc; j++){ T1_AddFont( argv[j]); } } /* We return if no fonts could be installed */ if ((j=T1_Get_no_fonts())<=0){ fprintf(stderr,"xglyph: No fonts in database (T1_errno=%d)!\n", T1_errno); return(-1); } /* Set the raster parameters */ T1_SetRasterFlags( rasterflags); /* Load alternate encoding and associate it with filename: */ encstruct[0].encoding=T1_LoadEncoding(T1LIBENCFILE); encstruct[0].encfilename=(char *)malloc(strlen(T1LIBENCFILE)+1); strcpy( encstruct[0].encfilename, T1LIBENCFILE); for ( i=1; i<MAXENCODINGS; i++){ encstruct[i].encoding=NULL; encstruct[i].encfilename=NULL; } /* If requested, set a default encoding vector */ if (extraflags & CHECK_DEFAULT_ENCODING){ T1_SetDefaultEncoding( encstruct[0].encoding); } if( extraflags & CHECK_T1_COPYFONT_T1_ADDFONT){ { int k; /* The following code is to test the T1_CopyFont()-function. It generates logical fonts with IDs twice the ID of the original font which are then slanted by 0.3. */ nofonts=T1_Get_no_fonts(); printf("Initial number of fonts: %d\n", nofonts); for (i=0; i< nofonts; i++){ T1_LoadFont(i); if ((k=T1_CopyFont(i))<0){ fprintf(stderr,"T1_CopyFont() unsuccessful (k=%d), for FontID=%d\n", k, i); }else{ T1_SlantFont(k,0.3); fprintf(stderr,"Slanted Font under FontID %d generated\n", k); } } fprintf( stderr, "T1_AddFont() returned newID %d for fontfile %s!\n", T1_AddFont( TESTFONTFILE), TESTFONTFILE); nofonts=T1_Get_no_fonts(); printf("Final number of fonts: %d\n", nofonts); } } /* Setup arrays for the last... values */ nofonts=T1_Get_no_fonts(); if ( (last_resolution=(int *) malloc ( nofonts * sizeof(int)))==NULL){ fprintf( stderr, "xglyph: memory allocation error\n"); exit(1); } else for (i=0; i<nofonts; i++) last_resolution[i]=72; if ( (lastSlant=(float *) malloc ( nofonts * sizeof(float)))==NULL){ fprintf( stderr, "xglyph: memory allocation error\n"); exit(1); } else for (i=0; i<nofonts; i++) lastSlant[i]=0.0; if ( (lastExtent=(float *) malloc ( nofonts * sizeof(float)))==NULL){ fprintf( stderr, "xglyph: memory allocation error\n"); exit(1); } else for (i=0; i<nofonts; i++) lastExtent[i]=1.0; if (extraflags & CHECK_SMART_AA) T1_AASetSmartMode( T1_YES); /* Initialize application */ TopLevel = XtAppInitialize(&TopLevelApp, (String) "Xglyph", (XrmOptionDescList) NULL, (Cardinal) 0, &argc, argv, (String *) NULL, (ArgList) NULL, (Cardinal) 0); i=0; XtSetArg(args[i], XtNheight, APPLICATIONHEIGHT); i++; XtSetValues(TopLevel,args,i); /* Create window for graphics output */ Output = XtCreatePopupShell( "Xglyph-Output", topLevelShellWidgetClass, TopLevel, NULL,0); OutputWindow = XtCreateManagedWidget("xglyph-Output",labelWidgetClass, Output, NULL, 0); /* Get display/screen pointer and screennumber */ display = XtDisplay(OutputWindow); screen = XtScreen(OutputWindow); screennumber = DefaultScreen(display); depth = DefaultDepth(display,screennumber); /* In case client and server have different endian architecture, we have to care for the 16 and 32 bit aa-pixels to have the correct byte order */ if (T1_CheckEndian()==0) xglyph_byte_order=0; else xglyph_byte_order=1; if( extraflags & CHECK_PERFORMANCE){ perf_pixmap=0; /* The following is for testing only */ Output2 = XtCreatePopupShell( "Xglyph-Output2", topLevelShellWidgetClass, TopLevel, NULL,0); OutputWindow2 = XtCreateManagedWidget("xglyph-Output2",labelWidgetClass, Output2, NULL, 0); i=0; XtSetArg( args[i], XtNwidth, 800 ); i++; XtSetArg( args[i], XtNheight, 600 ); i++; XtSetValues(OutputWindow2,args,i); } /* Get colors and assign pixel values: */ XAllocNamedColor(display, DefaultColormap(display,screennumber), EDITABLE_COLOR, &edit_color, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "green", &green, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "blue", &blue, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "black", &gray4, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray25", &gray3, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray50", &gray2, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "gray75", &gray1, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "white", &gray0, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "yellow", &yellow, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "pink4", &pink4, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "cyan", &gridcolor1, &wozu); XAllocNamedColor(display, DefaultColormap(display,screennumber), "magenta", &gridcolor2, &wozu); white=gray0; black=gray4; gray=gray1; red=edit_color; /* Fill the aacolors and aapixels-array */ ComputeAAColorsX( black.pixel, white.pixel, AAMAXPLANES); /* Set default colors for X11 rastering functions */ fg=black.pixel; bg=white.pixel; T1_AASetBitsPerPixel(DefaultDepth(display,screennumber)); /* T1_LogicalPositionX( 0); */ /* The box-widget for all the buttons */ box=XtCreateManagedWidget("xglyph", boxWidgetClass, TopLevel, NULL, 0); i=0; XtSetArg(args[i], XtNheight,400); i++; XtSetValues(box,args,i); /* A dialogbox for the fontID-specification */ dialogfontid=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "FontID:"); i++; XtSetArg(args[i], XtNvalue, "0"); i++; XtSetValues(dialogfontid,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogfontid,"value"),args,i); /* A dialogbox for the font-Size */ dialogsize=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Font-Size [bp]:"); i++; XtSetArg(args[i], XtNvalue, DEFAULT_SIZE); i++; XtSetValues(dialogsize,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogsize,"value"),args,i); /* A dialogbox for the font slant specification */ dialogslant=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Slant:"); i++; XtSetArg(args[i], XtNvalue, "0.0"); i++; XtSetValues(dialogslant,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogslant,"value"),args,i); /* A dialogbox for the font-extension */ dialogextent=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Extension:"); i++; XtSetArg(args[i], XtNvalue, "1.0"); i++; XtSetValues(dialogextent,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH / 2 - 8); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogextent,"value"),args,i); /* transformation matrix dialog widget */ dialogtmatrix = XtCreateManagedWidget( "dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Transformation-Matrix:"); i++; XtSetArg(args[i], XtNvalue, "1.0, 0.0, 0.0, 1.0"); i++; XtSetValues(dialogtmatrix,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogtmatrix,"value"),args,i); /* A dialogbox for the device resolution */ dialogdevres=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Resolution [DPI]:"); i++; XtSetArg(args[i], XtNvalue, "72"); i++; XtSetValues(dialogdevres,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogdevres,"value"),args,i); /* A dialogbox for the encoding filename */ dialogencfile=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Encoding-File:"); i++; XtSetArg(args[i], XtNvalue, ""); i++; XtSetValues(dialogencfile,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogencfile,"value"),args,i); /* A dialogbox for the angle */ dialogangle=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Angle [deg]:"); i++; XtSetArg(args[i], XtNvalue, "0.0"); i++; XtSetValues(dialogangle,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogangle,"value"),args,i); /* A dialogbox for the space-offset in strings */ dialogspace=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Space-Off [1/1000 bp]:"); i++; XtSetArg(args[i], XtNvalue, "0"); i++; XtSetValues(dialogspace,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++; XtSetArg(args[i], XtNforeground, edit_color.pixel); i++; XtSetValues(XtNameToWidget(dialogspace,"value"),args,i); /* A dialogbox for the character */ dialogtestcharacter=XtCreateManagedWidget("dialog1", dialogWidgetClass, box, NULL, 0); i=0; XtSetArg(args[i], XtNlabel, "Character (decimal):"); i++; XtSetArg(args[i], XtNvalue, DEFAULT_CHAR); i++; XtSetValues(dialogtestcharacter,args,i); i=0; XtSetArg(args[i], XtNwidth,DIALOGWIDTH); i++; XtSetArg(args[i], XtNheight,DIALOGHEIGHT); i++; XtSetArg(args[i], XtNresize, FALSE); i++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -