static void print_pango_layout (GnomePrintContext *gpc, PangoLayout *layout) { PangoLayoutIter *iter; gnome_print_gsave (gpc); current_point_to_origin (gpc); iter = pango_layout_get_iter (layout); do { PangoRectangle logical_rect; PangoLayoutLine *line; int baseline; line = pango_layout_iter_get_line (iter); pango_layout_iter_get_line_extents (iter, NULL, &logical_rect); baseline = pango_layout_iter_get_baseline (iter); moveto (gpc, logical_rect.x, - baseline); print_pango_layout_line (gpc, line); } while (pango_layout_iter_next_line (iter)); pango_layout_iter_free (iter); gnome_print_grestore (gpc); }
/** * gnome_print_pango_layout_print: * @gpc: a #GnomePrintContext * @pl: the #PangoLayout to print * * Draws the text in @pl into the specified #GnomePrintContext. The * text is drawn in the current color unless that has been overridden * by attributes set on the layout and the glyphs are positioned so * that the left edge of the baseline is at the point (0, 0). This function * is obsolete; use gnome_print_pango_layout() instead. **/ void gnome_print_pango_layout_print (GnomePrintContext *gpc, PangoLayout* pl) { /* For compatibility with old code we allow users to use * this to print PangoLayout's from contexts that we * didn't create ourself. The spacing may be very bad, * because of hinting differences, but no worse than * before. */ g_return_if_fail (GNOME_IS_PRINT_CONTEXT (gpc)); g_return_if_fail (PANGO_IS_LAYOUT (pl)); gnome_print_gsave (gpc); gnome_print_moveto (gpc, 0, 0); print_pango_layout (gpc, pl); gnome_print_grestore (gpc); }
static int gnome_print_multipage_showpage (GnomePrintContext *pc) { GnomePrintMultipage *mp; gint ret; mp = GNOME_PRINT_MULTIPAGE (pc); ret = gnome_print_grestore (mp->subpc); g_return_val_if_fail (ret == GNOME_PRINT_OK, ret); mp->subpage = mp->subpage->next; if (mp->subpage == NULL) { /* Finished global page, start from the * beginning and show it */ mp->subpage = mp->affines; ret = gnome_print_showpage (mp->subpc); g_return_val_if_fail (ret == GNOME_PRINT_OK, ret); } return GNOME_PRINT_OK; }
static gint gpm_render (GnomePrintContext *dest, const guchar *data, gint pos, gint len, gboolean pageops) { const guchar *end; data = data + pos; end = data + len; while (data < end){ gint32 opcode, i; guchar *cval; gint32 ival; gdouble dval; ArtBpath *bpath; data = decode_int (data, &opcode); switch ((GnomeMetaType) opcode) { case GNOME_META_BEGINPAGE: data = gpm_decode_string (data, &cval); if (pageops) gnome_print_beginpage (dest, cval); g_free (cval); break; case GNOME_META_SHOWPAGE: if (pageops) gnome_print_showpage (dest); break; case GNOME_META_GSAVE: gnome_print_gsave (dest); break; case GNOME_META_GRESTORE: gnome_print_grestore (dest); break; case GNOME_META_CLIP: data = gpm_decode_bpath (data, &bpath); data = decode_int (data, &ival); gnome_print_clip_bpath_rule (dest, bpath, ival); g_free (bpath); break; case GNOME_META_FILL: data = gpm_decode_bpath (data, &bpath); data = decode_int (data, &ival); gnome_print_fill_bpath_rule (dest, bpath, ival); g_free (bpath); break; case GNOME_META_STROKE: data = gpm_decode_bpath (data, &bpath); gnome_print_stroke_bpath (dest, bpath); g_free (bpath); break; case GNOME_META_IMAGE: { gdouble affine[6]; gint32 width, height, channels; guchar *buf; data = decode_double (data, &affine[0]); data = decode_double (data, &affine[1]); data = decode_double (data, &affine[2]); data = decode_double (data, &affine[3]); data = decode_double (data, &affine[4]); data = decode_double (data, &affine[5]); data = decode_int (data, &height); data = decode_int (data, &width); data = decode_int (data, &channels); buf = g_new (guchar, height * width * channels); memcpy (buf, data, height * width * channels); data += height * width * channels; gnome_print_image_transform (dest, affine, buf, width, height, channels * width, channels); g_free (buf); break; } case GNOME_META_GLYPHLIST: { GnomeGlyphList *gl; gdouble affine[6]; gint32 len, code, ival, i; gdouble dval; data = decode_double (data, &affine[0]); data = decode_double (data, &affine[1]); data = decode_double (data, &affine[2]); data = decode_double (data, &affine[3]); data = decode_double (data, &affine[4]); data = decode_double (data, &affine[5]); gl = gnome_glyphlist_new (); data = decode_int (data, &len); if (len > 0) { gl->glyphs = g_new (int, len); gl->g_length = len; gl->g_size = len; for (i = 0; i < len; i++) { data = decode_int (data, &ival); gl->glyphs[i] = ival; } } data = decode_int (data, &len); if (len > 0) { gl->rules = g_new (GGLRule, len); gl->r_length = len; gl->r_size = len; for (i = 0; i < len; i++) { data = decode_int (data, &code); gl->rules[i].code = code; switch (code) { case GGL_POSITION: case GGL_ADVANCE: case GGL_COLOR: data = decode_int (data, &ival); gl->rules[i].value.ival = ival; break; case GGL_MOVETOX: case GGL_MOVETOY: case GGL_RMOVETOX: case GGL_RMOVETOY: case GGL_LETTERSPACE: case GGL_KERNING: data = decode_double (data, &dval); gl->rules[i].value.dval = dval; break; case GGL_FONT: { GnomeFont *font; guchar *name; data = decode_double (data, &dval); data = gpm_decode_string (data, &name); font = gnome_font_find (name, dval); if (font == NULL) g_warning ("Cannot find font: %s\n", name); g_free (name); gl->rules[i].value.font = font; break; } default: break; } } } gnome_print_glyphlist_transform (dest, affine, gl); gnome_glyphlist_unref (gl); break; } break; case GNOME_META_COLOR: { gdouble r, g, b, a; data = decode_double (data, &r); data = decode_double (data, &g); data = decode_double (data, &b); gnome_print_setrgbcolor (dest, r, g, b); data = decode_double (data, &a); gnome_print_setopacity (dest, a); break; } case GNOME_META_LINE: data = decode_double (data, &dval); gnome_print_setlinewidth (dest, dval); data = decode_double (data, &dval); gnome_print_setmiterlimit (dest, dval); data = decode_int (data, &ival); gnome_print_setlinejoin (dest, ival); data = decode_int (data, &ival); gnome_print_setlinecap (dest, ival); break; case GNOME_META_DASH: { int n; double *values, offset; data = decode_int (data, &n); values = g_new (double, n); for (i = 0; i < n; i++) { data = decode_double (data, &values [i]); } data = decode_double (data, &offset); gnome_print_setdash (dest, n, values, offset); g_free (values); break; } default: g_warning ("Serious print meta data corruption %d", opcode); break; } }
static int gnome_print_multipage_grestore (GnomePrintContext *pc) { GnomePrintMultipage *multipage = GNOME_PRINT_MULTIPAGE(pc); return gnome_print_grestore (multipage->subpc); }
static void print_pango_layout_line (GnomePrintContext *gpc, PangoLayoutLine *line) { GSList *tmp_list = line->runs; PangoRectangle overall_rect; PangoRectangle logical_rect; PangoRectangle ink_rect; gint x_off = 0; gnome_print_gsave (gpc); current_point_to_origin (gpc); pango_layout_line_get_extents (line, NULL, &overall_rect); while (tmp_list) { ItemProperties properties; PangoLayoutRun *run = tmp_list->data; tmp_list = tmp_list->next; get_item_properties (run->item, &properties); if (properties.shape_logical_rect) { x_off += properties.shape_logical_rect->width; continue; } gnome_print_gsave (gpc); translate (gpc, x_off, properties.rise); gnome_print_moveto (gpc, 0, 0); if (properties.uline == PANGO_UNDERLINE_NONE && !properties.strikethrough) pango_glyph_string_extents (run->glyphs, run->item->analysis.font, NULL, &logical_rect); else pango_glyph_string_extents (run->glyphs, run->item->analysis.font, &ink_rect, &logical_rect); if (properties.bg_color) { gnome_print_gsave (gpc); gnome_print_setrgbcolor (gpc, (gdouble) properties.bg_color->red / 0xFFFF, (gdouble) properties.bg_color->green / 0xFFFF, (gdouble) properties.bg_color->blue / 0xFFFF); rect_filled (gpc, logical_rect.x, - overall_rect.y - overall_rect.height, logical_rect.width, overall_rect.height); gnome_print_grestore (gpc); } if (properties.fg_color) { gnome_print_setrgbcolor (gpc, (gdouble) properties.fg_color->red / 0xFFFF, (gdouble) properties.fg_color->green / 0xFFFF, (gdouble) properties.fg_color->blue / 0xFFFF); } gnome_print_pango_glyph_string (gpc, run->item->analysis.font, run->glyphs); if (properties.uline != PANGO_UNDERLINE_NONE || properties.strikethrough) { PangoFontMetrics *metrics = pango_font_get_metrics (run->item->analysis.font, run->item->analysis.language); if (properties.uline != PANGO_UNDERLINE_NONE) draw_underline (gpc, metrics, properties.uline, ink_rect.x, ink_rect.width, ink_rect.y + ink_rect.height); if (properties.strikethrough) draw_strikethrough (gpc, metrics, ink_rect.x, ink_rect.width); pango_font_metrics_unref (metrics); } gnome_print_grestore (gpc); x_off += logical_rect.width; } gnome_print_grestore (gpc); }
void DrawPrint( GnomePrintContext *gpc ) { int bl_width = 32; int bl_height = 32; int seq_size = 32; int the_width = RUNG_WIDTH*bl_width; int the_height = RUNG_HEIGHT*bl_height; int iCurrentLanguage = SectionArray[ InfosGene->CurrentSection ].Language; GdkPixmap *pixmap_for_print; #ifdef SEQUENTIAL_SUPPORT if ( iCurrentLanguage==SECTION_IN_SEQUENTIAL ) { the_width = SEQ_PAGE_WIDTH*seq_size; the_height = SEQ_PAGE_HEIGHT*seq_size; } #endif pixmap_for_print = gdk_pixmap_new( drawing_area->window/*drawable*/, the_width, the_height, -1/*depth*/ ); if ( pixmap_for_print ) { char TheEnd = FALSE; char NewPage = TRUE; int SizePageOffset = 800; int ScanRung = InfosGene->FirstRung; int PageNumber = 1; do { char Buffer[ LGT_LABEL+LGT_COMMENT+20 ]; GdkPixbuf *pixbuf_for_print; if ( NewPage==TRUE ) { gnome_print_beginpage( gpc, (guchar *)"1" ); NewPage = FALSE; SizePageOffset = 800; sprintf(Buffer, "ClassicLadder" RELEASE_VER_STRING ". Section:%s - Page:%d", SectionArray[ InfosGene->CurrentSection ].Name, PageNumber ); gnome_print_moveto( gpc, 50, 20 ); gnome_print_show( gpc, (guchar *)Buffer ); } gdk_draw_rectangle (pixmap_for_print, drawing_area->style->white_gc, TRUE, 0, 0, the_width, the_height); if ( iCurrentLanguage==SECTION_IN_LADDER ) DrawRung( pixmap_for_print, &RungArray[ ScanRung ], 0/*PosiY*/, bl_width, bl_height, DRAW_FOR_PRINT ); #ifdef SEQUENTIAL_SUPPORT if ( iCurrentLanguage==SECTION_IN_SEQUENTIAL ) { DrawSequentialPage( pixmap_for_print, SectionArray[ InfosGene->CurrentSection ].SequentialPage, DRAW_FOR_PRINT ); TheEnd = TRUE; } #endif pixbuf_for_print = gdk_pixbuf_get_from_drawable( NULL /*GdkPixbuf *dest*/, pixmap_for_print, NULL /*cmap*/, 0 /*src_x*/, 0 /*src_y*/, 0 /*dest_x*/, 0 /*dest_y*/, the_width, the_height); if ( pixbuf_for_print ) { guchar *raw_image; gint rowstride; if ( iCurrentLanguage==SECTION_IN_LADDER ) { char BuffFormat[10] = "%s (%s)"; if ( RungArray[ ScanRung ].Comment[0]=='\0' ) strcpy( BuffFormat, "%s %s" ); sprintf( Buffer, BuffFormat, RungArray[ ScanRung ].Label, RungArray[ ScanRung ].Comment ); gnome_print_moveto( gpc, 50, SizePageOffset ); SizePageOffset = SizePageOffset-20; gnome_print_show( gpc, (guchar *)Buffer ); } raw_image = gdk_pixbuf_get_pixels( pixbuf_for_print ); rowstride = gdk_pixbuf_get_rowstride( pixbuf_for_print ); gnome_print_gsave( gpc ); gnome_print_translate( gpc, 20, SizePageOffset-the_height+15 ); gnome_print_scale( gpc, the_width, the_height ); gnome_print_rgbimage( gpc, raw_image, the_width, the_height, rowstride); gnome_print_grestore( gpc ); SizePageOffset = SizePageOffset-the_height-20; gdk_pixbuf_unref( pixbuf_for_print ); if ( iCurrentLanguage==SECTION_IN_LADDER ) { if ( ScanRung!=InfosGene->LastRung ) ScanRung = RungArray[ ScanRung ].NextRung; else TheEnd = TRUE; } if ( SizePageOffset<200 || TheEnd ) { NewPage = TRUE; PageNumber++; gnome_print_showpage ( gpc ); } } else { printf( "Failed to create pixbuf_for_print\n" ); } } while( !TheEnd ); gdk_pixmap_unref( pixmap_for_print ); } else { printf( "Failed to create pixmap_for_print\n" ); } }