///////////////////////////////////////////////////////////////////////////// // SurfaceEps SurfaceEps::SurfaceEps( const std::string &filePath, double widthInPoints, double heightInPoints, bool enableLevel3 ) : SurfaceBase( (int32_t)widthInPoints, (int32_t)heightInPoints ) { mCairoSurface = cairo_ps_surface_create( filePath.c_str(), widthInPoints, heightInPoints ); cairo_ps_surface_set_eps( mCairoSurface, TRUE ); cairo_ps_surface_restrict_to_level( mCairoSurface, ( enableLevel3 ) ? CAIRO_PS_LEVEL_3 : CAIRO_PS_LEVEL_2 ); }
/* Worker function used by both export_ps and export_eps */ static void export_postscript (gboolean is_eps) { cairo_surface_t *surface; cairo_rectangle_t extents; cairo_matrix_t mtx; cairo_t *cr; GList *iter; /* Create a surface. To begin with, we don't know the size. */ surface = cairo_ps_surface_create (settings.outfile, 1, 1); cairo_ps_surface_set_eps (surface, is_eps); cr = cairo_create (surface); g_object_set (renderer, "cairo-context", cr, NULL); for (iter = geda_list_get_glist (toplevel->pages); iter != NULL; iter = g_list_next (iter)) { PAGE *page = (PAGE *) iter->data; export_layout_page (page, &extents, &mtx); cairo_ps_surface_set_size (surface, extents.width, extents.height); cairo_set_matrix (cr, &mtx); export_draw_page (page); cairo_show_page (cr); } cairo_surface_finish (surface); export_cairo_check_error (cairo_surface_status (surface)); }
static VALUE cr_ps_surface_set_eps (VALUE self, VALUE eps) { cairo_ps_surface_set_eps (_SELF, RTEST (eps)); cr_surface_check_status (_SELF); return Qnil; }
// cairo_public void // cairo_ps_surface_set_eps (cairo_surface_t *surface, // cairo_bool_t eps); static int l_cairo_ps_surface_set_eps(lua_State* L) { cairo_surface_t *surface = get_cairo_surface_t (L, 1); cairo_bool_t eps = (cairo_bool_t)luaL_checkinteger(L, 2); cairo_ps_surface_set_eps (surface, eps); return 0; }
static int surface_set_eps (lua_State *L) { cairo_surface_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_SURFACE); if (cairo_surface_get_type(*obj) != CAIRO_SURFACE_TYPE_PS) return luaL_error(L, "method 'set_eps' only works on PostScript" " surfaces"); cairo_ps_surface_set_eps(*obj, lua_toboolean(L, 2)); return 0; }
static cairo_test_status_t preamble (cairo_test_context_t *ctx) { cairo_surface_t *surface; /* get the error surface */ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, INT_MAX, INT_MAX); #if CAIRO_HAS_GL_SURFACE cairo_gl_surface_set_size (surface, 0, 0); cairo_gl_surface_swapbuffers (surface); #endif #if CAIRO_HAS_OS2_SURFACE cairo_os2_surface_set_hwnd (surface, 0); cairo_os2_surface_set_size (surface, 0, 0); cairo_os2_surface_set_manual_window_refresh (surface, FALSE); #endif #if CAIRO_HAS_PDF_SURFACE cairo_pdf_surface_restrict_to_version (surface, CAIRO_PDF_VERSION_1_4); cairo_pdf_surface_set_size (surface, 0, 0); #endif #if CAIRO_HAS_PS_SURFACE cairo_ps_surface_set_eps (surface, FALSE); cairo_ps_surface_set_size (surface, 0, 0); cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_2); cairo_ps_surface_dsc_comment (surface, NULL); cairo_ps_surface_dsc_begin_setup (surface); cairo_ps_surface_dsc_begin_page_setup (surface); #endif #if CAIRO_HAS_XCB_SURFACE cairo_xcb_surface_set_size (surface, 0, 0); #endif #if CAIRO_HAS_XLIB_SURFACE cairo_xlib_surface_set_size (surface, 0, 0); cairo_xlib_surface_set_drawable (surface, 0, 0, 0); #endif cairo_surface_set_mime_data (surface, NULL, NULL, 0, NULL, 0); cairo_surface_set_device_offset (surface, 0, 0); cairo_surface_set_fallback_resolution (surface, 0, 0); cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; }
/*================================================================================== pspltrgn - subroutine to set which small plot region to use This routine is called by pschem in psvdraw_new in order to plot multiple ternary chemographies on a single page. Each page can hold MAXPLOTSPERPAGE. If another is requested, then a new document will be created with a name similar to that of the first, and the process will begin again. This overrides any settings made in psssc2, and assumes that x and y (real-unit) bounds are 0.0-1.0. Note that if this routine is called, then plot_aspect_ratio will be ignored. Note that plotnum is a zero-based index ==================================================================================*/ void pspltrgn_ (int *plotnum) { char *outFileName = malloc((strlen(dmh_fileNameRoot)+50) * sizeof(char)); int plotPosition = *plotnum % MAXPLOTSPERPAGE; int pageNum = *plotnum / MAXPLOTSPERPAGE; int boxEdge, rowNum, colNum; DEBUGPRINT(("In pspltrgn. Plotnum = %i, plotPosition = %i, pageNum = %i\n", *plotnum, plotPosition, pageNum)); if (plotPosition == 0 && pageNum > 0) { /* we need to start a new page, so let's close the current one, and start a new one with a related name */ DEBUGPRINT(("In pspltrgn. Closing current page and starting a new one with\n page number=%i and file type=%i\n", pageNum, dmh_outputFileType)); closeSurface(); // close existing surface switch(dmh_outputFileType) { case PDFTYPE: sprintf(outFileName, "%s_%i.%s", dmh_fileNameRoot, pageNum, "pdf"); dmh_surf = cairo_pdf_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight); break; case PSTYPE: sprintf(outFileName, "%s_%i.%s", dmh_fileNameRoot, pageNum, "ps"); dmh_surf = cairo_ps_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight); cairo_ps_surface_set_eps (dmh_surf, 1); break; case SVGTYPE: sprintf(outFileName, "%s_%i.%s", dmh_fileNameRoot, pageNum, "svg"); dmh_surf = cairo_svg_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight); break; } dmh_cr = cairo_create (dmh_surf); cairo_identity_matrix(dmh_cr); cairo_set_line_join(dmh_cr, CAIRO_LINE_JOIN_ROUND); dmh_min_tracked_x = DBL_MAX; } /* Set the location on the page for the small plot */ dmh_aspectRatio = 1.0; /* Ignores plot_aspect_ratio. */ boxEdge = (dmh_pageWidth - LEFTMARGIN - RIGHTMARGIN - MULTIPLOTGUTTER) / 2; rowNum = plotPosition / 2; colNum = plotPosition % 2; dmh_xoffset = LEFTMARGIN + ((boxEdge + MULTIPLOTGUTTER) * colNum); dmh_yoffset = (dmh_pageHeight * 0.5) + (boxEdge * 1.5) + MULTIPLOTGUTTER - (boxEdge * (rowNum+1)) - (MULTIPLOTGUTTER * rowNum); dmh_xscale = boxEdge; dmh_yscale = boxEdge; DEBUGPRINT(("End pspltrgn. boxEdge=%i; r,c=(%i,%i); scale=(%f, %f); offset=(%f, %f); DevPtRange=(%f,%f)-(%f,%f).\n", boxEdge, rowNum, colNum, dmh_xscale, dmh_yscale, dmh_xoffset, dmh_yoffset,deviceX(0), deviceY(0), deviceX(1), deviceY(1))); }
void CairoBox::out_eps(const char* filename, int wpts, int hpts) { cairo_surface_t* surface; cairo_t* cr; surface = cairo_ps_surface_create (filename, wpts, hpts); cairo_ps_surface_set_eps(surface, 1); cr = cairo_create (surface); cairo_set_source_rgb (cr, 0, 0, 0); // user coordinates -- see cairo_ps_surface_create graphic(cr, 0, 0, wpts, hpts); cairo_show_page (cr); cairo_destroy (cr); cairo_surface_destroy (surface); return; }
/*================================================================================== psopen - opens a document for writing ==================================================================================*/ void psopen_(char *fname, int fnamelen) { char *outFileName; char outputType[255]; char pageWidthString[255]; char pageHeightString[255]; /* Set debug status based upon presence of file named 'debug_yes' in directory */ FILE *debugFile = fopen("debug_yes", "r"); if (debugFile == NULL) { dmh_debug = 0; } else { dmh_debug = 1; fclose(debugFile); } fname[fnamelen]='\0'; fname = trim(fname); outFileName = malloc((strlen(fname) + 50) * sizeof(char)); strcpy(outFileName, fname); DEBUGPRINT(("Found file name:%s of length: %lu\n", fname, strlen(fname))); dmh_fileNameRoot = malloc(255*sizeof(char)); strcpy(dmh_fileNameRoot, fname); /* Look for plot options file to specify what sort of output we want: SVG/PS/PDF Could use the Perplex routine to do this, but calling into C from fortran is bad enough. */ /* Default Values - If these get changed, then need to change the display in pscom_new.f as well */ if (!getOptionForKey("plot_output_type", outputType, 255)) { strcpy(outputType, "PDF"); } if (get2OptionsForKey("page_size", pageWidthString, pageHeightString, 255)) { DEBUGPRINT(("Found page size strings: (%s, %s)\n", pageWidthString, pageHeightString)); sscanf(pageWidthString, "%i", &dmh_pageWidth); sscanf(pageHeightString, "%i", &dmh_pageHeight); DEBUGPRINT(("Found page size values: (%i, %i)\n", dmh_pageWidth, dmh_pageHeight)); } else { dmh_pageWidth = 612; dmh_pageHeight = 792; } dmh_fontFace = malloc(255*sizeof(char)); if (!getCompleteOptionForKey("new_font", dmh_fontFace, 255)) { strcpy(dmh_fontFace, "Arial"); } if (!strcmp(outputType, "SVG") || !strcmp(outputType, "svg")) { dmh_outputFileType = SVGTYPE; strcat(outFileName, ".svg"); dmh_surf = cairo_svg_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight); } else if (!strcmp(outputType, "PS") || !strcmp(outputType, "ps")) { dmh_outputFileType = PSTYPE; strcat(outFileName, ".ps"); dmh_surf = cairo_ps_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight); cairo_ps_surface_set_eps (dmh_surf, 1); } else { /* PDF is the default if nothing is specified in the plot options file */ dmh_outputFileType = PDFTYPE; strcat(outFileName, ".pdf"); dmh_surf = cairo_pdf_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight); } dmh_cr = cairo_create (dmh_surf); cairo_identity_matrix(dmh_cr); cairo_set_line_join(dmh_cr, CAIRO_LINE_JOIN_ROUND); dmh_min_tracked_x = DBL_MAX; free(outFileName); }
static cairo_t * create_cairo(struct objlist *obj, N_VALUE *inst, char *fname, int iw, int ih, int *err) { cairo_surface_t *ps; cairo_t *cairo; double w, h; int format, dpi, r; struct gra2cairo_local *local; #ifdef WINDOWS fname = g_locale_from_utf8(fname, -1, NULL, NULL, NULL); #else /* WINDOWS */ fname = g_filename_from_utf8(fname, -1, NULL, NULL, NULL); #endif /* WINDOWS */ if (fname == NULL) { *err = CAIRO_STATUS_NO_MEMORY; return NULL; } *err = 0; _getobj(obj, "format", inst, &format); _getobj(obj, "dpi", inst, &dpi); _getobj(obj, "_local", inst, &local); w = iw * dpi / 25.4 / 100; h = ih * dpi / 25.4 / 100; switch (format) { case TYPE_PS2: ps = cairo_ps_surface_create(fname, w, h); cairo_ps_surface_restrict_to_level(ps, CAIRO_PS_LEVEL_2); cairo_ps_surface_set_eps(ps, FALSE); break; case TYPE_PS3: ps = cairo_ps_surface_create(fname, w, h); cairo_ps_surface_restrict_to_level(ps, CAIRO_PS_LEVEL_3); cairo_ps_surface_set_eps(ps, FALSE); break; case TYPE_EPS2: ps = cairo_ps_surface_create(fname, w, h); cairo_ps_surface_restrict_to_level(ps, CAIRO_PS_LEVEL_2); cairo_ps_surface_set_eps(ps, TRUE); break; case TYPE_EPS3: ps = cairo_ps_surface_create(fname, w, h); cairo_ps_surface_restrict_to_level(ps, CAIRO_PS_LEVEL_3); cairo_ps_surface_set_eps(ps, TRUE); break; case TYPE_PDF: ps = cairo_pdf_surface_create(fname, w, h); break; case TYPE_SVG1_1: ps = cairo_svg_surface_create(fname, w, h); cairo_svg_surface_restrict_to_version(ps, CAIRO_SVG_VERSION_1_1); break; case TYPE_SVG1_2: ps = cairo_svg_surface_create(fname, w, h); cairo_svg_surface_restrict_to_version(ps, CAIRO_SVG_VERSION_1_2); break; case TYPE_PNG: ps = cairo_image_surface_create(CAIRO_FORMAT_RGB24, w, h); break; #ifdef CAIRO_HAS_WIN32_SURFACE case TYPE_EMF: ps = open_emf(dpi, fname); if (ps == NULL) { g_free(fname); return NULL; } break; #endif /* CAIRO_HAS_WIN32_SURFACE */ default: ps = cairo_ps_surface_create(fname, w, h); } g_free(fname); r = cairo_surface_status(ps); if (r != CAIRO_STATUS_SUCCESS) { *err = r; cairo_surface_destroy(ps); return NULL; } cairo = cairo_create(ps); /* cairo_create() references target, so you can immediately call cairo_surface_destroy() on it */ cairo_surface_destroy(ps); r = cairo_status(cairo); if (r != CAIRO_STATUS_SUCCESS) { *err = r; cairo_destroy(cairo); return NULL; } switch (format) { case TYPE_PNG: cairo_set_source_rgb(cairo, 1, 1, 1); cairo_paint(cairo); cairo_new_path(cairo); break; } return cairo; }
static cairo_test_status_t test_cairo_ps_surface_set_eps (cairo_surface_t *surface) { cairo_ps_surface_set_eps (surface, TRUE); return CAIRO_TEST_SUCCESS; }
static void BM_NewPage(const pGEcontext gc, pDevDesc dd) { pX11Desc xd = (pX11Desc) dd->deviceSpecific; char buf[PATH_MAX]; cairo_status_t res; xd->npages++; if (xd->type == PNG || xd->type == JPEG || xd->type == BMP) { if (xd->npages > 1) { /* try to preserve the page we do have */ BM_Close_bitmap(xd); if (xd->fp) fclose(xd->fp); } snprintf(buf, PATH_MAX, xd->filename, xd->npages); xd->fp = R_fopen(R_ExpandFileName(buf), "wb"); if (!xd->fp) error(_("could not open file '%s'"), buf); } else if(xd->type == PNGdirect || xd->type == TIFF) { if (xd->npages > 1) { xd->npages--; BM_Close_bitmap(xd); xd->npages++; } } #ifdef HAVE_CAIRO_SVG else if(xd->type == SVG) { if (xd->npages > 1 && xd->cs) { cairo_show_page(xd->cc); if(!xd->onefile) { cairo_surface_destroy(xd->cs); cairo_destroy(xd->cc); } } if(xd->npages == 1 || !xd->onefile) { snprintf(buf, PATH_MAX, xd->filename, xd->npages); xd->cs = cairo_svg_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { xd->cs = NULL; error("cairo error '%s'", cairo_status_to_string(res)); } if(xd->onefile) cairo_svg_surface_restrict_to_version(xd->cs, CAIRO_SVG_VERSION_1_2); xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } cairo_set_antialias(xd->cc, xd->antialias); } } #endif #ifdef HAVE_CAIRO_PDF else if(xd->type == PDF) { if (xd->npages > 1) { cairo_show_page(xd->cc); if(!xd->onefile) { cairo_surface_destroy(xd->cs); cairo_destroy(xd->cc); } } if(xd->npages == 1 || !xd->onefile) { snprintf(buf, PATH_MAX, xd->filename, xd->npages); xd->cs = cairo_pdf_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } cairo_set_antialias(xd->cc, xd->antialias); } } #endif #ifdef HAVE_CAIRO_PS else if(xd->type == PS) { if (xd->npages > 1 && !xd->onefile) { cairo_show_page(xd->cc); cairo_surface_destroy(xd->cs); cairo_destroy(xd->cc); } if(xd->npages == 1 || !xd->onefile) { snprintf(buf, PATH_MAX, xd->filename, xd->npages); xd->cs = cairo_ps_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } // We already require >= 1.2 #if CAIRO_VERSION_MAJOR > 2 || CAIRO_VERSION_MINOR >= 6 if(!xd->onefile) cairo_ps_surface_set_eps(xd->cs, TRUE); #endif xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } cairo_set_antialias(xd->cc, xd->antialias); } } #endif else error(_("unimplemented cairo-based device")); cairo_reset_clip(xd->cc); if (xd->type == PNG || xd->type == TIFF|| xd->type == PNGdirect) { /* First clear it */ cairo_set_operator (xd->cc, CAIRO_OPERATOR_CLEAR); cairo_paint (xd->cc); cairo_set_operator (xd->cc, CAIRO_OPERATOR_OVER); xd->fill = gc->fill; } else xd->fill = R_OPAQUE(gc->fill) ? gc->fill: xd->canvas; CairoColor(xd->fill, xd); cairo_new_path(xd->cc); cairo_paint(xd->cc); }
void Board::saveCairo( const char * filename, CairoType type, double pageWidth, double pageHeight, double margin ) const { cairo_surface_t *surface; cairo_t *cr; double cairoWidth, cairoHeight; TransformCairo transform; Rect box = boundingBox(); bool clipping = _clippingPath.size() > 2; if ( clipping ) box = box && _clippingPath.boundingBox(); transform.setBoundingBox( box, pageWidth, pageHeight, margin ); if ( pageWidth > 0 && pageHeight > 0 ) { cairoWidth = pageWidth; cairoHeight = pageHeight; } else { cairoWidth = box.width; cairoHeight = box.height; } switch (type) { case CairoPDF: surface = cairo_pdf_surface_create (filename, cairoWidth, cairoHeight); break; case CairoPS: surface = cairo_ps_surface_create (filename, cairoWidth, cairoHeight); break; case CairoEPS: surface = cairo_ps_surface_create (filename, cairoWidth, cairoHeight); cairo_ps_surface_set_eps(surface, true); break; case CairoSVG: surface = cairo_svg_surface_create (filename, cairoWidth, cairoHeight); break; case CairoPNG: default: surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, cairoWidth, cairoHeight); } cr = cairo_create (surface); /* For 1.0 x 1.0 coordinate space */ //cairo_scale (cr, cairoWidth, cairoHeight); //temp: http://zetcode.com/tutorials/cairographicstutorial/basicdrawing/ //temp: http://www.graphviz.org/pub/scm/graphviz-cairo/plugin/cairo/gvrender_cairo.c // Draw the background color if needed. if ( _backgroundColor != Color::None ) { Rectangle r( box, Color::None, _backgroundColor, 0.0 ); r.flushCairo( cr, transform ); } // Draw the shapes. std::vector< Shape* > shapes = _shapes; stable_sort( shapes.begin(), shapes.end(), shapeGreaterDepth ); std::vector< Shape* >::const_iterator i = shapes.begin(); std::vector< Shape* >::const_iterator end = shapes.end(); while ( i != end ) { (*i)->flushCairo( cr, transform ); ++i; } if (type==CairoPNG) cairo_surface_write_to_png (surface, filename); cairo_destroy (cr); cairo_surface_destroy (surface); }
static Rboolean BM_Open(pDevDesc dd, pX11Desc xd, int width, int height) { char buf[PATH_MAX]; cairo_status_t res; if (xd->type == PNG || xd->type == JPEG || xd->type == TIFF || xd->type == BMP || xd->type == PNGdirect) { xd->cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, xd->windowWidth, xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_set_operator(xd->cc, CAIRO_OPERATOR_OVER); cairo_reset_clip(xd->cc); cairo_set_antialias(xd->cc, xd->antialias); } #ifdef HAVE_CAIRO_SVG else if(xd->type == SVG) { snprintf(buf, PATH_MAX, xd->filename, xd->npages + 1); xd->cs = cairo_svg_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { xd->cs = NULL; warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } if(xd->onefile) cairo_svg_surface_restrict_to_version(xd->cs, CAIRO_SVG_VERSION_1_2); xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_set_antialias(xd->cc, xd->antialias); } #endif #ifdef HAVE_CAIRO_PDF else if(xd->type == PDF) { snprintf(buf, PATH_MAX, xd->filename, xd->npages + 1); xd->cs = cairo_pdf_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_surface_set_fallback_resolution(xd->cs, xd->fallback_dpi, xd->fallback_dpi); xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_set_antialias(xd->cc, xd->antialias); } #endif #ifdef HAVE_CAIRO_PS else if(xd->type == PS) { snprintf(buf, PATH_MAX, xd->filename, xd->npages + 1); xd->cs = cairo_ps_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } // We already require >= 1.2 #if CAIRO_VERSION_MAJOR > 2 || CAIRO_VERSION_MINOR >= 6 if(!xd->onefile) cairo_ps_surface_set_eps(xd->cs, TRUE); #endif cairo_surface_set_fallback_resolution(xd->cs, xd->fallback_dpi, xd->fallback_dpi); xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_set_antialias(xd->cc, xd->antialias); } #endif else error(_("unimplemented cairo-based device")); return TRUE; }
bool QCairoPaintEngine::begin(QPaintDevice *pd) { if (surface) { end(); } const QCairoPaintDevice* cpd=dynamic_cast<const QCairoPaintDevice*>(pd); surface = NULL; if (cpd) { exportText=cpd->getExportText(); QCairoPaintDevice::CairoFileType ft=cpd->getFileType(); QSizeF s=cpd->getFileSizeMM(); //qDebug()<<ft; if (ft==QCairoPaintDevice::cftPDF14) { //qDebug()<< "Cairo-PDF1.4"; surface = cairo_pdf_surface_create (cpd->getFileName().toLocal8Bit().data(), s.width()/25.4*72.0, s.height()/25.4*72.0); cairo_pdf_surface_restrict_to_version(surface, CAIRO_PDF_VERSION_1_4); } else if (ft==QCairoPaintDevice::cftPDF15) { //Debug()<< "Cairo-PDF1.5"<<s<<s.width()/25.4*72.0<<s.height()/25.4*72.0; surface = cairo_pdf_surface_create (cpd->getFileName().toLocal8Bit().data(), s.width()/25.4*72.0, s.height()/25.4*72.0); cairo_pdf_surface_restrict_to_version(surface, CAIRO_PDF_VERSION_1_5); } else if (ft==QCairoPaintDevice::cftPS2) { //qDebug()<< "Cairo-PS2"; surface = cairo_ps_surface_create (cpd->getFileName().toLocal8Bit().data(), s.width()/25.4*72.0, s.height()/25.4*72.0); cairo_ps_surface_restrict_to_level(surface, CAIRO_PS_LEVEL_2); } else if (ft==QCairoPaintDevice::cftPS3) { //qDebug()<< "Cairo-PS3"; surface = cairo_ps_surface_create (cpd->getFileName().toLocal8Bit().data(), s.width()/25.4*72.0, s.height()/25.4*72.0); cairo_ps_surface_restrict_to_level(surface, CAIRO_PS_LEVEL_2); } else if (ft==QCairoPaintDevice::cftEPS2) { //qDebug()<< "Cairo-EPS2"; surface = cairo_ps_surface_create (cpd->getFileName().toLocal8Bit().data(), s.width()/25.4*72.0, s.height()/25.4*72.0); cairo_ps_surface_restrict_to_level(surface, CAIRO_PS_LEVEL_2); cairo_ps_surface_set_eps(surface, 1); } else if (ft==QCairoPaintDevice::cftEPS3) { //qDebug()<< "Cairo-EPS3"; surface = cairo_ps_surface_create (cpd->getFileName().toLocal8Bit().data(), s.width()/25.4*72.0, s.height()/25.4*72.0); cairo_ps_surface_restrict_to_level(surface, CAIRO_PS_LEVEL_2); cairo_ps_surface_set_eps(surface, 1); } else if (ft==QCairoPaintDevice::cftSVG11) { //qDebug()<< "Cairo-SVG11"; surface = cairo_svg_surface_create (cpd->getFileName().toLocal8Bit().data(), s.width()/25.4*72.0, s.height()/25.4*72.0); cairo_svg_surface_restrict_to_version(surface, CAIRO_SVG_VERSION_1_1); } else if (ft==QCairoPaintDevice::cftSVG12) { //qDebug()<< "Cairo-SVG12"; surface = cairo_svg_surface_create (cpd->getFileName().toLocal8Bit().data(), s.width()/25.4*72.0, s.height()/25.4*72.0); cairo_svg_surface_restrict_to_version(surface, CAIRO_SVG_VERSION_1_2); } } if (surface) { if (cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS) { cr = cairo_create(surface); if (cr) { if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) { qDebug()<<"QCairoPaintDevice error initializing CAIRO: "<<cairo_status_to_string(cairo_status(cr)); end(); return false; } else { cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT); } } else { qDebug()<<"QCairoPaintDevice error initializing CAIRO !!!"; end(); return false; } } else { qDebug()<<"QCairoPaintDevice error creating surface: "<<cairo_status_to_string(cairo_surface_status(surface)); end(); return false; } } else { qDebug()<<"UNKNOWN QCairoPaintDevice type !!!"; return false; } return true; }