void init_fonts (void) { define_font (default_oleo_name, default_x_name, default_ps_name); define_font ("times", default_x_name, default_ps_name); define_font ("f9x15", "9x15", "sdlkfj"); the_default_font = intern_font (default_oleo_name, 1.0); }
/* ----- init_index_file ------- */ void init_index_file (void) { time_t ltime; char tstr[41]; fprintf (findex, "%%!PS-Adobe-3.0\n"); fprintf (findex, "%%%%Title: abctab2ps index\n"); time(<ime); strcpy (tstr, ctime(<ime)); tstr[24]='\0'; tstr[16]='\0'; fprintf (findex, "%%%%Creator: abctab2ps %s.%s\n", VERSION, REVISION); fprintf (findex, "%%%%CreationDate: %s %s\n", tstr+4,tstr+20); if (!noauthor) fprintf (findex, "%%%%For: %s\n", get_real_user_name().c_str()); if (PS_LEVEL == 2) fprintf (findex, "%%%%LanguageLevel: 2\n"); fprintf (findex, "%%%%EndComments\n\n"); fprintf (findex, "%%%%BeginSetup\n"); if (PS_LEVEL < 2) level1_fix (findex); define_font (findex,cfmt.indexfont.name,1); fprintf (findex, "\n/T {translate} bind def\n/M {moveto} bind def\n"); fprintf (findex, "/S {show} bind def\n"); def_misc (findex); fprintf (findex, "%%%%EndSetup\n\n"); index_pagenum=0; init_index_page (findex); index_initialized=1; }
static void load_font() { vcons.glyph_width = CHAR_WIDTH; vcons.glyph_height = CHAR_HEIGHT; vcons.text_cols = vcons.scrn_width / vcons.glyph_width; vcons.text_rows = vcons.scrn_height / vcons.glyph_height; // center the text display, giving any extra pixels to the left/bottom vcons.txt_off_x = ((vcons.scrn_width - (vcons.text_cols * vcons.glyph_width)) + 1) / 2; vcons.txt_off_y = ((vcons.scrn_height - (vcons.text_rows * vcons.glyph_height)) + 0) / 2; define_font(1, ((CHAR_WIDTH + 7) & ~7), sizeof(FONT), FONT); dprintf("load_font: %dx%d glyphs\n", vcons.text_cols, vcons.text_rows); }
/* ----- init_ps ------- */ void init_ps (FILE *fp, char *str, int is_epsf, float bx1, float by1, float bx2, float by2) { time_t ltime; char tstr[41]; int i; if (is_epsf) { if (vb>=8) printf("Open EPS file with title \"%s\"\n", str); fprintf (fp, "%%!PS-Adobe-3.0 EPSF-3.0\n"); fprintf (fp, "%%%%BoundingBox: %.0f %.0f %.0f %.0f\n", bx1,by1,bx2,by2); } else { if (vb>=8) printf("Open PS file with title \"%s\"\n", str); fprintf (fp, "%%!PS-Adobe-3.0\n"); } /* Title */ fprintf (fp, "%%%%Title: %s\n", str); /* CreationDate */ time(<ime); strcpy (tstr, ctime(<ime)); tstr[24]='\0'; tstr[16]='\0'; fprintf (fp, "%%%%Creator: abctab2ps %s.%s\n", VERSION, REVISION); fprintf (fp, "%%%%CreationDate: %s %s\n", tstr+4,tstr+20); /* Author */ if (!noauthor) fprintf (fp, "%%%%For: %s\n", get_real_user_name().c_str()); if (PS_LEVEL == 2) fprintf (fp, "%%%%LanguageLevel: 2\n"); if (!is_epsf) fprintf (fp, "%%%%Pages: (atend)\n"); fprintf (fp, "%%%%EndComments\n\n"); if (is_epsf) fprintf (fp, "gsave /origstate save def mark\n100 dict begin\n\n"); fprintf (fp, "%%%%BeginSetup\n"); if (PS_LEVEL < 2) level1_fix (fp); if (vb>=7) printf ("\nDefining ISO fonts in file header:\n"); for (i=0;i<nfontnames;i++) { define_font (fp,fontnames[i],i); if (vb>=7) printf (" F%d %s\n", i,fontnames[i]); } define_symbols (fp); fprintf (fp, "\n/T {translate} bind def\n/M {moveto} bind def\n"); fprintf (fp, "\n0 setlinecap 0 setlinejoin 0.8 setlinewidth\n"); fprintf (fp, "%%%%EndSetup\n"); file_initialized=1; }
void set_default_font (char * name, double scale) { struct font_names * fn = find_font_name (name); if (fn != find_font_name (default_oleo_name)) define_font (default_oleo_name, fn->x_name, fn->ps_name); the_default_font = intern_font (default_oleo_name, scale); #ifndef X_DISPLAY_MISSING if (using_x) set_x_default_point_size (Global->cell_font_point_size); else #endif io_repaint (); }
static struct font_names * matching_font_names (char * x_name, char * ps_name) { struct font_names * fn; for (fn = font_names; fn; fn = fn->next) { if ( stricmp (fn->oleo_name, "default") && !stricmp (ps_name, fn->ps_name) && !stricmp (x_name, fn->x_name)) return fn; } { char * oleo_name = mk_sprintf ("%s,%s", x_name, ps_name); define_font (oleo_name, x_name, ps_name); fn = find_font_name (oleo_name); free (oleo_name); return fn; } }
unsigned long #else void #endif read_VF_index(struct font *fontp, wide_bool hushcs) { FILE *VF_file = fontp->file; ubyte cmnd; ubyte *avail, *availend; /* available space for macros */ long checksum; #ifdef Omega struct macro *newmacro; unsigned long maxcc = 0; int i; #endif Boolean dummy = False; fontp->read_char = NULL; fontp->flags |= FONT_VIRTUAL; fontp->set_char_p = set_vf_char; if (debug & DBG_PK) Printf("Reading VF file %s\n", fontp->filename); /* * Read preamble. */ Fseek(VF_file, (long)one(VF_file), 1); /* skip comment */ checksum = four(VF_file); if (checksum != fontp->checksum && checksum != 0 && fontp->checksum != 0 && !hushcs) Fprintf(stderr, "Checksum mismatch (dvi = %lu, vf = %lu) in font file %s\n", fontp->checksum, checksum, fontp->filename); (void)four(VF_file); /* skip design size */ /* * Read the fonts. */ fontp->vf_table = xmalloc(VFTABLELEN * sizeof(struct font *)); bzero((char *)fontp->vf_table, VFTABLELEN * sizeof(struct font *)); fontp->vf_chain = NULL; fontp->first_font = NULL; while ((cmnd = one(VF_file)) >= FNTDEF1 && cmnd <= FNTDEF4) { struct font *newfontp = define_font(VF_file, cmnd, fontp, fontp->vf_table, VFTABLELEN, &fontp->vf_chain, &dummy); if (fontp->first_font == NULL) fontp->first_font = newfontp; } /* * Prepare macro array. */ #ifdef Omega fontp->maxchar = 65535; fontp->macro = xmalloc(65536 * sizeof(struct macro)); bzero((char *)fontp->macro, 65536 * sizeof(struct macro)); #else fontp->macro = xmalloc(256 * sizeof(struct macro)); bzero((char *)fontp->macro, 256 * sizeof(struct macro)); #endif /* * Read macros. */ avail = availend = NULL; for (; cmnd <= LONG_CHAR; cmnd = one(VF_file)) { struct macro *m; int len; unsigned long cc; long width; if (cmnd == LONG_CHAR) { /* long form packet */ len = four(VF_file); cc = four(VF_file); width = four(VF_file); #ifdef Omega if (cc >= 65536) { #else if (cc >= 256) { #endif Fprintf(stderr, "Virtual character %lu in font %s ignored.\n", cc, fontp->fontname); Fseek(VF_file, (long)len, 1); continue; } } else { /* short form packet */ len = cmnd; cc = one(VF_file); width = num(VF_file, 3); } #ifdef Omega maxcc = (cc > maxcc) ? cc : maxcc; #endif m = &fontp->macro[cc]; m->dvi_adv = width * fontp->dimconv; if (len > 0) { if (len <= availend - avail) { m->pos = avail; avail += len; } else { m->free_me = True; if (len <= VF_PARM_1) { m->pos = avail = xmalloc(VF_PARM_2); availend = avail + VF_PARM_2; avail += len; } else m->pos = xmalloc((unsigned)len); } Fread((char *)m->pos, 1, len, VF_file); m->end = m->pos + len; } if (debug & DBG_PK) Printf("Read VF macro for character %lu; dy = %ld, length = %d\n", cc, m->dvi_adv, len); } if (cmnd != POST) oops("Wrong command byte found in VF macro list: %d", cmnd); Fclose(VF_file); fontp->file = NULL; n_files_left++; #ifdef Omega newmacro = xmalloc((maxcc + 1) * sizeof(struct macro)); for (i = 0; i <= maxcc; i++) { newmacro[i] = fontp->macro[i]; } free(fontp->macro); fontp->macro = newmacro; fontp->maxchar = maxcc; return maxcc; #endif }
void set_ps_font_cmd (char * ps_name) { define_font (default_oleo_name, the_default_font->names->x_name, ps_name); }
void set_x_default_font (char * str) { define_font (default_oleo_name, str, the_default_font->names->ps_name); io_repaint (); }