[cairo-commit] 2 commits - src/cairo-type1-fallback.c src/cairo-win32-font.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Sat Dec 1 07:07:19 PST 2007
src/cairo-type1-fallback.c | 6 ++--
src/cairo-win32-font.c | 63 +++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 65 insertions(+), 4 deletions(-)
New commits:
commit b701b4263048c3641f77796b9ea7bdc60b9815f7
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Sun Dec 2 01:36:43 2007 +1030
win32: Implement _cairo_win32_scaled_font_init_glyph_surface()
This is required when using win32 bitmap fonts with PS/PDF surfaces.
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index 358d61c..9e46d23 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -101,6 +101,7 @@ typedef struct {
cairo_bool_t is_truetype;
cairo_bool_t glyph_indexing;
+ cairo_bool_t is_bitmap;
cairo_bool_t delete_scaled_hfont;
} cairo_win32_scaled_font_t;
@@ -113,6 +114,10 @@ _cairo_win32_scaled_font_init_glyph_metrics (cairo_win32_scaled_font_t *scaled_f
cairo_scaled_glyph_t *scaled_glyph);
static cairo_status_t
+_cairo_win32_scaled_font_init_glyph_surface (cairo_win32_scaled_font_t *scaled_font,
+ cairo_scaled_glyph_t *scaled_glyph);
+
+static cairo_status_t
_cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font,
cairo_scaled_glyph_t *scaled_glyph);
@@ -742,6 +747,11 @@ _cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
}
+ if (metrics.tmPitchAndFamily & TMPF_VECTOR)
+ scaled_font->is_bitmap = FALSE;
+ else
+ scaled_font->is_bitmap = TRUE;
+
scaled_font->is_truetype = (metrics.tmPitchAndFamily & TMPF_TRUETYPE) != 0;
scaled_font->glyph_indexing = scaled_font->is_truetype ||
(GetFontData (hdc, OPENTYPE_CFF_TAG, 0, NULL, 0) != GDI_ERROR);
@@ -1157,8 +1167,10 @@ _cairo_win32_scaled_font_glyph_init (void *abstract_font,
return status;
}
- if ((info & CAIRO_SCALED_GLYPH_INFO_SURFACE) != 0) {
- ASSERT_NOT_REACHED;
+ if (info & CAIRO_SCALED_GLYPH_INFO_SURFACE) {
+ status = _cairo_win32_scaled_font_init_glyph_surface (scaled_font, scaled_glyph);
+ if (status)
+ return status;
}
if ((info & CAIRO_SCALED_GLYPH_INFO_PATH) != 0) {
@@ -1330,6 +1342,50 @@ _cairo_win32_scaled_font_map_glyphs_to_unicode (void *abstract_font,
font_subset->to_unicode[i] = font_subset->glyphs[i];
}
+static cairo_status_t
+_cairo_win32_scaled_font_init_glyph_surface (cairo_win32_scaled_font_t *scaled_font,
+ cairo_scaled_glyph_t *scaled_glyph)
+{
+ cairo_status_t status = CAIRO_STATUS_SUCCESS;
+ cairo_glyph_t glyph;
+ cairo_win32_surface_t *surface;
+ cairo_t *cr;
+ cairo_surface_t *image;
+ int width, height;
+ int x1, y1, x2, y2;
+
+ x1 = _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.x);
+ y1 = _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.y);
+ x2 = _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.x);
+ y2 = _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.y);
+ width = x2 - x1;
+ height = y2 - y1;
+
+ surface = (cairo_win32_surface_t *)
+ cairo_win32_surface_create_with_dib (CAIRO_FORMAT_RGB24, width, height);
+
+ cr = cairo_create((cairo_surface_t *)surface);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+ cairo_destroy(cr);
+
+ glyph.index = _cairo_scaled_glyph_index (scaled_glyph);
+ glyph.x = -x1;
+ glyph.y = -y1;
+ status = _draw_glyphs_on_surface (surface, scaled_font, RGB(0,0,0),
+ 0, 0, &glyph, 1);
+ GdiFlush();
+
+ image = _compute_a8_mask (surface);
+ cairo_surface_set_device_offset ((cairo_surface_t *)image, -x1, -y1);
+ _cairo_scaled_glyph_set_surface (scaled_glyph,
+ &scaled_font->base,
+ (cairo_image_surface_t*)image);
+ cairo_surface_destroy (&surface->base);
+
+ return status;
+}
+
static void
_cairo_win32_transform_FIXED_to_fixed (cairo_matrix_t *matrix,
FIXED Fx, FIXED Fy,
@@ -1357,6 +1413,9 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
cairo_fixed_t x, y;
UINT glyph_index_option;
+ if (scaled_font->is_bitmap)
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
hdc = _get_global_font_dc ();
if (!hdc)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
commit 1441e165f2338bc6a8e2945baca77611ff417b2f
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Sun Dec 2 00:50:28 2007 +1030
Fix regression in Type1 Fallback
As a result of the changes to improve the status checking,
_cairo_type2_charstrings_init() was failing due to the failure
status returned when the font->output stream is destroyed.
This is because _cairo_type2_charstrings_init() does not
create an output stream.
Fix this by initializing font->output to NULL and only
destroy it if not NULL.
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index 626c7b5..3532692 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -110,6 +110,7 @@ cairo_type1_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
goto fail;
_cairo_array_init (&font->contents, sizeof (unsigned char));
+ font->output = NULL;
*subset_return = font;
@@ -709,12 +710,13 @@ cairo_type1_font_generate (cairo_type1_font_t *font, const char *name)
static cairo_status_t
cairo_type1_font_destroy (cairo_type1_font_t *font)
{
- cairo_status_t status;
+ cairo_status_t status = CAIRO_STATUS_SUCCESS;
free (font->widths);
cairo_scaled_font_destroy (font->type1_scaled_font);
_cairo_array_fini (&font->contents);
- status = _cairo_output_stream_destroy (font->output);
+ if (font->output)
+ status = _cairo_output_stream_destroy (font->output);
free (font);
return status;
More information about the cairo-commit
mailing list