summaryrefslogtreecommitdiff
path: root/src/cairo-type1-fallback.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-09-07 17:07:54 -0700
committerCarl Worth <cworth@cworth.org>2006-09-07 17:07:54 -0700
commit8364251db55c2451eca9b8162aa32ae00f433251 (patch)
tree6f957ef50c8715b4004db865468ca9cc76fe5fbd /src/cairo-type1-fallback.c
parent75ac7ee171d4bbe2b590e444bde9eb95138a2452 (diff)
cairo_type1_font_create: Fix missing NO_MEMORY check and cleanup style.
Diffstat (limited to 'src/cairo-type1-fallback.c')
-rw-r--r--src/cairo-type1-fallback.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index a07d10144..df59c2a4b 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -39,11 +39,14 @@
#include "cairo-output-stream-private.h"
typedef struct _cairo_type1_font {
+ int *widths;
+
cairo_scaled_font_subset_t *scaled_font_subset;
cairo_scaled_font_t *type1_scaled_font;
+ cairo_array_t contents;
+
double x_min, y_min, x_max, y_max;
- int *widths;
const char *data;
unsigned long header_size;
@@ -53,7 +56,6 @@ typedef struct _cairo_type1_font {
int bbox_max_chars;
cairo_output_stream_t *output;
- cairo_array_t contents;
unsigned short eexec_key;
cairo_bool_t hex_encode;
@@ -65,32 +67,42 @@ cairo_type1_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
cairo_type1_font_t **subset_return)
{
cairo_type1_font_t *font;
+ cairo_font_face_t *font_face;
cairo_matrix_t font_matrix;
cairo_matrix_t ctm;
- cairo_font_options_t *font_options;
+ cairo_font_options_t font_options;
font = calloc (1, sizeof (cairo_type1_font_t));
if (font == NULL)
return CAIRO_STATUS_NO_MEMORY;
+ font->widths = calloc (scaled_font_subset->num_glyphs,
+ sizeof (int));
+ if (font->widths == NULL) {
+ free (font);
+ return CAIRO_STATUS_NO_MEMORY;
+ }
+
+ font->scaled_font_subset = scaled_font_subset;
+
+ font_face = cairo_scaled_font_get_font_face (scaled_font_subset->scaled_font);
+
cairo_matrix_init_scale (&font_matrix, 1000, 1000);
cairo_matrix_init_identity (&ctm);
- font_options = cairo_font_options_create ();
- cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
- cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_OFF);
- font->type1_scaled_font = cairo_scaled_font_create (
- cairo_scaled_font_get_font_face (scaled_font_subset->scaled_font),
- &font_matrix,
- &ctm,
- font_options);
- cairo_font_options_destroy (font_options);
- font->scaled_font_subset = scaled_font_subset;
- font->widths = calloc (font->scaled_font_subset->num_glyphs,
- sizeof (int));
+ _cairo_font_options_init_default (&font_options);
+ cairo_font_options_set_hint_style (&font_options, CAIRO_HINT_STYLE_NONE);
+ cairo_font_options_set_hint_metrics (&font_options, CAIRO_HINT_METRICS_OFF);
+
+ font->type1_scaled_font = cairo_scaled_font_create (font_face,
+ &font_matrix,
+ &ctm,
+ &font_options);
_cairo_array_init (&font->contents, sizeof (unsigned char));
+
*subset_return = font;
+
return CAIRO_STATUS_SUCCESS;
}