-#include "image.h"
+#include "imager.h"
#include <sys/types.h>
#include <sys/stat.h>
*/
int
-i_t1_bbox(int fontnum,float points,char *str,int len,int cords[6], int utf8,char const *flags) {
+i_t1_bbox(int fontnum,float points,const char *str,int len,int cords[6], int utf8,char const *flags) {
BBox bbox;
BBox gbbox;
int mod_flags = t1_get_flags(flags);
myfree(work);
}
else {
- bbox = T1_GetStringBBox(fontnum,str,len,0,mod_flags);
+ bbox = T1_GetStringBBox(fontnum,(char *)str,len,0,mod_flags);
}
gbbox = T1_GetFontBBox(fontnum);
- advance = T1_GetStringWidth(fontnum, str, len, 0, mod_flags);
+ advance = T1_GetStringWidth(fontnum, (char *)str, len, 0, mod_flags);
mm_log((1,"bbox: (%d,%d,%d,%d)\n",
(int)(bbox.llx*points/1000),
*/
undef_int
-i_t1_text(i_img *im,int xb,int yb,i_color *cl,int fontnum,float points,char* str,int len,int align, int utf8, char const *flags) {
+i_t1_text(i_img *im,int xb,int yb,const i_color *cl,int fontnum,float points,const char* str,int len,int align, int utf8, char const *flags) {
GLYPH *glyph;
int xsize,ysize,x,y,ch;
i_color val;
myfree(work);
}
else {
- glyph=T1_AASetString( fontnum, str, len, 0, mod_flags, points, NULL);
+ /* T1_AASetString() accepts a char * not a const char */
+ glyph=T1_AASetString( fontnum, (char *)str, len, 0, mod_flags, points, NULL);
}
if (glyph == NULL)
return 0;
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;
i_tt_render_all_glyphs( TT_Fonthandle *handle, int inst, TT_Raster_Map *bit,
TT_Raster_Map *small_bit, int cords[6],
char const* txt, int len, int smooth, int utf8 );
-static void i_tt_dump_raster_map2( i_img* im, TT_Raster_Map* bit, int xb, int yb, i_color *cl, int smooth );
+static void i_tt_dump_raster_map2( i_img* im, TT_Raster_Map* bit, int xb, int yb, const i_color *cl, int smooth );
static void i_tt_dump_raster_map_channel( i_img* im, TT_Raster_Map* bit, int xb, int yb, int channel, int smooth );
static int
i_tt_rasterize( TT_Fonthandle *handle, TT_Raster_Map *bit, int cords[6],
*/
TT_Fonthandle*
-i_tt_new(char *fontname) {
+i_tt_new(const char *fontname) {
TT_Error error;
TT_Fonthandle *handle;
unsigned short i,n;
/* 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 */
}
+
+ /* rows can be 0 for some glyphs, for example ' ' */
+ if (bit->rows && 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 );
}
static
void
-i_tt_dump_raster_map2( i_img* im, TT_Raster_Map* bit, int xb, int yb, i_color *cl, int smooth ) {
+i_tt_dump_raster_map2( i_img* im, TT_Raster_Map* bit, int xb, int yb, const i_color *cl, int smooth ) {
char *bmap;
i_color val;
int c, i, ch, x, y;
*/
undef_int
-i_tt_text( TT_Fonthandle *handle, i_img *im, int xb, int yb, i_color *cl, float points, char const* txt, int len, int smooth, int utf8, int align) {
+i_tt_text( TT_Fonthandle *handle, i_img *im, int xb, int yb, const i_color *cl, float points, char const* txt, int len, int smooth, int utf8, int align) {
int cords[BOUNDING_BOX_COUNT];
int ascent, st_offset, y;
TT_Raster_Map bit;
*/
undef_int
-i_tt_bbox( TT_Fonthandle *handle, float points,char *txt,int len,int cords[6], int utf8) {
+i_tt_bbox( TT_Fonthandle *handle, float points,const char *txt,int len,int cords[6], int utf8) {
int inst;
i_clear_error();