29#include "../core/ps.h"
46 PostscriptDocument
doc;
53 ctxt->
doc.osHeader() <<
s;
60 ctxt->
doc.osBody() <<
s;
67 ctxt->
doc.osFooter() <<
s;
76 gvprintf(job,
"%%%%Creator: %s version %s (%s)\n",
88 gvprintf(job,
"%%%%BoundingBox: %d %d %d %d\n",
91 gvputs(job,
"end\nrestore\n");
99 class StreamBuf_Swapper
102 StreamBuf_Swapper(ostream & orig, ostream & replacement)
103 : buf_(orig.rdbuf()), str_(orig)
105 orig.rdbuf(replacement.rdbuf());
112 std::streambuf * buf_;
114 } swapper(cout, output);
117 ctxt->
doc.write(cout);
120 gvputs(job, output.str().c_str());
135 gvputs(job,
"%%Pages: (atend)\n");
137 gvputs(job,
"%%Pages: 1\n");
140 gvputs(job,
"%%BoundingBox: (atend)\n");
142 gvprintf(job,
"%%%%BoundingBox: %d %d %d %d\n",
146 gvputs(job,
"%%EndComments\nsave\n");
160 gvprintf(job,
"[ {Catalog} << /URI << /Base %s >> >>\n"
166 gvprintf(job,
"%d %d setlayer\n", layerNum, numLayers);
176 gvprintf(job,
"%%%%PageBoundingBox: %d %d %d %d\n",
178 gvprintf(job,
"%%%%PageOrientation: %s\n",
179 (job->
rotation ?
"Landscape" :
"Portrait"));
181 gvprintf(job,
"<< /PageSize [%d %d] >> setpagedevice\n",
183 gvprintf(job,
"%d %d %d beginpage\n",
186 gvprintf(job,
"gsave\n%d %d %d %d boxprim clip newpath\n",
188 gvprintf(job,
"%g %g set_scale %d rotate %g %g translate\n",
196 job->
common->
errorfn(
"canvas size (%d,%d) exceeds PDF limit (%d)\n"
197 "\t(suggest setting a bounding box size, see dot(1))\n",
199 gvprintf(job,
"[ /CropBox [%d %d %d %d] /PAGES pdfmark\n",
207 gvputs(job,
"0 0 0 edgecolor\n");
212 gvputs(job,
"endpage\nshowpage\ngrestore\n");
213 gvputs(job,
"%%PageTrailer\n");
227 gvputs(job,
"grestore\n");
237 gvputs(job,
"grestore\n");
248 gvputs(job,
"grestore\n");
256 gvputs(job,
"[ /Rect [ ");
259 gvprintf(job,
" /Border [ 0 0 0 ]\n"
260 " /Action << /Subtype /URI /URI %s >>\n"
273 gvputs(job,
" setlinewidth\n");
275 while (
s && (p = line = *
s++)) {
276 if (line == std::string{
"setlinewidth"})
287 if (line == std::string{
"invis"})
313 gvprintf(job,
"%.3g %.3g %.3g %scolor\n",
321 const PangoFontDescription *pango_font;
332 pango_font = pango_layout_get_font_description((PangoLayout*)(span->
layout));
333 font = pango_font_description_get_family(pango_font);
334 switch (pango_font_description_get_stretch(pango_font)) {
335 case PANGO_STRETCH_ULTRA_CONDENSED: stretch = ULTRACONDENSED;
break;
336 case PANGO_STRETCH_EXTRA_CONDENSED: stretch = EXTRACONDENSED;
break;
337 case PANGO_STRETCH_CONDENSED: stretch = CONDENSED;
break;
338 case PANGO_STRETCH_SEMI_CONDENSED: stretch = SEMICONDENSED;
break;
339 case PANGO_STRETCH_NORMAL: stretch = NORMAL_STRETCH;
break;
340 case PANGO_STRETCH_SEMI_EXPANDED: stretch = SEMIEXPANDED;
break;
341 case PANGO_STRETCH_EXPANDED: stretch = EXPANDED;
break;
342 case PANGO_STRETCH_EXTRA_EXPANDED: stretch = EXTRAEXPANDED;
break;
343 case PANGO_STRETCH_ULTRA_EXPANDED: stretch = ULTRAEXPANDED;
break;
347 switch (pango_font_description_get_style(pango_font)) {
348 case PANGO_STYLE_NORMAL: style = NORMAL_STYLE;
break;
349 case PANGO_STYLE_OBLIQUE: style = OBLIQUE;
break;
350 case PANGO_STYLE_ITALIC: style =
ITALIC;
break;
354 switch (pango_font_description_get_variant(pango_font)) {
355 case PANGO_VARIANT_NORMAL: variant = NORMAL_VARIANT;
break;
356 case PANGO_VARIANT_SMALL_CAPS: variant = SMALLCAPS;
break;
357#if PANGO_VERSION_CHECK(1, 50, 0)
358 case PANGO_VARIANT_ALL_SMALL_CAPS: variant = SMALLCAPS;
break;
359 case PANGO_VARIANT_PETITE_CAPS: variant = SMALLCAPS;
break;
360 case PANGO_VARIANT_ALL_PETITE_CAPS: variant = SMALLCAPS;
break;
361 case PANGO_VARIANT_UNICASE: variant = SMALLCAPS;
break;
362 case PANGO_VARIANT_TITLE_CAPS: variant = SMALLCAPS;
break;
367 switch (pango_font_description_get_weight(pango_font)) {
368#if PANGO_VERSION_CHECK(1, 24, 0)
369 case PANGO_WEIGHT_THIN: weight = ULTRALIGHT;
break;
371 case PANGO_WEIGHT_ULTRALIGHT: weight = ULTRALIGHT;
break;
372 case PANGO_WEIGHT_LIGHT: weight = LIGHT;
break;
373#if PANGO_VERSION_CHECK(1, 36, 7)
374 case PANGO_WEIGHT_SEMILIGHT: weight = LIGHT;
break;
376#if PANGO_VERSION_CHECK(1, 24, 0)
377 case PANGO_WEIGHT_BOOK: weight = NORMAL_WEIGHT;
break;
379 case PANGO_WEIGHT_NORMAL: weight = NORMAL_WEIGHT;
break;
380#if PANGO_VERSION_CHECK(1, 24, 0)
381 case PANGO_WEIGHT_MEDIUM: weight = NORMAL_WEIGHT;
break;
383 case PANGO_WEIGHT_SEMIBOLD: weight =
BOLD;
break;
384 case PANGO_WEIGHT_BOLD: weight =
BOLD;
break;
385 case PANGO_WEIGHT_ULTRABOLD: weight = ULTRABOLD;
break;
386 case PANGO_WEIGHT_HEAVY: weight = HEAVY;
break;
387#if PANGO_VERSION_CHECK(1, 24, 0)
388 case PANGO_WEIGHT_ULTRAHEAVY: weight = HEAVY;
break;
397 stretch = NORMAL_STRETCH;
401 style = NORMAL_STYLE;
402 variant = NORMAL_VARIANT;
406 weight = NORMAL_WEIGHT;
411 ctxt->
doc.osBody() << setFont(
font, style, weight, variant, stretch) << setFontSize(span->
font->
size) <<
"\n";
412 switch (span->
just) {
421 p.
x -= span->
size.
x / 2.0;
427 ctxt->
doc.osBody() << show(span->
str) <<
"\n";
437 AA[1].
x =
A[1].x -
A[0].x;
438 AA[1].
y =
A[1].y -
A[0].y;
443 gvputs(job,
" ellipse_path fill\n");
449 gvputs(job,
" ellipse_path stroke\n");
459 for (
size_t j = 1; j < n; j += 3) {
461 gvputs(job,
" curveto\n");
463 gvputs(job,
"closepath fill\n");
471 for (
size_t j = 1; j < n; j += 3) {
473 gvputs(job,
" curveto\n");
485 for (
size_t j = 1; j < n; j++) {
489 gvputs(job,
"closepath fill\n");
497 for (
size_t j = 1; j < n; j++) {
501 gvputs(job,
"closepath stroke\n");
512 for (
size_t j = 1; j < n; j++) {
609 {0,
nullptr, 0,
nullptr,
nullptr}
616 {0,
nullptr, 0,
nullptr,
nullptr}
static double len(glCompPoint p)
char * agnameof(void *)
returns a string descriptor for the object.
#define GVRENDER_NO_WHITE_BG
#define GVDEVICE_DOES_PAGES
#define GVDEVICE_DOES_LAYERS
#define GVRENDER_DOES_MAPS
#define GVRENDER_DOES_TRANSFORM
#define GVRENDER_DOES_MAP_RECTANGLE
static void color(Agraph_t *g)
int gvputs(GVJ_t *job, const char *s)
void gvprintpointflist(GVJ_t *job, pointf *p, size_t n)
void gvprintpointf(GVJ_t *job, pointf p)
void gvprintf(GVJ_t *job, const char *format,...)
void gvprintdouble(GVJ_t *job, double num)
static gvrender_engine_t lasi_engine
static size_t lasi_head_writer(GVJ_t *job, const char *s, size_t len)
static void lasi_begin_graph(GVJ_t *job)
static gvdevice_features_t device_features_eps
static void lasi_end_cluster(GVJ_t *job)
static size_t lasi_footer_writer(GVJ_t *job, const char *s, size_t len)
static size_t lasi_body_writer(GVJ_t *job, const char *s, size_t len)
static void lasi_end_edge(GVJ_t *job)
gvplugin_installed_t gvdevice_lasi_types[]
static void lasi_begin_cluster(GVJ_t *job)
static void lasi_begin_anchor(GVJ_t *job, char *url, char *, char *, char *)
static void lasi_comment(GVJ_t *job, char *str)
static void lasi_end_node(GVJ_t *job)
static void ps_set_color(GVJ_t *job, gvcolor_t *color)
static void lasi_begin_edge(GVJ_t *job)
static void lasi_polygon(GVJ_t *job, pointf *A, size_t n, int filled)
#define PDFMAX
Maximum size of PDF page.
static void lasi_library_shape(GVJ_t *job, char *name, pointf *A, size_t n, int filled)
static gvdevice_features_t device_features_ps
gvplugin_installed_t gvrender_lasi_types[]
static void lasi_textspan(GVJ_t *job, pointf p, textspan_t *span)
static void lasi_begin_node(GVJ_t *job)
static void lasi_end_job(GVJ_t *job)
static void lasi_polyline(GVJ_t *job, pointf *A, size_t n)
static void lasi_begin_job(GVJ_t *job)
static void lasi_begin_page(GVJ_t *job)
static void lasi_end_page(GVJ_t *job)
static gvrender_features_t render_features_lasi
static void lasi_ellipse(GVJ_t *job, pointf *A, int filled)
static void lasi_begin_layer(GVJ_t *job, char *, int layerNum, int numLayers)
static void lasi_bezier(GVJ_t *job, pointf *A, size_t n, int filled)
static void ps_set_pen_style(GVJ_t *job)
textitem scanner parser str
#define PRISIZE_T
PRIu64 alike for printing size_t
static const char * ps_txt[]
void epsf_define(GVJ_t *job)
char * ps_string(char *ins, int chset)
void cat_libfile(GVJ_t *job, const char **arglib, const char **stdlib)
size_t(*)(GVJ_t *, const char *, size_t) write_fn
void(* errorfn)(const char *fmt,...)
const char ** show_boxes
emit code for correct box coordinates
int viewNum
rendering state
size_t(* write_fn)(GVJ_t *job, const char *s, size_t len)
gvplugin_active_render_t render
PostscriptAlias * postscript_alias
double yoffset_centerline