Index: extension/internal/cairo-render-context.cpp =================================================================== --- extension/internal/cairo-render-context.cpp (revision 17949) +++ extension/internal/cairo-render-context.cpp (working copy) @@ -50,6 +50,7 @@ #include "sp-pattern.h" #include "sp-mask.h" #include "sp-clippath.h" +#include "FontFactory.h" // USE_PANGO_WIN32 #include @@ -73,6 +74,10 @@ #ifdef CAIRO_HAS_FT_FONT #include #endif +#ifdef CAIRO_HAS_WIN32_FONT +#include +#include +#endif #include @@ -1421,16 +1426,33 @@ { // create a cairo_font_face from PangoFont double size = style->font_size.computed; + cairo_font_face_t *font_face = NULL; + + FcPattern *fc_pattern = NULL; + +#ifdef USE_PANGO_WIN32 +# ifdef CAIRO_HAS_WIN32_FONT + LOGFONTA *lfa = pango_win32_font_logfont(font); + LOGFONTW lfw; + + ZeroMemory(&lfw, sizeof(LOGFONTW)); + memcpy(&lfw, lfa, sizeof(LOGFONTA)); + MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, lfa->lfFaceName, LF_FACESIZE, lfw.lfFaceName, LF_FACESIZE); + + font_face = cairo_win32_font_face_create_for_logfontw(&lfw); +# endif +#else +# ifdef CAIRO_HAS_FT_FONT PangoFcFont *fc_font = PANGO_FC_FONT(font); - FcPattern *fc_pattern = fc_font->font_pattern; - + fc_pattern = fc_font->font_pattern; + font_face = cairo_ft_font_face_create_for_pattern(fc_pattern); +# endif +#endif + cairo_save(_cr); - -#ifdef CAIRO_HAS_FT_FONT - cairo_font_face_t *font_face = cairo_ft_font_face_create_for_pattern(fc_pattern); cairo_set_font_face(_cr, font_face); - if (FcPatternGetDouble(fc_pattern, FC_PIXEL_SIZE, 0, &size) != FcResultMatch) + if (fc_pattern && FcPatternGetDouble(fc_pattern, FC_PIXEL_SIZE, 0, &size) != FcResultMatch) size = 12.0; // set the given font matrix @@ -1471,14 +1493,9 @@ cairo_restore(_cr); - cairo_font_face_destroy(font_face); -#else - (void)size; - (void)fc_pattern; + if (font_face) + cairo_font_face_destroy(font_face); - cairo_restore(_cr); -#endif - return true; } Index: ui/dialog/print.cpp =================================================================== --- ui/dialog/print.cpp (revision 17949) +++ ui/dialog/print.cpp (working copy) @@ -28,6 +28,47 @@ #include "svg/svg-color.h" +#ifdef WIN32 +#include +#include +#include +#include + +static cairo_surface_t * +_cairo_win32_printing_surface_create (HDC hdc) +{ + int x, y, x_dpi, y_dpi, x_off, y_off, depth; + XFORM xform; + cairo_surface_t *surface; + + x = GetDeviceCaps (hdc, HORZRES); + y = GetDeviceCaps (hdc, VERTRES); + + x_dpi = GetDeviceCaps (hdc, LOGPIXELSX); + y_dpi = GetDeviceCaps (hdc, LOGPIXELSY); + + x_off = GetDeviceCaps (hdc, PHYSICALOFFSETX); + y_off = GetDeviceCaps (hdc, PHYSICALOFFSETY); + + depth = GetDeviceCaps(hdc, BITSPIXEL); + + SetGraphicsMode (hdc, GM_ADVANCED); + xform.eM11 = x_dpi/72.0; + xform.eM12 = 0; + xform.eM21 = 0; + xform.eM22 = y_dpi/72.0; + xform.eDx = -x_off; + xform.eDy = -y_off; + SetWorldTransform (hdc, &xform); + + surface = cairo_win32_printing_surface_create (hdc); + //cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi); + + return surface; +} +#endif + + static void draw_page (GtkPrintOperation *operation, GtkPrintContext *context, @@ -90,7 +131,20 @@ // Render as vectors Inkscape::Extension::Internal::CairoRenderer renderer; Inkscape::Extension::Internal::CairoRenderContext *ctx = renderer.createContext(); - bool ret = ctx->setSurfaceTarget (cairo_get_target (gtk_print_context_get_cairo_context (context)), true); + + // ctx->setPSLevel(CAIRO_PS_LEVEL_3); + ctx->setTextToPath(false); + ctx->setFilterToBitmap(true); + ctx->setBitmapResolution(72); + + cairo_t *cr = gtk_print_context_get_cairo_context (context); + cairo_surface_t *surface = cairo_get_target(cr); +#ifdef WIN32 + HDC dc = cairo_win32_surface_get_dc (surface); + surface = _cairo_win32_printing_surface_create (dc); +#endif + + bool ret = ctx->setSurfaceTarget (surface, true); if (ret) { ret = renderer.setupDocument (ctx, junk->_doc); if (ret) { @@ -149,13 +203,17 @@ gtk_print_operation_set_job_name (_printop, title.c_str()); // set up paper size to match the document size + gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS); GtkPageSetup *page_setup = gtk_page_setup_new(); gdouble doc_width = sp_document_width(_doc) * PT_PER_PX; gdouble doc_height = sp_document_height(_doc) * PT_PER_PX; GtkPaperSize *paper_size = gtk_paper_size_new_custom("custom", "custom", doc_width, doc_height, GTK_UNIT_POINTS); gtk_page_setup_set_paper_size (page_setup, paper_size); +#ifndef WIN32 gtk_print_operation_set_default_page_setup (_printop, page_setup); +#endif + gtk_print_operation_set_use_full_page (_printop, TRUE); // set up signals _workaround._doc = _doc;