home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
useful
/
dist
/
text
/
tex
/
pastex
/
macros
/
latex
/
nfss2
/
psmetrics
/
vpltovpl.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-29
|
29KB
|
1,042 lines
#define VERSION "10 (July 1993)"
/*
vpltovpl.c. version 1. december 1990
version 2. january 1992
version 3. may 1992
version 4. dec 1992
version 5. dec 28 1992
version 6. may 20 1993. removed progress indicators.
put back with -DDEBUG
version 7. may 25 1993. cleaned up and re-used generation of
extra file for dotlessj only (activated by -DSPECIAL)
version 8. july 12 1993. redo some of virtual font code;
and generate the dotlessj missing char with vpl
rather than using a tiny PS font
version 9. july 14 1993. add in code to check if we are an
artificial small caps font, and do things right for
that
version 10. july 1993. corrected aogonek
by Sebastian Rahtz
spqr@minster.york.ac.uk
(thanks also to Alexander Samarin for suggestions;
and Michael Doob and Craig Platt for ideas on how to do dotlessj)
Take an existing .vpl file, create extra characters for new composite
characters for extended TeX layout, and add them to the end of the
file
[
where necessary write a tiny new font metric file for extra characters;
abandoned in version 8
]
Parameters: 1) name of vpl file (which is going to be overwritten)
2) name of original AFM file
a quite dreadfully written C program converted from an Icon program:
--------------------------------------------------------
# vplovx.icn version 1
#
# Sebastian Rahtz October 1990
#
--------------------------------------------------------
bits pinched from other people. notably the `findchar' and `newchar'
functions, with associated material, taken from afm2tfm almost verbatim
*/
#include "vpltovpl.h"
char vplname[LINELENGTH], afmname[LINELENGTH];
char command[LINELENGTH], plname[LINELENGTH];
char basefont[100];
float uppergap,lowergap = -1.0 ;
FILE *vplfile, *afmfile, *plfile;
char entry[MAXENTRY];
int SCFont = 0;
float fontat=.8;
struct character {
struct character *next;
char *name;
float width,height,depth,charic;
} *chars,*vchars[MAXCHARS] ;
/*---------------------------*/
struct character * findchar(p)
char *p ;
{
register struct character *ai ;
for (ai=chars; ai; ai = ai->next)
{
if (strcmp(p, ai->name)==0)
return(ai) ;
}
return(NULL) ;
}
/*--------------------------*/
float width(key)
char *key;
{
register struct character *ai;
ai = findchar(key);
if (ai == NULL)
{
#ifdef DEBUG
fprintf(stderr,"No width for %s\n",key);
#endif
return (0);
}
else
return (ai->width);
}
/*--------------------------*/
float height(key)
char *key;
{
register struct character *ai;
ai = findchar(key);
if (ai == NULL)
{
#ifdef DEBUG
fprintf(stderr,"No height for %s\n",key);
#endif
return (0);
}
else
return (ai->height);
}
/*--------------------------*/
float depth(key)
char *key;
{
register struct character *ai;
ai = findchar(key);
if (ai == NULL)
{
#ifdef DEBUG
fprintf(stderr,"No depth for %s\n",key);
#endif
return (0);
}
else
return (ai->depth);
}
/*--------------------------*/
float charic(key)
char *key;
{
register struct character *ai;
ai = findchar(key);
if (ai == NULL)
{
#ifdef DEBUG
fprintf(stderr,"No charic for %s\n",key);
#endif
return (0);
}
else
return (ai->charic);
}
/*--------------------------*/
void error(s)
register char *s ;
{
extern void exit() ;
(void)fprintf(stderr, "%s\n", s) ;
if (*s == '!')
exit(1) ;
}
/*--------------------------*/
char * mymalloc(len)
unsigned long len ;
{
register char *p ;
int i ;
#ifdef SMALLMALLOC
if (len > 65500L)
error("! can't allocate more than 64K!") ;
#endif
p = malloc((unsigned)len) ;
if (p==NULL)
error("! out of memory") ;
for (i=0; i<len; i++)
p[i] = 0 ;
return(p) ;
}
/*--------------------------*/
char * namespace() {
register char *q;
q = mymalloc(6) ;
return(q) ;
}
/*--------------------------*/
struct character * anewchar() {
register struct character *ai ;
ai = (struct character *)mymalloc((unsigned long)sizeof(struct character)) ;
ai->width = 0 ;
ai->name = NULL ;
ai->height = 0 ;
ai->depth = 0 ;
ai->charic = 0 ;
ai->next = chars ;
chars = ai ;
return(ai) ;
}
/*--------------------------*/
int count(line)
char *line;
{
/* count the parentheses in a line, add +1 for a '(', -1 for a ')' */
char *p;
int cnt = 0;
for (p=line; *p; p++) {
if (*p=='(')
cnt += 1;
if (*p==')')
cnt -= 1;
}
return(cnt);
}
#ifndef MSDOS
/*--------------------------*/
float max(float a, float b)
{
if (a > b )
return (a) ;
else
return (b) ;
}
#endif
/*--------------------------*/
void vchar(charnum,charname,charwd,charht,chardp,
charic,oldchar,accent,moveright,moveup,WhichFont)
int charnum; /* number of new character*/
char *charname; /* name of new character*/
float charwd; /* width of character*/
float charht; /* height of character*/
float chardp; /* depth of character*/
float charic; /* italic correction of character*/
char *oldchar; /* number of old character*/
char *accent; /* string of accent number*/
float moveright; /* (can be negative)*/
float moveup; /* (can be negative)*/
int WhichFont ; /* for small caps. 0 or 1 */
{
#ifdef DEBUG
fprintf(stderr,"generate character %s from %s and %s: %f %f\n",
charname,oldchar,accent,moveup,moveright);
#endif
fprintf(vplfile,"(CHARACTER O %d (comment %s: %.2f %.2f)\n",charnum,charname,moveright,moveup);
if (charwd != 0 )
fprintf(vplfile," (CHARWD R %.2f)\n",charwd);
if (charht != 0 )
fprintf(vplfile," (CHARHT R %.2f)\n",charht);
if (chardp != 0 )
fprintf(vplfile," (CHARDP R %.2f)\n",chardp);
if (charic != 0 )
fprintf(vplfile," (CHARIC R %.2f)\n",charic);
/* WhichFont will be 0 normally, but 1 if we are a small caps font */
fprintf(vplfile," (MAP (SELECTFONT D %d)\n",WhichFont);
fprintf(vplfile," (SETCHAR %s)\n",oldchar);
if (moveright != 0.0)
fprintf(vplfile," (MOVERIGHT R %.2f)\n",-moveright);
if (moveup != 0.0 )
fprintf(vplfile," (MOVEUP R %.2f)\n",moveup);
fprintf(vplfile," (SETCHAR %s)\n",accent);
fprintf(vplfile," )\n");
fprintf(vplfile," )\n");
}
/*----------------------*/
void upperacc(number,c,accent,name)
int number;
char *c,*accent,*name;
{
float xdepth,xheight,xmoveup;
#ifdef DEBUG
fprintf(vplfile,"(COMMENT UPPERACC with %d: %s, %s, %s )\n",number,c,accent,name);
#endif
xdepth=depth(accent);
if (xdepth > 0.0)
/*
# its an underneath accent
# no need to move up
*/
{
xheight=height(c);
xmoveup=0.0;
}
else
{
xdepth=depth(c);
xheight=height(accent);
xmoveup=uppergap;
}
vchar(number,
name,
width(c),
xheight+xmoveup,
xdepth,
charic(c),
c,
accent,
(float) ( ( width(c) / 2.0 ) + ( width(accent) / 2.0 ) ),
xmoveup,0);
}
/*--------------------------*/
void loweracc(number,c,accent,name,movedown)
int number;
float movedown;
char *c,*accent,*name;
{
float moveup,adepth,xheight,xdepth,xmoveup;
float CDepth,CHeight,CWidth,ADepth,AHeight,AWidth,CIc;
char CharName[5];
char LastChar;
strcpy(CharName,c);
/* if we are in small caps, uppercase the character name */
if (SCFont == 1 )
{
LastChar=CharName[strlen(CharName)-1];
CharName[strlen(CharName)-1]=toupper(LastChar);
/*
for a small caps font, we need to reduce the dimensions to the size
of the small caps font; we have derived this from the vpl file earlier
as `fontat'
*/
ADepth=depth(accent) * fontat;
AWidth=width(accent) * fontat ;
AHeight=height(accent) * fontat + SC_ACCENT_RAISE ;
CWidth=width(CharName) * fontat ;
CHeight=height(CharName) * fontat ;
CDepth=depth(CharName) * fontat ;
CIc=charic(CharName) * fontat ;
}
else
{
ADepth=depth(accent);
AWidth=width(accent) ;
AHeight=height(accent) ;
CWidth=width(CharName) ;
CHeight=height(CharName) ;
CDepth=depth(CharName) ;
CIc=charic(CharName) ;
}
#ifdef DEBUG
fprintf(vplfile,"(COMMENT LOWERACC with %d: %s, %s, %s %f)\n",number,CharName,accent,name,movedown);
#endif
xdepth=ADepth;
if (xdepth > 0.0 )
{
xheight=CHeight;
xmoveup=0.0;
}
else
{
xdepth=CDepth;
xheight=AHeight;
xmov