33 #include <glib/gi18n-lib.h>
36 # define WIFEXITED(x) ((x) != 3)
37 # define WEXITSTATUS(x) (x)
39 # include <sys/wait.h>
94 filename = g_filename_from_uri (uri, NULL, error);
107 g_set_error_literal (error,
110 _(
"DVI document has incorrect format"));
123 g_free (dvi_document->
uri);
124 dvi_document->
uri = g_strdup (uri);
160 static cairo_surface_t *
164 cairo_surface_t *surface;
165 cairo_surface_t *rotated_surface;
167 gdouble xscale, yscale;
168 gint required_width, required_height;
169 gint proposed_width, proposed_height;
170 gint xmargin = 0, ymargin = 0;
187 &required_width, &required_height);
191 if (required_width >= proposed_width)
192 xmargin = (required_width - proposed_width) / 2;
193 if (required_height >= proposed_height)
194 ymargin = (required_height - proposed_height) / 2;
207 cairo_surface_destroy (surface);
209 return rotated_surface;
225 g_free (dvi_document->
params);
233 g_free (dvi_document->
uri);
235 G_OBJECT_CLASS (dvi_document_parent_class)->finalize (
object);
247 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
291 g_string_append_printf (dvi_document->
exporter_opts,
"%d,", (rc->page->index) + 1);
304 command_line = g_strdup_printf (
"dvipdfm %s -o %s \"%s\"",
309 success = g_spawn_command_line_sync (command_line,
315 g_free (command_line);
317 if (success ==
FALSE) {
318 g_warning (
"Error: %s", err->message);
319 }
else if (!WIFEXITED(exit_stat) || WEXITSTATUS(exit_stat) != EXIT_SUCCESS){
320 g_warning (
"Error: dvipdfm does not end normally or exit with a failure status.");
346 #define RGB2ULONG(r,g,b) ((0xFF<<24)|(r<<16)|(g<<8)|(b))
349 hsb2rgb (
float h,
float s,
float v, guchar *red, guchar *green, guchar *blue)
351 float f, p, q, t, r, g, b;
360 else if ((i > 6) || (i < 0))
364 q = v * (1 - (s * f));
365 t = v * (1 - (s * (1 - f)));
393 *red = (guchar)floor(r * 255.0);
394 *green = (guchar)floor(g * 255.0);
395 *blue = (guchar)floor(b * 255.0);
405 gchar *p = (gchar *)ptr;
408 for (i = 0; i < n_color; i++) {
409 while (isspace (*p)) p++;
410 color[i] = g_ascii_strtod (p, NULL);
411 while (!isspace (*p) && *p !=
'\0') p++;
420 if (strncmp (arg,
"pop", 3) == 0) {
422 }
else if (strncmp (arg,
"push", 4) == 0) {
424 const char *tmp = arg + 4;
426 while (isspace (*tmp)) tmp++;
428 if (!strncmp (
"rgb", tmp, 3)) {
430 guchar red, green, blue;
435 green = 255 * rgb[1];
439 }
else if (!strncmp (
"hsb", tmp, 4)) {
441 guchar red, green, blue;
445 if (
hsb2rgb (hsb[0], hsb[1], hsb[2], &red, &green, &blue))
447 }
else if (!strncmp (
"cmyk", tmp, 4)) {
450 guchar red, green, blue;
454 r = 1.0 - cmyk[0] - cmyk[3];
457 g = 1.0 - cmyk[1] - cmyk[3];
460 b = 1.0 - cmyk[2] - cmyk[3];
465 green = g * 255 + 0.5;
466 blue = b * 255 + 0.5;
469 }
else if (!strncmp (
"gray ", tmp, 5)) {
475 rgb = gray * 255 + 0.5;
481 if (gdk_color_parse (tmp, &color)) {
482 guchar red, green, blue;
484 red = color.red * 255 / 65535.;
485 green = color.green * 255 / 65535.;
486 blue = color.blue * 255 / 65535.;
511 dvi_document->
spec = NULL;
513 dvi_document->
params->
bg = 0xffffffff;
514 dvi_document->
params->
fg = 0xff000000;