Ejemplo n.º 1
0
void pdf_startclip(gfxdevice_t*dev, gfxline_t*line)
{
    internal_t*i = (internal_t*)dev->internal;
    
    restore_matrix(i);
    PDF_save(i->p);
    
    if(mkline(line, i->p, i->config_xpad, i->config_ypad, 1.0, 1))
	PDF_clip(i->p);
    else   
	; // TODO: strictly speaking, an empty clip clears everything
    
    reset_matrix(i);
}
Ejemplo n.º 2
0
void pdf_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
{
    internal_t*i = (internal_t*)dev->internal;
    if(width<1e-6)
	return;
    reset_matrix(i);
    PDF_setlinewidth(i->p, width);
    PDF_setlinecap(i->p, cap_style==gfx_capButt?0:(cap_style==gfx_capRound?1:2));
    PDF_setlinejoin(i->p, joint_style==gfx_joinMiter?0:(joint_style==gfx_joinRound?1:2));
    
    PDF_setrgbcolor_stroke(i->p, color->r/255.0, color->g/255.0, color->b/255.0);

    if(joint_style==gfx_joinMiter)
	PDF_setmiterlimit(i->p, miterLimit);
    if(mkline(line, i->p, i->config_xpad, i->config_ypad, 1.0, 0))
	PDF_stroke(i->p);
}
Ejemplo n.º 3
0
void pdf_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
{
    internal_t*i = (internal_t*)dev->internal;
    reset_matrix(i);
    PDF_setrgbcolor_fill(i->p, color->r/255.0, color->g/255.0, color->b/255.0);
    /*
       pdf-x (pdf 1.3) doesn't support opacityfill
    if(color->a!=255) {
	char opacityfill[80];
	sprintf(opacityfill, "opacityfill %f", color->a/256.0);
	int gstate = PDF_create_gstate(i->p, opacityfill);
	PDF_set_gstate(i->p, gstate);
    }*/
	
    if(mkline(line, i->p, i->config_xpad, i->config_ypad, 1.0, 1)) {
	PDF_fill(i->p);
    }
}
Ejemplo n.º 4
0
/*
 * updateline() - like s_refresh() but only for cursor line 
 *
 * This determines whether or not we need to call s_refresh() to examine
 * the entire screen for changes. This occurs if the size of the cursor line
 * (in rows) has changed.
 */
