summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--src/cairo-font-subset.c4
-rw-r--r--src/cairo-ft-font.c12
-rw-r--r--src/cairo-ft-private.h6
-rw-r--r--src/cairo-pdf-surface.c8
-rw-r--r--src/cairo-ps-surface.c12
6 files changed, 57 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index dee6f5b6..2def55a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2005-07-13 Carl Worth <cworth@cworth.org>
+
+ * src/cairo-ft-private.h:
+ * src/cairo-ft-font.c: (_cairo_unscaled_font_is_ft),
+ (_cairo_scaled_font_is_ft): New predicates to allow checking for
+ cairo_ft derivates of generic font type.
+
+ * src/cairo-ps-surface.c: (_cairo_ps_surface_get_font),
+ (_cairo_ps_surface_show_glyphs), (_ps_output_show_glyphs):
+ * src/cairo-pdf-surface.c: (_cairo_pdf_document_get_font),
+ (_cairo_pdf_surface_show_glyphs):
+ * src/cairo-font-subset.c: (_cairo_font_subset_create):
+ Add explicit checks for cairo_ft derivatives of generic fonts
+ rather than just blindly assuming that's what we get.
+
2005-07-12 Carl Worth <cworth@cworth.org>
* src/cairo-hash-private.h:
diff --git a/src/cairo-font-subset.c b/src/cairo-font-subset.c
index 2fac7f3e..e3a2784c 100644
--- a/src/cairo-font-subset.c
+++ b/src/cairo-font-subset.c
@@ -139,6 +139,10 @@ _cairo_font_subset_create (cairo_unscaled_font_t *unscaled_font)
unsigned long size;
int i, j;
+ /* XXX: Need to fix this to work with a general cairo_unscaled_font_t. */
+ if (! _cairo_unscaled_font_is_ft (unscaled_font))
+ return NULL;
+
face = _cairo_ft_unscaled_font_lock_face (unscaled_font);
/* We currently only support freetype truetype fonts. */
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index f1d418f7..99776764 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -129,6 +129,12 @@ _ft_unscaled_font_create_from_face (FT_Face face)
return unscaled;
}
+cairo_bool_t
+_cairo_unscaled_font_is_ft (cairo_unscaled_font_t *unscaled_font)
+{
+ return unscaled_font->backend == &cairo_ft_unscaled_font_backend;
+}
+
static ft_unscaled_font_t *
_ft_unscaled_font_create_from_filename (const char *filename,
int id)
@@ -1018,6 +1024,12 @@ _ft_scaled_font_create (ft_unscaled_font_t *unscaled,
return (cairo_scaled_font_t *)f;
}
+cairo_bool_t
+_cairo_scaled_font_is_ft (cairo_scaled_font_t *scaled_font)
+{
+ return scaled_font->backend == &cairo_ft_scaled_font_backend;
+}
+
static cairo_status_t
_cairo_ft_scaled_font_create (const char *family,
cairo_font_slant_t slant,
diff --git a/src/cairo-ft-private.h b/src/cairo-ft-private.h
index 494d8369..e92048b2 100644
--- a/src/cairo-ft-private.h
+++ b/src/cairo-ft-private.h
@@ -44,6 +44,12 @@
CAIRO_BEGIN_DECLS
+cairo_bool_t
+_cairo_unscaled_font_is_ft (cairo_unscaled_font_t *unscaled_font);
+
+cairo_bool_t
+_cairo_scaled_font_is_ft (cairo_scaled_font_t *scaled_font);
+
/* These functions are needed by the PDF backend, which needs to keep track of the
* the different fonts-on-disk used by a document, so it can embed them
*/
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index bfb77217..f578fd62 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1233,6 +1233,10 @@ _cairo_pdf_document_get_font (cairo_pdf_document_t *document,
cairo_font_subset_t *pdf_font;
unsigned int num_fonts, i;
+ /* XXX: Need to fix this to work with a general cairo_scaled_font_t. */
+ if (! _cairo_scaled_font_is_ft (scaled_font))
+ return NULL;
+
/* XXX Why is this an ft specific function? */
unscaled_font = _cairo_ft_scaled_font_get_unscaled_font (scaled_font);
@@ -1279,6 +1283,10 @@ _cairo_pdf_surface_show_glyphs (cairo_scaled_font_t *scaled_font,
cairo_font_subset_t *pdf_font;
int i, index;
+ /* XXX: Need to fix this to work with a general cairo_scaled_font_t. */
+ if (! _cairo_scaled_font_is_ft (scaled_font))
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
pdf_font = _cairo_pdf_document_get_font (document, scaled_font);
if (pdf_font == NULL)
return CAIRO_STATUS_NO_MEMORY;
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 6684c6e6..14046932 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -368,6 +368,10 @@ _cairo_ps_surface_get_font (cairo_ps_surface_t *surface,
cairo_font_subset_t *subset;
unsigned int num_fonts, i;
+ /* XXX: Need to fix this to work with a general cairo_scaled_font_t. */
+ if (! _cairo_scaled_font_is_ft (scaled_font))
+ return NULL;
+
/* XXX Why is this an ft specific function? */
unscaled_font = _cairo_ft_scaled_font_get_unscaled_font (scaled_font);
@@ -409,6 +413,10 @@ _cairo_ps_surface_show_glyphs (cairo_scaled_font_t *scaled_font,
cairo_font_subset_t *subset;
int i;
+ /* XXX: Need to fix this to work with a general cairo_scaled_font_t. */
+ if (! _cairo_scaled_font_is_ft (scaled_font))
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
/* Collect font subset info as we go. */
subset = _cairo_ps_surface_get_font (surface, scaled_font);
if (subset == NULL)
@@ -1039,6 +1047,10 @@ _ps_output_show_glyphs (cairo_scaled_font_t *scaled_font,
cairo_font_subset_t *subset;
int i, subset_index;
+ /* XXX: Need to fix this to work with a general cairo_scaled_font_t. */
+ if (! _cairo_scaled_font_is_ft (scaled_font))
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
_cairo_output_stream_printf (stream,
"%% _ps_output_show_glyphs\n");