index 1301e888aaa26fd120df0681680d7f273238b09f..fedde86a2020989542902721f35c67641d61e89f 100644 (file)
#include <libnr/n-art-bpath.h>
#include <glib/gmem.h>
+#include <glib/gstrfuncs.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtkframe.h>
#include <ft2build.h>
#include FT_FREETYPE_H
-#include <freetype/internal/ftobjs.h>
+#include FT_XFREE86_H
#include <pango/pangoft2.h>
#include <string>
#include <iostream>
#include <fstream>
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
+#include <cmath>
+
+/*
+using std::atof;
+using std::ceil;
+using std::fclose;
+using std::ferror;
+using std::fflush;
+using std::fgetc;
+using std::fprintf; --> this line will result 'std::libintl_fprintf' has not been declared
+using std::fputc;
+using std::fseek;
+using std::ifstream;
+using std::ios;
+using std::memset;
+using std::strchr;
+using std::strcmp;
+using std::strerror;
+using std::tmpfile;
+*/
using namespace std;
namespace Inkscape {
_bitmap(false)
{
//map font types
- _fontTypesMap["type1"] = FONT_TYPE1;
- _fontTypesMap["truetype"] = FONT_TRUETYPE;
+ _fontTypesMap["Type 1"] = FONT_TYPE1;
+ _fontTypesMap["TrueType"] = FONT_TRUETYPE;
//TODO: support other font types (cf. embed_font())
}
#endif
unsigned int ret = FALSE;
+ gchar const *destination = mod->get_param_string("destination");
/* Create dialog */
GtkTooltips *tt = gtk_tooltips_new();
g_object_ref((GObject *) tt);
gtk_object_sink((GtkObject *) tt);
- GtkWidget *dlg = gtk_dialog_new_with_buttons(_("Print Destination"),
+ GtkWidget *dlg = gtk_dialog_new_with_buttons(
+ destination ? _("Print Configuration") : _("Print Destination"),
// SP_DT_WIDGET(SP_ACTIVE_DESKTOP)->window,
NULL,
(GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
- GTK_STOCK_PRINT,
+ destination ? GTK_STOCK_GO_FORWARD : GTK_STOCK_PRINT,
GTK_RESPONSE_OK,
NULL);
GtkWidget *l = gtk_label_new(_("Resolution:"));
gtk_box_pack_end(GTK_BOX(hb), l, FALSE, FALSE, 0);
- /* Print destination frame */
- f = gtk_frame_new(_("Print destination"));
- gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 4);
- vb = gtk_vbox_new(FALSE, 4);
- gtk_container_add(GTK_CONTAINER(f), vb);
- gtk_container_set_border_width(GTK_CONTAINER(vb), 4);
-
- l = gtk_label_new(_("Printer name (as given by lpstat -p);\n"
- "leave empty to use the system default printer.\n"
- "Use '> filename' to print to file.\n"
+ GtkWidget *e = NULL;
+ /* if the destination isn't already set, we must prompt for it */
+ if (!destination) {
+ /* Print destination frame */
+ f = gtk_frame_new(_("Print destination"));
+ gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 4);
+ vb = gtk_vbox_new(FALSE, 4);
+ gtk_container_add(GTK_CONTAINER(f), vb);
+ gtk_container_set_border_width(GTK_CONTAINER(vb), 4);
+
+ l = gtk_label_new(_("Printer name (as given by lpstat -p);\n"
+ "leave empty to use the system default printer.\n"
+ "Use '> filename' to print to file.\n"
"Use '| prog arg...' to pipe to a program."));
- gtk_box_pack_start(GTK_BOX(vb), l, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vb), l, FALSE, FALSE, 0);
- GtkWidget *e = gtk_entry_new();
- if (1) {
- gchar const *val = mod->get_param_string("destination");
- gtk_entry_set_text(GTK_ENTRY(e), ( val != NULL
- ? val
+ e = gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(e), ( destination != NULL
+ ? destination
: "" ));
- }
- gtk_box_pack_start(GTK_BOX(vb), e, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vb), e, FALSE, FALSE, 0);
- // pressing enter in the destination field is the same as clicking Print:
- gtk_entry_set_activates_default(GTK_ENTRY(e), TRUE);
+ // pressing enter in the destination field is the same as clicking Print:
+ gtk_entry_set_activates_default(GTK_ENTRY(e), TRUE);
+ }
gtk_widget_show_all(vbox);
_bitmap = gtk_toggle_button_get_active((GtkToggleButton *) rb);
sstr = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
_dpi = (unsigned int) MAX((int)(atof(sstr)), 1);
- /* Arrgh, have to do something */
- fn = gtk_entry_get_text(GTK_ENTRY(e));
- /* skip leading whitespace, bug #1068483 */
- while (fn && *fn==' ') { fn++; }
- /* g_print("Printing to %s\n", fn); */
+ /* if the destination was prompted for, record the new value */
+ if (e) {
+ /* Arrgh, have to do something */
+ fn = gtk_entry_get_text(GTK_ENTRY(e));
+ /* skip leading whitespace, bug #1068483 */
+ while (fn && *fn==' ') { fn++; }
+ /* g_print("Printing to %s\n", fn); */
+
+ mod->set_param_string("destination", (gchar *)fn);
+ }
mod->set_param_bool("bitmap", _bitmap);
mod->set_param_string("resolution", (gchar *)sstr);
- mod->set_param_string("destination", (gchar *)fn);
ret = TRUE;
}
if (fn != NULL) {
if (*fn == '|') {
fn += 1;
- while (isspace(*fn)) fn += 1;
+ while (g_ascii_isspace(*fn)) fn += 1;
#ifndef WIN32
osp = popen(fn, "w");
#else
<< d.x0 << " "
<< (_height - d.y0) << " "
<< d.x1 << "\n";
- os << "%%DocumentMedia: plain "
- << (int) ceil(_height) << " "
- << (int) ceil(_width) << " "
- << "0 () ()\n";
+ if (!epsexport) {
+ os << "%%DocumentMedia: plain "
+ << (int) ceil(_height) << " "
+ << (int) ceil(_width) << " "
+ << "0 () ()\n";
+ }
} else {
os << "%%Orientation: Portrait\n";
os << "%%BoundingBox: " << (int) d.x0 << " "
<< d.y0 << " "
<< d.x1 << " "
<< d.y1 << "\n";
- os << "%%DocumentMedia: plain "
- << (int) ceil(_width) << " "
- << (int) ceil(_height) << " "
- << "0 () ()\n";
+ if (!epsexport) {
+ os << "%%DocumentMedia: plain "
+ << (int) ceil(_width) << " "
+ << (int) ceil(_height) << " "
+ << "0 () ()\n";
+ }
}
os << "%%EndComments\n";
bbox.x0, bbox.y0, bbox.x1, bbox.y1,
(guchar*)px, 4 * width, FALSE, FALSE);
memset(px, 0xff, 4 * width * 64);
- nr_arena_item_invoke_render(mod->root, &bbox, &pb, 0);
+ nr_arena_item_invoke_render(NULL, mod->root, &bbox, &pb, 0);
/* Blitter goes here */
NRMatrix imgt;
imgt.c[0] = (bbox.x1 - bbox.x0) / dots_per_pt;
{
while((c = fgetc(_stream))!=EOF) fputc(c, _begin_stream);
}
- fclose(_begin_stream);
+ fclose(_stream);
+ _stream = _begin_stream;
}
/* fixme: should really use pclose for popen'd streams */
fclose(_stream);
- _stream = 0;
+ _stream = NULL;
+
_latin1_encoded_fonts.clear();
g_tree_destroy(_fonts);
}
unsigned int
-PrintPS::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, float opacity)
+PrintPS::bind(Inkscape::Extension::Print */*mod*/, NRMatrix const *transform, float /*opacity*/)
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
}
unsigned int
-PrintPS::release(Inkscape::Extension::Print *mod)
+PrintPS::release(Inkscape::Extension::Print */*mod*/)
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
}
unsigned int
-PrintPS::comment(Inkscape::Extension::Print *mod, char const *comment)
+PrintPS::comment(Inkscape::Extension::Print */*mod*/, char const *comment)
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
void
PrintPS::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRRect const *pbox)
{
- g_return_if_fail( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_return_if_fail( style->fill.isColor()
+ || ( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) );
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
float rgb[3];
sp_color_get_rgb_floatv(&style->fill.value.color, rgb);
os << rgb[0] << " " << rgb[1] << " " << rgb[2] << " setrgbcolor\n";
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );
if (SP_IS_LINEARGRADIENT(SP_STYLE_FILL_SERVER(style))) {
@@ -781,8 +818,8 @@ PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix co
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
- if ( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ if ( style->fill.isColor()
+ || ( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) )
{
Inkscape::SVGOStringStream os;
@@ -793,11 +830,11 @@ PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix co
print_bpath(os, bpath->path);
- if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
+ if (style->fill.isColor()) {
os << "eofill\n";
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );
SPGradient const *g = SP_GRADIENT(SP_STYLE_FILL_SERVER(style));
os << "eoclip\n";
@@ -812,10 +849,10 @@ PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix co
}
}
} else {
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
os << "fill\n";
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );
SPGradient const *g = SP_GRADIENT(SP_STYLE_FILL_SERVER(style));
os << "clip\n";
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
- if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ if (style->stroke.isColor()) {
Inkscape::SVGOStringStream os;
print_stroke_style(os, style);
{
//check font type
FT_Face font_face = pango_ft2_font_get_face(font->pFont);
- const FT_String* font_type = FT_MODULE_CLASS(font_face->driver)->module_name;
+ const FT_String* font_type = FT_Get_X11_Font_Format(font_face);
g_return_val_if_fail (_fontTypesMap[font_type] == FONT_TYPE1, false);
//get font filename, stream to font file and size
FT_Stream font_stream = font_face->stream;
//Hinted at by a comment in libgnomeprint/fcpattern_to_gp_font_entry()
//Determining the font type in the "Pango way"
FT_Face font_face = pango_ft2_font_get_face(font->pFont);
- const FT_String* font_type = FT_MODULE_CLASS(font_face->driver)->module_name;
+ const FT_String* font_type = FT_Get_X11_Font_Format(font_face);
/**
- * Possible values of "font_type" variable, not supported (font types):
- * truetype, cff, t1cid, sfnt, bdf, pcf, pfr, winfonts (FNT/FON).
+ * Possible values of "font_type": Type 1, TrueType, etc.
+ * Embedding available only for Type 1 fonts so far.
*/
- //TODO: provide support for the font types above
+ //TODO: provide support for other font types (TrueType is a priority)
switch(_fontTypesMap[font_type])
{
case FONT_TYPE1:
@@ -1333,18 +1370,24 @@ PrintPS::text(Inkscape::Extension::Print *mod, char const *text, NR::Point p,
"definefont} def\n"; // create the new font and leave it on the stack, define the proc
_newlatin1font_proc_defined = true;
}
- os << "/" << fn << "-ISOLatin1 /" << fn << " newlatin1font\n";
+ if(strchr(fn, ' ') == NULL)
+ os << "/" << fn << "-ISOLatin1 /" << fn << " newlatin1font\n";
+ else
+ os << "(/" << fn << "-ISOLatin1) (/" << fn << ") newlatin1font\n";
_latin1_encoded_fonts.insert(fn);
} else
- os << "/" << fn << "-ISOLatin1 findfont\n";
+ if(strchr(fn, ' ') == NULL)
+ os << "/" << fn << "-ISOLatin1 findfont\n";
+ else
+ os << "(/" << fn << "-ISOLatin1) findfont\n";
}
os << style->font_size.computed << " scalefont\n";
os << "setfont\n";
//The commented line beneath causes Inkscape to crash under Linux but not under Windows
//g_free((void*) fn);
- if ( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ if ( style->fill.isColor()
+ || ( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) )
{
// set fill style
os << ") show\n";
}
- if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ if (style->stroke.isColor()) {
// set stroke style
print_stroke_style(os, style);