static void
updateline(void)
{
    char           *ptr;
    int             col;
    int             size;
    int             j;

    if (RedrawingDisabled)	/* Is this the correct action ? */
	return;

    ptr = format_line(Curschar->linep->s, &col);

    size = 1 + ((col - 1) / Columns);
    if (Cline_size == size) {
	s_cursor_off();
	windgoto(Cline_row, 0);
	if (P(P_NU)) {
	    /*
	     * This should be done more efficiently. 
	     */
	    outstr(mkline(cntllines(Filemem, Curschar)));
	}
	outstr(ptr);

	j = col;
	col %= Columns;
	if ((col != 0) || (j == 0)) {
#ifdef T_END_L
	    windgoto(Cline_row + size - 1, col);
	    toutstr(T_END_L);
#else
	    for (; col < Columns; col++)
		outchar(' ');
#endif
	}
	s_cursor_on();
    } else {
	s_refresh(VALID_TO_CURSCHAR);
    }
}
Ejemplo n.º 5
0
void cmconf_append(struct cmconf *conf, const char *str)
{
	struct cmconf_line *newline;
	newline = mkline(str);
	list_add_tail(&newline->list, &conf->lines);
}
Ejemplo n.º 6
0
void cmconf_insert_after(struct cmconf_line *line, const char *str)
{
	struct cmconf_line *newline;
	newline = mkline(str);
	list_add_tail(&newline->list, &line->list);
}
Ejemplo n.º 7
0
void pdf_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
{
    internal_t*i = (internal_t*)dev->internal;

    if(!font)
	return;

    gfxglyph_t*glyph = &font->glyphs[glyphnr];
    char as_shape = 0;
    if(!type3 && !ttf) {msg("<warning> No type3 enabled. Drawing char %d as shape", glyphnr);as_shape=1;}
    if(glyphnr>256-32) {msg("<warning> Drawing char %d as shape (not < 224)", glyphnr);as_shape=1;}
	
    if(as_shape) {
	reset_matrix(i);
	PDF_setrgbcolor_fill(i->p, color->r/255.0, color->g/255.0, color->b/255.0);
	gfxline_t*line2 = gfxline_clone(glyph->line);
	gfxline_transform(line2, matrix);
	if(mkline(line2, i->p, i->config_xpad, i->config_ypad, 1.0, 1)) {
	    PDF_fill(i->p);
	}
	gfxline_free(line2);
    } else {
	assert(gfxfontlist_hasfont(i->fontlist, font));
	int fontid = (int)(ptroff_t)gfxfontlist_getuserdata(i->fontlist, font->id);

	gfxmatrix_t m = *matrix;

	m.m00*=64;
	m.m01*=64;
	m.m10*=64;
	m.m11*=64;
	if(ttf) {
	    m.m10 = -m.m10;
	    m.m11 = -m.m11;
	}

	if(!(fabs(m.m00 - i->m00) < 1e-6 &&
	     fabs(m.m01 - i->m01) < 1e-6 &&
	     fabs(m.m10 - i->m10) < 1e-6 &&
	     fabs(m.m11 - i->m11) < 1e-6)) {
	    set_matrix(i, m.m00, m.m01, m.m10, m.m11);
	}
	double tx, ty;
	transform_back(i, m.tx+i->config_xpad, m.ty+i->config_ypad, &tx, &ty);
	
	PDF_setfont(i->p, fontid, ttf?16.0:1.0);
	PDF_setrgbcolor_fill(i->p, color->r/255.0, color->g/255.0, color->b/255.0);

	char name[32];
	sprintf(name, "%c", glyphnr+32);

	if(fabs(tx - i->lastx) > 0.001 || ty != i->lasty) {
	    PDF_show_xy2(i->p, name, strlen(name), tx, ty);
	} else {
	    PDF_show2(i->p, name, strlen(name));
	}

	i->lastx = tx + glyph->advance;
	i->lasty = ty;
    }
}
Ejemplo n.º 8
0
void pdf_addfont(gfxdevice_t*dev, gfxfont_t*font)
{
    internal_t*i = (internal_t*)dev->internal;

    int num = font->num_glyphs<256-32?font->num_glyphs:256-32;
    if(type3) {
	int fontid = 0;
	if(!gfxfontlist_hasfont(i->fontlist, font)) {

	    static int fontnr = 1;
	    char fontname[32];
	    sprintf(fontname, "font%d", fontnr++);
	    int l = strlen(fontname);
	    char fontname2[64];
	    int t;
	    for(t=0;t<l+1;t++) {
		fontname2[t*2+0] = fontname[t];
		fontname2[t*2+1] = 0;
	    }

	    PDF_begin_font(i->p, fontname2, l*2, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0, "");
	    for(t=0;t<num;t++) {
		gfxglyph_t*g = &font->glyphs[t];
		gfxbbox_t bbox = gfxline_getbbox(g->line);
		char name[32];
		sprintf(name, "chr%d", t+32);
		PDF_encoding_set_char(i->p, fontname, t+32, name, 0);
		PDF_begin_glyph(i->p, name, g->advance, bbox.xmin/64.0, bbox.ymin/64.0, bbox.xmax/64.0, bbox.ymax/64.0);
		if(mkline(g->line, i->p, 0, 0, 1.0/64.0, 1))
		    PDF_fill(i->p);
		PDF_end_glyph(i->p);
	    }
	    PDF_end_font(i->p);
	    fontid = PDF_load_font(i->p, fontname2, l*2, fontname, "");
	    
	    i->fontlist = gfxfontlist_addfont2(i->fontlist, font, (void*)(ptroff_t)fontid);
	}
    } else if(ttf) {
	int fontid = 0;
	if(!gfxfontlist_hasfont(i->fontlist, font)) {
	    char fontname[32],filename[32],fontname2[64];
	    static int fontnr = 1;
	    sprintf(fontname, "font%d", fontnr);
	    sprintf(filename, "font%d.ttf", fontnr);
	    fontnr++;
	    const char*old_id = font->id;
	    font->id = fontname;
	    int t;
	    for(t=0;t<num;t++) {
		font->glyphs[t].unicode = 32+t;
	    }
	    font->max_unicode = 0;
	    font->unicode2glyph = 0;
	    gfxfont_save(font, filename);
	    font->id=old_id;
	    
#ifdef RUN_TTX
	    /* for testing the generated fonts: run everything through ttx (fonttools) */
	    char cmd[256];
	    sprintf(cmd, "mv %s.ttf test.ttf", fontname);system(cmd);
	    system("rm -f test.ttx");
	    if(system("ttx test.ttf")&0xff00) exit(1);
	    sprintf(cmd, "mv test.ttf %s.old.ttf", fontname, fontname);system(cmd);
	    sprintf(cmd, "ttx test.ttx;mv test.ttf %s.ttf", fontname);system(cmd);
	    sprintf(cmd, "rm -f test.ttx");system(cmd);
#endif
	   
	    int l = strlen(fontname);
	    for(t=0;t<l+1;t++) {
		fontname2[t*2+0] = fontname[t];
		fontname2[t*2+1] = 0;
	    }
	    
	    fontid = PDF_load_font(i->p, fontname2, l*2, "host", "embedding=true");
	    i->fontlist = gfxfontlist_addfont2(i->fontlist, font, (void*)(ptroff_t)fontid);
	    unlink(filename);
	}
    }
}