1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
#ifdef VFLIB
#include "defs.h"
#include "emit.h"
#include "global.h"
#include "bifont.h"
#include "rastfont.h"
#include "ps.h"
#include "VF.h"
static struct pd pd;
dev_vflo_begfontdict()
{
initpd(pd);
}
void
dev_vflo_initfontdict(fe, vflfi, k, c, tw, w, h, d, outline)
struct font_entry *fe;
struct vflfntinfo *vflfi;
int k, c;
int tw, w, h, d;
long *outline;
{
struct vflchar_entry *ce;
int bw;
end_string();
ce = vflfi->ch+k;
/* open font dict before first char */
if (getpd(&pd))
EMIT(outfp, "%.3f %d /%s NF2\n",
1.0, NPACKPSCHARS, psfname(pd.pd_font));
#ifdef STATS
if (fe->ncdl == -1)
fe->ncdl = 0;
#endif
ce->dev_font = pd.pd_font;
ce->dev_char = pd.pd_char;
dev_setfont(ce->dev_font);
#ifdef DEBUG
if (Debug)
EMIT(outfp, "%% font: %s char: %x\n", fe->n, c);
#endif
bw = (w+7)>>3;
EMITC('[');
pscharoutline(w, h, outline);
EMIT(outfp, "\n%d %d %d %d %.3f] %d D\n",
bw<<3, h,
0, d, ((float)tw)/hconv,
/*ce->xoffset, (((int)ce->height)-ce->yoffset)-1, cw/cf,*/
ce->dev_char);
}
/* The following function pscharoutline is written by Ein Terakawa. */
#define TOKEN_INITIAL 0
#define TOKEN_LINE 1
#define TOKEN_BEZ 2
#define ConvX(x) ((VFD_GET_X(x)-OUTLINE_OFFSET))
#define ConvY(x) ((OUTLINE_SIZE-(VFD_GET_Y(x)-OUTLINE_OFFSET)))
#define checklen(l) \
{cc += l; \
if (cc > 67) {EMITC('\n'); cc = 0;} \
else EMITC(' ');}
#define emitdata(x,y,i) {EMIT(outfp, "%d %d %c", (x), (y), i); checklen(12);}
#define emitdata0(x,y) {EMIT(outfp, "%d %d", (x), (y)); checklen(10);}
pscharoutline(w, h, outline)
int w, h;
long *outline;
{
long *ptr;
int token;
int cmd, dat;
int cc;
int initialx, initialy;
EMITC('{');
EMIT(outfp, "%.3f %.3f scale\n",
(float)w/OUTLINE_SIZE, (float)h/OUTLINE_SIZE);
ptr = &outline[2];
token = TOKEN_INITIAL;
cc = 0;
while (*ptr != 0) {
if (*ptr&VFD_TOKEN) {
cmd = *ptr++;
dat = *ptr++;;
if ((cmd&VFD_CWCURV) == VFD_CWCURV ||
(cmd&VFD_CCWCURV) == VFD_CCWCURV) {
if (token != TOKEN_INITIAL) {
if (token == TOKEN_BEZ) {
emitdata(initialx, initialy, 'c');
}
EMITS("closepath\n");
cc = 0;
}
emitdata(ConvX(dat), ConvY(dat), 'p');
initialx = ConvX(dat);
initialy = ConvY(dat);
} else if (token == TOKEN_BEZ) {
emitdata(ConvX(dat), ConvY(dat), 'c');
} else {
emitdata(ConvX(dat), ConvY(dat), 'l');
}
if ((cmd&VFD_BEZ) == VFD_BEZ)
token = TOKEN_BEZ;
else if ((cmd&VFD_LINE) == VFD_LINE)
token = TOKEN_LINE;
} else {
dat = *ptr++;
if (token == TOKEN_BEZ) {
emitdata(ConvX(dat), ConvY(dat), 'c');
} else {
emitdata(ConvX(dat), ConvY(dat), 'l');
}
}
if (token == TOKEN_BEZ) {
dat = *ptr++;
emitdata0(ConvX(dat), ConvY(dat));
dat = *ptr++;
emitdata0(ConvX(dat), ConvY(dat));
}
}
if (token == TOKEN_BEZ) {
emitdata(initialx, initialy, 'c');
}
EMITS("closepath eofill}");
/*
if(outline[0] & 1)
EMIT(outfp, "{0 0 p %d %d l %d 0 p 0 %d l 20 setlinewidth stroke}",
w,h,w,h);
else
EMIT(outfp, "{0 %d p 0 %d %d 0 %d 0 c %d 0 %d %d %d %d c %d %d %d %d %d %d c %d %d 0 %d 0 %d c closepath fill}",
h/2,h/4,w/4,w/2,w*3/4,w,h/4,w,h/2,
w,h*3/4,w*3/4,h,w/2,h,w/4,h,h*3/4,h/2);
*/
}
#endif
|