[cairo-commit] 2 commits - src/cairo-ps-surface.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Wed Dec 12 05:17:19 PST 2007
src/cairo-ps-surface.c | 65 +++++++++++++++++++++++++++++++++++++++----------
1 file changed, 52 insertions(+), 13 deletions(-)
New commits:
commit 9b3ce8b17ab8179131ae45a227d76241916f42e8
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Wed Dec 12 23:41:53 2007 +1030
PS: Use the correct bounding box in Type 3 fonts
Previously this was a fixed size.
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 41e791b..5065d67 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -569,7 +569,8 @@ _cairo_ps_surface_emit_truetype_font_subset (cairo_ps_surface_t *surface,
static cairo_int_status_t
_cairo_ps_surface_emit_outline_glyph_data (cairo_ps_surface_t *surface,
cairo_scaled_font_t *scaled_font,
- unsigned long glyph_index)
+ unsigned long glyph_index,
+ cairo_box_t *bbox)
{
cairo_scaled_glyph_t *scaled_glyph;
cairo_status_t status;
@@ -582,6 +583,7 @@ _cairo_ps_surface_emit_outline_glyph_data (cairo_ps_surface_t *surface,
if (status)
return status;
+ *bbox = scaled_glyph->bbox;
_cairo_output_stream_printf (surface->final_stream,
"0 0 %f %f %f %f setcachedevice\n",
_cairo_fixed_to_double (scaled_glyph->bbox.p1.x),
@@ -604,7 +606,8 @@ _cairo_ps_surface_emit_outline_glyph_data (cairo_ps_surface_t *surface,
static cairo_int_status_t
_cairo_ps_surface_emit_bitmap_glyph_data (cairo_ps_surface_t *surface,
cairo_scaled_font_t *scaled_font,
- unsigned long glyph_index)
+ unsigned long glyph_index,
+ cairo_box_t *bbox)
{
cairo_scaled_glyph_t *scaled_glyph;
cairo_status_t status;
@@ -621,6 +624,7 @@ _cairo_ps_surface_emit_bitmap_glyph_data (cairo_ps_surface_t *surface,
if (status)
return status;
+ *bbox = scaled_glyph->bbox;
x_advance = scaled_glyph->metrics.x_advance;
y_advance = scaled_glyph->metrics.y_advance;
cairo_matrix_transform_distance (&scaled_font->ctm, &x_advance, &y_advance);
@@ -684,7 +688,8 @@ static cairo_status_t
_cairo_ps_surface_emit_glyph (cairo_ps_surface_t *surface,
cairo_scaled_font_t *scaled_font,
unsigned long scaled_font_glyph_index,
- unsigned int subset_glyph_index)
+ unsigned int subset_glyph_index,
+ cairo_box_t *bbox)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
@@ -694,11 +699,13 @@ _cairo_ps_surface_emit_glyph (cairo_ps_surface_t *surface,
if (subset_glyph_index != 0) {
status = _cairo_ps_surface_emit_outline_glyph_data (surface,
scaled_font,
- scaled_font_glyph_index);
+ scaled_font_glyph_index,
+ bbox);
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
status = _cairo_ps_surface_emit_bitmap_glyph_data (surface,
scaled_font,
- scaled_font_glyph_index);
+ scaled_font_glyph_index,
+ bbox);
}
_cairo_output_stream_printf (surface->final_stream,
@@ -719,6 +726,8 @@ _cairo_ps_surface_emit_type3_font_subset (cairo_ps_surface_t *surface,
cairo_status_t status;
cairo_matrix_t matrix;
unsigned int i;
+ cairo_box_t font_bbox = {{0,0},{0,0}};
+ cairo_box_t bbox = {{0,0},{0,0}};
#if DEBUG_PS
_cairo_output_stream_printf (surface->final_stream,
@@ -733,7 +742,6 @@ _cairo_ps_surface_emit_type3_font_subset (cairo_ps_surface_t *surface,
"8 dict begin\n"
"/FontType 3 def\n"
"/FontMatrix [%f %f %f %f 0 0] def\n"
- "/FontBBox [0 0 0 0] def\n"
"/Encoding 256 array def\n"
"0 1 255 { Encoding exch /.notdef put } for\n",
matrix.xx,
@@ -758,13 +766,31 @@ _cairo_ps_surface_emit_type3_font_subset (cairo_ps_surface_t *surface,
for (i = 0; i < font_subset->num_glyphs; i++) {
status = _cairo_ps_surface_emit_glyph (surface,
font_subset->scaled_font,
- font_subset->glyphs[i], i);
+ font_subset->glyphs[i], i,
+ &bbox);
if (status)
return status;
+
+ if (i == 0) {
+ font_bbox.p1.x = bbox.p1.x;
+ font_bbox.p1.y = bbox.p1.y;
+ font_bbox.p2.x = bbox.p2.x;
+ font_bbox.p2.y = bbox.p2.y;
+ } else {
+ if (bbox.p1.x < font_bbox.p1.x)
+ font_bbox.p1.x = bbox.p1.x;
+ if (bbox.p1.y < font_bbox.p1.y)
+ font_bbox.p1.y = bbox.p1.y;
+ if (bbox.p2.x > font_bbox.p2.x)
+ font_bbox.p2.x = bbox.p2.x;
+ if (bbox.p2.y > font_bbox.p2.y)
+ font_bbox.p2.y = bbox.p2.y;
+ }
}
_cairo_output_stream_printf (surface->final_stream,
"] def\n"
+ "/FontBBox [%f %f %f %f] def\n"
"/BuildChar {\n"
" exch /Glyphs get\n"
" exch get exec\n"
@@ -772,6 +798,10 @@ _cairo_ps_surface_emit_type3_font_subset (cairo_ps_surface_t *surface,
"currentdict\n"
"end\n"
"/CairoFont-%d-%d exch definefont pop\n",
+ _cairo_fixed_to_double (font_bbox.p1.x),
+ _cairo_fixed_to_double (font_bbox.p1.y),
+ _cairo_fixed_to_double (font_bbox.p2.x),
+ _cairo_fixed_to_double (font_bbox.p2.y),
font_subset->font_id,
font_subset->subset_id);
commit afdd53d35f53cfe3440c38531c112a586d3d7486
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Wed Dec 12 23:35:56 2007 +1030
PS: Return the status for emit_image and gradients
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 8dac043..41e791b 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2011,9 +2011,12 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
transparency == CAIRO_IMAGE_HAS_ALPHA ||
(transparency == CAIRO_IMAGE_HAS_BILEVEL_ALPHA &&
surface->ps_level == CAIRO_PS_LEVEL_2)) {
- _cairo_ps_surface_flatten_image_transparency (surface,
- image,
- &opaque_image);
+ status = _cairo_ps_surface_flatten_image_transparency (surface,
+ image,
+ &opaque_image);
+ if (status)
+ return status;
+
use_mask = FALSE;
} else if (transparency == CAIRO_IMAGE_IS_OPAQUE) {
opaque_image = image;
@@ -2227,7 +2230,7 @@ _cairo_ps_surface_emit_image_surface (cairo_ps_surface_t *surface,
if (status)
return status;
- _cairo_ps_surface_emit_image (surface, image, "CairoPattern", op);
+ status = _cairo_ps_surface_emit_image (surface, image, "CairoPattern", op);
if (status)
goto fail;
@@ -2680,11 +2683,17 @@ _cairo_ps_surface_emit_pattern (cairo_ps_surface_t *surface,
break;
case CAIRO_PATTERN_TYPE_LINEAR:
- _cairo_ps_surface_emit_linear_pattern (surface, (cairo_linear_pattern_t *) pattern);
+ status = _cairo_ps_surface_emit_linear_pattern (surface,
+ (cairo_linear_pattern_t *) pattern);
+ if (status)
+ return status;
break;
case CAIRO_PATTERN_TYPE_RADIAL:
- _cairo_ps_surface_emit_radial_pattern (surface, (cairo_radial_pattern_t *) pattern);
+ status = _cairo_ps_surface_emit_radial_pattern (surface,
+ (cairo_radial_pattern_t *) pattern);
+ if (status)
+ return status;
break;
}
More information about the cairo-commit
mailing list