]> git.donarmstrong.com Git - xournal.git/commitdiff
fix x86_64 bug in PDF export code (#2897699)
authorauroux <auroux>
Sun, 15 Nov 2009 05:06:00 +0000 (05:06 +0000)
committerauroux <auroux>
Sun, 15 Nov 2009 05:06:00 +0000 (05:06 +0000)
ChangeLog
src/TODO
src/xo-print.c

index 85fce2adcd121008df3f986ddf3018cf33241e08..fcc818ea09b509efbbf9186994045c53acb13e82 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 This version:
   - win32 portability code (contributed by Dirk Gerrits)
+  - fix a bug in PDF export code on 64-bit systems (patch by Robert Buchholz)
 
 Version 0.4.5 (Oct 2, 2009):
   - bugfixes for GTK+ 2.16/2.17 issues with xinput events
index e58e73bb401b1b35e7b339f8b8d3920ce860e516..7368f33597ef6515f886e83a223d8fcd10b8f992 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -19,11 +19,13 @@ List of features to be implemented (not in any particular order)
 
 BUGS:
 ** lingering issues with synaptics touchpads? (#2872667)
    - add patch 0.4.5-fix-synaptics-v1.patch (fix ButtonDown events)
-     - set device to Absolute mode at startup? (GDK doesn't expose API,
-       cf XSetDeviceMode() in /usr/include/X11/extensions/XInput.h)
(DONE) - add patch 0.4.5-fix-synaptics-v1.patch (fix ButtonDown events)
+        - set device to Absolute mode at startup? (GDK doesn't expose API,
+          cf XSetDeviceMode() in /usr/include/X11/extensions/XInput.h)
 ** color picker into canvas doesn't work in GTK+ 2.16 (should disable
    xinput first?)
+** PDF export crashes in 64-bit due to wrong types (#2897699)
+ (DONE) patch by Robert Buchholz
 
 WIN32:
 - test further
@@ -46,6 +48,8 @@ PATCHES TO INCORPORATE:
    *** NEW VERSION: #2881919 (autosave for 0.4.5, w/ some changes)
    NB: last modif should be triggered by prepare_new_undo() and undo/redo?
 
+** insert images patch (Victor Saase) #2890925
+
 - PDF bg memory usage throttling / delete oldest pdf backgrounds
 - replace ttsubset by something more modern? (eg. from cairo ?)
 - auto-hide patch from ~/prog/src/xournal-autohide/ ?
@@ -60,6 +64,7 @@ PATCHES TO INCORPORATE:
 - new recognizer icon (andruk on patches tracker)
 - recognizer: if variable-width, associate average width
 - recognizer should snap to existing recognized geometric shapes
+- patch to find text in PDF (dmg = Daniel German, Nov 13 2009)
 
 - improve recognizer: two passes for polygons (low tolerance, then higher)
   to better detect elongated rectangles? (if low tolerance recognizer
index 6340ca3aedc9a539f6e4740921c99331e9ab16fd..8887984c028f388fef5ab34d4fda8b12531bf859 100644 (file)
@@ -761,7 +761,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 +840,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 +864,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 +881,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 +900,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 +938,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);
@@ -1258,7 +1260,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 ");
@@ -1276,7 +1278,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);