Package: libcairo2
Version: 1.2.4-4
Severity: normal
Tags: patch

Cairo sometimes creates pdf files that contain invalid fonts, like the
following:

<< /Type /Font
   /Subtype /TrueType
   /BaseFont /DejaVuSans
   /FirstChar 0
   /LastChar 256
   /FontDescriptor 171 0 R
   /Widths [ ...(255 integers)... ]
>>

This font contains 256 characters, but /LastChar is incorrectly set to
256 instead of 255. acroread complains about incorrect /Widths in such
fonts (but shows file anyway).

There are several places in source code where number of characters is
passed as parameter for /LastChar, attached patch fixes this.

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.20-rc3-me
Locale: LANG=uk_UA.UTF-8, LC_CTYPE=uk_UA.UTF-8 (charmap=UTF-8)

Versions of packages libcairo2 depends on:
ii  libc6                     2.3.6.ds1-9    GNU C Library: Shared libraries
ii  libfontconfig1            2.4.2-1        generic font configuration library
ii  libfreetype6              2.2.1-5        FreeType 2 font engine, shared lib
ii  libpng12-0                1.2.15~beta5-1 PNG library - runtime
ii  libx11-6                  2:1.0.3-4      X11 client-side library
ii  libxrender1               1:0.9.1-3      X Rendering Extension client libra
ii  zlib1g                    1:1.2.3-13     compression library - runtime

libcairo2 recommends no packages.

-- no debconf information
diff -urpN -U 10 libcairo-1.2.4/src/cairo-pdf-surface.c 
libcairo-1.2.4.fix/src/cairo-pdf-surface.c
--- libcairo-1.2.4/src/cairo-pdf-surface.c      2006-08-19 01:11:58.000000000 
+0200
+++ libcairo-1.2.4.fix/src/cairo-pdf-surface.c  2007-01-09 13:31:19.000000000 
+0100
@@ -1658,21 +1658,21 @@ _cairo_pdf_surface_emit_type1_font_subse
                                 "%d 0 obj\r\n"
                                 "<< /Type /Font\r\n"
                                 "   /Subtype /Type1\r\n"
                                 "   /BaseFont /%s\r\n"
                                 "   /FirstChar 0\r\n"
                                 "   /LastChar %d\r\n"
                                 "   /FontDescriptor %d 0 R\r\n"
                                 "   /Widths [",
                                 subset_resource.id,
                                 subset.base_font,
-                                font_subset->num_glyphs,
+                                font_subset->num_glyphs - 1,
                                 descriptor.id);
 
     for (i = 0; i < font_subset->num_glyphs; i++)
        _cairo_output_stream_printf (surface->output,
                                     " %d",
                                     subset.widths[i]);
 
     _cairo_output_stream_printf (surface->output,
                                 " ]\r\n"
                                 ">>\r\n"
@@ -1761,21 +1761,21 @@ _cairo_pdf_surface_emit_truetype_font_su
                                 "%d 0 obj\r\n"
                                 "<< /Type /Font\r\n"
                                 "   /Subtype /TrueType\r\n"
                                 "   /BaseFont /%s\r\n"
                                 "   /FirstChar 0\r\n"
                                 "   /LastChar %d\r\n"
                                 "   /FontDescriptor %d 0 R\r\n"
                                 "   /Widths [",
                                 subset_resource.id,
                                 subset.base_font,
-                                font_subset->num_glyphs,
+                                font_subset->num_glyphs - 1,
                                 descriptor.id);
 
     for (i = 0; i < font_subset->num_glyphs; i++)
        _cairo_output_stream_printf (surface->output,
                                     " %d",
                                     subset.widths[i]);
 
     _cairo_output_stream_printf (surface->output,
                                 " ]\r\n"
                                 ">>\r\n"
@@ -2138,21 +2138,21 @@ _cairo_pdf_surface_write_fonts (cairo_pd
                                     "%d 0 obj\r\n"
                                     "<< /Type /Font\r\n"
                                     "   /Subtype /TrueType\r\n"
                                     "   /BaseFont /%s\r\n"
                                     "   /FirstChar 0\r\n"
                                     "   /LastChar %d\r\n"
                                     "   /FontDescriptor %d 0 R\r\n"
                                     "   /Widths ",
                                     font->font_id,
                                     font->base_font,
-                                    font->num_glyphs,
+                                    font->num_glyphs - 1,
                                     descriptor.id);
 
        _cairo_output_stream_printf (surface->output,
                                     "[");
 
        for (j = 0; j < font->num_glyphs; j++)
            _cairo_output_stream_printf (surface->output,
                                         " %d",
                                         font->widths[j]);
 

Reply via email to