diff -u -r cairo-1.4.10.orig/src/cairo-pdf-surface.c cairo-1.4.10/src/cairo-pdf-surface.c --- cairo-1.4.10.orig/src/cairo-pdf-surface.c 2007-05-19 05:45:40.000000000 +0930 +++ cairo-1.4.10/src/cairo-pdf-surface.c 2007-07-04 20:12:15.475176742 +0930 @@ -2122,6 +2122,27 @@ return stream; } +static void +set_font_tag (unsigned int font_id, unsigned int subset_id, char *tag) +{ + int i; + unsigned int r; + + for (i = 3; i >= 0; i--) { + r = font_id % 26; + font_id /= 26; + tag[i] = 'A' + r; + } + + for (i = 1; i >= 0; i--) { + r = subset_id % 26; + font_id /= 26; + tag[i+4] = 'A' + r; + } + + tag[6] = 0; +} + static cairo_status_t _cairo_pdf_surface_emit_cff_font (cairo_pdf_surface_t *surface, cairo_scaled_font_subset_t *font_subset, @@ -2134,6 +2155,9 @@ char *compressed; unsigned int i; cairo_status_t status; + char tag[10]; + + set_font_tag (font_subset->font_id, font_subset->subset_id, tag); compressed = compress_dup (subset->data, subset->data_length, &compressed_length); if (compressed == NULL) @@ -2162,19 +2186,20 @@ _cairo_output_stream_printf (surface->output, "%d 0 obj\r\n" "<< /Type /FontDescriptor\r\n" - " /FontName /%s\r\n" + " /FontName /%s+%s\r\n" " /Flags 4\r\n" " /FontBBox [ %ld %ld %ld %ld ]\r\n" " /ItalicAngle 0\r\n" " /Ascent %ld\r\n" " /Descent %ld\r\n" - " /CapHeight 500\r\n" + " /CapHeight %ld\r\n" " /StemV 80\r\n" - " /StemH 80\r\n" + " /XHeight %ld\r\n" " /FontFile3 %u 0 R\r\n" ">>\r\n" "endobj\r\n", descriptor.id, + tag, subset->base_font, subset->x_min, subset->y_min, @@ -2182,6 +2207,8 @@ subset->y_max, subset->ascent, subset->descent, + subset->ascent, + subset->ascent, stream.id); cidfont_dict = _cairo_pdf_surface_new_object (surface); @@ -2189,7 +2216,7 @@ "%d 0 obj\r\n" "<< /Type /Font\r\n" " /Subtype /CIDFontType0\r\n" - " /BaseFont /%s\r\n" + " /BaseFont /%s+%s\r\n" " /CIDSystemInfo\r\n" " << /Registry (Adobe)\r\n" " /Ordering (Identity)\r\n" @@ -2198,6 +2225,7 @@ " /FontDescriptor %d 0 R\r\n" " /W [0 [", cidfont_dict.id, + tag, subset->base_font, descriptor.id); @@ -2216,10 +2244,11 @@ "%d 0 obj\r\n" "<< /Type /Font\r\n" " /Subtype /Type0\r\n" - " /BaseFont /%s\r\n" + " /BaseFont /%s+%s\r\n" " /Encoding /Identity-H\r\n" " /DescendantFonts [ %d 0 R]\r\n", subset_resource.id, + tag, subset->base_font, cidfont_dict.id); @@ -2292,7 +2321,9 @@ unsigned long length, compressed_length; char *compressed; unsigned int i; + char tag[10]; + set_font_tag (font_subset->font_id, font_subset->subset_id, tag); /* We ignore the zero-trailer and set Length3 to 0. */ length = subset->header_length + subset->data_length; @@ -2327,7 +2358,7 @@ _cairo_output_stream_printf (surface->output, "%d 0 obj\r\n" "<< /Type /FontDescriptor\r\n" - " /FontName /%s\r\n" + " /FontName /%s+%s\r\n" " /Flags 4\r\n" " /FontBBox [ %ld %ld %ld %ld ]\r\n" " /ItalicAngle 0\r\n" @@ -2340,6 +2371,7 @@ ">>\r\n" "endobj\r\n", descriptor.id, + tag, subset->base_font, subset->x_min, subset->y_min, @@ -2354,12 +2386,13 @@ "%d 0 obj\r\n" "<< /Type /Font\r\n" " /Subtype /Type1\r\n" - " /BaseFont /%s\r\n" + " /BaseFont /%s+%s\r\n" " /FirstChar 0\r\n" " /LastChar %d\r\n" " /FontDescriptor %d 0 R\r\n" " /Widths [", subset_resource.id, + tag, subset->base_font, font_subset->num_glyphs - 1, descriptor.id); @@ -2443,6 +2476,9 @@ unsigned long compressed_length; char *compressed; unsigned int i; + char tag[10]; + + set_font_tag (font_subset->font_id, font_subset->subset_id, tag); status = _cairo_truetype_subset_init (&subset, font_subset); if (status) @@ -2479,7 +2515,7 @@ _cairo_output_stream_printf (surface->output, "%d 0 obj\r\n" "<< /Type /FontDescriptor\r\n" - " /FontName /%s\r\n" + " /FontName /%s+%s\r\n" " /Flags 4\r\n" " /FontBBox [ %ld %ld %ld %ld ]\r\n" " /ItalicAngle 0\r\n" @@ -2487,11 +2523,12 @@ " /Descent %ld\r\n" " /CapHeight %ld\r\n" " /StemV 80\r\n" - " /StemH 80\r\n" + " /XHeight %ld\r\n" " /FontFile2 %u 0 R\r\n" ">>\r\n" "endobj\r\n", descriptor.id, + tag, subset.base_font, (long)(subset.x_min*PDF_UNITS_PER_EM), (long)(subset.y_min*PDF_UNITS_PER_EM), @@ -2499,7 +2536,8 @@ (long)(subset.y_max*PDF_UNITS_PER_EM), (long)(subset.ascent*PDF_UNITS_PER_EM), (long)(subset.descent*PDF_UNITS_PER_EM), - (long)(subset.y_max*PDF_UNITS_PER_EM), + (long)(subset.ascent*PDF_UNITS_PER_EM), + (long)(subset.ascent*PDF_UNITS_PER_EM), stream.id); cidfont_dict = _cairo_pdf_surface_new_object (surface); @@ -2507,7 +2545,7 @@ "%d 0 obj\r\n" "<< /Type /Font\r\n" " /Subtype /CIDFontType2\r\n" - " /BaseFont /%s\r\n" + " /BaseFont /%s+%s\r\n" " /CIDSystemInfo\r\n" " << /Registry (Adobe)\r\n" " /Ordering (Identity)\r\n" @@ -2516,6 +2554,7 @@ " /FontDescriptor %d 0 R\r\n" " /W [0 [", cidfont_dict.id, + tag, subset.base_font, descriptor.id); @@ -2534,10 +2573,11 @@ "%d 0 obj\r\n" "<< /Type /Font\r\n" " /Subtype /Type0\r\n" - " /BaseFont /%s\r\n" + " /BaseFont /%s+%s\r\n" " /Encoding /Identity-H\r\n" " /DescendantFonts [ %d 0 R]\r\n", subset_resource.id, + tag, subset.base_font, cidfont_dict.id);