예제 #1
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);
    }
}
예제 #2
0
PDFLIB_API void PDFLIB_CALL
PDF_setrgbcolor(PDF *p, float red, float green, float blue)
{
    if (PDF_SANITY_CHECK_FAILED(p))
	return;

    if (red < 0.0 || red > EPSILON || green < 0.0 || green > EPSILON ||
	blue < 0.0 || blue > EPSILON) {
	pdf_error(p, PDF_NonfatalError, 
	    "Bogus color value (%f/%f/%f) in PDF_setrgbcolor",
	    red, green, blue);
	return;
    }

    if (red == green && green == blue)
	PDF_setgray(p, red);
    else {
	PDF_setrgbcolor_fill(p, red, green, blue);
	PDF_setrgbcolor_stroke(p, red, green, blue);
    }
}
예제 #3
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;
    }
}