[cairo-commit] src/cairo-pdf-surface.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Sun Feb 4 05:18:03 PST 2007


 src/cairo-pdf-surface.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

New commits:
diff-tree 28e3a20d79c3390547d3e53435c06442ca8ac8a2 (from 05ff2c77da86c7be95924f9af4d3ad944afbbf66)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Feb 4 23:47:28 2007 +1030

    PDF: Fix TrueType font metrics

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 17c4108..18f79ca 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1872,6 +1872,8 @@ _cairo_pdf_surface_emit_type1_fallback_f
     return status;
 }
 
+#define GLYPH_TRUETYPE_TO_PDF  (1000.0/2048.0)
+
 static cairo_status_t
 _cairo_pdf_surface_emit_truetype_font_subset (cairo_pdf_surface_t		*surface,
 					      cairo_scaled_font_subset_t	*font_subset)
@@ -1923,7 +1925,7 @@ _cairo_pdf_surface_emit_truetype_font_su
 				 "   /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"
 				 "   /FontFile2 %u 0 R\r\n"
@@ -1931,12 +1933,13 @@ _cairo_pdf_surface_emit_truetype_font_su
 				 "endobj\r\n",
 				 descriptor.id,
 				 subset.base_font,
-				 subset.x_min,
-				 subset.y_min,
-				 subset.x_max,
-				 subset.y_max,
-				 subset.ascent,
-				 subset.descent,
+				 (long)(subset.x_min * GLYPH_TRUETYPE_TO_PDF),
+				 (long)(subset.y_min * GLYPH_TRUETYPE_TO_PDF),
+                                 (long)(subset.x_max * GLYPH_TRUETYPE_TO_PDF),
+				 (long)(subset.y_max * GLYPH_TRUETYPE_TO_PDF),
+				 (long)(subset.ascent * GLYPH_TRUETYPE_TO_PDF),
+				 (long)(subset.descent * GLYPH_TRUETYPE_TO_PDF),
+				 (long)(subset.y_max * GLYPH_TRUETYPE_TO_PDF),
 				 stream.id);
 
     encoding = _cairo_pdf_surface_new_object (surface);
@@ -1974,7 +1977,7 @@ _cairo_pdf_surface_emit_truetype_font_su
     for (i = 0; i < font_subset->num_glyphs; i++)
 	_cairo_output_stream_printf (surface->output,
 				     " %d",
-				     subset.widths[i]);
+				     (int)(subset.widths[i] * GLYPH_TRUETYPE_TO_PDF));
 
     _cairo_output_stream_printf (surface->output,
 				 " ]\r\n"


More information about the cairo-commit mailing list