Exemplo n.º 1
0
static void container_processor(int type)
{
/*printf("container_processor(%04x)\n", type);
*/
	if (type == 0x03EE) {
		if (past_first_slide)
			emitchar('\f');
		else
			past_first_slide = 1;
	}
	switch (type) {
	case 0x000D:
		if (last_container == 0x11)		/* suppress notes info */
			output_this_container = 0;
		else
			output_this_container = 1;
		break;
	case 0x0FF0:
		output_this_container = 1;
		break;
	default:
/*		printf("Cont:%x|\n", type);	*/
		output_this_container = 0;
		break;
	}
	last_container = type;
}
Exemplo n.º 2
0
void
emit(Rune r)
{
	emitchar(r | attr);
	/*
	 * Close man page references early, so that 
	 * .IR proof (1),
	 * doesn't make the comma part of the link.
	 */
	if(r == ')')
		attr &= ~(1<<Anchor);
}
Exemplo n.º 3
0
int
main(int argc, char **argv)
{
	while(gets(line))
	{
		if (strstr(line, "FONT ") == line)
			fontname = strdup(line + 5);
		if (strstr(line, "FACE_NAME ") == line)
			facename = strdup(line + 10);
		if (strstr(line, "FAMILY_NAME ") == line)
			familyname = strdup(line + 12);
		if (strstr(line, "PIXEL_SIZE ") == line)
			sscanf(line, "%*s %d", &fontsize);
		if (strstr(line, "FONTBOUNDINGBOX") == line)
			sscanf(line, "%*s %d %d %d %d", fbbx+0, fbbx+1, fbbx+2, fbbx+3);
		if (strstr(line, "FONT_ASCENT") == line)
			sscanf(line, "%*s %d", &ascent);
		if (strstr(line, "FONT_DESCENT") == line)
			sscanf(line, "%*s %d", &descent);
		if (strstr(line, "ENDPROPERTIES") == line)
			emithead();

		if (strstr(line, "STARTCHAR") == line)
			charname = strdup(line + 10);
		if (strstr(line, "ENCODING") == line)
			encoding = atoi(line + 9);
		if (strstr(line, "SWIDTH") == line)
			swidth = atoi(line + 7);
		if (strstr(line, "DWIDTH") == line)
			dwidth = atoi(line + 7);
		if (strstr(line, "BBX") == line)
			sscanf(line + 4, "%d %d %d %d", bbx+0, bbx+1, bbx+2, bbx+3);
		if (strstr(line, "BITMAP") == line)
			readbitmap();
		if (strstr(line, "ENDCHAR") == line)
			emitchar();
	}
}
Exemplo n.º 4
0
static void atom_processor(int type, int count, int buf_last, unsigned char *working_buffer, int buf_idx)
{
	int i;
/*printf("atom_processor(%04x, %d, %d, %d)\n", type, count, buf_last, buf_idx);
*/
	if (output_this_container == 0) return;

	switch (type) {
	case 0x0FA0:	/* Text String in unicode */
/*printf("text string in unicode\n");
*/
		print_unicode(working_buffer, buf_idx);
		emitchar('\n');
		break;
	case 0x0FA8:	/* Text String in ASCII */
		for (i=0;i<buf_idx; i++) {
			if (working_buffer[i] == 0x0D) {
				emitchar('\n');
			} else {
				emitchar(working_buffer[i]);
			}
		}
		emitchar('\n');
		break;
	case 0x0FBA:	/* CString - unicode... */
/*printf("cstring - unicode\n");
*/
		print_unicode(working_buffer, buf_idx);
		emitchar('\n');
		break;
	case 0x03F3:	/* new sheet? */
		emitchar('\f');
		break;
	default:
/*printf("none of the above\n");
*/
		break;
	}
}
Exemplo n.º 5
0
void
xcmd(Biobuf *b)
{
	char *p, *fld[16], buf[1024];

	int i, nfld;

	p = getline(b);
	if(p == nil)
		sysfatal("xcmd error: %r");
	if(debug)
		fprint(2, "x command '%s'\n", p);
	nfld = tokenize(p, fld, nelem(fld));
	if(nfld == 0)
		return;
	switch(fld[0][0]){
	case 'f':
		/* mount font */
		if(nfld != 3)
			break;
		i = atoi(fld[1]);
		if(i<0 || Nfont<=i)
			sysfatal("font %d out of range at %s:#%d", i, filename, cno);
		mountfont(i, fld[2]);
		return;
	case 'i':
		/* init */
		return;
	case 'r':
		if(nfld<2 || atoi(fld[1])!=res)
			sysfatal("typesetter has unexpected resolution %s", fld[1]? fld[1] : "<unspecified>");
		return;
	case 's':
		/* stop */
		return;
	case 't':
		/* trailer */
		return;
	case 'T':
		if(nfld!=2 || strcmp(fld[1], "utf")!=0)
			sysfatal("output for unknown typesetter type %s", fld[1]);
		return;
	case 'X':
		if(nfld<3 || strcmp(fld[1], "html")!=0)
			break;
		/* is it a man reference of the form cp(1)? */
		/* X manref start/end cp (1) */
		if(nfld==6 && strcmp(fld[2], "manref")==0){
			/* was the right macro; is it the right form? */
			if(strlen(fld[5])>=3 &&
			   fld[5][0]=='(' && fld[5][2]==')' &&
			   '0'<=fld[5][1] && fld[5][1]<='9'){
				if(strcmp(fld[3], "start") == 0){
					/* set anchor attribute and remember string */
					attr |= (1<<Anchor);
					snprint(buf, sizeof buf,
						"<a href=\"/magic/man2html/%c/%s\">",
						fld[5][1], fld[4]);
					nanchors++;
					anchors = erealloc(anchors, nanchors*sizeof(char*));
					anchors[nanchors-1] = estrdup(buf);
				}else if(strcmp(fld[3], "end") == 0)
					attr &= ~(1<<Anchor);
			}
		}else if(strcmp(fld[2], "manPP") == 0){
			didP = 1;
			emitchar(Epp);
		}else if(nfld<4 || strcmp(fld[2], "manref")!=0){
			if(nfld>2 && strcmp(fld[2], "<P>")==0){	/* avoid triggering extra <br> */
				didP = 1;
				/* clear all font attributes before paragraph */
				emitchar(' ' | (attr & ~(0xFFFF|((1<<Italic)|(1<<Bold)|(1<<CW)))));
				emitstr("<P>");
				/* next emittec char will turn font attributes back on */
			}else if(nfld>2 && strcmp(fld[2], "<H4>")==0)
				attr |= (1<<Heading);
			else if(nfld>2 && strcmp(fld[2], "</H4>")==0)
				attr &= ~(1<<Heading);
			else if(debug)
				fprint(2, "unknown in-line html %s... at %s:%#d\n",
					fld[2], filename, cno);
		}
		return;
	}
	if(debug)
		fprint(2, "unknown or badly formatted x command %s\n", fld[0]);
}
Exemplo n.º 6
0
void
emitstr(char *s)
{
	emitchar(Estring);
	emitchar((Char)s);
}
Exemplo n.º 7
0
static void OutputCharCorrected(unsigned char c)
{
	switch (c) {	/* Special char handlers here... */
	case '\r':
		emitchar('\n');
		break;
	case 0x3C:
		emitchar('<');
		break;
	case 0x3E:
		emitchar('>');
		break;
	case 0x26:
		emitchar('&');
		break;
	case 0x22:
		emitchar('\'');
		break;
#if 0
	/* Also need to cover 128-159 since MS uses this area... */
	case 0x80:		/* Euro Symbol */
		html_string("&#8364;");
		break;
	case 0x82:		/* baseline single quote */
		html_string("&#8218;");
		break;
	case 0x83:		/* florin */
		html_string("&#402;");
		break;
	case 0x84:		/* baseline double quote */
		html_string("&#8222;");
		break;
	case 0x85:		/* ellipsis */
		html_string("&#8230;");
		break;
	case 0x86:		/* dagger */
		html_string("&#8224;");
		break;
	case 0x87:		/* double dagger */
		html_string("&#8225;");
		break;
	case 0x88:		/* circumflex accent */
		html_string("&#710;");
		break;
	case 0x89:		/* permile */
		html_string("&#8240;");
		break;
	case 0x8A:		/* S Hacek */
		html_string("&#352;");
		break;
	case 0x8B:		/* left single guillemet */
		html_string("&#8249;");
		break;
	case 0x8C:		/* OE ligature */
		html_string("&#338;");
		break;
	case 0x8E:		/*  #LATIN CAPITAL LETTER Z WITH CARON */
		html_string("&#381;");
		break;
	case 0x91:		/* left single quote ? */
		html_string("&#8216;");
		break;
	case 0x92:		/* right single quote ? */
		html_string("&#8217;");
		break;
	case 0x93:		/* left double quote */
		html_string("&#8220;");
		break;
	case 0x94:		/* right double quote */
		html_string("&#8221;");
		break;
	case 0x95:		/* bullet */
		html_string("&#8226;");
		break;
	case 0x96:		/* endash */
		html_string("&#8211;");
		break;
	case 0x97:		/* emdash */
		html_string("&#8212;");
		break;
	case 0x98:		/* tilde accent */
		html_string("&#732;");
		break;
	case 0x99:		/* trademark ligature */
		html_string("&#8482;");
		break;
	case 0x9A:		/* s Haceks Hacek */
		html_string("&#353;");
		break;
	case 0x9B:		/* right single guillemet */
		html_string("&#8250;");
		break;
	case 0x9C:		/* oe ligature */
		html_string("&#339;");
		break;
	case 0x9F:		/* Y Dieresis */
		html_string("&#376;");
		break;
#endif
	default:
		emitchar(c);
		break;
	}
}
Exemplo n.º 8
0
/* I must admit that I don't fully understand what this function does...

   It clears all but the 6 LSB, then sets the MSB. Ho hum.
*/
static void put_utf8(unsigned short c)
{
	emitchar(0x0080 | ((short)c & 0x003F));
}
Exemplo n.º 9
0
static void emitchar(int c)
{
	char name[1024];
	MwAniScript *as;
       
	if (mute) return;
       
	if (c == '\f') {

/* hack to prevent empty pages */
if (buf->sht[sht].cast == NULL) return;

		if (obi) emitchar('\n');	/* flush pending text */
		sht++;
		if (sht >= buf->nsht) {
			buffer_add_sheet(buf, sht);
		}
		y = 20;
	} else if (c == '\n') { /* break the current line */
		outbuf[obi] = '\0';
		if (!only_space(outbuf)) {
			if (buf->sht[sht].cast == NULL) {
				ao = MwMalloc(sizeof *ao);
				buf->sht[sht].cast = ao;
			} else {
				ao->next = MwMalloc(sizeof *ao);
				ao = ao->next;
			}
			ao->next = NULL;
			ao->type = MW_ANI_STRING;
			ao->fmt = fmt;
			sprintf(name, "String %d", nobj++);
			ao->name = MwStrdup(name);
			ao->string = MwStrdup(outbuf);
			as = MwMalloc(sizeof *as);
			ao->script = as;
			as->next = NULL;
			as->time = 0;
			as->x = 10;
			as->y = y;
			as->width = 500;
			as->height = 20;
			as->visible = TRUE;
		}
		y += 20;
		obi = 0;
	} else {
		if (obi > 60) {
			int i;
			char b[1024];
			/* try to split line */
			for (i = 60; i > 0 && outbuf[i] != ' '; i--);
			if (i) {
				strcpy(b, outbuf+i);
				outbuf[i] = '\0';
				emitchar('\n');
				for (i = 0; b[i]; i++) emitchar(b[i]);
			}
		}
		if (obi < 255) outbuf[obi++] = c;
	}
}