New predicates to allow checking for cairo_ft derivates of generic font type.

Add explicit checks for cairo_ft derivatives of generic fonts rather than just blindly assuming that's what we get.
This commit is contained in:
Carl Worth 2005-07-13 11:01:25 +00:00
parent dda555de99
commit 6725cc9d7f
6 changed files with 57 additions and 0 deletions

View file

@ -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:

View file

@ -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. */

View file

@ -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,

View file

@ -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
*/

View file

@ -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;

View file

@ -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");