static void t1_push_error(void);
+static int t1_active_fonts = 0;
+static int t1_initialized = 0;
+
/*
=item i_init_t1(t1log)
i_init_t1(int t1log) {
int init_flags = IGNORE_CONFIGFILE|IGNORE_FONTDATABASE;
mm_log((1,"init_t1()\n"));
+
+ if (t1_active_fonts) {
+ mm_log((1, "Cannot re-initialize T1 - active fonts\n"));
+ return 1;
+ }
+
+ if (t1_initialized) {
+ T1_CloseLib();
+ }
if (t1log)
init_flags |= LOGFILE;
}
T1_SetLogLevel(T1LOG_DEBUG);
i_t1_set_aa(1); /* Default Antialias value */
+
+ ++t1_initialized;
+
return(0);
}
void
i_close_t1(void) {
T1_CloseLib();
+ t1_initialized = 0;
}
if (T1_SetAfmFileName(font_id,afm)<0) mm_log((1,"i_t1_new: afm loading of '%s' failed.\n",afm));
}
+ ++t1_active_fonts;
+
return font_id;
}
int
i_t1_destroy(int font_id) {
mm_log((1,"i_t1_destroy(font_id %d)\n",font_id));
+
+ --t1_active_fonts;
+
return T1_DeleteFont(font_id);
}
static char *
t1_from_utf8(char const *in, int len, int *outlen) {
- char *out = mymalloc(len+1);
+ /* at this point len is from a perl SV, so can't approach MAXINT */
+ char *out = mymalloc(len+1); /* checked 5Nov05 tonyc */
char *p = out;
unsigned long c;
/* allocate memory for the structure */
- handle = mymalloc( sizeof(TT_Fonthandle) );
+ handle = mymalloc( sizeof(TT_Fonthandle) ); /* checked 5Nov05 tonyc */
/* load the typeface */
error = TT_Open_Face( engine, fontname, &handle->face );
bit->cols = ( bit->width + 7 ) / 8; /* convert to # of bytes */
bit->size = bit->rows * bit->cols; /* number of bytes in buffer */
}
+
+ if (bit->size / bit->rows != bit->cols) {
+ m_fatal(0, "Integer overflow calculating bitmap size (%d, %d)\n",
+ bit->width, bit->rows);
+ }
mm_log((1,"i_tt_init_raster_map: bit->width %d, bit->cols %d, bit->rows %d, bit->size %d)\n", bit->width, bit->cols, bit->rows, bit->size ));
- bit->bitmap = (void *) mymalloc( bit->size );
+ bit->bitmap = (void *) mymalloc( bit->size ); /* checked 6Nov05 tonyc */
if ( !bit->bitmap ) m_fatal(0,"Not enough memory to allocate bitmap (%d)!\n",bit->size );
}