48 PostscriptDocument *
doc;
51 static size_t lasi_head_writer(
GVJ_t * job,
const char *
s,
size_t len)
57 static size_t lasi_body_writer(
GVJ_t * job,
const char *
s,
size_t len)
63 static size_t lasi_footer_writer(
GVJ_t * job,
const char *s,
size_t len)
69 static void lasi_begin_job(
GVJ_t * job)
71 doc =
new PostscriptDocument;
76 gvprintf(job,
"%%%%Creator: %s version %s (%s)\n",
80 static void lasi_end_job(
GVJ_t * job)
89 gvprintf(job,
"%%%%BoundingBox: %d %d %d %d\n",
92 gvputs(job,
"end\nrestore\n");
101 class StreamBuf_Swapper
104 StreamBuf_Swapper(ostream & orig, ostream & replacement)
105 : buf_(orig.rdbuf()), str_(orig)
107 orig.rdbuf(replacement.rdbuf());
114 std::streambuf * buf_;
116 } swapper(cout, output);
121 gvputs(job, output.str().c_str());
127 static void lasi_begin_graph(
GVJ_t * job)
138 gvputs(job,
"%%Pages: (atend)\n");
140 gvputs(job,
"%%Pages: 1\n");
143 gvputs(job,
"%%BoundingBox: (atend)\n");
145 gvprintf(job,
"%%%%BoundingBox: %d %d %d %d\n",
149 gvputs(job,
"%%EndComments\nsave\n");
174 gvprintf(job,
"[ {Catalog} << /URI << /Base %s >> >>\n"
178 static void lasi_begin_layer(
GVJ_t * job,
char *layername,
int layerNum,
int numLayers)
180 gvprintf(job,
"%d %d setlayer\n", layerNum, numLayers);
183 static void lasi_begin_page(
GVJ_t * job)
190 gvprintf(job,
"%%%%PageBoundingBox: %d %d %d %d\n",
192 gvprintf(job,
"%%%%PageOrientation: %s\n",
193 (job->
rotation ?
"Landscape" :
"Portrait"));
195 gvprintf(job,
"<< /PageSize [%d %d] >> setpagedevice\n",
197 gvprintf(job,
"%d %d %d beginpage\n",
200 gvprintf(job,
"gsave\n%d %d %d %d boxprim clip newpath\n",
202 gvprintf(job,
"%g %g set_scale %d rotate %g %g translate\n",
210 job->
common->
errorfn(
"canvas size (%d,%d) exceeds PDF limit (%d)\n"
211 "\t(suggest setting a bounding box size, see dot(1))\n",
213 gvprintf(job,
"[ /CropBox [%d %d %d %d] /PAGES pdfmark\n",
218 static void lasi_end_page(
GVJ_t * job)
221 gvputs(job,
"0 0 0 edgecolor\n");
227 gvputs(job,
"endpage\nshowpage\ngrestore\n");
228 gvputs(job,
"%%PageTrailer\n");
232 static void lasi_begin_cluster(
GVJ_t * job)
240 static void lasi_end_cluster(
GVJ_t * job)
242 gvputs(job,
"grestore\n");
245 static void lasi_begin_node(
GVJ_t * job)
250 static void lasi_end_node(
GVJ_t * job)
252 gvputs(job,
"grestore\n");
256 lasi_begin_edge(
GVJ_t * job)
261 static void lasi_end_edge(
GVJ_t * job)
263 gvputs(job,
"grestore\n");
266 static void lasi_begin_anchor(
GVJ_t *job,
char *url,
char *tooltip,
char *target,
char *
id)
271 gvputs(job,
"[ /Rect [ ");
274 gvprintf(job,
" /Border [ 0 0 0 ]\n"
275 " /Action << /Subtype /URI /URI %s >>\n"
282 static void ps_set_pen_style(
GVJ_t *job)
288 gvputs(job,
" setlinewidth\n");
290 while (s && (p = line = *s++)) {
291 if (strcmp(line,
"setlinewidth") == 0)
302 if (strcmp(line,
"invis") == 0)
328 gvprintf(job,
"%.3g %.3g %.3g %scolor\n",
337 const PangoFontDescription *pango_font;
348 pango_font = pango_layout_get_font_description((PangoLayout*)(span->
layout));
349 font = pango_font_description_get_family(pango_font);
350 switch (pango_font_description_get_stretch(pango_font)) {
351 case PANGO_STRETCH_ULTRA_CONDENSED: stretch = ULTRACONDENSED;
break;
352 case PANGO_STRETCH_EXTRA_CONDENSED: stretch = EXTRACONDENSED;
break;
353 case PANGO_STRETCH_CONDENSED: stretch = CONDENSED;
break;
354 case PANGO_STRETCH_SEMI_CONDENSED: stretch = SEMICONDENSED;
break;
355 case PANGO_STRETCH_NORMAL: stretch = NORMAL_STRETCH;
break;
356 case PANGO_STRETCH_SEMI_EXPANDED: stretch = SEMIEXPANDED;
break;
357 case PANGO_STRETCH_EXPANDED: stretch = EXPANDED;
break;
358 case PANGO_STRETCH_EXTRA_EXPANDED: stretch = EXTRAEXPANDED;
break;
359 case PANGO_STRETCH_ULTRA_EXPANDED: stretch = ULTRAEXPANDED;
break;
361 switch (pango_font_description_get_style(pango_font)) {
362 case PANGO_STYLE_NORMAL: style = NORMAL_STYLE;
break;
363 case PANGO_STYLE_OBLIQUE: style = OBLIQUE;
break;
364 case PANGO_STYLE_ITALIC: style =
ITALIC;
break;
366 switch (pango_font_description_get_variant(pango_font)) {
367 case PANGO_VARIANT_NORMAL: variant = NORMAL_VARIANT;
break;
368 case PANGO_VARIANT_SMALL_CAPS: variant = SMALLCAPS;
break;
370 switch (pango_font_description_get_weight(pango_font)) {
371 case PANGO_WEIGHT_ULTRALIGHT: weight = ULTRALIGHT;
break;
372 case PANGO_WEIGHT_LIGHT: weight = LIGHT;
break;
373 case PANGO_WEIGHT_NORMAL: weight = NORMAL_WEIGHT;
break;
374 case PANGO_WEIGHT_SEMIBOLD: weight =
BOLD;
break;
375 case PANGO_WEIGHT_BOLD: weight =
BOLD;
break;
376 case PANGO_WEIGHT_ULTRABOLD: weight = ULTRABOLD;
break;
377 case PANGO_WEIGHT_HEAVY: weight = HEAVY;
break;
383 stretch = NORMAL_STRETCH;
388 style = NORMAL_STYLE;
389 variant = NORMAL_VARIANT;
394 weight = NORMAL_WEIGHT;
400 doc->osBody() << setFont(font, style, weight, variant, stretch) << setFontSize(span->
font->
size) << endl;
401 switch (span->
just) {
410 p.
x -= span->
size.
x / 2.0;
419 doc->osBody() << show(span->
str) << endl;
423 static void lasi_ellipse(
GVJ_t * job,
pointf * A,
int filled)
429 AA[1].
x = A[1].
x - A[0].
x;
430 AA[1].
y = A[1].
y - A[0].
y;
435 gvputs(job,
" ellipse_path fill\n");
438 ps_set_pen_style(job);
441 gvputs(job,
" ellipse_path stroke\n");
446 lasi_bezier(
GVJ_t * job,
pointf * A,
int n,
int arrow_at_start,
447 int arrow_at_end,
int filled)
456 for (j = 1; j < n; j += 3) {
458 gvputs(job,
" curveto\n");
460 gvputs(job,
"closepath fill\n");
463 ps_set_pen_style(job);
468 for (j = 1; j < n; j += 3) {
470 gvputs(job,
" curveto\n");
476 static void lasi_polygon(
GVJ_t * job,
pointf * A,
int n,
int filled)
485 for (j = 1; j < n; j++) {
489 gvputs(job,
"closepath fill\n");
492 ps_set_pen_style(job);
497 for (j = 1; j < n; j++) {
501 gvputs(job,
"closepath stroke\n");
505 static void lasi_polyline(
GVJ_t * job,
pointf * A,
int n)
510 ps_set_pen_style(job);
515 for (j = 1; j < n; j++) {
523 static void lasi_comment(
GVJ_t * job,
char *str)
530 static void lasi_library_shape(
GVJ_t * job,
char *name,
pointf * A,
int n,
int filled)
538 gvprintf(job,
" ] %d true %s\n", n, name);
541 ps_set_pen_style(job);
547 gvprintf(job,
" ] %d false %s\n", n, name);
611 {
FORMAT_PS,
"lasi", -5, &lasi_engine, &render_features_lasi},
#define GVDEVICE_DOES_PAGES
void gvprintpointflist(GVJ_t *job, pointf *p, int n)
gvplugin_installed_t gvrender_lasi_types[]
char * ps_string(char *ins, int chset)
#define GVRENDER_DOES_MAP_RECTANGLE
#define GVRENDER_DOES_TRANSFORM
int gvputs(GVJ_t *job, const char *s)
gvplugin_active_render_t render
#define GVDEVICE_DOES_LAYERS
void epsf_define(GVJ_t *job)
void cat_libfile(GVJ_t *job, const char **arglib, const char **stdlib)
CGRAPH_API char * agnameof(void *)
void gvprintpointf(GVJ_t *job, pointf p)
double yoffset_centerline
PostscriptAlias * postscript_alias
void(* errorfn)(const char *fmt,...)
#define GVRENDER_NO_WHITE_BG
void gvprintdouble(GVJ_t *job, double num)
#define GVRENDER_DOES_MAPS
size_t(* save_write_fn)(GVJ_t *job, const char *s, size_t len)
gvplugin_installed_t gvdevice_lasi_types[]
size_t(* write_fn)(GVJ_t *job, const char *s, size_t len)
void gvprintf(GVJ_t *job, const char *format,...)