X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fxo-print.c;h=2cfc18ecd46dac68ac5b1581e504732e82a6d16c;hb=1858c4feaa24e40cea4b1b5ea39a60fb6670f33b;hp=62e0dce0dc6ffb4f7384b5ed2b0d72ff96afb769;hpb=72a310c8265a0d1e3e95fabb2987f70cfecbf525;p=xournal.git diff --git a/src/xo-print.c b/src/xo-print.c index 62e0dce..2cfc18e 100644 --- a/src/xo-print.c +++ b/src/xo-print.c @@ -1,3 +1,18 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifdef HAVE_CONFIG_H # include #endif @@ -728,7 +743,7 @@ int pdf_draw_bitmap_background(struct Page *pg, GString *str, width = (int) (PDFTOPPM_PRINTING_DPI * pgwidth/72.0); height = (int) (PDFTOPPM_PRINTING_DPI * pgheight/72.0); pix = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height); - poppler_page_render_to_pixbuf( + wrapper_poppler_page_render_to_pixbuf( pdfpage, 0, 0, width, height, PDFTOPPM_PRINTING_DPI/72.0, 0, pix); g_object_unref(pdfpage); } @@ -761,7 +776,7 @@ int pdf_draw_bitmap_background(struct Page *pg, GString *str, make_xref(xref, xref->last+1, pdfbuf->len); g_string_append_printf(pdfbuf, - "%d 0 obj\n<< /Length %d /Filter /FlateDecode /Type /Xobject " + "%d 0 obj\n<< /Length %zu /Filter /FlateDecode /Type /Xobject " "/Subtype /Image /Width %d /Height %d /ColorSpace /DeviceRGB " "/BitsPerComponent 8 >> stream\n", xref->last, zpix->len, width, height); @@ -840,8 +855,10 @@ void embed_pdffont(GString *pdfbuf, struct XrefTable *xref, struct PdfFont *font gboolean fallback, is_binary; guchar encoding[256]; gushort glyphs[256]; - int i, j, num, len1, len2; - gsize len; + int i, j, num; + guint32 len1, len2; + guint32 tt_len; + gsize t1_len; TrueTypeFont *ttfnt; char *seg1, *seg2; char *fontdata, *p; @@ -862,14 +879,14 @@ void embed_pdffont(GString *pdfbuf, struct XrefTable *xref, struct PdfFont *font } font->num_glyphs_used = num-1; if (OpenTTFont(font->filename, 0, &ttfnt) == SF_OK) { - if (CreateTTFromTTGlyphs_tomemory(ttfnt, (guint8**)&fontdata, &len, glyphs, encoding, num, + if (CreateTTFromTTGlyphs_tomemory(ttfnt, (guint8**)&fontdata, &tt_len, glyphs, encoding, num, 0, NULL, TTCF_AutoName | TTCF_IncludeOS2) == SF_OK) { make_xref(xref, xref->last+1, pdfbuf->len); nobj_fontprog = xref->last; g_string_append_printf(pdfbuf, - "%d 0 obj\n<< /Length %d /Length1 %d >> stream\n", - nobj_fontprog, (int)len, (int)len); - g_string_append_len(pdfbuf, fontdata, len); + "%d 0 obj\n<< /Length %u /Length1 %u >> stream\n", + nobj_fontprog, tt_len, tt_len); + g_string_append_len(pdfbuf, fontdata, tt_len); g_string_append(pdfbuf, "endstream\nendobj\n"); g_free(fontdata); } @@ -879,7 +896,7 @@ void embed_pdffont(GString *pdfbuf, struct XrefTable *xref, struct PdfFont *font else fallback = TRUE; } else { // embed the font file: Type1 case - if (g_file_get_contents(font->filename, &fontdata, &len, NULL) && len>=8) { + if (g_file_get_contents(font->filename, &fontdata, &t1_len, NULL) && t1_len>=8) { if (fontdata[0]==(char)0x80 && fontdata[1]==(char)0x01) { is_binary = TRUE; len1 = pfb_get_length((unsigned char *)fontdata+2); @@ -898,7 +915,7 @@ void embed_pdffont(GString *pdfbuf, struct XrefTable *xref, struct PdfFont *font if (*p=='\n' || *p=='\r') p++; if (*p=='\n' || *p=='\r') p++; len1 = p-fontdata; - p = g_strrstr_len(fontdata, len, T1_SEGMENT_3_END); + p = g_strrstr_len(fontdata, t1_len, T1_SEGMENT_3_END); if (p==NULL) fallback = TRUE; else { // rewind 512 zeros @@ -936,7 +953,7 @@ void embed_pdffont(GString *pdfbuf, struct XrefTable *xref, struct PdfFont *font make_xref(xref, xref->last+1, pdfbuf->len); nobj_fontprog = xref->last; g_string_append_printf(pdfbuf, - "%d 0 obj\n<< /Length %d /Length1 %d /Length2 %d /Length3 0 >> stream\n", + "%d 0 obj\n<< /Length %u /Length1 %u /Length2 %u /Length3 0 >> stream\n", nobj_fontprog, len1+len2, len1, len2); g_string_append_len(pdfbuf, seg1, len1); g_string_append_len(pdfbuf, seg2, len2); @@ -1082,7 +1099,8 @@ void pdf_draw_page(struct Page *pg, GString *str, gboolean *use_hiliter, old_text_rgba = item->brush.color_rgba & ~0xff; fontmap = pango_ft2_font_map_new(); pango_ft2_font_map_set_resolution(PANGO_FT2_FONT_MAP (fontmap), 72, 72); - context = pango_font_map_create_context(fontmap); + context = pango_context_new(); + pango_context_set_font_map(context, fontmap); layout = pango_layout_new(context); g_object_unref(fontmap); g_object_unref(context); @@ -1190,7 +1208,7 @@ gboolean print_to_pdf(char *filename) struct PdfFont *font; char *tmpbuf; - f = fopen(filename, "w"); + f = fopen(filename, "wb"); if (f == NULL) return FALSE; setlocale(LC_NUMERIC, "C"); annot = FALSE; @@ -1257,7 +1275,7 @@ gboolean print_to_pdf(char *filename) tmpstr = make_pdfprefix(pdfinfo.pages+(pg->bg->file_page_seq-1), pg->width, pg->height); g_string_append_printf(pdfbuf, - "%d 0 obj\n<< /Length %d >> stream\n%s\nendstream\nendobj\n", + "%d 0 obj\n<< /Length %zu >> stream\n%s\nendstream\nendobj\n", n_obj_prefix, tmpstr->len, tmpstr->str); g_string_free(tmpstr, TRUE); g_string_prepend(pgstrm, "Q Q Q "); @@ -1275,7 +1293,7 @@ gboolean print_to_pdf(char *filename) make_xref(&xref, xref.last+1, pdfbuf->len); g_string_append_printf(pdfbuf, - "%d 0 obj\n<< /Length %d /Filter /FlateDecode>> stream\n", + "%d 0 obj\n<< /Length %zu /Filter /FlateDecode>> stream\n", xref.last, zpgstrm->len); g_string_append_len(pdfbuf, zpgstrm->str, zpgstrm->len); g_string_free(zpgstrm, TRUE);